@p4code/cli 0.9.12 → 0.9.13

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 (270) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/{binCli-D9zhTalS.mjs → binCli-D22yxtxv.mjs} +273 -36
  3. package/dist/client/.vite/manifest.json +2046 -2046
  4. package/dist/client/assets/{2NI2N5EU-DOvURDwM.js → 2NI2N5EU-DBKJSvEQ.js} +2 -2
  5. package/dist/client/assets/{4UO7MD6I-CArKQR6u.js → 4UO7MD6I-1JuY3zN7.js} +2 -2
  6. package/dist/client/assets/{5B3SVYGG-D3yJKYTq.js → 5B3SVYGG-CwgmePuE.js} +2 -2
  7. package/dist/client/assets/{5GK6JWQ2-C7D6qJvm.js → 5GK6JWQ2-D9VJsozU.js} +2 -2
  8. package/dist/client/assets/{5N7A7DKN-DDTV444t.js → 5N7A7DKN-CFgZoUw5.js} +2 -2
  9. package/dist/client/assets/{5OC2THR4-CYaAiBA5.js → 5OC2THR4-Cx6keXWX.js} +2 -2
  10. package/dist/client/assets/{5S6HY5KT-jYzQX9YI.js → 5S6HY5KT-Ce1reKKv.js} +2 -2
  11. package/dist/client/assets/{6IMQ5BUJ-CZSZgyOb.js → 6IMQ5BUJ-D7X0q9kf.js} +2 -2
  12. package/dist/client/assets/{6OLKWJ4F-D_TpeHsd.js → 6OLKWJ4F-YLfMA9aH.js} +2 -2
  13. package/dist/client/assets/{74OO7NKP-VJq-BY7c.js → 74OO7NKP-Wm5pZPTC.js} +2 -2
  14. package/dist/client/assets/{75O6YZUN-BCik3Y9V.js → 75O6YZUN-D2He6_fp.js} +2 -2
  15. package/dist/client/assets/{77XECAW3-Ce_-nZaY.js → 77XECAW3-CV_JLSeU.js} +2 -2
  16. package/dist/client/assets/{ABYRPUBD-C1hL61qL.js → ABYRPUBD-D0xOVN1A.js} +2 -2
  17. package/dist/client/assets/AlertDialogRoot-DaczVYX9.js +2 -0
  18. package/dist/client/assets/{AnimatedHeight-DEeywxgS.js → AnimatedHeight-yuTG4G03.js} +2 -2
  19. package/dist/client/assets/{AuthSurfaceShell-835o12nS.js → AuthSurfaceShell-CCBOJP5G.js} +2 -2
  20. package/dist/client/assets/{BB2UYUI2-DlIE2g50.js → BB2UYUI2-BdXGRPif.js} +2 -2
  21. package/dist/client/assets/{BUM34MOA-D9NQPxww.js → BUM34MOA-isqGnSvm.js} +2 -2
  22. package/dist/client/assets/{CEQABKGZ-BsiY6pPC.js → CEQABKGZ-DE0PWXRq.js} +2 -2
  23. package/dist/client/assets/{CXAC5362-t7YfF0UQ.js → CXAC5362-0Zr5tv4C.js} +2 -2
  24. package/dist/client/assets/{ChatGptUsageButton-C3xHekTe.js → ChatGptUsageButton-w6RkBCUH.js} +2 -2
  25. package/dist/client/assets/{ChatMarkdown-Cw9bEYxG.js → ChatMarkdown-CFUfXlYp.js} +5 -5
  26. package/dist/client/assets/{CheckboxIndicator-XdXpYxXy.js → CheckboxIndicator-lkbFKbE7.js} +2 -2
  27. package/dist/client/assets/{ClippedText-C-unQqBz.js → ClippedText-Bf8FSQkX.js} +2 -2
  28. package/dist/client/assets/{CodexSetupSection.logic-Bl5OcEqH.js → CodexSetupSection.logic-SHExnMKR.js} +2 -2
  29. package/dist/client/assets/{ComboboxClear-CBRGIQSm.js → ComboboxClear-B0HJXjbz.js} +2 -2
  30. package/dist/client/assets/{ComboboxGroupLabel-DVAwRoGV.js → ComboboxGroupLabel-CMc5xUrd.js} +2 -2
  31. package/dist/client/assets/{CommandBlock-D6NTupaO.js → CommandBlock-CluJmhVo.js} +2 -2
  32. package/dist/client/assets/{ComposerPromptEditor-BqLNVkse.js → ComposerPromptEditor-DR1WsmjD.js} +4 -4
  33. package/dist/client/assets/{CompositeRoot-DBS-Yo_S.js → CompositeRoot-BMHKb-nN.js} +2 -2
  34. package/dist/client/assets/{ConnectAgentSurface-TBgGDnVI.js → ConnectAgentSurface-CNWdh9ck.js} +2 -2
  35. package/dist/client/assets/{ConnectionStatusDot-CR_qWdCU.js → ConnectionStatusDot-CpmZ8NE5.js} +2 -2
  36. package/dist/client/assets/{DRLTVNUE-DkTzG_pM.js → DRLTVNUE-Dttc5MrD.js} +2 -2
  37. package/dist/client/assets/{DYY6UVD2-BBRUtn6A.js → DYY6UVD2-DTrZAR1D.js} +2 -2
  38. package/dist/client/assets/{DevicePanel-BS7y97f_.js → DevicePanel-CRFuAv_j.js} +2 -2
  39. package/dist/client/assets/{DeviceSetup-TIKLCkls.js → DeviceSetup-DRzepax4.js} +2 -2
  40. package/dist/client/assets/{DialogTitle-DzoEjZ6h.js → DialogTitle-pLX9Mw1n.js} +2 -2
  41. package/dist/client/assets/{DiffCommentAnnotation-y1CrEDvy.js → DiffCommentAnnotation-6V9nI3Cm.js} +2 -2
  42. package/dist/client/assets/{DiffFileTree-BM7RDTEn.js → DiffFileTree-CBEjDul5.js} +2 -2
  43. package/dist/client/assets/{DiffPanel-CAK_DAYa.js → DiffPanel-CM5Rvb_z.js} +2 -2
  44. package/dist/client/assets/{DiffWorkerPoolProvider-D2t5zRbN.js → DiffWorkerPoolProvider-f4-YQsHo.js} +2 -2
  45. package/dist/client/assets/{EmbeddedDesign-_id3IQO6.js → EmbeddedDesign-DSEjf0KK.js} +2 -2
  46. package/dist/client/assets/{EnvironmentMachineIcon-oObSi9GI.js → EnvironmentMachineIcon-B6wAZat7.js} +2 -2
  47. package/dist/client/assets/{ExpandableText-BLwIQ2BJ.js → ExpandableText-Cjat32hh.js} +2 -2
  48. package/dist/client/assets/{FNOVOB4O-B469NSHv.js → FNOVOB4O-LisHSqAM.js} +2 -2
  49. package/dist/client/assets/{FieldControl-Btl-j-6W.js → FieldControl-DwBVFJAI.js} +2 -2
  50. package/dist/client/assets/{FileDiff-CGLKzg3V.js → FileDiff-Bj9kBLN2.js} +2 -2
  51. package/dist/client/assets/{FilePreviewPanel-DJ-LkCJ7.js → FilePreviewPanel-z6NirC2y.js} +2 -2
  52. package/dist/client/assets/{FoldedSettingsSection-DPTJODig.js → FoldedSettingsSection-DIlgxayr.js} +2 -2
  53. package/dist/client/assets/{FormContext-Be16jmaZ.js → FormContext-DcnLkh-4.js} +2 -2
  54. package/dist/client/assets/{HDGCDEEZ-BUMQl9WF.js → HDGCDEEZ-Bn1jLSys.js} +2 -2
  55. package/dist/client/assets/{HSJLKHB7-C08sJAK2.js → HSJLKHB7-CHpiqxlA.js} +2 -2
  56. package/dist/client/assets/{Icons-2l7Ym4KO.js → Icons-Be1TL1sN.js} +2 -2
  57. package/dist/client/assets/Input-BZ1XdBC0.js +2 -0
  58. package/dist/client/assets/JZOYTAAL-BZEjBuKj.js +1 -0
  59. package/dist/client/assets/{K3MD6TGW-D4RWgVJJ.js → K3MD6TGW-D5oCFPkP.js} +2 -2
  60. package/dist/client/assets/{K7RP3OMA-B8UDebPA.js → K7RP3OMA-ZIPW--CU.js} +2 -2
  61. package/dist/client/assets/{KeybindingsSettings.logic-CCfOv-KZ.js → KeybindingsSettings.logic-Ctmq4InP.js} +2 -2
  62. package/dist/client/assets/{LHDIQX7Q-DwRY1EjH.js → LHDIQX7Q-BkDTNH4X.js} +2 -2
  63. package/dist/client/assets/{LUXOKEGN-BTGUp3oJ.js → LUXOKEGN-BMFFLlMk.js} +2 -2
  64. package/dist/client/assets/{LinkMachineSelect-DoHeQGoj.js → LinkMachineSelect-DGm4EDKi.js} +2 -2
  65. package/dist/client/assets/{MathTypeset-DZCUnfpK.js → MathTypeset-DpXMOBGY.js} +2 -2
  66. package/dist/client/assets/{N3JZAHOW-C-bkdj1S.js → N3JZAHOW-CV9TIlCo.js} +2 -2
  67. package/dist/client/assets/{NUIALGQ3-COfmKsf1.js → NUIALGQ3-WBqakHka.js} +2 -2
  68. package/dist/client/assets/{NoProjectsHero-CbIPjHEJ.js → NoProjectsHero-BfU7AxbB.js} +2 -2
  69. package/dist/client/assets/{O65XPQGZ-BPK2EL3_.js → O65XPQGZ-CYhr2tYZ.js} +2 -2
  70. package/dist/client/assets/{O7XIQ6OM-qzVUZXbW.js → O7XIQ6OM-D2JMbFqc.js} +2 -2
  71. package/dist/client/assets/{OFQON5FD-DJVnaZou.js → OFQON5FD-B1aTfx9o.js} +2 -2
  72. package/dist/client/assets/{P4ConnectAccountPages-DwBbHN5Q.js → P4ConnectAccountPages-J205rNHS.js} +2 -2
  73. package/dist/client/assets/{P4ConnectSidebarSignIn-D7VczA30.js → P4ConnectSidebarSignIn-Bc4xlsJh.js} +2 -2
  74. package/dist/client/assets/{PJQHF43J-CTXALHLE.js → PJQHF43J-Dm3RMjWi.js} +2 -2
  75. package/dist/client/assets/{PanelLayoutControls-D8g6TJ8z.js → PanelLayoutControls-BQZYES2T.js} +4 -4
  76. package/dist/client/assets/{PierreEntryIcon-CUoKY0yE.js → PierreEntryIcon-CHy821MU.js} +2 -2
  77. package/dist/client/assets/{PopoverHandle-tRSwNzqr.js → PopoverHandle-BkzqaTB6.js} +2 -2
  78. package/dist/client/assets/{PreviewPanel-cYx50TF6.js → PreviewPanel-D8V2zDl4.js} +2 -2
  79. package/dist/client/assets/{ProjectDefaultsSettings-G0FTRG0c.js → ProjectDefaultsSettings-6UkudkKP.js} +2 -2
  80. package/dist/client/assets/{ProjectFavicon-in-OyDkg.js → ProjectFavicon-LcyFYpHB.js} +3 -3
  81. package/dist/client/assets/{ProjectIconPickerDialog-JCPOaZup.js → ProjectIconPickerDialog-D03-Jrsi.js} +2 -2
  82. package/dist/client/assets/{ProjectMonogram-DdbScW3Y.js → ProjectMonogram-C8FlNLaU.js} +2 -2
  83. package/dist/client/assets/{ProviderAuthTerminal-CCw2XmNz.js → ProviderAuthTerminal-DMTbKboR.js} +2 -2
  84. package/dist/client/assets/{ProviderModelPicker-DWqfDVY9.js → ProviderModelPicker-CpWE-Lfx.js} +2 -2
  85. package/dist/client/assets/{ProviderSettingsForm-_viBEB9w.js → ProviderSettingsForm-DrCFln8c.js} +2 -2
  86. package/dist/client/assets/{PullRequestCodeTab-D3ntjIAg.js → PullRequestCodeTab-CjBrGNWY.js} +2 -2
  87. package/dist/client/assets/{RHNBAITX-BR5h8H8U.js → RHNBAITX-C7mnxleL.js} +2 -2
  88. package/dist/client/assets/{ReadOnlySourcePreview-Bx9Jebzp.js → ReadOnlySourcePreview-BasbTHVd.js} +2 -2
  89. package/dist/client/assets/{RedactedSensitiveText-DM7Kme26.js → RedactedSensitiveText-DACYfm7e.js} +2 -2
  90. package/dist/client/assets/{RenderErrorBoundary-BeYcnW7D.js → RenderErrorBoundary-CIVNp8r9.js} +2 -2
  91. package/dist/client/assets/{SLD4V6NK-DfUtjUb_.js → SLD4V6NK-BkeVs7gb.js} +2 -2
  92. package/dist/client/assets/{ScheduledTasksSettings-BcF7IiOl.js → ScheduledTasksSettings-DpYigye5.js} +2 -2
  93. package/dist/client/assets/{ScopedSwitch-CD9C3Bhs.js → ScopedSwitch-D1uscoF8.js} +2 -2
  94. package/dist/client/assets/{ScrollAreaCorner-D5JbJL5g.js → ScrollAreaCorner-DBtks1xb.js} +2 -2
  95. package/dist/client/assets/{SecretInput-ttyiYbVY.js → SecretInput-ZW3hnCoN.js} +2 -2
  96. package/dist/client/assets/{SelectScrollUpArrow-BV1xykNQ.js → SelectScrollUpArrow-Bq-GYRhT.js} +2 -2
  97. package/dist/client/assets/{SelfImproveSettingsSection-Dm8NhqV7.js → SelfImproveSettingsSection-CDIhJO4P.js} +2 -2
  98. package/dist/client/assets/{SettingsPanels-BsyJETg8.js → SettingsPanels-Co5mks6X.js} +2 -2
  99. package/dist/client/assets/{SettingsPanels.logic-DS-Semyc.js → SettingsPanels.logic-H5v8FTnu.js} +2 -2
  100. package/dist/client/assets/{SettingsScopeNotice--a-aNSRR.js → SettingsScopeNotice-gFtgpybO.js} +2 -2
  101. package/dist/client/assets/{SidebarStageBackdrop-ntSLLOvm.js → SidebarStageBackdrop-DSuAw8Ob.js} +2 -2
  102. package/dist/client/assets/{T3PCR2KE-C5JeZecU.js → T3PCR2KE-D6MHoseG.js} +2 -2
  103. package/dist/client/assets/{TKWO2OVW-B11aaxW8.js → TKWO2OVW-gZK7dLQZ.js} +2 -2
  104. package/dist/client/assets/{TSHNXIZL-2800Jt5F.js → TSHNXIZL-BKUmF3Cu.js} +2 -2
  105. package/dist/client/assets/{ThemeEditorPanel-CTXEQSgi.js → ThemeEditorPanel-lI_9CbBH.js} +2 -2
  106. package/dist/client/assets/{ThreadTerminalDrawer-DIUp50A3.js → ThreadTerminalDrawer-CD3plt2C.js} +2 -2
  107. package/dist/client/assets/{TooltipViewport-rDmof6w5.js → TooltipViewport-Be_gbUW1.js} +2 -2
  108. package/dist/client/assets/{UQJE5E4I-BG1U9EIM.js → UQJE5E4I-D6av033t.js} +2 -2
  109. package/dist/client/assets/{USNYFO5S-d4iGw5HU.js → USNYFO5S-Cy6sDMEU.js} +2 -2
  110. package/dist/client/assets/{Virtualizer-CzClYBap.js → Virtualizer-B_IsUzcr.js} +2 -2
  111. package/dist/client/assets/{WEVWDWVA-V2MwjUCO.js → WEVWDWVA-Cq1fZcng.js} +2 -2
  112. package/dist/client/assets/{WorkspaceBreadcrumb-Dpau2BKr.js → WorkspaceBreadcrumb-DbQW7iNE.js} +2 -2
  113. package/dist/client/assets/{WorkspacePageContainer-C3u06BW-.js → WorkspacePageContainer-BxI-x0oV.js} +2 -2
  114. package/dist/client/assets/{WorkspacePageHeader-MBEFb20_.js → WorkspacePageHeader-Bc_F6Uog.js} +2 -2
  115. package/dist/client/assets/{X5RFHQXM-D_mIa6o9.js → X5RFHQXM-DdtKPA-W.js} +2 -2
  116. package/dist/client/assets/{X62E3GBT-Cwvyi_iR.js → X62E3GBT-C7OjB5pB.js} +2 -2
  117. package/dist/client/assets/{XBNEOJTC-sfA1U_fe.js → XBNEOJTC-_Tbl2Kwh.js} +2 -2
  118. package/dist/client/assets/{YHV2MVVZ-CZoP6AAo.js → YHV2MVVZ-CA4YS5f4.js} +2 -2
  119. package/dist/client/assets/{YURCZMG2-DYo6rqon.js → YURCZMG2-DSnhUUsH.js} +2 -2
  120. package/dist/client/assets/{YVG2LODB-D8sTsTwc.js → YVG2LODB-D-qFsH5t.js} +2 -2
  121. package/dist/client/assets/_chat-Cnc6rxt6.js +47 -0
  122. package/dist/client/assets/{_chat.design-Nh4vxHDS.js → _chat.design-SX7SShjI.js} +2 -2
  123. package/dist/client/assets/{_chat.index-YNITFXX3.js → _chat.index-Bz1lJLpv.js} +2 -2
  124. package/dist/client/assets/{_chat.new-B16PAbQN.js → _chat.new-BEqc5oJc.js} +2 -2
  125. package/dist/client/assets/{_chat.pull-requests-DEHC0db5.js → _chat.pull-requests-A3IwVYWs.js} +2 -2
  126. package/dist/client/assets/{alert-UH7IbYie.js → alert-BOVMKHDy.js} +2 -2
  127. package/dist/client/assets/{alert-dialog-D3mCT6Vy.js → alert-dialog-Du3fYY3I.js} +2 -2
  128. package/dist/client/assets/{assetUrls-BNjjSBLP.js → assetUrls-CYjvy6P4.js} +2 -2
  129. package/dist/client/assets/{assets-CrCgj2yM.js → assets-JgE2I_Ix.js} +2 -2
  130. package/dist/client/assets/{browserHistoryStore-CW_ylkPy.js → browserHistoryStore-CdncPjG8.js} +2 -2
  131. package/dist/client/assets/{browserLinkTarget-Dlnk6CC2.js → browserLinkTarget-Bf9H9UVe.js} +2 -2
  132. package/dist/client/assets/{checkbox-Bqcsvpsf.js → checkbox-d50pgAVe.js} +2 -2
  133. package/dist/client/assets/{color-picker-DAcpRn0k.js → color-picker-zcQshxaE.js} +2 -2
  134. package/dist/client/assets/{combobox-CoLp0McG.js → combobox-BrCd1kH5.js} +2 -2
  135. package/dist/client/assets/{command-cKnhWwdw.js → command-DFkhX6wm.js} +2 -2
  136. package/dist/client/assets/{connect-rbXRyqde.js → connect-DkH09d_M.js} +2 -2
  137. package/dist/client/assets/connect-agent-DJHm1Ubj.js +2 -0
  138. package/dist/client/assets/{design-BJbd-4a9.js → design-DrpehYJf.js} +2 -2
  139. package/dist/client/assets/{device-BqGYZxfg.js → device-Nh7DArH7.js} +2 -2
  140. package/dist/client/assets/{dialog-CjB1WWbE.js → dialog-BpR3dRVS.js} +2 -2
  141. package/dist/client/assets/{diffRendering-JsGpyVJ1.js → diffRendering-BuOJdnZ8.js} +2 -2
  142. package/dist/client/assets/{dist-D4GndTOF.js → dist-CMJL98Oz.js} +3 -3
  143. package/dist/client/assets/{draft-input-1ySc55QI.js → draft-input-CzfhM72Z.js} +2 -2
  144. package/dist/client/assets/{duoViewer-DvlUJy5A.js → duoViewer-ChrCWcjO.js} +2 -2
  145. package/dist/client/assets/{dynamic-B8PD-aHj.js → dynamic-CVt07u2H.js} +2 -2
  146. package/dist/client/assets/{embeddedScripts-ByokzHX1.js → embeddedScripts-BWqMWwOU.js} +2 -2
  147. package/dist/client/assets/{empty-CMnFXg8W.js → empty-Cy-8us9l.js} +2 -2
  148. package/dist/client/assets/{entities-CTJ1ube2.js → entities-aKdRyfsJ.js} +2 -2
  149. package/dist/client/assets/{fileLinks-lUzqPrjb.js → fileLinks-BgHa8yE4.js} +2 -2
  150. package/dist/client/assets/{fileTreeExpansion-B6sjoSXU.js → fileTreeExpansion-CBn1SzSX.js} +2 -2
  151. package/dist/client/assets/{getDiffFileInput-Bt5vSiss.js → getDiffFileInput-IQ1TDM4E.js} +2 -2
  152. package/dist/client/assets/{guideRunStore-DFawhaj_.js → guideRunStore-DfNfJUIu.js} +2 -2
  153. package/dist/client/assets/{htmlRender-DJLbbd4O.js → htmlRender-lwQ3HyqS.js} +2 -2
  154. package/dist/client/assets/{index-CxLeDuff.js → index-BXvrSYK3.js} +3 -3
  155. package/dist/client/assets/{input-CSgYZgdv.js → input-FUjAUGXY.js} +2 -2
  156. package/dist/client/assets/{input-group-a-sGQMiV.js → input-group-BdZ_CKvG.js} +2 -2
  157. package/dist/client/assets/{kbd-D3uRVBMx.js → kbd-CGgmav-Q.js} +2 -2
  158. package/dist/client/assets/{keybindings-B9X0TLvu.js → keybindings-DuCyi9aT.js} +2 -2
  159. package/dist/client/assets/{lazy-C_hQh3dP.js → lazy-Bs2SFpYS.js} +4 -4
  160. package/dist/client/assets/{lazyRouteComponent-GMfIUG8o.js → lazyRouteComponent-CYNRqeNP.js} +2 -2
  161. package/dist/client/assets/{link-BmkuqfGQ.js → link-DW1IQk5s.js} +2 -2
  162. package/dist/client/assets/{linkedPrompt-BNxBPorU.js → linkedPrompt-yo2xi4Z8.js} +2 -2
  163. package/dist/client/assets/{main-DIEsHSIy.js → main-C0z861OK.js} +7 -7
  164. package/dist/client/assets/{mediaReference-CVS-Yvam.js → mediaReference-BQ9J-tjl.js} +2 -2
  165. package/dist/client/assets/{mediaSource-DQsJoeCH.js → mediaSource-BLpxwEw3.js} +2 -2
  166. package/dist/client/assets/{number-field-Bw2BDGyn.js → number-field-Pve745k3.js} +2 -2
  167. package/dist/client/assets/{observeResize-Br7VOcTc.js → observeResize-CZuDzlcZ.js} +2 -2
  168. package/dist/client/assets/{onboarding-D6kvYnD1.js → onboarding-CE8pzS12.js} +2 -2
  169. package/dist/client/assets/{openFileInPreview-52PEk4wb.js → openFileInPreview-Dns9tPaB.js} +2 -2
  170. package/dist/client/assets/{p4ProjectFile-B1qTw64E.js → p4ProjectFile-jwYvYDE-.js} +2 -2
  171. package/dist/client/assets/{pair-Das8G2kV.js → pair-OPslYcM9.js} +2 -2
  172. package/dist/client/assets/{pendingSendStore-B1MXHU-Y.js → pendingSendStore-CLwMM17y.js} +2 -2
  173. package/dist/client/assets/{phoneViewer-iWL9Ocv_.js → phoneViewer-CkTxyA9N.js} +2 -2
  174. package/dist/client/assets/{pierre-icons-CyZxWykW.js → pierre-icons-DY8ZeGCr.js} +2 -2
  175. package/dist/client/assets/{popover-Cpc0L75h.js → popover-hYAmvSJj.js} +2 -2
  176. package/dist/client/assets/{preview-DRZGCh-w.js → preview-CI9HEdfV.js} +2 -2
  177. package/dist/client/assets/{preview-CDQ5ceMi.js → preview-YhZE3kRt.js} +2 -2
  178. package/dist/client/assets/{previewMiniPlayerStore-Dd2KfilQ.js → previewMiniPlayerStore-DUPe1gGI.js} +2 -2
  179. package/dist/client/assets/{primary-YDhFfOF8.js → primary-BlS2rEKe.js} +2 -2
  180. package/dist/client/assets/{primaryCloudLinkState-kvnCGEBC.js → primaryCloudLinkState-CyPf4N0F.js} +2 -2
  181. package/dist/client/assets/{projectFilesQueryState-DvEcN38K.js → projectFilesQueryState-BdWJ4WwI.js} +2 -2
  182. package/dist/client/assets/{projectScriptEditor-lOSI5meb.js → projectScriptEditor-C0FBhCbn.js} +2 -2
  183. package/dist/client/assets/{providerSkills-CRmME5qO.js → providerSkills-Ca_7EbAx.js} +2 -2
  184. package/dist/client/assets/{pullRequestDetail.logic-CXEtJJcn.js → pullRequestDetail.logic-DYx7bEwE.js} +2 -2
  185. package/dist/client/assets/{pullRequestIcons-D8Koo716.js → pullRequestIcons-csprKuju.js} +2 -2
  186. package/dist/client/assets/{pullRequestReviewStore-CpLjLBJR.js → pullRequestReviewStore-_uEYgfaW.js} +2 -2
  187. package/dist/client/assets/{pullRequests-DKqH-UAm.js → pullRequests-B85p5Xnw.js} +2 -2
  188. package/dist/client/assets/{queries-eqpX-CHf.js → queries-B0FvRKmk.js} +2 -2
  189. package/dist/client/assets/{query-D5Kb9u_z.js → query-B2_Td0ad.js} +2 -2
  190. package/dist/client/assets/{radio-group-DpxVKrML.js → radio-group-IyWHDcIP.js} +2 -2
  191. package/dist/client/assets/{renderScheduler-B1rJHKDM.js → renderScheduler-DR2WAtIH.js} +2 -2
  192. package/dist/client/assets/{rightPanelStore-DQ1c3-Lt.js → rightPanelStore-rZSIb-5z.js} +2 -2
  193. package/dist/client/assets/{runtime-DCbEdU32.js → runtime-BK2Lh1vB.js} +3 -3
  194. package/dist/client/assets/{runtime-DeVKKxNz.js → runtime-BVmDVuJ-.js} +3 -3
  195. package/dist/client/assets/{runtimeModeConfig-CZCsG9b4.js → runtimeModeConfig-DFxXOIlV.js} +2 -2
  196. package/dist/client/assets/{scheduledTasksSettings.logic-gN3n5v-e.js → scheduledTasksSettings.logic-W9AQpJk4.js} +2 -2
  197. package/dist/client/assets/{scroll-area-C9Jh_pl0.js → scroll-area-Cf7uLi_s.js} +2 -2
  198. package/dist/client/assets/{select-oshTwPZM.js → select-vBkqTMKL.js} +2 -2
  199. package/dist/client/assets/selfImproveFindings-4GGN9cRm.js +2 -0
  200. package/dist/client/assets/{server-Ct4-BCZx.js → server-DwkxciXh.js} +2 -2
  201. package/dist/client/assets/{session-Bb7JWdWO.js → session-BIwsf8Q4.js} +2 -2
  202. package/dist/client/assets/{session-logic-D0Wb0fc2.js → session-logic-D8FbVFDm.js} +2 -2
  203. package/dist/client/assets/{settings-CQtFOh_t.js → settings-C58Y7hMl.js} +2 -2
  204. package/dist/client/assets/{settings.appearance-CqHPJVJ2.js → settings.appearance-C9ZmuG-n.js} +2 -2
  205. package/dist/client/assets/settings.archived-BxqS4kuW.js +2 -0
  206. package/dist/client/assets/{settings.computer-use-CDrWkvkD.js → settings.computer-use-CeIs-8zf.js} +2 -2
  207. package/dist/client/assets/{settings.connections-CHXX5kH0.js → settings.connections-CEr4PdrJ.js} +2 -2
  208. package/dist/client/assets/{settings.data-controls-Bd79f82M.js → settings.data-controls-BbzJxjBi.js} +2 -2
  209. package/dist/client/assets/{settings.decisions-B-i781li.js → settings.decisions-DagsCV4K.js} +2 -2
  210. package/dist/client/assets/{settings.designs-DpX9xXFH.js → settings.designs-DEThhuEj.js} +2 -2
  211. package/dist/client/assets/{settings.diagnostics-Du6_cMwQ.js → settings.diagnostics-DdsecwWn.js} +2 -2
  212. package/dist/client/assets/{settings.general-6bgZAoM7.js → settings.general-RgU1jNmB.js} +2 -2
  213. package/dist/client/assets/{settings.integrations-Ct8ruO3E.js → settings.integrations-CO-aLXSC.js} +2 -2
  214. package/dist/client/assets/{settings.keybindings-DzB2I9OY.js → settings.keybindings-CU8fBQaI.js} +2 -2
  215. package/dist/client/assets/{settings.open-source-licenses-C-RX63iR.js → settings.open-source-licenses-rG8Neftl.js} +2 -2
  216. package/dist/client/assets/{settings.plugins-CqpVlMrk.js → settings.plugins-Dr0VpcPy.js} +2 -2
  217. package/dist/client/assets/{settings.projects-DosfFxrs.js → settings.projects-hxwk8_7r.js} +3 -3
  218. package/dist/client/assets/{settings.providers-DKgzTRpw.js → settings.providers-D5-Kj1jY.js} +3 -3
  219. package/dist/client/assets/{settings.scheduled-tasks-Ca4XxyAg.js → settings.scheduled-tasks-DwUd14Xj.js} +2 -2
  220. package/dist/client/assets/{settings.snap-shot-BkSOnsJ3.js → settings.snap-shot-CTMJRtJe.js} +2 -2
  221. package/dist/client/assets/{settings.source-control-uZ0ges0j.js → settings.source-control-BHD5KE8W.js} +2 -2
  222. package/dist/client/assets/{settings.storage-BkURtSS0.js → settings.storage-Bhd9ragP.js} +2 -2
  223. package/dist/client/assets/{settingsLayout-krWuVpsF.js → settingsLayout-WhjsCfB6.js} +2 -2
  224. package/dist/client/assets/{sidebar-PSpwc3Zu.js → sidebar-O52WtiJv.js} +2 -2
  225. package/dist/client/assets/{sidebarProjectGrouping-D02jVAL6.js → sidebarProjectGrouping-BYVdJp_w.js} +2 -2
  226. package/dist/client/assets/{skeleton-DIPW_H7N.js → skeleton-PlPtYr_f.js} +2 -2
  227. package/dist/client/assets/{sourceControl-B9aMMjp2.js → sourceControl-BkJeQRrv.js} +2 -2
  228. package/dist/client/assets/{sourceControlClients-XtdH6kjx.js → sourceControlClients-CtMx7u86.js} +2 -2
  229. package/dist/client/assets/{spinner-BeAnBYcY.js → spinner-BZ5ohCyO.js} +2 -2
  230. package/dist/client/assets/{terminal-links-CYEBYRi6.js → terminal-links-UI2UJn0y.js} +2 -2
  231. package/dist/client/assets/{terminalSessions-C2k3TT8f.js → terminalSessions-C1xOLG3i.js} +2 -2
  232. package/dist/client/assets/{textarea-DBTtAB2q.js → textarea-DIg__-Gi.js} +2 -2
  233. package/dist/client/assets/{themePalette-Uk7bx8zb.js → themePalette-BMlBfFUx.js} +2 -2
  234. package/dist/client/assets/{toast-Dkj3G-UM.js → toast-BZ96uuab.js} +2 -2
  235. package/dist/client/assets/{toggle-DYYe3Gb8.js → toggle-DJ8KOwn5.js} +2 -2
  236. package/dist/client/assets/{toggle-group-hQw0fxkT.js → toggle-group-2e3XGJdx.js} +2 -2
  237. package/dist/client/assets/{tooltip-BeHmtauD.js → tooltip-BPiLl1TV.js} +2 -2
  238. package/dist/client/assets/{uiStateStore-Cd96D_GT.js → uiStateStore-4i21PZUL.js} +2 -2
  239. package/dist/client/assets/{usage-ChIGOn5O.js → usage-uuNPbJve.js} +2 -2
  240. package/dist/client/assets/{usageAccess-DTKEwCKL.js → usageAccess-CsMv6eC9.js} +2 -2
  241. package/dist/client/assets/{usageFormat-D1mf8I5d.js → usageFormat-DhefL58S.js} +2 -2
  242. package/dist/client/assets/{usageShortcuts-C0jTsdR4.js → usageShortcuts-CREc0FBr.js} +2 -2
  243. package/dist/client/assets/{use-atom-command-D4TeQyNE.js → use-atom-command-CdV5BZYB.js} +2 -2
  244. package/dist/client/assets/{useAriaLabelledBy-Cod6bMX5.js → useAriaLabelledBy-CYRfRdAq.js} +2 -2
  245. package/dist/client/assets/{useHandleNewThread-CJ3yJ6tD.js → useHandleNewThread-BsnMrEPr.js} +2 -2
  246. package/dist/client/assets/{useLocation-DNv7cb59.js → useLocation-DHd-KBb-.js} +2 -2
  247. package/dist/client/assets/{useNavigate-PfhtEZbl.js → useNavigate-AZUCIeU4.js} +2 -2
  248. package/dist/client/assets/{useNavigateBack-DUje4FcE.js → useNavigateBack-C7DkQuEE.js} +2 -2
  249. package/dist/client/assets/{useP4ConnectAuthPrompt-evKe5nuS.js → useP4ConnectAuthPrompt-u1GHgwlc.js} +2 -2
  250. package/dist/client/assets/{useParams-CzC0HF0R.js → useParams-rbhXoEw9.js} +2 -2
  251. package/dist/client/assets/{usePermissionStatus-BUDWSxLm.js → usePermissionStatus-DHzE_VGG.js} +2 -2
  252. package/dist/client/assets/{usePullRequestActions-Cxt5UQ0d.js → usePullRequestActions-Cv12eqOn.js} +2 -2
  253. package/dist/client/assets/{useRegisterFieldControl-B4MJ2axN.js → useRegisterFieldControl-D4FG4i3_.js} +2 -2
  254. package/dist/client/assets/{useScopedModelAvailability-ujoqpGuE.js → useScopedModelAvailability-D6cbxQLl.js} +2 -2
  255. package/dist/client/assets/{useSettings-Cg0O7Ek7.js → useSettings-B09a3zie.js} +2 -2
  256. package/dist/client/assets/utils-C5GGWTfe.js +37 -0
  257. package/dist/client/assets/{vcsRefInvalidation-B5V_HlR9.js → vcsRefInvalidation-B66hRx4g.js} +2 -2
  258. package/dist/client/assets/{welcome-DqtsIjdN.js → welcome-D2-tjFV3.js} +2 -2
  259. package/dist/client/index.html +1 -1
  260. package/dist/{renderer-CmxAcIV2.mjs → renderer-CuqsXHrO.mjs} +2 -2
  261. package/dist/{runtime-CAtWuL14.mjs → runtime-CWPUW_8Y.mjs} +24 -7
  262. package/package.json +1 -1
  263. package/dist/client/assets/AlertDialogRoot-C6RQ4Ag-.js +0 -2
  264. package/dist/client/assets/Input--rtZ2Jji.js +0 -2
  265. package/dist/client/assets/JZOYTAAL-PmkwTnld.js +0 -1
  266. package/dist/client/assets/_chat-DNoJniWX.js +0 -47
  267. package/dist/client/assets/connect-agent-CsvW078q.js +0 -2
  268. package/dist/client/assets/selfImproveFindings-DUmfxmCO.js +0 -2
  269. package/dist/client/assets/settings.archived-DDtPGPcJ.js +0 -2
  270. package/dist/client/assets/utils-CcBaVOX5.js +0 -37
@@ -1,2 +1,2 @@
1
- import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{t as i}from"./plus-B2sOrZDk.js";import{$_ as a,$l as o,AC as s,Bd as c,Bv as l,Cx as u,Dx as d,Kf as f,M_ as p,O_ as m,Pl as h,Px as g,Q_ as _,Qo as v,Rd as y,Rm as b,SE as x,X_ as S,Xn as C,Y_ as w,Yc as T,_s as E,aE as D,av as O,cr as k,cs as A,cv as j,dr as M,dv as N,er as P,eu as F,ev as ee,fS as I,ff as te,fr as L,fv as ne,hE as re,ir as ie,iv as ae,lr as oe,lv as R,ms as se,nb as ce,nm as le,nr as ue,ns as de,om as fe,or as z,ov as pe,pm as me,pr as he,pv as ge,q_ as _e,rr as B,rv as V,ss as ve,sv as ye,t as be,uh as H,ur as xe,uv as Se,vE as Ce,vv as we,yE as Te,yb as Ee}from"./utils-CcBaVOX5.js";import{Dt as U,Et as De,F as Oe,Ht as ke,On as Ae,Ot as W,R as je,Ut as G,W as Me,jt as K,kt as Ne,o as Pe,on as Fe,tt as Ie,w as Le,x as Re}from"./runtime-DeVKKxNz.js";import{E as ze,F as Be,Ft as Ve,Pt as q,S as He,_ as Ue,jt as We,kt as Ge,t as Ke}from"./runtime-DCbEdU32.js";import{a as qe,c as Je,o as Ye,s as Xe,t as Ze}from"./select-oshTwPZM.js";import{t as Qe}from"./spinner-BeAnBYcY.js";import{i as J,p as $e}from"./toast-Dkj3G-UM.js";import{A as et,D as tt,E as nt,O as Y,_ as rt,c as it,et as at,s as ot,y as st}from"./useSettings-Cg0O7Ek7.js";import{f as ct,h as lt,s as ut}from"./server-Ct4-BCZx.js";import{a as dt,i as ft,n as pt,o as mt,s as ht}from"./session-Bb7JWdWO.js";import{n as gt}from"./query-D5Kb9u_z.js";import{t as _t}from"./use-atom-command-D4TeQyNE.js";import{t as vt}from"./toastHelpers-DxXYm50b.js";import{i as yt,r as bt}from"./timestampFormat-wac2e_Jz.js";import{a as xt,n as St,t as Ct}from"./tooltip-BeHmtauD.js";import{t as wt}from"./textarea-DBTtAB2q.js";import{t as Tt}from"./input-CSgYZgdv.js";import{t as Et}from"./scroll-area-C9Jh_pl0.js";import{a as Dt,c as Ot,i as kt,l as At,n as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./dialog-CjB1WWbE.js";import{n as It}from"./P4ConnectAccountPages-DwBbHN5Q.js";import{a as Lt,i as Rt,o as zt,r as Bt,t as Vt}from"./empty-CMnFXg8W.js";import{t as Ht}from"./AnimatedHeight-DEeywxgS.js";import{C as Ut,_ as Wt,w as Gt,y as Kt}from"./keybindings-B9X0TLvu.js";import{i as qt,o as Jt,t as Yt}from"./popover-Cpc0L75h.js";import{a as Xt,c as Zt,i as Qt,l as $t,r as en,s as tn,t as nn,u as rn}from"./LinkMachineSelect-DoHeQGoj.js";import{t as an}from"./checkbox-Bqcsvpsf.js";import{r as on}from"./uiStateStore-Cd96D_GT.js";import{n as sn,t as cn}from"./EnvironmentMachineIcon-oObSi9GI.js";import{r as ln,t as un}from"./alert-UH7IbYie.js";import{a as dn,i as fn,n as pn,o as mn,r as hn,s as gn,t as _n}from"./alert-dialog-D3mCT6Vy.js";import{a as vn,i as yn,s as bn,u as X}from"./settingsLayout-krWuVpsF.js";import{_ as xn,b as Sn,g as Cn,h as wn,v as Tn,x as En,y as Dn}from"./command-cKnhWwdw.js";import{t as On}from"./ConnectionStatusDot-CR_qWdCU.js";import{a as kn,n as An,o as jn,s as Mn,t as Nn}from"./primary-YDhFfOF8.js";import{n as Pn,t as Fn}from"./onboarding-D6kvYnD1.js";import{$r as In,Ai as Ln,Ar as Rn,Br as zn,Ci as Bn,Di as Vn,Fi as Hn,Ii as Un,Mi as Wn,Ni as Gn,Oi as Kn,Pi as qn,Qr as Jn,Rr as Yn,Si as Xn,T as Zn,Ti as Qn,Tr as $n,Vr as er,Xr as tr,Yr as nr,an as rr,ar as ir,br as ar,cn as or,cr as sr,fr as cr,go as lr,gr as ur,hr as dr,ji as fr,ki as pr,ln as mr,lr as hr,mo as gr,or as _r,po as vr,pr as yr,sn as br,sr as xr,ur as Sr,wi as Cr,wr,zr as Tr}from"./main-DIEsHSIy.js";import{n as Er}from"./ConnectAgentSurface-TBgGDnVI.js";import{t as Dr}from"./FoldedSettingsSection-DPTJODig.js";var Z=n(),Or=[{scope:ae,title:`View environment`,description:`Read threads, status, checkpoints, and configuration.`},{scope:V,title:`Operate tasks`,description:`Start, update, and stop tasks.`},{scope:R,title:`Change environment settings`,description:`Edit environment preferences and keybindings.`},{scope:pe,title:`Manage providers`,description:`Configure, install, sign in to, and update providers and usage sources.`},{scope:_,title:`Maintain environment`,description:`Update the server and control environment processes.`},{scope:O,title:`Control previews`,description:`Open browser previews and host browser automation.`},{scope:S,title:`View diagnostics and usage`,description:`Read process diagnostics, resource history, and usage totals.`},{scope:ge,title:`View terminals`,description:`Read existing terminal output and status.`},{scope:ne,title:`Use terminals`,description:`Create terminals and send input to running shells.`},{scope:Se,title:`Change source control`,description:`Commit, push, manage branches and repositories, and change pull requests.`},{scope:a,title:`Read files`,description:`Browse host files, search workspaces, and inspect local changes.`},{scope:ee,title:`Write files`,description:`Edit workspace files and save plans to disk.`},{scope:_e,title:`View access`,description:`Inspect pairing links and authorized clients.`},{scope:w,title:`Manage access`,description:`Issue and revoke credentials for other clients.`},{scope:ye,title:`View relay`,description:`Inspect managed relay connectivity.`},{scope:j,title:`Manage relay`,description:`Change managed tunnel connectivity.`}],Q=e(r(),1);function kr(e){let t=(0,Z.c)(4),{environmentId:n,connected:r,routeContext:i}=e,a=i!==void 0&&i,o=dt(n),s;return t[0]!==r||t[1]!==a||t[2]!==o?(s=r&&!o.hasError&&!o.isPending&&o.data?.authenticated?(0,Q.jsxs)(`div`,{className:`space-y-3 py-3 text-xs`,children:[(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:a?`These permissions apply to your active route. Other routes may have different permissions.`:`These permissions apply to this client’s current connection.`}),(0,Q.jsx)(`ul`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2`,children:Or.map(e=>{let{scope:t,title:n}=e;return(0,Q.jsxs)(`li`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`span`,{children:n}),(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:we(o.data,t)?`Allowed`:`Not granted`})]},t)})})]}):(0,Q.jsx)(`p`,{className:`py-3 text-xs text-muted-foreground`,children:`Permissions not checked. Connect to this environment to view this session’s permissions.`}),t[0]=r,t[1]=a,t[2]=o,t[3]=s):s=t[3],s}var $=e(t(),1);function Ar(e,t){let n=new URL(e);return n.pathname=`/pair`,Ve(n,t).toString()}function jr(e,t){return new URL(e).protocol===`https:`?He({host:e,token:t}):null}function Mr(){let e=(0,Z.c)(48),t=window.desktopBridge?.setLocalEnvironmentEnabled,[n]=(0,$.useState)(Nr),[r,i]=(0,$.useState)(!1),[a,o]=(0,$.useState)(!1),[s,c]=(0,$.useState)(null);if(!t)return null;let l;e[0]===n?l=e[1]:(l=async()=>{o(!0),c(null);try{await t(!n)}catch(e){let t=e;c(t instanceof Error?t.message:`Couldn't change this setting.`),o(!1)}},e[0]=n,e[1]=l);let u=l,d;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=Rn(`local-environment`),e[2]=d):d=e[2];let f=n?`Run agents on this computer. Turn off to use P4 Code only with remote environments.`:`Turned off. Agents only run in remote environments.`,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>i(!0),e[3]=p):p=e[3];let m;e[4]!==n||e[5]!==a?(m=(0,Q.jsx)(lr,{checked:n,disabled:a,onCheckedChange:p,"aria-label":`Local environment`}),e[4]=n,e[5]=a,e[6]=m):m=e[6];let h;e[7]!==f||e[8]!==m?(h=(0,Q.jsx)(vn,{...d,description:f,control:m}),e[7]=f,e[8]=m,e[9]=h):h=e[9];let g;e[10]===a?g=e[11]:(g=e=>{a||(i(e),e||c(null))},e[10]=a,e[11]=g);let _=n?`Turn off local environment?`:`Turn on local environment?`,v;e[12]===_?v=e[13]:(v=(0,Q.jsx)(gn,{children:_}),e[12]=_,e[13]=v);let y=n?`P4 Code will restart without running a server on this computer. Any agents and terminals running here will stop, and other devices will no longer be able to connect to this computer. Your projects, history, and remote environments are unaffected.`:`P4 Code will restart and start running a server on this computer again.`,b;e[14]===y?b=e[15]:(b=(0,Q.jsx)(hn,{children:y}),e[14]=y,e[15]=b);let x;e[16]!==b||e[17]!==v?(x=(0,Q.jsxs)(dn,{children:[v,b]}),e[16]=b,e[17]=v,e[18]=x):x=e[18];let S;e[19]===s?S=e[20]:(S=s?(0,Q.jsx)(`p`,{className:`px-6 pb-4 text-sm text-destructive`,children:s}):null,e[19]=s,e[20]=S);let C;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(L,{variant:`outline`}),e[21]=C):C=e[21];let w;e[22]===a?w=e[23]:(w=(0,Q.jsx)(pn,{disabled:a,render:C,children:`Cancel`}),e[22]=a,e[23]=w);let T=n?`destructive`:`default`,E;e[24]===u?E=e[25]:(E=()=>void u(),e[24]=u,e[25]=E);let D;e[26]!==n||e[27]!==a?(D=a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):n?`Restart and turn off`:`Restart and turn on`,e[26]=n,e[27]=a,e[28]=D):D=e[28];let O;e[29]!==a||e[30]!==T||e[31]!==E||e[32]!==D?(O=(0,Q.jsx)(L,{variant:T,disabled:a,onClick:E,children:D}),e[29]=a,e[30]=T,e[31]=E,e[32]=D,e[33]=O):O=e[33];let k;e[34]!==w||e[35]!==O?(k=(0,Q.jsxs)(fn,{children:[w,O]}),e[34]=w,e[35]=O,e[36]=k):k=e[36];let A;e[37]!==x||e[38]!==S||e[39]!==k?(A=(0,Q.jsxs)(mn,{children:[x,S,k]}),e[37]=x,e[38]=S,e[39]=k,e[40]=A):A=e[40];let j;e[41]!==r||e[42]!==A||e[43]!==g?(j=(0,Q.jsx)(_n,{open:r,onOpenChange:g,children:A}),e[41]=r,e[42]=A,e[43]=g,e[44]=j):j=e[44];let M;return e[45]!==j||e[46]!==h?(M=(0,Q.jsxs)(Q.Fragment,{children:[h,j]}),e[45]=j,e[46]=h,e[47]=M):M=e[47],M}function Nr(){return!Le()}function Pr(e){return e.serverConfig===null?`Connect to this environment to change its icon.`:e.serverConfig.environment.capabilities.environmentIcon===!0?e.operateAccess===`granted`?null:`Your session on this environment cannot change its settings.`:`This environment's server is too old to keep an icon. Update it to choose one.`}function Fr(e){let t=(0,Z.c)(27),{environmentId:n,serverConfig:r}=e,i=st(n),a=ft(n,`settings:write`)?`granted`:`denied`,o;t[0]!==a||t[1]!==r?(o=Pr({serverConfig:r,operateAccess:a}),t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c=r?.environment.platform.machine??`server`,l;t[3]===r?l=t[4]:(l=h(r),t[3]=r,t[4]=l);let u=l,d;t[5]===u?d=t[6]:(d=(0,Q.jsxs)(xe,{children:[(0,Q.jsx)(sn,{kind:u}),`Icon`]}),t[5]=u,t[6]=d);let f;t[7]===s?f=t[8]:(f=s===null?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{disabled:!0,className:`whitespace-normal`,children:s}),(0,Q.jsx)(z,{})]}),t[7]=s,t[8]=f);let g;t[9]!==c||t[10]!==s||t[11]!==i?(g=e=>{s===null&&p(e)&&i({environmentIcon:e===c?null:e})},t[9]=c,t[10]=s,t[11]=i,t[12]=g):g=t[12];let _;t[13]!==c||t[14]!==s||t[15]!==r?.environment?(_=m.map(e=>(0,Q.jsx)(ie,{value:e,disabled:s!==null,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(sn,{kind:e,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:cn[e]}),e===c?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:r?.environment.platform.machine?`detected`:`default`}):null]})},e)),t[13]=c,t[14]=s,t[15]=r?.environment,t[16]=_):_=t[16];let v;t[17]!==u||t[18]!==g||t[19]!==_?(v=(0,Q.jsx)(B,{value:u,onValueChange:g,children:_}),t[17]=u,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==f||t[22]!==v?(y=(0,Q.jsxs)(oe,{children:[f,v]}),t[21]=f,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==d||t[25]!==y?(b=(0,Q.jsxs)(k,{children:[d,y]}),t[24]=d,t[25]=y,t[26]=b):b=t[26],b}function Ir(e){let t=(0,Z.c)(31),{environment:n,onAddRoute:r}=e,i=Ne(n.entry),a=i.map(Rr),[o,s]=(0,$.useState)(null),c=o!==null&&o.length===a.length&&o.some((e,t)=>e!==a[t])?[...o]:a,l=new Map(i.map(Lr)),u=c.flatMap(e=>l.get(e)??[]),d=ht(n.environmentId),f;t[0]!==n.connection||t[1]!==d._tag||t[2]!==d.value?(f=d._tag===`Some`&&n.connection.phase===`connected`?U(d.value.target):null,t[0]=n.connection,t[1]=d._tag,t[2]=d.value,t[3]=f):f=t[3];let p=f,m=_t(lt.reorderRoutes,`Reorder routes`),h=_t(lt.removeRoute,`Remove route`),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g={activationConstraint:{distance:4}},t[4]=g):g=t[4];let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_={coordinateGetter:Vn},t[5]=_):_=t[5];let v=Hn(qn(Wn,g),qn(fr,_)),y;t[6]!==n.environmentId||t[7]!==h?(y=async e=>{let t=De(e);await at(`Remove ${W(e)} route?${t===null?``:`\n${t}`}`,{variant:`destructive`})===!0&&await h({environmentId:n.environmentId,routeId:U(e.target)})},t[6]=n.environmentId,t[7]=h,t[8]=y):y=t[8];let b=y,x=e=>{if(e.over===null||e.active.id===e.over.id)return;let t=Qn(c,c.indexOf(String(e.active.id)),c.indexOf(String(e.over.id)));s(t),m({environmentId:n.environmentId,routeIds:t}).then(e=>{e._tag===`Failure`&&s(null)})},S=Ln,C=Gn,w;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=[Bn,Xn],t[9]=w):w=t[9];let T=Cr,E=pr,D=`Routes to ${n.label}, preferred first`,O=u.map((e,t)=>(0,Q.jsx)(zr,{route:e,position:t+1,inUse:U(e.target)===p,removable:u.length>1&&!K(e),onRemove:()=>void b(e)},U(e.target))),k;t[10]!==O||t[11]!==D?(k=(0,Q.jsx)(`ol`,{"aria-label":D,children:O}),t[10]=O,t[11]=D,t[12]=k):k=t[12];let A;t[13]!==T||t[14]!==c||t[15]!==k||t[16]!==E?(A=(0,Q.jsx)(T,{items:c,strategy:E,children:k}),t[13]=T,t[14]=c,t[15]=k,t[16]=E,t[17]=A):A=t[17];let j;t[18]!==S||t[19]!==x||t[20]!==v||t[21]!==A||t[22]!==C||t[23]!==w?(j=(0,Q.jsx)(S,{sensors:v,collisionDetection:C,modifiers:w,onDragEnd:x,children:A}),t[18]=S,t[19]=x,t[20]=v,t[21]=A,t[22]=C,t[23]=w,t[24]=j):j=t[24];let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(le,{className:`size-3`}),t[25]=M):M=t[25];let N;t[26]===r?N=t[27]:(N=(0,Q.jsx)(`div`,{className:`-ml-1.5 pt-1`,children:(0,Q.jsxs)(L,{size:`xs`,variant:`ghost-muted`,onClick:r,children:[M,`Add route`]})}),t[26]=r,t[27]=N);let P;return t[28]!==j||t[29]!==N?(P=(0,Q.jsxs)(`div`,{className:`mt-2 border-t border-border/50 py-2`,children:[j,N]}),t[28]=j,t[29]=N,t[30]=P):P=t[30],P}function Lr(e){return[U(e.target),e]}function Rr(e){return U(e.target)}function zr(e){let t=(0,Z.c)(43),{route:n,position:r,inUse:i,removable:a,onRemove:o}=e,s;t[0]===n.target?s=t[1]:(s=U(n.target),t[0]=n.target,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=W(n),t[2]=n,t[3]=l);let u=l,d;t[4]===n?d=t[5]:(d=De(n),t[4]=n,t[5]=d);let p=d,m;t[6]===c?m=t[7]:(m={id:c},t[6]=c,t[7]=m);let{attributes:h,listeners:g,setNodeRef:_,setActivatorNodeRef:v,transform:y,transition:b,isDragging:x}=Kn(m),S;t[8]===y?S=t[9]:(S=Un.Translate.toString(y),t[8]=y,t[9]=S);let C;t[10]!==S||t[11]!==b?(C={transform:S,transition:b},t[10]=S,t[11]=b,t[12]=C):C=t[12];let w=x&&`relative z-10 rounded-md bg-background shadow-md`,T;t[13]===w?T=t[14]:(T=be(`flex items-center gap-2 py-2`,w),t[13]=w,t[14]=T);let E;t[15]===i?E=t[16]:(E=i?(0,Q.jsx)(`span`,{className:`rounded-sm bg-success/12 px-1 text-2xs font-normal text-success-foreground`,children:`In use`}):null,t[15]=i,t[16]=E);let D;t[17]!==u||t[18]!==E?(D=(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[u,E]}),t[17]=u,t[18]=E,t[19]=D):D=t[19];let O;t[20]!==p||t[21]!==n?(O=p===null?null:(0,Q.jsxs)(`p`,{className:`truncate text-2xs text-muted-foreground`,children:[p,K(n)?` · found automatically`:``]}),t[20]=p,t[21]=n,t[22]=O):O=t[22];let k;t[23]!==D||t[24]!==O?(k=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O]}),t[23]=D,t[24]=O,t[25]=k):k=t[25];let A=`Reorder ${u}, position ${r}`,j;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(f,{className:`size-3.5`}),t[26]=j):j=t[26];let M;t[27]!==h||t[28]!==g||t[29]!==v||t[30]!==A?(M=(0,Q.jsx)(`button`,{type:`button`,ref:v,...h,...g,"aria-label":A,className:`flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground/70 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:cursor-grabbing`,children:j}),t[27]=h,t[28]=g,t[29]=v,t[30]=A,t[31]=M):M=t[31];let N;t[32]!==u||t[33]!==o||t[34]!==a?(N=a?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Remove ${u} route`,onClick:o}),children:(0,Q.jsx)(H,{className:`size-3`})}),(0,Q.jsx)(St,{side:`top`,children:`Remove route`})]}):null,t[32]=u,t[33]=o,t[34]=a,t[35]=N):N=t[35];let P;return t[36]!==_||t[37]!==k||t[38]!==M||t[39]!==N||t[40]!==C||t[41]!==T?(P=(0,Q.jsxs)(`li`,{ref:_,style:C,className:T,children:[k,M,N]}),t[36]=_,t[37]=k,t[38]=M,t[39]=N,t[40]=C,t[41]=T,t[42]=P):P=t[42],P}function Br(e){let t=e.username?`${e.username}@${e.hostname}`:e.hostname;return e.port?`${t}:${e.port}`:t}function Vr(e,t=null){let{entry:n}=e;if(n.target._tag===`PrimaryConnectionTarget`)return`This machine`;let r=Ne(n);if(r.length>1){let e=t===null?void 0:r.find(e=>U(e.target)===U(t));return e===void 0?W(r[0]):`via ${W(e)}`}return e.relayManaged?`P4 Connect`:Ue(n.target)?`WSL`:n.target._tag===`SshConnectionTarget`&&Te(n.profile)&&n.profile.value._tag===`SshConnectionProfile`?`SSH ${Br(n.profile.value.target)}`:e.displayUrl??`Remote link`}function Hr(e){let t=(0,Z.c)(23),{kind:n,label:r,subtitle:i,below:a,detail:o,dimmed:s,className:c,children:l}=e,u=s!==void 0&&s&&`opacity-60`,d;t[0]!==c||t[1]!==u?(d=be(`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 px-3 py-2.5 sm:px-4`,u,c),t[0]=c,t[1]=u,t[2]=d):d=t[2];let f;t[3]===n?f=t[4]:(f=(0,Q.jsx)(sn,{"aria-hidden":!0,kind:n,className:`size-4 text-muted-foreground`}),t[3]=n,t[4]=f);let p;t[5]===r?p=t[6]:(p=(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:r}),t[5]=r,t[6]=p);let m;t[7]===i?m=t[8]:(m=(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:i}),t[7]=i,t[8]=m);let h;t[9]!==a||t[10]!==p||t[11]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[p,m,a]}),t[9]=a,t[10]=p,t[11]=m,t[12]=h):h=t[12];let g;t[13]===l?g=t[14]:(g=(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:l}),t[13]=l,t[14]=g);let _;t[15]===o?_=t[16]:(_=o?(0,Q.jsx)(`div`,{className:`col-span-2 col-start-2 min-w-0`,children:o}):null,t[15]=o,t[16]=_);let v;return t[17]!==d||t[18]!==f||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,Q.jsxs)(`div`,{className:d,children:[f,h,g,_]}),t[17]=d,t[18]=f,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var Ur=(e,t)=>J.add(vt({type:`error`,title:e,description:t}));function Wr(e){let t=(0,Z.c)(19),{environmentId:n,environmentLabel:r,isSearchTarget:i}=e,a;t[0]===n?a=t[1]:(a=cr.list({environmentId:n,input:{}}),t[0]=n,t[1]=a);let o=gt(a),s;t[2]===n?s=t[3]:(s=cr.link.permissionAtom(n),t[2]=n,t[3]=s);let c=de(s),l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=Rn(`linked-environments`),t[4]=l):l=t[4];let u=l,d;t[5]===i?d=t[6]:(d=i?{id:u.id}:{},t[5]=i,t[6]=d);let f=r===null?u.title:`${u.title} · ${r}`,p;t[7]!==c||t[8]!==n?(p=c?(0,Q.jsx)(Kr,{environmentId:n}):null,t[7]=c,t[8]=n,t[9]=p):p=t[9];let m;t[10]!==n||t[11]!==o.data||t[12]!==o.error?(m=o.error?(0,Q.jsx)(vn,{title:`Could not load linked environments`,description:o.error}):o.data?o.data.links.length===0?(0,Q.jsx)(vn,{title:`No linked environments`,description:`Link another machine running P4 Code, such as a VPS, so agents here can launch and drive threads there.`}):o.data.links.map(e=>(0,Q.jsx)(Gr,{environmentId:n,link:e},e.environmentId)):(0,Q.jsx)(vn,{title:`Loading linked environments…`,role:`status`}),t[10]=n,t[11]=o.data,t[12]=o.error,t[13]=m):m=t[13];let h;return t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(h=(0,Q.jsx)(bn,{...d,title:f,headerAction:p,children:m}),t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h):h=t[18],h}function Gr(e){let t=(0,Z.c)(37),{environmentId:n,link:r}=e,i=rn(),a;t[0]!==r||t[1]!==i?(a=ur(r,d(i)),t[0]=r,t[1]=i,t[2]=a):a=t[2];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={label:`unlink environment`},t[3]=s):s=t[3];let c=_t(cr.unlink,s),l;t[4]===n?l=t[5]:(l=cr.unlink.permissionAtom(n),t[4]=n,t[5]=l);let u=de(l),[f,p]=(0,$.useState)(!1),m;t[6]!==n||t[7]!==r.environmentId||t[8]!==r.label||t[9]!==c?(m=async()=>{if(!await(at(`Forget ${r.label}? Agents here stop working there. Revoke "P4 Code · …" in ${r.label}'s Connections to end the session there too.`,{variant:`destructive`})??Promise.resolve(!1)))return;p(!0);let e=await c({environmentId:n,input:{environmentId:r.environmentId}});p(!1),e._tag===`Failure`&&!je(e)&&Ur(`Could not forget the link`,String(Me(e)))},t[6]=n,t[7]=r.environmentId,t[8]=r.label,t[9]=c,t[10]=m):m=t[10];let h=m,g=o.kind===`expired`?`Expired. Link it again with a new pairing code.`:o.kind===`unreachable`?o.detail??`Not answering right now.`:o.kind===`failing`?o.detail:o.expiresInDays===null?`Reachable`:`Expires in ${o.expiresInDays} ${o.expiresInDays===1?`day`:`days`}. Link it again to renew.`,_=o.kind===`reachable`?o.expiresInDays===null?`bg-success`:`bg-warning`:o.kind===`expired`||o.kind===`failing`?`bg-destructive`:`bg-muted-foreground/30`,v;t[11]!==g||t[12]!==_?(v=(0,Q.jsx)(On,{tooltipText:g,dotClassName:_,pingClassName:null}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===r.label?y=t[15]:(y=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:r.label}),t[14]=r.label,t[15]=y);let b;t[16]!==v||t[17]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[v,y]}),t[16]=v,t[17]=y,t[18]=b):b=t[18];let x=Er[r.access],S;t[19]!==g||t[20]!==x.label?(S=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[x.label,` · `,g]}),t[19]=g,t[20]=x.label,t[21]=S):S=t[21];let C;t[22]===r.urls?C=t[23]:(C=r.urls.join(`, `),t[22]=r.urls,t[23]=C);let w;t[24]===C?w=t[25]:(w=(0,Q.jsx)(`p`,{className:`truncate text-xs text-muted-foreground/80`,children:C}),t[24]=C,t[25]=w);let T;t[26]!==S||t[27]!==w||t[28]!==b?(T=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[b,S,w]}),t[26]=S,t[27]=w,t[28]=b,t[29]=T):T=t[29];let E;t[30]!==f||t[31]!==u||t[32]!==h?(E=u?(0,Q.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:f,onClick:()=>void h(),children:f?`Forgetting…`:`Forget`})}):null,t[30]=f,t[31]=u,t[32]=h,t[33]=E):E=t[33];let D;return t[34]!==T||t[35]!==E?(D=(0,Q.jsx)(`div`,{className:br,children:(0,Q.jsxs)(`div`,{className:or,children:[T,E]})}),t[34]=T,t[35]=E,t[36]=D):D=t[36],D}function Kr(e){let t=(0,Z.c)(84),{environmentId:n}=e,[r,a]=(0,$.useState)(!1),o=yr(n,r),[s,c]=(0,$.useState)(null),[l,u]=(0,$.useState)(``),[d,f]=(0,$.useState)(``),[p,m]=(0,$.useState)(`approval-required`),[h,g]=(0,$.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=new Set,t[0]=_):_=t[0];let[v,y]=(0,$.useState)(_),b=(0,$.useRef)(!1),x=(0,$.useId)(),S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S={label:`link environment`},t[1]=S):S=t[1];let C=_t(cr.link,S),T=s??(o.length===0?`another-address`:null),E;t[2]!==o||t[3]!==T?(E=o.find(e=>e.environmentId===T)??null,t[2]=o,t[3]=T,t[4]=E):E=t[4];let O=E,k=O?.environmentId??null,A=ht(k),j=ft(k,w),M;t[5]!==A||t[6]!==j||t[7]!==v||t[8]!==k?(M=k!==null&&Te(A)&&j&&!v.has(k),t[5]=A,t[6]=j,t[7]=v,t[8]=k,t[9]=M):M=t[9];let N=M,P=T===`another-address`||O?.urls.length===0,F;t[10]!==l||t[11]!==N||t[12]!==P||t[13]!==d||t[14]!==T?(F=T!==null&&(!P||l.trim().length>0)&&(N||d.trim().length>0),t[10]=l,t[11]=N,t[12]=P,t[13]=d,t[14]=T,t[15]=F):F=t[15];let ee=F,I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{a(e),e||(c(null),u(``),f(``),m(`approval-required`),y(new Set))},t[16]=I):I=t[16];let te=I,ne;t[17]!==p||t[18]!==N||t[19]!==d||t[20]!==k?(ne=async()=>{if(!N||k===null)return d.trim();let e=await Xt(k,p);return D(e)?e.success:(y(e=>new Set(e).add(k)),Ur(`Could not link the environment`,ar(e.failure)),null)},t[17]=p,t[18]=N,t[19]=d,t[20]=k,t[21]=ne):ne=t[21];let re=ne,ie;t[22]!==p||t[23]!==l||t[24]!==n||t[25]!==C||t[26]!==O||t[27]!==P||t[28]!==ee||t[29]!==re?(ie=async()=>{let[e,...t]=O===null||P?[l.trim()]:O.urls;if(b.current||!ee||e===void 0)return;b.current=!0,g(!0);let r=await re(),i=r===null?null:await C({environmentId:n,input:{url:e,...t.length>0?{alternateUrls:t}:{},...O===null?{}:{expectedEnvironmentId:O.environmentId,expectedLabel:O.label},pairingCode:r,access:p}});b.current=!1,g(!1),i!==null&&(i._tag===`Success`?(J.add({type:`success`,title:`Linked ${i.value.label}`}),te(!1)):je(i)||Ur(`Could not link the environment`,String(Me(i))))},t[22]=p,t[23]=l,t[24]=n,t[25]=C,t[26]=O,t[27]=P,t[28]=ee,t[29]=re,t[30]=ie):ie=t[30];let ae=ie,oe;t[31]===h?oe=t[32]:(oe=e=>{(e||!h)&&te(e)},t[31]=h,t[32]=oe);let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`default`,children:[(0,Q.jsx)(i,{className:`size-3`}),`Link`]})}),t[33]=R):R=t[33];let se;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Link an environment`}),(0,Q.jsx)(Nt,{children:`Agents here can then launch, message and wait on threads there. It appears in that environment's Connections, where it can be revoked.`})]}),t[34]=se):se=t[34];let ce;t[35]===ae?ce=t[36]:(ce=e=>{e.preventDefault(),ae()},t[35]=ae,t[36]=ce);let le;t[37]!==h||t[38]!==o||t[39]!==T?(le=o.length>0?(0,Q.jsx)(en,{machines:o,value:T,disabled:h,onChange:c}):null,t[37]=h,t[38]=o,t[39]=T,t[40]=le):le=t[40];let ue;t[41]===O?.linked?ue=t[42]:(ue=O?.linked?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Already linked. Linking again renews it with the access you pick.`}):null,t[41]=O?.linked,t[42]=ue);let de;t[43]!==l||t[44]!==h||t[45]!==s||t[46]!==O||t[47]!==o.length||t[48]!==P?(de=P?(0,Q.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:`Address`}),(0,Q.jsx)(Tt,{value:l,onChange:e=>{u(e.target.value),s===null&&c(nn)},placeholder:`https://box.example.ts.net`,disabled:h,autoFocus:o.length===0,nativeInput:!0,spellCheck:!1}),O===null?null:(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`This app has no address for `,O.label,` that another machine can reach. Enter its https or Tailscale address.`]})]}):null,t[43]=l,t[44]=h,t[45]=s,t[46]=O,t[47]=o.length,t[48]=P,t[49]=de):de=t[49];let fe;t[50]!==h||t[51]!==N||t[52]!==O||t[53]!==d||t[54]!==T?(fe=T===null||N?null:(0,Q.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:`Pairing code`}),(0,Q.jsx)(Tt,{value:d,onChange:e=>f(e.target.value),placeholder:O===null?`From that environment's Connections, or p4c pair there`:`Paste the code`,disabled:h,autoComplete:`one-time-code`,nativeInput:!0,spellCheck:!1}),O===null?null:(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Create a link on `,O.label,`: Settings → Connections → Create link, then paste its code here.`]})]}),t[50]=h,t[51]=N,t[52]=O,t[53]=d,t[54]=T,t[55]=fe):fe=t[55];let z;t[56]!==p||t[57]!==h?(z=(0,Q.jsx)(Qt,{value:p,onChange:m,disabled:h}),t[56]=p,t[57]=h,t[58]=z):z=t[58];let pe;t[59]!==x||t[60]!==ce||t[61]!==le||t[62]!==ue||t[63]!==de||t[64]!==fe||t[65]!==z?(pe=(0,Q.jsx)(Mt,{children:(0,Q.jsxs)(`form`,{id:x,className:`space-y-4`,autoComplete:`off`,onSubmit:ce,children:[le,ue,de,fe,z]})}),t[59]=x,t[60]=ce,t[61]=le,t[62]=ue,t[63]=de,t[64]=fe,t[65]=z,t[66]=pe):pe=t[66];let me;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Q.jsx)(L,{variant:`outline`,type:`button`}),t[67]=me):me=t[67];let he;t[68]===h?he=t[69]:(he=(0,Q.jsx)(jt,{disabled:h,render:me,children:`Cancel`}),t[68]=h,t[69]=he);let ge=h||!ee,_e=h?`Linking…`:`Link`,B;t[70]!==x||t[71]!==ge||t[72]!==_e?(B=(0,Q.jsx)(L,{form:x,type:`submit`,disabled:ge,children:_e}),t[70]=x,t[71]=ge,t[72]=_e,t[73]=B):B=t[73];let V;t[74]!==he||t[75]!==B?(V=(0,Q.jsxs)(kt,{variant:`bare`,children:[he,B]}),t[74]=he,t[75]=B,t[76]=V):V=t[76];let ve;t[77]!==pe||t[78]!==V?(ve=(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[se,pe,V]}),t[77]=pe,t[78]=V,t[79]=ve):ve=t[79];let ye;return t[80]!==r||t[81]!==ve||t[82]!==oe?(ye=(0,Q.jsxs)(Ft,{open:r,onOpenChange:oe,children:[R,ve]}),t[80]=r,t[81]=ve,t[82]=oe,t[83]=ye):ye=t[83],ye}function qr(){let e=(0,Z.c)(13),{environments:t}=nt(),n;e[0]===t?n=e[1]:(n=t.filter(Jr),e[0]=t,e[1]=n);let r=n,i=mt(r,R),a=_t(ct.updateSettings,`Linked environments beta update`),o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Rn(`linked-environments-beta`),e[2]=o):o=e[2];let s=o;if(r.length===0)return null;let c=s.id,l=s.title,u;if(e[3]!==r||e[4]!==a||e[5]!==i){let t;e[7]!==r.length||e[8]!==a||e[9]!==i?(t=e=>(0,Q.jsx)(vn,{title:r.length>1?e.label:`Linked environments`,description:`Let agents here work on your other machines, and theirs here. Turn it on for each machine, then link them below. While it is off, nothing new starts over a link; tasks already running finish.`,control:(0,Q.jsx)(lr,{checked:e.serverConfig?.settings.linkedEnvironmentsEnabled===!0,disabled:!i.has(e.environmentId),onCheckedChange:t=>void a({environmentId:e.environmentId,input:{patch:{linkedEnvironmentsEnabled:!!t}}}),"aria-label":`Linked environments on ${e.label}`})},e.environmentId),e[7]=r.length,e[8]=a,e[9]=i,e[10]=t):t=e[10],u=r.map(t),e[3]=r,e[4]=a,e[5]=i,e[6]=u}else u=e[6];let d;return e[11]===u?d=e[12]:(d=(0,Q.jsx)(bn,{id:c,title:l,children:u}),e[11]=u,e[12]=d),d}function Jr(e){return e.connection.phase===`connected`&&e.serverConfig?.environment.capabilities.peerLinks===!0}var Yr=[{value:100,label:`Prefer`},{value:50,label:`Normal`},{value:25,label:`Less often`},{value:0,label:`Manual only`}];function Xr(e){return e===void 0||e===50?50:e===0?0:e<50?25:100}function Zr(e){return Yr.find(t=>t.value===e).label}function Qr(e,t){let n=e.flatMap(e=>{let n=Xr(t[e.environmentId]);return n===50?[]:[`${e.label} ${Zr(n).toLowerCase()}`]});return n.length===0?null:n.join(` · `)}function $r(e){let t=(0,Z.c)(27),{environments:n}=e,r=ot(),i=it(),a=rt();if(n.length<2)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=Rn(`load-balancing`),t[0]=o):o=t[0];let{id:s,title:c}=o,l;t[1]!==n||t[2]!==r.loadBalancingEnabled||t[3]!==r.loadBalancingWeights?(l=r.loadBalancingEnabled?Qr(n,r.loadBalancingWeights):`Off`,t[1]=n,t[2]=r.loadBalancingEnabled,t[3]=r.loadBalancingWeights,t[4]=l):l=t[4];let u=!i,d;t[5]===a?d=t[6]:(d=e=>a({loadBalancingEnabled:e}),t[5]=a,t[6]=d);let f;t[7]!==r.loadBalancingEnabled||t[8]!==u||t[9]!==d?(f=(0,Q.jsx)(lr,{"aria-label":`Automatically balance load`,checked:r.loadBalancingEnabled,disabled:u,onCheckedChange:d}),t[7]=r.loadBalancingEnabled,t[8]=u,t[9]=d,t[10]=f):f=t[10];let p;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`p`,{className:`px-3 py-2.5 text-xs text-muted-foreground sm:px-4`,children:`New threads in shared projects start on the machine with the most free CPU and memory, weighted by each machine's preference.`}),t[11]=p):p=t[11];let m;if(t[12]!==n||t[13]!==r.loadBalancingEnabled||t[14]!==r.loadBalancingWeights||t[15]!==i||t[16]!==a){let e;t[18]!==r.loadBalancingEnabled||t[19]!==r.loadBalancingWeights||t[20]!==i||t[21]!==a?(e=e=>(0,Q.jsx)(Hr,{kind:h(e.serverConfig),label:e.label,subtitle:Vr(e),children:(0,Q.jsxs)(Ze,{items:Yr,value:Xr(r.loadBalancingWeights[e.environmentId]),disabled:!i||!r.loadBalancingEnabled,onValueChange:t=>{t!==null&&a({loadBalancingWeights:{...r.loadBalancingWeights,[e.environmentId]:t}})},children:[(0,Q.jsx)(Xe,{size:`xs`,className:`w-32`,"aria-label":`${e.label} load preference`,children:(0,Q.jsx)(Je,{})}),(0,Q.jsx)(Ye,{align:`end`,alignItemWithTrigger:!1,children:Yr.map(ei)})]})},e.environmentId),t[18]=r.loadBalancingEnabled,t[19]=r.loadBalancingWeights,t[20]=i,t[21]=a,t[22]=e):e=t[22],m=n.map(e),t[12]=n,t[13]=r.loadBalancingEnabled,t[14]=r.loadBalancingWeights,t[15]=i,t[16]=a,t[17]=m}else m=t[17];let g;return t[23]!==l||t[24]!==f||t[25]!==m?(g=(0,Q.jsxs)(Dr,{id:s,title:c,summary:l,control:f,children:[p,m]}),t[23]=l,t[24]=f,t[25]=m,t[26]=g):g=t[26],g}function ei(e){let{value:t,label:n}=e;return(0,Q.jsx)(qe,{value:t,children:n},t)}var ti=[{value:`off`,label:`Off`},{value:`read`,label:`Read PRs`},{value:`read-write`,label:`Read and act`}],ni={"read-write":`read and act`,read:`read PRs`};function ri(e){let t=[`read-write`,`read`].flatMap(t=>{let n=e.filter(e=>e.permission===t);return n.length===0?[]:[`${n.map(e=>e.label).join(`, `)} ${ni[t]}`]});return t.length===0?null:t.join(` · `)}function ii(e){let t=(0,Z.c)(19),{environments:n}=e,r=de(lt.githubRoutingPermissionsValueAtom),i=de(lt.catalogValueAtom),a=_t(lt.setGitHubRoutingPermission),[o,s]=(0,$.useState)(!1);if(n.length<2)return null;let c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Rn(`github-routing`),t[0]=c):c=t[0];let{id:l,title:u}=c,d;t[1]!==n||t[2]!==r?(d=ri(n.map(e=>({label:e.label,permission:G(e.entry,r)})))??`Off`,t[1]=n,t[2]=r,t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`p`,{className:`px-3 py-2.5 text-xs text-muted-foreground sm:px-4`,children:`Machines you trust here can read PR data through each other's GitHub access. Enable both machines. Read and act may use broader permissions than the machine that owns them. This applies only to this device.`}),t[4]=f):f=t[4];let p;if(t[5]!==i||t[6]!==n||t[7]!==r||t[8]!==o||t[9]!==a){let e;t[11]!==i||t[12]!==r||t[13]!==o||t[14]!==a?(e=e=>(0,Q.jsx)(Hr,{kind:h(e.serverConfig),label:e.label,subtitle:Vr(e),children:(0,Q.jsxs)(Ze,{items:ti,value:G(e.entry,r),disabled:!i.isReady||o||ke(e.entry)===null,onValueChange:t=>{t!==null&&(s(!0),a({environmentId:e.environmentId,permission:t}).then(e=>{s(!1),e._tag===`Failure`&&J.add({type:`error`,title:`Could not save GitHub routing permission`})}))},children:[(0,Q.jsx)(Xe,{size:`xs`,className:`w-32`,"aria-label":`${e.label} GitHub routing`,children:(0,Q.jsx)(Je,{})}),(0,Q.jsx)(Ye,{align:`end`,alignItemWithTrigger:!1,children:ti.map(ai)})]})},e.environmentId),t[11]=i,t[12]=r,t[13]=o,t[14]=a,t[15]=e):e=t[15],p=n.map(e),t[5]=i,t[6]=n,t[7]=r,t[8]=o,t[9]=a,t[10]=p}else p=t[10];let m;return t[16]!==d||t[17]!==p?(m=(0,Q.jsxs)(Dr,{id:l,title:u,summary:d,children:[f,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18],m}function ai(e){let{value:t,label:n}=e;return(0,Q.jsx)(qe,{value:t,children:n},t)}function oi(e){let t=(0,Z.c)(26),{environmentLabel:n,onCancel:r,onConfirm:i}=e,a=It(),[o,s]=(0,$.useState)(n);n!==null&&n!==o&&s(n);let c=a.open,l=n!==null,u;t[0]===r?u=t[1]:(u=e=>{e||r()},t[0]=r,t[1]=u);let d;t[2]===o?d=t[3]:(d=(0,Q.jsxs)(gn,{children:[`Remove `,o,` from this device?`]}),t[2]=o,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(hn,{children:`This forgets its pairing, credentials, and cached threads here.`}),t[4]=f):f=t[4];let p;t[5]!==r||t[6]!==c?(p=c?(0,Q.jsx)(he,{onClick:()=>{r(),c()},children:`P4 Connect settings`}):`P4 Connect settings`,t[5]=r,t[6]=c,t[7]=p):p=t[7];let m;t[8]===p?m=t[9]:(m=(0,Q.jsxs)(hn,{children:[`It stays on your P4 Connect account and keeps its host space. Deregister it in`,` `,p,` `,`to free it.`]}),t[8]=p,t[9]=m);let h;t[10]!==d||t[11]!==m?(h=(0,Q.jsxs)(dn,{children:[d,f,m]}),t[10]=d,t[11]=m,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(pn,{render:(0,Q.jsx)(L,{variant:`outline`}),children:`Cancel`}),t[13]=g):g=t[13];let _;t[14]===i?_=t[15]:(_=(0,Q.jsxs)(fn,{children:[g,(0,Q.jsx)(L,{variant:`destructive`,onClick:i,children:`Remove from this device`})]}),t[14]=i,t[15]=_);let v;t[16]!==h||t[17]!==_?(v=(0,Q.jsxs)(mn,{children:[h,_]}),t[16]=h,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==l||t[20]!==v||t[21]!==u?(y=(0,Q.jsx)(_n,{open:l,onOpenChange:u,children:v}),t[19]=l,t[20]=v,t[21]=u,t[22]=y):y=t[22];let b;return t[23]!==a.portals||t[24]!==y?(b=(0,Q.jsxs)(Q.Fragment,{children:[y,a.portals]}),t[23]=a.portals,t[24]=y,t[25]=b):b=t[25],b}var si={pairingLinks:[],clientSessions:[]};function ci(e,t,n){let r=n(t);return[...e.filter(e=>n(e)!==r),t]}function li(e,t){switch(t.type){case`snapshot`:return t.payload;case`pairingLinkUpserted`:return{...e,pairingLinks:ci(e.pairingLinks,t.payload,e=>e.id)};case`pairingLinkRemoved`:return{...e,pairingLinks:e.pairingLinks.filter(e=>e.id!==t.payload.id)};case`clientUpserted`:return{...e,clientSessions:ci(e.clientSessions,t.payload,e=>e.sessionId)};case`clientRemoved`:return{...e,clientSessions:e.clientSessions.filter(e=>e.sessionId!==t.payload.sessionId)}}}function ui(e,t){let n=li(e,t);return[n,[{version:1,revision:t.revision,type:`snapshot`,payload:n}]]}function di(e){return{accessChanges:Oe(e,{label:`environment-data:server:auth-access-changes`,subscribe:e=>Ie(T.subscribeAuthAccess,{}).pipe(l(()=>si,ui))})}}var fi=di(Ke),pi=3e4,mi=class extends Ee()(`DesktopNetworkAccessUnavailableError`,{}){get message(){return`Desktop network access is unavailable.`}},hi=class extends Ee()(`DesktopServerExposureStateLoadError`,{cause:ce()}){get message(){return`Failed to load desktop server exposure state.`}},gi=class extends Ee()(`DesktopAdvertisedEndpointsLoadError`,{cause:ce()}){get message(){return`Failed to load advertised desktop endpoints.`}};function _i(){return typeof window>`u`?void 0:window.desktopBridge}function vi(e){let t=I(`loadDesktopNetworkAccess`)(function*(){let t=e();if(!t)return yield*new mi;let[n,r]=yield*g([s({try:()=>t.getServerExposureState(),catch:e=>new hi({cause:e})}),s({try:()=>t.getAdvertisedEndpoints(),catch:e=>new gi({cause:e})})],{concurrency:`unbounded`});return{advertisedEndpoints:r,serverExposureState:n}});return A(t()).pipe(se({staleTime:pi,revalidateOnMount:!0}),ve,E(`desktop:network-access`))}var yi=vi(_i);function bi(){v.refresh(yi)}function xi(e,t){let n=t.trim().toLowerCase();if(n.length===0)return e;let r=[],i=[];for(let t of e){let e=t.alias.toLowerCase();e.startsWith(n)?r.push(t):e.includes(n)&&i.push(t)}return[...r,...i]}var Si=class extends Ee()(`DesktopSshDiscoveryUnavailableError`,{}){get message(){return`Desktop SSH host discovery is unavailable.`}},Ci=class extends Ee()(`DesktopSshDiscoveryError`,{cause:ce()}){get message(){return`Failed to discover SSH hosts.`}};function wi(){return typeof window>`u`?void 0:window.desktopBridge}function Ti(e){let t=I(`discoverDesktopSshHosts`)(function*(){let t=e();return t?yield*s({try:()=>t.discoverSshHosts(),catch:e=>new Ci({cause:e})}):yield*new Si});return A(t()).pipe(se({staleTime:3e4,revalidateOnMount:!0}),ve,E(`desktop:ssh-hosts`))}var Ei=Ti(wi),Di=443,Oi=[],ki=[],Ai=`backend:default-wsl`,ji=`backend:wsl-off`,Mi=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function Ni(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Mi.format(t)}function Pi(e){let t=(0,Z.c)(13),{scopes:n,label:r}=e,i=`${n.length} ${n.length===1?`scope`:`scopes`}`,a=`${r}: show ${i}`,o;t[0]===a?o=t[1]:(o=(0,Q.jsx)(`button`,{type:`button`,"aria-label":a,className:`cursor-help underline decoration-border underline-offset-2 outline-hidden hover:text-foreground focus-visible:text-foreground`}),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,Q.jsx)(Jt,{openOnHover:!0,delay:250,closeDelay:100,render:o,children:i}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`p`,{className:`mb-1 font-medium`,children:`Granted scopes`}),t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=n.map(Fi),t[6]=n,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,Q.jsxs)(qt,{side:`top`,align:`start`,tooltipStyle:!0,className:`w-max max-w-80 whitespace-normal`,children:[c,(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:l})]}),t[8]=l,t[9]=u);let d;return t[10]!==s||t[11]!==u?(d=(0,Q.jsxs)(Yt,{children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12],d}function Fi(e){return(0,Q.jsx)(`code`,{className:`font-mono text-foreground/85`,children:e},e)}function Ii(e){let t=e.host.trim();if(t.length===0)throw Error(`SSH host or alias is required.`);let n=t,r=e.username.trim()||null,i=null,a=n.lastIndexOf(`@`);if(a>0){let e=n.slice(0,a).trim();n=n.slice(a+1).trim(),!r&&e.length>0&&(r=e)}let o=/^\[([^\]]+)\](?::(\d+))?$/u.exec(n);if(o)n=o[1].trim(),o[2]&&(i=Number.parseInt(o[2],10));else{let e=n.split(`:`);e.length===2&&/^\d+$/u.test(e[1]??``)&&(n=e[0].trim(),i=Number.parseInt(e[1],10))}let s=e.port.trim();if(s.length>0&&(i=Number.parseInt(s,10)),n.length===0)throw Error(`SSH host or alias is required.`);if(i!==null&&(!Number.isInteger(i)||i<=0||i>65535))throw Error(`SSH port must be between 1 and 65535.`);return{alias:n,hostname:n,username:r,port:i}}function Li(e){let t=e.trim();if(!t)return null;try{let e=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//u.test(t)||t.startsWith(`//`)?t:`https://${t}`,n=new URL(e,window.location.origin),r=ze(n);if(r)return{host:r.host,pairingCode:r.token};let i=q(n);return i?{host:n.origin,pairingCode:i}:null}catch{return null}}function Ri(e){let t=Li(e.host);if(t)return t;let n=e.host.trim(),r=e.pairingCode.trim();if(!n)throw Error(`Enter a backend host.`);if(!r)throw Error(`Enter a pairing code.`);return{host:n,pairingCode:r}}function zi(e){let t=`Failed to connect SSH host.`;return(e instanceof Error?e.message:t).replace(/^Error invoking remote method 'desktop:ensure-ssh-environment':\s*/u,``).replace(/^Ssh[A-Za-z]+Error:\s*/u,``).trim()||t}var Bi=`first:rounded-t-xl last:rounded-b-xl px-3 py-2.5 sm:px-4`;function Vi(e){return br}function Hi(e,t){return e===`endpoint-rail`?be(`relative first:rounded-t-xl last:rounded-b-xl px-3 py-3 sm:px-4`,!t&&`bg-muted/15`):be(Bi,!t&&`bg-muted/24`)}function Ui(e){return[...e].toSorted((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())}function Wi(e,t){return[`${e.length} ${e.length===1?`client`:`clients`}`,t.length>0?`${t.length} ${t.length===1?`pairing link`:`pairing links`}`:null].filter(e=>e!==null).join(` · `)}function Gi(e){return[...e].toSorted((e,t)=>e.current===t.current?e.connected===t.connected?new Date(t.issuedAt).getTime()-new Date(e.issuedAt).getTime():e.connected?-1:1:e.current?-1:1)}function Ki(e){return{...e,scopes:e.permissions??e.scopes,createdAt:u(e.createdAt),expiresAt:u(e.expiresAt)}}function qi(e){return{...e,scopes:e.permissions??e.scopes,issuedAt:u(e.issuedAt),expiresAt:u(e.expiresAt),lastConnectedAt:e.lastConnectedAt===null?null:u(e.lastConnectedAt)}}function Ji(e,t){let n=e.filter(e=>e.status!==`unavailable`);if(t){let e=n.find(e=>Xi(e)===t);if(e)return e}return n.find(e=>e.isDefault)??n.find(e=>e.reachability!==`loopback`)??n.find(e=>e.compatibility.hostedHttpsApp===`compatible`)??null}function Yi(e){return e.id.startsWith(`tailscale-magicdns:`)}function Xi(e){if(e.id.startsWith(`desktop-loopback:`))return`desktop-core:loopback:http`;if(e.id.startsWith(`desktop-lan:`))return`desktop-core:lan:http`;if(e.id.startsWith(`tailscale-ip:`))return`tailscale:ip:http`;if(Yi(e))return`tailscale:magicdns:https`;let t=`unknown`;try{t=new URL(e.httpBaseUrl).protocol.replace(/:$/u,``)}catch{}return`${e.provider.id}:${e.reachability}:${t}:${e.label}`}function Zi(e,t){return e.compatibility.hostedHttpsApp===`compatible`?jr(e.httpBaseUrl,t)??Ar(e.httpBaseUrl,t):Ar(e.httpBaseUrl,t)}function Qi(e){let t=new URL(`/pair`,window.location.href);return Ve(t,e).toString()}function $i(e){try{let t=new URL(e);return t.pathname===`/pair`&&t.searchParams.has(`host`)}catch{return!1}}function ea(e,t){if($i(t))return`Opens the hosted app, no install needed`;switch(e.reachability){case`lan`:return`Devices on the same network`;case`private-network`:return`Devices on your private network`;case`public`:return`Reachable from anywhere`;case`loopback`:return`Clients on this machine`}}var ta=(0,$.memo)(function(e){let t=(0,Z.c)(135),{pairingLink:n,credential:r,endpointUrl:i,endpoints:a,defaultEndpointKey:o,presentation:s,revokingPairingLinkId:c,onRevoke:l,canRevoke:u}=e,d=s===void 0?`current`:s,f=X(1e3),p=new Date(n.expiresAt).getTime(),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(!1),[v,y]=(0,$.useState)(null),b=(0,$.useId)(),x;t[0]===r?x=t[1]:(x=r?Qi(r):null,t[0]=r,t[1]=x);let S=x,C;t[2]!==r||t[3]!==i?(C=r&&i!=null&&i!==``?jr(i,r):null,t[2]=r,t[3]=i,t[4]=C):C=t[4];let w=C,T;if(t[5]!==r||t[6]!==o||t[7]!==a){let e=Ji(a,o);T=e&&r?Zi(e,r):null,t[5]=r,t[6]=o,t[7]=a,t[8]=T}else T=t[8];let E=T,D;if(t[9]!==r||t[10]!==a){bb0:{let e=[];if(!r){D=e;break bb0}for(let t of a){if(t.status===`unavailable`)continue;let n=Zi(t,r);e.push({id:t.id,preferenceKey:Xi(t),label:t.label,url:n,detail:ea(t,n),qrShareable:xr(t)})}D=e}t[9]=r,t[10]=a,t[11]=D}else D=t[11];let O=D,k;t[12]!==r||t[13]!==S||t[14]!==E||t[15]!==i||t[16]!==w?(k=E??(r&&i!=null&&i!==``?w??Ar(i,r):Re(window.location.hostname)?null:S),t[12]=r,t[13]=S,t[14]=E,t[15]=i,t[16]=w,t[17]=k):k=t[17];let A=k,[j,M]=(0,$.useState)(null),N=j??A??r??``,P=N!==r,F=P&&$i(N),ee=O.find(e=>e.url===N)?.qrShareable??!0,I=typeof window<`u`&&window.isSecureContext&&navigator.clipboard?.writeText!=null,te;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(te={onCopy:wa,onError:(e,t)=>{let{value:n,kind:r}=t;M(n),h(!0),J.add(vt({type:`error`,title:I?r===`hosted-link`?`Could not copy hosted app link`:r===`link`?`Could not copy pairing URL`:`Could not copy pairing code`:`Clipboard copy unavailable`,description:I?e.message:`Showing the full value instead.`}))}},t[18]=te):te=t[18];let{copyToClipboard:ne}=$e(te),re;t[19]===ne?re=t[20]:(re=(e,t)=>{ne(e,{value:e,kind:t})},t[19]=ne,t[20]=re);let ie=re,ae=Ta,oe;t[21]!==ie||t[22]!==r?(oe=()=>{r&&ie(r,`code`)},t[21]=ie,t[22]=r,t[23]=oe):oe=t[23];let R=oe,se;t[24]===n.expiresAt?se=t[25]:(se=Ni(n.expiresAt),t[24]=n.expiresAt,t[25]=se);let ce=se,le=n.label??`Pairing link`,ue;t[26]!==o||t[27]!==O||t[28]!==v?(ue=hr(O,v,o),t[26]=o,t[27]=O,t[28]=v,t[29]=ue):ue=t[29];let de=ue,z=de?.url??A,pe=de?.qrShareable??!0;if(p<=f)return null;let me;t[30]===d?me=t[31]:(me=Vi(d),t[30]=d,t[31]=me);let he;t[32]===n.createdAt?he=t[33]:(he=Ni(n.createdAt),t[32]=n.createdAt,t[33]=he);let ge=`Link created at ${he}`,_e;t[34]===ge?_e=t[35]:(_e=(0,Q.jsx)(On,{tooltipText:ge,dotClassName:`bg-warning`}),t[34]=ge,t[35]=_e);let B;t[36]===le?B=t[37]:(B=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:le}),t[36]=le,t[37]=B);let V;t[38]!==_e||t[39]!==B?(V=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[_e,B]}),t[38]=_e,t[39]=B,t[40]=V):V=t[40];let ve;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(`span`,{}),t[41]=ve):ve=t[41];let ye;t[42]!==f||t[43]!==n.expiresAt?(ye=yt(n.expiresAt,f),t[42]=f,t[43]=n.expiresAt,t[44]=ye):ye=t[44];let H;t[45]===ye?H=t[46]:(H=(0,Q.jsx)(xt,{render:ve,children:ye}),t[45]=ye,t[46]=H);let xe;t[47]===ce?xe=t[48]:(xe=(0,Q.jsx)(St,{side:`top`,children:ce}),t[47]=ce,t[48]=xe);let Se;t[49]!==H||t[50]!==xe?(Se=(0,Q.jsxs)(Ct,{children:[H,xe]}),t[49]=H,t[50]=xe,t[51]=Se):Se=t[51];let Ce;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,Q.jsx)(`span`,{"aria-hidden":!0,children:` · `}),t[52]=Ce):Ce=t[52];let we;t[53]===n.scopes?we=t[54]:(we=(0,Q.jsx)(Pi,{scopes:n.scopes,label:`Pairing link scopes`}),t[53]=n.scopes,t[54]=we);let Te;t[55]!==Se||t[56]!==we?(Te=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Se,Ce,we]}),t[55]=Se,t[56]=we,t[57]=Te):Te=t[57];let Ee;t[58]!==r||t[59]!==A?(Ee=r?A===null?(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Copy the token and pair from another client using this backend's reachable host.`}):null:(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Create a new link to share from this client.`}),t[58]=r,t[59]=A,t[60]=Ee):Ee=t[60];let U;t[61]!==V||t[62]!==Te||t[63]!==Ee?(U=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[V,Te,Ee]}),t[61]=V,t[62]=Te,t[63]=Ee,t[64]=U):U=t[64];let De;t[65]!==g||t[66]!==b||t[67]!==A?(De=A&&I?(0,Q.jsxs)(L,{size:`xs`,variant:`outline`,"aria-expanded":g,"aria-controls":b,onClick:()=>_(Ea),children:[(0,Q.jsx)(fe,{"aria-hidden":!0}),`Share`]}):null,t[65]=g,t[66]=b,t[67]=A,t[68]=De):De=t[68];let Oe=r!==void 0&&m,ke;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>{h(e),e||M(null)},t[69]=ke):ke=t[69];let Ae;t[70]!==r||t[71]!==R||t[72]!==A?(Ae=r?I?A?null:(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:R,children:`Copy code`}):(0,Q.jsx)(At,{render:(0,Q.jsx)(L,{size:`xs`,variant:`outline`}),children:A?`Show link`:`Show code`}):null,t[70]=r,t[71]=R,t[72]=A,t[73]=Ae):Ae=t[73];let W=P?F?`Hosted app pairing link`:`Pairing link`:`Pairing code`,je;t[74]===W?je=t[75]:(je=(0,Q.jsx)(Ot,{children:W}),t[74]=W,t[75]=je);let G=P?F?`Clipboard copy is unavailable here. Open or manually copy this hosted app link on the device you want to connect.`:`Clipboard copy is unavailable here. Open or manually copy this full pairing URL on the device you want to connect.`:`Clipboard copy is unavailable here. Manually copy this code into another client.`,Me;t[76]===G?Me=t[77]:(Me=(0,Q.jsx)(Nt,{children:G}),t[76]=G,t[77]=Me);let K;t[78]!==je||t[79]!==Me?(K=(0,Q.jsxs)(Dt,{children:[je,Me]}),t[78]=je,t[79]=Me,t[80]=K):K=t[80];let Ne=P?4:3,Pe;t[81]!==N||t[82]!==Ne?(Pe=(0,Q.jsx)(wt,{readOnly:!0,value:N,rows:Ne,onFocus:Da,onClick:Oa}),t[81]=N,t[82]=Ne,t[83]=Pe):Pe=t[83];let Fe;t[84]!==ee||t[85]!==P||t[86]!==N?(Fe=P&&ee?(0,Q.jsx)(`div`,{className:`flex justify-center rounded-xl border border-border/60 bg-muted/30 p-4`,children:(0,Q.jsx)(Zn,{value:N,size:132,level:`M`,marginSize:2,title:`Pairing link — scan to open on another device`})}):null,t[84]=ee,t[85]=P,t[86]=N,t[87]=Fe):Fe=t[87];let Ie;t[88]!==Pe||t[89]!==Fe?(Ie=(0,Q.jsxs)(Mt,{children:[Pe,Fe]}),t[88]=Pe,t[89]=Fe,t[90]=Ie):Ie=t[90];let Le;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,Q.jsx)(L,{variant:`outline`,onClick:()=>h(!1),children:`Done`}),t[91]=Le):Le=t[91];let ze;t[92]===R?ze=t[93]:(ze=I?(0,Q.jsx)(L,{variant:`outline`,onClick:R,children:`Copy code`}):null,t[92]=R,t[93]=ze);let Be;t[94]===ze?Be=t[95]:(Be=(0,Q.jsxs)(kt,{variant:`bare`,children:[Le,ze]}),t[94]=ze,t[95]=Be);let Ve;t[96]!==K||t[97]!==Ie||t[98]!==Be?(Ve=(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[K,Ie,Be]}),t[96]=K,t[97]=Ie,t[98]=Be,t[99]=Ve):Ve=t[99];let q;t[100]!==Oe||t[101]!==Ae||t[102]!==Ve?(q=(0,Q.jsxs)(Ft,{open:Oe,onOpenChange:ke,children:[Ae,Ve]}),t[100]=Oe,t[101]=Ae,t[102]=Ve,t[103]=q):q=t[103];let He=!u||c===n.id,Ue;t[104]!==l||t[105]!==n.id?(Ue=()=>void l(n.id),t[104]=l,t[105]=n.id,t[106]=Ue):Ue=t[106];let We=c===n.id?`Revoking…`:`Revoke`,Ge;t[107]!==He||t[108]!==Ue||t[109]!==We?(Ge=(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:He,onClick:Ue,children:We}),t[107]=He,t[108]=Ue,t[109]=We,t[110]=Ge):Ge=t[110];let Ke;t[111]!==De||t[112]!==q||t[113]!==Ge?(Ke=(0,Q.jsxs)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:[De,q,Ge]}),t[111]=De,t[112]=q,t[113]=Ge,t[114]=Ke):Ke=t[114];let qe;t[115]!==U||t[116]!==Ke?(qe=(0,Q.jsxs)(`div`,{className:or,children:[U,Ke]}),t[115]=U,t[116]=Ke,t[117]=qe):qe=t[117];let Je=g&&z!==null,Ye;t[118]!==pe||t[119]!==ie||t[120]!==O||t[121]!==R||t[122]!==z||t[123]!==b||t[124]!==de?.id?(Ye=z===null?null:(0,Q.jsxs)(`div`,{id:b,className:`mt-3 flex flex-col gap-4 border-t border-border/50 pt-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[O.length>1?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,role:`radiogroup`,"aria-label":`Endpoint the pairing QR code and URL use`,children:[(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Reach this machine via`}),O.map(e=>{let t=e.id===de?.id;return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:be(`flex w-full items-baseline gap-2 rounded-lg border px-2.5 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t?`border-foreground/60 bg-muted/30`:`border-border/50 hover:bg-muted/20`),onClick:()=>y(e.id),children:[(0,Q.jsx)(`span`,{className:be(`text-xs font-medium`,t?`text-foreground`:`text-muted-foreground`),children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-2xs text-muted-foreground/70`,children:e.detail})]},e.id)})]}):null,(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-muted/30 px-2.5 py-1.5`,children:[(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-2xs text-muted-foreground`,children:z})}),(0,Q.jsx)(St,{side:`top`,children:z})]}),(0,Q.jsx)(L,{size:`xs`,variant:`ghost`,className:`shrink-0`,onClick:()=>ie(z,ae(z)),children:`Copy link`})]}),(0,Q.jsx)(L,{size:`xs`,variant:`ghost`,onClick:R,children:`Copy code only`})]}),pe?(0,Q.jsx)(`div`,{className:`w-fit shrink-0 self-center rounded-xl bg-white p-3 sm:self-start`,children:(0,Q.jsx)(Zn,{value:z,size:168,level:`M`,marginSize:1,title:`Pairing link — scan to open on another device`})}):(0,Q.jsx)(`div`,{className:`flex size-[192px] shrink-0 items-center justify-center self-center rounded-xl border border-border/50 p-4 sm:self-start`,children:(0,Q.jsx)(`p`,{className:`text-center text-2xs text-muted-foreground/70`,children:`No QR for this endpoint. Another device scanning a loopback link would dial itself; copy the URL for use on this machine instead.`})})]}),t[118]=pe,t[119]=ie,t[120]=O,t[121]=R,t[122]=z,t[123]=b,t[124]=de?.id,t[125]=Ye):Ye=t[125];let Xe;t[126]===Ye?Xe=t[127]:(Xe=(0,Q.jsx)(gr,{children:Ye}),t[126]=Ye,t[127]=Xe);let Ze;t[128]!==Je||t[129]!==Xe?(Ze=(0,Q.jsx)(vr,{open:Je,children:Xe}),t[128]=Je,t[129]=Xe,t[130]=Ze):Ze=t[130];let Qe;return t[131]!==me||t[132]!==qe||t[133]!==Ze?(Qe=(0,Q.jsxs)(`div`,{className:me,children:[qe,Ze]}),t[131]=me,t[132]=qe,t[133]=Ze,t[134]=Qe):Qe=t[134],Qe}),na=(0,$.memo)(function(e){let t=(0,Z.c)(54),{clientSession:n,presentation:r,revokingClientSessionId:i,onRevokeSession:a,canRevoke:o}=e,s=r===void 0?`current`:r,c=X(1e3),l=n.current||n.connected,u=n.lastConnectedAt,d;t[0]!==l||t[1]!==u||t[2]!==c?(d=l?u?`Connected for ${bt(u,c)}`:`Connected`:u?`Last connected at ${Ni(u)}`:`Not connected yet.`,t[0]=l,t[1]=u,t[2]=c,t[3]=d):d=t[3];let f=d,p;t[4]===n.client.deviceType?p=t[5]:(p=n.client.deviceType===`unknown`?null:n.client.deviceType[0]?.toUpperCase()+n.client.deviceType.slice(1),t[4]=n.client.deviceType,t[5]=p);let m=n.client.os??null,h=n.client.browser??null,g=n.client.ipAddress??null,_;t[6]!==p||t[7]!==m||t[8]!==h||t[9]!==g?(_=[p,m,h,g].filter(ka),t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_):_=t[10];let v=_,y;t[11]!==n.client.browser||t[12]!==n.client.label||t[13]!==n.client.os||t[14]!==n.subject?(y=n.client.label??([n.client.os,n.client.browser].filter(Boolean).join(` · `)||n.subject),t[11]=n.client.browser,t[12]=n.client.label,t[13]=n.client.os,t[14]=n.subject,t[15]=y):y=t[15];let b=y,x;t[16]===s?x=t[17]:(x=Vi(s),t[16]=s,t[17]=x);let S=l?`bg-success`:`bg-muted-foreground/30`,C=l?`bg-success/60 duration-2000`:null,w;t[18]!==f||t[19]!==S||t[20]!==C?(w=(0,Q.jsx)(On,{tooltipText:f,dotClassName:S,pingClassName:C}),t[18]=f,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;t[22]===b?T=t[23]:(T=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:b}),t[22]=b,t[23]=T);let E;t[24]===n.current?E=t[25]:(E=n.current?(0,Q.jsx)(`span`,{className:`text-3xs text-muted-foreground/80 rounded-md border border-border/50 bg-muted/50 px-1 py-0.5`,children:`This device`}):null,t[24]=n.current,t[25]=E);let D;t[26]!==w||t[27]!==T||t[28]!==E?(D=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[w,T,E]}),t[26]=w,t[27]=T,t[28]=E,t[29]=D):D=t[29];let O;t[30]===v?O=t[31]:(O=v.length>0?(0,Q.jsxs)(Q.Fragment,{children:[v.join(` · `),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:` · `})]}):null,t[30]=v,t[31]=O);let k;t[32]===n.scopes?k=t[33]:(k=(0,Q.jsx)(Pi,{scopes:n.scopes,label:`Client scopes`}),t[32]=n.scopes,t[33]=k);let A;t[34]!==O||t[35]!==k?(A=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36];let j;t[37]!==D||t[38]!==A?(j=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[D,A]}),t[37]=D,t[38]=A,t[39]=j):j=t[39];let M;t[40]!==o||t[41]!==n.current||t[42]!==n.sessionId||t[43]!==a||t[44]!==i?(M=n.current?null:(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:!o||i===n.sessionId,onClick:()=>void a(n.sessionId),children:i===n.sessionId?`Revoking…`:`Revoke`}),t[40]=o,t[41]=n.current,t[42]=n.sessionId,t[43]=a,t[44]=i,t[45]=M):M=t[45];let N;t[46]===M?N=t[47]:(N=(0,Q.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:M}),t[46]=M,t[47]=N);let P;t[48]!==j||t[49]!==N?(P=(0,Q.jsxs)(`div`,{className:or,children:[j,N]}),t[48]=j,t[49]=N,t[50]=P):P=t[50];let F;return t[51]!==P||t[52]!==x?(F=(0,Q.jsx)(`div`,{className:x,children:P}),t[51]=P,t[52]=x,t[53]=F):F=t[53],F}),ra=(0,$.memo)(function({onPairingLinkCreated:e,clientSessions:t,isRevokingOtherClients:n,onRevokeOtherClients:r,delegatableScopes:i}){let o=Y(),[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(``),[d,f]=(0,$.useState)([...N]),p=d.filter(e=>i.includes(e)),[m,h]=(0,$.useState)(!1),g=(0,$.useCallback)(async()=>{if(o!==null&&p.length!==0&&pt(o,`access:write`)&&p.every(e=>pt(o,e))){h(!0);try{e(await An({label:l,scopes:p})),u(``),f(N.filter(e=>i.includes(e))),c(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to create pairing URL.`;J.add(vt({type:`error`,title:`Could not create pairing URL`,description:t}))}finally{h(!1)}}},[i,e,l,o,p]),_=(0,$.useCallback)((e,t)=>{f(n=>Sr(n,e,t))},[]);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:n||!_r(t),onClick:()=>void r(),children:n?`Revoking…`:`Revoke others`}),(0,Q.jsxs)(Ft,{open:s,onOpenChange:e=>{c(e),e||(u(``),f(N.filter(e=>i.includes(e))))},children:[(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`default`,children:[(0,Q.jsx)(le,{className:`size-3`}),`Create link`]})}),(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Create pairing link`}),(0,Q.jsx)(Nt,{children:`Generate a one-time link that another device can use to pair with this backend as an authorized client.`})]}),(0,Q.jsxs)(Mt,{children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Client label (optional)`}),(0,Q.jsx)(Tt,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. Living room iPad`,disabled:m,autoFocus:!0})]}),(0,Q.jsxs)(`section`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-foreground`,children:`Permissions`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Limit what the paired client can do.`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:m,onClick:()=>f([ae,a,S,ge].filter(e=>i.includes(e))),children:`Read only`}),(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:m,onClick:()=>f(N.filter(e=>i.includes(e))),children:`Standard`})]})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border/60 rounded-lg border border-input bg-muted/25`,children:Or.filter(({scope:e})=>i.includes(e)).map(({scope:e,title:t,description:n})=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-3 py-2.5 transition-colors hover:bg-muted/40`,children:[(0,Q.jsx)(an,{className:`mt-0.5`,checked:d.includes(e),disabled:m,onCheckedChange:t=>_(e,t===!0)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:t}),(0,Q.jsx)(`span`,{className:`block text-xs leading-snug text-muted-foreground`,children:n})]})]},e))}),p.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:`Select at least one permission.`}):p.includes(`access:write`)?(0,Q.jsx)(`p`,{className:`text-xs text-warning`,children:`This client can create or revoke access for other devices.`}):null]})]}),(0,Q.jsxs)(kt,{variant:`bare`,children:[(0,Q.jsx)(L,{variant:`outline`,disabled:m,onClick:()=>c(!1),children:`Cancel`}),(0,Q.jsx)(L,{disabled:m||p.length===0,onClick:()=>void g(),children:m?`Creating…`:`Create link`})]})]})]})]})}),ia=(0,$.memo)(function(e){let t=(0,Z.c)(39),{endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:a,isLoading:o,pairingLinks:s,createdPairingCredentials:c,clientSessions:l,revokingPairingLinkId:u,revokingClientSessionId:d,onRevokePairingLink:f,onRevokeClientSession:p,canRevoke:m}=e,h=a===void 0?`current`:a,g;if(t[0]!==m||t[1]!==c||t[2]!==i||t[3]!==n||t[4]!==r||t[5]!==f||t[6]!==s||t[7]!==h||t[8]!==u){let e;t[10]!==m||t[11]!==c||t[12]!==i||t[13]!==n||t[14]!==r||t[15]!==f||t[16]!==h||t[17]!==u?(e=e=>(0,Q.jsx)(ta,{pairingLink:e,credential:c.get(e.id),endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:h,revokingPairingLinkId:u,onRevoke:f,canRevoke:m},e.id),t[10]=m,t[11]=c,t[12]=i,t[13]=n,t[14]=r,t[15]=f,t[16]=h,t[17]=u,t[18]=e):e=t[18],g=s.map(e),t[0]=m,t[1]=c,t[2]=i,t[3]=n,t[4]=r,t[5]=f,t[6]=s,t[7]=h,t[8]=u,t[9]=g}else g=t[9];let _;if(t[19]!==m||t[20]!==l||t[21]!==p||t[22]!==h||t[23]!==d){let e;t[25]!==m||t[26]!==p||t[27]!==h||t[28]!==d?(e=e=>(0,Q.jsx)(na,{clientSession:e,presentation:h,revokingClientSessionId:d,onRevokeSession:p,canRevoke:m},e.sessionId),t[25]=m,t[26]=p,t[27]=h,t[28]=d,t[29]=e):e=t[29],_=l.map(e),t[19]=m,t[20]=l,t[21]=p,t[22]=h,t[23]=d,t[24]=_}else _=t[24];let v;t[30]!==l.length||t[31]!==o||t[32]!==s.length||t[33]!==h?(v=s.length===0&&l.length===0&&!o?(0,Q.jsx)(`div`,{className:Vi(h),children:(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`No pairing links or client sessions.`})}):null,t[30]=l.length,t[31]=o,t[32]=s.length,t[33]=h,t[34]=v):v=t[34];let y;return t[35]!==g||t[36]!==_||t[37]!==v?(y=(0,Q.jsxs)(Q.Fragment,{children:[g,_,v]}),t[35]=g,t[36]=_,t[37]=v,t[38]=y):y=t[38],y}),aa=(0,$.memo)(function(e){let t=(0,Z.c)(50),{endpoint:n,isDefault:r,presentation:i,onSetDefault:a,onSetupTailscaleServe:o,onDisableTailscaleServe:s,isUpdatingTailscaleServe:c}=e,l=i===void 0?`current`:i,u=n.status===`available`,d;t[0]===n?d=t[1]:(d=Yi(n)&&n.status!==`available`,t[0]=n,t[1]=d);let f=d,p;t[2]===n?p=t[3]:(p=Yi(n)&&n.status===`available`,t[2]=n,t[3]=p);let m=p,h=!f,g=l===`endpoint-rail`,_;t[4]!==u||t[5]!==l?(_=Hi(l,u),t[4]=u,t[5]=l,t[6]=_):_=t[6];let v;t[7]!==r||t[8]!==g?(v=g&&r?(0,Q.jsx)(`span`,{className:`absolute inset-y-2 left-0 w-1 rounded-r-full bg-primary`,"aria-hidden":!0}):null,t[7]=r,t[8]=g,t[9]=v):v=t[9];let y;t[10]===n.label?y=t[11]:(y=(0,Q.jsx)(`h3`,{className:`shrink-0 text-sm leading-5 font-medium text-foreground`,children:n.label}),t[10]=n.label,t[11]=y);let b;t[12]!==n.httpBaseUrl||t[13]!==h?(b=h?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-xs leading-5 text-muted-foreground`,children:n.httpBaseUrl})}),(0,Q.jsx)(St,{side:`top`,children:n.httpBaseUrl})]}):null,t[12]=n.httpBaseUrl,t[13]=h,t[14]=b):b=t[14];let x;t[15]===u?x=t[16]:(x=u?null:(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md border border-border/70 px-1 py-0.5 text-3xs text-muted-foreground`,children:`Setup required`}),t[15]=u,t[16]=x);let S;t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[y,b,x]}),t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20];let C;t[21]===r?C=t[22]:(C=r?(0,Q.jsx)(`span`,{className:`rounded-md border border-primary/30 bg-primary/10 px-1 py-0.5 text-3xs text-primary`,children:`Default`}):null,t[21]=r,t[22]=C);let w;t[23]!==n||t[24]!==c||t[25]!==f||t[26]!==o?(w=f?(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:()=>o(n),disabled:c,children:c?`Restarting…`:`Setup`}):null,t[23]=n,t[24]=c,t[25]=f,t[26]=o,t[27]=w):w=t[27];let T;t[28]!==m||t[29]!==n||t[30]!==c||t[31]!==s?(T=m?(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,onClick:()=>s(n),disabled:c,children:c?`Restarting…`:`Disable`}):null,t[28]=m,t[29]=n,t[30]=c,t[31]=s,t[32]=T):T=t[32];let E;t[33]!==n||t[34]!==r||t[35]!==f||t[36]!==a?(E=!f&&!r?(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:()=>a(n),children:`Set as default`}):null,t[33]=n,t[34]=r,t[35]=f,t[36]=a,t[37]=E):E=t[37];let D;t[38]!==C||t[39]!==w||t[40]!==T||t[41]!==E?(D=(0,Q.jsxs)(`div`,{className:`ml-auto flex min-h-6 shrink-0 items-center justify-end gap-2`,children:[C,w,T,E]}),t[38]=C,t[39]=w,t[40]=T,t[41]=E,t[42]=D):D=t[42];let O;t[43]!==D||t[44]!==S?(O=(0,Q.jsxs)(`div`,{className:`flex min-h-6 min-w-0 flex-col gap-2 sm:-my-0.5 sm:flex-row sm:items-center`,children:[S,D]}),t[43]=D,t[44]=S,t[45]=O):O=t[45];let k;return t[46]!==O||t[47]!==_||t[48]!==v?(k=(0,Q.jsxs)(`div`,{className:_,children:[v,O]}),t[46]=O,t[47]=_,t[48]=v,t[49]=k):k=t[49],k});function oa(e){let t=(0,Z.c)(14),{endpoint:n,hiddenEndpointCount:r,expanded:i,onToggleExpanded:a,fallback:o}=e;if(!n)return o;let s;t[0]===n.httpBaseUrl?s=t[1]:(s=(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:n.httpBaseUrl}),t[0]=n.httpBaseUrl,t[1]=s);let c;t[2]!==i||t[3]!==r?(c=r>0?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:i?`Hide`:`+${r}`}):null,t[2]=i,t[3]=r,t[4]=c):c=t[4];let l;t[5]!==s||t[6]!==c?(l=(0,Q.jsxs)(Q.Fragment,{children:[s,c]}),t[5]=s,t[6]=c,t[7]=l):l=t[7];let u=l,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`span`,{className:`shrink-0`,children:`Reachable at`}),t[8]=d):d=t[8];let f;return t[9]!==i||t[10]!==r||t[11]!==a||t[12]!==u?(f=(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-1`,children:[d,r>0?(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-baseline gap-2 border-b border-dotted border-muted-foreground/60 text-left text-muted-foreground underline-offset-4 hover:border-foreground hover:text-foreground`,onClick:a,"aria-expanded":i,children:u}):(0,Q.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-2`,children:u})]}),t[9]=i,t[10]=r,t[11]=a,t[12]=u,t[13]=f):f=t[13],f}function sa(e){if(!e.entry.enabled&&e.connection.phase!==`unsupported`)return{text:`Off`,tone:`muted`};let{connection:t}=e;switch(t.phase){case`connected`:return{text:`Connected`,tone:`muted`};case`connecting`:return{text:`Connecting`,tone:`muted`};case`reconnecting`:return{text:t.error?`Reconnecting: ${t.error}`:`Reconnecting`,tone:`error`};case`unsupported`:return{text:`Client not supported`,tone:`muted`};case`error`:return{text:t.error?`Connection failed: ${t.error}`:`Connection failed`,tone:`error`};case`offline`:return{text:`Offline`,tone:`muted`};case`available`:return{text:`Not connected`,tone:`muted`}}}function ca(e){let t=(0,Z.c)(177),{environment:n,removingEnvironmentId:r,onSetEnabled:i,onRemove:a,onAddRoute:o}=e,[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(!1),[d,f]=(0,$.useState)(!1),p=n.environmentId,m=n.connection.phase===`unsupported`,g=n.entry.enabled&&!m,_=n.connection.phase===`connected`,v=r===p,b=n.connection.traceId,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S={target:`trace ID`,onCopy:_a,onError:ga},t[0]=S):S=t[0];let{copyToClipboard:w}=$e(S),T;t[1]===w?T=t[2]:(T=e=>{w(e,{traceId:e})},t[1]=w,t[2]=T);let E=T,D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D={target:`MCP URL`,onCopy:ha,onError:ma},t[3]=D):D=t[3];let{copyToClipboard:O}=$e(D),k;t[4]===n.serverConfig?k=t[5]:(k=nr(n.serverConfig),t[4]=n.serverConfig,t[5]=k);let A=k,j;t[6]===p?j=t[7]:(j=ct.updateStateAtom(p),t[6]=p,t[7]=j);let N=de(j),F=N.status===`running`&&N.stage===`resuming`,ee;t[8]===n?ee=t[9]:(ee=sa(n),t[8]=n,t[9]=ee);let I=ee,ne=n.serverConfig?.environment.serverVersion??null,ie=et(),ae;t[10]!==p||t[11]!==ie.environments?(ae=re(ie.environments.get(p)?.status??x())?.descriptor,t[10]=p,t[11]=ie.environments,t[12]=ae):ae=t[12];let oe=ae,[R,se]=(0,$.useState)(oe);oe!==void 0&&oe!==R&&se(oe);let ce;t[13]!==p||t[14]!==ie.environments?(ce=ie.environments.get(p)?.environment.endpoint.httpBaseUrl,t[13]=p,t[14]=ie.environments,t[15]=ce):ce=t[15];let le=ce,[fe,pe]=(0,$.useState)(le);le!==void 0&&le!==fe&&pe(le);let he=_t(lt.retryNow),{diagnosis:ge,state:_e,relayOnly:B}=$t(n),V=F?null:ge,ve=ht(p),ye=_&&ve._tag===`Some`?ve.value.target:null,H=le??fe,xe;t[16]!==ye||t[17]!==n.entry||t[18]!==H?(xe=We({entry:n.entry,relayHttpBaseUrl:H,connectedTarget:ye}),t[16]=ye,t[17]=n.entry,t[18]=H,t[19]=xe):xe=t[19];let Se=xe,Ce;t[20]!==n.serverConfig||t[21]!==R?(Ce=n.serverConfig??(R===void 0?null:{environment:R}),t[20]=n.serverConfig,t[21]=R,t[22]=Ce):Ce=t[22];let we;t[23]===Ce?we=t[24]:(we=h(Ce),t[23]=Ce,t[24]=we);let Te=we,Ee;t[25]===n.entry?Ee=t[26]:(Ee=Ne(n.entry),t[25]=n.entry,t[26]=Ee);let U=Ee.length,De;t[27]!==ye||t[28]!==n?(De=Vr(n,ye),t[27]=ye,t[28]=n,t[29]=De):De=t[29];let Oe=V?null:F?`Restarting`:I.text,ke=g&&A?ne:null,Ae;t[30]!==De||t[31]!==Oe||t[32]!==ke?(Ae=[De,Oe,ke].filter(pa),t[30]=De,t[31]=Oe,t[32]=ke,t[33]=Ae):Ae=t[33];let W=Ae.join(` · `),je=g&&_&&A!==null&&(N.status===`idle`||N.status===`failed`),G;t[34]!==g||t[35]!==n.connection||t[36]!==m?(G=m?n.connection.error??Ge(n.connection):g?Ge(n.connection):`Switched off`,t[34]=g,t[35]=n.connection,t[36]=m,t[37]=G):G=t[37];let Me=`${G}${A?`\nUpdate available: ${A.serverVersion} → ${A.clientVersion}`:``}`,K=n.label,Pe=!g,Fe=g&&I.tone===`error`&&!F&&!V&&`text-destructive`,Ie;t[38]===Fe?Ie=t[39]:(Ie=be(`min-w-0 truncate`,Fe),t[38]=Fe,t[39]=Ie);let Le;t[40]===Ie?Le=t[41]:(Le=(0,Q.jsx)(`span`,{className:Ie}),t[40]=Ie,t[41]=Le);let Re;t[42]!==Me||t[43]!==W||t[44]!==Le?(Re=(0,Q.jsx)(xt,{payload:Me,render:Le,children:W}),t[42]=Me,t[43]=W,t[44]=Le,t[45]=Re):Re=t[45];let ze;t[46]===Me?ze=t[47]:(ze=(0,Q.jsx)(St,{side:`top`,className:`whitespace-pre-wrap`,children:Me}),t[46]=Me,t[47]=ze);let Ve;t[48]!==Re||t[49]!==ze?(Ve=(0,Q.jsxs)(Ct,{children:[Re,ze]}),t[48]=Re,t[49]=ze,t[50]=Ve):Ve=t[50];let q;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0`,children:`·`}),t[51]=q):q=t[51];let He;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(He=()=>c(fa),t[52]=He):He=t[52];let Ue=U===1?`Routes`:`${U} routes`,Ke=s&&`rotate-90`,qe;t[53]===Ke?qe=t[54]:(qe=be(`size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none`,Ke),t[53]=Ke,t[54]=qe);let Je;t[55]===qe?Je=t[56]:(Je=(0,Q.jsx)(y,{"aria-hidden":!0,className:qe}),t[55]=qe,t[56]=Je);let Ye;t[57]!==s||t[58]!==Ue||t[59]!==Je?(Ye=(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:He,className:`inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,children:[Ue,Je]}),t[57]=s,t[58]=Ue,t[59]=Je,t[60]=Ye):Ye=t[60];let Xe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0`,children:`·`}),t[61]=Xe):Xe=t[61];let Ze=`remote-permissions-${p}`,Qe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=()=>u(da),t[62]=Qe):Qe=t[62];let J=l&&`rotate-90`,tt;t[63]===J?tt=t[64]:(tt=be(`size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none`,J),t[63]=J,t[64]=tt);let nt;t[65]===tt?nt=t[66]:(nt=(0,Q.jsx)(y,{"aria-hidden":!0,className:tt}),t[65]=tt,t[66]=nt);let Y;t[67]!==l||t[68]!==Ze||t[69]!==nt?(Y=(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":l,"aria-controls":Ze,onClick:Qe,className:`inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,children:[`Permissions`,nt]}),t[67]=l,t[68]=Ze,t[69]=nt,t[70]=Y):Y=t[70];let rt;t[71]!==Ve||t[72]!==Ye||t[73]!==Y?(rt=(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[Ve,q,Ye,Xe,Y]}),t[71]=Ve,t[72]=Ye,t[73]=Y,t[74]=rt):rt=t[74];let it;t[75]!==_e||t[76]!==V||t[77]!==d?(it=V?(0,Q.jsx)(Zt,{diagnosis:V,retryAt:_e.phase===`backoff`?_e.retryAt:null,attempt:_e.attempt,expanded:d,onToggle:()=>f(ua)}):null,t[75]=_e,t[76]=V,t[77]=d,t[78]=it):it=t[78];let at;t[79]===N?at=t[80]:(at=N.status===`idle`?null:(0,Q.jsx)(`div`,{className:`mt-1 max-w-md`,children:(0,Q.jsx)(zn,{state:N})}),t[79]=N,t[80]=at);let ot;t[81]!==it||t[82]!==at?(ot=(0,Q.jsxs)(Q.Fragment,{children:[it,at]}),t[81]=it,t[82]=at,t[83]=ot):ot=t[83];let st;t[84]!==V||t[85]!==d||t[86]!==n||t[87]!==p||t[88]!==o||t[89]!==B||t[90]!==he?(st=V&&d?(0,Q.jsx)(tn,{hostLabel:n.label,diagnosis:V,onRetry:()=>void he(p),onAddRoute:B?()=>o(n):null}):null,t[84]=V,t[85]=d,t[86]=n,t[87]=p,t[88]=o,t[89]=B,t[90]=he,t[91]=st):st=t[91];let ut;t[92]!==n||t[93]!==o||t[94]!==s?(ut=s&&(0,Q.jsx)(Ir,{environment:n,onAddRoute:()=>o(n)}),t[92]=n,t[93]=o,t[94]=s,t[95]=ut):ut=t[95];let dt;t[96]!==p||t[97]!==_||t[98]!==l?(dt=l&&(0,Q.jsx)(`div`,{id:`remote-permissions-${p}`,className:`mt-2 border-t border-border/50`,children:(0,Q.jsx)(kr,{environmentId:p,connected:_,routeContext:!0})}),t[96]=p,t[97]=_,t[98]=l,t[99]=dt):dt=t[99];let ft;t[100]!==st||t[101]!==ut||t[102]!==dt?(ft=(0,Q.jsxs)(Q.Fragment,{children:[st,ut,dt]}),t[100]=st,t[101]=ut,t[102]=dt,t[103]=ft):ft=t[103];let pt;t[104]!==n.entry.serverUpdateRequired||t[105]!==n.label||t[106]!==p||t[107]!==R?.serverVersion||t[108]!==N.status||t[109]!==m?(pt=m&&n.entry.serverUpdateRequired===!0&&N.status!==`running`?(0,Q.jsx)(Yn,{environmentId:p,serverLabel:`${n.label} server`,fromVersion:R?.serverVersion,targetVersion:Be,label:N.status===`failed`?`Retry update`:`Update`}):null,t[104]=n.entry.serverUpdateRequired,t[105]=n.label,t[106]=p,t[107]=R?.serverVersion,t[108]=N.status,t[109]=m,t[110]=pt):pt=t[110];let mt;t[111]!==n.label||t[112]!==n.serverConfig||t[113]!==p||t[114]!==N.status||t[115]!==je||t[116]!==A?(mt=je?(0,Q.jsx)(Tr,{environmentId:p,serverLabel:`${n.label} server`,selfUpdate:tr(n.serverConfig),installation:n.serverConfig?.environment.capabilities.serverInstallation,desktopAppUpdate:Jn(n.serverConfig),threadContinuation:In(n.serverConfig),targetVersion:A.clientVersion,label:N.status===`failed`?`Retry update`:`Update`,appearance:`icon`}):null,t[111]=n.label,t[112]=n.serverConfig,t[113]=p,t[114]=N.status,t[115]=je,t[116]=A,t[117]=mt):mt=t[117];let gt=v||m,vt=`${g?`Switch off`:`Switch on`} ${n.label}`,yt;t[118]!==p||t[119]!==i?(yt=e=>i(p,e),t[118]=p,t[119]=i,t[120]=yt):yt=t[120];let bt;t[121]!==g||t[122]!==gt||t[123]!==vt||t[124]!==yt?(bt=(0,Q.jsx)(xt,{render:(0,Q.jsx)(lr,{size:`sm`,checked:g,disabled:gt,"aria-label":vt,onCheckedChange:yt})}),t[121]=g,t[122]=gt,t[123]=vt,t[124]=yt,t[125]=bt):bt=t[125];let wt=m?`Client not supported`:g?`Switch off`:`Switch on`,Tt;t[126]===wt?Tt=t[127]:(Tt=(0,Q.jsx)(St,{side:`top`,children:wt}),t[126]=wt,t[127]=Tt);let Et;t[128]!==bt||t[129]!==Tt?(Et=(0,Q.jsxs)(Ct,{children:[bt,Tt]}),t[128]=bt,t[129]=Tt,t[130]=Et):Et=t[130];let Dt=`More actions for ${n.label}`,Ot;t[131]!==v||t[132]!==Dt?(Ot=(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,disabled:v,"aria-label":Dt}),t[131]=v,t[132]=Dt,t[133]=Ot):Ot=t[133];let kt;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(kt=(0,Q.jsx)(te,{className:`size-3.5`}),t[134]=kt):kt=t[134];let At;t[135]===Ot?At=t[136]:(At=(0,Q.jsx)(M,{render:Ot,children:kt}),t[135]=Ot,t[136]=At);let jt;t[137]!==n.serverConfig||t[138]!==p?(jt=(0,Q.jsx)(Fr,{environmentId:p,serverConfig:n.serverConfig}),t[137]=n.serverConfig,t[138]=p,t[139]=jt):jt=t[139];let Mt,Nt;t[140]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=()=>c(la),Nt=(0,Q.jsx)(me,{}),t[140]=Mt,t[141]=Nt):(Mt=t[140],Nt=t[141]);let Pt=s?`Hide routes`:`Routes`,Ft;t[142]===Pt?Ft=t[143]:(Ft=(0,Q.jsxs)(P,{onClick:Mt,children:[Nt,Pt]}),t[142]=Pt,t[143]=Ft);let It;t[144]!==O||t[145]!==Se?(It=Se?(0,Q.jsx)(P,{onClick:()=>O(Se,{url:Se}),children:`Copy MCP URL`}):null,t[144]=O,t[145]=Se,t[146]=It):It=t[146];let Lt;t[147]!==E||t[148]!==b?(Lt=b?(0,Q.jsx)(P,{onClick:()=>E(b),children:`Copy trace ID`}):null,t[147]=E,t[148]=b,t[149]=Lt):Lt=t[149];let Rt;t[150]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=(0,Q.jsx)(z,{}),t[150]=Rt):Rt=t[150];let zt;t[151]!==n||t[152]!==a?(zt=()=>a(n),t[151]=n,t[152]=a,t[153]=zt):zt=t[153];let Bt=v?`Removing…`:`Remove from this device…`,Vt;t[154]!==zt||t[155]!==Bt?(Vt=(0,Q.jsx)(P,{variant:`destructive`,onClick:zt,children:Bt}),t[154]=zt,t[155]=Bt,t[156]=Vt):Vt=t[156];let Ht;t[157]!==jt||t[158]!==Ft||t[159]!==It||t[160]!==Lt||t[161]!==Vt?(Ht=(0,Q.jsxs)(ue,{align:`end`,children:[jt,Ft,It,Lt,Rt,Vt]}),t[157]=jt,t[158]=Ft,t[159]=It,t[160]=Lt,t[161]=Vt,t[162]=Ht):Ht=t[162];let Ut;t[163]!==At||t[164]!==Ht?(Ut=(0,Q.jsxs)(C,{children:[At,Ht]}),t[163]=At,t[164]=Ht,t[165]=Ut):Ut=t[165];let Wt;return t[166]!==n.label||t[167]!==Te||t[168]!==Pe||t[169]!==rt||t[170]!==ot||t[171]!==ft||t[172]!==pt||t[173]!==mt||t[174]!==Et||t[175]!==Ut?(Wt=(0,Q.jsxs)(Hr,{kind:Te,label:K,dimmed:Pe,subtitle:rt,below:ot,detail:ft,children:[pt,mt,Et,Ut]}),t[166]=n.label,t[167]=Te,t[168]=Pe,t[169]=rt,t[170]=ot,t[171]=ft,t[172]=pt,t[173]=mt,t[174]=Et,t[175]=Ut,t[176]=Wt):Wt=t[176],Wt}function la(e){return!e}function ua(e){return!e}function da(e){return!e}function fa(e){return!e}function pa(e){return e!==null}function ma(e){J.add(vt({type:`error`,title:`Could not copy MCP URL`,description:e.message}))}function ha(e){let{url:t}=e;J.add({type:`success`,title:`MCP URL copied`,description:`Add it to an agent, e.g. claude mcp add --transport http p4 ${t}`})}function ga(e){J.add(vt({type:`error`,title:`Could not copy trace ID`,description:e.message}))}function _a(e){let{traceId:t}=e;J.add({type:`success`,title:`Trace ID copied`,description:t})}function va(e){let t=(0,Z.c)(10),{checked:n,disabled:r,disabledReason:i,onCheckedChange:a,ariaLabel:o}=e,s=o===void 0?`Enable P4 Connect`:o,c;t[0]===a?c=t[1]:(c=a?{onCheckedChange:a}:{},t[0]=a,t[1]=c);let l;t[2]!==s||t[3]!==n||t[4]!==r||t[5]!==c?(l=(0,Q.jsx)(lr,{"aria-label":s,checked:n,disabled:r,...c}),t[2]=s,t[3]=n,t[4]=r,t[5]=c,t[6]=l):l=t[6];let u=l,d;return t[7]!==u||t[8]!==i?(d=i?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`span`,{className:`inline-flex`,children:u})}),(0,Q.jsx)(St,{side:`top`,children:i})]}):u,t[7]=u,t[8]=i,t[9]=d):d=t[9],d}function ya(e){let t=(0,Z.c)(53),{canManageRelay:n}=e,r=Y(),{isSignedIn:i,linkState:a,linkRevoked:s,managedTunnelActive:c,managedTunnelOutOfSync:l,publishAgentActivity:u,holdWebhooksWhileOffline:d,operationError:f,reconcileCloudState:p}=mr(),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(!1),v=i?n?null:`Your session does not have permission to manage P4 Connect access.`:`Sign in to P4 Connect to manage this environment.`,y=m||g,b=(0,$.useEffectEvent)(a.refresh),x;t[0]===b?x=t[1]:(x=()=>{let e=window.setInterval(()=>b(),3e4);return()=>window.clearInterval(e)},t[0]=b,t[1]=x);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[2]=S):S=t[2],(0,$.useEffect)(x,S);let C=c?a.data?.reachability:void 0,w;t[3]===C?w=t[4]:(w=C?.status===`reachable`?F(C):C?.status===`unreachable`?(0,Q.jsxs)(`span`,{className:`block text-destructive`,children:[[C.reason,C.hint,`Fix: ${C.fix}`].filter(Boolean).join(` `),` `,(0,Q.jsx)(`a`,{href:o(C.cause),target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:`More info`})]}):null,t[3]=C,t[4]=w);let T=w,E;t[5]!==r||t[6]!==u||t[7]!==p?(E=async e=>{r!==null&&pt(r,`relay:write`)&&(h(!0),await p({managedTunnel:e,publish:u})&&J.add({type:`success`,title:e?`P4 Connect linked`:u?`P4 Connect tunnel disabled`:`P4 Connect unlinked`,description:e?`This environment is available through P4 Connect.`:u?`The managed tunnel was removed. Agent activity publishing stays on.`:`This environment is no longer available through P4 Connect.`}),h(!1))},t[5]=r,t[6]=u,t[7]=p,t[8]=E):E=t[8];let D=E,O;t[9]!==c||t[10]!==r||t[11]!==p?(O=async e=>{r!==null&&pt(r,`relay:write`)&&(_(!0),await p({managedTunnel:c,publish:e})&&J.add({type:`success`,title:e?`Agent activity enabled`:`Agent activity disabled`,description:e?`This environment publishes agent activity to your mobile clients.`:`This environment will stop publishing agent activity.`}),_(!1))},t[9]=c,t[10]=r,t[11]=p,t[12]=O):O=t[12];let k=O,A;t[13]!==c||t[14]!==u||t[15]!==p?(A=async e=>{_(!0),await p({managedTunnel:c,publish:u,holdWebhooksWhileOffline:e})&&J.add({type:`success`,title:e?`Webhooks held while offline`:`Webhooks no longer held`,description:e?`P4 Connect keeps webhook requests for up to 24 hours while this environment is offline.`:`Requests to an offline environment now fail. Anything already held is still delivered.`}),_(!1)},t[13]=c,t[14]=u,t[15]=p,t[16]=A):A=t[16];let j=A,M;t[17]!==n||t[18]!==v||t[19]!==y||t[20]!==i||t[21]!==s||t[22]!==c||t[23]!==l||t[24]!==f||t[25]!==a.data||t[26]!==a.error||t[27]!==a.isPending||t[28]!==C?.status||t[29]!==T||t[30]!==D?(M=window.desktopBridge?(0,Q.jsx)(vn,{title:Rn(`p4-connect`).title,description:s?`This environment was removed from P4 Connect. Turn it on to link it again.`:c?C?.status===`unreachable`?`P4 Connect is on, but other devices cannot reach this environment.`:C?.status===`reachable`?`This environment is available to your other devices through P4 Connect.`:`P4 Connect is on. Reachability has not been checked yet.`:l?`P4 Connect is out of sync. This environment is linked only to publish agent activity, so other devices cannot connect. Turn P4 Connect on to repair it.`:`Make this environment available to your other devices through P4 Connect.`,status:f??a.error??T,control:(0,Q.jsx)(va,{checked:c,disabled:!n||!i||a.data===null||a.isPending||y,disabledReason:v,onCheckedChange:e=>void D(e)})}):s?(0,Q.jsx)(vn,{title:Rn(`p4-connect`).title,description:"This environment was removed from P4 Connect. Run `p4c connect link` on the host to link it again."}):null,t[17]=n,t[18]=v,t[19]=y,t[20]=i,t[21]=s,t[22]=c,t[23]=l,t[24]=f,t[25]=a.data,t[26]=a.error,t[27]=a.isPending,t[28]=C?.status,t[29]=T,t[30]=D,t[31]=M):M=t[31];let N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=Rn(`publish-agent-activity`),t[32]=N):N=t[32];let P=!n||!i||a.data===null||a.isPending||y,ee;t[33]===k?ee=t[34]:(ee=e=>void k(e),t[33]=k,t[34]=ee);let I;t[35]!==v||t[36]!==u||t[37]!==ee||t[38]!==P?(I=(0,Q.jsx)(vn,{title:N.title,description:`Send activity to mobile notifications and Live Activities without P4 Connect.`,control:(0,Q.jsx)(va,{ariaLabel:`Publish agent activity to mobile clients`,checked:u,disabled:P,disabledReason:v,onCheckedChange:ee})}),t[35]=v,t[36]=u,t[37]=ee,t[38]=P,t[39]=I):I=t[39];let te;t[40]!==n||t[41]!==v||t[42]!==d||t[43]!==y||t[44]!==i||t[45]!==c||t[46]!==a.isPending||t[47]!==j?(te=c?(0,Q.jsx)(vn,{title:Rn(`hold-webhooks-while-offline`).title,description:`Keep webhook requests for up to 24 hours while this environment is offline, then deliver them. Off: P4 Connect only forwards requests and stores nothing.`,control:(0,Q.jsx)(va,{ariaLabel:`Hold webhook requests while this environment is offline`,checked:d,disabled:!n||!i||a.isPending||y,disabledReason:v,onCheckedChange:e=>void j(e)})}):null,t[40]=n,t[41]=v,t[42]=d,t[43]=y,t[44]=i,t[45]=c,t[46]=a.isPending,t[47]=j,t[48]=te):te=t[48];let L;return t[49]!==I||t[50]!==te||t[51]!==M?(L=(0,Q.jsxs)(Q.Fragment,{children:[M,I,te]}),t[49]=I,t[50]=te,t[51]=M,t[52]=L):L=t[52],L}function ba(e){let t=(0,Z.c)(3),{canReadRelay:n,canManageRelay:r}=e;if(!Pe())return null;if(!n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(vn,{title:`P4 Connect`,description:`To edit these settings, pair this connection with both View relay and Manage relay permissions.`}),t[0]=e):e=t[0],e}let i;return t[1]===r?i=t[2]:(i=(0,Q.jsx)(ya,{canManageRelay:r}),t[1]=r,t[2]=i),i}function xa(e){let t=(0,Z.c)(4),{cloudEnabled:n}=e,r=n===void 0||n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Lt,{variant:`icon`,children:(0,Q.jsx)(c,{})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(zt,{children:`No saved remote environments`}),t[1]=a):a=t[1];let o=r?`Click “Add environment” to pair another environment, or connect one from P4 Connect.`:`Click “Add environment” to pair another environment.`,s;return t[2]===o?s=t[3]:(s=(0,Q.jsxs)(Vt,{className:`min-h-52`,children:[i,(0,Q.jsxs)(Rt,{children:[a,(0,Q.jsx)(Bt,{children:o})]})]}),t[2]=o,t[3]=s),s}function Sa(e){let t=(0,Z.c)(3),{primaryEnvironmentId:n,savedEnvironments:r}=e,i;return t[0]!==n||t[1]!==r?(i=Pe()?(0,Q.jsx)(rr,{primaryEnvironmentId:n,savedEnvironments:r,empty:(0,Q.jsx)(xa,{})}):r.length===0?(0,Q.jsx)(xa,{cloudEnabled:!1}):null,t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Ca(){let e=window.desktopBridge,t=de(ut),{environments:n}=nt(),r=tt(),i=dr(),a=_t(Fn,{reportFailure:!1}),o=_t(Pn,{reportFailure:!1}),s=_t(lt.remove,{reportFailure:!1}),l=_t(lt.register,{reportFailure:!1}),u=et(),d=_t(lt.setEnabled,{reportFailure:!1}),f=r?.environmentId??null,p=Nn(),m=p.data?.authenticated?p.data.permissions??p.data.scopes??null:null,g=e?null:p.data?.auth.policy??null,v=(0,$.useMemo)(()=>n.filter(e=>e.entry.target._tag!==`PrimaryConnectionTarget`),[n]),x=(0,$.useMemo)(()=>v.filter(e=>!Ue(e.entry.target)),[v]),S=(0,$.useMemo)(()=>A(e=>v.map(t=>({environment:t,updateStatus:e(ct.updateStateAtom(t.environmentId)).status}))),[v]),T=de(S),E=(0,$.useMemo)(()=>T.flatMap(({environment:e,updateStatus:t})=>{let n=nr(e.serverConfig),r=tr(e.serverConfig),i=Jn(e.serverConfig);return!n||t===`running`||!e.entry.enabled||e.connection.phase!==`connected`||Ue(e.entry.target)||r===null||r===`desktop-managed`&&!i?[]:[{environmentId:e.environmentId,serverLabel:e.label,selfUpdate:r,installation:e.serverConfig?.environment.capabilities.serverInstallation,desktopAppUpdate:i,threadContinuation:In(e.serverConfig),continueThreadsAfterServerUpdate:e.serverConfig?.settings.continueThreadsAfterServerUpdate??!1,targetVersion:n.clientVersion}]}),[T]),D=(0,$.useMemo)(()=>[...r?[r]:[],...v.filter(e=>e.entry.enabled)],[r,v]),O=(0,$.useMemo)(()=>{let e=new Set;for(let t of v){let n=t.entry.profile;if(t.entry.target._tag!==`SshConnectionTarget`||Ce(n)||n.value._tag!==`SshConnectionProfile`)continue;let r=n.value.target;e.add(r.alias),e.add(Br(r))}return e},[v]),[k,N]=(0,$.useState)(null),[P,F]=(0,$.useState)(null),[ee,I]=(0,$.useState)(()=>new Map),ne=(0,$.useCallback)(e=>{I(t=>new Map(t).set(e.id,e.credential))},[]),[re,ie]=(0,$.useState)(null),[ae,oe]=(0,$.useState)(null),[R,se]=(0,$.useState)(!1),[ce,fe]=(0,$.useState)(!1),[z,pe]=(0,$.useState)(null),[me,he]=(0,$.useState)(`remote`),[ge,B]=(0,$.useState)(``),[V,ve]=(0,$.useState)(``),[H,xe]=(0,$.useState)(``),[Se,we]=(0,$.useState)(``),[Te,Ee]=(0,$.useState)(``),[U,De]=(0,$.useState)(!1),Oe=(0,$.useRef)(void 0),[ke,W]=(0,$.useState)(null),[G,K]=(0,$.useState)(!1),[Ne,Ie]=(0,$.useState)(null),[Re,ze]=(0,$.useState)(!1),[Be,Ve]=(0,$.useState)(!1),[q,He]=(0,$.useState)(!1),[We,Ge]=(0,$.useState)(!1),[Ke,$e]=(0,$.useState)(null),[Y,rt]=(0,$.useState)(null),it=Y!==null,[ot,st]=(0,$.useState)(null),[dt,mt]=(0,$.useState)(!1),[ht,yt]=(0,$.useState)(String(Di)),[bt,wt]=(0,$.useState)(null),It=r?.serverConfig??null,Lt=nr(It),Rt=de(ct.updateStateAtom(f)),[zt,Bt]=(0,$.useState)(!1),Vt=on(e=>e.defaultAdvertisedEndpointKey),qt=on(e=>e.setDefaultAdvertisedEndpointKey),Jt=ft(f,_e),Yt=ft(f,w),Xt=ft(f,ye),Zt=ft(f,_),Qt=ft(f,j),$t=!Le()&&Zt,en=gt(Jt&&f!==null?fi.accessChanges({environmentId:f,input:null}):null),tn=gt($t&&e?yi:null),nn=e!==void 0&&ce&&me===`ssh`,rn=gt(nn?Ei:null),an=rn.refresh;(0,$.useEffect)(()=>{nn&&an()},[nn,an]);let cn=gt($t&&e?wr:null),X=cn.data,On=Ke??cn.error,An=cn.isPending&&cn.data===null,Ln=rn.data??ki,Bn=(0,$.useMemo)(()=>Ln.filter(e=>{let t=Br(e);return!O.has(e.alias)&&!O.has(t)}),[Ln,O]),Vn=(0,$.useMemo)(()=>xi(Bn,H),[H,Bn]),Hn=rn.isPending&&rn.data===null,Un=rn.error,Wn=e!==void 0&&(Hn||Bn.length>0),Gn=tn.data?.serverExposureState??null,Kn=tn.data?.advertisedEndpoints??Oi,qn=k??tn.error,Yn=P??en.error,Xn=en.isPending&&en.data===null,Zn=(0,$.useMemo)(()=>{let e=en.data;return e?.type===`snapshot`?Ui(e.payload.pairingLinks.map(e=>Ki(e))):[]},[en.data]),Qn=(0,$.useMemo)(()=>{let e=en.data;return e?.type===`snapshot`?Gi(e.payload.clientSessions.map(e=>qi(e))):[]},[en.data]),rr=e?Gn?.mode===`network-accessible`:g===`remote-reachable`,ar=ht.trim(),or=Number(ar),cr=/^\d+$/u.test(ar)&&Number.isInteger(or)&&or>=1&&or<=65535,ur=(0,$.useMemo)(()=>{if(!ot)return null;if(!cr||or===Di)return ot.httpBaseUrl;try{let e=new URL(ot.httpBaseUrl);return e.port=String(or),e.toString().replace(/\/$/u,``)}catch{return ot.httpBaseUrl}},[cr,or,ot]),fr=(0,$.useCallback)(async t=>{if(e&&f!==null&&pt(f,`environment:maintain`)){ze(!0),N(null);try{await e.setServerExposureMode(t?`network-accessible`:`local-only`),bi(),Ve(!1),ze(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to update network exposure.`;Ve(!1),N(t),J.add(vt({type:`error`,title:`Could not update network access`,description:t})),ze(!1)}}},[e,f]),pr=(0,$.useCallback)(()=>{bt!==null&&fr(bt===`network-accessible`)},[fr,bt]),mr=(0,$.useCallback)(async()=>{if(e&&f!==null&&pt(f,`environment:maintain`)&&cr){He(!0),N(null);try{await e.setTailscaleServeEnabled({enabled:!0,port:or}),bi(),st(null)}catch(e){let t=e instanceof Error?e.message:`Failed to configure Tailscale HTTPS.`;N(t),J.add(vt({type:`error`,title:`Could not set up Tailscale HTTPS`,description:t}))}finally{He(!1)}}},[e,cr,or,f]),hr=(0,$.useCallback)(e=>{yt(String(Gn?.tailscaleServePort??Di)),st(e)},[Gn?.tailscaleServePort]),gr=(0,$.useCallback)(async()=>{if(e&&f!==null&&pt(f,`environment:maintain`)){He(!0),N(null);try{await e.setTailscaleServeEnabled({enabled:!1,port:Gn?.tailscaleServePort??Di}),bi(),mt(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to disable Tailscale HTTPS.`;N(t),J.add(vt({type:`error`,title:`Could not disable Tailscale HTTPS`,description:t}))}finally{He(!1)}}},[e,Gn,f]),_r=(0,$.useCallback)(e=>{mt(!0)},[]),vr=(0,$.useCallback)(async e=>{if(f!==null&&pt(f,`access:write`)){ie(e),F(null);try{await Mn(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke pairing link.`;F(t),J.add(vt({type:`error`,title:`Could not revoke pairing link`,description:t}))}finally{ie(null)}}},[f]),yr=(0,$.useCallback)(async e=>{if(f!==null&&pt(f,`access:write`)){oe(e),F(null);try{await jn(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke client access.`;F(t),J.add(vt({type:`error`,title:`Could not revoke client access`,description:t}))}finally{oe(null)}}},[f]),br=(0,$.useCallback)(async()=>{if(f!==null&&pt(f,`access:write`)){se(!0),F(null);try{let e=await kn();J.add({type:`success`,title:e===1?`Revoked 1 other client`:`Revoked ${e} clients`,description:`Other paired clients will need a new pairing link before reconnecting.`})}catch(e){let t=e instanceof Error?e.message:`Failed to revoke other clients.`;F(t),J.add(vt({type:`error`,title:`Could not revoke other clients`,description:t}))}finally{se(!1)}}},[f]),xr=(0,$.useCallback)(async e=>{K(!0),W(null);let t=await o({target:e,label:``,...z?{expectedEnvironmentId:z.environmentId}:{}});t._tag===`Failure`?(je(t)||W(zi(Me(t))),K(!1)):(B(``),ve(``),xe(``),we(``),Ee(``),fe(!1),J.add({type:`success`,title:z?`Route added`:`Environment connected`,description:z?`${z.label} can now be reached over SSH ${e.alias}.`:`${e.alias} is ready over an SSH-managed tunnel.`}),K(!1))},[o,z]),Sr=(0,$.useCallback)(async()=>{if(me===`ssh`){let e;try{e=Ii({host:H,username:Se,port:Te})}catch(e){W(zi(e));return}await xr(e);return}K(!0),W(null);let e;try{e=Ri({host:ge,pairingCode:V})}catch(e){let t=e instanceof Error?e.message:`Failed to add backend.`;W(t),J.add(vt({type:`error`,title:`Could not add backend`,description:t})),K(!1);return}let t=await a({...e,...z?{expectedEnvironmentId:z.environmentId}:{}});if(t._tag===`Failure`){if(!je(t)){let e=Me(t),n=e instanceof Error?e.message:`Failed to add backend.`;W(n),J.add(vt({type:`error`,title:`Could not add backend`,description:n}))}K(!1)}else B(``),ve(``),xe(``),we(``),Ee(``),fe(!1),J.add(z?{type:`success`,title:`Route added`,description:`${z.label} now has another way to connect.`}:{type:`success`,title:`Backend added`,description:`The environment is saved and will reconnect on app startup.`}),K(!1)},[z,a,xr,ge,me,V,H,Te,Se]),Cr=(0,$.useCallback)(e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&H.trim().length>0&&(e.preventDefault(),Sr())},[Sr,H]),Er=(0,$.useCallback)(async t=>{if(G||!e)return;K(!0),W(null),xe(t.alias);let n;try{n=await e.resolveSshHost(t.alias)}catch(e){W(zi(e)),K(!1);return}we(n.username??``),Ee(n.port===null?``:String(n.port)),await xr(n)},[xr,e,G]),Z=(0,$.useCallback)(e=>{if(e.nativeEvent.isComposing||e.keyCode===229)return;let n=U&&Wn;if(n){let n=Wt(e,t,{platform:navigator.platform,context:{modelPickerOpen:!1}}),r=Gt(n??``),i=r===null?void 0:Vn[r];if(i){e.preventDefault(),e.stopPropagation(),De(!1),Er(i);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation();return}}let r=n&&Oe.current!==void 0;!e.defaultPrevented&&!r&&e.key===`Enter`&&H.trim().length>0&&(e.preventDefault(),Sr())},[Vn,Sr,Er,Wn,t,H,U]),Or=(0,$.useCallback)(async(e,t)=>{W(null);let n=await d({environmentId:e,enabled:t});if(n._tag===`Failure`&&!je(n)){let e=Me(n),r=e instanceof Error?e.message:`Failed to switch the backend ${t?`on`:`off`}.`;W(r),J.add(vt({type:`error`,title:`Could not switch backend ${t?`on`:`off`}`,description:r}))}},[d]),Ar=(0,$.useCallback)(async e=>{let t=e.environmentId;Ie(t),W(null);let n=await s(t);if(Ie(null),n._tag===`Failure`&&!je(n)){let e=Me(n),t=e instanceof Error?e.message:`Failed to remove backend.`;W(t),J.add(vt({type:`error`,title:`Could not remove backend`,description:t}))}},[s]),[jr,Nr]=(0,$.useState)(null),Pr=(0,$.useCallback)(async e=>{e.relayManaged&&Pe()?Nr(e):await at(`Remove ${e.label} from this device?\nThis forgets its pairing, credentials, and cached threads here. Switch it off instead to keep it saved.`,{variant:`destructive`})===!0&&await Ar(e)},[Ar]),Ir=Zn,Lr=(0,$.useMemo)(()=>Kn.find(Yi)??null,[Kn]),Rr=(0,$.useMemo)(()=>rr?Kn.filter(e=>!Yi(e)):[],[Kn,rr]),zr=(0,$.useMemo)(()=>Lr?[...Rr,Lr]:Rr,[Lr,Rr]),Vr=(0,$.useMemo)(()=>Ji(Rr,Vt),[Vt,Rr]),Hr=(0,$.useMemo)(()=>Vr??Ji(Lr?[Lr]:[],Vt),[Vt,Vr,Lr]),Ur=Hr?Xi(Hr):null,Gr=(0,$.useCallback)(e=>{qt(Xi(e))},[qt]),Kr=(0,$.useCallback)(e=>{let t=Li(e);t?(B(t.host),ve(t.pairingCode)):B(e)},[]),Jr=e=>{let t=me===e.mode;return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,className:be(`group flex min-h-24 items-start gap-3 rounded-lg border p-4 text-left`,t?`border-primary/50 bg-primary/5`:`border-border/60 hover:bg-muted/40`),disabled:G,onClick:()=>{he(e.mode)},children:[e.icon?(0,Q.jsx)(`span`,{className:be(`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border`,t?`border-primary/30 bg-primary/10 text-primary`:`border-border/70 bg-background text-muted-foreground group-hover:text-foreground`),children:e.icon}):null,(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-muted-foreground`,children:e.description})]})]})},Yr=()=>(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Host`}),(0,Q.jsx)(Tt,{value:ge,onChange:e=>Kr(e.target.value),placeholder:`backend.example.com`,disabled:G,spellCheck:!1})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Pairing code`}),(0,Q.jsx)(Tt,{value:V,onChange:e=>ve(e.target.value),placeholder:`PAIRCODE`,disabled:G,spellCheck:!1})]})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`span`,{className:`mt-1 block text-2xs text-muted-foreground`,children:`Paste a full pairing URL here to fill both fields automatically.`})})]}),Xr=z!==null&&!z.relayManaged&&u.environments.has(z.environmentId)?u.environments.get(z.environmentId).environment:null,Zr=async()=>{if(Xr===null||z===null)return;K(!0);let e=await l(new Fe({target:new Ae({environmentId:Xr.environmentId,label:z.label})}));if(K(!1),e._tag===`Failure`){if(!je(e)){let t=Me(e);W(t instanceof Error?t.message:`Could not add the route.`)}}else fe(!1),J.add({type:`success`,title:`Route added`,description:`${z.label} falls back to P4 Connect when its other routes are unreachable.`})},Qr=()=>(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Xr===null?null:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This machine is on your P4 Connect account. Use it as a fallback route.`}),(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:G,onClick:()=>void Zr(),children:`Add P4 Connect`})]}),Yr(),ke?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:ke}):null,(0,Q.jsxs)(L,{variant:`outline`,className:`w-full`,disabled:G,onClick:()=>void Sr(),children:[(0,Q.jsx)(le,{className:`size-3.5`}),G?`Adding…`:z?`Add route`:`Add environment`]})]}),ei=()=>(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`block`,children:[(0,Q.jsx)(`label`,{htmlFor:`saved-backend-ssh-host`,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`SSH host or alias`}),(0,Q.jsxs)(Cn,{items:Vn,itemToStringValue:e=>e.alias,mode:`none`,openOnInputClick:!0,open:U,onOpenChange:De,onItemHighlighted:e=>{Oe.current=e},value:H,onValueChange:(e,t)=>{if(xe(e),t.reason!==`item-press`)return;let n=Vn.find(t=>t.alias===e);n&&Er(n)},children:[(0,Q.jsx)(Tn,{id:`saved-backend-ssh-host`,onKeyDown:Z,placeholder:`Search hosts or type devbox`,disabled:G,spellCheck:!1}),Wn?(0,Q.jsx)(En,{children:Hn?(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`Loading hosts…`}):Vn.length>0?(0,Q.jsx)(Sn,{className:`max-h-72`,children:Vn.map((e,n)=>{let r=Br(e),i=n<9?Ut(n):null,a=i?Kt(t,i,navigator.platform):null;return(0,Q.jsxs)(Dn,{value:e,className:`h-8 min-h-8 whitespace-nowrap`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium`,children:e.alias}),r===e.alias?(0,Q.jsx)(`span`,{className:`flex-1`}):(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:r}),a?(0,Q.jsx)(wn,{className:`shrink-0`,children:a}):null]},`${e.alias}:${e.hostname}:${e.port??``}`)})}):(0,Q.jsxs)(xn,{className:`break-all`,children:[`No hosts match "`,H.trim(),`".`]})}):null]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem]`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Username`}),(0,Q.jsx)(Tt,{value:Se,onChange:e=>we(e.target.value),onKeyDown:Cr,placeholder:`root`,disabled:G,spellCheck:!1})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Port`}),(0,Q.jsx)(Tt,{value:Te,onChange:e=>Ee(e.target.value),onKeyDown:Cr,placeholder:`22`,inputMode:`numeric`,disabled:G,spellCheck:!1})]})]}),ke||Un?(0,Q.jsx)(un,{variant:`error`,children:(0,Q.jsx)(ln,{children:ke??Un})}):null,(0,Q.jsxs)(L,{variant:`outline`,className:`w-full`,disabled:G,onClick:()=>void Sr(),children:[(0,Q.jsx)(le,{className:`size-3.5`}),G?`Adding…`:z?`Add route`:`Add environment`]})]})}),ti=()=>(0,Q.jsx)(lr,{checked:Gn?.mode===`network-accessible`,disabled:!Gn||Re,onCheckedChange:e=>{wt(e?`network-accessible`:`local-only`),Ve(!0)},"aria-label":`Enable network access`}),ni=e=>zt?Rr.map(t=>{let n=Xi(t);return(0,Q.jsx)(aa,{endpoint:t,isDefault:n===Ur,presentation:e,onSetDefault:Gr,onSetupTailscaleServe:hr,onDisableTailscaleServe:_r,isUpdatingTailscaleServe:q},t.id)}):null,ri=(0,$.useCallback)(async t=>{if(e&&f!==null&&pt(f,`environment:maintain`)){Ge(!0),$e(null);try{await t(),$n()}catch(e){let t=e instanceof Error?e.message:`Failed to update WSL backend.`;$e(t),J.add(vt({type:`error`,title:`Could not change WSL backend`,description:t})),$n()}finally{Ge(!1)}}},[e,f]),ai=(0,$.useCallback)(()=>{$e(null),$n()},[]),si=(0,$.useMemo)(()=>n.some(e=>Ue(e.entry.target)),[n]),ci=(0,$.useCallback)(t=>{if(!e||!X)return;let n=X.distros.find(e=>e.isDefault)?.name??null;if(t===ji){if(!X.enabled&&!X.wslOnly)return;let t=X.wslOnly;if(si||t){rt({kind:`disable`,wasWslOnly:t});return}ri(()=>e.setWslBackendEnabled(!1));return}let r=t===Ai?null:t,i=r??n;X.enabled?(X.distro??n)!==i&&(si||X.wslOnly?rt({kind:`distro`,nextDistro:r}):ri(()=>e.setWslDistro(r))):rt({kind:`enable`,nextDistro:r})},[ri,e,X,si]),li=(0,$.useCallback)(t=>{if(!e||!Y||Y.kind!==`enable`)return;let n=Y.nextDistro;rt(null);let r=X?.distro??null;ri(()=>ir({bridge:e,mode:t,nextDistro:n,persistedDistro:r}))},[ri,e,X,Y]),ui=(0,$.useCallback)(t=>{e&&X&&X.wslOnly!==t&&rt({kind:`wsl-only`,nextValue:t})},[e,X]),di=(0,$.useCallback)(()=>{if(!e||!Y)return;let t=Y;t.kind!==`enable`&&(rt(null),t.kind===`disable`?ri(async()=>{let n=await e.setWslBackendEnabled(!1);return t.wasWslOnly?await e.setWslOnly(!1):n}):t.kind===`distro`?ri(()=>e.setWslDistro(t.nextDistro)):ri(()=>e.setWslOnly(t.nextValue)))},[ri,e,Y]),pi=()=>{if(!X)return sr({state:null,error:On})&&$t?(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`Couldn't load the WSL backend state.`,status:(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}),control:(0,Q.jsx)(L,{size:`sm`,variant:`outline`,onClick:ai,disabled:An,children:An?`Retrying…`:`Retry`})}):null;if(!sr({state:X,error:On}))return null;if(!X.available)return(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`WSL is unavailable, so Windows is running instead. Turn WSL off to clear this preference.`,status:On?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}):null,control:(0,Q.jsx)(L,{size:`sm`,variant:`outline`,disabled:We,onClick:()=>ci(ji),children:`Switch to Windows`})});let e=X.distros.find(e=>e.isDefault)?.name??null,t=X.enabled?X.distro??e??Ai:ji,n=t===ji?`Off`:t===Ai?`Default distro`:t;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`Run the selected WSL distro alongside Windows. Projects remain on their current filesystem.`,status:On?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}):X.preflightError?(0,Q.jsxs)(`span`,{className:`block text-destructive`,children:[`WSL backend couldn't start: `,X.preflightError]}):null,control:(0,Q.jsxs)(Ze,{value:t,onValueChange:e=>{typeof e==`string`&&ci(e)},children:[(0,Q.jsx)(Xe,{size:`sm`,className:`w-full sm:w-56`,"aria-label":`WSL backend`,disabled:We,children:(0,Q.jsx)(Je,{children:n})}),(0,Q.jsxs)(Ye,{align:`end`,alignItemWithTrigger:!1,children:[(0,Q.jsx)(qe,{hideIndicator:!0,value:ji,children:`Off`}),X.distros.length===0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qe,{hideIndicator:!0,value:Ai,children:`Default distro`}),X.distro===null?null:(0,Q.jsx)(qe,{hideIndicator:!0,value:X.distro,children:X.distro})]}):X.distros.map(e=>(0,Q.jsxs)(qe,{hideIndicator:!0,value:e.name,children:[e.name,e.isDefault?` (default)`:``]},e.name))]})]})}),X.enabled?(0,Q.jsx)(vn,{title:`WSL only`,description:`Run only the WSL backend. P4 Code restarts when this changes.`,className:`bg-muted/20 pl-7 sm:pl-8`,control:(0,Q.jsx)(lr,{checked:X.wslOnly,disabled:We,onCheckedChange:e=>ui(e),"aria-label":`Run WSL only`})}):null]})},mi=()=>(0,Q.jsx)(vn,{title:Rn(`tailscale-https`).title,description:Lr?Lr.status===`available`?Lr.httpBaseUrl:`Use Tailscale Serve to expose this backend through a MagicDNS HTTPS URL.`:`Start Tailscale to set up HTTPS access through MagicDNS.`,control:Lr?(0,Q.jsx)(lr,{checked:Lr.status===`available`,disabled:q,onCheckedChange:e=>{e?hr(Lr):_r(Lr)},"aria-label":`Enable Tailscale HTTPS`}):null}),hi=e=>(0,Q.jsxs)(Q.Fragment,{children:[Yn?(0,Q.jsx)(`div`,{className:Vi(e),children:(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:Yn})}):null,(0,Q.jsx)(ia,{endpointUrl:Gn?.endpointUrl,endpoints:zr,defaultEndpointKey:Ur,presentation:e,isLoading:Xn,pairingLinks:Ir,createdPairingCredentials:ee,clientSessions:Qn,revokingPairingLinkId:re,revokingClientSessionId:ae,onRevokePairingLink:vr,onRevokeClientSession:yr,canRevoke:Yt})]}),gi=()=>(0,Q.jsx)(vn,{title:Rn(`network-access`).title,description:rr?(0,Q.jsx)(oa,{endpoint:Vr,hiddenEndpointCount:Math.max(Rr.length-1,0),expanded:zt,onToggleExpanded:()=>Bt(e=>!e),fallback:Gn?.endpointUrl?`Reachable at ${Gn.endpointUrl}`:Gn?.advertisedHost?`Exposed on all interfaces. Pairing links use ${Gn.advertisedHost}.`:`Exposed on all interfaces.`}):Gn?`Limited to this machine.`:`Loading…`,status:qn?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:qn}):null,control:ti()}),_i=()=>(0,Q.jsx)(vn,{title:Rn(`network-access`).title,description:e?`This connection cannot view or change network exposure.`:g===`remote-reachable`?`Remote access is already configured. Change network exposure where the server starts.`:g===`loopback-browser`?`Only this machine can connect. Restart with a non-loopback host for remote pairing.`:`Network exposure information is unavailable.`,control:!e&&(g===`remote-reachable`||g===`loopback-browser`)?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`span`,{className:`inline-flex`,children:(0,Q.jsx)(lr,{checked:rr,disabled:!0,"aria-label":`Enable network access`})})}),(0,Q.jsx)(St,{side:`top`,children:`Network exposure changes restart the backend and must be controlled where the server process is launched.`})]}):void 0}),vi=(0,Q.jsx)(Q.Fragment,{children:f===null?(0,Q.jsxs)(bn,{...Rn(`connections-environment`),children:[(0,Q.jsx)(vn,{title:`No environment selected`,description:`Connect an environment to view its settings and access.`}),(0,Q.jsx)(Mr,{}),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(bn,{...Rn(`connections-environment`),title:r?.label??(e?`This machine`:`Primary environment`),icon:(0,Q.jsx)(sn,{"aria-hidden":!0,kind:It?h(It):`desktop`,className:`size-4`}),headerAction:f===null?null:(0,Q.jsxs)(C,{children:[(0,Q.jsx)(M,{render:(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`More actions for this machine`}),children:(0,Q.jsx)(te,{className:`size-3.5`})}),(0,Q.jsx)(ue,{align:`end`,children:(0,Q.jsx)(Fr,{environmentId:f,serverConfig:It})})]}),children:[(0,Q.jsx)(Mr,{}),$t?(0,Q.jsx)(vn,{title:`Version`,description:Rt.status===`idle`?[It?.environment.serverVersion??null,r?.displayUrl??null].filter(e=>e!==null).join(` · `)||`Loading…`:(0,Q.jsx)(zn,{state:Rt}),control:Lt&&f!==null&&Rt.status!==`running`?(0,Q.jsx)(Tr,{size:`sm`,environmentId:f,serverLabel:r?`${r.label} server`:`server`,selfUpdate:tr(It),installation:It?.environment.capabilities.serverInstallation,desktopAppUpdate:Jn(It),threadContinuation:In(It),targetVersion:Lt.clientVersion,label:Rt.status===`failed`?`Retry update`:`Update to ${Lt.clientVersion}`}):Rt.status===`idle`&&It?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Up to date`}):void 0}):null,$t&&e?(0,Q.jsxs)(Q.Fragment,{children:[gi(),ni(`endpoint-rail`),mi(),pi(),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):$t?(0,Q.jsxs)(Q.Fragment,{children:[_i(),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):null,r?(0,Q.jsxs)(`details`,{className:`group px-3 sm:px-4`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-md text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring [&::-webkit-details-marker]:hidden`,children:[`Permissions`,(0,Q.jsx)(y,{"aria-hidden":!0,className:`size-3 text-muted-foreground group-open:rotate-90`})]}),(0,Q.jsx)(kr,{environmentId:r.environmentId,connected:r.connection.phase===`connected`})]}):null]}),Jt||Yt?(0,Q.jsx)(Dr,{id:`authorized-clients`,title:`Authorized clients`,summary:Wi(Qn,Ir),control:Yt?(0,Q.jsx)(ra,{delegatableScopes:m??[],onPairingLinkCreated:ne,clientSessions:Jt&&en.error===null&&en.data?.type===`snapshot`?Qn:null,isRevokingOtherClients:R,onRevokeOtherClients:br}):void 0,children:(0,Q.jsx)(Et,{scrollFade:!0,chainVerticalScroll:!0,className:`max-h-[22.5rem]`,"data-testid":`authorized-clients-scroll-area`,children:Jt?hi(`current`):(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`This connection can create access links but cannot view authorized clients.`})})}):null,(0,Q.jsx)(_n,{open:Be&&$t,onOpenChange:e=>{Re||Ve(e)},onOpenChangeComplete:e=>{e||wt(null)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:bt===`network-accessible`?`Enable network access?`:`Disable network access?`}),(0,Q.jsx)(hn,{children:bt===`network-accessible`?`Let your other devices connect to P4 Code over the network. Pair devices to give them access. P4 Code will restart.`:`Devices connected over your local network will disconnect. Existing tunnels, such as P4 Connect or Tailscale HTTPS, keep working. P4 Code will restart.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:Re,render:(0,Q.jsx)(L,{variant:`outline`,disabled:Re}),children:(0,Q.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:`Cancel`})}),(0,Q.jsxs)(L,{variant:`default`,onClick:pr,disabled:!$t||bt===null||Re,children:[Re&&(0,Q.jsx)(Qe,{size:`sm`}),(0,Q.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:Re?`Restarting…`:bt===`network-accessible`?`Restart and enable`:`Restart and disable`})]})]})]})}),(0,Q.jsx)(_n,{open:it&&$t,onOpenChange:e=>{We||e||rt(null)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:Y?.kind===`disable`?Y.wasWslOnly?`Turn off WSL and switch back to Windows?`:`Disable WSL backend?`:Y?.kind===`distro`?`Switch WSL distro?`:Y?.kind===`enable`?`Start the WSL backend`:Y?.nextValue?`Run only the WSL backend?`:`Re-enable the Windows backend?`}),(0,Q.jsx)(hn,{children:Y?.kind===`disable`?Y.wasWslOnly?`P4 Code will restart on the Windows backend. Threads and projects opened against WSL stay safe inside the distro and become available again when you re-enable WSL.`:`The WSL backend will stop. Threads and projects opened against WSL stay safe inside the distro, but they'll be unavailable in P4 Code until you re-enable WSL.`:Y?.kind===`distro`?`P4 Code will restart the WSL backend on the new distro. Sessions still running on the current distro will be interrupted.`:Y?.kind===`enable`?`Run the WSL backend alongside the Windows one, or stop the Windows backend and use only WSL? You can change this later from Settings.`:Y?.nextValue?`P4 Code will restart and start only the WSL backend. Your Windows-side projects won't be accessible until you turn this off again.`:`P4 Code will restart and bring the Windows backend back up alongside WSL.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:We,render:(0,Q.jsx)(L,{variant:`outline`,disabled:We}),children:`Cancel`}),Y?.kind===`enable`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{variant:`outline`,onClick:()=>li(`wsl-only`),disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):`Use only WSL`}),(0,Q.jsx)(L,{variant:`default`,onClick:()=>li(`both`),disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):`Run both backends`})]}):(0,Q.jsx)(L,{variant:Y?.kind===`disable`||Y?.kind===`wsl-only`&&Y.nextValue?`destructive`:`default`,onClick:di,disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):Y?.kind===`disable`?Y.wasWslOnly?`Switch to Windows`:`Disable WSL`:Y?.kind===`distro`?`Switch distro`:Y?.nextValue?`Restart and enable`:`Restart and disable`})]})]})}),(0,Q.jsx)(_n,{open:dt&&$t,onOpenChange:e=>{q||mt(e)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:`Disable Tailscale HTTPS?`}),(0,Q.jsx)(hn,{children:`P4 Code will restart the local backend without Tailscale Serve.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:q,render:(0,Q.jsx)(L,{variant:`outline`,disabled:q}),children:`Cancel`}),(0,Q.jsx)(L,{variant:`destructive`,onClick:()=>void gr(),disabled:q||!$t,children:q?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):`Restart and disable`})]})]})}),(0,Q.jsx)(Ft,{open:ot!==null,onOpenChange:e=>{q||e||st(null)},children:(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Set up Tailscale HTTPS?`}),(0,Q.jsx)(Nt,{children:`P4 Code will restart the local backend with Tailscale Serve enabled and ask Tailscale to proxy HTTPS traffic to this backend.`})]}),(0,Q.jsxs)(Mt,{children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`HTTPS port`}),(0,Q.jsx)(Tt,{className:`mt-2`,type:`number`,inputMode:`numeric`,min:1,max:65535,step:1,value:ht,onChange:e=>yt(e.target.value),disabled:q})]}),cr?null:(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:`Enter a port from 1 to 65535.`}),(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-muted/20 px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`HTTPS endpoint`}),(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm text-foreground`,children:ur??`Pending MagicDNS endpoint`})}),ur?(0,Q.jsx)(St,{side:`top`,children:ur}):null]})]})]}),(0,Q.jsxs)(kt,{children:[(0,Q.jsx)(jt,{disabled:q,render:(0,Q.jsx)(L,{variant:`outline`,disabled:q}),children:`Cancel`}),(0,Q.jsx)(L,{onClick:()=>void mr(),disabled:q||!cr,children:q?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):`Enable`})]})]})})]})});return(0,Q.jsxs)(yn,{children:[vi,(0,Q.jsxs)(bn,{...Rn(`remote-environments`),title:`Environments`,headerAction:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[E.length>0?(0,Q.jsx)(er,{targets:E,variant:`ghost-muted`}):null,(0,Q.jsxs)(Ft,{open:ce,onOpenChange:e=>{fe(e),e?pe(null):W(null)},children:[(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`ghost-muted`,"aria-label":`Add environment`,children:[(0,Q.jsx)(le,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Add environment`})]})})}),(0,Q.jsx)(St,{side:`top`,children:`Add environment`})]}),(0,Q.jsxs)(Pt,{className:`max-h-[80dvh] sm:max-w-3xl`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:z?`Add a route to ${z.label}`:`Add Environment`}),(0,Q.jsx)(Nt,{children:z?`Pair this machine again over another address, such as its Tailscale name. It joins the existing routes instead of adding a second machine.`:`Pair another environment to this client.`})]}),(0,Q.jsx)(Mt,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Jr({mode:`remote`,title:`Remote link`,description:`Enter a backend host and pairing code.`,icon:(0,Q.jsx)(c,{"aria-hidden":!0,className:`size-4`})}),e?Jr({mode:`ssh`,title:`SSH`,description:`Use local SSH config, agent, and tunnels for the backend.`,icon:(0,Q.jsx)(b,{"aria-hidden":!0,className:`size-4`})}):null]}),(0,Q.jsx)(Ht,{children:me===`ssh`?ei():Qr()})]})})]})]})]}),children:[x.map(e=>(0,Q.jsx)(ca,{environment:e,removingEnvironmentId:Ne,onSetEnabled:Or,onRemove:Pr,onAddRoute:e=>{pe(e),W(null),fe(!0)}},e.environmentId)),(0,Q.jsx)(Sa,{primaryEnvironmentId:f,savedEnvironments:v})]}),Pe()?(0,Q.jsx)(oi,{environmentLabel:jr?.label??null,onCancel:()=>Nr(null),onConfirm:()=>{jr&&(Nr(null),Ar(jr))}}):null,(0,Q.jsx)(qr,{}),i.map((e,t)=>(0,Q.jsx)(Wr,{environmentId:e.environmentId,environmentLabel:i.length>1?e.label:null,isSearchTarget:t===0},e.environmentId)),(0,Q.jsx)($r,{environments:D}),(0,Q.jsx)(ii,{environments:D})]})}function wa(e){let{kind:t}=e;J.add({type:`success`,title:t===`hosted-link`?`Hosted app link copied`:t===`link`?`Pairing URL copied`:`Pairing code copied`,description:t===`hosted-link`?`Open it in the browser on the device you want to connect.`:t===`link`?`Open it in the client you want to pair to this environment.`:`Paste it into another client to finish pairing.`})}function Ta(e){return $i(e)?`hosted-link`:`link`}function Ea(e){return!e}function Da(e){return e.currentTarget.select()}function Oa(e){return e.currentTarget.select()}function ka(e){return e!==null}var Aa=Ca;export{Aa as component};
2
- //# sourceMappingURL=settings.connections-CHXX5kH0.js.map
1
+ import{a as e,t}from"./react-BUfh6y28.js";import{n,t as r}from"./jsx-runtime-DJeoFXNw.js";import{t as i}from"./plus-B2sOrZDk.js";import{$_ as a,$l as o,AC as s,Bd as c,Bv as l,Cx as u,Dx as d,Kf as f,M_ as p,O_ as m,Pl as h,Px as g,Q_ as _,Qo as v,Rd as y,Rm as b,SE as x,X_ as S,Xn as C,Y_ as w,Yc as T,_s as E,aE as D,av as O,cr as k,cs as A,cv as j,dr as M,dv as N,er as P,eu as F,ev as ee,fS as I,ff as te,fr as L,fv as ne,hE as re,ir as ie,iv as ae,lr as oe,lv as R,ms as se,nb as ce,nm as le,nr as ue,ns as de,om as fe,or as z,ov as pe,pm as me,pr as he,pv as ge,q_ as _e,rr as B,rv as V,ss as ve,sv as ye,t as be,uh as H,ur as xe,uv as Se,vE as Ce,vv as we,yE as Te,yb as Ee}from"./utils-C5GGWTfe.js";import{Dt as U,Et as De,F as Oe,Ht as ke,On as Ae,Ot as W,R as je,Ut as G,W as Me,jt as K,kt as Ne,o as Pe,on as Fe,tt as Ie,w as Le,x as Re}from"./runtime-BVmDVuJ-.js";import{E as ze,F as Be,Ft as Ve,Pt as q,S as He,_ as Ue,jt as We,kt as Ge,t as Ke}from"./runtime-BK2Lh1vB.js";import{a as qe,c as Je,o as Ye,s as Xe,t as Ze}from"./select-vBkqTMKL.js";import{t as Qe}from"./spinner-BZ5ohCyO.js";import{i as J,p as $e}from"./toast-BZ96uuab.js";import{A as et,D as tt,E as nt,O as Y,_ as rt,c as it,et as at,s as ot,y as st}from"./useSettings-B09a3zie.js";import{f as ct,h as lt,s as ut}from"./server-DwkxciXh.js";import{a as dt,i as ft,n as pt,o as mt,s as ht}from"./session-BIwsf8Q4.js";import{n as gt}from"./query-B2_Td0ad.js";import{t as _t}from"./use-atom-command-CdV5BZYB.js";import{t as vt}from"./toastHelpers-DxXYm50b.js";import{i as yt,r as bt}from"./timestampFormat-wac2e_Jz.js";import{a as xt,n as St,t as Ct}from"./tooltip-BPiLl1TV.js";import{t as wt}from"./textarea-DIg__-Gi.js";import{t as Tt}from"./input-FUjAUGXY.js";import{t as Et}from"./scroll-area-Cf7uLi_s.js";import{a as Dt,c as Ot,i as kt,l as At,n as jt,o as Mt,r as Nt,s as Pt,t as Ft}from"./dialog-BpR3dRVS.js";import{n as It}from"./P4ConnectAccountPages-J205rNHS.js";import{a as Lt,i as Rt,o as zt,r as Bt,t as Vt}from"./empty-Cy-8us9l.js";import{t as Ht}from"./AnimatedHeight-yuTG4G03.js";import{C as Ut,_ as Wt,w as Gt,y as Kt}from"./keybindings-DuCyi9aT.js";import{i as qt,o as Jt,t as Yt}from"./popover-hYAmvSJj.js";import{a as Xt,c as Zt,i as Qt,l as $t,r as en,s as tn,t as nn,u as rn}from"./LinkMachineSelect-DGm4EDKi.js";import{t as an}from"./checkbox-d50pgAVe.js";import{r as on}from"./uiStateStore-4i21PZUL.js";import{n as sn,t as cn}from"./EnvironmentMachineIcon-B6wAZat7.js";import{r as ln,t as un}from"./alert-BOVMKHDy.js";import{a as dn,i as fn,n as pn,o as mn,r as hn,s as gn,t as _n}from"./alert-dialog-Du3fYY3I.js";import{a as vn,i as yn,s as bn,u as X}from"./settingsLayout-WhjsCfB6.js";import{_ as xn,b as Sn,g as Cn,h as wn,v as Tn,x as En,y as Dn}from"./command-DFkhX6wm.js";import{t as On}from"./ConnectionStatusDot-CpmZ8NE5.js";import{a as kn,n as An,o as jn,s as Mn,t as Nn}from"./primary-BlS2rEKe.js";import{n as Pn,t as Fn}from"./onboarding-CE8pzS12.js";import{$r as In,Ai as Ln,Ar as Rn,Br as zn,Ci as Bn,Di as Vn,Fi as Hn,Ii as Un,Mi as Wn,Ni as Gn,Oi as Kn,Pi as qn,Qr as Jn,Rr as Yn,Si as Xn,T as Zn,Ti as Qn,Tr as $n,Vr as er,Xr as tr,Yr as nr,an as rr,ar as ir,br as ar,cn as or,cr as sr,fr as cr,go as lr,gr as ur,hr as dr,ji as fr,ki as pr,ln as mr,lr as hr,mo as gr,or as _r,po as vr,pr as yr,sn as br,sr as xr,ur as Sr,wi as Cr,wr,zr as Tr}from"./main-C0z861OK.js";import{n as Er}from"./ConnectAgentSurface-CNWdh9ck.js";import{t as Dr}from"./FoldedSettingsSection-DIlgxayr.js";var Z=n(),Or=[{scope:ae,title:`View environment`,description:`Read threads, status, checkpoints, and configuration.`},{scope:V,title:`Operate tasks`,description:`Start, update, and stop tasks.`},{scope:R,title:`Change environment settings`,description:`Edit environment preferences and keybindings.`},{scope:pe,title:`Manage providers`,description:`Configure, install, sign in to, and update providers and usage sources.`},{scope:_,title:`Maintain environment`,description:`Update the server and control environment processes.`},{scope:O,title:`Control previews`,description:`Open browser previews and host browser automation.`},{scope:S,title:`View diagnostics and usage`,description:`Read process diagnostics, resource history, and usage totals.`},{scope:ge,title:`View terminals`,description:`Read existing terminal output and status.`},{scope:ne,title:`Use terminals`,description:`Create terminals and send input to running shells.`},{scope:Se,title:`Change source control`,description:`Commit, push, manage branches and repositories, and change pull requests.`},{scope:a,title:`Read files`,description:`Browse host files, search workspaces, and inspect local changes.`},{scope:ee,title:`Write files`,description:`Edit workspace files and save plans to disk.`},{scope:_e,title:`View access`,description:`Inspect pairing links and authorized clients.`},{scope:w,title:`Manage access`,description:`Issue and revoke credentials for other clients.`},{scope:ye,title:`View relay`,description:`Inspect managed relay connectivity.`},{scope:j,title:`Manage relay`,description:`Change managed tunnel connectivity.`}],Q=e(r(),1);function kr(e){let t=(0,Z.c)(4),{environmentId:n,connected:r,routeContext:i}=e,a=i!==void 0&&i,o=dt(n),s;return t[0]!==r||t[1]!==a||t[2]!==o?(s=r&&!o.hasError&&!o.isPending&&o.data?.authenticated?(0,Q.jsxs)(`div`,{className:`space-y-3 py-3 text-xs`,children:[(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:a?`These permissions apply to your active route. Other routes may have different permissions.`:`These permissions apply to this client’s current connection.`}),(0,Q.jsx)(`ul`,{className:`grid gap-x-6 gap-y-2 sm:grid-cols-2`,children:Or.map(e=>{let{scope:t,title:n}=e;return(0,Q.jsxs)(`li`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`span`,{children:n}),(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:we(o.data,t)?`Allowed`:`Not granted`})]},t)})})]}):(0,Q.jsx)(`p`,{className:`py-3 text-xs text-muted-foreground`,children:`Permissions not checked. Connect to this environment to view this session’s permissions.`}),t[0]=r,t[1]=a,t[2]=o,t[3]=s):s=t[3],s}var $=e(t(),1);function Ar(e,t){let n=new URL(e);return n.pathname=`/pair`,Ve(n,t).toString()}function jr(e,t){return new URL(e).protocol===`https:`?He({host:e,token:t}):null}function Mr(){let e=(0,Z.c)(48),t=window.desktopBridge?.setLocalEnvironmentEnabled,[n]=(0,$.useState)(Nr),[r,i]=(0,$.useState)(!1),[a,o]=(0,$.useState)(!1),[s,c]=(0,$.useState)(null);if(!t)return null;let l;e[0]===n?l=e[1]:(l=async()=>{o(!0),c(null);try{await t(!n)}catch(e){let t=e;c(t instanceof Error?t.message:`Couldn't change this setting.`),o(!1)}},e[0]=n,e[1]=l);let u=l,d;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=Rn(`local-environment`),e[2]=d):d=e[2];let f=n?`Run agents on this computer. Turn off to use P4 Code only with remote environments.`:`Turned off. Agents only run in remote environments.`,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>i(!0),e[3]=p):p=e[3];let m;e[4]!==n||e[5]!==a?(m=(0,Q.jsx)(lr,{checked:n,disabled:a,onCheckedChange:p,"aria-label":`Local environment`}),e[4]=n,e[5]=a,e[6]=m):m=e[6];let h;e[7]!==f||e[8]!==m?(h=(0,Q.jsx)(vn,{...d,description:f,control:m}),e[7]=f,e[8]=m,e[9]=h):h=e[9];let g;e[10]===a?g=e[11]:(g=e=>{a||(i(e),e||c(null))},e[10]=a,e[11]=g);let _=n?`Turn off local environment?`:`Turn on local environment?`,v;e[12]===_?v=e[13]:(v=(0,Q.jsx)(gn,{children:_}),e[12]=_,e[13]=v);let y=n?`P4 Code will restart without running a server on this computer. Any agents and terminals running here will stop, and other devices will no longer be able to connect to this computer. Your projects, history, and remote environments are unaffected.`:`P4 Code will restart and start running a server on this computer again.`,b;e[14]===y?b=e[15]:(b=(0,Q.jsx)(hn,{children:y}),e[14]=y,e[15]=b);let x;e[16]!==b||e[17]!==v?(x=(0,Q.jsxs)(dn,{children:[v,b]}),e[16]=b,e[17]=v,e[18]=x):x=e[18];let S;e[19]===s?S=e[20]:(S=s?(0,Q.jsx)(`p`,{className:`px-6 pb-4 text-sm text-destructive`,children:s}):null,e[19]=s,e[20]=S);let C;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(L,{variant:`outline`}),e[21]=C):C=e[21];let w;e[22]===a?w=e[23]:(w=(0,Q.jsx)(pn,{disabled:a,render:C,children:`Cancel`}),e[22]=a,e[23]=w);let T=n?`destructive`:`default`,E;e[24]===u?E=e[25]:(E=()=>void u(),e[24]=u,e[25]=E);let D;e[26]!==n||e[27]!==a?(D=a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):n?`Restart and turn off`:`Restart and turn on`,e[26]=n,e[27]=a,e[28]=D):D=e[28];let O;e[29]!==a||e[30]!==T||e[31]!==E||e[32]!==D?(O=(0,Q.jsx)(L,{variant:T,disabled:a,onClick:E,children:D}),e[29]=a,e[30]=T,e[31]=E,e[32]=D,e[33]=O):O=e[33];let k;e[34]!==w||e[35]!==O?(k=(0,Q.jsxs)(fn,{children:[w,O]}),e[34]=w,e[35]=O,e[36]=k):k=e[36];let A;e[37]!==x||e[38]!==S||e[39]!==k?(A=(0,Q.jsxs)(mn,{children:[x,S,k]}),e[37]=x,e[38]=S,e[39]=k,e[40]=A):A=e[40];let j;e[41]!==r||e[42]!==A||e[43]!==g?(j=(0,Q.jsx)(_n,{open:r,onOpenChange:g,children:A}),e[41]=r,e[42]=A,e[43]=g,e[44]=j):j=e[44];let M;return e[45]!==j||e[46]!==h?(M=(0,Q.jsxs)(Q.Fragment,{children:[h,j]}),e[45]=j,e[46]=h,e[47]=M):M=e[47],M}function Nr(){return!Le()}function Pr(e){return e.serverConfig===null?`Connect to this environment to change its icon.`:e.serverConfig.environment.capabilities.environmentIcon===!0?e.operateAccess===`granted`?null:`Your session on this environment cannot change its settings.`:`This environment's server is too old to keep an icon. Update it to choose one.`}function Fr(e){let t=(0,Z.c)(27),{environmentId:n,serverConfig:r}=e,i=st(n),a=ft(n,`settings:write`)?`granted`:`denied`,o;t[0]!==a||t[1]!==r?(o=Pr({serverConfig:r,operateAccess:a}),t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c=r?.environment.platform.machine??`server`,l;t[3]===r?l=t[4]:(l=h(r),t[3]=r,t[4]=l);let u=l,d;t[5]===u?d=t[6]:(d=(0,Q.jsxs)(xe,{children:[(0,Q.jsx)(sn,{kind:u}),`Icon`]}),t[5]=u,t[6]=d);let f;t[7]===s?f=t[8]:(f=s===null?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{disabled:!0,className:`whitespace-normal`,children:s}),(0,Q.jsx)(z,{})]}),t[7]=s,t[8]=f);let g;t[9]!==c||t[10]!==s||t[11]!==i?(g=e=>{s===null&&p(e)&&i({environmentIcon:e===c?null:e})},t[9]=c,t[10]=s,t[11]=i,t[12]=g):g=t[12];let _;t[13]!==c||t[14]!==s||t[15]!==r?.environment?(_=m.map(e=>(0,Q.jsx)(ie,{value:e,disabled:s!==null,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(sn,{kind:e,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:cn[e]}),e===c?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:r?.environment.platform.machine?`detected`:`default`}):null]})},e)),t[13]=c,t[14]=s,t[15]=r?.environment,t[16]=_):_=t[16];let v;t[17]!==u||t[18]!==g||t[19]!==_?(v=(0,Q.jsx)(B,{value:u,onValueChange:g,children:_}),t[17]=u,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==f||t[22]!==v?(y=(0,Q.jsxs)(oe,{children:[f,v]}),t[21]=f,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==d||t[25]!==y?(b=(0,Q.jsxs)(k,{children:[d,y]}),t[24]=d,t[25]=y,t[26]=b):b=t[26],b}function Ir(e){let t=(0,Z.c)(31),{environment:n,onAddRoute:r}=e,i=Ne(n.entry),a=i.map(Rr),[o,s]=(0,$.useState)(null),c=o!==null&&o.length===a.length&&o.some((e,t)=>e!==a[t])?[...o]:a,l=new Map(i.map(Lr)),u=c.flatMap(e=>l.get(e)??[]),d=ht(n.environmentId),f;t[0]!==n.connection||t[1]!==d._tag||t[2]!==d.value?(f=d._tag===`Some`&&n.connection.phase===`connected`?U(d.value.target):null,t[0]=n.connection,t[1]=d._tag,t[2]=d.value,t[3]=f):f=t[3];let p=f,m=_t(lt.reorderRoutes,`Reorder routes`),h=_t(lt.removeRoute,`Remove route`),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g={activationConstraint:{distance:4}},t[4]=g):g=t[4];let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_={coordinateGetter:Vn},t[5]=_):_=t[5];let v=Hn(qn(Wn,g),qn(fr,_)),y;t[6]!==n.environmentId||t[7]!==h?(y=async e=>{let t=De(e);await at(`Remove ${W(e)} route?${t===null?``:`\n${t}`}`,{variant:`destructive`})===!0&&await h({environmentId:n.environmentId,routeId:U(e.target)})},t[6]=n.environmentId,t[7]=h,t[8]=y):y=t[8];let b=y,x=e=>{if(e.over===null||e.active.id===e.over.id)return;let t=Qn(c,c.indexOf(String(e.active.id)),c.indexOf(String(e.over.id)));s(t),m({environmentId:n.environmentId,routeIds:t}).then(e=>{e._tag===`Failure`&&s(null)})},S=Ln,C=Gn,w;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=[Bn,Xn],t[9]=w):w=t[9];let T=Cr,E=pr,D=`Routes to ${n.label}, preferred first`,O=u.map((e,t)=>(0,Q.jsx)(zr,{route:e,position:t+1,inUse:U(e.target)===p,removable:u.length>1&&!K(e),onRemove:()=>void b(e)},U(e.target))),k;t[10]!==O||t[11]!==D?(k=(0,Q.jsx)(`ol`,{"aria-label":D,children:O}),t[10]=O,t[11]=D,t[12]=k):k=t[12];let A;t[13]!==T||t[14]!==c||t[15]!==k||t[16]!==E?(A=(0,Q.jsx)(T,{items:c,strategy:E,children:k}),t[13]=T,t[14]=c,t[15]=k,t[16]=E,t[17]=A):A=t[17];let j;t[18]!==S||t[19]!==x||t[20]!==v||t[21]!==A||t[22]!==C||t[23]!==w?(j=(0,Q.jsx)(S,{sensors:v,collisionDetection:C,modifiers:w,onDragEnd:x,children:A}),t[18]=S,t[19]=x,t[20]=v,t[21]=A,t[22]=C,t[23]=w,t[24]=j):j=t[24];let M;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(le,{className:`size-3`}),t[25]=M):M=t[25];let N;t[26]===r?N=t[27]:(N=(0,Q.jsx)(`div`,{className:`-ml-1.5 pt-1`,children:(0,Q.jsxs)(L,{size:`xs`,variant:`ghost-muted`,onClick:r,children:[M,`Add route`]})}),t[26]=r,t[27]=N);let P;return t[28]!==j||t[29]!==N?(P=(0,Q.jsxs)(`div`,{className:`mt-2 border-t border-border/50 py-2`,children:[j,N]}),t[28]=j,t[29]=N,t[30]=P):P=t[30],P}function Lr(e){return[U(e.target),e]}function Rr(e){return U(e.target)}function zr(e){let t=(0,Z.c)(43),{route:n,position:r,inUse:i,removable:a,onRemove:o}=e,s;t[0]===n.target?s=t[1]:(s=U(n.target),t[0]=n.target,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=W(n),t[2]=n,t[3]=l);let u=l,d;t[4]===n?d=t[5]:(d=De(n),t[4]=n,t[5]=d);let p=d,m;t[6]===c?m=t[7]:(m={id:c},t[6]=c,t[7]=m);let{attributes:h,listeners:g,setNodeRef:_,setActivatorNodeRef:v,transform:y,transition:b,isDragging:x}=Kn(m),S;t[8]===y?S=t[9]:(S=Un.Translate.toString(y),t[8]=y,t[9]=S);let C;t[10]!==S||t[11]!==b?(C={transform:S,transition:b},t[10]=S,t[11]=b,t[12]=C):C=t[12];let w=x&&`relative z-10 rounded-md bg-background shadow-md`,T;t[13]===w?T=t[14]:(T=be(`flex items-center gap-2 py-2`,w),t[13]=w,t[14]=T);let E;t[15]===i?E=t[16]:(E=i?(0,Q.jsx)(`span`,{className:`rounded-sm bg-success/12 px-1 text-2xs font-normal text-success-foreground`,children:`In use`}):null,t[15]=i,t[16]=E);let D;t[17]!==u||t[18]!==E?(D=(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[u,E]}),t[17]=u,t[18]=E,t[19]=D):D=t[19];let O;t[20]!==p||t[21]!==n?(O=p===null?null:(0,Q.jsxs)(`p`,{className:`truncate text-2xs text-muted-foreground`,children:[p,K(n)?` · found automatically`:``]}),t[20]=p,t[21]=n,t[22]=O):O=t[22];let k;t[23]!==D||t[24]!==O?(k=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O]}),t[23]=D,t[24]=O,t[25]=k):k=t[25];let A=`Reorder ${u}, position ${r}`,j;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(f,{className:`size-3.5`}),t[26]=j):j=t[26];let M;t[27]!==h||t[28]!==g||t[29]!==v||t[30]!==A?(M=(0,Q.jsx)(`button`,{type:`button`,ref:v,...h,...g,"aria-label":A,className:`flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground/70 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring active:cursor-grabbing`,children:j}),t[27]=h,t[28]=g,t[29]=v,t[30]=A,t[31]=M):M=t[31];let N;t[32]!==u||t[33]!==o||t[34]!==a?(N=a?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`Remove ${u} route`,onClick:o}),children:(0,Q.jsx)(H,{className:`size-3`})}),(0,Q.jsx)(St,{side:`top`,children:`Remove route`})]}):null,t[32]=u,t[33]=o,t[34]=a,t[35]=N):N=t[35];let P;return t[36]!==_||t[37]!==k||t[38]!==M||t[39]!==N||t[40]!==C||t[41]!==T?(P=(0,Q.jsxs)(`li`,{ref:_,style:C,className:T,children:[k,M,N]}),t[36]=_,t[37]=k,t[38]=M,t[39]=N,t[40]=C,t[41]=T,t[42]=P):P=t[42],P}function Br(e){let t=e.username?`${e.username}@${e.hostname}`:e.hostname;return e.port?`${t}:${e.port}`:t}function Vr(e,t=null){let{entry:n}=e;if(n.target._tag===`PrimaryConnectionTarget`)return`This machine`;let r=Ne(n);if(r.length>1){let e=t===null?void 0:r.find(e=>U(e.target)===U(t));return e===void 0?W(r[0]):`via ${W(e)}`}return e.relayManaged?`P4 Connect`:Ue(n.target)?`WSL`:n.target._tag===`SshConnectionTarget`&&Te(n.profile)&&n.profile.value._tag===`SshConnectionProfile`?`SSH ${Br(n.profile.value.target)}`:e.displayUrl??`Remote link`}function Hr(e){let t=(0,Z.c)(23),{kind:n,label:r,subtitle:i,below:a,detail:o,dimmed:s,className:c,children:l}=e,u=s!==void 0&&s&&`opacity-60`,d;t[0]!==c||t[1]!==u?(d=be(`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 px-3 py-2.5 sm:px-4`,u,c),t[0]=c,t[1]=u,t[2]=d):d=t[2];let f;t[3]===n?f=t[4]:(f=(0,Q.jsx)(sn,{"aria-hidden":!0,kind:n,className:`size-4 text-muted-foreground`}),t[3]=n,t[4]=f);let p;t[5]===r?p=t[6]:(p=(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:r}),t[5]=r,t[6]=p);let m;t[7]===i?m=t[8]:(m=(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:i}),t[7]=i,t[8]=m);let h;t[9]!==a||t[10]!==p||t[11]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[p,m,a]}),t[9]=a,t[10]=p,t[11]=m,t[12]=h):h=t[12];let g;t[13]===l?g=t[14]:(g=(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:l}),t[13]=l,t[14]=g);let _;t[15]===o?_=t[16]:(_=o?(0,Q.jsx)(`div`,{className:`col-span-2 col-start-2 min-w-0`,children:o}):null,t[15]=o,t[16]=_);let v;return t[17]!==d||t[18]!==f||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,Q.jsxs)(`div`,{className:d,children:[f,h,g,_]}),t[17]=d,t[18]=f,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var Ur=(e,t)=>J.add(vt({type:`error`,title:e,description:t}));function Wr(e){let t=(0,Z.c)(19),{environmentId:n,environmentLabel:r,isSearchTarget:i}=e,a;t[0]===n?a=t[1]:(a=cr.list({environmentId:n,input:{}}),t[0]=n,t[1]=a);let o=gt(a),s;t[2]===n?s=t[3]:(s=cr.link.permissionAtom(n),t[2]=n,t[3]=s);let c=de(s),l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=Rn(`linked-environments`),t[4]=l):l=t[4];let u=l,d;t[5]===i?d=t[6]:(d=i?{id:u.id}:{},t[5]=i,t[6]=d);let f=r===null?u.title:`${u.title} · ${r}`,p;t[7]!==c||t[8]!==n?(p=c?(0,Q.jsx)(Kr,{environmentId:n}):null,t[7]=c,t[8]=n,t[9]=p):p=t[9];let m;t[10]!==n||t[11]!==o.data||t[12]!==o.error?(m=o.error?(0,Q.jsx)(vn,{title:`Could not load linked environments`,description:o.error}):o.data?o.data.links.length===0?(0,Q.jsx)(vn,{title:`No linked environments`,description:`Link another machine running P4 Code, such as a VPS, so agents here can launch and drive threads there.`}):o.data.links.map(e=>(0,Q.jsx)(Gr,{environmentId:n,link:e},e.environmentId)):(0,Q.jsx)(vn,{title:`Loading linked environments…`,role:`status`}),t[10]=n,t[11]=o.data,t[12]=o.error,t[13]=m):m=t[13];let h;return t[14]!==d||t[15]!==f||t[16]!==p||t[17]!==m?(h=(0,Q.jsx)(bn,{...d,title:f,headerAction:p,children:m}),t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h):h=t[18],h}function Gr(e){let t=(0,Z.c)(37),{environmentId:n,link:r}=e,i=rn(),a;t[0]!==r||t[1]!==i?(a=ur(r,d(i)),t[0]=r,t[1]=i,t[2]=a):a=t[2];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={label:`unlink environment`},t[3]=s):s=t[3];let c=_t(cr.unlink,s),l;t[4]===n?l=t[5]:(l=cr.unlink.permissionAtom(n),t[4]=n,t[5]=l);let u=de(l),[f,p]=(0,$.useState)(!1),m;t[6]!==n||t[7]!==r.environmentId||t[8]!==r.label||t[9]!==c?(m=async()=>{if(!await(at(`Forget ${r.label}? Agents here stop working there. Revoke "P4 Code · …" in ${r.label}'s Connections to end the session there too.`,{variant:`destructive`})??Promise.resolve(!1)))return;p(!0);let e=await c({environmentId:n,input:{environmentId:r.environmentId}});p(!1),e._tag===`Failure`&&!je(e)&&Ur(`Could not forget the link`,String(Me(e)))},t[6]=n,t[7]=r.environmentId,t[8]=r.label,t[9]=c,t[10]=m):m=t[10];let h=m,g=o.kind===`expired`?`Expired. Link it again with a new pairing code.`:o.kind===`unreachable`?o.detail??`Not answering right now.`:o.kind===`failing`?o.detail:o.expiresInDays===null?`Reachable`:`Expires in ${o.expiresInDays} ${o.expiresInDays===1?`day`:`days`}. Link it again to renew.`,_=o.kind===`reachable`?o.expiresInDays===null?`bg-success`:`bg-warning`:o.kind===`expired`||o.kind===`failing`?`bg-destructive`:`bg-muted-foreground/30`,v;t[11]!==g||t[12]!==_?(v=(0,Q.jsx)(On,{tooltipText:g,dotClassName:_,pingClassName:null}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===r.label?y=t[15]:(y=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:r.label}),t[14]=r.label,t[15]=y);let b;t[16]!==v||t[17]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[v,y]}),t[16]=v,t[17]=y,t[18]=b):b=t[18];let x=Er[r.access],S;t[19]!==g||t[20]!==x.label?(S=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[x.label,` · `,g]}),t[19]=g,t[20]=x.label,t[21]=S):S=t[21];let C;t[22]===r.urls?C=t[23]:(C=r.urls.join(`, `),t[22]=r.urls,t[23]=C);let w;t[24]===C?w=t[25]:(w=(0,Q.jsx)(`p`,{className:`truncate text-xs text-muted-foreground/80`,children:C}),t[24]=C,t[25]=w);let T;t[26]!==S||t[27]!==w||t[28]!==b?(T=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[b,S,w]}),t[26]=S,t[27]=w,t[28]=b,t[29]=T):T=t[29];let E;t[30]!==f||t[31]!==u||t[32]!==h?(E=u?(0,Q.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:f,onClick:()=>void h(),children:f?`Forgetting…`:`Forget`})}):null,t[30]=f,t[31]=u,t[32]=h,t[33]=E):E=t[33];let D;return t[34]!==T||t[35]!==E?(D=(0,Q.jsx)(`div`,{className:br,children:(0,Q.jsxs)(`div`,{className:or,children:[T,E]})}),t[34]=T,t[35]=E,t[36]=D):D=t[36],D}function Kr(e){let t=(0,Z.c)(84),{environmentId:n}=e,[r,a]=(0,$.useState)(!1),o=yr(n,r),[s,c]=(0,$.useState)(null),[l,u]=(0,$.useState)(``),[d,f]=(0,$.useState)(``),[p,m]=(0,$.useState)(`approval-required`),[h,g]=(0,$.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=new Set,t[0]=_):_=t[0];let[v,y]=(0,$.useState)(_),b=(0,$.useRef)(!1),x=(0,$.useId)(),S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S={label:`link environment`},t[1]=S):S=t[1];let C=_t(cr.link,S),T=s??(o.length===0?`another-address`:null),E;t[2]!==o||t[3]!==T?(E=o.find(e=>e.environmentId===T)??null,t[2]=o,t[3]=T,t[4]=E):E=t[4];let O=E,k=O?.environmentId??null,A=ht(k),j=ft(k,w),M;t[5]!==A||t[6]!==j||t[7]!==v||t[8]!==k?(M=k!==null&&Te(A)&&j&&!v.has(k),t[5]=A,t[6]=j,t[7]=v,t[8]=k,t[9]=M):M=t[9];let N=M,P=T===`another-address`||O?.urls.length===0,F;t[10]!==l||t[11]!==N||t[12]!==P||t[13]!==d||t[14]!==T?(F=T!==null&&(!P||l.trim().length>0)&&(N||d.trim().length>0),t[10]=l,t[11]=N,t[12]=P,t[13]=d,t[14]=T,t[15]=F):F=t[15];let ee=F,I;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{a(e),e||(c(null),u(``),f(``),m(`approval-required`),y(new Set))},t[16]=I):I=t[16];let te=I,ne;t[17]!==p||t[18]!==N||t[19]!==d||t[20]!==k?(ne=async()=>{if(!N||k===null)return d.trim();let e=await Xt(k,p);return D(e)?e.success:(y(e=>new Set(e).add(k)),Ur(`Could not link the environment`,ar(e.failure)),null)},t[17]=p,t[18]=N,t[19]=d,t[20]=k,t[21]=ne):ne=t[21];let re=ne,ie;t[22]!==p||t[23]!==l||t[24]!==n||t[25]!==C||t[26]!==O||t[27]!==P||t[28]!==ee||t[29]!==re?(ie=async()=>{let[e,...t]=O===null||P?[l.trim()]:O.urls;if(b.current||!ee||e===void 0)return;b.current=!0,g(!0);let r=await re(),i=r===null?null:await C({environmentId:n,input:{url:e,...t.length>0?{alternateUrls:t}:{},...O===null?{}:{expectedEnvironmentId:O.environmentId,expectedLabel:O.label},pairingCode:r,access:p}});b.current=!1,g(!1),i!==null&&(i._tag===`Success`?(J.add({type:`success`,title:`Linked ${i.value.label}`}),te(!1)):je(i)||Ur(`Could not link the environment`,String(Me(i))))},t[22]=p,t[23]=l,t[24]=n,t[25]=C,t[26]=O,t[27]=P,t[28]=ee,t[29]=re,t[30]=ie):ie=t[30];let ae=ie,oe;t[31]===h?oe=t[32]:(oe=e=>{(e||!h)&&te(e)},t[31]=h,t[32]=oe);let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`default`,children:[(0,Q.jsx)(i,{className:`size-3`}),`Link`]})}),t[33]=R):R=t[33];let se;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Link an environment`}),(0,Q.jsx)(Nt,{children:`Agents here can then launch, message and wait on threads there. It appears in that environment's Connections, where it can be revoked.`})]}),t[34]=se):se=t[34];let ce;t[35]===ae?ce=t[36]:(ce=e=>{e.preventDefault(),ae()},t[35]=ae,t[36]=ce);let le;t[37]!==h||t[38]!==o||t[39]!==T?(le=o.length>0?(0,Q.jsx)(en,{machines:o,value:T,disabled:h,onChange:c}):null,t[37]=h,t[38]=o,t[39]=T,t[40]=le):le=t[40];let ue;t[41]===O?.linked?ue=t[42]:(ue=O?.linked?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Already linked. Linking again renews it with the access you pick.`}):null,t[41]=O?.linked,t[42]=ue);let de;t[43]!==l||t[44]!==h||t[45]!==s||t[46]!==O||t[47]!==o.length||t[48]!==P?(de=P?(0,Q.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:`Address`}),(0,Q.jsx)(Tt,{value:l,onChange:e=>{u(e.target.value),s===null&&c(nn)},placeholder:`https://box.example.ts.net`,disabled:h,autoFocus:o.length===0,nativeInput:!0,spellCheck:!1}),O===null?null:(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`This app has no address for `,O.label,` that another machine can reach. Enter its https or Tailscale address.`]})]}):null,t[43]=l,t[44]=h,t[45]=s,t[46]=O,t[47]=o.length,t[48]=P,t[49]=de):de=t[49];let fe;t[50]!==h||t[51]!==N||t[52]!==O||t[53]!==d||t[54]!==T?(fe=T===null||N?null:(0,Q.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:`Pairing code`}),(0,Q.jsx)(Tt,{value:d,onChange:e=>f(e.target.value),placeholder:O===null?`From that environment's Connections, or p4c pair there`:`Paste the code`,disabled:h,autoComplete:`one-time-code`,nativeInput:!0,spellCheck:!1}),O===null?null:(0,Q.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`Create a link on `,O.label,`: Settings → Connections → Create link, then paste its code here.`]})]}),t[50]=h,t[51]=N,t[52]=O,t[53]=d,t[54]=T,t[55]=fe):fe=t[55];let z;t[56]!==p||t[57]!==h?(z=(0,Q.jsx)(Qt,{value:p,onChange:m,disabled:h}),t[56]=p,t[57]=h,t[58]=z):z=t[58];let pe;t[59]!==x||t[60]!==ce||t[61]!==le||t[62]!==ue||t[63]!==de||t[64]!==fe||t[65]!==z?(pe=(0,Q.jsx)(Mt,{children:(0,Q.jsxs)(`form`,{id:x,className:`space-y-4`,autoComplete:`off`,onSubmit:ce,children:[le,ue,de,fe,z]})}),t[59]=x,t[60]=ce,t[61]=le,t[62]=ue,t[63]=de,t[64]=fe,t[65]=z,t[66]=pe):pe=t[66];let me;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Q.jsx)(L,{variant:`outline`,type:`button`}),t[67]=me):me=t[67];let he;t[68]===h?he=t[69]:(he=(0,Q.jsx)(jt,{disabled:h,render:me,children:`Cancel`}),t[68]=h,t[69]=he);let ge=h||!ee,_e=h?`Linking…`:`Link`,B;t[70]!==x||t[71]!==ge||t[72]!==_e?(B=(0,Q.jsx)(L,{form:x,type:`submit`,disabled:ge,children:_e}),t[70]=x,t[71]=ge,t[72]=_e,t[73]=B):B=t[73];let V;t[74]!==he||t[75]!==B?(V=(0,Q.jsxs)(kt,{variant:`bare`,children:[he,B]}),t[74]=he,t[75]=B,t[76]=V):V=t[76];let ve;t[77]!==pe||t[78]!==V?(ve=(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[se,pe,V]}),t[77]=pe,t[78]=V,t[79]=ve):ve=t[79];let ye;return t[80]!==r||t[81]!==ve||t[82]!==oe?(ye=(0,Q.jsxs)(Ft,{open:r,onOpenChange:oe,children:[R,ve]}),t[80]=r,t[81]=ve,t[82]=oe,t[83]=ye):ye=t[83],ye}function qr(){let e=(0,Z.c)(13),{environments:t}=nt(),n;e[0]===t?n=e[1]:(n=t.filter(Jr),e[0]=t,e[1]=n);let r=n,i=mt(r,R),a=_t(ct.updateSettings,`Linked environments beta update`),o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Rn(`linked-environments-beta`),e[2]=o):o=e[2];let s=o;if(r.length===0)return null;let c=s.id,l=s.title,u;if(e[3]!==r||e[4]!==a||e[5]!==i){let t;e[7]!==r.length||e[8]!==a||e[9]!==i?(t=e=>(0,Q.jsx)(vn,{title:r.length>1?e.label:`Linked environments`,description:`Let agents here work on your other machines, and theirs here. Turn it on for each machine, then link them below. While it is off, nothing new starts over a link; tasks already running finish.`,control:(0,Q.jsx)(lr,{checked:e.serverConfig?.settings.linkedEnvironmentsEnabled===!0,disabled:!i.has(e.environmentId),onCheckedChange:t=>void a({environmentId:e.environmentId,input:{patch:{linkedEnvironmentsEnabled:!!t}}}),"aria-label":`Linked environments on ${e.label}`})},e.environmentId),e[7]=r.length,e[8]=a,e[9]=i,e[10]=t):t=e[10],u=r.map(t),e[3]=r,e[4]=a,e[5]=i,e[6]=u}else u=e[6];let d;return e[11]===u?d=e[12]:(d=(0,Q.jsx)(bn,{id:c,title:l,children:u}),e[11]=u,e[12]=d),d}function Jr(e){return e.connection.phase===`connected`&&e.serverConfig?.environment.capabilities.peerLinks===!0}var Yr=[{value:100,label:`Prefer`},{value:50,label:`Normal`},{value:25,label:`Less often`},{value:0,label:`Manual only`}];function Xr(e){return e===void 0||e===50?50:e===0?0:e<50?25:100}function Zr(e){return Yr.find(t=>t.value===e).label}function Qr(e,t){let n=e.flatMap(e=>{let n=Xr(t[e.environmentId]);return n===50?[]:[`${e.label} ${Zr(n).toLowerCase()}`]});return n.length===0?null:n.join(` · `)}function $r(e){let t=(0,Z.c)(27),{environments:n}=e,r=ot(),i=it(),a=rt();if(n.length<2)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=Rn(`load-balancing`),t[0]=o):o=t[0];let{id:s,title:c}=o,l;t[1]!==n||t[2]!==r.loadBalancingEnabled||t[3]!==r.loadBalancingWeights?(l=r.loadBalancingEnabled?Qr(n,r.loadBalancingWeights):`Off`,t[1]=n,t[2]=r.loadBalancingEnabled,t[3]=r.loadBalancingWeights,t[4]=l):l=t[4];let u=!i,d;t[5]===a?d=t[6]:(d=e=>a({loadBalancingEnabled:e}),t[5]=a,t[6]=d);let f;t[7]!==r.loadBalancingEnabled||t[8]!==u||t[9]!==d?(f=(0,Q.jsx)(lr,{"aria-label":`Automatically balance load`,checked:r.loadBalancingEnabled,disabled:u,onCheckedChange:d}),t[7]=r.loadBalancingEnabled,t[8]=u,t[9]=d,t[10]=f):f=t[10];let p;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`p`,{className:`px-3 py-2.5 text-xs text-muted-foreground sm:px-4`,children:`New threads in shared projects start on the machine with the most free CPU and memory, weighted by each machine's preference.`}),t[11]=p):p=t[11];let m;if(t[12]!==n||t[13]!==r.loadBalancingEnabled||t[14]!==r.loadBalancingWeights||t[15]!==i||t[16]!==a){let e;t[18]!==r.loadBalancingEnabled||t[19]!==r.loadBalancingWeights||t[20]!==i||t[21]!==a?(e=e=>(0,Q.jsx)(Hr,{kind:h(e.serverConfig),label:e.label,subtitle:Vr(e),children:(0,Q.jsxs)(Ze,{items:Yr,value:Xr(r.loadBalancingWeights[e.environmentId]),disabled:!i||!r.loadBalancingEnabled,onValueChange:t=>{t!==null&&a({loadBalancingWeights:{...r.loadBalancingWeights,[e.environmentId]:t}})},children:[(0,Q.jsx)(Xe,{size:`xs`,className:`w-32`,"aria-label":`${e.label} load preference`,children:(0,Q.jsx)(Je,{})}),(0,Q.jsx)(Ye,{align:`end`,alignItemWithTrigger:!1,children:Yr.map(ei)})]})},e.environmentId),t[18]=r.loadBalancingEnabled,t[19]=r.loadBalancingWeights,t[20]=i,t[21]=a,t[22]=e):e=t[22],m=n.map(e),t[12]=n,t[13]=r.loadBalancingEnabled,t[14]=r.loadBalancingWeights,t[15]=i,t[16]=a,t[17]=m}else m=t[17];let g;return t[23]!==l||t[24]!==f||t[25]!==m?(g=(0,Q.jsxs)(Dr,{id:s,title:c,summary:l,control:f,children:[p,m]}),t[23]=l,t[24]=f,t[25]=m,t[26]=g):g=t[26],g}function ei(e){let{value:t,label:n}=e;return(0,Q.jsx)(qe,{value:t,children:n},t)}var ti=[{value:`off`,label:`Off`},{value:`read`,label:`Read PRs`},{value:`read-write`,label:`Read and act`}],ni={"read-write":`read and act`,read:`read PRs`};function ri(e){let t=[`read-write`,`read`].flatMap(t=>{let n=e.filter(e=>e.permission===t);return n.length===0?[]:[`${n.map(e=>e.label).join(`, `)} ${ni[t]}`]});return t.length===0?null:t.join(` · `)}function ii(e){let t=(0,Z.c)(19),{environments:n}=e,r=de(lt.githubRoutingPermissionsValueAtom),i=de(lt.catalogValueAtom),a=_t(lt.setGitHubRoutingPermission),[o,s]=(0,$.useState)(!1);if(n.length<2)return null;let c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Rn(`github-routing`),t[0]=c):c=t[0];let{id:l,title:u}=c,d;t[1]!==n||t[2]!==r?(d=ri(n.map(e=>({label:e.label,permission:G(e.entry,r)})))??`Off`,t[1]=n,t[2]=r,t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`p`,{className:`px-3 py-2.5 text-xs text-muted-foreground sm:px-4`,children:`Machines you trust here can read PR data through each other's GitHub access. Enable both machines. Read and act may use broader permissions than the machine that owns them. This applies only to this device.`}),t[4]=f):f=t[4];let p;if(t[5]!==i||t[6]!==n||t[7]!==r||t[8]!==o||t[9]!==a){let e;t[11]!==i||t[12]!==r||t[13]!==o||t[14]!==a?(e=e=>(0,Q.jsx)(Hr,{kind:h(e.serverConfig),label:e.label,subtitle:Vr(e),children:(0,Q.jsxs)(Ze,{items:ti,value:G(e.entry,r),disabled:!i.isReady||o||ke(e.entry)===null,onValueChange:t=>{t!==null&&(s(!0),a({environmentId:e.environmentId,permission:t}).then(e=>{s(!1),e._tag===`Failure`&&J.add({type:`error`,title:`Could not save GitHub routing permission`})}))},children:[(0,Q.jsx)(Xe,{size:`xs`,className:`w-32`,"aria-label":`${e.label} GitHub routing`,children:(0,Q.jsx)(Je,{})}),(0,Q.jsx)(Ye,{align:`end`,alignItemWithTrigger:!1,children:ti.map(ai)})]})},e.environmentId),t[11]=i,t[12]=r,t[13]=o,t[14]=a,t[15]=e):e=t[15],p=n.map(e),t[5]=i,t[6]=n,t[7]=r,t[8]=o,t[9]=a,t[10]=p}else p=t[10];let m;return t[16]!==d||t[17]!==p?(m=(0,Q.jsxs)(Dr,{id:l,title:u,summary:d,children:[f,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18],m}function ai(e){let{value:t,label:n}=e;return(0,Q.jsx)(qe,{value:t,children:n},t)}function oi(e){let t=(0,Z.c)(26),{environmentLabel:n,onCancel:r,onConfirm:i}=e,a=It(),[o,s]=(0,$.useState)(n);n!==null&&n!==o&&s(n);let c=a.open,l=n!==null,u;t[0]===r?u=t[1]:(u=e=>{e||r()},t[0]=r,t[1]=u);let d;t[2]===o?d=t[3]:(d=(0,Q.jsxs)(gn,{children:[`Remove `,o,` from this device?`]}),t[2]=o,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(hn,{children:`This forgets its pairing, credentials, and cached threads here.`}),t[4]=f):f=t[4];let p;t[5]!==r||t[6]!==c?(p=c?(0,Q.jsx)(he,{onClick:()=>{r(),c()},children:`P4 Connect settings`}):`P4 Connect settings`,t[5]=r,t[6]=c,t[7]=p):p=t[7];let m;t[8]===p?m=t[9]:(m=(0,Q.jsxs)(hn,{children:[`It stays on your P4 Connect account and keeps its host space. Deregister it in`,` `,p,` `,`to free it.`]}),t[8]=p,t[9]=m);let h;t[10]!==d||t[11]!==m?(h=(0,Q.jsxs)(dn,{children:[d,f,m]}),t[10]=d,t[11]=m,t[12]=h):h=t[12];let g;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(pn,{render:(0,Q.jsx)(L,{variant:`outline`}),children:`Cancel`}),t[13]=g):g=t[13];let _;t[14]===i?_=t[15]:(_=(0,Q.jsxs)(fn,{children:[g,(0,Q.jsx)(L,{variant:`destructive`,onClick:i,children:`Remove from this device`})]}),t[14]=i,t[15]=_);let v;t[16]!==h||t[17]!==_?(v=(0,Q.jsxs)(mn,{children:[h,_]}),t[16]=h,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==l||t[20]!==v||t[21]!==u?(y=(0,Q.jsx)(_n,{open:l,onOpenChange:u,children:v}),t[19]=l,t[20]=v,t[21]=u,t[22]=y):y=t[22];let b;return t[23]!==a.portals||t[24]!==y?(b=(0,Q.jsxs)(Q.Fragment,{children:[y,a.portals]}),t[23]=a.portals,t[24]=y,t[25]=b):b=t[25],b}var si={pairingLinks:[],clientSessions:[]};function ci(e,t,n){let r=n(t);return[...e.filter(e=>n(e)!==r),t]}function li(e,t){switch(t.type){case`snapshot`:return t.payload;case`pairingLinkUpserted`:return{...e,pairingLinks:ci(e.pairingLinks,t.payload,e=>e.id)};case`pairingLinkRemoved`:return{...e,pairingLinks:e.pairingLinks.filter(e=>e.id!==t.payload.id)};case`clientUpserted`:return{...e,clientSessions:ci(e.clientSessions,t.payload,e=>e.sessionId)};case`clientRemoved`:return{...e,clientSessions:e.clientSessions.filter(e=>e.sessionId!==t.payload.sessionId)}}}function ui(e,t){let n=li(e,t);return[n,[{version:1,revision:t.revision,type:`snapshot`,payload:n}]]}function di(e){return{accessChanges:Oe(e,{label:`environment-data:server:auth-access-changes`,subscribe:e=>Ie(T.subscribeAuthAccess,{}).pipe(l(()=>si,ui))})}}var fi=di(Ke),pi=3e4,mi=class extends Ee()(`DesktopNetworkAccessUnavailableError`,{}){get message(){return`Desktop network access is unavailable.`}},hi=class extends Ee()(`DesktopServerExposureStateLoadError`,{cause:ce()}){get message(){return`Failed to load desktop server exposure state.`}},gi=class extends Ee()(`DesktopAdvertisedEndpointsLoadError`,{cause:ce()}){get message(){return`Failed to load advertised desktop endpoints.`}};function _i(){return typeof window>`u`?void 0:window.desktopBridge}function vi(e){let t=I(`loadDesktopNetworkAccess`)(function*(){let t=e();if(!t)return yield*new mi;let[n,r]=yield*g([s({try:()=>t.getServerExposureState(),catch:e=>new hi({cause:e})}),s({try:()=>t.getAdvertisedEndpoints(),catch:e=>new gi({cause:e})})],{concurrency:`unbounded`});return{advertisedEndpoints:r,serverExposureState:n}});return A(t()).pipe(se({staleTime:pi,revalidateOnMount:!0}),ve,E(`desktop:network-access`))}var yi=vi(_i);function bi(){v.refresh(yi)}function xi(e,t){let n=t.trim().toLowerCase();if(n.length===0)return e;let r=[],i=[];for(let t of e){let e=t.alias.toLowerCase();e.startsWith(n)?r.push(t):e.includes(n)&&i.push(t)}return[...r,...i]}var Si=class extends Ee()(`DesktopSshDiscoveryUnavailableError`,{}){get message(){return`Desktop SSH host discovery is unavailable.`}},Ci=class extends Ee()(`DesktopSshDiscoveryError`,{cause:ce()}){get message(){return`Failed to discover SSH hosts.`}};function wi(){return typeof window>`u`?void 0:window.desktopBridge}function Ti(e){let t=I(`discoverDesktopSshHosts`)(function*(){let t=e();return t?yield*s({try:()=>t.discoverSshHosts(),catch:e=>new Ci({cause:e})}):yield*new Si});return A(t()).pipe(se({staleTime:3e4,revalidateOnMount:!0}),ve,E(`desktop:ssh-hosts`))}var Ei=Ti(wi),Di=443,Oi=[],ki=[],Ai=`backend:default-wsl`,ji=`backend:wsl-off`,Mi=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function Ni(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Mi.format(t)}function Pi(e){let t=(0,Z.c)(13),{scopes:n,label:r}=e,i=`${n.length} ${n.length===1?`scope`:`scopes`}`,a=`${r}: show ${i}`,o;t[0]===a?o=t[1]:(o=(0,Q.jsx)(`button`,{type:`button`,"aria-label":a,className:`cursor-help underline decoration-border underline-offset-2 outline-hidden hover:text-foreground focus-visible:text-foreground`}),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,Q.jsx)(Jt,{openOnHover:!0,delay:250,closeDelay:100,render:o,children:i}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`p`,{className:`mb-1 font-medium`,children:`Granted scopes`}),t[5]=c):c=t[5];let l;t[6]===n?l=t[7]:(l=n.map(Fi),t[6]=n,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,Q.jsxs)(qt,{side:`top`,align:`start`,tooltipStyle:!0,className:`w-max max-w-80 whitespace-normal`,children:[c,(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:l})]}),t[8]=l,t[9]=u);let d;return t[10]!==s||t[11]!==u?(d=(0,Q.jsxs)(Yt,{children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12],d}function Fi(e){return(0,Q.jsx)(`code`,{className:`font-mono text-foreground/85`,children:e},e)}function Ii(e){let t=e.host.trim();if(t.length===0)throw Error(`SSH host or alias is required.`);let n=t,r=e.username.trim()||null,i=null,a=n.lastIndexOf(`@`);if(a>0){let e=n.slice(0,a).trim();n=n.slice(a+1).trim(),!r&&e.length>0&&(r=e)}let o=/^\[([^\]]+)\](?::(\d+))?$/u.exec(n);if(o)n=o[1].trim(),o[2]&&(i=Number.parseInt(o[2],10));else{let e=n.split(`:`);e.length===2&&/^\d+$/u.test(e[1]??``)&&(n=e[0].trim(),i=Number.parseInt(e[1],10))}let s=e.port.trim();if(s.length>0&&(i=Number.parseInt(s,10)),n.length===0)throw Error(`SSH host or alias is required.`);if(i!==null&&(!Number.isInteger(i)||i<=0||i>65535))throw Error(`SSH port must be between 1 and 65535.`);return{alias:n,hostname:n,username:r,port:i}}function Li(e){let t=e.trim();if(!t)return null;try{let e=/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//u.test(t)||t.startsWith(`//`)?t:`https://${t}`,n=new URL(e,window.location.origin),r=ze(n);if(r)return{host:r.host,pairingCode:r.token};let i=q(n);return i?{host:n.origin,pairingCode:i}:null}catch{return null}}function Ri(e){let t=Li(e.host);if(t)return t;let n=e.host.trim(),r=e.pairingCode.trim();if(!n)throw Error(`Enter a backend host.`);if(!r)throw Error(`Enter a pairing code.`);return{host:n,pairingCode:r}}function zi(e){let t=`Failed to connect SSH host.`;return(e instanceof Error?e.message:t).replace(/^Error invoking remote method 'desktop:ensure-ssh-environment':\s*/u,``).replace(/^Ssh[A-Za-z]+Error:\s*/u,``).trim()||t}var Bi=`first:rounded-t-xl last:rounded-b-xl px-3 py-2.5 sm:px-4`;function Vi(e){return br}function Hi(e,t){return e===`endpoint-rail`?be(`relative first:rounded-t-xl last:rounded-b-xl px-3 py-3 sm:px-4`,!t&&`bg-muted/15`):be(Bi,!t&&`bg-muted/24`)}function Ui(e){return[...e].toSorted((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())}function Wi(e,t){return[`${e.length} ${e.length===1?`client`:`clients`}`,t.length>0?`${t.length} ${t.length===1?`pairing link`:`pairing links`}`:null].filter(e=>e!==null).join(` · `)}function Gi(e){return[...e].toSorted((e,t)=>e.current===t.current?e.connected===t.connected?new Date(t.issuedAt).getTime()-new Date(e.issuedAt).getTime():e.connected?-1:1:e.current?-1:1)}function Ki(e){return{...e,scopes:e.permissions??e.scopes,createdAt:u(e.createdAt),expiresAt:u(e.expiresAt)}}function qi(e){return{...e,scopes:e.permissions??e.scopes,issuedAt:u(e.issuedAt),expiresAt:u(e.expiresAt),lastConnectedAt:e.lastConnectedAt===null?null:u(e.lastConnectedAt)}}function Ji(e,t){let n=e.filter(e=>e.status!==`unavailable`);if(t){let e=n.find(e=>Xi(e)===t);if(e)return e}return n.find(e=>e.isDefault)??n.find(e=>e.reachability!==`loopback`)??n.find(e=>e.compatibility.hostedHttpsApp===`compatible`)??null}function Yi(e){return e.id.startsWith(`tailscale-magicdns:`)}function Xi(e){if(e.id.startsWith(`desktop-loopback:`))return`desktop-core:loopback:http`;if(e.id.startsWith(`desktop-lan:`))return`desktop-core:lan:http`;if(e.id.startsWith(`tailscale-ip:`))return`tailscale:ip:http`;if(Yi(e))return`tailscale:magicdns:https`;let t=`unknown`;try{t=new URL(e.httpBaseUrl).protocol.replace(/:$/u,``)}catch{}return`${e.provider.id}:${e.reachability}:${t}:${e.label}`}function Zi(e,t){return e.compatibility.hostedHttpsApp===`compatible`?jr(e.httpBaseUrl,t)??Ar(e.httpBaseUrl,t):Ar(e.httpBaseUrl,t)}function Qi(e){let t=new URL(`/pair`,window.location.href);return Ve(t,e).toString()}function $i(e){try{let t=new URL(e);return t.pathname===`/pair`&&t.searchParams.has(`host`)}catch{return!1}}function ea(e,t){if($i(t))return`Opens the hosted app, no install needed`;switch(e.reachability){case`lan`:return`Devices on the same network`;case`private-network`:return`Devices on your private network`;case`public`:return`Reachable from anywhere`;case`loopback`:return`Clients on this machine`}}var ta=(0,$.memo)(function(e){let t=(0,Z.c)(135),{pairingLink:n,credential:r,endpointUrl:i,endpoints:a,defaultEndpointKey:o,presentation:s,revokingPairingLinkId:c,onRevoke:l,canRevoke:u}=e,d=s===void 0?`current`:s,f=X(1e3),p=new Date(n.expiresAt).getTime(),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(!1),[v,y]=(0,$.useState)(null),b=(0,$.useId)(),x;t[0]===r?x=t[1]:(x=r?Qi(r):null,t[0]=r,t[1]=x);let S=x,C;t[2]!==r||t[3]!==i?(C=r&&i!=null&&i!==``?jr(i,r):null,t[2]=r,t[3]=i,t[4]=C):C=t[4];let w=C,T;if(t[5]!==r||t[6]!==o||t[7]!==a){let e=Ji(a,o);T=e&&r?Zi(e,r):null,t[5]=r,t[6]=o,t[7]=a,t[8]=T}else T=t[8];let E=T,D;if(t[9]!==r||t[10]!==a){bb0:{let e=[];if(!r){D=e;break bb0}for(let t of a){if(t.status===`unavailable`)continue;let n=Zi(t,r);e.push({id:t.id,preferenceKey:Xi(t),label:t.label,url:n,detail:ea(t,n),qrShareable:xr(t)})}D=e}t[9]=r,t[10]=a,t[11]=D}else D=t[11];let O=D,k;t[12]!==r||t[13]!==S||t[14]!==E||t[15]!==i||t[16]!==w?(k=E??(r&&i!=null&&i!==``?w??Ar(i,r):Re(window.location.hostname)?null:S),t[12]=r,t[13]=S,t[14]=E,t[15]=i,t[16]=w,t[17]=k):k=t[17];let A=k,[j,M]=(0,$.useState)(null),N=j??A??r??``,P=N!==r,F=P&&$i(N),ee=O.find(e=>e.url===N)?.qrShareable??!0,I=typeof window<`u`&&window.isSecureContext&&navigator.clipboard?.writeText!=null,te;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(te={onCopy:wa,onError:(e,t)=>{let{value:n,kind:r}=t;M(n),h(!0),J.add(vt({type:`error`,title:I?r===`hosted-link`?`Could not copy hosted app link`:r===`link`?`Could not copy pairing URL`:`Could not copy pairing code`:`Clipboard copy unavailable`,description:I?e.message:`Showing the full value instead.`}))}},t[18]=te):te=t[18];let{copyToClipboard:ne}=$e(te),re;t[19]===ne?re=t[20]:(re=(e,t)=>{ne(e,{value:e,kind:t})},t[19]=ne,t[20]=re);let ie=re,ae=Ta,oe;t[21]!==ie||t[22]!==r?(oe=()=>{r&&ie(r,`code`)},t[21]=ie,t[22]=r,t[23]=oe):oe=t[23];let R=oe,se;t[24]===n.expiresAt?se=t[25]:(se=Ni(n.expiresAt),t[24]=n.expiresAt,t[25]=se);let ce=se,le=n.label??`Pairing link`,ue;t[26]!==o||t[27]!==O||t[28]!==v?(ue=hr(O,v,o),t[26]=o,t[27]=O,t[28]=v,t[29]=ue):ue=t[29];let de=ue,z=de?.url??A,pe=de?.qrShareable??!0;if(p<=f)return null;let me;t[30]===d?me=t[31]:(me=Vi(d),t[30]=d,t[31]=me);let he;t[32]===n.createdAt?he=t[33]:(he=Ni(n.createdAt),t[32]=n.createdAt,t[33]=he);let ge=`Link created at ${he}`,_e;t[34]===ge?_e=t[35]:(_e=(0,Q.jsx)(On,{tooltipText:ge,dotClassName:`bg-warning`}),t[34]=ge,t[35]=_e);let B;t[36]===le?B=t[37]:(B=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:le}),t[36]=le,t[37]=B);let V;t[38]!==_e||t[39]!==B?(V=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[_e,B]}),t[38]=_e,t[39]=B,t[40]=V):V=t[40];let ve;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(`span`,{}),t[41]=ve):ve=t[41];let ye;t[42]!==f||t[43]!==n.expiresAt?(ye=yt(n.expiresAt,f),t[42]=f,t[43]=n.expiresAt,t[44]=ye):ye=t[44];let H;t[45]===ye?H=t[46]:(H=(0,Q.jsx)(xt,{render:ve,children:ye}),t[45]=ye,t[46]=H);let xe;t[47]===ce?xe=t[48]:(xe=(0,Q.jsx)(St,{side:`top`,children:ce}),t[47]=ce,t[48]=xe);let Se;t[49]!==H||t[50]!==xe?(Se=(0,Q.jsxs)(Ct,{children:[H,xe]}),t[49]=H,t[50]=xe,t[51]=Se):Se=t[51];let Ce;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,Q.jsx)(`span`,{"aria-hidden":!0,children:` · `}),t[52]=Ce):Ce=t[52];let we;t[53]===n.scopes?we=t[54]:(we=(0,Q.jsx)(Pi,{scopes:n.scopes,label:`Pairing link scopes`}),t[53]=n.scopes,t[54]=we);let Te;t[55]!==Se||t[56]!==we?(Te=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[Se,Ce,we]}),t[55]=Se,t[56]=we,t[57]=Te):Te=t[57];let Ee;t[58]!==r||t[59]!==A?(Ee=r?A===null?(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Copy the token and pair from another client using this backend's reachable host.`}):null:(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Create a new link to share from this client.`}),t[58]=r,t[59]=A,t[60]=Ee):Ee=t[60];let U;t[61]!==V||t[62]!==Te||t[63]!==Ee?(U=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[V,Te,Ee]}),t[61]=V,t[62]=Te,t[63]=Ee,t[64]=U):U=t[64];let De;t[65]!==g||t[66]!==b||t[67]!==A?(De=A&&I?(0,Q.jsxs)(L,{size:`xs`,variant:`outline`,"aria-expanded":g,"aria-controls":b,onClick:()=>_(Ea),children:[(0,Q.jsx)(fe,{"aria-hidden":!0}),`Share`]}):null,t[65]=g,t[66]=b,t[67]=A,t[68]=De):De=t[68];let Oe=r!==void 0&&m,ke;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>{h(e),e||M(null)},t[69]=ke):ke=t[69];let Ae;t[70]!==r||t[71]!==R||t[72]!==A?(Ae=r?I?A?null:(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:R,children:`Copy code`}):(0,Q.jsx)(At,{render:(0,Q.jsx)(L,{size:`xs`,variant:`outline`}),children:A?`Show link`:`Show code`}):null,t[70]=r,t[71]=R,t[72]=A,t[73]=Ae):Ae=t[73];let W=P?F?`Hosted app pairing link`:`Pairing link`:`Pairing code`,je;t[74]===W?je=t[75]:(je=(0,Q.jsx)(Ot,{children:W}),t[74]=W,t[75]=je);let G=P?F?`Clipboard copy is unavailable here. Open or manually copy this hosted app link on the device you want to connect.`:`Clipboard copy is unavailable here. Open or manually copy this full pairing URL on the device you want to connect.`:`Clipboard copy is unavailable here. Manually copy this code into another client.`,Me;t[76]===G?Me=t[77]:(Me=(0,Q.jsx)(Nt,{children:G}),t[76]=G,t[77]=Me);let K;t[78]!==je||t[79]!==Me?(K=(0,Q.jsxs)(Dt,{children:[je,Me]}),t[78]=je,t[79]=Me,t[80]=K):K=t[80];let Ne=P?4:3,Pe;t[81]!==N||t[82]!==Ne?(Pe=(0,Q.jsx)(wt,{readOnly:!0,value:N,rows:Ne,onFocus:Da,onClick:Oa}),t[81]=N,t[82]=Ne,t[83]=Pe):Pe=t[83];let Fe;t[84]!==ee||t[85]!==P||t[86]!==N?(Fe=P&&ee?(0,Q.jsx)(`div`,{className:`flex justify-center rounded-xl border border-border/60 bg-muted/30 p-4`,children:(0,Q.jsx)(Zn,{value:N,size:132,level:`M`,marginSize:2,title:`Pairing link — scan to open on another device`})}):null,t[84]=ee,t[85]=P,t[86]=N,t[87]=Fe):Fe=t[87];let Ie;t[88]!==Pe||t[89]!==Fe?(Ie=(0,Q.jsxs)(Mt,{children:[Pe,Fe]}),t[88]=Pe,t[89]=Fe,t[90]=Ie):Ie=t[90];let Le;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,Q.jsx)(L,{variant:`outline`,onClick:()=>h(!1),children:`Done`}),t[91]=Le):Le=t[91];let ze;t[92]===R?ze=t[93]:(ze=I?(0,Q.jsx)(L,{variant:`outline`,onClick:R,children:`Copy code`}):null,t[92]=R,t[93]=ze);let Be;t[94]===ze?Be=t[95]:(Be=(0,Q.jsxs)(kt,{variant:`bare`,children:[Le,ze]}),t[94]=ze,t[95]=Be);let Ve;t[96]!==K||t[97]!==Ie||t[98]!==Be?(Ve=(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[K,Ie,Be]}),t[96]=K,t[97]=Ie,t[98]=Be,t[99]=Ve):Ve=t[99];let q;t[100]!==Oe||t[101]!==Ae||t[102]!==Ve?(q=(0,Q.jsxs)(Ft,{open:Oe,onOpenChange:ke,children:[Ae,Ve]}),t[100]=Oe,t[101]=Ae,t[102]=Ve,t[103]=q):q=t[103];let He=!u||c===n.id,Ue;t[104]!==l||t[105]!==n.id?(Ue=()=>void l(n.id),t[104]=l,t[105]=n.id,t[106]=Ue):Ue=t[106];let We=c===n.id?`Revoking…`:`Revoke`,Ge;t[107]!==He||t[108]!==Ue||t[109]!==We?(Ge=(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:He,onClick:Ue,children:We}),t[107]=He,t[108]=Ue,t[109]=We,t[110]=Ge):Ge=t[110];let Ke;t[111]!==De||t[112]!==q||t[113]!==Ge?(Ke=(0,Q.jsxs)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:[De,q,Ge]}),t[111]=De,t[112]=q,t[113]=Ge,t[114]=Ke):Ke=t[114];let qe;t[115]!==U||t[116]!==Ke?(qe=(0,Q.jsxs)(`div`,{className:or,children:[U,Ke]}),t[115]=U,t[116]=Ke,t[117]=qe):qe=t[117];let Je=g&&z!==null,Ye;t[118]!==pe||t[119]!==ie||t[120]!==O||t[121]!==R||t[122]!==z||t[123]!==b||t[124]!==de?.id?(Ye=z===null?null:(0,Q.jsxs)(`div`,{id:b,className:`mt-3 flex flex-col gap-4 border-t border-border/50 pt-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[O.length>1?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,role:`radiogroup`,"aria-label":`Endpoint the pairing QR code and URL use`,children:[(0,Q.jsx)(`p`,{className:`text-2xs text-muted-foreground/70`,children:`Reach this machine via`}),O.map(e=>{let t=e.id===de?.id;return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:be(`flex w-full items-baseline gap-2 rounded-lg border px-2.5 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,t?`border-foreground/60 bg-muted/30`:`border-border/50 hover:bg-muted/20`),onClick:()=>y(e.id),children:[(0,Q.jsx)(`span`,{className:be(`text-xs font-medium`,t?`text-foreground`:`text-muted-foreground`),children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-2xs text-muted-foreground/70`,children:e.detail})]},e.id)})]}):null,(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-muted/30 px-2.5 py-1.5`,children:[(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-2xs text-muted-foreground`,children:z})}),(0,Q.jsx)(St,{side:`top`,children:z})]}),(0,Q.jsx)(L,{size:`xs`,variant:`ghost`,className:`shrink-0`,onClick:()=>ie(z,ae(z)),children:`Copy link`})]}),(0,Q.jsx)(L,{size:`xs`,variant:`ghost`,onClick:R,children:`Copy code only`})]}),pe?(0,Q.jsx)(`div`,{className:`w-fit shrink-0 self-center rounded-xl bg-white p-3 sm:self-start`,children:(0,Q.jsx)(Zn,{value:z,size:168,level:`M`,marginSize:1,title:`Pairing link — scan to open on another device`})}):(0,Q.jsx)(`div`,{className:`flex size-[192px] shrink-0 items-center justify-center self-center rounded-xl border border-border/50 p-4 sm:self-start`,children:(0,Q.jsx)(`p`,{className:`text-center text-2xs text-muted-foreground/70`,children:`No QR for this endpoint. Another device scanning a loopback link would dial itself; copy the URL for use on this machine instead.`})})]}),t[118]=pe,t[119]=ie,t[120]=O,t[121]=R,t[122]=z,t[123]=b,t[124]=de?.id,t[125]=Ye):Ye=t[125];let Xe;t[126]===Ye?Xe=t[127]:(Xe=(0,Q.jsx)(gr,{children:Ye}),t[126]=Ye,t[127]=Xe);let Ze;t[128]!==Je||t[129]!==Xe?(Ze=(0,Q.jsx)(vr,{open:Je,children:Xe}),t[128]=Je,t[129]=Xe,t[130]=Ze):Ze=t[130];let Qe;return t[131]!==me||t[132]!==qe||t[133]!==Ze?(Qe=(0,Q.jsxs)(`div`,{className:me,children:[qe,Ze]}),t[131]=me,t[132]=qe,t[133]=Ze,t[134]=Qe):Qe=t[134],Qe}),na=(0,$.memo)(function(e){let t=(0,Z.c)(54),{clientSession:n,presentation:r,revokingClientSessionId:i,onRevokeSession:a,canRevoke:o}=e,s=r===void 0?`current`:r,c=X(1e3),l=n.current||n.connected,u=n.lastConnectedAt,d;t[0]!==l||t[1]!==u||t[2]!==c?(d=l?u?`Connected for ${bt(u,c)}`:`Connected`:u?`Last connected at ${Ni(u)}`:`Not connected yet.`,t[0]=l,t[1]=u,t[2]=c,t[3]=d):d=t[3];let f=d,p;t[4]===n.client.deviceType?p=t[5]:(p=n.client.deviceType===`unknown`?null:n.client.deviceType[0]?.toUpperCase()+n.client.deviceType.slice(1),t[4]=n.client.deviceType,t[5]=p);let m=n.client.os??null,h=n.client.browser??null,g=n.client.ipAddress??null,_;t[6]!==p||t[7]!==m||t[8]!==h||t[9]!==g?(_=[p,m,h,g].filter(ka),t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_):_=t[10];let v=_,y;t[11]!==n.client.browser||t[12]!==n.client.label||t[13]!==n.client.os||t[14]!==n.subject?(y=n.client.label??([n.client.os,n.client.browser].filter(Boolean).join(` · `)||n.subject),t[11]=n.client.browser,t[12]=n.client.label,t[13]=n.client.os,t[14]=n.subject,t[15]=y):y=t[15];let b=y,x;t[16]===s?x=t[17]:(x=Vi(s),t[16]=s,t[17]=x);let S=l?`bg-success`:`bg-muted-foreground/30`,C=l?`bg-success/60 duration-2000`:null,w;t[18]!==f||t[19]!==S||t[20]!==C?(w=(0,Q.jsx)(On,{tooltipText:f,dotClassName:S,pingClassName:C}),t[18]=f,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;t[22]===b?T=t[23]:(T=(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:b}),t[22]=b,t[23]=T);let E;t[24]===n.current?E=t[25]:(E=n.current?(0,Q.jsx)(`span`,{className:`text-3xs text-muted-foreground/80 rounded-md border border-border/50 bg-muted/50 px-1 py-0.5`,children:`This device`}):null,t[24]=n.current,t[25]=E);let D;t[26]!==w||t[27]!==T||t[28]!==E?(D=(0,Q.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[w,T,E]}),t[26]=w,t[27]=T,t[28]=E,t[29]=D):D=t[29];let O;t[30]===v?O=t[31]:(O=v.length>0?(0,Q.jsxs)(Q.Fragment,{children:[v.join(` · `),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:` · `})]}):null,t[30]=v,t[31]=O);let k;t[32]===n.scopes?k=t[33]:(k=(0,Q.jsx)(Pi,{scopes:n.scopes,label:`Client scopes`}),t[32]=n.scopes,t[33]=k);let A;t[34]!==O||t[35]!==k?(A=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36];let j;t[37]!==D||t[38]!==A?(j=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[D,A]}),t[37]=D,t[38]=A,t[39]=j):j=t[39];let M;t[40]!==o||t[41]!==n.current||t[42]!==n.sessionId||t[43]!==a||t[44]!==i?(M=n.current?null:(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:!o||i===n.sessionId,onClick:()=>void a(n.sessionId),children:i===n.sessionId?`Revoking…`:`Revoke`}),t[40]=o,t[41]=n.current,t[42]=n.sessionId,t[43]=a,t[44]=i,t[45]=M):M=t[45];let N;t[46]===M?N=t[47]:(N=(0,Q.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:M}),t[46]=M,t[47]=N);let P;t[48]!==j||t[49]!==N?(P=(0,Q.jsxs)(`div`,{className:or,children:[j,N]}),t[48]=j,t[49]=N,t[50]=P):P=t[50];let F;return t[51]!==P||t[52]!==x?(F=(0,Q.jsx)(`div`,{className:x,children:P}),t[51]=P,t[52]=x,t[53]=F):F=t[53],F}),ra=(0,$.memo)(function({onPairingLinkCreated:e,clientSessions:t,isRevokingOtherClients:n,onRevokeOtherClients:r,delegatableScopes:i}){let o=Y(),[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(``),[d,f]=(0,$.useState)([...N]),p=d.filter(e=>i.includes(e)),[m,h]=(0,$.useState)(!1),g=(0,$.useCallback)(async()=>{if(o!==null&&p.length!==0&&pt(o,`access:write`)&&p.every(e=>pt(o,e))){h(!0);try{e(await An({label:l,scopes:p})),u(``),f(N.filter(e=>i.includes(e))),c(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to create pairing URL.`;J.add(vt({type:`error`,title:`Could not create pairing URL`,description:t}))}finally{h(!1)}}},[i,e,l,o,p]),_=(0,$.useCallback)((e,t)=>{f(n=>Sr(n,e,t))},[]);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,disabled:n||!_r(t),onClick:()=>void r(),children:n?`Revoking…`:`Revoke others`}),(0,Q.jsxs)(Ft,{open:s,onOpenChange:e=>{c(e),e||(u(``),f(N.filter(e=>i.includes(e))))},children:[(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`default`,children:[(0,Q.jsx)(le,{className:`size-3`}),`Create link`]})}),(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Create pairing link`}),(0,Q.jsx)(Nt,{children:`Generate a one-time link that another device can use to pair with this backend as an authorized client.`})]}),(0,Q.jsxs)(Mt,{children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Client label (optional)`}),(0,Q.jsx)(Tt,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. Living room iPad`,disabled:m,autoFocus:!0})]}),(0,Q.jsxs)(`section`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-foreground`,children:`Permissions`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Limit what the paired client can do.`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:m,onClick:()=>f([ae,a,S,ge].filter(e=>i.includes(e))),children:`Read only`}),(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:m,onClick:()=>f(N.filter(e=>i.includes(e))),children:`Standard`})]})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border/60 rounded-lg border border-input bg-muted/25`,children:Or.filter(({scope:e})=>i.includes(e)).map(({scope:e,title:t,description:n})=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-3 py-2.5 transition-colors hover:bg-muted/40`,children:[(0,Q.jsx)(an,{className:`mt-0.5`,checked:d.includes(e),disabled:m,onCheckedChange:t=>_(e,t===!0)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-xs font-medium text-foreground`,children:t}),(0,Q.jsx)(`span`,{className:`block text-xs leading-snug text-muted-foreground`,children:n})]})]},e))}),p.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:`Select at least one permission.`}):p.includes(`access:write`)?(0,Q.jsx)(`p`,{className:`text-xs text-warning`,children:`This client can create or revoke access for other devices.`}):null]})]}),(0,Q.jsxs)(kt,{variant:`bare`,children:[(0,Q.jsx)(L,{variant:`outline`,disabled:m,onClick:()=>c(!1),children:`Cancel`}),(0,Q.jsx)(L,{disabled:m||p.length===0,onClick:()=>void g(),children:m?`Creating…`:`Create link`})]})]})]})]})}),ia=(0,$.memo)(function(e){let t=(0,Z.c)(39),{endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:a,isLoading:o,pairingLinks:s,createdPairingCredentials:c,clientSessions:l,revokingPairingLinkId:u,revokingClientSessionId:d,onRevokePairingLink:f,onRevokeClientSession:p,canRevoke:m}=e,h=a===void 0?`current`:a,g;if(t[0]!==m||t[1]!==c||t[2]!==i||t[3]!==n||t[4]!==r||t[5]!==f||t[6]!==s||t[7]!==h||t[8]!==u){let e;t[10]!==m||t[11]!==c||t[12]!==i||t[13]!==n||t[14]!==r||t[15]!==f||t[16]!==h||t[17]!==u?(e=e=>(0,Q.jsx)(ta,{pairingLink:e,credential:c.get(e.id),endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:h,revokingPairingLinkId:u,onRevoke:f,canRevoke:m},e.id),t[10]=m,t[11]=c,t[12]=i,t[13]=n,t[14]=r,t[15]=f,t[16]=h,t[17]=u,t[18]=e):e=t[18],g=s.map(e),t[0]=m,t[1]=c,t[2]=i,t[3]=n,t[4]=r,t[5]=f,t[6]=s,t[7]=h,t[8]=u,t[9]=g}else g=t[9];let _;if(t[19]!==m||t[20]!==l||t[21]!==p||t[22]!==h||t[23]!==d){let e;t[25]!==m||t[26]!==p||t[27]!==h||t[28]!==d?(e=e=>(0,Q.jsx)(na,{clientSession:e,presentation:h,revokingClientSessionId:d,onRevokeSession:p,canRevoke:m},e.sessionId),t[25]=m,t[26]=p,t[27]=h,t[28]=d,t[29]=e):e=t[29],_=l.map(e),t[19]=m,t[20]=l,t[21]=p,t[22]=h,t[23]=d,t[24]=_}else _=t[24];let v;t[30]!==l.length||t[31]!==o||t[32]!==s.length||t[33]!==h?(v=s.length===0&&l.length===0&&!o?(0,Q.jsx)(`div`,{className:Vi(h),children:(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`No pairing links or client sessions.`})}):null,t[30]=l.length,t[31]=o,t[32]=s.length,t[33]=h,t[34]=v):v=t[34];let y;return t[35]!==g||t[36]!==_||t[37]!==v?(y=(0,Q.jsxs)(Q.Fragment,{children:[g,_,v]}),t[35]=g,t[36]=_,t[37]=v,t[38]=y):y=t[38],y}),aa=(0,$.memo)(function(e){let t=(0,Z.c)(50),{endpoint:n,isDefault:r,presentation:i,onSetDefault:a,onSetupTailscaleServe:o,onDisableTailscaleServe:s,isUpdatingTailscaleServe:c}=e,l=i===void 0?`current`:i,u=n.status===`available`,d;t[0]===n?d=t[1]:(d=Yi(n)&&n.status!==`available`,t[0]=n,t[1]=d);let f=d,p;t[2]===n?p=t[3]:(p=Yi(n)&&n.status===`available`,t[2]=n,t[3]=p);let m=p,h=!f,g=l===`endpoint-rail`,_;t[4]!==u||t[5]!==l?(_=Hi(l,u),t[4]=u,t[5]=l,t[6]=_):_=t[6];let v;t[7]!==r||t[8]!==g?(v=g&&r?(0,Q.jsx)(`span`,{className:`absolute inset-y-2 left-0 w-1 rounded-r-full bg-primary`,"aria-hidden":!0}):null,t[7]=r,t[8]=g,t[9]=v):v=t[9];let y;t[10]===n.label?y=t[11]:(y=(0,Q.jsx)(`h3`,{className:`shrink-0 text-sm leading-5 font-medium text-foreground`,children:n.label}),t[10]=n.label,t[11]=y);let b;t[12]!==n.httpBaseUrl||t[13]!==h?(b=h?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-xs leading-5 text-muted-foreground`,children:n.httpBaseUrl})}),(0,Q.jsx)(St,{side:`top`,children:n.httpBaseUrl})]}):null,t[12]=n.httpBaseUrl,t[13]=h,t[14]=b):b=t[14];let x;t[15]===u?x=t[16]:(x=u?null:(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md border border-border/70 px-1 py-0.5 text-3xs text-muted-foreground`,children:`Setup required`}),t[15]=u,t[16]=x);let S;t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[y,b,x]}),t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20];let C;t[21]===r?C=t[22]:(C=r?(0,Q.jsx)(`span`,{className:`rounded-md border border-primary/30 bg-primary/10 px-1 py-0.5 text-3xs text-primary`,children:`Default`}):null,t[21]=r,t[22]=C);let w;t[23]!==n||t[24]!==c||t[25]!==f||t[26]!==o?(w=f?(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:()=>o(n),disabled:c,children:c?`Restarting…`:`Setup`}):null,t[23]=n,t[24]=c,t[25]=f,t[26]=o,t[27]=w):w=t[27];let T;t[28]!==m||t[29]!==n||t[30]!==c||t[31]!==s?(T=m?(0,Q.jsx)(L,{size:`xs`,variant:`destructive-outline`,onClick:()=>s(n),disabled:c,children:c?`Restarting…`:`Disable`}):null,t[28]=m,t[29]=n,t[30]=c,t[31]=s,t[32]=T):T=t[32];let E;t[33]!==n||t[34]!==r||t[35]!==f||t[36]!==a?(E=!f&&!r?(0,Q.jsx)(L,{size:`xs`,variant:`outline`,onClick:()=>a(n),children:`Set as default`}):null,t[33]=n,t[34]=r,t[35]=f,t[36]=a,t[37]=E):E=t[37];let D;t[38]!==C||t[39]!==w||t[40]!==T||t[41]!==E?(D=(0,Q.jsxs)(`div`,{className:`ml-auto flex min-h-6 shrink-0 items-center justify-end gap-2`,children:[C,w,T,E]}),t[38]=C,t[39]=w,t[40]=T,t[41]=E,t[42]=D):D=t[42];let O;t[43]!==D||t[44]!==S?(O=(0,Q.jsxs)(`div`,{className:`flex min-h-6 min-w-0 flex-col gap-2 sm:-my-0.5 sm:flex-row sm:items-center`,children:[S,D]}),t[43]=D,t[44]=S,t[45]=O):O=t[45];let k;return t[46]!==O||t[47]!==_||t[48]!==v?(k=(0,Q.jsxs)(`div`,{className:_,children:[v,O]}),t[46]=O,t[47]=_,t[48]=v,t[49]=k):k=t[49],k});function oa(e){let t=(0,Z.c)(14),{endpoint:n,hiddenEndpointCount:r,expanded:i,onToggleExpanded:a,fallback:o}=e;if(!n)return o;let s;t[0]===n.httpBaseUrl?s=t[1]:(s=(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:n.httpBaseUrl}),t[0]=n.httpBaseUrl,t[1]=s);let c;t[2]!==i||t[3]!==r?(c=r>0?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:i?`Hide`:`+${r}`}):null,t[2]=i,t[3]=r,t[4]=c):c=t[4];let l;t[5]!==s||t[6]!==c?(l=(0,Q.jsxs)(Q.Fragment,{children:[s,c]}),t[5]=s,t[6]=c,t[7]=l):l=t[7];let u=l,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`span`,{className:`shrink-0`,children:`Reachable at`}),t[8]=d):d=t[8];let f;return t[9]!==i||t[10]!==r||t[11]!==a||t[12]!==u?(f=(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-1`,children:[d,r>0?(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-baseline gap-2 border-b border-dotted border-muted-foreground/60 text-left text-muted-foreground underline-offset-4 hover:border-foreground hover:text-foreground`,onClick:a,"aria-expanded":i,children:u}):(0,Q.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-2`,children:u})]}),t[9]=i,t[10]=r,t[11]=a,t[12]=u,t[13]=f):f=t[13],f}function sa(e){if(!e.entry.enabled&&e.connection.phase!==`unsupported`)return{text:`Off`,tone:`muted`};let{connection:t}=e;switch(t.phase){case`connected`:return{text:`Connected`,tone:`muted`};case`connecting`:return{text:`Connecting`,tone:`muted`};case`reconnecting`:return{text:t.error?`Reconnecting: ${t.error}`:`Reconnecting`,tone:`error`};case`unsupported`:return{text:`Client not supported`,tone:`muted`};case`error`:return{text:t.error?`Connection failed: ${t.error}`:`Connection failed`,tone:`error`};case`offline`:return{text:`Offline`,tone:`muted`};case`available`:return{text:`Not connected`,tone:`muted`}}}function ca(e){let t=(0,Z.c)(177),{environment:n,removingEnvironmentId:r,onSetEnabled:i,onRemove:a,onAddRoute:o}=e,[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(!1),[d,f]=(0,$.useState)(!1),p=n.environmentId,m=n.connection.phase===`unsupported`,g=n.entry.enabled&&!m,_=n.connection.phase===`connected`,v=r===p,b=n.connection.traceId,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S={target:`trace ID`,onCopy:_a,onError:ga},t[0]=S):S=t[0];let{copyToClipboard:w}=$e(S),T;t[1]===w?T=t[2]:(T=e=>{w(e,{traceId:e})},t[1]=w,t[2]=T);let E=T,D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D={target:`MCP URL`,onCopy:ha,onError:ma},t[3]=D):D=t[3];let{copyToClipboard:O}=$e(D),k;t[4]===n.serverConfig?k=t[5]:(k=nr(n.serverConfig),t[4]=n.serverConfig,t[5]=k);let A=k,j;t[6]===p?j=t[7]:(j=ct.updateStateAtom(p),t[6]=p,t[7]=j);let N=de(j),F=N.status===`running`&&N.stage===`resuming`,ee;t[8]===n?ee=t[9]:(ee=sa(n),t[8]=n,t[9]=ee);let I=ee,ne=n.serverConfig?.environment.serverVersion??null,ie=et(),ae;t[10]!==p||t[11]!==ie.environments?(ae=re(ie.environments.get(p)?.status??x())?.descriptor,t[10]=p,t[11]=ie.environments,t[12]=ae):ae=t[12];let oe=ae,[R,se]=(0,$.useState)(oe);oe!==void 0&&oe!==R&&se(oe);let ce;t[13]!==p||t[14]!==ie.environments?(ce=ie.environments.get(p)?.environment.endpoint.httpBaseUrl,t[13]=p,t[14]=ie.environments,t[15]=ce):ce=t[15];let le=ce,[fe,pe]=(0,$.useState)(le);le!==void 0&&le!==fe&&pe(le);let he=_t(lt.retryNow),{diagnosis:ge,state:_e,relayOnly:B}=$t(n),V=F?null:ge,ve=ht(p),ye=_&&ve._tag===`Some`?ve.value.target:null,H=le??fe,xe;t[16]!==ye||t[17]!==n.entry||t[18]!==H?(xe=We({entry:n.entry,relayHttpBaseUrl:H,connectedTarget:ye}),t[16]=ye,t[17]=n.entry,t[18]=H,t[19]=xe):xe=t[19];let Se=xe,Ce;t[20]!==n.serverConfig||t[21]!==R?(Ce=n.serverConfig??(R===void 0?null:{environment:R}),t[20]=n.serverConfig,t[21]=R,t[22]=Ce):Ce=t[22];let we;t[23]===Ce?we=t[24]:(we=h(Ce),t[23]=Ce,t[24]=we);let Te=we,Ee;t[25]===n.entry?Ee=t[26]:(Ee=Ne(n.entry),t[25]=n.entry,t[26]=Ee);let U=Ee.length,De;t[27]!==ye||t[28]!==n?(De=Vr(n,ye),t[27]=ye,t[28]=n,t[29]=De):De=t[29];let Oe=V?null:F?`Restarting`:I.text,ke=g&&A?ne:null,Ae;t[30]!==De||t[31]!==Oe||t[32]!==ke?(Ae=[De,Oe,ke].filter(pa),t[30]=De,t[31]=Oe,t[32]=ke,t[33]=Ae):Ae=t[33];let W=Ae.join(` · `),je=g&&_&&A!==null&&(N.status===`idle`||N.status===`failed`),G;t[34]!==g||t[35]!==n.connection||t[36]!==m?(G=m?n.connection.error??Ge(n.connection):g?Ge(n.connection):`Switched off`,t[34]=g,t[35]=n.connection,t[36]=m,t[37]=G):G=t[37];let Me=`${G}${A?`\nUpdate available: ${A.serverVersion} → ${A.clientVersion}`:``}`,K=n.label,Pe=!g,Fe=g&&I.tone===`error`&&!F&&!V&&`text-destructive`,Ie;t[38]===Fe?Ie=t[39]:(Ie=be(`min-w-0 truncate`,Fe),t[38]=Fe,t[39]=Ie);let Le;t[40]===Ie?Le=t[41]:(Le=(0,Q.jsx)(`span`,{className:Ie}),t[40]=Ie,t[41]=Le);let Re;t[42]!==Me||t[43]!==W||t[44]!==Le?(Re=(0,Q.jsx)(xt,{payload:Me,render:Le,children:W}),t[42]=Me,t[43]=W,t[44]=Le,t[45]=Re):Re=t[45];let ze;t[46]===Me?ze=t[47]:(ze=(0,Q.jsx)(St,{side:`top`,className:`whitespace-pre-wrap`,children:Me}),t[46]=Me,t[47]=ze);let Ve;t[48]!==Re||t[49]!==ze?(Ve=(0,Q.jsxs)(Ct,{children:[Re,ze]}),t[48]=Re,t[49]=ze,t[50]=Ve):Ve=t[50];let q;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0`,children:`·`}),t[51]=q):q=t[51];let He;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(He=()=>c(fa),t[52]=He):He=t[52];let Ue=U===1?`Routes`:`${U} routes`,Ke=s&&`rotate-90`,qe;t[53]===Ke?qe=t[54]:(qe=be(`size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none`,Ke),t[53]=Ke,t[54]=qe);let Je;t[55]===qe?Je=t[56]:(Je=(0,Q.jsx)(y,{"aria-hidden":!0,className:qe}),t[55]=qe,t[56]=Je);let Ye;t[57]!==s||t[58]!==Ue||t[59]!==Je?(Ye=(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:He,className:`inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,children:[Ue,Je]}),t[57]=s,t[58]=Ue,t[59]=Je,t[60]=Ye):Ye=t[60];let Xe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0`,children:`·`}),t[61]=Xe):Xe=t[61];let Ze=`remote-permissions-${p}`,Qe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=()=>u(da),t[62]=Qe):Qe=t[62];let J=l&&`rotate-90`,tt;t[63]===J?tt=t[64]:(tt=be(`size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none`,J),t[63]=J,t[64]=tt);let nt;t[65]===tt?nt=t[66]:(nt=(0,Q.jsx)(y,{"aria-hidden":!0,className:tt}),t[65]=tt,t[66]=nt);let Y;t[67]!==l||t[68]!==Ze||t[69]!==nt?(Y=(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":l,"aria-controls":Ze,onClick:Qe,className:`inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`,children:[`Permissions`,nt]}),t[67]=l,t[68]=Ze,t[69]=nt,t[70]=Y):Y=t[70];let rt;t[71]!==Ve||t[72]!==Ye||t[73]!==Y?(rt=(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[Ve,q,Ye,Xe,Y]}),t[71]=Ve,t[72]=Ye,t[73]=Y,t[74]=rt):rt=t[74];let it;t[75]!==_e||t[76]!==V||t[77]!==d?(it=V?(0,Q.jsx)(Zt,{diagnosis:V,retryAt:_e.phase===`backoff`?_e.retryAt:null,attempt:_e.attempt,expanded:d,onToggle:()=>f(ua)}):null,t[75]=_e,t[76]=V,t[77]=d,t[78]=it):it=t[78];let at;t[79]===N?at=t[80]:(at=N.status===`idle`?null:(0,Q.jsx)(`div`,{className:`mt-1 max-w-md`,children:(0,Q.jsx)(zn,{state:N})}),t[79]=N,t[80]=at);let ot;t[81]!==it||t[82]!==at?(ot=(0,Q.jsxs)(Q.Fragment,{children:[it,at]}),t[81]=it,t[82]=at,t[83]=ot):ot=t[83];let st;t[84]!==V||t[85]!==d||t[86]!==n||t[87]!==p||t[88]!==o||t[89]!==B||t[90]!==he?(st=V&&d?(0,Q.jsx)(tn,{hostLabel:n.label,diagnosis:V,onRetry:()=>void he(p),onAddRoute:B?()=>o(n):null}):null,t[84]=V,t[85]=d,t[86]=n,t[87]=p,t[88]=o,t[89]=B,t[90]=he,t[91]=st):st=t[91];let ut;t[92]!==n||t[93]!==o||t[94]!==s?(ut=s&&(0,Q.jsx)(Ir,{environment:n,onAddRoute:()=>o(n)}),t[92]=n,t[93]=o,t[94]=s,t[95]=ut):ut=t[95];let dt;t[96]!==p||t[97]!==_||t[98]!==l?(dt=l&&(0,Q.jsx)(`div`,{id:`remote-permissions-${p}`,className:`mt-2 border-t border-border/50`,children:(0,Q.jsx)(kr,{environmentId:p,connected:_,routeContext:!0})}),t[96]=p,t[97]=_,t[98]=l,t[99]=dt):dt=t[99];let ft;t[100]!==st||t[101]!==ut||t[102]!==dt?(ft=(0,Q.jsxs)(Q.Fragment,{children:[st,ut,dt]}),t[100]=st,t[101]=ut,t[102]=dt,t[103]=ft):ft=t[103];let pt;t[104]!==n.entry.serverUpdateRequired||t[105]!==n.label||t[106]!==p||t[107]!==R?.serverVersion||t[108]!==N.status||t[109]!==m?(pt=m&&n.entry.serverUpdateRequired===!0&&N.status!==`running`?(0,Q.jsx)(Yn,{environmentId:p,serverLabel:`${n.label} server`,fromVersion:R?.serverVersion,targetVersion:Be,label:N.status===`failed`?`Retry update`:`Update`}):null,t[104]=n.entry.serverUpdateRequired,t[105]=n.label,t[106]=p,t[107]=R?.serverVersion,t[108]=N.status,t[109]=m,t[110]=pt):pt=t[110];let mt;t[111]!==n.label||t[112]!==n.serverConfig||t[113]!==p||t[114]!==N.status||t[115]!==je||t[116]!==A?(mt=je?(0,Q.jsx)(Tr,{environmentId:p,serverLabel:`${n.label} server`,selfUpdate:tr(n.serverConfig),installation:n.serverConfig?.environment.capabilities.serverInstallation,desktopAppUpdate:Jn(n.serverConfig),threadContinuation:In(n.serverConfig),targetVersion:A.clientVersion,label:N.status===`failed`?`Retry update`:`Update`,appearance:`icon`}):null,t[111]=n.label,t[112]=n.serverConfig,t[113]=p,t[114]=N.status,t[115]=je,t[116]=A,t[117]=mt):mt=t[117];let gt=v||m,vt=`${g?`Switch off`:`Switch on`} ${n.label}`,yt;t[118]!==p||t[119]!==i?(yt=e=>i(p,e),t[118]=p,t[119]=i,t[120]=yt):yt=t[120];let bt;t[121]!==g||t[122]!==gt||t[123]!==vt||t[124]!==yt?(bt=(0,Q.jsx)(xt,{render:(0,Q.jsx)(lr,{size:`sm`,checked:g,disabled:gt,"aria-label":vt,onCheckedChange:yt})}),t[121]=g,t[122]=gt,t[123]=vt,t[124]=yt,t[125]=bt):bt=t[125];let wt=m?`Client not supported`:g?`Switch off`:`Switch on`,Tt;t[126]===wt?Tt=t[127]:(Tt=(0,Q.jsx)(St,{side:`top`,children:wt}),t[126]=wt,t[127]=Tt);let Et;t[128]!==bt||t[129]!==Tt?(Et=(0,Q.jsxs)(Ct,{children:[bt,Tt]}),t[128]=bt,t[129]=Tt,t[130]=Et):Et=t[130];let Dt=`More actions for ${n.label}`,Ot;t[131]!==v||t[132]!==Dt?(Ot=(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,disabled:v,"aria-label":Dt}),t[131]=v,t[132]=Dt,t[133]=Ot):Ot=t[133];let kt;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(kt=(0,Q.jsx)(te,{className:`size-3.5`}),t[134]=kt):kt=t[134];let At;t[135]===Ot?At=t[136]:(At=(0,Q.jsx)(M,{render:Ot,children:kt}),t[135]=Ot,t[136]=At);let jt;t[137]!==n.serverConfig||t[138]!==p?(jt=(0,Q.jsx)(Fr,{environmentId:p,serverConfig:n.serverConfig}),t[137]=n.serverConfig,t[138]=p,t[139]=jt):jt=t[139];let Mt,Nt;t[140]===Symbol.for(`react.memo_cache_sentinel`)?(Mt=()=>c(la),Nt=(0,Q.jsx)(me,{}),t[140]=Mt,t[141]=Nt):(Mt=t[140],Nt=t[141]);let Pt=s?`Hide routes`:`Routes`,Ft;t[142]===Pt?Ft=t[143]:(Ft=(0,Q.jsxs)(P,{onClick:Mt,children:[Nt,Pt]}),t[142]=Pt,t[143]=Ft);let It;t[144]!==O||t[145]!==Se?(It=Se?(0,Q.jsx)(P,{onClick:()=>O(Se,{url:Se}),children:`Copy MCP URL`}):null,t[144]=O,t[145]=Se,t[146]=It):It=t[146];let Lt;t[147]!==E||t[148]!==b?(Lt=b?(0,Q.jsx)(P,{onClick:()=>E(b),children:`Copy trace ID`}):null,t[147]=E,t[148]=b,t[149]=Lt):Lt=t[149];let Rt;t[150]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=(0,Q.jsx)(z,{}),t[150]=Rt):Rt=t[150];let zt;t[151]!==n||t[152]!==a?(zt=()=>a(n),t[151]=n,t[152]=a,t[153]=zt):zt=t[153];let Bt=v?`Removing…`:`Remove from this device…`,Vt;t[154]!==zt||t[155]!==Bt?(Vt=(0,Q.jsx)(P,{variant:`destructive`,onClick:zt,children:Bt}),t[154]=zt,t[155]=Bt,t[156]=Vt):Vt=t[156];let Ht;t[157]!==jt||t[158]!==Ft||t[159]!==It||t[160]!==Lt||t[161]!==Vt?(Ht=(0,Q.jsxs)(ue,{align:`end`,children:[jt,Ft,It,Lt,Rt,Vt]}),t[157]=jt,t[158]=Ft,t[159]=It,t[160]=Lt,t[161]=Vt,t[162]=Ht):Ht=t[162];let Ut;t[163]!==At||t[164]!==Ht?(Ut=(0,Q.jsxs)(C,{children:[At,Ht]}),t[163]=At,t[164]=Ht,t[165]=Ut):Ut=t[165];let Wt;return t[166]!==n.label||t[167]!==Te||t[168]!==Pe||t[169]!==rt||t[170]!==ot||t[171]!==ft||t[172]!==pt||t[173]!==mt||t[174]!==Et||t[175]!==Ut?(Wt=(0,Q.jsxs)(Hr,{kind:Te,label:K,dimmed:Pe,subtitle:rt,below:ot,detail:ft,children:[pt,mt,Et,Ut]}),t[166]=n.label,t[167]=Te,t[168]=Pe,t[169]=rt,t[170]=ot,t[171]=ft,t[172]=pt,t[173]=mt,t[174]=Et,t[175]=Ut,t[176]=Wt):Wt=t[176],Wt}function la(e){return!e}function ua(e){return!e}function da(e){return!e}function fa(e){return!e}function pa(e){return e!==null}function ma(e){J.add(vt({type:`error`,title:`Could not copy MCP URL`,description:e.message}))}function ha(e){let{url:t}=e;J.add({type:`success`,title:`MCP URL copied`,description:`Add it to an agent, e.g. claude mcp add --transport http p4 ${t}`})}function ga(e){J.add(vt({type:`error`,title:`Could not copy trace ID`,description:e.message}))}function _a(e){let{traceId:t}=e;J.add({type:`success`,title:`Trace ID copied`,description:t})}function va(e){let t=(0,Z.c)(10),{checked:n,disabled:r,disabledReason:i,onCheckedChange:a,ariaLabel:o}=e,s=o===void 0?`Enable P4 Connect`:o,c;t[0]===a?c=t[1]:(c=a?{onCheckedChange:a}:{},t[0]=a,t[1]=c);let l;t[2]!==s||t[3]!==n||t[4]!==r||t[5]!==c?(l=(0,Q.jsx)(lr,{"aria-label":s,checked:n,disabled:r,...c}),t[2]=s,t[3]=n,t[4]=r,t[5]=c,t[6]=l):l=t[6];let u=l,d;return t[7]!==u||t[8]!==i?(d=i?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`span`,{className:`inline-flex`,children:u})}),(0,Q.jsx)(St,{side:`top`,children:i})]}):u,t[7]=u,t[8]=i,t[9]=d):d=t[9],d}function ya(e){let t=(0,Z.c)(53),{canManageRelay:n}=e,r=Y(),{isSignedIn:i,linkState:a,linkRevoked:s,managedTunnelActive:c,managedTunnelOutOfSync:l,publishAgentActivity:u,holdWebhooksWhileOffline:d,operationError:f,reconcileCloudState:p}=mr(),[m,h]=(0,$.useState)(!1),[g,_]=(0,$.useState)(!1),v=i?n?null:`Your session does not have permission to manage P4 Connect access.`:`Sign in to P4 Connect to manage this environment.`,y=m||g,b=(0,$.useEffectEvent)(a.refresh),x;t[0]===b?x=t[1]:(x=()=>{let e=window.setInterval(()=>b(),3e4);return()=>window.clearInterval(e)},t[0]=b,t[1]=x);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],t[2]=S):S=t[2],(0,$.useEffect)(x,S);let C=c?a.data?.reachability:void 0,w;t[3]===C?w=t[4]:(w=C?.status===`reachable`?F(C):C?.status===`unreachable`?(0,Q.jsxs)(`span`,{className:`block text-destructive`,children:[[C.reason,C.hint,`Fix: ${C.fix}`].filter(Boolean).join(` `),` `,(0,Q.jsx)(`a`,{href:o(C.cause),target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:`More info`})]}):null,t[3]=C,t[4]=w);let T=w,E;t[5]!==r||t[6]!==u||t[7]!==p?(E=async e=>{r!==null&&pt(r,`relay:write`)&&(h(!0),await p({managedTunnel:e,publish:u})&&J.add({type:`success`,title:e?`P4 Connect linked`:u?`P4 Connect tunnel disabled`:`P4 Connect unlinked`,description:e?`This environment is available through P4 Connect.`:u?`The managed tunnel was removed. Agent activity publishing stays on.`:`This environment is no longer available through P4 Connect.`}),h(!1))},t[5]=r,t[6]=u,t[7]=p,t[8]=E):E=t[8];let D=E,O;t[9]!==c||t[10]!==r||t[11]!==p?(O=async e=>{r!==null&&pt(r,`relay:write`)&&(_(!0),await p({managedTunnel:c,publish:e})&&J.add({type:`success`,title:e?`Agent activity enabled`:`Agent activity disabled`,description:e?`This environment publishes agent activity to your mobile clients.`:`This environment will stop publishing agent activity.`}),_(!1))},t[9]=c,t[10]=r,t[11]=p,t[12]=O):O=t[12];let k=O,A;t[13]!==c||t[14]!==u||t[15]!==p?(A=async e=>{_(!0),await p({managedTunnel:c,publish:u,holdWebhooksWhileOffline:e})&&J.add({type:`success`,title:e?`Webhooks held while offline`:`Webhooks no longer held`,description:e?`P4 Connect keeps webhook requests for up to 24 hours while this environment is offline.`:`Requests to an offline environment now fail. Anything already held is still delivered.`}),_(!1)},t[13]=c,t[14]=u,t[15]=p,t[16]=A):A=t[16];let j=A,M;t[17]!==n||t[18]!==v||t[19]!==y||t[20]!==i||t[21]!==s||t[22]!==c||t[23]!==l||t[24]!==f||t[25]!==a.data||t[26]!==a.error||t[27]!==a.isPending||t[28]!==C?.status||t[29]!==T||t[30]!==D?(M=window.desktopBridge?(0,Q.jsx)(vn,{title:Rn(`p4-connect`).title,description:s?`This environment was removed from P4 Connect. Turn it on to link it again.`:c?C?.status===`unreachable`?`P4 Connect is on, but other devices cannot reach this environment.`:C?.status===`reachable`?`This environment is available to your other devices through P4 Connect.`:`P4 Connect is on. Reachability has not been checked yet.`:l?`P4 Connect is out of sync. This environment is linked only to publish agent activity, so other devices cannot connect. Turn P4 Connect on to repair it.`:`Make this environment available to your other devices through P4 Connect.`,status:f??a.error??T,control:(0,Q.jsx)(va,{checked:c,disabled:!n||!i||a.data===null||a.isPending||y,disabledReason:v,onCheckedChange:e=>void D(e)})}):s?(0,Q.jsx)(vn,{title:Rn(`p4-connect`).title,description:"This environment was removed from P4 Connect. Run `p4c connect link` on the host to link it again."}):null,t[17]=n,t[18]=v,t[19]=y,t[20]=i,t[21]=s,t[22]=c,t[23]=l,t[24]=f,t[25]=a.data,t[26]=a.error,t[27]=a.isPending,t[28]=C?.status,t[29]=T,t[30]=D,t[31]=M):M=t[31];let N;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(N=Rn(`publish-agent-activity`),t[32]=N):N=t[32];let P=!n||!i||a.data===null||a.isPending||y,ee;t[33]===k?ee=t[34]:(ee=e=>void k(e),t[33]=k,t[34]=ee);let I;t[35]!==v||t[36]!==u||t[37]!==ee||t[38]!==P?(I=(0,Q.jsx)(vn,{title:N.title,description:`Send activity to mobile notifications and Live Activities without P4 Connect.`,control:(0,Q.jsx)(va,{ariaLabel:`Publish agent activity to mobile clients`,checked:u,disabled:P,disabledReason:v,onCheckedChange:ee})}),t[35]=v,t[36]=u,t[37]=ee,t[38]=P,t[39]=I):I=t[39];let te;t[40]!==n||t[41]!==v||t[42]!==d||t[43]!==y||t[44]!==i||t[45]!==c||t[46]!==a.isPending||t[47]!==j?(te=c?(0,Q.jsx)(vn,{title:Rn(`hold-webhooks-while-offline`).title,description:`Keep webhook requests for up to 24 hours while this environment is offline, then deliver them. Off: P4 Connect only forwards requests and stores nothing.`,control:(0,Q.jsx)(va,{ariaLabel:`Hold webhook requests while this environment is offline`,checked:d,disabled:!n||!i||a.isPending||y,disabledReason:v,onCheckedChange:e=>void j(e)})}):null,t[40]=n,t[41]=v,t[42]=d,t[43]=y,t[44]=i,t[45]=c,t[46]=a.isPending,t[47]=j,t[48]=te):te=t[48];let L;return t[49]!==I||t[50]!==te||t[51]!==M?(L=(0,Q.jsxs)(Q.Fragment,{children:[M,I,te]}),t[49]=I,t[50]=te,t[51]=M,t[52]=L):L=t[52],L}function ba(e){let t=(0,Z.c)(3),{canReadRelay:n,canManageRelay:r}=e;if(!Pe())return null;if(!n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(vn,{title:`P4 Connect`,description:`To edit these settings, pair this connection with both View relay and Manage relay permissions.`}),t[0]=e):e=t[0],e}let i;return t[1]===r?i=t[2]:(i=(0,Q.jsx)(ya,{canManageRelay:r}),t[1]=r,t[2]=i),i}function xa(e){let t=(0,Z.c)(4),{cloudEnabled:n}=e,r=n===void 0||n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Lt,{variant:`icon`,children:(0,Q.jsx)(c,{})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(zt,{children:`No saved remote environments`}),t[1]=a):a=t[1];let o=r?`Click “Add environment” to pair another environment, or connect one from P4 Connect.`:`Click “Add environment” to pair another environment.`,s;return t[2]===o?s=t[3]:(s=(0,Q.jsxs)(Vt,{className:`min-h-52`,children:[i,(0,Q.jsxs)(Rt,{children:[a,(0,Q.jsx)(Bt,{children:o})]})]}),t[2]=o,t[3]=s),s}function Sa(e){let t=(0,Z.c)(3),{primaryEnvironmentId:n,savedEnvironments:r}=e,i;return t[0]!==n||t[1]!==r?(i=Pe()?(0,Q.jsx)(rr,{primaryEnvironmentId:n,savedEnvironments:r,empty:(0,Q.jsx)(xa,{})}):r.length===0?(0,Q.jsx)(xa,{cloudEnabled:!1}):null,t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Ca(){let e=window.desktopBridge,t=de(ut),{environments:n}=nt(),r=tt(),i=dr(),a=_t(Fn,{reportFailure:!1}),o=_t(Pn,{reportFailure:!1}),s=_t(lt.remove,{reportFailure:!1}),l=_t(lt.register,{reportFailure:!1}),u=et(),d=_t(lt.setEnabled,{reportFailure:!1}),f=r?.environmentId??null,p=Nn(),m=p.data?.authenticated?p.data.permissions??p.data.scopes??null:null,g=e?null:p.data?.auth.policy??null,v=(0,$.useMemo)(()=>n.filter(e=>e.entry.target._tag!==`PrimaryConnectionTarget`),[n]),x=(0,$.useMemo)(()=>v.filter(e=>!Ue(e.entry.target)),[v]),S=(0,$.useMemo)(()=>A(e=>v.map(t=>({environment:t,updateStatus:e(ct.updateStateAtom(t.environmentId)).status}))),[v]),T=de(S),E=(0,$.useMemo)(()=>T.flatMap(({environment:e,updateStatus:t})=>{let n=nr(e.serverConfig),r=tr(e.serverConfig),i=Jn(e.serverConfig);return!n||t===`running`||!e.entry.enabled||e.connection.phase!==`connected`||Ue(e.entry.target)||r===null||r===`desktop-managed`&&!i?[]:[{environmentId:e.environmentId,serverLabel:e.label,selfUpdate:r,installation:e.serverConfig?.environment.capabilities.serverInstallation,desktopAppUpdate:i,threadContinuation:In(e.serverConfig),continueThreadsAfterServerUpdate:e.serverConfig?.settings.continueThreadsAfterServerUpdate??!1,targetVersion:n.clientVersion}]}),[T]),D=(0,$.useMemo)(()=>[...r?[r]:[],...v.filter(e=>e.entry.enabled)],[r,v]),O=(0,$.useMemo)(()=>{let e=new Set;for(let t of v){let n=t.entry.profile;if(t.entry.target._tag!==`SshConnectionTarget`||Ce(n)||n.value._tag!==`SshConnectionProfile`)continue;let r=n.value.target;e.add(r.alias),e.add(Br(r))}return e},[v]),[k,N]=(0,$.useState)(null),[P,F]=(0,$.useState)(null),[ee,I]=(0,$.useState)(()=>new Map),ne=(0,$.useCallback)(e=>{I(t=>new Map(t).set(e.id,e.credential))},[]),[re,ie]=(0,$.useState)(null),[ae,oe]=(0,$.useState)(null),[R,se]=(0,$.useState)(!1),[ce,fe]=(0,$.useState)(!1),[z,pe]=(0,$.useState)(null),[me,he]=(0,$.useState)(`remote`),[ge,B]=(0,$.useState)(``),[V,ve]=(0,$.useState)(``),[H,xe]=(0,$.useState)(``),[Se,we]=(0,$.useState)(``),[Te,Ee]=(0,$.useState)(``),[U,De]=(0,$.useState)(!1),Oe=(0,$.useRef)(void 0),[ke,W]=(0,$.useState)(null),[G,K]=(0,$.useState)(!1),[Ne,Ie]=(0,$.useState)(null),[Re,ze]=(0,$.useState)(!1),[Be,Ve]=(0,$.useState)(!1),[q,He]=(0,$.useState)(!1),[We,Ge]=(0,$.useState)(!1),[Ke,$e]=(0,$.useState)(null),[Y,rt]=(0,$.useState)(null),it=Y!==null,[ot,st]=(0,$.useState)(null),[dt,mt]=(0,$.useState)(!1),[ht,yt]=(0,$.useState)(String(Di)),[bt,wt]=(0,$.useState)(null),It=r?.serverConfig??null,Lt=nr(It),Rt=de(ct.updateStateAtom(f)),[zt,Bt]=(0,$.useState)(!1),Vt=on(e=>e.defaultAdvertisedEndpointKey),qt=on(e=>e.setDefaultAdvertisedEndpointKey),Jt=ft(f,_e),Yt=ft(f,w),Xt=ft(f,ye),Zt=ft(f,_),Qt=ft(f,j),$t=!Le()&&Zt,en=gt(Jt&&f!==null?fi.accessChanges({environmentId:f,input:null}):null),tn=gt($t&&e?yi:null),nn=e!==void 0&&ce&&me===`ssh`,rn=gt(nn?Ei:null),an=rn.refresh;(0,$.useEffect)(()=>{nn&&an()},[nn,an]);let cn=gt($t&&e?wr:null),X=cn.data,On=Ke??cn.error,An=cn.isPending&&cn.data===null,Ln=rn.data??ki,Bn=(0,$.useMemo)(()=>Ln.filter(e=>{let t=Br(e);return!O.has(e.alias)&&!O.has(t)}),[Ln,O]),Vn=(0,$.useMemo)(()=>xi(Bn,H),[H,Bn]),Hn=rn.isPending&&rn.data===null,Un=rn.error,Wn=e!==void 0&&(Hn||Bn.length>0),Gn=tn.data?.serverExposureState??null,Kn=tn.data?.advertisedEndpoints??Oi,qn=k??tn.error,Yn=P??en.error,Xn=en.isPending&&en.data===null,Zn=(0,$.useMemo)(()=>{let e=en.data;return e?.type===`snapshot`?Ui(e.payload.pairingLinks.map(e=>Ki(e))):[]},[en.data]),Qn=(0,$.useMemo)(()=>{let e=en.data;return e?.type===`snapshot`?Gi(e.payload.clientSessions.map(e=>qi(e))):[]},[en.data]),rr=e?Gn?.mode===`network-accessible`:g===`remote-reachable`,ar=ht.trim(),or=Number(ar),cr=/^\d+$/u.test(ar)&&Number.isInteger(or)&&or>=1&&or<=65535,ur=(0,$.useMemo)(()=>{if(!ot)return null;if(!cr||or===Di)return ot.httpBaseUrl;try{let e=new URL(ot.httpBaseUrl);return e.port=String(or),e.toString().replace(/\/$/u,``)}catch{return ot.httpBaseUrl}},[cr,or,ot]),fr=(0,$.useCallback)(async t=>{if(e&&f!==null&&pt(f,`environment:maintain`)){ze(!0),N(null);try{await e.setServerExposureMode(t?`network-accessible`:`local-only`),bi(),Ve(!1),ze(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to update network exposure.`;Ve(!1),N(t),J.add(vt({type:`error`,title:`Could not update network access`,description:t})),ze(!1)}}},[e,f]),pr=(0,$.useCallback)(()=>{bt!==null&&fr(bt===`network-accessible`)},[fr,bt]),mr=(0,$.useCallback)(async()=>{if(e&&f!==null&&pt(f,`environment:maintain`)&&cr){He(!0),N(null);try{await e.setTailscaleServeEnabled({enabled:!0,port:or}),bi(),st(null)}catch(e){let t=e instanceof Error?e.message:`Failed to configure Tailscale HTTPS.`;N(t),J.add(vt({type:`error`,title:`Could not set up Tailscale HTTPS`,description:t}))}finally{He(!1)}}},[e,cr,or,f]),hr=(0,$.useCallback)(e=>{yt(String(Gn?.tailscaleServePort??Di)),st(e)},[Gn?.tailscaleServePort]),gr=(0,$.useCallback)(async()=>{if(e&&f!==null&&pt(f,`environment:maintain`)){He(!0),N(null);try{await e.setTailscaleServeEnabled({enabled:!1,port:Gn?.tailscaleServePort??Di}),bi(),mt(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to disable Tailscale HTTPS.`;N(t),J.add(vt({type:`error`,title:`Could not disable Tailscale HTTPS`,description:t}))}finally{He(!1)}}},[e,Gn,f]),_r=(0,$.useCallback)(e=>{mt(!0)},[]),vr=(0,$.useCallback)(async e=>{if(f!==null&&pt(f,`access:write`)){ie(e),F(null);try{await Mn(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke pairing link.`;F(t),J.add(vt({type:`error`,title:`Could not revoke pairing link`,description:t}))}finally{ie(null)}}},[f]),yr=(0,$.useCallback)(async e=>{if(f!==null&&pt(f,`access:write`)){oe(e),F(null);try{await jn(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke client access.`;F(t),J.add(vt({type:`error`,title:`Could not revoke client access`,description:t}))}finally{oe(null)}}},[f]),br=(0,$.useCallback)(async()=>{if(f!==null&&pt(f,`access:write`)){se(!0),F(null);try{let e=await kn();J.add({type:`success`,title:e===1?`Revoked 1 other client`:`Revoked ${e} clients`,description:`Other paired clients will need a new pairing link before reconnecting.`})}catch(e){let t=e instanceof Error?e.message:`Failed to revoke other clients.`;F(t),J.add(vt({type:`error`,title:`Could not revoke other clients`,description:t}))}finally{se(!1)}}},[f]),xr=(0,$.useCallback)(async e=>{K(!0),W(null);let t=await o({target:e,label:``,...z?{expectedEnvironmentId:z.environmentId}:{}});t._tag===`Failure`?(je(t)||W(zi(Me(t))),K(!1)):(B(``),ve(``),xe(``),we(``),Ee(``),fe(!1),J.add({type:`success`,title:z?`Route added`:`Environment connected`,description:z?`${z.label} can now be reached over SSH ${e.alias}.`:`${e.alias} is ready over an SSH-managed tunnel.`}),K(!1))},[o,z]),Sr=(0,$.useCallback)(async()=>{if(me===`ssh`){let e;try{e=Ii({host:H,username:Se,port:Te})}catch(e){W(zi(e));return}await xr(e);return}K(!0),W(null);let e;try{e=Ri({host:ge,pairingCode:V})}catch(e){let t=e instanceof Error?e.message:`Failed to add backend.`;W(t),J.add(vt({type:`error`,title:`Could not add backend`,description:t})),K(!1);return}let t=await a({...e,...z?{expectedEnvironmentId:z.environmentId}:{}});if(t._tag===`Failure`){if(!je(t)){let e=Me(t),n=e instanceof Error?e.message:`Failed to add backend.`;W(n),J.add(vt({type:`error`,title:`Could not add backend`,description:n}))}K(!1)}else B(``),ve(``),xe(``),we(``),Ee(``),fe(!1),J.add(z?{type:`success`,title:`Route added`,description:`${z.label} now has another way to connect.`}:{type:`success`,title:`Backend added`,description:`The environment is saved and will reconnect on app startup.`}),K(!1)},[z,a,xr,ge,me,V,H,Te,Se]),Cr=(0,$.useCallback)(e=>{e.nativeEvent.isComposing||e.keyCode===229||e.key===`Enter`&&H.trim().length>0&&(e.preventDefault(),Sr())},[Sr,H]),Er=(0,$.useCallback)(async t=>{if(G||!e)return;K(!0),W(null),xe(t.alias);let n;try{n=await e.resolveSshHost(t.alias)}catch(e){W(zi(e)),K(!1);return}we(n.username??``),Ee(n.port===null?``:String(n.port)),await xr(n)},[xr,e,G]),Z=(0,$.useCallback)(e=>{if(e.nativeEvent.isComposing||e.keyCode===229)return;let n=U&&Wn;if(n){let n=Wt(e,t,{platform:navigator.platform,context:{modelPickerOpen:!1}}),r=Gt(n??``),i=r===null?void 0:Vn[r];if(i){e.preventDefault(),e.stopPropagation(),De(!1),Er(i);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation();return}}let r=n&&Oe.current!==void 0;!e.defaultPrevented&&!r&&e.key===`Enter`&&H.trim().length>0&&(e.preventDefault(),Sr())},[Vn,Sr,Er,Wn,t,H,U]),Or=(0,$.useCallback)(async(e,t)=>{W(null);let n=await d({environmentId:e,enabled:t});if(n._tag===`Failure`&&!je(n)){let e=Me(n),r=e instanceof Error?e.message:`Failed to switch the backend ${t?`on`:`off`}.`;W(r),J.add(vt({type:`error`,title:`Could not switch backend ${t?`on`:`off`}`,description:r}))}},[d]),Ar=(0,$.useCallback)(async e=>{let t=e.environmentId;Ie(t),W(null);let n=await s(t);if(Ie(null),n._tag===`Failure`&&!je(n)){let e=Me(n),t=e instanceof Error?e.message:`Failed to remove backend.`;W(t),J.add(vt({type:`error`,title:`Could not remove backend`,description:t}))}},[s]),[jr,Nr]=(0,$.useState)(null),Pr=(0,$.useCallback)(async e=>{e.relayManaged&&Pe()?Nr(e):await at(`Remove ${e.label} from this device?\nThis forgets its pairing, credentials, and cached threads here. Switch it off instead to keep it saved.`,{variant:`destructive`})===!0&&await Ar(e)},[Ar]),Ir=Zn,Lr=(0,$.useMemo)(()=>Kn.find(Yi)??null,[Kn]),Rr=(0,$.useMemo)(()=>rr?Kn.filter(e=>!Yi(e)):[],[Kn,rr]),zr=(0,$.useMemo)(()=>Lr?[...Rr,Lr]:Rr,[Lr,Rr]),Vr=(0,$.useMemo)(()=>Ji(Rr,Vt),[Vt,Rr]),Hr=(0,$.useMemo)(()=>Vr??Ji(Lr?[Lr]:[],Vt),[Vt,Vr,Lr]),Ur=Hr?Xi(Hr):null,Gr=(0,$.useCallback)(e=>{qt(Xi(e))},[qt]),Kr=(0,$.useCallback)(e=>{let t=Li(e);t?(B(t.host),ve(t.pairingCode)):B(e)},[]),Jr=e=>{let t=me===e.mode;return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,className:be(`group flex min-h-24 items-start gap-3 rounded-lg border p-4 text-left`,t?`border-primary/50 bg-primary/5`:`border-border/60 hover:bg-muted/40`),disabled:G,onClick:()=>{he(e.mode)},children:[e.icon?(0,Q.jsx)(`span`,{className:be(`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border`,t?`border-primary/30 bg-primary/10 text-primary`:`border-border/70 bg-background text-muted-foreground group-hover:text-foreground`),children:e.icon}):null,(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-muted-foreground`,children:e.description})]})]})},Yr=()=>(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Host`}),(0,Q.jsx)(Tt,{value:ge,onChange:e=>Kr(e.target.value),placeholder:`backend.example.com`,disabled:G,spellCheck:!1})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Pairing code`}),(0,Q.jsx)(Tt,{value:V,onChange:e=>ve(e.target.value),placeholder:`PAIRCODE`,disabled:G,spellCheck:!1})]})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`span`,{className:`mt-1 block text-2xs text-muted-foreground`,children:`Paste a full pairing URL here to fill both fields automatically.`})})]}),Xr=z!==null&&!z.relayManaged&&u.environments.has(z.environmentId)?u.environments.get(z.environmentId).environment:null,Zr=async()=>{if(Xr===null||z===null)return;K(!0);let e=await l(new Fe({target:new Ae({environmentId:Xr.environmentId,label:z.label})}));if(K(!1),e._tag===`Failure`){if(!je(e)){let t=Me(e);W(t instanceof Error?t.message:`Could not add the route.`)}}else fe(!1),J.add({type:`success`,title:`Route added`,description:`${z.label} falls back to P4 Connect when its other routes are unreachable.`})},Qr=()=>(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Xr===null?null:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This machine is on your P4 Connect account. Use it as a fallback route.`}),(0,Q.jsx)(L,{size:`xs`,variant:`outline`,disabled:G,onClick:()=>void Zr(),children:`Add P4 Connect`})]}),Yr(),ke?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:ke}):null,(0,Q.jsxs)(L,{variant:`outline`,className:`w-full`,disabled:G,onClick:()=>void Sr(),children:[(0,Q.jsx)(le,{className:`size-3.5`}),G?`Adding…`:z?`Add route`:`Add environment`]})]}),ei=()=>(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`block`,children:[(0,Q.jsx)(`label`,{htmlFor:`saved-backend-ssh-host`,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`SSH host or alias`}),(0,Q.jsxs)(Cn,{items:Vn,itemToStringValue:e=>e.alias,mode:`none`,openOnInputClick:!0,open:U,onOpenChange:De,onItemHighlighted:e=>{Oe.current=e},value:H,onValueChange:(e,t)=>{if(xe(e),t.reason!==`item-press`)return;let n=Vn.find(t=>t.alias===e);n&&Er(n)},children:[(0,Q.jsx)(Tn,{id:`saved-backend-ssh-host`,onKeyDown:Z,placeholder:`Search hosts or type devbox`,disabled:G,spellCheck:!1}),Wn?(0,Q.jsx)(En,{children:Hn?(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`Loading hosts…`}):Vn.length>0?(0,Q.jsx)(Sn,{className:`max-h-72`,children:Vn.map((e,n)=>{let r=Br(e),i=n<9?Ut(n):null,a=i?Kt(t,i,navigator.platform):null;return(0,Q.jsxs)(Dn,{value:e,className:`h-8 min-h-8 whitespace-nowrap`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium`,children:e.alias}),r===e.alias?(0,Q.jsx)(`span`,{className:`flex-1`}):(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:r}),a?(0,Q.jsx)(wn,{className:`shrink-0`,children:a}):null]},`${e.alias}:${e.hostname}:${e.port??``}`)})}):(0,Q.jsxs)(xn,{className:`break-all`,children:[`No hosts match "`,H.trim(),`".`]})}):null]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem]`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Username`}),(0,Q.jsx)(Tt,{value:Se,onChange:e=>we(e.target.value),onKeyDown:Cr,placeholder:`root`,disabled:G,spellCheck:!1})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Port`}),(0,Q.jsx)(Tt,{value:Te,onChange:e=>Ee(e.target.value),onKeyDown:Cr,placeholder:`22`,inputMode:`numeric`,disabled:G,spellCheck:!1})]})]}),ke||Un?(0,Q.jsx)(un,{variant:`error`,children:(0,Q.jsx)(ln,{children:ke??Un})}):null,(0,Q.jsxs)(L,{variant:`outline`,className:`w-full`,disabled:G,onClick:()=>void Sr(),children:[(0,Q.jsx)(le,{className:`size-3.5`}),G?`Adding…`:z?`Add route`:`Add environment`]})]})}),ti=()=>(0,Q.jsx)(lr,{checked:Gn?.mode===`network-accessible`,disabled:!Gn||Re,onCheckedChange:e=>{wt(e?`network-accessible`:`local-only`),Ve(!0)},"aria-label":`Enable network access`}),ni=e=>zt?Rr.map(t=>{let n=Xi(t);return(0,Q.jsx)(aa,{endpoint:t,isDefault:n===Ur,presentation:e,onSetDefault:Gr,onSetupTailscaleServe:hr,onDisableTailscaleServe:_r,isUpdatingTailscaleServe:q},t.id)}):null,ri=(0,$.useCallback)(async t=>{if(e&&f!==null&&pt(f,`environment:maintain`)){Ge(!0),$e(null);try{await t(),$n()}catch(e){let t=e instanceof Error?e.message:`Failed to update WSL backend.`;$e(t),J.add(vt({type:`error`,title:`Could not change WSL backend`,description:t})),$n()}finally{Ge(!1)}}},[e,f]),ai=(0,$.useCallback)(()=>{$e(null),$n()},[]),si=(0,$.useMemo)(()=>n.some(e=>Ue(e.entry.target)),[n]),ci=(0,$.useCallback)(t=>{if(!e||!X)return;let n=X.distros.find(e=>e.isDefault)?.name??null;if(t===ji){if(!X.enabled&&!X.wslOnly)return;let t=X.wslOnly;if(si||t){rt({kind:`disable`,wasWslOnly:t});return}ri(()=>e.setWslBackendEnabled(!1));return}let r=t===Ai?null:t,i=r??n;X.enabled?(X.distro??n)!==i&&(si||X.wslOnly?rt({kind:`distro`,nextDistro:r}):ri(()=>e.setWslDistro(r))):rt({kind:`enable`,nextDistro:r})},[ri,e,X,si]),li=(0,$.useCallback)(t=>{if(!e||!Y||Y.kind!==`enable`)return;let n=Y.nextDistro;rt(null);let r=X?.distro??null;ri(()=>ir({bridge:e,mode:t,nextDistro:n,persistedDistro:r}))},[ri,e,X,Y]),ui=(0,$.useCallback)(t=>{e&&X&&X.wslOnly!==t&&rt({kind:`wsl-only`,nextValue:t})},[e,X]),di=(0,$.useCallback)(()=>{if(!e||!Y)return;let t=Y;t.kind!==`enable`&&(rt(null),t.kind===`disable`?ri(async()=>{let n=await e.setWslBackendEnabled(!1);return t.wasWslOnly?await e.setWslOnly(!1):n}):t.kind===`distro`?ri(()=>e.setWslDistro(t.nextDistro)):ri(()=>e.setWslOnly(t.nextValue)))},[ri,e,Y]),pi=()=>{if(!X)return sr({state:null,error:On})&&$t?(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`Couldn't load the WSL backend state.`,status:(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}),control:(0,Q.jsx)(L,{size:`sm`,variant:`outline`,onClick:ai,disabled:An,children:An?`Retrying…`:`Retry`})}):null;if(!sr({state:X,error:On}))return null;if(!X.available)return(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`WSL is unavailable, so Windows is running instead. Turn WSL off to clear this preference.`,status:On?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}):null,control:(0,Q.jsx)(L,{size:`sm`,variant:`outline`,disabled:We,onClick:()=>ci(ji),children:`Switch to Windows`})});let e=X.distros.find(e=>e.isDefault)?.name??null,t=X.enabled?X.distro??e??Ai:ji,n=t===ji?`Off`:t===Ai?`Default distro`:t;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vn,{...Rn(`wsl-backend`),description:`Run the selected WSL distro alongside Windows. Projects remain on their current filesystem.`,status:On?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:On}):X.preflightError?(0,Q.jsxs)(`span`,{className:`block text-destructive`,children:[`WSL backend couldn't start: `,X.preflightError]}):null,control:(0,Q.jsxs)(Ze,{value:t,onValueChange:e=>{typeof e==`string`&&ci(e)},children:[(0,Q.jsx)(Xe,{size:`sm`,className:`w-full sm:w-56`,"aria-label":`WSL backend`,disabled:We,children:(0,Q.jsx)(Je,{children:n})}),(0,Q.jsxs)(Ye,{align:`end`,alignItemWithTrigger:!1,children:[(0,Q.jsx)(qe,{hideIndicator:!0,value:ji,children:`Off`}),X.distros.length===0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qe,{hideIndicator:!0,value:Ai,children:`Default distro`}),X.distro===null?null:(0,Q.jsx)(qe,{hideIndicator:!0,value:X.distro,children:X.distro})]}):X.distros.map(e=>(0,Q.jsxs)(qe,{hideIndicator:!0,value:e.name,children:[e.name,e.isDefault?` (default)`:``]},e.name))]})]})}),X.enabled?(0,Q.jsx)(vn,{title:`WSL only`,description:`Run only the WSL backend. P4 Code restarts when this changes.`,className:`bg-muted/20 pl-7 sm:pl-8`,control:(0,Q.jsx)(lr,{checked:X.wslOnly,disabled:We,onCheckedChange:e=>ui(e),"aria-label":`Run WSL only`})}):null]})},mi=()=>(0,Q.jsx)(vn,{title:Rn(`tailscale-https`).title,description:Lr?Lr.status===`available`?Lr.httpBaseUrl:`Use Tailscale Serve to expose this backend through a MagicDNS HTTPS URL.`:`Start Tailscale to set up HTTPS access through MagicDNS.`,control:Lr?(0,Q.jsx)(lr,{checked:Lr.status===`available`,disabled:q,onCheckedChange:e=>{e?hr(Lr):_r(Lr)},"aria-label":`Enable Tailscale HTTPS`}):null}),hi=e=>(0,Q.jsxs)(Q.Fragment,{children:[Yn?(0,Q.jsx)(`div`,{className:Vi(e),children:(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:Yn})}):null,(0,Q.jsx)(ia,{endpointUrl:Gn?.endpointUrl,endpoints:zr,defaultEndpointKey:Ur,presentation:e,isLoading:Xn,pairingLinks:Ir,createdPairingCredentials:ee,clientSessions:Qn,revokingPairingLinkId:re,revokingClientSessionId:ae,onRevokePairingLink:vr,onRevokeClientSession:yr,canRevoke:Yt})]}),gi=()=>(0,Q.jsx)(vn,{title:Rn(`network-access`).title,description:rr?(0,Q.jsx)(oa,{endpoint:Vr,hiddenEndpointCount:Math.max(Rr.length-1,0),expanded:zt,onToggleExpanded:()=>Bt(e=>!e),fallback:Gn?.endpointUrl?`Reachable at ${Gn.endpointUrl}`:Gn?.advertisedHost?`Exposed on all interfaces. Pairing links use ${Gn.advertisedHost}.`:`Exposed on all interfaces.`}):Gn?`Limited to this machine.`:`Loading…`,status:qn?(0,Q.jsx)(`span`,{className:`block text-destructive`,children:qn}):null,control:ti()}),_i=()=>(0,Q.jsx)(vn,{title:Rn(`network-access`).title,description:e?`This connection cannot view or change network exposure.`:g===`remote-reachable`?`Remote access is already configured. Change network exposure where the server starts.`:g===`loopback-browser`?`Only this machine can connect. Restart with a non-loopback host for remote pairing.`:`Network exposure information is unavailable.`,control:!e&&(g===`remote-reachable`||g===`loopback-browser`)?(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`span`,{className:`inline-flex`,children:(0,Q.jsx)(lr,{checked:rr,disabled:!0,"aria-label":`Enable network access`})})}),(0,Q.jsx)(St,{side:`top`,children:`Network exposure changes restart the backend and must be controlled where the server process is launched.`})]}):void 0}),vi=(0,Q.jsx)(Q.Fragment,{children:f===null?(0,Q.jsxs)(bn,{...Rn(`connections-environment`),children:[(0,Q.jsx)(vn,{title:`No environment selected`,description:`Connect an environment to view its settings and access.`}),(0,Q.jsx)(Mr,{}),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(bn,{...Rn(`connections-environment`),title:r?.label??(e?`This machine`:`Primary environment`),icon:(0,Q.jsx)(sn,{"aria-hidden":!0,kind:It?h(It):`desktop`,className:`size-4`}),headerAction:f===null?null:(0,Q.jsxs)(C,{children:[(0,Q.jsx)(M,{render:(0,Q.jsx)(L,{type:`button`,variant:`ghost-muted`,size:`icon-xs`,"aria-label":`More actions for this machine`}),children:(0,Q.jsx)(te,{className:`size-3.5`})}),(0,Q.jsx)(ue,{align:`end`,children:(0,Q.jsx)(Fr,{environmentId:f,serverConfig:It})})]}),children:[(0,Q.jsx)(Mr,{}),$t?(0,Q.jsx)(vn,{title:`Version`,description:Rt.status===`idle`?[It?.environment.serverVersion??null,r?.displayUrl??null].filter(e=>e!==null).join(` · `)||`Loading…`:(0,Q.jsx)(zn,{state:Rt}),control:Lt&&f!==null&&Rt.status!==`running`?(0,Q.jsx)(Tr,{size:`sm`,environmentId:f,serverLabel:r?`${r.label} server`:`server`,selfUpdate:tr(It),installation:It?.environment.capabilities.serverInstallation,desktopAppUpdate:Jn(It),threadContinuation:In(It),targetVersion:Lt.clientVersion,label:Rt.status===`failed`?`Retry update`:`Update to ${Lt.clientVersion}`}):Rt.status===`idle`&&It?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Up to date`}):void 0}):null,$t&&e?(0,Q.jsxs)(Q.Fragment,{children:[gi(),ni(`endpoint-rail`),mi(),pi(),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):$t?(0,Q.jsxs)(Q.Fragment,{children:[_i(),Xt||Qt?(0,Q.jsx)(ba,{canReadRelay:Xt,canManageRelay:Qt}):null]}):null,r?(0,Q.jsxs)(`details`,{className:`group px-3 sm:px-4`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-md text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring [&::-webkit-details-marker]:hidden`,children:[`Permissions`,(0,Q.jsx)(y,{"aria-hidden":!0,className:`size-3 text-muted-foreground group-open:rotate-90`})]}),(0,Q.jsx)(kr,{environmentId:r.environmentId,connected:r.connection.phase===`connected`})]}):null]}),Jt||Yt?(0,Q.jsx)(Dr,{id:`authorized-clients`,title:`Authorized clients`,summary:Wi(Qn,Ir),control:Yt?(0,Q.jsx)(ra,{delegatableScopes:m??[],onPairingLinkCreated:ne,clientSessions:Jt&&en.error===null&&en.data?.type===`snapshot`?Qn:null,isRevokingOtherClients:R,onRevokeOtherClients:br}):void 0,children:(0,Q.jsx)(Et,{scrollFade:!0,chainVerticalScroll:!0,className:`max-h-[22.5rem]`,"data-testid":`authorized-clients-scroll-area`,children:Jt?hi(`current`):(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`This connection can create access links but cannot view authorized clients.`})})}):null,(0,Q.jsx)(_n,{open:Be&&$t,onOpenChange:e=>{Re||Ve(e)},onOpenChangeComplete:e=>{e||wt(null)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:bt===`network-accessible`?`Enable network access?`:`Disable network access?`}),(0,Q.jsx)(hn,{children:bt===`network-accessible`?`Let your other devices connect to P4 Code over the network. Pair devices to give them access. P4 Code will restart.`:`Devices connected over your local network will disconnect. Existing tunnels, such as P4 Connect or Tailscale HTTPS, keep working. P4 Code will restart.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:Re,render:(0,Q.jsx)(L,{variant:`outline`,disabled:Re}),children:(0,Q.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:`Cancel`})}),(0,Q.jsxs)(L,{variant:`default`,onClick:pr,disabled:!$t||bt===null||Re,children:[Re&&(0,Q.jsx)(Qe,{size:`sm`}),(0,Q.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:Re?`Restarting…`:bt===`network-accessible`?`Restart and enable`:`Restart and disable`})]})]})]})}),(0,Q.jsx)(_n,{open:it&&$t,onOpenChange:e=>{We||e||rt(null)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:Y?.kind===`disable`?Y.wasWslOnly?`Turn off WSL and switch back to Windows?`:`Disable WSL backend?`:Y?.kind===`distro`?`Switch WSL distro?`:Y?.kind===`enable`?`Start the WSL backend`:Y?.nextValue?`Run only the WSL backend?`:`Re-enable the Windows backend?`}),(0,Q.jsx)(hn,{children:Y?.kind===`disable`?Y.wasWslOnly?`P4 Code will restart on the Windows backend. Threads and projects opened against WSL stay safe inside the distro and become available again when you re-enable WSL.`:`The WSL backend will stop. Threads and projects opened against WSL stay safe inside the distro, but they'll be unavailable in P4 Code until you re-enable WSL.`:Y?.kind===`distro`?`P4 Code will restart the WSL backend on the new distro. Sessions still running on the current distro will be interrupted.`:Y?.kind===`enable`?`Run the WSL backend alongside the Windows one, or stop the Windows backend and use only WSL? You can change this later from Settings.`:Y?.nextValue?`P4 Code will restart and start only the WSL backend. Your Windows-side projects won't be accessible until you turn this off again.`:`P4 Code will restart and bring the Windows backend back up alongside WSL.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:We,render:(0,Q.jsx)(L,{variant:`outline`,disabled:We}),children:`Cancel`}),Y?.kind===`enable`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{variant:`outline`,onClick:()=>li(`wsl-only`),disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):`Use only WSL`}),(0,Q.jsx)(L,{variant:`default`,onClick:()=>li(`both`),disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):`Run both backends`})]}):(0,Q.jsx)(L,{variant:Y?.kind===`disable`||Y?.kind===`wsl-only`&&Y.nextValue?`destructive`:`default`,onClick:di,disabled:We||!$t,children:We?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Applying…`]}):Y?.kind===`disable`?Y.wasWslOnly?`Switch to Windows`:`Disable WSL`:Y?.kind===`distro`?`Switch distro`:Y?.nextValue?`Restart and enable`:`Restart and disable`})]})]})}),(0,Q.jsx)(_n,{open:dt&&$t,onOpenChange:e=>{q||mt(e)},children:(0,Q.jsxs)(mn,{children:[(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(gn,{children:`Disable Tailscale HTTPS?`}),(0,Q.jsx)(hn,{children:`P4 Code will restart the local backend without Tailscale Serve.`})]}),(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(pn,{disabled:q,render:(0,Q.jsx)(L,{variant:`outline`,disabled:q}),children:`Cancel`}),(0,Q.jsx)(L,{variant:`destructive`,onClick:()=>void gr(),disabled:q||!$t,children:q?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):`Restart and disable`})]})]})}),(0,Q.jsx)(Ft,{open:ot!==null,onOpenChange:e=>{q||e||st(null)},children:(0,Q.jsxs)(Pt,{className:`max-w-md`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:`Set up Tailscale HTTPS?`}),(0,Q.jsx)(Nt,{children:`P4 Code will restart the local backend with Tailscale Serve enabled and ask Tailscale to proxy HTTPS traffic to this backend.`})]}),(0,Q.jsxs)(Mt,{children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`HTTPS port`}),(0,Q.jsx)(Tt,{className:`mt-2`,type:`number`,inputMode:`numeric`,min:1,max:65535,step:1,value:ht,onChange:e=>yt(e.target.value),disabled:q})]}),cr?null:(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:`Enter a port from 1 to 65535.`}),(0,Q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-muted/20 px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`HTTPS endpoint`}),(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm text-foreground`,children:ur??`Pending MagicDNS endpoint`})}),ur?(0,Q.jsx)(St,{side:`top`,children:ur}):null]})]})]}),(0,Q.jsxs)(kt,{children:[(0,Q.jsx)(jt,{disabled:q,render:(0,Q.jsx)(L,{variant:`outline`,disabled:q}),children:`Cancel`}),(0,Q.jsx)(L,{onClick:()=>void mr(),disabled:q||!cr,children:q?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qe,{size:`sm`}),`Restarting…`]}):`Enable`})]})]})})]})});return(0,Q.jsxs)(yn,{children:[vi,(0,Q.jsxs)(bn,{...Rn(`remote-environments`),title:`Environments`,headerAction:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[E.length>0?(0,Q.jsx)(er,{targets:E,variant:`ghost-muted`}):null,(0,Q.jsxs)(Ft,{open:ce,onOpenChange:e=>{fe(e),e?pe(null):W(null)},children:[(0,Q.jsxs)(Ct,{children:[(0,Q.jsx)(xt,{render:(0,Q.jsx)(At,{render:(0,Q.jsxs)(L,{size:`xs`,variant:`ghost-muted`,"aria-label":`Add environment`,children:[(0,Q.jsx)(le,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Add environment`})]})})}),(0,Q.jsx)(St,{side:`top`,children:`Add environment`})]}),(0,Q.jsxs)(Pt,{className:`max-h-[80dvh] sm:max-w-3xl`,children:[(0,Q.jsxs)(Dt,{children:[(0,Q.jsx)(Ot,{children:z?`Add a route to ${z.label}`:`Add Environment`}),(0,Q.jsx)(Nt,{children:z?`Pair this machine again over another address, such as its Tailscale name. It joins the existing routes instead of adding a second machine.`:`Pair another environment to this client.`})]}),(0,Q.jsx)(Mt,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Jr({mode:`remote`,title:`Remote link`,description:`Enter a backend host and pairing code.`,icon:(0,Q.jsx)(c,{"aria-hidden":!0,className:`size-4`})}),e?Jr({mode:`ssh`,title:`SSH`,description:`Use local SSH config, agent, and tunnels for the backend.`,icon:(0,Q.jsx)(b,{"aria-hidden":!0,className:`size-4`})}):null]}),(0,Q.jsx)(Ht,{children:me===`ssh`?ei():Qr()})]})})]})]})]}),children:[x.map(e=>(0,Q.jsx)(ca,{environment:e,removingEnvironmentId:Ne,onSetEnabled:Or,onRemove:Pr,onAddRoute:e=>{pe(e),W(null),fe(!0)}},e.environmentId)),(0,Q.jsx)(Sa,{primaryEnvironmentId:f,savedEnvironments:v})]}),Pe()?(0,Q.jsx)(oi,{environmentLabel:jr?.label??null,onCancel:()=>Nr(null),onConfirm:()=>{jr&&(Nr(null),Ar(jr))}}):null,(0,Q.jsx)(qr,{}),i.map((e,t)=>(0,Q.jsx)(Wr,{environmentId:e.environmentId,environmentLabel:i.length>1?e.label:null,isSearchTarget:t===0},e.environmentId)),(0,Q.jsx)($r,{environments:D}),(0,Q.jsx)(ii,{environments:D})]})}function wa(e){let{kind:t}=e;J.add({type:`success`,title:t===`hosted-link`?`Hosted app link copied`:t===`link`?`Pairing URL copied`:`Pairing code copied`,description:t===`hosted-link`?`Open it in the browser on the device you want to connect.`:t===`link`?`Open it in the client you want to pair to this environment.`:`Paste it into another client to finish pairing.`})}function Ta(e){return $i(e)?`hosted-link`:`link`}function Ea(e){return!e}function Da(e){return e.currentTarget.select()}function Oa(e){return e.currentTarget.select()}function ka(e){return e!==null}var Aa=Ca;export{Aa as component};
2
+ //# sourceMappingURL=settings.connections-CEr4PdrJ.js.map
@@ -1,2 +1,2 @@
1
- import{a as e,t}from"./react-BUfh6y28.js";import{t as n}from"./jsx-runtime-DJeoFXNw.js";import{fr as r,nc as i,ns as a,rv as o}from"./utils-CcBaVOX5.js";import{W as s}from"./runtime-DeVKKxNz.js";import{B as c,K as l,k as u,q as d}from"./entities-CTJ1ube2.js";import{Kt as f,Yt as p}from"./runtime-DCbEdU32.js";import{t as m}from"./link-BmkuqfGQ.js";import{q as h}from"./useSettings-Cg0O7Ek7.js";import{o as g}from"./session-Bb7JWdWO.js";import{g as _}from"./queries-eqpX-CHf.js";import{r as v}from"./SettingsPanels-BsyJETg8.js";import{i as y}from"./assetUrls-BNjjSBLP.js";import{V as b,a as x,i as S,s as C}from"./settingsLayout-krWuVpsF.js";import{ca as w,qi as T,sa as E}from"./main-DIEsHSIy.js";import{t as D}from"./legalLinks-C4VP5hPh.js";var O=e(t(),1),k=e(n(),1);function A(){let{scope:e,search:t,connectedEnvironments:n}=b(),A=u(),j=a((0,O.useMemo)(()=>l({environmentIds:e.environmentIds,shellStateValueAtom:d.stateValueAtom}),[e.environmentIds])),M=E(e.environmentIds),N=g(n,o),{changedSettingLabels:P,restoreDefaults:F}=v(),I=w(c.archive,{reportFailure:!1}),{deleteThread:L}=T(),R=y(_.v2.threadProjection,{reportFailure:!1}),[z,B]=(0,O.useState)(null),V=(0,O.useRef)(!1),[H,U]=(0,O.useState)(null),[W,G]=(0,O.useState)(null),K=e.kind===`project`||e.kind===`checkout`?new Set(e.members.map(e=>`${e.environmentId}:${e.id}`)):null,q=[...new Map([...A,...M.snapshots.flatMap(({environmentId:e,snapshot:t})=>t.threads.map(t=>f(e,t)))].filter(t=>e.environmentIds.includes(t.environmentId)&&(K===null||K.has(`${t.environmentId}:${t.projectId}`))).map(e=>[`${e.environmentId}:${e.id}`,e])).values()],J=q.filter(e=>e.archivedAt===null&&p(e.runtime)),Y=j&&e.environmentIds.length>0&&!M.isLoading&&!M.error&&e.environmentIds.every(e=>n.some(t=>t.environmentId===e)&&M.snapshots.some(t=>t.environmentId===e)),X=Y&&e.environmentIds.every(e=>N.has(e)),Z=async t=>{if(V.current)return;V.current=!0,B(t===`export`?t:`confirm`),U(null),G(null);let n=t===`archive`?J:q,r=0;try{if(t!==`export`&&!await h().dialogs.confirm(t===`delete`?`Permanently delete all ${n.length} chats in ${e.label}, including archived chats? This cannot be undone.`:`Archive ${n.length} inactive chats in ${e.label}? Active chats stay open. You can restore archived chats later.`,{variant:t===`delete`?`destructive`:`default`}))return;B(t);let a=[];for(let e of n){let n=i(e.environmentId,e.id);if(t===`export`){let t=await R({environmentId:e.environmentId,input:{threadId:e.id}});if(t._tag===`Failure`)throw s(t);a.push({environmentId:e.environmentId,thread:t.value.thread,messages:t.value.messages})}else{let r=t===`archive`?await I({environmentId:e.environmentId,input:{threadId:e.id}}):await L(n);if(r._tag===`Failure`)throw s(r)}r++}if(t===`export`){let e=URL.createObjectURL(new Blob([JSON.stringify({version:1,exportedAt:new Date().toISOString(),conversations:a},null,2)],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`p4-chats-${new Date().toISOString().slice(0,10)}.json`,t.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)}U(`${r} chats ${t===`archive`?`archived`:t===`delete`?`deleted`:`exported`}.`)}catch(e){G(`${r} of ${n.length} completed. ${e instanceof Error?e.message:`The action failed. Try again.`}`)}finally{M.refresh(),V.current=!1,B(null)}};return(0,k.jsxs)(S,{width:`wide`,children:[(0,k.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Data controls`}),(0,k.jsxs)(C,{title:`Data controls`,hideTitle:!0,id:`data-controls`,children:[(0,k.jsx)(x,{title:`Connected devices and access`,description:`Manage pairing links, devices, and access to your environments.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/connections`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Model training`,description:`Your provider account controls how it uses your chats. P4 cannot change that preference for you.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/providers`,search:t}),children:`Providers`})}),(0,k.jsx)(x,{title:`Network access`,description:`Manage how devices connect to your P4 server.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/connections`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Reset preferences`,description:`Restore default appearance and behavior settings. Your chats and provider credentials are kept.`,control:(0,k.jsx)(r,{variant:`destructive-outline`,size:`sm`,disabled:!!z||!P.length,onClick:()=>void F(),children:`Reset`})}),(0,k.jsx)(x,{title:`MCP access`,description:`Manage the MCP servers available to agents and their sign-ins.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/plugins`,hash:`mcp-servers`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Archived chats`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/archived`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Archive all chats`,description:`Archives inactive chats in the selected scope.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,disabled:!!z||!X||!J.length,onClick:()=>void Z(`archive`),children:z===`archive`?`Archiving…`:`Archive all`})}),(0,k.jsx)(x,{title:`Delete all chats`,description:`Permanently deletes chats in the selected scope, including the archive.`,control:(0,k.jsx)(r,{variant:`destructive-outline`,size:`sm`,disabled:!!z||!X||!q.length,onClick:()=>void Z(`delete`),children:z===`delete`?`Deleting…`:`Delete all`})}),(0,k.jsx)(x,{title:`Export chat data`,description:`Download chat metadata and messages as JSON. Attachment files and tool output are not included.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,disabled:!!z||!Y||!q.length,onClick:()=>void Z(`export`),children:z===`export`?`Exporting…`:`Export`})}),(0,k.jsx)(x,{title:`Privacy policy`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(`a`,{href:D,target:`_blank`,rel:`noreferrer`}),children:`Read`})})]}),W||M.error?(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive-foreground`,children:W??M.error}):null,H?(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:H}):null,Y?null:(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect all environments in this scope and wait for chats to load to use bulk actions.`})]})}var j=A;export{j as component};
2
- //# sourceMappingURL=settings.data-controls-Bd79f82M.js.map
1
+ import{a as e,t}from"./react-BUfh6y28.js";import{t as n}from"./jsx-runtime-DJeoFXNw.js";import{fr as r,nc as i,ns as a,rv as o}from"./utils-C5GGWTfe.js";import{W as s}from"./runtime-BVmDVuJ-.js";import{B as c,K as l,k as u,q as d}from"./entities-aKdRyfsJ.js";import{Kt as f,Yt as p}from"./runtime-BK2Lh1vB.js";import{t as m}from"./link-DW1IQk5s.js";import{q as h}from"./useSettings-B09a3zie.js";import{o as g}from"./session-BIwsf8Q4.js";import{g as _}from"./queries-B0FvRKmk.js";import{r as v}from"./SettingsPanels-Co5mks6X.js";import{i as y}from"./assetUrls-CYjvy6P4.js";import{V as b,a as x,i as S,s as C}from"./settingsLayout-WhjsCfB6.js";import{ca as w,qi as T,sa as E}from"./main-C0z861OK.js";import{t as D}from"./legalLinks-C4VP5hPh.js";var O=e(t(),1),k=e(n(),1);function A(){let{scope:e,search:t,connectedEnvironments:n}=b(),A=u(),j=a((0,O.useMemo)(()=>l({environmentIds:e.environmentIds,shellStateValueAtom:d.stateValueAtom}),[e.environmentIds])),M=E(e.environmentIds),N=g(n,o),{changedSettingLabels:P,restoreDefaults:F}=v(),I=w(c.archive,{reportFailure:!1}),{deleteThread:L}=T(),R=y(_.v2.threadProjection,{reportFailure:!1}),[z,B]=(0,O.useState)(null),V=(0,O.useRef)(!1),[H,U]=(0,O.useState)(null),[W,G]=(0,O.useState)(null),K=e.kind===`project`||e.kind===`checkout`?new Set(e.members.map(e=>`${e.environmentId}:${e.id}`)):null,q=[...new Map([...A,...M.snapshots.flatMap(({environmentId:e,snapshot:t})=>t.threads.map(t=>f(e,t)))].filter(t=>e.environmentIds.includes(t.environmentId)&&(K===null||K.has(`${t.environmentId}:${t.projectId}`))).map(e=>[`${e.environmentId}:${e.id}`,e])).values()],J=q.filter(e=>e.archivedAt===null&&p(e.runtime)),Y=j&&e.environmentIds.length>0&&!M.isLoading&&!M.error&&e.environmentIds.every(e=>n.some(t=>t.environmentId===e)&&M.snapshots.some(t=>t.environmentId===e)),X=Y&&e.environmentIds.every(e=>N.has(e)),Z=async t=>{if(V.current)return;V.current=!0,B(t===`export`?t:`confirm`),U(null),G(null);let n=t===`archive`?J:q,r=0;try{if(t!==`export`&&!await h().dialogs.confirm(t===`delete`?`Permanently delete all ${n.length} chats in ${e.label}, including archived chats? This cannot be undone.`:`Archive ${n.length} inactive chats in ${e.label}? Active chats stay open. You can restore archived chats later.`,{variant:t===`delete`?`destructive`:`default`}))return;B(t);let a=[];for(let e of n){let n=i(e.environmentId,e.id);if(t===`export`){let t=await R({environmentId:e.environmentId,input:{threadId:e.id}});if(t._tag===`Failure`)throw s(t);a.push({environmentId:e.environmentId,thread:t.value.thread,messages:t.value.messages})}else{let r=t===`archive`?await I({environmentId:e.environmentId,input:{threadId:e.id}}):await L(n);if(r._tag===`Failure`)throw s(r)}r++}if(t===`export`){let e=URL.createObjectURL(new Blob([JSON.stringify({version:1,exportedAt:new Date().toISOString(),conversations:a},null,2)],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`p4-chats-${new Date().toISOString().slice(0,10)}.json`,t.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)}U(`${r} chats ${t===`archive`?`archived`:t===`delete`?`deleted`:`exported`}.`)}catch(e){G(`${r} of ${n.length} completed. ${e instanceof Error?e.message:`The action failed. Try again.`}`)}finally{M.refresh(),V.current=!1,B(null)}};return(0,k.jsxs)(S,{width:`wide`,children:[(0,k.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Data controls`}),(0,k.jsxs)(C,{title:`Data controls`,hideTitle:!0,id:`data-controls`,children:[(0,k.jsx)(x,{title:`Connected devices and access`,description:`Manage pairing links, devices, and access to your environments.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/connections`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Model training`,description:`Your provider account controls how it uses your chats. P4 cannot change that preference for you.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/providers`,search:t}),children:`Providers`})}),(0,k.jsx)(x,{title:`Network access`,description:`Manage how devices connect to your P4 server.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/connections`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Reset preferences`,description:`Restore default appearance and behavior settings. Your chats and provider credentials are kept.`,control:(0,k.jsx)(r,{variant:`destructive-outline`,size:`sm`,disabled:!!z||!P.length,onClick:()=>void F(),children:`Reset`})}),(0,k.jsx)(x,{title:`MCP access`,description:`Manage the MCP servers available to agents and their sign-ins.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/plugins`,hash:`mcp-servers`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Archived chats`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(m,{to:`/settings/archived`,search:t}),children:`Manage`})}),(0,k.jsx)(x,{title:`Archive all chats`,description:`Archives inactive chats in the selected scope.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,disabled:!!z||!X||!J.length,onClick:()=>void Z(`archive`),children:z===`archive`?`Archiving…`:`Archive all`})}),(0,k.jsx)(x,{title:`Delete all chats`,description:`Permanently deletes chats in the selected scope, including the archive.`,control:(0,k.jsx)(r,{variant:`destructive-outline`,size:`sm`,disabled:!!z||!X||!q.length,onClick:()=>void Z(`delete`),children:z===`delete`?`Deleting…`:`Delete all`})}),(0,k.jsx)(x,{title:`Export chat data`,description:`Download chat metadata and messages as JSON. Attachment files and tool output are not included.`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,disabled:!!z||!Y||!q.length,onClick:()=>void Z(`export`),children:z===`export`?`Exporting…`:`Export`})}),(0,k.jsx)(x,{title:`Privacy policy`,control:(0,k.jsx)(r,{variant:`soft`,size:`sm`,render:(0,k.jsx)(`a`,{href:D,target:`_blank`,rel:`noreferrer`}),children:`Read`})})]}),W||M.error?(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive-foreground`,children:W??M.error}):null,H?(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:H}):null,Y?null:(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect all environments in this scope and wait for chats to load to use bulk actions.`})]})}var j=A;export{j as component};
2
+ //# sourceMappingURL=settings.data-controls-BbzJxjBi.js.map