ryco-cli 0.1.6 → 0.1.7

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 (152) hide show
  1. package/dist/{AzureDevOpsSourceControlProvider-6holYS_D.cjs → AzureDevOpsSourceControlProvider-5exivY-1.cjs} +2 -2
  2. package/dist/{AzureDevOpsSourceControlProvider-CC2_COxP.mjs → AzureDevOpsSourceControlProvider-CF5LuCHp.mjs} +2 -2
  3. package/dist/{BitbucketSourceControlProvider-a0IsNFyG.cjs → BitbucketSourceControlProvider-1GWENqcl.cjs} +2 -2
  4. package/dist/{BitbucketSourceControlProvider-CYR_BD1d.mjs → BitbucketSourceControlProvider-CKH09tfT.mjs} +2 -2
  5. package/dist/{ClaudeDriver-C6tQNEWO.cjs → ClaudeDriver-BXLdjrht.cjs} +177 -4
  6. package/dist/{ClaudeDriver-D3nsxwH9.mjs → ClaudeDriver-WwWFTu61.mjs} +178 -5
  7. package/dist/{CodexDriver-BILrJG8o.mjs → CodexDriver-93-TmCrO.mjs} +6 -5
  8. package/dist/{CodexDriver-ms_YgFD7.cjs → CodexDriver-BboMT9uk.cjs} +5 -4
  9. package/dist/{CodexTextGeneration-CHEgoANm.cjs → CodexTextGeneration-0pRbJji3.cjs} +2 -2
  10. package/dist/{CodexTextGeneration-BIKHl7E3.mjs → CodexTextGeneration-BU9Myn87.mjs} +3 -3
  11. package/dist/{CopilotDriver-CmD3Ffyl.mjs → CopilotDriver-BASi8pJ0.mjs} +4 -4
  12. package/dist/{CopilotDriver-B0--ZwIK.cjs → CopilotDriver-DCsv-17W.cjs} +3 -3
  13. package/dist/{CursorDriver-DTVPXZ-R.cjs → CursorDriver-BTSiM3A8.cjs} +161 -14
  14. package/dist/{CursorDriver-CbeaIbdb.mjs → CursorDriver-D5LvIqUk.mjs} +162 -15
  15. package/dist/{ForgejoSourceControlProvider-DwAog76b.cjs → ForgejoSourceControlProvider-BTXRDCGB.cjs} +2 -2
  16. package/dist/{ForgejoSourceControlProvider-DX6d9gvz.mjs → ForgejoSourceControlProvider-e-4hvvZ_.mjs} +2 -2
  17. package/dist/{GitHubSourceControlProvider-C-LGwho3.mjs → GitHubSourceControlProvider-26IofDAO.mjs} +2 -2
  18. package/dist/{GitHubSourceControlProvider-9lJFzjsu.cjs → GitHubSourceControlProvider-DWmwkA_y.cjs} +2 -2
  19. package/dist/{GitLabSourceControlProvider-CvKA74lg.cjs → GitLabSourceControlProvider-D-YHnxRe.cjs} +2 -2
  20. package/dist/{GitLabSourceControlProvider-CkeT2aEx.mjs → GitLabSourceControlProvider-DePct78W.mjs} +2 -2
  21. package/dist/{OpenCodeDriver-ClWtCk0j.mjs → OpenCodeDriver-BhvLOmvn.mjs} +325 -38
  22. package/dist/{OpenCodeDriver-CXUsnl5o.cjs → OpenCodeDriver-CVeZ4n9-.cjs} +324 -37
  23. package/dist/{SourceControlProviderDiscoveryCatalog-_rg0mc1o.cjs → SourceControlProviderDiscoveryCatalog-DeFR5xH3.cjs} +1 -64
  24. package/dist/{SourceControlProviderDiscoveryCatalog-yMDer_Yh.mjs → SourceControlProviderDiscoveryCatalog-mJV_Xitr.mjs} +3 -48
  25. package/dist/bin.cjs +1280 -519
  26. package/dist/bin.mjs +1234 -474
  27. package/dist/client/assets/{AnimatedHeight-DgItDSis.js → AnimatedHeight-BSU0lzYs.js} +1 -1
  28. package/dist/client/assets/AppearanceSettings-D7q0ujGK.js +1 -0
  29. package/dist/client/assets/{BranchToolbar.logic-C_xHEt9C.js → BranchToolbar.logic-CZIFSvhd.js} +1 -1
  30. package/dist/client/assets/ChatRightPanel-CWHOIuiQ.js +188 -0
  31. package/dist/client/assets/{ChatThreadRouteView-CV6ETYG5.js → ChatThreadRouteView-bA7xWXzc.js} +1 -1
  32. package/dist/client/assets/{CommandPaletteDialog-C_H7R8S5.js → CommandPaletteDialog-DNYaVOZO.js} +1 -1
  33. package/dist/client/assets/CompositeRoot-B_KEfCUE.js +1 -0
  34. package/dist/client/assets/ConnectionsSettings-CLZPbx_K.js +1 -0
  35. package/dist/client/assets/{DiagnosticsSettings-B340S_mq.js → DiagnosticsSettings-DtzPCb6N.js} +1 -1
  36. package/dist/client/assets/{DialogHandle-BJY7cHCV.js → DialogHandle-DuHnmWoE.js} +1 -1
  37. package/dist/client/assets/{DialogRoot-Ej1FVk-_.js → DialogRoot-BV25qAcA.js} +1 -1
  38. package/dist/client/assets/DialogTitle-DQsi-RTa.js +1 -0
  39. package/dist/client/assets/DialogTrigger-D0fA01C6.js +1 -0
  40. package/dist/client/assets/{DialogViewport-DvjAl76K.js → DialogViewport-CMV_BePU.js} +1 -1
  41. package/dist/client/assets/{DraftChatThreadRouteView-pOkyeKPS.js → DraftChatThreadRouteView-BoiKnrii.js} +1 -1
  42. package/dist/client/assets/{JetBrainsIcons-DTTF47I0.js → JetBrainsIcons-BcPxJlMf.js} +1 -1
  43. package/dist/client/assets/{KeybindingsSettings-CW3RRi-7.js → KeybindingsSettings-LuI98pdF.js} +1 -1
  44. package/dist/client/assets/McpServersSettings-BFMuWYVV.js +6 -0
  45. package/dist/client/assets/{NoActiveThreadState-DVHwrkCp.js → NoActiveThreadState-C2q_O1kP.js} +1 -1
  46. package/dist/client/assets/{OpinionatedPluginsSettings-Cjj23Fs4.js → OpinionatedPluginsSettings-Bqwct37O.js} +1 -1
  47. package/dist/client/assets/{ProjectFavicon-TDP7HRfn.js → ProjectFavicon-D2imiJ8M.js} +1 -1
  48. package/dist/client/assets/{ProviderUpdateLaunchNotification.logic-6TpFsmiI.js → ProviderUpdateLaunchNotification.logic-CJgA--nK.js} +1 -1
  49. package/dist/client/assets/ProvidersSettingsPanel-B97vbeu6.js +1 -0
  50. package/dist/client/assets/{RedactedSensitiveText-BfoVjPsE.js → RedactedSensitiveText-B2GFTyfq.js} +1 -1
  51. package/dist/client/assets/RootAppShell-C1xTR98P.js +12 -0
  52. package/dist/client/assets/SettingsDialog-Q0Q8O5oH.js +2 -0
  53. package/dist/client/assets/SourceControlSettings-KAvoPTNi.js +1 -0
  54. package/dist/client/assets/StatisticsPanel-BzsQ444K.js +64 -0
  55. package/dist/client/assets/{ThreadStatusIndicators-B0leIJGD.js → ThreadStatusIndicators-Cw_jLVQf.js} +1 -1
  56. package/dist/client/assets/{ThreadTerminalDrawer-COq2Fk17.js → ThreadTerminalDrawer-D1WnSemH.js} +17 -17
  57. package/dist/client/assets/ThreadWorkspacePanel-L4qCPTOA.js +166 -0
  58. package/dist/client/assets/{alert-dialog-lMfKpG2t.js → alert-dialog-CNmKa0BK.js} +1 -1
  59. package/dist/client/assets/chart-column-BWSKYZ_a.js +1 -0
  60. package/dist/client/assets/{chatThreadActions-PPyTj_x0.js → chatThreadActions-TtDsiwDC.js} +1 -1
  61. package/dist/client/assets/chevron-up-zopJ_99l.js +1 -0
  62. package/dist/client/assets/{clamp-JiD4IZ0Z.js → clamp-Ds6WJu8j.js} +1 -1
  63. package/dist/client/assets/{clipboard-copy-CYBLSG2q.js → clipboard-copy-BoJGpdmJ.js} +1 -1
  64. package/dist/client/assets/clock-CzUHThzk.js +1 -0
  65. package/dist/client/assets/{commandPaletteStore-uVfCD7zE.js → commandPaletteStore-KebG835b.js} +1 -1
  66. package/dist/client/assets/composerDraftStore-DpPEQ6BN.js +21 -0
  67. package/dist/client/assets/{desktopUpdateAtoms-X6uM5SoD.js → desktopUpdateAtoms-BQ0GGEfM.js} +1 -1
  68. package/dist/client/assets/{download-DLBlpp4h.js → download-CUiRE0N9.js} +1 -1
  69. package/dist/client/assets/{draft-input-dLlVMl5P.js → draft-input-CwpGDtoT.js} +1 -1
  70. package/dist/client/assets/editorPreferences-jN7DKbyt.js +1 -0
  71. package/dist/client/assets/{empty-DlLY-Hhj.js → empty-CBuXePtg.js} +1 -1
  72. package/dist/client/assets/{group-zDBPF7rR.js → group-BpZvxjG5.js} +1 -1
  73. package/dist/client/assets/{index-Dq8sT2lF.js → index-BKzXTNJ_.js} +2 -2
  74. package/dist/client/assets/{input-B9-RWT56.js → input-CgDawd6k.js} +1 -1
  75. package/dist/client/assets/kbd-QYSL97CK.js +1 -0
  76. package/dist/client/assets/{keybindings-Dx4Nc1vY.js → keybindings-CUTRYI_A.js} +1 -1
  77. package/dist/client/assets/{keyboard-DDTWQkr0.js → keyboard-DFFiI7JY.js} +1 -1
  78. package/dist/client/assets/{keyedQuery-Ds4OGhX2.js → keyedQuery-DiOCbGH0.js} +0 -0
  79. package/dist/client/assets/{main-DxfpmoKJ.js → main-BgFGju3e.js} +3 -3
  80. package/dist/client/assets/main-D0UFdwts.css +2 -0
  81. package/dist/client/assets/{palette-BQcz-ZYV.js → palette-BXCL909c.js} +1 -1
  82. package/dist/client/assets/{play-QloDGe4R.js → play-DI2LZohg.js} +1 -1
  83. package/dist/client/assets/plus-DzgIfHUF.js +1 -0
  84. package/dist/client/assets/projectAtoms-DXXpuERK.js +1 -0
  85. package/dist/client/assets/providerDriverMeta-CRNNp0q3.js +1 -0
  86. package/dist/client/assets/providerIconUtils-D-DFhem2.js +47 -0
  87. package/dist/client/assets/radio-group-_PPYg3YY.js +1 -0
  88. package/dist/client/assets/{refresh-cw-DkBMGllm.js → refresh-cw-BsQTNBXl.js} +1 -1
  89. package/dist/client/assets/{resolveAriaLabelledBy-DDfIbj05.js → resolveAriaLabelledBy-CRHo_s16.js} +1 -1
  90. package/dist/client/assets/{rightPanelRouteSearch-DfuWVvXN.js → rightPanelRouteSearch-CfmZ7osj.js} +1 -1
  91. package/dist/client/assets/{scale-BActunFu.js → scale-DDEJ-tvn.js} +1 -1
  92. package/dist/client/assets/{scroll-area-D-YOUG02.js → scroll-area-HgsI-ErG.js} +1 -1
  93. package/dist/client/assets/{separator-TInKeIDo.js → separator-ClnL4mUB.js} +1 -1
  94. package/dist/client/assets/{server-BtEG3NAw.js → server-Bbs3L-6_.js} +1 -1
  95. package/dist/client/assets/{session-logic-DNf1aXq_.js → session-logic-CKQkgIwo.js} +1 -1
  96. package/dist/client/assets/settingsDialogStore-SG-W1q0A.js +1 -0
  97. package/dist/client/assets/{settingsLayout-D22Mm0u3.js → settingsLayout-G5xVm-ZT.js} +1 -1
  98. package/dist/client/assets/sidebar-_u7SGgmC.js +1 -0
  99. package/dist/client/assets/sidebarStatusText-BTYnwflG.js +1 -0
  100. package/dist/client/assets/{skeleton-DWaac_qp.js → skeleton-CmUvhZGP.js} +1 -1
  101. package/dist/client/assets/{storeSelectors-Cx1IYPA4.js → storeSelectors-DhJRpdiw.js} +1 -1
  102. package/dist/client/assets/threadSelectionStore-ygmA4DNA.js +1 -0
  103. package/dist/client/assets/toast-DmA_ziPT.js +1 -0
  104. package/dist/client/assets/toggle-DGS7tKuj.js +1 -0
  105. package/dist/client/assets/{toggle-group-CnLjaHSL.js → toggle-group-Dtv1ZUFW.js} +1 -1
  106. package/dist/client/assets/{tokenModePresentation-BSYdIvBm.js → tokenModePresentation-Dor1DnBx.js} +1 -1
  107. package/dist/client/assets/{trash-2-BI5xcbsm.js → trash-2-C2G3VGoV.js} +1 -1
  108. package/dist/client/assets/{triangle-alert-DJef_Uvh.js → triangle-alert-Bpz3xGu5.js} +1 -1
  109. package/dist/client/assets/{undo-2-DeZ2cMGS.js → undo-2-C3rtxuqZ.js} +1 -1
  110. package/dist/client/assets/{useHandleNewThread-XB82O6SA.js → useHandleNewThread-ypSbzG0P.js} +1 -1
  111. package/dist/client/assets/useLabelableId-Bc7KEnHU.js +1 -0
  112. package/dist/client/assets/{useNavigate-B2tgshhW.js → useNavigate-_4hWGSey.js} +1 -1
  113. package/dist/client/assets/useTheme-HcKmBfpF.js +1 -0
  114. package/dist/client/assets/{vscode-icons-DM9qFoEr.js → vscode-icons-DdSTtxYd.js} +1 -1
  115. package/dist/client/assets/{wrench-je4QOyG-.js → wrench-C4jdis40.js} +1 -1
  116. package/dist/client/assets/x-CG2WU63t.js +1 -0
  117. package/dist/client/index.html +1 -1
  118. package/dist/{collectUint8StreamText-C2z5Y8tF.mjs → collectUint8StreamText-Lv4GGI79.mjs} +269 -14
  119. package/dist/{collectUint8StreamText-TCG6xW_P.cjs → collectUint8StreamText-uNXVRHOf.cjs} +291 -12
  120. package/dist/{makeManagedServerProvider-DPFw9gV_.cjs → makeManagedServerProvider-3SD-Q5xh.cjs} +1 -1
  121. package/dist/{makeManagedServerProvider-BXO8QvzC.mjs → makeManagedServerProvider-CkPEptun.mjs} +1 -1
  122. package/package.json +1 -1
  123. package/dist/client/assets/AppearanceSettings-BlsMFBvJ.js +0 -1
  124. package/dist/client/assets/ChatRightPanel-CThudBb1.js +0 -188
  125. package/dist/client/assets/CompositeRoot-DjnzUIwC.js +0 -1
  126. package/dist/client/assets/ConnectionsSettings-hArR4Oe3.js +0 -1
  127. package/dist/client/assets/DialogTitle-H1yIMmA9.js +0 -1
  128. package/dist/client/assets/DialogTrigger-BHMq_K2G.js +0 -1
  129. package/dist/client/assets/McpServersSettings-dQ3BzOWY.js +0 -6
  130. package/dist/client/assets/ProvidersSettingsPanel-D15EeWAq.js +0 -1
  131. package/dist/client/assets/RootAppShell-CWBPSA2w.js +0 -12
  132. package/dist/client/assets/SettingsDialog-oJCE5foT.js +0 -2
  133. package/dist/client/assets/SourceControlSettings-CPnlMxNm.js +0 -1
  134. package/dist/client/assets/ThreadWorkspacePanel-qF9y6QT9.js +0 -166
  135. package/dist/client/assets/composerDraftStore-D12lUSfh.js +0 -21
  136. package/dist/client/assets/editorPreferences-BLeEBSD_.js +0 -1
  137. package/dist/client/assets/folder-open-DMjz0lpx.js +0 -1
  138. package/dist/client/assets/kbd-aeSsjiPI.js +0 -1
  139. package/dist/client/assets/main-C57RhHZ_.css +0 -2
  140. package/dist/client/assets/plus-4Oy56d-3.js +0 -1
  141. package/dist/client/assets/projectAtoms-DUEBb7Zz.js +0 -1
  142. package/dist/client/assets/providerDriverMeta-Dwi6Zqgd.js +0 -1
  143. package/dist/client/assets/providerIconUtils-uhWb4bdg.js +0 -47
  144. package/dist/client/assets/radio-group-DHyQlLeX.js +0 -1
  145. package/dist/client/assets/settingsDialogStore-BINi7pdD.js +0 -1
  146. package/dist/client/assets/sidebar-DHwNQmWp.js +0 -1
  147. package/dist/client/assets/threadSelectionStore-C0ig4405.js +0 -1
  148. package/dist/client/assets/toast-DE7a4wkW.js +0 -1
  149. package/dist/client/assets/toggle-BIW4AyPY.js +0 -1
  150. package/dist/client/assets/useLabelableId-DBAgv9qQ.js +0 -1
  151. package/dist/client/assets/useTheme-Dv42Z8uy.js +0 -1
  152. package/dist/client/assets/x-fI9snvD3.js +0 -1
@@ -1 +1 @@
1
- import{i as e,t}from"./react-PSPkXoKo.js";import{t as n}from"./compiler-runtime-BNrXlsa1.js";import{Ot as r,mt as i,sn as a,wt as o}from"./projectAtoms-DUEBb7Zz.js";import{Ni as s,a as c}from"./composerDraftStore-D12lUSfh.js";import{t as ee}from"./useNavigate-B2tgshhW.js";import{c as l}from"./toast-DE7a4wkW.js";import{a as te,c as ne,i as re,n as ie,o as ae,s as oe,t as se}from"./rightPanelRouteSearch-DfuWVvXN.js";import{Jt as ce}from"./providerIconUtils-uhWb4bdg.js";import{a as le,d as ue,f as de,i as fe,l as pe,n as me,p as he,r as u,s as ge,t as _e}from"./ChatRightPanel-CThudBb1.js";import{b as ve,o as ye}from"./sidebar-DHwNQmWp.js";import{i as be,t as xe}from"./storeSelectors-Cx1IYPA4.js";var Se=n(),d=e(t(),1),f=s();function p(e){let t=(0,Se.c)(154),{threadRef:n,search:s}=e;ce(`ChatThreadRouteView`);let u=ee(),p;t[0]===n?.environmentId?p=t[1]:(p=e=>i(e,n?.environmentId??null).bootstrapComplete,t[0]=n?.environmentId,t[1]=p);let m=r(p),Te;t[2]===n?Te=t[3]:(Te=be(n),t[2]=n,t[3]=Te);let Ee=r(Te),De;t[4]===n?De=t[5]:(De=e=>o(e,n),t[4]=n,t[5]=De);let Oe=r(De),ke;t[6]===n?.environmentId?ke=t[7]:(ke=e=>i(e,n?.environmentId??null).threadIds.length>0,t[6]=n?.environmentId,t[7]=ke);let Ae=r(ke),je=a(we),h;t[8]!==je||t[9]!==n?.environmentId?(h=()=>xe(n?.environmentId??null,je),t[8]=je,t[9]=n?.environmentId,t[10]=h):h=t[10],n?.environmentId;let Me;t[11]===h?Me=t[12]:(Me=h(),t[11]=h,t[12]=Me);let g=r(Me),Ne=de(n),_=ue(n),Pe=he(n?.environmentId),v=Oe||Ne,y;t[13]===Ee?y=t[14]:(y=ge(Ee),t[13]=Ee,t[14]=y);let b=y,x=Ae||Pe,S=s.diff===`1`,C=s.preview===`1`,w;t[15]===s?w=t[16]:(w=se(s),t[15]=s,t[16]=w);let T=w,Fe;t[17]===s?Fe=t[18]:(Fe=ie(s),t[17]=s,t[18]=Fe);let E=Fe,D=s.workspaceTab===`agent`&&s.workspaceAgentKey?s.workspaceAgentKey:null,Ie=ve(pe),O=n?`${n.environmentId}:${n.threadId}`:null,Le;t[19]!==D||t[20]!==O||t[21]!==S||t[22]!==C||t[23]!==T?(Le=()=>({threadKey:O,hasOpenedDiff:S,hasOpenedPreview:C,hasOpenedTerminal:T===`terminal`,openedAgentKeys:D?[D]:[]}),t[19]=D,t[20]=O,t[21]=S,t[22]=C,t[23]=T,t[24]=Le):Le=t[24];let[k,Re]=(0,d.useState)(Le),A=k.threadKey===O?k.hasOpenedDiff:S,j=k.threadKey===O?k.hasOpenedPreview:C,M=k.threadKey===O?k.hasOpenedTerminal:T===`terminal`,ze;t[25]!==D||t[26]!==O||t[27]!==k.openedAgentKeys||t[28]!==k.threadKey?(ze=k.threadKey===O?k.openedAgentKeys:D?[D]:[],t[25]=D,t[26]=O,t[27]=k.openedAgentKeys,t[28]=k.threadKey,t[29]=ze):ze=t[29];let N=ze,Be;t[30]!==D||t[31]!==N?(Be=D&&!N.includes(D)?[...N,D]:N,t[30]=D,t[31]=N,t[32]=Be):Be=t[32];let P=Be,Ve;t[33]===T?Ve=t[34]:(Ve=()=>T??`review`,t[33]=T,t[34]=Ve);let[F,He]=(0,d.useState)(Ve),I;t[35]!==A||t[36]!==j||t[37]!==M||t[38]!==T?(I=[],(j||T===`files`)&&I.push(`files`),(A||T===`review`)&&I.push(`review`),(M||T===`terminal`)&&I.push(`terminal`),t[35]=A,t[36]=j,t[37]=M,t[38]=T,t[39]=I):I=t[39];let L=I,Ue;t[40]!==O||t[41]!==S||t[42]!==P||t[43]!==C||t[44]!==T?(Ue=e=>{He(e),Re(t=>{let n={threadKey:O,hasOpenedDiff:(t.threadKey===O?t.hasOpenedDiff:S)||e===`review`,hasOpenedPreview:(t.threadKey===O?t.hasOpenedPreview:C)||e===`files`,hasOpenedTerminal:(t.threadKey===O?t.hasOpenedTerminal:T===`terminal`)||e===`terminal`,openedAgentKeys:t.threadKey===O?t.openedAgentKeys:P};return t.threadKey===n.threadKey&&t.hasOpenedDiff===n.hasOpenedDiff&&t.hasOpenedPreview===n.hasOpenedPreview&&t.hasOpenedTerminal===n.hasOpenedTerminal&&t.openedAgentKeys===n.openedAgentKeys?t:n})},t[40]=O,t[41]=S,t[42]=P,t[43]=C,t[44]=T,t[45]=Ue):Ue=t[45];let R=Ue,We;t[46]!==u||t[47]!==n?(We=()=>{n&&u({to:`/$environmentId/$threadId`,params:l(n),search:Ce})},t[46]=u,t[47]=n,t[48]=We):We=t[48];let z=We,Ge;t[49]!==A||t[50]!==j||t[51]!==M||t[52]!==F||t[53]!==u||t[54]!==P||t[55]!==n?(Ge=()=>{n&&u({to:`/$environmentId/$threadId`,params:l(n),search:e=>{let t=P[P.length-1];return F===`agent`&&t?re(e,t):F===`files`&&j?te(e):F===`review`&&A?ae(e):F===`terminal`&&M?oe(e):j?te(e):A?ae(e):M?oe(e):t?re(e,t):ne(e)}})},t[49]=A,t[50]=j,t[51]=M,t[52]=F,t[53]=u,t[54]=P,t[55]=n,t[56]=Ge):Ge=t[56];let B=Ge,Ke;t[57]!==z||t[58]!==B||t[59]!==E?(Ke=()=>{if(E){z();return}B()},t[57]=z,t[58]=B,t[59]=E,t[60]=Ke):Ke=t[60];let V=Ke,qe;t[61]!==D||t[62]!==O||t[63]!==A||t[64]!==j||t[65]!==M||t[66]!==u||t[67]!==P||t[68]!==T||t[69]!==n?(qe=e=>{if(!n)return;if(e.mode===`agent`){let t=P.filter(t=>t!==e.agentKey);Re(e=>({threadKey:O,hasOpenedDiff:e.threadKey===O?e.hasOpenedDiff:A,hasOpenedPreview:e.threadKey===O?e.hasOpenedPreview:j,hasOpenedTerminal:e.threadKey===O?e.hasOpenedTerminal:M,openedAgentKeys:t})),T===`agent`&&D===e.agentKey&&u({to:`/$environmentId/$threadId`,params:l(n),search:e=>{let n=t[t.length-1];return n?re(e,n):j?te(e):A?ae(e):M?oe(e):ne(e)}});return}let t=e.mode===`review`?!1:A||T===`review`,r=e.mode===`files`?!1:j||T===`files`,i=e.mode===`terminal`?!1:M||T===`terminal`;Re(e=>{let n={threadKey:O,hasOpenedDiff:t,hasOpenedPreview:r,hasOpenedTerminal:i,openedAgentKeys:e.threadKey===O?e.openedAgentKeys:P};return e.threadKey===n.threadKey&&e.hasOpenedDiff===n.hasOpenedDiff&&e.hasOpenedPreview===n.hasOpenedPreview&&e.hasOpenedTerminal===n.hasOpenedTerminal&&e.openedAgentKeys===n.openedAgentKeys?e:n}),T===e.mode&&u({to:`/$environmentId/$threadId`,params:l(n),search:n=>e.mode!==`files`&&r?te(n):e.mode!==`review`&&t?ae(n):e.mode!==`terminal`&&i?oe(n):ne(n)})},t[61]=D,t[62]=O,t[63]=A,t[64]=j,t[65]=M,t[66]=u,t[67]=P,t[68]=T,t[69]=n,t[70]=qe):qe=t[70];let H=qe,U,Je;t[71]!==R||t[72]!==T?(U=()=>{T!==null&&(He(T),R(T))},Je=[R,T],t[71]=R,t[72]=T,t[73]=U,t[74]=Je):(U=t[73],Je=t[74]),(0,d.useEffect)(U,Je);let Ye,Xe;t[75]!==D||t[76]!==O||t[77]!==S||t[78]!==A||t[79]!==j||t[80]!==M||t[81]!==C||t[82]!==T?(Ye=()=>{!O||!D||Re(e=>{let t=e.threadKey===O?e.openedAgentKeys:[];return t.includes(D)?e.threadKey===O?e:{threadKey:O,hasOpenedDiff:A,hasOpenedPreview:j,hasOpenedTerminal:M,openedAgentKeys:t}:{threadKey:O,hasOpenedDiff:e.threadKey===O?e.hasOpenedDiff:S,hasOpenedPreview:e.threadKey===O?e.hasOpenedPreview:C,hasOpenedTerminal:e.threadKey===O?e.hasOpenedTerminal:T===`terminal`,openedAgentKeys:[...t,D]}})},Xe=[D,O,S,A,j,M,C,T],t[75]=D,t[76]=O,t[77]=S,t[78]=A,t[79]=j,t[80]=M,t[81]=C,t[82]=T,t[83]=Ye,t[84]=Xe):(Ye=t[83],Xe=t[84]),(0,d.useEffect)(Ye,Xe);let Ze,Qe;t[85]!==m||t[86]!==x||t[87]!==g||t[88]!==u||t[89]!==v||t[90]!==n?(Ze=()=>{!n||!m||!v&&x&&u(g?{to:`/$environmentId/$threadId`,params:l(g),replace:!0}:{to:`/`,replace:!0})},Qe=[m,x,g,u,v,n],t[85]=m,t[86]=x,t[87]=g,t[88]=u,t[89]=v,t[90]=n,t[91]=Ze,t[92]=Qe):(Ze=t[91],Qe=t[92]),(0,d.useEffect)(Ze,Qe);let $e;t[93]!==_?.promotedTo||t[94]!==b||t[95]!==n?($e=()=>{!n||!b||!_?.promotedTo||c(n)},t[93]=_?.promotedTo,t[94]=b,t[95]=n,t[96]=$e):$e=t[96];let et=_?.promotedTo,tt;if(t[97]!==b||t[98]!==et||t[99]!==n?(tt=[et,b,n],t[97]=b,t[98]=et,t[99]=n,t[100]=tt):tt=t[100],(0,d.useEffect)($e,tt),!n||!m||!v)return null;let W=E||T===`review`||A||T===`files`||j||T===`terminal`||M||T===`agent`||P.length>0,G=E?T:F;if(!Ie){let e,r,i,a;t[101]===R?(e=t[102],r=t[103],i=t[104],a=t[105]):(e=()=>R(`review`),r=()=>R(`files`),i=()=>R(`terminal`),a=()=>R(`agent`),t[101]=R,t[102]=e,t[103]=r,t[104]=i,t[105]=a);let o;t[106]!==E||t[107]!==e||t[108]!==r||t[109]!==i||t[110]!==a||t[111]!==n.environmentId||t[112]!==n.threadId||t[113]!==V?(o=(0,f.jsx)(ye,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,f.jsx)(fe,{environmentId:n.environmentId,threadId:n.threadId,onDiffPanelOpen:e,onPreviewPanelOpen:r,onTerminalPanelOpen:i,onAgentPanelOpen:a,workspacePanelOpen:E,onToggleWorkspacePanel:V,routeKind:`server`})}),t[106]=E,t[107]=e,t[108]=r,t[109]=i,t[110]=a,t[111]=n.environmentId,t[112]=n.threadId,t[113]=V,t[114]=o):o=t[114];let s;t[115]!==H||t[116]!==z||t[117]!==G||t[118]!==B||t[119]!==P||t[120]!==L||t[121]!==E||t[122]!==W?(s=(0,f.jsx)(me,{open:E,panelMode:G,openedPanelModes:L,openedAgentKeys:P,onClosePanelTab:H,onClose:z,onOpen:B,renderContent:W}),t[115]=H,t[116]=z,t[117]=G,t[118]=B,t[119]=P,t[120]=L,t[121]=E,t[122]=W,t[123]=s):s=t[123];let c;return t[124]!==o||t[125]!==s?(c=(0,f.jsxs)(f.Fragment,{children:[o,s]}),t[124]=o,t[125]=s,t[126]=c):c=t[126],c}let K,q,J,Y;t[127]===R?(K=t[128],q=t[129],J=t[130],Y=t[131]):(K=()=>R(`review`),q=()=>R(`files`),J=()=>R(`terminal`),Y=()=>R(`agent`),t[127]=R,t[128]=K,t[129]=q,t[130]=J,t[131]=Y);let X;t[132]!==E||t[133]!==K||t[134]!==q||t[135]!==J||t[136]!==Y||t[137]!==n.environmentId||t[138]!==n.threadId||t[139]!==V?(X=(0,f.jsx)(ye,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,f.jsx)(fe,{environmentId:n.environmentId,threadId:n.threadId,onDiffPanelOpen:K,onPreviewPanelOpen:q,onTerminalPanelOpen:J,onAgentPanelOpen:Y,workspacePanelOpen:E,onToggleWorkspacePanel:V,routeKind:`server`})}),t[132]=E,t[133]=K,t[134]=q,t[135]=J,t[136]=Y,t[137]=n.environmentId,t[138]=n.threadId,t[139]=V,t[140]=X):X=t[140];let Z;t[141]!==H||t[142]!==G||t[143]!==P||t[144]!==L||t[145]!==W?(Z=W?(0,f.jsx)(_e,{mode:`sheet`,panelMode:G,openedPanelModes:L,openedAgentKeys:P,onClosePanelTab:H}):null,t[141]=H,t[142]=G,t[143]=P,t[144]=L,t[145]=W,t[146]=Z):Z=t[146];let Q;t[147]!==z||t[148]!==E||t[149]!==Z?(Q=(0,f.jsx)(le,{open:E,onClose:z,children:Z}),t[147]=z,t[148]=E,t[149]=Z,t[150]=Q):Q=t[150];let $;return t[151]!==X||t[152]!==Q?($=(0,f.jsxs)(f.Fragment,{children:[X,Q]}),t[151]=X,t[152]=Q,t[153]=$):$=t[153],$}function Ce(e){return u(e)}function we(e){return e.sidebarThreadSortOrder}export{p as ChatThreadRouteView};
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{t as n}from"./compiler-runtime-BNrXlsa1.js";import{Ot as r,mt as i,sn as a,wt as o}from"./projectAtoms-DXXpuERK.js";import{Pi as s,a as c}from"./composerDraftStore-DpPEQ6BN.js";import{t as ee}from"./useNavigate-_4hWGSey.js";import{c as l}from"./toast-DmA_ziPT.js";import{a as te,c as ne,i as re,n as ie,o as ae,s as oe,t as se}from"./rightPanelRouteSearch-CfmZ7osj.js";import{Gt as ce}from"./providerIconUtils-D-DFhem2.js";import{a as le,d as ue,f as de,i as fe,l as pe,n as me,p as he,r as u,s as ge,t as _e}from"./ChatRightPanel-CWHOIuiQ.js";import{o as ve,x as ye}from"./sidebar-_u7SGgmC.js";import{i as be,t as xe}from"./storeSelectors-DhJRpdiw.js";var Se=n(),d=e(t(),1),f=s();function p(e){let t=(0,Se.c)(154),{threadRef:n,search:s}=e;ce(`ChatThreadRouteView`);let u=ee(),p;t[0]===n?.environmentId?p=t[1]:(p=e=>i(e,n?.environmentId??null).bootstrapComplete,t[0]=n?.environmentId,t[1]=p);let m=r(p),Te;t[2]===n?Te=t[3]:(Te=be(n),t[2]=n,t[3]=Te);let Ee=r(Te),De;t[4]===n?De=t[5]:(De=e=>o(e,n),t[4]=n,t[5]=De);let Oe=r(De),ke;t[6]===n?.environmentId?ke=t[7]:(ke=e=>i(e,n?.environmentId??null).threadIds.length>0,t[6]=n?.environmentId,t[7]=ke);let Ae=r(ke),je=a(we),h;t[8]!==je||t[9]!==n?.environmentId?(h=()=>xe(n?.environmentId??null,je),t[8]=je,t[9]=n?.environmentId,t[10]=h):h=t[10],n?.environmentId;let Me;t[11]===h?Me=t[12]:(Me=h(),t[11]=h,t[12]=Me);let g=r(Me),Ne=de(n),_=ue(n),Pe=he(n?.environmentId),v=Oe||Ne,y;t[13]===Ee?y=t[14]:(y=ge(Ee),t[13]=Ee,t[14]=y);let b=y,x=Ae||Pe,S=s.diff===`1`,C=s.preview===`1`,w;t[15]===s?w=t[16]:(w=se(s),t[15]=s,t[16]=w);let T=w,Fe;t[17]===s?Fe=t[18]:(Fe=ie(s),t[17]=s,t[18]=Fe);let E=Fe,D=s.workspaceTab===`agent`&&s.workspaceAgentKey?s.workspaceAgentKey:null,Ie=ye(pe),O=n?`${n.environmentId}:${n.threadId}`:null,Le;t[19]!==D||t[20]!==O||t[21]!==S||t[22]!==C||t[23]!==T?(Le=()=>({threadKey:O,hasOpenedDiff:S,hasOpenedPreview:C,hasOpenedTerminal:T===`terminal`,openedAgentKeys:D?[D]:[]}),t[19]=D,t[20]=O,t[21]=S,t[22]=C,t[23]=T,t[24]=Le):Le=t[24];let[k,Re]=(0,d.useState)(Le),A=k.threadKey===O?k.hasOpenedDiff:S,j=k.threadKey===O?k.hasOpenedPreview:C,M=k.threadKey===O?k.hasOpenedTerminal:T===`terminal`,ze;t[25]!==D||t[26]!==O||t[27]!==k.openedAgentKeys||t[28]!==k.threadKey?(ze=k.threadKey===O?k.openedAgentKeys:D?[D]:[],t[25]=D,t[26]=O,t[27]=k.openedAgentKeys,t[28]=k.threadKey,t[29]=ze):ze=t[29];let N=ze,Be;t[30]!==D||t[31]!==N?(Be=D&&!N.includes(D)?[...N,D]:N,t[30]=D,t[31]=N,t[32]=Be):Be=t[32];let P=Be,Ve;t[33]===T?Ve=t[34]:(Ve=()=>T??`review`,t[33]=T,t[34]=Ve);let[F,He]=(0,d.useState)(Ve),I;t[35]!==A||t[36]!==j||t[37]!==M||t[38]!==T?(I=[],(j||T===`files`)&&I.push(`files`),(A||T===`review`)&&I.push(`review`),(M||T===`terminal`)&&I.push(`terminal`),t[35]=A,t[36]=j,t[37]=M,t[38]=T,t[39]=I):I=t[39];let L=I,Ue;t[40]!==O||t[41]!==S||t[42]!==P||t[43]!==C||t[44]!==T?(Ue=e=>{He(e),Re(t=>{let n={threadKey:O,hasOpenedDiff:(t.threadKey===O?t.hasOpenedDiff:S)||e===`review`,hasOpenedPreview:(t.threadKey===O?t.hasOpenedPreview:C)||e===`files`,hasOpenedTerminal:(t.threadKey===O?t.hasOpenedTerminal:T===`terminal`)||e===`terminal`,openedAgentKeys:t.threadKey===O?t.openedAgentKeys:P};return t.threadKey===n.threadKey&&t.hasOpenedDiff===n.hasOpenedDiff&&t.hasOpenedPreview===n.hasOpenedPreview&&t.hasOpenedTerminal===n.hasOpenedTerminal&&t.openedAgentKeys===n.openedAgentKeys?t:n})},t[40]=O,t[41]=S,t[42]=P,t[43]=C,t[44]=T,t[45]=Ue):Ue=t[45];let R=Ue,We;t[46]!==u||t[47]!==n?(We=()=>{n&&u({to:`/$environmentId/$threadId`,params:l(n),search:Ce})},t[46]=u,t[47]=n,t[48]=We):We=t[48];let z=We,Ge;t[49]!==A||t[50]!==j||t[51]!==M||t[52]!==F||t[53]!==u||t[54]!==P||t[55]!==n?(Ge=()=>{n&&u({to:`/$environmentId/$threadId`,params:l(n),search:e=>{let t=P[P.length-1];return F===`agent`&&t?re(e,t):F===`files`&&j?te(e):F===`review`&&A?ae(e):F===`terminal`&&M?oe(e):j?te(e):A?ae(e):M?oe(e):t?re(e,t):ne(e)}})},t[49]=A,t[50]=j,t[51]=M,t[52]=F,t[53]=u,t[54]=P,t[55]=n,t[56]=Ge):Ge=t[56];let B=Ge,Ke;t[57]!==z||t[58]!==B||t[59]!==E?(Ke=()=>{if(E){z();return}B()},t[57]=z,t[58]=B,t[59]=E,t[60]=Ke):Ke=t[60];let V=Ke,qe;t[61]!==D||t[62]!==O||t[63]!==A||t[64]!==j||t[65]!==M||t[66]!==u||t[67]!==P||t[68]!==T||t[69]!==n?(qe=e=>{if(!n)return;if(e.mode===`agent`){let t=P.filter(t=>t!==e.agentKey);Re(e=>({threadKey:O,hasOpenedDiff:e.threadKey===O?e.hasOpenedDiff:A,hasOpenedPreview:e.threadKey===O?e.hasOpenedPreview:j,hasOpenedTerminal:e.threadKey===O?e.hasOpenedTerminal:M,openedAgentKeys:t})),T===`agent`&&D===e.agentKey&&u({to:`/$environmentId/$threadId`,params:l(n),search:e=>{let n=t[t.length-1];return n?re(e,n):j?te(e):A?ae(e):M?oe(e):ne(e)}});return}let t=e.mode===`review`?!1:A||T===`review`,r=e.mode===`files`?!1:j||T===`files`,i=e.mode===`terminal`?!1:M||T===`terminal`;Re(e=>{let n={threadKey:O,hasOpenedDiff:t,hasOpenedPreview:r,hasOpenedTerminal:i,openedAgentKeys:e.threadKey===O?e.openedAgentKeys:P};return e.threadKey===n.threadKey&&e.hasOpenedDiff===n.hasOpenedDiff&&e.hasOpenedPreview===n.hasOpenedPreview&&e.hasOpenedTerminal===n.hasOpenedTerminal&&e.openedAgentKeys===n.openedAgentKeys?e:n}),T===e.mode&&u({to:`/$environmentId/$threadId`,params:l(n),search:n=>e.mode!==`files`&&r?te(n):e.mode!==`review`&&t?ae(n):e.mode!==`terminal`&&i?oe(n):ne(n)})},t[61]=D,t[62]=O,t[63]=A,t[64]=j,t[65]=M,t[66]=u,t[67]=P,t[68]=T,t[69]=n,t[70]=qe):qe=t[70];let H=qe,U,Je;t[71]!==R||t[72]!==T?(U=()=>{T!==null&&(He(T),R(T))},Je=[R,T],t[71]=R,t[72]=T,t[73]=U,t[74]=Je):(U=t[73],Je=t[74]),(0,d.useEffect)(U,Je);let Ye,Xe;t[75]!==D||t[76]!==O||t[77]!==S||t[78]!==A||t[79]!==j||t[80]!==M||t[81]!==C||t[82]!==T?(Ye=()=>{!O||!D||Re(e=>{let t=e.threadKey===O?e.openedAgentKeys:[];return t.includes(D)?e.threadKey===O?e:{threadKey:O,hasOpenedDiff:A,hasOpenedPreview:j,hasOpenedTerminal:M,openedAgentKeys:t}:{threadKey:O,hasOpenedDiff:e.threadKey===O?e.hasOpenedDiff:S,hasOpenedPreview:e.threadKey===O?e.hasOpenedPreview:C,hasOpenedTerminal:e.threadKey===O?e.hasOpenedTerminal:T===`terminal`,openedAgentKeys:[...t,D]}})},Xe=[D,O,S,A,j,M,C,T],t[75]=D,t[76]=O,t[77]=S,t[78]=A,t[79]=j,t[80]=M,t[81]=C,t[82]=T,t[83]=Ye,t[84]=Xe):(Ye=t[83],Xe=t[84]),(0,d.useEffect)(Ye,Xe);let Ze,Qe;t[85]!==m||t[86]!==x||t[87]!==g||t[88]!==u||t[89]!==v||t[90]!==n?(Ze=()=>{!n||!m||!v&&x&&u(g?{to:`/$environmentId/$threadId`,params:l(g),replace:!0}:{to:`/`,replace:!0})},Qe=[m,x,g,u,v,n],t[85]=m,t[86]=x,t[87]=g,t[88]=u,t[89]=v,t[90]=n,t[91]=Ze,t[92]=Qe):(Ze=t[91],Qe=t[92]),(0,d.useEffect)(Ze,Qe);let $e;t[93]!==_?.promotedTo||t[94]!==b||t[95]!==n?($e=()=>{!n||!b||!_?.promotedTo||c(n)},t[93]=_?.promotedTo,t[94]=b,t[95]=n,t[96]=$e):$e=t[96];let et=_?.promotedTo,tt;if(t[97]!==b||t[98]!==et||t[99]!==n?(tt=[et,b,n],t[97]=b,t[98]=et,t[99]=n,t[100]=tt):tt=t[100],(0,d.useEffect)($e,tt),!n||!m||!v)return null;let W=E||T===`review`||A||T===`files`||j||T===`terminal`||M||T===`agent`||P.length>0,G=E?T:F;if(!Ie){let e,r,i,a;t[101]===R?(e=t[102],r=t[103],i=t[104],a=t[105]):(e=()=>R(`review`),r=()=>R(`files`),i=()=>R(`terminal`),a=()=>R(`agent`),t[101]=R,t[102]=e,t[103]=r,t[104]=i,t[105]=a);let o;t[106]!==E||t[107]!==e||t[108]!==r||t[109]!==i||t[110]!==a||t[111]!==n.environmentId||t[112]!==n.threadId||t[113]!==V?(o=(0,f.jsx)(ve,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,f.jsx)(fe,{environmentId:n.environmentId,threadId:n.threadId,onDiffPanelOpen:e,onPreviewPanelOpen:r,onTerminalPanelOpen:i,onAgentPanelOpen:a,workspacePanelOpen:E,onToggleWorkspacePanel:V,routeKind:`server`})}),t[106]=E,t[107]=e,t[108]=r,t[109]=i,t[110]=a,t[111]=n.environmentId,t[112]=n.threadId,t[113]=V,t[114]=o):o=t[114];let s;t[115]!==H||t[116]!==z||t[117]!==G||t[118]!==B||t[119]!==P||t[120]!==L||t[121]!==E||t[122]!==W?(s=(0,f.jsx)(me,{open:E,panelMode:G,openedPanelModes:L,openedAgentKeys:P,onClosePanelTab:H,onClose:z,onOpen:B,renderContent:W}),t[115]=H,t[116]=z,t[117]=G,t[118]=B,t[119]=P,t[120]=L,t[121]=E,t[122]=W,t[123]=s):s=t[123];let c;return t[124]!==o||t[125]!==s?(c=(0,f.jsxs)(f.Fragment,{children:[o,s]}),t[124]=o,t[125]=s,t[126]=c):c=t[126],c}let K,q,J,Y;t[127]===R?(K=t[128],q=t[129],J=t[130],Y=t[131]):(K=()=>R(`review`),q=()=>R(`files`),J=()=>R(`terminal`),Y=()=>R(`agent`),t[127]=R,t[128]=K,t[129]=q,t[130]=J,t[131]=Y);let X;t[132]!==E||t[133]!==K||t[134]!==q||t[135]!==J||t[136]!==Y||t[137]!==n.environmentId||t[138]!==n.threadId||t[139]!==V?(X=(0,f.jsx)(ve,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,f.jsx)(fe,{environmentId:n.environmentId,threadId:n.threadId,onDiffPanelOpen:K,onPreviewPanelOpen:q,onTerminalPanelOpen:J,onAgentPanelOpen:Y,workspacePanelOpen:E,onToggleWorkspacePanel:V,routeKind:`server`})}),t[132]=E,t[133]=K,t[134]=q,t[135]=J,t[136]=Y,t[137]=n.environmentId,t[138]=n.threadId,t[139]=V,t[140]=X):X=t[140];let Z;t[141]!==H||t[142]!==G||t[143]!==P||t[144]!==L||t[145]!==W?(Z=W?(0,f.jsx)(_e,{mode:`sheet`,panelMode:G,openedPanelModes:L,openedAgentKeys:P,onClosePanelTab:H}):null,t[141]=H,t[142]=G,t[143]=P,t[144]=L,t[145]=W,t[146]=Z):Z=t[146];let Q;t[147]!==z||t[148]!==E||t[149]!==Z?(Q=(0,f.jsx)(le,{open:E,onClose:z,children:Z}),t[147]=z,t[148]=E,t[149]=Z,t[150]=Q):Q=t[150];let $;return t[151]!==X||t[152]!==Q?($=(0,f.jsxs)(f.Fragment,{children:[X,Q]}),t[151]=X,t[152]=Q,t[153]=$):$=t[153],$}function Ce(e){return u(e)}function we(e){return e.sidebarThreadSortOrder}export{p as ChatThreadRouteView};
@@ -1 +1 @@
1
- import{i as e,t}from"./react-PSPkXoKo.js";import{t as n}from"./compiler-runtime-BNrXlsa1.js";import{ma as r,no as i,ro as a}from"./react-CjD7iThp.js";import{B as o,F as s,G as c,H as l,I as u,K as d,Kt as f,L as ee,O as te,Ot as ne,P as re,R as ie,U as ae,V as oe,W as se,Yt as ce,_t as le,a as ue,gt as de,hn as fe,nn as pe,p as me,qt as he,sn as ge,tn as _e,z as ve}from"./projectAtoms-DUEBb7Zz.js";import{A as ye,Cr as be,M as xe,Ni as Se,O as Ce,Or as we,Sr as p,Tr as Te,Xr as m,br as Ee,ca as De,da as Oe,k as ke,wr as h}from"./composerDraftStore-D12lUSfh.js";import{t as Ae}from"./useNavigate-B2tgshhW.js";import{a as g,c as je,i as _}from"./toast-DE7a4wkW.js";import{i as Me,r as Ne}from"./primary-CSkhdakK.js";import{$t as Pe,An as Fe,Dn as Ie,Er as Le,Fn as Re,Ln as v,Mn as ze,Nn as y,Pn as b,Qn as Be,Tn as x,Wn as S,an as Ve,cn as C,cr as He,fn as w,in as T,jn as Ue,kn as We,mr as Ge,rr as Ke,un as qe,wn as Je}from"./providerIconUtils-uhWb4bdg.js";import{C as Ye,n as E,t as D,w as Xe}from"./kbd-aeSsjiPI.js";import{n as Ze,t as Qe}from"./commandPaletteStore-uVfCD7zE.js";import{c as O,n as $e,r as et}from"./ThreadStatusIndicators-B0leIJGD.js";import{i as tt,n as nt,r as rt}from"./chatThreadActions-PPyTj_x0.js";import{a as it,l as at,s as ot}from"./BranchToolbar.logic-C_xHEt9C.js";import{t as st}from"./shallow-Dmd-gez1.js";import{a as ct,s as k}from"./storeSelectors-Cx1IYPA4.js";import{t as lt}from"./settingsDialogStore-BINi7pdD.js";import{t as ut}from"./useHandleNewThread-XB82O6SA.js";import{g as dt}from"./keybindings-Dx4Nc1vY.js";import{t as ft}from"./ProjectFavicon-TDP7HRfn.js";var pt=m(`corner-left-up`,[[`path`,{d:`M14 9 9 4 4 9`,key:`1af5af`}],[`path`,{d:`M20 20h-7a4 4 0 0 1-4-4V4`,key:`1blwi3`}]]),mt=m(`folder-symlink`,[[`path`,{d:`M2 9.35V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7`,key:`y8kt7d`}],[`path`,{d:`m8 16 3-3-3-3`,key:`rlqrt1`}]]),A=e(t(),1),j=n(),M=`size-4 text-muted-foreground/80`,N=`size-4`;function ht(e){return e.isAlias?`browse:alias:${e.name}:${e.fullPath}`:`browse:${e.fullPath}`}function gt(e){let t=e.browseFilterQuery.toLowerCase(),n=e.browseFilterQuery.startsWith(`.`),r=e.browseEntries.filter(e=>e.name.toLowerCase().startsWith(t)&&(n||!e.name.startsWith(`.`))),i=null,a=e.highlightedItemValue;a&&a.startsWith(`browse:`)&&(i=r.find(e=>ht(e)===a)??null);let o=e.browseFilterQuery.length>0?r.find(t=>t.name===e.browseFilterQuery)??null:null;return{filteredEntries:r,highlightedEntry:i,exactEntry:o}}function P(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function _t(e){return e.projects.map(t=>({kind:`action`,value:`${e.valuePrefix}:${t.environmentId}:${t.id}`,searchTerms:[t.name,t.cwd],title:t.name,description:t.cwd,icon:e.icon(t),run:async()=>{await e.runProject(t)}}))}function vt(e){let t=k(e.threads.filter(e=>e.archivedAt===null),e.sortOrder);return(e.limit===void 0?t:t.slice(0,e.limit)).map(t=>{let n=e.projectTitleById.get(t.projectId),r=[];n&&r.push(n),t.branch&&r.push(`#${t.branch}`),t.id===e.activeThreadId&&r.push(`Current thread`);let i=e.renderLeadingContent?.(t),a=e.renderTrailingContent?.(t);return Object.assign({kind:`action`,value:`thread:${t.id}`,searchTerms:[t.title,n??``,t.branch??``],title:t.title,description:r.join(` · `),timestamp:S(t.latestUserMessageAt??t.updatedAt??t.createdAt),icon:e.icon},i?{titleLeadingContent:i}:{},a?{titleTrailingContent:a}:{},{run:async()=>{await e.runThread(t)}})})}function yt(e,t){let n=P(e);return n.length===0||!n.includes(t)?-1/0:n===t?3:n.startsWith(t)?2:1}function bt(e,t){let n=e.searchTerms.filter(e=>e.length>0);if(n.length===0)return 0;for(let[e,r]of n.entries()){let n=yt(r,t);if(n!==-1/0)return 1e3-e*100+n}return 0}function xt(e){let t=e.query.startsWith(`>`),n=P(t?e.query.slice(1):e.query);if(n.length===0)return t?e.activeGroups.filter(e=>e.value===`actions`):[...e.activeGroups];let r=[...e.activeGroups];t?r=r.filter(e=>e.value===`actions`):e.isInSubmenu||(r=r.filter(e=>e.value!==`recent-threads`));let i=[...r];return!e.isInSubmenu&&!t&&(e.projectSearchItems.length>0&&i.push({value:`projects-search`,label:`Projects`,items:e.projectSearchItems}),e.threadSearchItems.length>0&&i.push({value:`threads-search`,label:`Threads`,items:e.threadSearchItems})),i.flatMap(e=>{let t=e.items.map((e,t)=>P(e.searchTerms.join(` `)).includes(n)?{item:e,index:t,rank:bt(e,n)}:null).filter(e=>e!==null).toSorted((e,t)=>t.rank-e.rank||e.index-t.index).map(e=>e.item);return t.length===0?[]:[{value:e.value,label:e.label,items:t}]})}function St(e){let t=[];e.canBrowseUp&&t.push({kind:`action`,value:`browse:up`,searchTerms:[e.browseQuery,`..`],title:`..`,icon:e.upIcon,keepOpen:!0,run:async()=>{e.browseUp()}});for(let n of e.browseEntries)t.push({kind:`action`,value:ht(n),searchTerms:[e.browseQuery,n.fullPath,n.name],title:n.name,icon:n.isSymlink?e.symlinkIcon:e.directoryIcon,keepOpen:!0,run:async()=>{n.isAlias?e.browseToPath(n.fullPath):e.browseTo(n.name)}});return[{value:`directories`,label:`Directories`,items:t}]}function Ct(e){return e.currentView?e.isBrowsing?`submenu-browse`:`submenu`:e.isBrowsing?`root-browse`:`root`}function wt(e){let t=[];return e.actionItems.length>0&&t.push({value:`actions`,label:`Actions`,items:e.actionItems}),e.recentThreadItems.length>0&&t.push({value:`recent-threads`,label:`Recent Threads`,items:e.recentThreadItems}),t}function Tt(e){switch(e){case`root`:return`Search commands, projects, and threads...`;case`root-browse`:return`Enter project path (e.g. ~/projects/my-app)`;case`submenu`:return`Search...`;case`submenu-browse`:return`Enter path (e.g. ~/projects/my-app)`}}var F=Se();function Et(e){let t=(0,j.c)(13);if(e.groups.length===0){let n=e.emptyStateMessage??(e.isActionsOnly?`No matching actions.`:`No matching commands, projects, or threads.`),r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:n}),t[0]=n,t[1]=r),r}let n;if(t[2]!==e.groups||t[3]!==e.highlightedItemValue||t[4]!==e.keybindings||t[5]!==e.onExecuteItem){let r;t[7]!==e.highlightedItemValue||t[8]!==e.keybindings||t[9]!==e.onExecuteItem?(r=t=>(0,F.jsxs)(Fe,{items:t.items,children:[(0,F.jsx)(Ue,{children:t.label}),(0,F.jsx)(x,{children:t=>t.disabled?(0,F.jsx)(I,{item:t},t.value):(0,F.jsx)(L,{item:t,keybindings:e.keybindings,isActive:e.highlightedItemValue===t.value,onExecuteItem:e.onExecuteItem},t.value)})]},t.value),t[7]=e.highlightedItemValue,t[8]=e.keybindings,t[9]=e.onExecuteItem,t[10]=r):r=t[10],n=e.groups.map(r),t[2]=e.groups,t[3]=e.highlightedItemValue,t[4]=e.keybindings,t[5]=e.onExecuteItem,t[6]=n}else n=t[6];let r;return t[11]===n?r=t[12]:(r=(0,F.jsx)(b,{children:n}),t[11]=n,t[12]=r),r}function I(e){let t=(0,j.c)(8),n;t[0]!==e.item.description||t[1]!==e.item.title||t[2]!==e.item.titleLeadingContent?(n=e.item.description?(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),(0,F.jsx)(`span`,{className:`truncate text-muted-foreground/70 text-xs`,children:e.item.description})]}):(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),t[0]=e.item.description,t[1]=e.item.title,t[2]=e.item.titleLeadingContent,t[3]=n):n=t[3];let r;return t[4]!==e.item.icon||t[5]!==e.item.titleTrailingContent||t[6]!==n?(r=(0,F.jsxs)(`div`,{className:`flex min-h-8 select-none items-center gap-2 rounded-sm px-2 py-1.5 text-base opacity-64 sm:min-h-7 sm:text-sm`,children:[e.item.icon,n,e.item.titleTrailingContent]}),t[4]=e.item.icon,t[5]=e.item.titleTrailingContent,t[6]=n,t[7]=r):r=t[7],r}function L(e){let t=(0,j.c)(27),n;t[0]!==e.item.shortcutCommand||t[1]!==e.keybindings?(n=e.item.shortcutCommand?dt(e.keybindings,e.item.shortcutCommand):null,t[0]=e.item.shortcutCommand,t[1]=e.keybindings,t[2]=n):n=t[2];let r=n,i=e.item.value,a=e.isActive&&`bg-accent! text-accent-foreground!`,o;t[3]===a?o=t[4]:(o=p(`cursor-pointer gap-2 hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit data-selected:bg-transparent data-selected:text-inherit [&[data-highlighted][data-selected]]:bg-transparent [&[data-highlighted][data-selected]]:text-inherit`,a),t[3]=a,t[4]=o);let s;t[5]===e?s=t[6]:(s=()=>{e.onExecuteItem(e.item)},t[5]=e,t[6]=s);let c;t[7]!==e.item.description||t[8]!==e.item.title||t[9]!==e.item.titleLeadingContent?(c=e.item.description?(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),(0,F.jsx)(`span`,{className:`truncate text-muted-foreground/70 text-xs`,children:e.item.description})]}):(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),t[7]=e.item.description,t[8]=e.item.title,t[9]=e.item.titleLeadingContent,t[10]=c):c=t[10];let l;t[11]===e.item.timestamp?l=t[12]:(l=e.item.timestamp?(0,F.jsx)(`span`,{className:`min-w-12 shrink-0 text-right text-[10px] tabular-nums text-muted-foreground/70`,children:e.item.timestamp}):null,t[11]=e.item.timestamp,t[12]=l);let u;t[13]===r?u=t[14]:(u=r?(0,F.jsx)(v,{children:r}):null,t[13]=r,t[14]=u);let d;t[15]===e.item.kind?d=t[16]:(d=e.item.kind===`submenu`?(0,F.jsx)(Le,{className:`ml-auto size-4 shrink-0 text-muted-foreground/50`}):null,t[15]=e.item.kind,t[16]=d);let f;return t[17]!==e.item.icon||t[18]!==e.item.titleTrailingContent||t[19]!==e.item.value||t[20]!==o||t[21]!==s||t[22]!==c||t[23]!==l||t[24]!==u||t[25]!==d?(f=(0,F.jsxs)(y,{value:i,className:o,onMouseDown:Dt,onClick:s,children:[e.item.icon,c,e.item.titleTrailingContent,l,u,d]}),t[17]=e.item.icon,t[18]=e.item.titleTrailingContent,t[19]=e.item.value,t[20]=o,t[21]=s,t[22]=c,t[23]=l,t[24]=u,t[25]=d,t[26]=f):f=t[26],f}function Dt(e){e.preventDefault()}var Ot=[],kt=3e4;function At(e){return be(e)?`Finder`:h(e)?`Explorer`:`Files`}function jt(e){return e===`windows`?`Win32`:e===`darwin`?`MacIntel`:e===`linux`?`Linux`:typeof navigator>`u`?``:navigator.platform}var Mt=[`url`,`github`,`gitlab`,`forgejo`,`bitbucket`,`azure-devops`],Nt=[`github`,`gitlab`,`forgejo`,`bitbucket`,`azure-devops`];function Pt(e){switch(e){case`github`:return`GitHub`;case`gitlab`:return`GitLab`;case`forgejo`:return`Forgejo`;case`bitbucket`:return`Bitbucket`;case`azure-devops`:return`Azure DevOps`;case`url`:return`Git URL`}}function Ft(e){switch(e){case`github`:return`owner/repo`;case`gitlab`:return`group/project`;case`forgejo`:return`owner/repo`;case`bitbucket`:return`workspace/repository`;case`azure-devops`:return`project/repository`;case`url`:return`URL`}}function It(e){return e===`url`?null:e}function R(e,t){switch(e){case`github`:return(0,F.jsx)(qe,{className:t});case`gitlab`:return(0,F.jsx)(w,{className:t});case`forgejo`:return(0,F.jsx)(C,{className:t});case`bitbucket`:return(0,F.jsx)(Ve,{className:t});case`azure-devops`:return(0,F.jsx)(T,{className:t});case`url`:return(0,F.jsx)(tt,{className:t})}}function Lt(e){return!e||e.step===`confirm`?null:e.source===`url`?`Enter Git clone URL`:`Enter ${Pt(e.source)} repository (${Ft(e.source)})`}function Rt(e){return e.split(`/`).at(-1)?.trim()??e}function zt(e){return`remote-repository:${e.provider}:${encodeURIComponent(e.nameWithOwner)}`}function Bt(e,t){return e===`bitbucket`?t.url:t.sshUrl}function Vt(e){return!e.includes(`/`)&&!e.includes(`:`)}function Ht(e){return e===`url`?null:e}function Ut(e){return Nt.toSorted((t,n)=>{let r=e[t].ready;return r===e[n].ready?Pt(t).localeCompare(Pt(n)):r?-1:1})}function Wt(e){let t={ready:!1,hint:`Provider status unavailable. Open Settings -> Source Control and rescan.`},n={url:{ready:!0,hint:null},github:t,gitlab:t,forgejo:t,bitbucket:t,"azure-devops":t};if(!e)return n;let i=new Map(e.sourceControlProviders.map(e=>[e.kind,e])),a={...n};for(let e of Mt){let n=Ht(e);if(!n)continue;let o=i.get(n);if(!o){a[e]=t;continue}if(o.status!==`available`){a[e]={ready:!1,hint:o.installHint};continue}if(o.auth.status===`unauthenticated`){a[e]={ready:!1,hint:r(o.auth.detail)??`${o.label} is not authenticated. Open Settings -> Source Control for setup guidance.`};continue}a[e]={ready:!0,hint:null}}return a}function Gt(e){return e instanceof Error&&e.message.trim().length>0?e.message:`An error occurred.`}function z(){let e=(0,j.c)(5),t=Qe(qt),n=Qe(Kt),r,i;e[0]===n?(r=e[1],i=e[2]):(r=()=>()=>{n(!1)},i=[n],e[0]=n,e[1]=r,e[2]=i),(0,A.useEffect)(r,i);let a;return e[3]===t?a=e[4]:(a=t?(0,F.jsx)(B,{}):null,e[3]=t,e[4]=a),a}function Kt(e){return e.setOpen}function qt(e){return e.open}function B(){let e=Ae(),t=Qe(e=>e.setOpen),n=Qe(e=>e.openIntent),r=Qe(e=>e.clearOpenIntent),Se=Pe(),[m,h]=(0,A.useState)(``),Fe=(0,A.useDeferredValue)(m),Le=Fe.startsWith(`>`),[v,y]=(0,A.useState)(null),b=ge(),{activeDraftThread:x,activeThread:S,defaultProjectRef:Ve,handleNewThread:C}=ut(),w=ne(st(de)),T=ne(st(le)),Ue=fe(),[qe,tt]=(0,A.useState)([]),k=qe.at(-1)??null,[dt,j]=(0,A.useState)(0),[ht,P]=(0,A.useState)(null),[yt,bt]=(0,A.useState)(!1),[I,L]=(0,A.useState)(null),[Dt,Mt]=(0,A.useState)(!1),[Nt,Ht]=(0,A.useState)(!1),z=Me(),Kt=Ne()?.label??null,qt=f(e=>e.byId),B=he(e=>e.byId),Jt=(0,A.useMemo)(()=>{let e=[],t=new Set;z&&(t.add(z),e.push({environmentId:z,label:it({isPrimary:!0,environmentId:z,runtimeLabel:Kt}),isPrimary:!0}));for(let n of Object.values(qt)){if(t.has(n.environmentId))continue;let r=B[n.environmentId];e.push({environmentId:n.environmentId,label:it({isPrimary:!1,environmentId:n.environmentId,runtimeLabel:r?.descriptor?.label??null,savedLabel:n.label}),isPrimary:!1})}return e.sort((e,t)=>e.isPrimary===t.isPrimary?e.label.localeCompare(t.label):e.isPrimary?-1:1),e},[z,Kt,qt,B]),Yt=Jt[0]?.environmentId??null,V=ht??Yt,Xt=(0,A.useMemo)(()=>jt(V&&z&&V===z?Ne()?.platform.os??null:V?B[V]?.descriptor?.platform.os??B[V]?.serverConfig?.environment.platform.os??null:null),[V,z,B]),Zt=I!==null,Qt=I?.step===`repository`,H=Qt&&I?It(I.source):null,U=Qt?Fe.trim():``,W=Be({environmentId:I?.step===`repository`?I.environmentId:null,provider:H,query:U,limit:25,enabled:I?.step===`repository`&&I.source!==`url`&&H===`bitbucket`}),G=!Qt&&ae(m,Xt),$t=Ct({currentView:k,isBrowsing:G}),en=(0,A.useCallback)(e=>{let t=(e&&z&&e===z?b:e?B[e]?.serverConfig?.settings:null)?.addProjectBaseDirectory?.trim()??``;return t.length===0?`~/`:u(t)},[z,B,b]),tn=(0,A.useMemo)(()=>new Map(w.map(e=>[e.id,e.cwd])),[w]),nn=(0,A.useMemo)(()=>new Map(w.map(e=>[e.id,e.name])),[w]),rn=S?.id,an=S?.environmentId??x?.environmentId??null,on=S?.projectId??x?.projectId??null,sn=on?tn.get(on)??null:null,K=V&&an===V?sn:null,q=d(m.trim())&&K===null,J=G?ie(m):``,cn=G&&!oe(m)?ve(m):``,ln=ot({environmentId:V,partialPath:J,cwd:K,staleTime:kt,enabled:G&&J.length>0&&V!==null&&!q}),Y=ln.data,un=ln.isPending,dn=Y?.entries??Ot,{filteredEntries:fn,exactEntry:pn}=(0,A.useMemo)(()=>gt({browseEntries:dn,browseFilterQuery:cn,highlightedItemValue:v}),[dn,cn,v]),mn=(0,A.useCallback)(e=>{ue({environmentId:V,partialPath:e,cwd:K,staleTime:kt})},[V,K]);(0,A.useEffect)(()=>{G&&s(m)&&mn(o(m))},[G,mn,m]);let hn=(0,A.useMemo)(()=>async t=>{Ce.getState().setProjectExpanded(te(t,b),!0);let n=ct(T.filter(e=>e.environmentId===t.environmentId),t.id,b.sidebarThreadSortOrder);if(n){await e({to:`/$environmentId/$threadId`,params:je(a(n.environmentId,n.id))});return}await C(i(t.environmentId,t.id),{envMode:b.defaultThreadEnvMode})},[C,e,b,T]),gn=(0,A.useMemo)(()=>_t({projects:w,valuePrefix:`project`,icon:e=>(0,F.jsx)(ft,{environmentId:e.environmentId,cwd:e.cwd,projectId:e.id,customAvatarContentHash:e.customAvatarContentHash??null,className:M}),runProject:hn}),[hn,w]),_n=(0,A.useMemo)(()=>_t({projects:w,valuePrefix:`new-thread-in`,icon:e=>(0,F.jsx)(ft,{environmentId:e.environmentId,cwd:e.cwd,projectId:e.id,customAvatarContentHash:e.customAvatarContentHash??null,className:M}),runProject:async e=>{await rt({activeDraftThread:x,activeThread:S,defaultProjectRef:Ve,defaultThreadEnvMode:b.defaultThreadEnvMode,handleNewThread:C},i(e.environmentId,e.id))}}),[x,S,Ve,C,w,b.defaultThreadEnvMode]),vn=(0,A.useMemo)(()=>vt({threads:T,...rn?{activeThreadId:rn}:{},projectTitleById:nn,sortOrder:b.sidebarThreadSortOrder,icon:(0,F.jsx)(He,{className:M}),renderLeadingContent:e=>(0,F.jsx)($e,{thread:e}),renderTrailingContent:e=>(0,F.jsx)(et,{thread:e}),runThread:async t=>{await e({to:`/$environmentId/$threadId`,params:je(a(t.environmentId,t.id))})}}),[rn,e,nn,b.sidebarThreadSortOrder,T]),yn=vn.slice(0,12);function X(e){tt(t=>[...t,{addonIcon:e.addonIcon,groups:e.groups,...e.initialQuery?{initialQuery:e.initialQuery}:{}}]),y(null),h(e.initialQuery??``)}function bn(e){X({addonIcon:e.addonIcon,groups:e.groups,...e.initialQuery?{initialQuery:e.initialQuery}:{}})}function xn(){L(null),qe.length<=1&&P(null),tt(e=>e.slice(0,-1)),y(null),h(``)}function Sn(e){y(null),h(e),e===``&&k?.initialQuery&&xn()}let Cn=(0,A.useCallback)(e=>{P(e),L(null),X({addonIcon:(0,F.jsx)(O,{className:N}),groups:[],initialQuery:en(e)})},[en]),wn=(0,A.useCallback)((e,t)=>{P(e),L({step:`repository`,environmentId:e,source:t}),X({addonIcon:R(t,N),groups:[],initialQuery:``})},[]),Tn=lt(e=>e.openSettings),En=(0,A.useCallback)(()=>{t(!1),Tn(`source-control`)},[Tn,t]),Dn=(0,A.useCallback)((e,t)=>{let n=[{kind:`action`,value:`action:add-project:${e}:local`,searchTerms:[`local`,`folder`,`directory`,`browse`],title:`Local folder`,description:`Browse a folder on disk`,icon:(0,F.jsx)(O,{className:M}),keepOpen:!0,run:async()=>{Cn(e)}}],r=[`url`,...Ut(t)];for(let i of r){let r=Pt(i),a=i===`url`?`Git URL`:`${r} repository`,o=i===`url`?`Clone from a remote URL`:`Clone ${r} ${Ft(i)}`,s=t[i],c=s.hint,l=s.ready?void 0:(0,F.jsx)(`span`,{className:`ml-auto`,children:(0,F.jsxs)(ke,{children:[(0,F.jsx)(xe,{render:(0,F.jsx)(Ee,{variant:`outline`,size:`xs`,className:`h-5 rounded-sm px-1.5 text-[10px] text-warning-foreground`,onClick:()=>{En()},children:`Setup Required`})}),(0,F.jsx)(ye,{align:`end`,side:`left`,children:c??`Open Settings -> Source Control to configure this provider.`})]})});if(!s.ready){n.push({kind:`action`,value:`action:add-project:${e}:${i}:not-ready`,searchTerms:[`clone`,`remote`,`repository`,`repo`,`git`,r,`setup required`],title:a,description:o,disabled:!0,icon:R(i,M),...l?{titleTrailingContent:l}:{},run:async()=>{}});continue}n.push({kind:`action`,value:`action:add-project:${e}:${i}`,searchTerms:[`clone`,`remote`,`repository`,`repo`,`git`,r],title:a,description:o,icon:R(i,M),...l?{titleTrailingContent:l}:{},keepOpen:!0,run:async()=>{wn(e,i)}})}return[{value:`sources:${e}`,label:`Sources`,items:n}]},[En,Cn,wn]),On=(0,A.useCallback)(e=>{P(e),L(null);let t={environmentId:e},n=_e(t).data;X({addonIcon:(0,F.jsx)(O,{className:N}),groups:Dn(e,Wt(n))}),pe(t).then(t=>{tt(n=>n.at(-1)?.groups[0]?.value===`sources:${e}`?[...n.slice(0,-1),{addonIcon:(0,F.jsx)(O,{className:N}),groups:Dn(e,Wt(t))}]:n)})},[Dn]),kn=Jt.map(e=>({kind:`action`,value:`action:add-project:environment:${e.environmentId}`,searchTerms:[e.label,e.environmentId,e.isPrimary?`this device`:``],title:e.label,description:e.isPrimary?`This device`:e.environmentId,icon:(0,F.jsx)(O,{className:M}),keepOpen:!0,run:async()=>{On(e.environmentId)}})),An=(0,A.useMemo)(()=>[{value:`environments`,label:`Environments`,items:kn}],[kn]),jn=(0,A.useCallback)(()=>{if(Jt.length>1){X({addonIcon:(0,F.jsx)(O,{className:N}),groups:An});return}let e=Yt;if(!e){_.add(g({type:`error`,title:`Unable to browse projects`,description:`No environment is available.`}));return}On(e)},[An,Jt.length,Yt,On]);(0,A.useLayoutEffect)(()=>{n?.kind===`add-project`&&(r(),jn())},[r,jn,n]);let Z=[];if(w.length>0){let e=on?nn.get(on)??null:null;e&&Z.push({kind:`action`,value:`action:new-thread`,searchTerms:[`new thread`,`chat`,`create`,`draft`],title:(0,F.jsxs)(F.Fragment,{children:[`New thread in `,(0,F.jsx)(`span`,{className:`font-semibold`,children:e})]}),icon:(0,F.jsx)(at,{className:M}),shortcutCommand:`chat.new`,run:async()=>{await nt({activeDraftThread:x,activeThread:S,defaultProjectRef:Ve,defaultThreadEnvMode:b.defaultThreadEnvMode,handleNewThread:C})}}),Z.push({kind:`submenu`,value:`action:new-thread-in`,searchTerms:[`new thread`,`project`,`pick`,`choose`,`select`],title:`New thread in...`,icon:(0,F.jsx)(at,{className:M}),addonIcon:(0,F.jsx)(at,{className:N}),groups:[{value:`projects`,label:`Projects`,items:_n}]})}Z.push({kind:`action`,value:`action:add-project`,searchTerms:[`add project`,`folder`,`directory`,`browse`,`clone`,`remote`,`repository`,`repo`,`git`,`github`,`gitlab`,`forgejo`,`codeberg`,`bitbucket`,`azure`,`devops`,`url`,`environment`],title:`Add project`,icon:(0,F.jsx)(O,{className:M}),keepOpen:!0,run:async()=>{jn()}}),Z.push({kind:`action`,value:`action:settings`,searchTerms:[`settings`,`preferences`,`configuration`,`keybindings`],title:`Open settings`,icon:(0,F.jsx)(Ke,{className:M}),run:async()=>{t(!1),Tn()}});let Mn=wt({actionItems:Z,recentThreadItems:yn}),Nn=xt({activeGroups:k?k.groups:Mn,query:Fe,isInSubmenu:k!==null,projectSearchItems:gn,threadSearchItems:vn}),Pn=(0,A.useCallback)(async n=>{if(!V)return;let r=me(V);if(!r)return;if(se(n.trim(),Xt)){_.add(g({type:`error`,title:`Failed to add project`,description:`Windows-style paths are only supported on Windows.`}));return}if(d(n.trim())&&!K){_.add(g({type:`error`,title:`Failed to add project`,description:`Relative paths require an active project.`}));return}let o=c(n,K);if(o.length===0)return;let s=ee(w.filter(e=>e.environmentId===V),o);if(s){Ce.getState().setProjectExpanded(te(s,b),!0);let n=ct(T.filter(e=>e.environmentId===s.environmentId),s.id,b.sidebarThreadSortOrder);n?await e({to:`/$environmentId/$threadId`,params:je(a(n.environmentId,n.id))}):await C(i(s.environmentId,s.id),{envMode:b.defaultThreadEnvMode}).catch(()=>void 0),t(!1);return}try{let e=we();await r.orchestration.dispatchCommand({type:`project.create`,commandId:Te(),projectId:e,title:l(o),workspaceRoot:o,projectMetadataDir:`.ryco`,createWorkspaceRootIfMissing:!0,defaultModelSelection:{instanceId:Oe.make(`codex`),model:De},createdAt:new Date().toISOString()}),await C(i(V,e),{envMode:b.defaultThreadEnvMode}).catch(()=>void 0),t(!1)}catch(e){_.add(g({type:`error`,title:`Failed to add project`,description:e instanceof Error?e.message:`An error occurred.`}))}},[V,Xt,K,C,e,w,t,b,T]),Fn=(0,A.useCallback)(e=>en(e),[en]),Q=(0,A.useCallback)(e=>{let t=Fn(e.flow.environmentId);L({step:`confirm`,environmentId:e.flow.environmentId,source:e.flow.source,repositoryInput:e.repositoryInput,repository:e.repository,remoteUrl:e.remoteUrl}),y(null),h(t),j(e=>e+1)},[Fn]);async function In(e){if(!I)return;let t=me(I.environmentId);if(!t){_.add(g({type:`error`,title:`Unable to clone project`,description:`Environment API is not available.`}));return}if(I.step===`repository`){let e=m.trim();if(e.length===0||Dt)return;let n=It(I.source);if(!n){Q({flow:I,repositoryInput:e,repository:null,remoteUrl:e});return}let r=W.data?.repositories??[];if(Vt(e)&&U===e&&r.length===1){let e=r[0];Q({flow:I,repositoryInput:e.nameWithOwner,repository:e,remoteUrl:Bt(I.source,e)});return}Mt(!0);try{let r=await t.sourceControl.lookupRepository({provider:n,repository:e});Q({flow:I,repositoryInput:e,repository:r,remoteUrl:Bt(I.source,r)})}catch(e){_.add(g({type:`error`,title:`Repository lookup failed`,description:Gt(e)}))}finally{Mt(!1)}return}let n=(e??m).trim();if(n.length===0||Nt)return;if(se(n,Xt)){_.add(g({type:`error`,title:`Clone failed`,description:`Windows-style paths are only supported on Windows.`}));return}if(d(n)&&!K){_.add(g({type:`error`,title:`Clone failed`,description:`Relative paths require an active project.`}));return}let r=c(n,K);if(r.length!==0){Ht(!0);try{let e=It(I.source);await Pn((await t.sourceControl.cloneRepository({...e&&I.repository?{provider:e,repository:I.repository.nameWithOwner,remoteUrl:I.remoteUrl,...I.source===`bitbucket`?{protocol:`https`}:{}}:{remoteUrl:I.remoteUrl},destinationPath:r})).cwd)}catch(e){_.add(g({type:`error`,title:`Clone failed`,description:Gt(e)}))}finally{Ht(!1)}}}function Ln(e){let t=re(m,e);y(null),h(t),j(e=>e+1)}function Rn(e){let t=u(e);y(null),h(t),j(e=>e+1)}function zn(){let e=o(m);e!==null&&(y(null),h(e),j(e=>e+1))}let Bn=oe(m)?Y?.parentPath??m.trim():pn?.fullPath??m.trim(),Vn=St({browseEntries:fn,browseQuery:m,canBrowseUp:G&&!q&&s(J),upIcon:(0,F.jsx)(pt,{className:M}),directoryIcon:(0,F.jsx)(Ge,{className:M}),symlinkIcon:(0,F.jsx)(mt,{className:M}),browseUp:zn,browseTo:Ln,browseToPath:Rn}),Hn=(0,A.useMemo)(()=>Vn.map(e=>e.value===`directories`?{...e,label:`Select where to clone`}:e),[Vn]),Un=(0,A.useMemo)(()=>I?.step===`confirm`?{title:I.repository?.nameWithOwner??I.repositoryInput,description:I.repository?.url??I.remoteUrl,icon:R(I.source,M)}:null,[I]),Wn=(0,A.useMemo)(()=>{if(I?.step!==`repository`||I.source===`url`||H!==`bitbucket`)return[];let e=W.data?.repositories??[];return e.length>0?[{value:`remote-repositories:${I.environmentId}:${H}`,label:U.length>0?`Matching repositories`:`Available repositories`,items:e.map(e=>({kind:`action`,value:zt(e),searchTerms:[e.nameWithOwner,Rt(e.nameWithOwner),e.url,e.sshUrl],title:e.nameWithOwner,description:e.url,icon:R(I.source,M),keepOpen:!0,run:async()=>{Q({flow:I,repositoryInput:e.nameWithOwner,repository:e,remoteUrl:Bt(I.source,e)})}}))}]:W.isFetching?[{value:`remote-repositories:${I.environmentId}:${H}:loading`,label:`Repositories`,items:[{kind:`action`,value:`remote-repositories:loading`,searchTerms:[`loading`,`repository`,`repo`],title:`Loading repositories`,description:`Reading available Bitbucket workspaces`,icon:R(I.source,M),disabled:!0,run:async()=>{}}]}]:W.error===null?[]:[{value:`remote-repositories:${I.environmentId}:${H}:error`,label:`Repositories`,items:[{kind:`action`,value:`remote-repositories:error`,searchTerms:[`error`,`repository`,`repo`],title:`Unable to load repositories`,description:Gt(W.error),icon:R(I.source,M),disabled:!0,run:async()=>{}}]}]},[I,Q,H,U,W.data?.repositories,W.error,W.isFetching]),Gn=I?.step===`repository`&&I.source===`bitbucket`?U.length===0?`No repositories found. Enter workspace/repository manually.`:`No matching repositories. Enter workspace/repository manually.`:null,Kn=Nn;I?.step===`repository`?Kn=Wn:I?.step===`confirm`?Kn=q?[]:Hn:G&&(Kn=q?[]:Vn);let qn=Lt(I)??Tt($t),Jn=$t===`submenu`||$t===`submenu-browse`,$=v?.startsWith(`browse:`)??!1,Yn=G&&!q,Xn=Yn&&!un&&m.trim().length>0&&!$&&(oe(m)?!Y:pn===null),Zn=be(navigator.platform),Qn=Zn?`⌘`:`Ctrl`,$n=I?.step===`confirm`,er=$n?Xn?`Create & Clone`:`Clone`:Xn?`Create & Add`:`Add`,tr=$?`${Qn} Enter`:`Enter`,nr=I?I.source===`url`?`Continue`:`Lookup`:null,rr=Dt||Nt,ir=I?.step===`repository`&&m.trim().length>0&&!rr,ar=At(navigator.platform),or=G&&V!==null&&z!==null&&V===z&&typeof window<`u`&&window.desktopBridge!==void 0,sr=(0,A.useMemo)(()=>{if(!or)return;let e=m.trim();if(e.length===0)return;let t=c(oe(m)?Y?.parentPath??e:J||e,K);return t.length>0?t:void 0},[J,Y?.parentPath,or,K,m]);function cr(e){return Zn?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function lr(e){if(I?.step===`repository`&&e.key===`Enter`){e.preventDefault();let t=W.data?.repositories.find(e=>zt(e)===v);if(t){Q({flow:I,repositoryInput:t.nameWithOwner,repository:t,remoteUrl:Bt(I.source,t)});return}In();return}if(Yn&&e.key===`Enter`&&(!$||cr(e))){e.preventDefault(),$n?In(Bn):Pn(Bn);return}e.key===`Backspace`&&m===``&&Jn&&(e.preventDefault(),xn())}function ur(e){if(!e.disabled){if(e.kind===`submenu`){bn(e);return}e.keepOpen||t(!1),e.run().catch(e=>{_.add(g({type:`error`,title:`Unable to run command`,description:e instanceof Error?e.message:`An unexpected error occurred.`}))})}}let dr=(0,A.useCallback)(async()=>{if(!or||yt)return;let e=ce();if(!e)return;bt(!0);let t=null;try{t=await e.dialogs.pickFolder(sr?{initialPath:sr}:void 0)}catch{bt(!1);return}bt(!1),t&&await Pn(t)},[or,sr,Pn,yt]);return(0,F.jsx)(Ie,{"aria-label":`Command palette`,className:`project-glass-surface overflow-hidden p-0`,"data-testid":`command-palette`,surface:`glass`,finalFocus:()=>(Se?.current?.focusAtEnd(),!1),onBackdropPointerDown:()=>{t(!1)},children:(0,F.jsxs)(Je,{"aria-label":`Command palette`,autoHighlight:G||Zt?!1:`always`,mode:`none`,onItemHighlighted:e=>{y(typeof e==`string`?e:null)},onValueChange:Sn,value:m,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(ze,{className:I?.step===`repository`?`pe-32`:G?Xn?`pe-36`:`pe-16`:void 0,placeholder:qn,wrapperClassName:Jn?`[&_[data-slot=autocomplete-start-addon]]:pointer-events-auto`:void 0,...Jn?{startAddon:(0,F.jsx)(`button`,{type:`button`,className:`flex cursor-pointer items-center`,"aria-label":`Back`,onClick:xn,children:(0,F.jsx)(Ze,{})})}:G&&!Jn?{startAddon:(0,F.jsx)(O,{})}:{},onKeyDown:lr}),I?.step===`repository`?(0,F.jsxs)(Ee,{variant:`outline`,size:`xs`,tabIndex:-1,className:`absolute inset-e-2.5 top-1/2 gap-1.5 pe-1 ps-2 -translate-y-1/2`,"aria-label":`${nr??`Continue`} (Enter)`,disabled:!ir,onMouseDown:e=>{e.preventDefault()},onClick:()=>{In()},title:`${nr??`Continue`} (Enter)`,children:[(0,F.jsx)(`span`,{children:rr?`Working`:nr}),(0,F.jsx)(E,{className:`pointer-events-none -me-0.5 items-center gap-1`,children:(0,F.jsx)(D,{children:`Enter`})})]}):G?(0,F.jsxs)(Ee,{variant:`outline`,size:`xs`,tabIndex:-1,className:p(`absolute inset-e-2.5 top-1/2 pe-1 ps-2 -translate-y-1/2`,$?`gap-1`:`gap-1.5`),"aria-label":`${er} (${tr})`,disabled:q||$n&&rr,onMouseDown:e=>{e.preventDefault()},onClick:()=>{q||($n?In(Bn):Pn(Bn))},title:`${er} (${tr})`,children:[(0,F.jsx)(`span`,{children:$n&&rr?`Cloning`:er}),(0,F.jsx)(E,{className:`pointer-events-none -me-0.5 items-center gap-1`,children:(0,F.jsx)(D,{children:$?`${Qn} Enter`:`Enter`})})]}):null]}),(0,F.jsxs)(Re,{className:`max-h-[min(28rem,70vh)] bg-transparent`,children:[Un?(0,F.jsxs)(`div`,{className:`p-2 pb-0`,children:[(0,F.jsx)(`div`,{className:`px-2 py-1.5 font-medium text-muted-foreground text-xs`,children:`Repository`}),(0,F.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1.5`,children:[Un.icon,(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsx)(`span`,{className:`truncate text-foreground text-sm`,children:Un.title}),(0,F.jsx)(`span`,{className:`truncate text-muted-foreground/70 text-xs`,children:Un.description})]})]})]}):null,(0,F.jsx)(Et,{groups:Kn,highlightedItemValue:v,isActionsOnly:Le,keybindings:Ue,onExecuteItem:ur,...I?.step===`repository`?{emptyStateMessage:I.source===`url`?`Enter a Git clone URL and press Enter to continue.`:Gn??`Enter a repository path and press Enter to look it up.`}:I?.step===`confirm`?{emptyStateMessage:`Choose a destination path and press Enter to clone.`}:q?{emptyStateMessage:`Relative paths require an active project.`}:Xn?{emptyStateMessage:`Press Enter to create this folder and add it as a project.`}:{}})]}),(0,F.jsxs)(We,{className:`gap-3 max-sm:flex-col max-sm:items-start`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:(0,F.jsx)(Ye,{})}),(0,F.jsx)(D,{children:(0,F.jsx)(Xe,{})}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Navigate`})]}),I?.step===`repository`?(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Enter`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:nr??`Continue`})]}):!Yn||$?(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Enter`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Select`})]}):null,Jn?(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Backspace`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Back`})]}):null,(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Esc`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Close`})]})]}),or?(0,F.jsx)(Ee,{variant:`ghost`,size:`xs`,className:`h-auto px-2 text-xs text-muted-foreground/80 hover:bg-transparent hover:text-foreground`,disabled:yt,onClick:()=>{dr()},children:`Open in ${ar}`}):null]})]},`${qe.length}-${dt}-${G}-${I?.step??`none`}`)})}export{z as CommandPaletteDialog};
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{t as n}from"./compiler-runtime-BNrXlsa1.js";import{ma as r,no as i,ro as a}from"./react-CjD7iThp.js";import{B as o,F as s,G as c,H as l,I as u,K as d,Kt as f,L as ee,O as te,Ot as ne,P as re,R as ie,U as ae,V as oe,W as se,Yt as ce,_t as le,a as ue,gt as de,hn as fe,nn as pe,p as me,qt as he,sn as ge,tn as _e,z as ve}from"./projectAtoms-DXXpuERK.js";import{A as ye,Cr as be,M as xe,O as Se,Or as Ce,Pi as we,Sr as p,Tr as Te,Zr as m,br as Ee,k as De,la as Oe,pa as ke,wr as h}from"./composerDraftStore-DpPEQ6BN.js";import{t as Ae}from"./useNavigate-_4hWGSey.js";import{a as g,c as je,i as _}from"./toast-DmA_ziPT.js";import{i as Me,r as Ne}from"./primary-CSkhdakK.js";import{An as Pe,Cr as Fe,Dn as v,En as Ie,Mn as Le,On as y,Pn as b,Sn as x,Vn as S,Xt as Re,Yn as ze,an as Be,er as Ve,fr as He,jn as C,kn as Ue,ln as w,nn as T,or as We,sn as Ge,tn as Ke,wn as qe,xn as Je}from"./providerIconUtils-D-DFhem2.js";import{C as Ye,n as E,t as D,w as Xe}from"./kbd-QYSL97CK.js";import{n as Ze,t as Qe}from"./commandPaletteStore-KebG835b.js";import{c as O,n as $e,r as et}from"./ThreadStatusIndicators-Cw_jLVQf.js";import{i as tt,n as nt,r as rt}from"./chatThreadActions-TtDsiwDC.js";import{c as it,o as at,u as ot}from"./BranchToolbar.logic-CZIFSvhd.js";import{t as st}from"./shallow-Dmd-gez1.js";import{a as ct,s as k}from"./storeSelectors-DhJRpdiw.js";import{t as lt}from"./settingsDialogStore-SG-W1q0A.js";import{t as ut}from"./useHandleNewThread-ypSbzG0P.js";import{g as dt}from"./keybindings-CUTRYI_A.js";import{t as ft}from"./ProjectFavicon-D2imiJ8M.js";var pt=m(`corner-left-up`,[[`path`,{d:`M14 9 9 4 4 9`,key:`1af5af`}],[`path`,{d:`M20 20h-7a4 4 0 0 1-4-4V4`,key:`1blwi3`}]]),mt=m(`folder-symlink`,[[`path`,{d:`M2 9.35V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7`,key:`y8kt7d`}],[`path`,{d:`m8 16 3-3-3-3`,key:`rlqrt1`}]]),A=e(t(),1),j=n(),M=`size-4 text-muted-foreground/80`,N=`size-4`;function ht(e){return e.isAlias?`browse:alias:${e.name}:${e.fullPath}`:`browse:${e.fullPath}`}function gt(e){let t=e.browseFilterQuery.toLowerCase(),n=e.browseFilterQuery.startsWith(`.`),r=e.browseEntries.filter(e=>e.name.toLowerCase().startsWith(t)&&(n||!e.name.startsWith(`.`))),i=null,a=e.highlightedItemValue;a&&a.startsWith(`browse:`)&&(i=r.find(e=>ht(e)===a)??null);let o=e.browseFilterQuery.length>0?r.find(t=>t.name===e.browseFilterQuery)??null:null;return{filteredEntries:r,highlightedEntry:i,exactEntry:o}}function P(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function _t(e){return e.projects.map(t=>({kind:`action`,value:`${e.valuePrefix}:${t.environmentId}:${t.id}`,searchTerms:[t.name,t.cwd],title:t.name,description:t.cwd,icon:e.icon(t),run:async()=>{await e.runProject(t)}}))}function vt(e){let t=k(e.threads.filter(e=>e.archivedAt===null),e.sortOrder);return(e.limit===void 0?t:t.slice(0,e.limit)).map(t=>{let n=e.projectTitleById.get(t.projectId),r=[];n&&r.push(n),t.branch&&r.push(`#${t.branch}`),t.id===e.activeThreadId&&r.push(`Current thread`);let i=e.renderLeadingContent?.(t),a=e.renderTrailingContent?.(t);return Object.assign({kind:`action`,value:`thread:${t.id}`,searchTerms:[t.title,n??``,t.branch??``],title:t.title,description:r.join(` · `),timestamp:S(t.latestUserMessageAt??t.updatedAt??t.createdAt),icon:e.icon},i?{titleLeadingContent:i}:{},a?{titleTrailingContent:a}:{},{run:async()=>{await e.runThread(t)}})})}function yt(e,t){let n=P(e);return n.length===0||!n.includes(t)?-1/0:n===t?3:n.startsWith(t)?2:1}function bt(e,t){let n=e.searchTerms.filter(e=>e.length>0);if(n.length===0)return 0;for(let[e,r]of n.entries()){let n=yt(r,t);if(n!==-1/0)return 1e3-e*100+n}return 0}function xt(e){let t=e.query.startsWith(`>`),n=P(t?e.query.slice(1):e.query);if(n.length===0)return t?e.activeGroups.filter(e=>e.value===`actions`):[...e.activeGroups];let r=[...e.activeGroups];t?r=r.filter(e=>e.value===`actions`):e.isInSubmenu||(r=r.filter(e=>e.value!==`recent-threads`));let i=[...r];return!e.isInSubmenu&&!t&&(e.projectSearchItems.length>0&&i.push({value:`projects-search`,label:`Projects`,items:e.projectSearchItems}),e.threadSearchItems.length>0&&i.push({value:`threads-search`,label:`Threads`,items:e.threadSearchItems})),i.flatMap(e=>{let t=e.items.map((e,t)=>P(e.searchTerms.join(` `)).includes(n)?{item:e,index:t,rank:bt(e,n)}:null).filter(e=>e!==null).toSorted((e,t)=>t.rank-e.rank||e.index-t.index).map(e=>e.item);return t.length===0?[]:[{value:e.value,label:e.label,items:t}]})}function St(e){let t=[];e.canBrowseUp&&t.push({kind:`action`,value:`browse:up`,searchTerms:[e.browseQuery,`..`],title:`..`,icon:e.upIcon,keepOpen:!0,run:async()=>{e.browseUp()}});for(let n of e.browseEntries)t.push({kind:`action`,value:ht(n),searchTerms:[e.browseQuery,n.fullPath,n.name],title:n.name,icon:n.isSymlink?e.symlinkIcon:e.directoryIcon,keepOpen:!0,run:async()=>{n.isAlias?e.browseToPath(n.fullPath):e.browseTo(n.name)}});return[{value:`directories`,label:`Directories`,items:t}]}function Ct(e){return e.currentView?e.isBrowsing?`submenu-browse`:`submenu`:e.isBrowsing?`root-browse`:`root`}function wt(e){let t=[];return e.actionItems.length>0&&t.push({value:`actions`,label:`Actions`,items:e.actionItems}),e.recentThreadItems.length>0&&t.push({value:`recent-threads`,label:`Recent Threads`,items:e.recentThreadItems}),t}function Tt(e){switch(e){case`root`:return`Search commands, projects, and threads...`;case`root-browse`:return`Enter project path (e.g. ~/projects/my-app)`;case`submenu`:return`Search...`;case`submenu-browse`:return`Enter path (e.g. ~/projects/my-app)`}}var F=we();function Et(e){let t=(0,j.c)(13);if(e.groups.length===0){let n=e.emptyStateMessage??(e.isActionsOnly?`No matching actions.`:`No matching commands, projects, or threads.`),r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:n}),t[0]=n,t[1]=r),r}let n;if(t[2]!==e.groups||t[3]!==e.highlightedItemValue||t[4]!==e.keybindings||t[5]!==e.onExecuteItem){let r;t[7]!==e.highlightedItemValue||t[8]!==e.keybindings||t[9]!==e.onExecuteItem?(r=t=>(0,F.jsxs)(v,{items:t.items,children:[(0,F.jsx)(y,{children:t.label}),(0,F.jsx)(x,{children:t=>t.disabled?(0,F.jsx)(I,{item:t},t.value):(0,F.jsx)(L,{item:t,keybindings:e.keybindings,isActive:e.highlightedItemValue===t.value,onExecuteItem:e.onExecuteItem},t.value)})]},t.value),t[7]=e.highlightedItemValue,t[8]=e.keybindings,t[9]=e.onExecuteItem,t[10]=r):r=t[10],n=e.groups.map(r),t[2]=e.groups,t[3]=e.highlightedItemValue,t[4]=e.keybindings,t[5]=e.onExecuteItem,t[6]=n}else n=t[6];let r;return t[11]===n?r=t[12]:(r=(0,F.jsx)(C,{children:n}),t[11]=n,t[12]=r),r}function I(e){let t=(0,j.c)(8),n;t[0]!==e.item.description||t[1]!==e.item.title||t[2]!==e.item.titleLeadingContent?(n=e.item.description?(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),(0,F.jsx)(`span`,{className:`truncate text-muted-foreground/70 text-xs`,children:e.item.description})]}):(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),t[0]=e.item.description,t[1]=e.item.title,t[2]=e.item.titleLeadingContent,t[3]=n):n=t[3];let r;return t[4]!==e.item.icon||t[5]!==e.item.titleTrailingContent||t[6]!==n?(r=(0,F.jsxs)(`div`,{className:`flex min-h-8 select-none items-center gap-2 rounded-sm px-2 py-1.5 text-base opacity-64 sm:min-h-7 sm:text-sm`,children:[e.item.icon,n,e.item.titleTrailingContent]}),t[4]=e.item.icon,t[5]=e.item.titleTrailingContent,t[6]=n,t[7]=r):r=t[7],r}function L(e){let t=(0,j.c)(27),n;t[0]!==e.item.shortcutCommand||t[1]!==e.keybindings?(n=e.item.shortcutCommand?dt(e.keybindings,e.item.shortcutCommand):null,t[0]=e.item.shortcutCommand,t[1]=e.keybindings,t[2]=n):n=t[2];let r=n,i=e.item.value,a=e.isActive&&`bg-accent! text-accent-foreground!`,o;t[3]===a?o=t[4]:(o=p(`cursor-pointer gap-2 hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit data-selected:bg-transparent data-selected:text-inherit [&[data-highlighted][data-selected]]:bg-transparent [&[data-highlighted][data-selected]]:text-inherit`,a),t[3]=a,t[4]=o);let s;t[5]===e?s=t[6]:(s=()=>{e.onExecuteItem(e.item)},t[5]=e,t[6]=s);let c;t[7]!==e.item.description||t[8]!==e.item.title||t[9]!==e.item.titleLeadingContent?(c=e.item.description?(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),(0,F.jsx)(`span`,{className:`truncate text-muted-foreground/70 text-xs`,children:e.item.description})]}):(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-foreground`,children:[e.item.titleLeadingContent,(0,F.jsx)(`span`,{className:`truncate`,children:e.item.title})]}),t[7]=e.item.description,t[8]=e.item.title,t[9]=e.item.titleLeadingContent,t[10]=c):c=t[10];let l;t[11]===e.item.timestamp?l=t[12]:(l=e.item.timestamp?(0,F.jsx)(`span`,{className:`min-w-12 shrink-0 text-right text-[10px] tabular-nums text-muted-foreground/70`,children:e.item.timestamp}):null,t[11]=e.item.timestamp,t[12]=l);let u;t[13]===r?u=t[14]:(u=r?(0,F.jsx)(b,{children:r}):null,t[13]=r,t[14]=u);let d;t[15]===e.item.kind?d=t[16]:(d=e.item.kind===`submenu`?(0,F.jsx)(Fe,{className:`ml-auto size-4 shrink-0 text-muted-foreground/50`}):null,t[15]=e.item.kind,t[16]=d);let f;return t[17]!==e.item.icon||t[18]!==e.item.titleTrailingContent||t[19]!==e.item.value||t[20]!==o||t[21]!==s||t[22]!==c||t[23]!==l||t[24]!==u||t[25]!==d?(f=(0,F.jsxs)(Pe,{value:i,className:o,onMouseDown:Dt,onClick:s,children:[e.item.icon,c,e.item.titleTrailingContent,l,u,d]}),t[17]=e.item.icon,t[18]=e.item.titleTrailingContent,t[19]=e.item.value,t[20]=o,t[21]=s,t[22]=c,t[23]=l,t[24]=u,t[25]=d,t[26]=f):f=t[26],f}function Dt(e){e.preventDefault()}var Ot=[],kt=3e4;function At(e){return be(e)?`Finder`:h(e)?`Explorer`:`Files`}function jt(e){return e===`windows`?`Win32`:e===`darwin`?`MacIntel`:e===`linux`?`Linux`:typeof navigator>`u`?``:navigator.platform}var Mt=[`url`,`github`,`gitlab`,`forgejo`,`bitbucket`,`azure-devops`],Nt=[`github`,`gitlab`,`forgejo`,`bitbucket`,`azure-devops`];function Pt(e){switch(e){case`github`:return`GitHub`;case`gitlab`:return`GitLab`;case`forgejo`:return`Forgejo`;case`bitbucket`:return`Bitbucket`;case`azure-devops`:return`Azure DevOps`;case`url`:return`Git URL`}}function Ft(e){switch(e){case`github`:return`owner/repo`;case`gitlab`:return`group/project`;case`forgejo`:return`owner/repo`;case`bitbucket`:return`workspace/repository`;case`azure-devops`:return`project/repository`;case`url`:return`URL`}}function It(e){return e===`url`?null:e}function R(e,t){switch(e){case`github`:return(0,F.jsx)(Ge,{className:t});case`gitlab`:return(0,F.jsx)(w,{className:t});case`forgejo`:return(0,F.jsx)(Be,{className:t});case`bitbucket`:return(0,F.jsx)(T,{className:t});case`azure-devops`:return(0,F.jsx)(Ke,{className:t});case`url`:return(0,F.jsx)(tt,{className:t})}}function Lt(e){return!e||e.step===`confirm`?null:e.source===`url`?`Enter Git clone URL`:`Enter ${Pt(e.source)} repository (${Ft(e.source)})`}function Rt(e){return e.split(`/`).at(-1)?.trim()??e}function zt(e){return`remote-repository:${e.provider}:${encodeURIComponent(e.nameWithOwner)}`}function Bt(e,t){return e===`bitbucket`?t.url:t.sshUrl}function Vt(e){return!e.includes(`/`)&&!e.includes(`:`)}function Ht(e){return e===`url`?null:e}function Ut(e){return Nt.toSorted((t,n)=>{let r=e[t].ready;return r===e[n].ready?Pt(t).localeCompare(Pt(n)):r?-1:1})}function Wt(e){let t={ready:!1,hint:`Provider status unavailable. Open Settings -> Source Control and rescan.`},n={url:{ready:!0,hint:null},github:t,gitlab:t,forgejo:t,bitbucket:t,"azure-devops":t};if(!e)return n;let i=new Map(e.sourceControlProviders.map(e=>[e.kind,e])),a={...n};for(let e of Mt){let n=Ht(e);if(!n)continue;let o=i.get(n);if(!o){a[e]=t;continue}if(o.status!==`available`){a[e]={ready:!1,hint:o.installHint};continue}if(o.auth.status===`unauthenticated`){a[e]={ready:!1,hint:r(o.auth.detail)??`${o.label} is not authenticated. Open Settings -> Source Control for setup guidance.`};continue}a[e]={ready:!0,hint:null}}return a}function Gt(e){return e instanceof Error&&e.message.trim().length>0?e.message:`An error occurred.`}function z(){let e=(0,j.c)(5),t=Qe(qt),n=Qe(Kt),r,i;e[0]===n?(r=e[1],i=e[2]):(r=()=>()=>{n(!1)},i=[n],e[0]=n,e[1]=r,e[2]=i),(0,A.useEffect)(r,i);let a;return e[3]===t?a=e[4]:(a=t?(0,F.jsx)(B,{}):null,e[3]=t,e[4]=a),a}function Kt(e){return e.setOpen}function qt(e){return e.open}function B(){let e=Ae(),t=Qe(e=>e.setOpen),n=Qe(e=>e.openIntent),r=Qe(e=>e.clearOpenIntent),we=Re(),[m,h]=(0,A.useState)(``),Pe=(0,A.useDeferredValue)(m),Fe=Pe.startsWith(`>`),[v,y]=(0,A.useState)(null),b=ge(),{activeDraftThread:x,activeThread:S,defaultProjectRef:Be,handleNewThread:C}=ut(),w=ne(st(de)),T=ne(st(le)),Ge=fe(),[Ke,tt]=(0,A.useState)([]),k=Ke.at(-1)??null,[dt,j]=(0,A.useState)(0),[ht,P]=(0,A.useState)(null),[yt,bt]=(0,A.useState)(!1),[I,L]=(0,A.useState)(null),[Dt,Mt]=(0,A.useState)(!1),[Nt,Ht]=(0,A.useState)(!1),z=Me(),Kt=Ne()?.label??null,qt=f(e=>e.byId),B=he(e=>e.byId),Jt=(0,A.useMemo)(()=>{let e=[],t=new Set;z&&(t.add(z),e.push({environmentId:z,label:at({isPrimary:!0,environmentId:z,runtimeLabel:Kt}),isPrimary:!0}));for(let n of Object.values(qt)){if(t.has(n.environmentId))continue;let r=B[n.environmentId];e.push({environmentId:n.environmentId,label:at({isPrimary:!1,environmentId:n.environmentId,runtimeLabel:r?.descriptor?.label??null,savedLabel:n.label}),isPrimary:!1})}return e.sort((e,t)=>e.isPrimary===t.isPrimary?e.label.localeCompare(t.label):e.isPrimary?-1:1),e},[z,Kt,qt,B]),Yt=Jt[0]?.environmentId??null,V=ht??Yt,Xt=(0,A.useMemo)(()=>jt(V&&z&&V===z?Ne()?.platform.os??null:V?B[V]?.descriptor?.platform.os??B[V]?.serverConfig?.environment.platform.os??null:null),[V,z,B]),Zt=I!==null,Qt=I?.step===`repository`,H=Qt&&I?It(I.source):null,U=Qt?Pe.trim():``,W=ze({environmentId:I?.step===`repository`?I.environmentId:null,provider:H,query:U,limit:25,enabled:I?.step===`repository`&&I.source!==`url`&&H===`bitbucket`}),G=!Qt&&ae(m,Xt),$t=Ct({currentView:k,isBrowsing:G}),en=(0,A.useCallback)(e=>{let t=(e&&z&&e===z?b:e?B[e]?.serverConfig?.settings:null)?.addProjectBaseDirectory?.trim()??``;return t.length===0?`~/`:u(t)},[z,B,b]),tn=(0,A.useMemo)(()=>new Map(w.map(e=>[e.id,e.cwd])),[w]),nn=(0,A.useMemo)(()=>new Map(w.map(e=>[e.id,e.name])),[w]),rn=S?.id,an=S?.environmentId??x?.environmentId??null,on=S?.projectId??x?.projectId??null,sn=on?tn.get(on)??null:null,K=V&&an===V?sn:null,q=d(m.trim())&&K===null,J=G?ie(m):``,cn=G&&!oe(m)?ve(m):``,ln=it({environmentId:V,partialPath:J,cwd:K,staleTime:kt,enabled:G&&J.length>0&&V!==null&&!q}),Y=ln.data,un=ln.isPending,dn=Y?.entries??Ot,{filteredEntries:fn,exactEntry:pn}=(0,A.useMemo)(()=>gt({browseEntries:dn,browseFilterQuery:cn,highlightedItemValue:v}),[dn,cn,v]),mn=(0,A.useCallback)(e=>{ue({environmentId:V,partialPath:e,cwd:K,staleTime:kt})},[V,K]);(0,A.useEffect)(()=>{G&&s(m)&&mn(o(m))},[G,mn,m]);let hn=(0,A.useMemo)(()=>async t=>{Se.getState().setProjectExpanded(te(t,b),!0);let n=ct(T.filter(e=>e.environmentId===t.environmentId),t.id,b.sidebarThreadSortOrder);if(n){await e({to:`/$environmentId/$threadId`,params:je(a(n.environmentId,n.id))});return}await C(i(t.environmentId,t.id),{envMode:b.defaultThreadEnvMode})},[C,e,b,T]),gn=(0,A.useMemo)(()=>_t({projects:w,valuePrefix:`project`,icon:e=>(0,F.jsx)(ft,{environmentId:e.environmentId,cwd:e.cwd,projectId:e.id,customAvatarContentHash:e.customAvatarContentHash??null,className:M}),runProject:hn}),[hn,w]),_n=(0,A.useMemo)(()=>_t({projects:w,valuePrefix:`new-thread-in`,icon:e=>(0,F.jsx)(ft,{environmentId:e.environmentId,cwd:e.cwd,projectId:e.id,customAvatarContentHash:e.customAvatarContentHash??null,className:M}),runProject:async e=>{await rt({activeDraftThread:x,activeThread:S,defaultProjectRef:Be,defaultThreadEnvMode:b.defaultThreadEnvMode,handleNewThread:C},i(e.environmentId,e.id))}}),[x,S,Be,C,w,b.defaultThreadEnvMode]),vn=(0,A.useMemo)(()=>vt({threads:T,...rn?{activeThreadId:rn}:{},projectTitleById:nn,sortOrder:b.sidebarThreadSortOrder,icon:(0,F.jsx)(We,{className:M}),renderLeadingContent:e=>(0,F.jsx)($e,{thread:e}),renderTrailingContent:e=>(0,F.jsx)(et,{thread:e}),runThread:async t=>{await e({to:`/$environmentId/$threadId`,params:je(a(t.environmentId,t.id))})}}),[rn,e,nn,b.sidebarThreadSortOrder,T]),yn=vn.slice(0,12);function X(e){tt(t=>[...t,{addonIcon:e.addonIcon,groups:e.groups,...e.initialQuery?{initialQuery:e.initialQuery}:{}}]),y(null),h(e.initialQuery??``)}function bn(e){X({addonIcon:e.addonIcon,groups:e.groups,...e.initialQuery?{initialQuery:e.initialQuery}:{}})}function xn(){L(null),Ke.length<=1&&P(null),tt(e=>e.slice(0,-1)),y(null),h(``)}function Sn(e){y(null),h(e),e===``&&k?.initialQuery&&xn()}let Cn=(0,A.useCallback)(e=>{P(e),L(null),X({addonIcon:(0,F.jsx)(O,{className:N}),groups:[],initialQuery:en(e)})},[en]),wn=(0,A.useCallback)((e,t)=>{P(e),L({step:`repository`,environmentId:e,source:t}),X({addonIcon:R(t,N),groups:[],initialQuery:``})},[]),Tn=lt(e=>e.openSettings),En=(0,A.useCallback)(()=>{t(!1),Tn(`source-control`)},[Tn,t]),Dn=(0,A.useCallback)((e,t)=>{let n=[{kind:`action`,value:`action:add-project:${e}:local`,searchTerms:[`local`,`folder`,`directory`,`browse`],title:`Local folder`,description:`Browse a folder on disk`,icon:(0,F.jsx)(O,{className:M}),keepOpen:!0,run:async()=>{Cn(e)}}],r=[`url`,...Ut(t)];for(let i of r){let r=Pt(i),a=i===`url`?`Git URL`:`${r} repository`,o=i===`url`?`Clone from a remote URL`:`Clone ${r} ${Ft(i)}`,s=t[i],c=s.hint,l=s.ready?void 0:(0,F.jsx)(`span`,{className:`ml-auto`,children:(0,F.jsxs)(De,{children:[(0,F.jsx)(xe,{render:(0,F.jsx)(Ee,{variant:`outline`,size:`xs`,className:`h-5 rounded-sm px-1.5 text-[10px] text-warning-foreground`,onClick:()=>{En()},children:`Setup Required`})}),(0,F.jsx)(ye,{align:`end`,side:`left`,children:c??`Open Settings -> Source Control to configure this provider.`})]})});if(!s.ready){n.push({kind:`action`,value:`action:add-project:${e}:${i}:not-ready`,searchTerms:[`clone`,`remote`,`repository`,`repo`,`git`,r,`setup required`],title:a,description:o,disabled:!0,icon:R(i,M),...l?{titleTrailingContent:l}:{},run:async()=>{}});continue}n.push({kind:`action`,value:`action:add-project:${e}:${i}`,searchTerms:[`clone`,`remote`,`repository`,`repo`,`git`,r],title:a,description:o,icon:R(i,M),...l?{titleTrailingContent:l}:{},keepOpen:!0,run:async()=>{wn(e,i)}})}return[{value:`sources:${e}`,label:`Sources`,items:n}]},[En,Cn,wn]),On=(0,A.useCallback)(e=>{P(e),L(null);let t={environmentId:e},n=_e(t).data;X({addonIcon:(0,F.jsx)(O,{className:N}),groups:Dn(e,Wt(n))}),pe(t).then(t=>{tt(n=>n.at(-1)?.groups[0]?.value===`sources:${e}`?[...n.slice(0,-1),{addonIcon:(0,F.jsx)(O,{className:N}),groups:Dn(e,Wt(t))}]:n)})},[Dn]),kn=Jt.map(e=>({kind:`action`,value:`action:add-project:environment:${e.environmentId}`,searchTerms:[e.label,e.environmentId,e.isPrimary?`this device`:``],title:e.label,description:e.isPrimary?`This device`:e.environmentId,icon:(0,F.jsx)(O,{className:M}),keepOpen:!0,run:async()=>{On(e.environmentId)}})),An=(0,A.useMemo)(()=>[{value:`environments`,label:`Environments`,items:kn}],[kn]),jn=(0,A.useCallback)(()=>{if(Jt.length>1){X({addonIcon:(0,F.jsx)(O,{className:N}),groups:An});return}let e=Yt;if(!e){_.add(g({type:`error`,title:`Unable to browse projects`,description:`No environment is available.`}));return}On(e)},[An,Jt.length,Yt,On]);(0,A.useLayoutEffect)(()=>{n?.kind===`add-project`&&(r(),jn())},[r,jn,n]);let Z=[];if(w.length>0){let e=on?nn.get(on)??null:null;e&&Z.push({kind:`action`,value:`action:new-thread`,searchTerms:[`new thread`,`chat`,`create`,`draft`],title:(0,F.jsxs)(F.Fragment,{children:[`New thread in `,(0,F.jsx)(`span`,{className:`font-semibold`,children:e})]}),icon:(0,F.jsx)(ot,{className:M}),shortcutCommand:`chat.new`,run:async()=>{await nt({activeDraftThread:x,activeThread:S,defaultProjectRef:Be,defaultThreadEnvMode:b.defaultThreadEnvMode,handleNewThread:C})}}),Z.push({kind:`submenu`,value:`action:new-thread-in`,searchTerms:[`new thread`,`project`,`pick`,`choose`,`select`],title:`New thread in...`,icon:(0,F.jsx)(ot,{className:M}),addonIcon:(0,F.jsx)(ot,{className:N}),groups:[{value:`projects`,label:`Projects`,items:_n}]})}Z.push({kind:`action`,value:`action:add-project`,searchTerms:[`add project`,`folder`,`directory`,`browse`,`clone`,`remote`,`repository`,`repo`,`git`,`github`,`gitlab`,`forgejo`,`codeberg`,`bitbucket`,`azure`,`devops`,`url`,`environment`],title:`Add project`,icon:(0,F.jsx)(O,{className:M}),keepOpen:!0,run:async()=>{jn()}}),Z.push({kind:`action`,value:`action:settings`,searchTerms:[`settings`,`preferences`,`configuration`,`keybindings`],title:`Open settings`,icon:(0,F.jsx)(Ve,{className:M}),run:async()=>{t(!1),Tn()}});let Mn=wt({actionItems:Z,recentThreadItems:yn}),Nn=xt({activeGroups:k?k.groups:Mn,query:Pe,isInSubmenu:k!==null,projectSearchItems:gn,threadSearchItems:vn}),Pn=(0,A.useCallback)(async n=>{if(!V)return;let r=me(V);if(!r)return;if(se(n.trim(),Xt)){_.add(g({type:`error`,title:`Failed to add project`,description:`Windows-style paths are only supported on Windows.`}));return}if(d(n.trim())&&!K){_.add(g({type:`error`,title:`Failed to add project`,description:`Relative paths require an active project.`}));return}let o=c(n,K);if(o.length===0)return;let s=ee(w.filter(e=>e.environmentId===V),o);if(s){Se.getState().setProjectExpanded(te(s,b),!0);let n=ct(T.filter(e=>e.environmentId===s.environmentId),s.id,b.sidebarThreadSortOrder);n?await e({to:`/$environmentId/$threadId`,params:je(a(n.environmentId,n.id))}):await C(i(s.environmentId,s.id),{envMode:b.defaultThreadEnvMode}).catch(()=>void 0),t(!1);return}try{let e=Ce();await r.orchestration.dispatchCommand({type:`project.create`,commandId:Te(),projectId:e,title:l(o),workspaceRoot:o,projectMetadataDir:`.ryco`,createWorkspaceRootIfMissing:!0,defaultModelSelection:{instanceId:ke.make(`codex`),model:Oe},createdAt:new Date().toISOString()}),await C(i(V,e),{envMode:b.defaultThreadEnvMode}).catch(()=>void 0),t(!1)}catch(e){_.add(g({type:`error`,title:`Failed to add project`,description:e instanceof Error?e.message:`An error occurred.`}))}},[V,Xt,K,C,e,w,t,b,T]),Fn=(0,A.useCallback)(e=>en(e),[en]),Q=(0,A.useCallback)(e=>{let t=Fn(e.flow.environmentId);L({step:`confirm`,environmentId:e.flow.environmentId,source:e.flow.source,repositoryInput:e.repositoryInput,repository:e.repository,remoteUrl:e.remoteUrl}),y(null),h(t),j(e=>e+1)},[Fn]);async function In(e){if(!I)return;let t=me(I.environmentId);if(!t){_.add(g({type:`error`,title:`Unable to clone project`,description:`Environment API is not available.`}));return}if(I.step===`repository`){let e=m.trim();if(e.length===0||Dt)return;let n=It(I.source);if(!n){Q({flow:I,repositoryInput:e,repository:null,remoteUrl:e});return}let r=W.data?.repositories??[];if(Vt(e)&&U===e&&r.length===1){let e=r[0];Q({flow:I,repositoryInput:e.nameWithOwner,repository:e,remoteUrl:Bt(I.source,e)});return}Mt(!0);try{let r=await t.sourceControl.lookupRepository({provider:n,repository:e});Q({flow:I,repositoryInput:e,repository:r,remoteUrl:Bt(I.source,r)})}catch(e){_.add(g({type:`error`,title:`Repository lookup failed`,description:Gt(e)}))}finally{Mt(!1)}return}let n=(e??m).trim();if(n.length===0||Nt)return;if(se(n,Xt)){_.add(g({type:`error`,title:`Clone failed`,description:`Windows-style paths are only supported on Windows.`}));return}if(d(n)&&!K){_.add(g({type:`error`,title:`Clone failed`,description:`Relative paths require an active project.`}));return}let r=c(n,K);if(r.length!==0){Ht(!0);try{let e=It(I.source);await Pn((await t.sourceControl.cloneRepository({...e&&I.repository?{provider:e,repository:I.repository.nameWithOwner,remoteUrl:I.remoteUrl,...I.source===`bitbucket`?{protocol:`https`}:{}}:{remoteUrl:I.remoteUrl},destinationPath:r})).cwd)}catch(e){_.add(g({type:`error`,title:`Clone failed`,description:Gt(e)}))}finally{Ht(!1)}}}function Ln(e){let t=re(m,e);y(null),h(t),j(e=>e+1)}function Rn(e){let t=u(e);y(null),h(t),j(e=>e+1)}function zn(){let e=o(m);e!==null&&(y(null),h(e),j(e=>e+1))}let Bn=oe(m)?Y?.parentPath??m.trim():pn?.fullPath??m.trim(),Vn=St({browseEntries:fn,browseQuery:m,canBrowseUp:G&&!q&&s(J),upIcon:(0,F.jsx)(pt,{className:M}),directoryIcon:(0,F.jsx)(He,{className:M}),symlinkIcon:(0,F.jsx)(mt,{className:M}),browseUp:zn,browseTo:Ln,browseToPath:Rn}),Hn=(0,A.useMemo)(()=>Vn.map(e=>e.value===`directories`?{...e,label:`Select where to clone`}:e),[Vn]),Un=(0,A.useMemo)(()=>I?.step===`confirm`?{title:I.repository?.nameWithOwner??I.repositoryInput,description:I.repository?.url??I.remoteUrl,icon:R(I.source,M)}:null,[I]),Wn=(0,A.useMemo)(()=>{if(I?.step!==`repository`||I.source===`url`||H!==`bitbucket`)return[];let e=W.data?.repositories??[];return e.length>0?[{value:`remote-repositories:${I.environmentId}:${H}`,label:U.length>0?`Matching repositories`:`Available repositories`,items:e.map(e=>({kind:`action`,value:zt(e),searchTerms:[e.nameWithOwner,Rt(e.nameWithOwner),e.url,e.sshUrl],title:e.nameWithOwner,description:e.url,icon:R(I.source,M),keepOpen:!0,run:async()=>{Q({flow:I,repositoryInput:e.nameWithOwner,repository:e,remoteUrl:Bt(I.source,e)})}}))}]:W.isFetching?[{value:`remote-repositories:${I.environmentId}:${H}:loading`,label:`Repositories`,items:[{kind:`action`,value:`remote-repositories:loading`,searchTerms:[`loading`,`repository`,`repo`],title:`Loading repositories`,description:`Reading available Bitbucket workspaces`,icon:R(I.source,M),disabled:!0,run:async()=>{}}]}]:W.error===null?[]:[{value:`remote-repositories:${I.environmentId}:${H}:error`,label:`Repositories`,items:[{kind:`action`,value:`remote-repositories:error`,searchTerms:[`error`,`repository`,`repo`],title:`Unable to load repositories`,description:Gt(W.error),icon:R(I.source,M),disabled:!0,run:async()=>{}}]}]},[I,Q,H,U,W.data?.repositories,W.error,W.isFetching]),Gn=I?.step===`repository`&&I.source===`bitbucket`?U.length===0?`No repositories found. Enter workspace/repository manually.`:`No matching repositories. Enter workspace/repository manually.`:null,Kn=Nn;I?.step===`repository`?Kn=Wn:I?.step===`confirm`?Kn=q?[]:Hn:G&&(Kn=q?[]:Vn);let qn=Lt(I)??Tt($t),Jn=$t===`submenu`||$t===`submenu-browse`,$=v?.startsWith(`browse:`)??!1,Yn=G&&!q,Xn=Yn&&!un&&m.trim().length>0&&!$&&(oe(m)?!Y:pn===null),Zn=be(navigator.platform),Qn=Zn?`⌘`:`Ctrl`,$n=I?.step===`confirm`,er=$n?Xn?`Create & Clone`:`Clone`:Xn?`Create & Add`:`Add`,tr=$?`${Qn} Enter`:`Enter`,nr=I?I.source===`url`?`Continue`:`Lookup`:null,rr=Dt||Nt,ir=I?.step===`repository`&&m.trim().length>0&&!rr,ar=At(navigator.platform),or=G&&V!==null&&z!==null&&V===z&&typeof window<`u`&&window.desktopBridge!==void 0,sr=(0,A.useMemo)(()=>{if(!or)return;let e=m.trim();if(e.length===0)return;let t=c(oe(m)?Y?.parentPath??e:J||e,K);return t.length>0?t:void 0},[J,Y?.parentPath,or,K,m]);function cr(e){return Zn?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function lr(e){if(I?.step===`repository`&&e.key===`Enter`){e.preventDefault();let t=W.data?.repositories.find(e=>zt(e)===v);if(t){Q({flow:I,repositoryInput:t.nameWithOwner,repository:t,remoteUrl:Bt(I.source,t)});return}In();return}if(Yn&&e.key===`Enter`&&(!$||cr(e))){e.preventDefault(),$n?In(Bn):Pn(Bn);return}e.key===`Backspace`&&m===``&&Jn&&(e.preventDefault(),xn())}function ur(e){if(!e.disabled){if(e.kind===`submenu`){bn(e);return}e.keepOpen||t(!1),e.run().catch(e=>{_.add(g({type:`error`,title:`Unable to run command`,description:e instanceof Error?e.message:`An unexpected error occurred.`}))})}}let dr=(0,A.useCallback)(async()=>{if(!or||yt)return;let e=ce();if(!e)return;bt(!0);let t=null;try{t=await e.dialogs.pickFolder(sr?{initialPath:sr}:void 0)}catch{bt(!1);return}bt(!1),t&&await Pn(t)},[or,sr,Pn,yt]);return(0,F.jsx)(qe,{"aria-label":`Command palette`,className:`project-glass-surface overflow-hidden p-0`,"data-testid":`command-palette`,surface:`glass`,finalFocus:()=>(we?.current?.focusAtEnd(),!1),onBackdropPointerDown:()=>{t(!1)},children:(0,F.jsxs)(Je,{"aria-label":`Command palette`,autoHighlight:G||Zt?!1:`always`,mode:`none`,onItemHighlighted:e=>{y(typeof e==`string`?e:null)},onValueChange:Sn,value:m,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(Ue,{className:I?.step===`repository`?`pe-32`:G?Xn?`pe-36`:`pe-16`:void 0,placeholder:qn,wrapperClassName:Jn?`[&_[data-slot=autocomplete-start-addon]]:pointer-events-auto`:void 0,...Jn?{startAddon:(0,F.jsx)(`button`,{type:`button`,className:`flex cursor-pointer items-center`,"aria-label":`Back`,onClick:xn,children:(0,F.jsx)(Ze,{})})}:G&&!Jn?{startAddon:(0,F.jsx)(O,{})}:{},onKeyDown:lr}),I?.step===`repository`?(0,F.jsxs)(Ee,{variant:`outline`,size:`xs`,tabIndex:-1,className:`absolute inset-e-2.5 top-1/2 gap-1.5 pe-1 ps-2 -translate-y-1/2`,"aria-label":`${nr??`Continue`} (Enter)`,disabled:!ir,onMouseDown:e=>{e.preventDefault()},onClick:()=>{In()},title:`${nr??`Continue`} (Enter)`,children:[(0,F.jsx)(`span`,{children:rr?`Working`:nr}),(0,F.jsx)(E,{className:`pointer-events-none -me-0.5 items-center gap-1`,children:(0,F.jsx)(D,{children:`Enter`})})]}):G?(0,F.jsxs)(Ee,{variant:`outline`,size:`xs`,tabIndex:-1,className:p(`absolute inset-e-2.5 top-1/2 pe-1 ps-2 -translate-y-1/2`,$?`gap-1`:`gap-1.5`),"aria-label":`${er} (${tr})`,disabled:q||$n&&rr,onMouseDown:e=>{e.preventDefault()},onClick:()=>{q||($n?In(Bn):Pn(Bn))},title:`${er} (${tr})`,children:[(0,F.jsx)(`span`,{children:$n&&rr?`Cloning`:er}),(0,F.jsx)(E,{className:`pointer-events-none -me-0.5 items-center gap-1`,children:(0,F.jsx)(D,{children:$?`${Qn} Enter`:`Enter`})})]}):null]}),(0,F.jsxs)(Le,{className:`max-h-[min(28rem,70vh)] bg-transparent`,children:[Un?(0,F.jsxs)(`div`,{className:`p-2 pb-0`,children:[(0,F.jsx)(`div`,{className:`px-2 py-1.5 font-medium text-muted-foreground text-xs`,children:`Repository`}),(0,F.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1.5`,children:[Un.icon,(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,F.jsx)(`span`,{className:`truncate text-foreground text-sm`,children:Un.title}),(0,F.jsx)(`span`,{className:`truncate text-muted-foreground/70 text-xs`,children:Un.description})]})]})]}):null,(0,F.jsx)(Et,{groups:Kn,highlightedItemValue:v,isActionsOnly:Fe,keybindings:Ge,onExecuteItem:ur,...I?.step===`repository`?{emptyStateMessage:I.source===`url`?`Enter a Git clone URL and press Enter to continue.`:Gn??`Enter a repository path and press Enter to look it up.`}:I?.step===`confirm`?{emptyStateMessage:`Choose a destination path and press Enter to clone.`}:q?{emptyStateMessage:`Relative paths require an active project.`}:Xn?{emptyStateMessage:`Press Enter to create this folder and add it as a project.`}:{}})]}),(0,F.jsxs)(Ie,{className:`gap-3 max-sm:flex-col max-sm:items-start`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:(0,F.jsx)(Ye,{})}),(0,F.jsx)(D,{children:(0,F.jsx)(Xe,{})}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Navigate`})]}),I?.step===`repository`?(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Enter`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:nr??`Continue`})]}):!Yn||$?(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Enter`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Select`})]}):null,Jn?(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Backspace`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Back`})]}):null,(0,F.jsxs)(E,{className:`items-center gap-1.5`,children:[(0,F.jsx)(D,{children:`Esc`}),(0,F.jsx)(`span`,{className:p(`text-muted-foreground/80`),children:`Close`})]})]}),or?(0,F.jsx)(Ee,{variant:`ghost`,size:`xs`,className:`h-auto px-2 text-xs text-muted-foreground/80 hover:bg-transparent hover:text-foreground`,disabled:yt,onClick:()=>{dr()},children:`Open in ${ar}`}):null]})]},`${Ke.length}-${dt}-${G}-${I?.step??`none`}`)})}export{z as CommandPaletteDialog};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{Br as n,Ct as r,Pi as i,Pr as a,St as o,Ur as s,Vr as c,Wn as l,Xn as u,_n as d,_t as f,dn as p,dt as m,fn as h,ft as g,gn as _,hn as v,lt as y,mn as b,mt as x,ot as S,pn as C,pt as w,rt as T,un as E,ut as D,vn as O,vt as k,wt as A,xt as j,yt as M}from"./composerDraftStore-DpPEQ6BN.js";var N=e(t());function P(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var F=`data-composite-item-active`,I=[];function L(e){let{itemSizes:t,cols:n=1,loopFocus:i=!0,dense:a=!1,orientation:c=`both`,direction:l,highlightedIndex:S,onHighlightedIndexChange:T,rootRef:M,enableHomeAndEndKeys:F=!1,stopEventPropagation:L=!1,disabledIndices:z,modifierKeys:B=I}=e,[V,H]=N.useState(0),U=n>1,W=N.useRef(null),G=s(W,M),K=N.useRef([]),q=N.useRef(!1),J=S??V,Y=u((e,t=!1)=>{if((T??H)(e),t){let t=K.current[e];A(W.current,t,l,c)}}),X=u(e=>{if(e.size===0||q.current)return;q.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&Y(r),A(W.current,n,l,c)}),Z=N.useMemo(()=>({"aria-orientation":c===`both`?void 0:c,ref:G,onFocus(e){!W.current||!r(e.target)||e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let s=F?y:m;if(!s.has(e.key)||R(e,B)||!W.current)return;let u=l===`rtl`,S=u?g:w,T={horizontal:S,vertical:D,both:S}[c],A=u?w:g,M={horizontal:A,vertical:x,both:A}[c];if(r(e.target)&&!P(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==M&&t<r.length||e.key!==T&&t>0)return}let N=J,I=_(K,z),V=v(K,z);if(U){let r=t||Array.from({length:K.current.length},()=>({width:1,height:1})),o=E(r,n,a),s=o.findIndex(e=>e!=null&&!O(K,e,z)),l=o.reduce((e,t,n)=>t!=null&&!O(K,t,z)?n:e,-1);N=o[b({current:o.map(e=>e?K.current[e]:null)},{event:e,orientation:c,loopFocus:i,cols:n,disabledIndices:C([...z||K.current.map((e,t)=>O(K,t)?t:void 0),void 0],o),minIndex:s,maxIndex:l,prevIndex:h(J>V?I:J,r,o,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:u})]}let H={horizontal:[S],vertical:[D],both:[S,D]}[c],G={horizontal:[A],vertical:[x],both:[A,x]}[c],q=U?s:{horizontal:F?k:f,vertical:F?o:j,both:s}[c];F&&(e.key===`Home`?N=I:e.key===`End`&&(N=V)),N===J&&(H.includes(e.key)||G.includes(e.key))&&(N=i&&N===V&&H.includes(e.key)?I:i&&N===I&&G.includes(e.key)?V:p(K,{startingIndex:N,decrement:G.includes(e.key),disabledIndices:z})),N!==J&&!d(K,N)&&(L&&e.stopPropagation(),q.has(e.key)&&e.preventDefault(),Y(N,!0),queueMicrotask(()=>{K.current[N]?.focus()}))}}),[n,a,l,z,K,F,J,U,t,i,G,B,Y,c,L]);return N.useMemo(()=>({props:Z,highlightedIndex:J,onHighlightedIndexChange:Y,elementsRef:K,disabledIndices:z,onMapChange:X,relayKeyboardEvent:Z.onKeyDown}),[Z,J,Y,K,z,X])}function R(e,t){for(let n of M.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}var z=i();function B(e){let{render:t,className:r,refs:i=n,props:o=n,state:s=c,stateAttributesMapping:u,highlightedIndex:d,onHighlightedIndexChange:f,orientation:p,dense:m,itemSizes:h,loopFocus:g,cols:_,enableHomeAndEndKeys:v,onMapChange:y,stopEventPropagation:b=!0,rootRef:x,disabledIndices:C,modifierKeys:w,highlightItemOnHover:E=!1,tag:D=`div`,...O}=e,{props:k,highlightedIndex:A,onHighlightedIndexChange:j,elementsRef:M,onMapChange:P,relayKeyboardEvent:F}=L({itemSizes:h,cols:_,loopFocus:g,dense:m,orientation:p,highlightedIndex:d,onHighlightedIndexChange:f,rootRef:x,stopEventPropagation:b,enableHomeAndEndKeys:v,direction:S(),disabledIndices:C,modifierKeys:w}),I=a(D,e,{state:s,ref:i,props:[k,...o,O],stateAttributesMapping:u}),R=N.useMemo(()=>({highlightedIndex:A,onHighlightedIndexChange:j,highlightItemOnHover:E,relayKeyboardEvent:F}),[A,j,E,F]);return(0,z.jsx)(l.Provider,{value:R,children:(0,z.jsx)(T,{elementsRef:M,onMapChange:e=>{y?.(e),P(e)},children:I})})}export{F as n,B as t};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{t as n}from"./compiler-runtime-BNrXlsa1.js";import{an as r}from"./react-CjD7iThp.js";import{Kt as i,S as a,X as o,_ as s,g as c,h as l,pn as u,qt as d,x as f,y as p}from"./projectAtoms-DXXpuERK.js";import{A as m,B as h,G as g,H as _,M as v,O as y,Pi as b,R as x,Sr as S,V as C,Yr as w,Zr as T,br as E,k as D,q as O,z as k}from"./composerDraftStore-DpPEQ6BN.js";import{a as A,i as j,o as M}from"./toast-DmA_ziPT.js";import{n as N,t as P}from"./pairingUrl-rQM9kSGT.js";import{d as F,f as I,h as L,o as R,s as ee,u as te}from"./primary-CSkhdakK.js";import{$n as ne,At as re,D as ie,Dt as ae,Et as oe,Ft as se,Mt as ce,Nt as le,Ot as z,Pt as ue,Rn as de,S as fe,Tt as pe,b as me,jt as he,kt as ge,x as _e,zn as ve}from"./providerIconUtils-D-DFhem2.js";import{t as ye}from"./plus-DzgIfHUF.js";import{t as B}from"./refresh-cw-BsQTNBXl.js";import{t as be}from"./triangle-alert-Bpz3xGu5.js";import{r as xe,t as Se}from"./hostedPairing-DAdvNuk3.js";import{t as V}from"./input-CgDawd6k.js";import{t as Ce}from"./scroll-area-HgsI-ErG.js";import{a as we,i as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./alert-dialog-CNmKa0BK.js";import{t as je}from"./AnimatedHeight-BSU0lzYs.js";import{n as Me,t as Ne}from"./group-BpZvxjG5.js";import{a as Pe,i as Fe,n as Ie,r as H}from"./settingsLayout-G5xVm-ZT.js";var Le=T(`chevrons-left-right-ellipsis`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`m17 7 5 5-5 5`,key:`1xlxn0`}],[`path`,{d:`m7 7-5 5 5 5`,key:`19njba`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}]]),Re=T(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),U=e(t(),1),W=n();function ze(e,t){let n=new URL(e);return n.pathname=`/pair`,N(n,t).toString()}function Be(e,t){return new URL(e).protocol===`https:`?Se({host:e,token:t}):null}var Ve=class e{static Ecc;static encodeText(t,n){let r=J.makeSegments(t);return e.encodeSegments(r,n)}static encodeBinary(t,n){let r=J.makeBytes(t);return e.encodeSegments([r],n)}static encodeSegments(t,n,r=1,i=40,a=-1,o=!0){if(!(e.MIN_VERSION<=r&&r<=i&&i<=e.MAX_VERSION)||a<-1||a>7)throw RangeError(`Invalid value`);let s,c;for(s=r;;s++){let r=e.getNumDataCodewords(s,n)*8,a=J.getTotalBits(t,s);if(a<=r){c=a;break}if(s>=i)throw RangeError(`Data too long`)}for(let t of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])o&&c<=e.getNumDataCodewords(s,t)*8&&(n=t);let l=[];for(let e of t){G(e.mode.modeBits,4,l),G(e.numChars,e.mode.numCharCountBits(s),l);for(let t of e.getData())l.push(t)}q(l.length==c);let u=e.getNumDataCodewords(s,n)*8;q(l.length<=u),G(0,Math.min(4,u-l.length),l),G(0,(8-l.length%8)%8,l),q(l.length%8==0);for(let e=236;l.length<u;e^=253)G(e,8,l);let d=[];for(;d.length*8<l.length;)d.push(0);return l.forEach((e,t)=>d[t>>>3]|=e<<7-(t&7)),new e(s,n,d,a)}version;errorCorrectionLevel;size;mask;modules=[];isFunction=[];constructor(t,n,r,i){if(this.version=t,this.errorCorrectionLevel=n,t<e.MIN_VERSION||t>e.MAX_VERSION)throw RangeError(`Version value out of range`);if(i<-1||i>7)throw RangeError(`Mask value out of range`);this.size=t*4+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();let o=this.addEccAndInterleave(r);if(this.drawCodewords(o),i==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(i=t,e=n),this.applyMask(t)}}q(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;q(r>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,K(r,e));this.setFunctionModule(8,7,K(r,6)),this.setFunctionModule(8,8,K(r,7)),this.setFunctionModule(7,8,K(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,K(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,K(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,K(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;q(t>>>18==0);for(let e=0;e<18;e++){let n=K(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(t){let n=this.version,r=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let i=e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],a=e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],o=Math.floor(e.getNumRawDataModules(n)/8),s=i-o%i,c=Math.floor(o/i),l=[],u=e.reedSolomonComputeDivisor(a);for(let n=0,r=0;n<i;n++){let i=t.slice(r,r+c-a+(n<s?0:1));r+=i.length;let o=e.reedSolomonComputeRemainder(i,u);n<s&&i.push(0),l.push(i.concat(o))}let d=[];for(let e=0;e<l[0].length;e++)l.forEach((t,n)=>{(e!=c-a||n>=s)&&d.push(t[e])});return q(d.length==o),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let e=this.size-1;e>=1;e-=2){e==6&&(e=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=e-i,o=e+1&2?r:this.size-1-r;!this.isFunction[o][a]&&n<t.length*8&&(this.modules[o][a]=K(t[n>>>3],7-(n&7)),n++)}}q(n==t.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let t=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]===r?(i++,i==5?t+=e.PENALTY_N1:i>5&&t++):(this.finderPenaltyAddHistory(i,a),r||(t+=this.finderPenaltyCountPatterns(a)*e.PENALTY_N3),r=this.modules[n][o],i=1);t+=this.finderPenaltyTerminateAndCount(r,i,a)*e.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]===r?(i++,i==5?t+=e.PENALTY_N1:i>5&&t++):(this.finderPenaltyAddHistory(i,a),r||(t+=this.finderPenaltyCountPatterns(a)*e.PENALTY_N3),r=this.modules[o][n],i=1);t+=this.finderPenaltyTerminateAndCount(r,i,a)*e.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(t+=e.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,i=Math.ceil(Math.abs(n*20-r*10)/r)-1;return q(0<=i&&i<=9),t+=i*e.PENALTY_N4,q(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*t+128)*t+64;if(t>=2){let e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}return q(208<=n&&n<=29648),n}static getNumDataCodewords(t,n){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw RangeError(`Degree out of range`);let n=[];for(let e=0;e<t-1;e++)n.push(0);n.push(1);let r=1;for(let i=0;i<t;i++){for(let t=0;t<n.length;t++)n[t]=e.reedSolomonMultiply(n[t],r),t+1<n.length&&(n[t]^=n[t+1]);r=e.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(t,n){let r=n.map(e=>0);for(let i of t){let t=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=e.reedSolomonMultiply(n,t))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return q(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];q(t<=this.size*3);let n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}static MIN_VERSION=1;static MAX_VERSION=40;static PENALTY_N1=3;static PENALTY_N2=3;static PENALTY_N3=40;static PENALTY_N4=10;static ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]];static NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]]};function G(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function K(e,t){return(e>>>t&1)!=0}function q(e){if(!e)throw Error(`Assertion error`)}var J=class e{static Mode;static makeBytes(t){let n=[];for(let e of t)G(e,8,n);return new e(e.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let n=[];for(let e=0;e<t.length;){let r=Math.min(t.length-e,3);G(parseInt(t.substring(e,e+r),10),r*3+1,n),e+=r}return new e(e.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let n=[],r;for(r=0;r+2<=t.length;r+=2){let i=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r))*45;i+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r+1)),G(i,11,n)}return r<t.length&&G(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r)),6,n),new e(e.Mode.ALPHANUMERIC,t.length,n)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let n=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)G(t,8,n);else if(t<16384)G(2,2,n),G(t,14,n);else if(t<1e6)G(6,3,n),G(t,21,n);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,n)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}mode;numChars;bitData;constructor(e,t,n){if(this.mode=e,this.numChars=t,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}static NUMERIC_REGEX=/^[0-9]*$/;static ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/;static ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`},He=class e{static LOW=new e(0,1);static MEDIUM=new e(1,0);static QUARTILE=new e(2,3);static HIGH=new e(3,2);ordinal;formatBits;constructor(e,t){this.ordinal=e,this.formatBits=t}},Y=class e{static NUMERIC=new e(1,[10,12,14]);static ALPHANUMERIC=new e(2,[9,11,13]);static BYTE=new e(4,[8,16,16]);static KANJI=new e(8,[8,10,12]);static ECI=new e(7,[0,0,0]);modeBits;numBitsCharCount;constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};Ve.Ecc=He,J.Mode=Y;var X=b(),Ue={L:Ve.Ecc.LOW,M:Ve.Ecc.MEDIUM,Q:Ve.Ecc.QUARTILE,H:Ve.Ecc.HIGH};function We(e,t){let n=[];for(let r=0;r<e.size;r+=1){let i=-1;for(let a=0;a<=e.size;a+=1){if(a<e.size&&e.getModule(a,r)){i===-1&&(i=a);continue}i!==-1&&(n.push(`M${i+t} ${r+t}h${a-i}v1H${i+t}z`),i=-1)}}return n.join(``)}var Ge=(0,U.memo)(function(e){let t=(0,W.c)(38),{value:n,size:r,level:i,marginSize:a,title:o,className:s,foregroundColor:c,backgroundColor:l}=e,u=r===void 0?128:r,d=i===void 0?`L`:i,f=a===void 0?0:a,p=c===void 0?`#000`:c,m=l===void 0?`#fff`:l,h,g,_,v,y,b,x,S,C,w,T;if(t[0]!==m||t[1]!==s||t[2]!==d||t[3]!==f||t[4]!==u||t[5]!==o||t[6]!==n){let e=Ve.encodeText(n,Ue[d]),r=e.size+f*2;C=`http://www.w3.org/2000/svg`,w=`0 0 ${r} ${r}`,T=u,h=u,g=`crispEdges`,_=o?`img`:void 0,v=o,y=s,t[18]===o?b=t[19]:(b=o?(0,X.jsx)(`title`,{children:o}):null,t[18]=o,t[19]=b),t[20]!==m||t[21]!==r?(x=(0,X.jsx)(`rect`,{width:r,height:r,fill:m}),t[20]=m,t[21]=r,t[22]=x):x=t[22],S=We(e,f),t[0]=m,t[1]=s,t[2]=d,t[3]=f,t[4]=u,t[5]=o,t[6]=n,t[7]=h,t[8]=g,t[9]=_,t[10]=v,t[11]=y,t[12]=b,t[13]=x,t[14]=S,t[15]=C,t[16]=w,t[17]=T}else h=t[7],g=t[8],_=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17];let E;t[23]!==p||t[24]!==S?(E=(0,X.jsx)(`path`,{d:S,fill:p}),t[23]=p,t[24]=S,t[25]=E):E=t[25];let D;return t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y||t[31]!==b||t[32]!==x||t[33]!==E||t[34]!==C||t[35]!==w||t[36]!==T?(D=(0,X.jsxs)(`svg`,{xmlns:C,viewBox:w,width:T,height:h,shapeRendering:g,role:_,"aria-label":v,className:y,children:[b,x,E]}),t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=b,t[32]=x,t[33]=E,t[34]=C,t[35]=w,t[36]=T,t[37]=D):D=t[37],D}),Ke=443,qe=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function Je(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:qe.format(t)}function Ye(e){let t=(0,W.c)(21),{tooltipText:n,dotClassName:r,pingClassName:i}=e,a;t[0]===i?a=t[1]:(a=i?(0,X.jsx)(`span`,{className:S(`absolute inline-flex h-full w-full animate-ping rounded-full`,i)}):null,t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=S(`relative inline-flex size-2 rounded-full`,r),t[2]=r,t[3]=o);let s;t[4]===o?s=t[5]:(s=(0,X.jsx)(`span`,{className:o}),t[4]=o,t[5]=s);let c;t[6]!==a||t[7]!==s?(c=(0,X.jsxs)(X.Fragment,{children:[a,s]}),t[6]=a,t[7]=s,t[8]=c):c=t[8];let l=c;if(!n){let e;return t[9]===l?e=t[10]:(e=(0,X.jsx)(`span`,{className:`relative flex size-3 shrink-0 items-center justify-center`,children:l}),t[9]=l,t[10]=e),e}let u;t[11]!==l||t[12]!==n?(u=(0,X.jsx)(`button`,{type:`button`,title:n,"aria-label":n,className:`relative flex size-3 shrink-0 cursor-help items-center justify-center rounded-full outline-hidden`,children:l}),t[11]=l,t[12]=n,t[13]=u):u=t[13];let d=u,f;t[14]===d?f=t[15]:(f=(0,X.jsx)(v,{render:d}),t[14]=d,t[15]=f);let p;t[16]===n?p=t[17]:(p=(0,X.jsx)(m,{side:`top`,className:`max-w-80 whitespace-pre-wrap leading-tight`,children:n}),t[16]=n,t[17]=p);let h;return t[18]!==f||t[19]!==p?(h=(0,X.jsxs)(D,{children:[f,p]}),t[18]=f,t[19]=p,t[20]=h):h=t[20],h}function Xe(e,t,n){let r=e?.connectionState??`disconnected`;if(r===`connected`){let r=e?.connectedAt??t.lastConnectedAt;return r?`Connected for ${de(r,n)}`:null}return r===`connecting`?null:r===`error`?e?.lastError??`An unknown connection error occurred.`:t.lastConnectedAt?`Last connected at ${Je(t.lastConnectedAt)}`:`Not connected yet.`}function Ze(e){let t=e.username?`${e.username}@${e.hostname}`:e.hostname;return e.port?`${t}:${e.port}`:t}function Qe(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 $e(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=xe(n);if(r)return{host:r.host,pairingCode:r.token};let i=P(n);return i?{host:n.origin,pairingCode:i}:null}catch{return null}}function et(e){let t=$e(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 tt(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 nt=`border-t border-border/60 px-4 py-4 first:border-t-0 sm:px-5`,rt=`border-t border-border/60 px-4 py-2.5 first:border-t-0 sm:px-5`,it=`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`;function at(e){return nt}function ot(e,t){return e===`endpoint-rail`?S(`relative border-t border-border/60 px-4 py-3 first:border-t-0 sm:px-5`,!t&&`bg-muted/20`):S(rt,!t&&`bg-muted/24`)}function st(e){return[...e].toSorted((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())}function ct(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 lt(e){return{...e,createdAt:r(e.createdAt),expiresAt:r(e.expiresAt)}}function ut(e){return{...e,issuedAt:r(e.issuedAt),expiresAt:r(e.expiresAt),lastConnectedAt:e.lastConnectedAt===null?null:r(e.lastConnectedAt)}}function dt(e,t){let n=e.findIndex(e=>e.id===t.id);if(n===-1)return st([...e,t]);let r=[...e];return r[n]=t,st(r)}function ft(e,t){return e.filter(e=>e.id!==t)}function pt(e,t){let n=e.findIndex(e=>e.sessionId===t.sessionId);if(n===-1)return ct([...e,t]);let r=[...e];return r[n]=t,ct(r)}function mt(e,t){return e.filter(e=>e.sessionId!==t)}function ht(e,t){let n=e.filter(e=>e.status!==`unavailable`);if(t){let e=n.find(e=>_t(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 gt(e){return e.id.startsWith(`tailscale-magicdns:`)}function _t(e){if(e.id.startsWith(`desktop-loopback:`)||e.id.startsWith(`server-loopback:`))return`desktop-core:loopback:http`;if(e.id.startsWith(`desktop-lan:`)||e.id.startsWith(`server-network:`))return`desktop-core:lan:http`;if(e.id.startsWith(`tailscale-ip:`))return`tailscale:ip:http`;if(gt(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 vt(e){switch(e){case`mixed-content-blocked`:return`Hosted app blocked`;case`requires-configuration`:return`Setup required for hosted app`;default:return null}}function yt(e){switch(e){case`mixed-content-blocked`:return`The hosted HTTPS app cannot connect to HTTP endpoints because browsers block mixed content.`;case`requires-configuration`:return`Configure HTTPS access before using this endpoint from the hosted app.`;default:return null}}function Z(e,t){return e.compatibility.hostedHttpsApp===`compatible`?Be(e.httpBaseUrl,t)??ze(e.httpBaseUrl,t):ze(e.httpBaseUrl,t)}function bt(e){return N(new URL(`/pair`,window.location.href),e).toString()}function xt(e){try{let t=new URL(e);return t.pathname===`/pair`&&t.searchParams.has(`host`)}catch{return!1}}var St=(0,U.memo)(function(e){let t=(0,W.c)(146),{pairingLink:n,endpointUrl:r,endpoints:i,defaultEndpointKey:a,presentation:o,revokingPairingLinkId:s,onRevoke:c}=e,l=o===void 0?`current`:o,u=Pe(1e3),d;t[0]===n.expiresAt?d=t[1]:(d=new Date(n.expiresAt).getTime(),t[0]=n.expiresAt,t[1]=d);let f=d,[p,m]=(0,U.useState)(!1),v;t[2]===n.credential?v=t[3]:(v=bt(n.credential),t[2]=n.credential,t[3]=v);let y=v,b;t[4]!==r||t[5]!==n.credential?(b=r!=null&&r!==``?Be(r,n.credential):null,t[4]=r,t[5]=n.credential,t[6]=b):b=t[6];let S=b,T;if(t[7]!==a||t[8]!==i||t[9]!==n.credential){let e=ht(i,a);T=e?Z(e,n.credential):null,t[7]=a,t[8]=i,t[9]=n.credential,t[10]=T}else T=t[10];let D=T,N;if(t[11]!==i||t[12]!==n.credential){let e;t[14]===n.credential?e=t[15]:(e=e=>{let t=Z(e,n.credential);return{key:_t(e),label:e.label,url:t,detail:xt(t)?`Hosted app link`:`Backend pairing URL`}},t[14]=n.credential,t[15]=e),N=i.filter(Mt).map(e),t[11]=i,t[12]=n.credential,t[13]=N}else N=t[13];let P=N,F;t[16]!==y||t[17]!==D||t[18]!==r||t[19]!==S||t[20]!==n.credential?(F=D??(r!=null&&r!==``?S??ze(r,n.credential):L(window.location.hostname)?null:y),t[16]=y,t[17]=D,t[18]=r,t[19]=S,t[20]=n.credential,t[21]=F):F=t[21];let I=F,R=I??n.credential,ee=I!==null&&xt(I),te=typeof window<`u`&&window.isSecureContext&&navigator.clipboard?.writeText!=null,ne;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(ne={onCopy:Nt,onError:(e,t)=>{m(!0),j.add(A({type:`error`,title:te?t===`hosted-link`?`Could not copy hosted app link`:t===`link`?`Could not copy pairing URL`:`Could not copy pairing code`:`Clipboard copy unavailable`,description:te?e.message:`Showing the full value instead.`}))}},t[22]=ne):ne=t[22];let{copyToClipboard:ie}=M(ne),oe;t[23]===ie?oe=t[24]:(oe=(e,t)=>{ie(e,t)},t[23]=ie,t[24]=oe);let z=oe,de=Pt,ye;t[25]!==z||t[26]!==n.credential?(ye=()=>{z(n.credential,`code`)},t[25]=z,t[26]=n.credential,t[27]=ye):ye=t[27];let B=ye,be;t[28]!==z||t[29]!==I?(be=()=>{I&&z(I,de(I))},t[28]=z,t[29]=I,t[30]=be):be=t[30];let xe=be,Se;t[31]===n.expiresAt?Se=t[32]:(Se=Je(n.expiresAt),t[31]=n.expiresAt,t[32]=Se);let V=Se,Ce=n.role===`owner`?`Owner`:`Client`,we=n.label??`${Ce} link`,Te;t[33]!==a||t[34]!==P?(Te=P.find(e=>e.key===a)??P[0]??null,t[33]=a,t[34]=P,t[35]=Te):Te=t[35];let Ee=Te?.label??`URL`,De,Oe,ke,Ae,je,Fe,Ie,H,Le;if(t[36]!==z||t[37]!==Ee||t[38]!==P||t[39]!==V||t[40]!==f||t[41]!==B||t[42]!==xe||t[43]!==p||t[44]!==u||t[45]!==n.createdAt||t[46]!==n.expiresAt||t[47]!==l||t[48]!==we||t[49]!==Ce||t[50]!==I){Le=Symbol.for(`react.early_return_sentinel`);bb0:{let e=P.filter(Ft),r=P.filter(It),i;t[60]!==z||t[61]!==P?(i=(e,t)=>{let n=e===void 0?P:e,r=t===void 0?!0:t;return n.map(e=>(0,X.jsx)(C,{onClick:()=>z(e.url,de(e.url)),children:(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate`,children:e.label}),r?(0,X.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:e.detail}):null]})},e.key))},t[60]=z,t[61]=P,t[62]=i):i=t[62];let a=i,o;t[63]===B?o=t[64]:(o=e=>(0,X.jsx)(C,{onClick:B,children:(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate`,children:`Copy code`}),e===void 0||e?(0,X.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:`Token only`}):null]})}),t[63]=B,t[64]=o);let s=o,c;t[65]===a?c=t[66]:(c=(e,t,n)=>t.length>0?(0,X.jsxs)(X.Fragment,{children:[n?(0,X.jsx)(g,{}):null,(0,X.jsxs)(k,{children:[(0,X.jsx)(h,{children:e}),a(t,!1)]})]}):null,t[65]=a,t[66]=c);let d=c,v=t=>(0,X.jsxs)(X.Fragment,{children:[t?.codeFirst?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(k,{children:[(0,X.jsx)(h,{children:`Pairing code`}),s(!1)]}),P.length>0?(0,X.jsx)(g,{}):null]}):null,d(`Pairing URLs`,e,!1),d(`Hosted app link`,r,e.length>0),t?.codeFirst?null:(0,X.jsxs)(X.Fragment,{children:[P.length>0?(0,X.jsx)(g,{}):null,(0,X.jsxs)(k,{children:[(0,X.jsx)(h,{children:`Pairing code`}),s(!1)]})]})]});if(f<=u){Le=null;break bb0}t[67]===l?H=t[68]:(H=at(l),t[67]=l,t[68]=H),Fe=it;let y;t[69]===n.createdAt?y=t[70]:(y=Je(n.createdAt),t[69]=n.createdAt,t[70]=y);let b=`Link created at ${y}`,S;t[71]===b?S=t[72]:(S=(0,X.jsx)(Ye,{tooltipText:b,dotClassName:`bg-amber-400`}),t[71]=b,t[72]=S);let T;t[73]===we?T=t[74]:(T=(0,X.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:we}),t[73]=we,t[74]=T);let D;t[75]===I?D=t[76]:(D=I?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fe,{openOnHover:!0,delay:250,closeDelay:100,render:(0,X.jsx)(`button`,{type:`button`,className:`inline-flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground/50 outline-none hover:text-foreground`,"aria-label":`Show QR code`}),children:(0,X.jsx)(Re,{"aria-hidden":!0,className:`size-3`})}),(0,X.jsx)(_e,{side:`top`,align:`start`,tooltipStyle:!0,className:`w-max`,children:(0,X.jsx)(Ge,{value:I,size:88,level:`M`,marginSize:2,title:`Pairing link — scan to open on another device`})})]}):null,t[75]=I,t[76]=D);let A;t[77]===D?A=t[78]:(A=(0,X.jsx)(me,{children:D}),t[77]=D,t[78]=A);let j;t[79]!==S||t[80]!==T||t[81]!==A?(j=(0,X.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[S,T,A]}),t[79]=S,t[80]=T,t[81]=A,t[82]=j):j=t[82];let M;t[83]!==u||t[84]!==n.expiresAt?(M=ve(n.expiresAt,u),t[83]=u,t[84]=n.expiresAt,t[85]=M):M=t[85];let N;t[86]!==Ce||t[87]!==M?(N=[Ce,M],t[86]=Ce,t[87]=M,t[88]=N):N=t[88];let F=N.join(` · `),L;t[89]!==V||t[90]!==F?(L=(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,title:V,children:F}),t[89]=V,t[90]=F,t[91]=L):L=t[91];let R;t[92]===I?R=t[93]:(R=I===null?(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:`Copy the token and pair from another client using this backend's reachable host.`}):null,t[92]=I,t[93]=R),t[94]!==j||t[95]!==L||t[96]!==R?(Ie=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[j,L,R]}),t[94]=j,t[95]=L,t[96]=R,t[97]=Ie):Ie=t[97],je=`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,De=ae,Oe=p,ke=m,Ae=te?(0,X.jsx)(X.Fragment,{children:I?(0,X.jsxs)(Ne,{"aria-label":`Copy selected endpoint`,children:[(0,X.jsx)(E,{size:`xs`,variant:`outline`,className:`max-w-56`,title:`Copy pairing URL for: ${Ee}`,onClick:xe,children:(0,X.jsxs)(`span`,{className:`truncate`,children:[`Copy pairing URL for: `,Ee]})}),(0,X.jsx)(Me,{}),(0,X.jsxs)(x,{children:[(0,X.jsx)(O,{render:(0,X.jsx)(E,{size:`icon-xs`,variant:`outline`,"aria-label":`Choose endpoint to copy`}),children:(0,X.jsx)(w,{className:`size-3.5`})}),(0,X.jsx)(_,{align:`end`,className:`min-w-60`,children:v()})]})]}):(0,X.jsx)(E,{size:`xs`,variant:`outline`,onClick:B,children:`Copy code`})}):(0,X.jsx)(se,{render:(0,X.jsx)(E,{size:`xs`,variant:`outline`}),children:I?`Show link`:`Show code`})}t[36]=z,t[37]=Ee,t[38]=P,t[39]=V,t[40]=f,t[41]=B,t[42]=xe,t[43]=p,t[44]=u,t[45]=n.createdAt,t[46]=n.expiresAt,t[47]=l,t[48]=we,t[49]=Ce,t[50]=I,t[51]=De,t[52]=Oe,t[53]=ke,t[54]=Ae,t[55]=je,t[56]=Fe,t[57]=Ie,t[58]=H,t[59]=Le}else De=t[51],Oe=t[52],ke=t[53],Ae=t[54],je=t[55],Fe=t[56],Ie=t[57],H=t[58],Le=t[59];if(Le!==Symbol.for(`react.early_return_sentinel`))return Le;let Ve=I?ee?`Hosted app pairing link`:`Pairing link`:`Pairing code`,G;t[98]===Ve?G=t[99]:(G=(0,X.jsx)(ue,{children:Ve}),t[98]=Ve,t[99]=G);let K=I?ee?`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.`,q;t[100]===K?q=t[101]:(q=(0,X.jsx)(ge,{children:K}),t[100]=K,t[101]=q);let J;t[102]!==G||t[103]!==q?(J=(0,X.jsxs)(he,{children:[G,q]}),t[102]=G,t[103]=q,t[104]=J):J=t[104];let He=I?4:3,Y;t[105]!==R||t[106]!==He?(Y=(0,X.jsx)(pe,{readOnly:!0,value:R,rows:He,className:`text-xs leading-relaxed`,onFocus:Lt,onClick:Rt}),t[105]=R,t[106]=He,t[107]=Y):Y=t[107];let Ue;t[108]===I?Ue=t[109]:(Ue=I?(0,X.jsx)(`div`,{className:`flex justify-center rounded-xl border border-border/60 bg-muted/30 p-4`,children:(0,X.jsx)(Ge,{value:I,size:132,level:`M`,marginSize:2,title:`Pairing link — scan to open on another device`})}):null,t[108]=I,t[109]=Ue);let We;t[110]!==Y||t[111]!==Ue?(We=(0,X.jsxs)(ce,{className:`space-y-4`,children:[Y,Ue]}),t[110]=Y,t[111]=Ue,t[112]=We):We=t[112];let Ke;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,X.jsx)(E,{variant:`outline`,onClick:()=>m(!1),children:`Done`}),t[113]=Ke):Ke=t[113];let qe;t[114]===B?qe=t[115]:(qe=te?(0,X.jsx)(E,{variant:`outline`,size:`xs`,onClick:B,children:`Copy code`}):null,t[114]=B,t[115]=qe);let Xe;t[116]===qe?Xe=t[117]:(Xe=(0,X.jsxs)(re,{variant:`bare`,children:[Ke,qe]}),t[116]=qe,t[117]=Xe);let Ze;t[118]!==J||t[119]!==We||t[120]!==Xe?(Ze=(0,X.jsxs)(le,{className:`max-w-md`,children:[J,We,Xe]}),t[118]=J,t[119]=We,t[120]=Xe,t[121]=Ze):Ze=t[121];let Qe;t[122]!==De||t[123]!==Oe||t[124]!==ke||t[125]!==Ae||t[126]!==Ze?(Qe=(0,X.jsxs)(De,{open:Oe,onOpenChange:ke,children:[Ae,Ze]}),t[122]=De,t[123]=Oe,t[124]=ke,t[125]=Ae,t[126]=Ze,t[127]=Qe):Qe=t[127];let $e=s===n.id,et;t[128]!==c||t[129]!==n.id?(et=()=>void c(n.id),t[128]=c,t[129]=n.id,t[130]=et):et=t[130];let tt=s===n.id?`Revoking…`:`Revoke`,nt;t[131]!==$e||t[132]!==et||t[133]!==tt?(nt=(0,X.jsx)(E,{size:`xs`,variant:`destructive-outline`,disabled:$e,onClick:et,children:tt}),t[131]=$e,t[132]=et,t[133]=tt,t[134]=nt):nt=t[134];let rt;t[135]!==je||t[136]!==Qe||t[137]!==nt?(rt=(0,X.jsxs)(`div`,{className:je,children:[Qe,nt]}),t[135]=je,t[136]=Qe,t[137]=nt,t[138]=rt):rt=t[138];let ot;t[139]!==Fe||t[140]!==Ie||t[141]!==rt?(ot=(0,X.jsxs)(`div`,{className:Fe,children:[Ie,rt]}),t[139]=Fe,t[140]=Ie,t[141]=rt,t[142]=ot):ot=t[142];let st;return t[143]!==H||t[144]!==ot?(st=(0,X.jsx)(`div`,{className:H,children:ot}),t[143]=H,t[144]=ot,t[145]=st):st=t[145],st}),Ct=(0,U.memo)(function(e){let t=(0,W.c)(51),{clientSession:n,presentation:r,revokingClientSessionId:i,onRevokeSession:a}=e,o=r===void 0?`current`:r,s=Pe(1e3),c=n.current||n.connected,l=n.lastConnectedAt,u;t[0]!==c||t[1]!==l||t[2]!==s?(u=c?l?`Connected for ${de(l,s)}`:`Connected`:l?`Last connected at ${Je(l)}`:`Not connected yet.`,t[0]=c,t[1]=l,t[2]=s,t[3]=u):u=t[3];let d=u,f=n.role===`owner`?`Owner`:`Client`,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(Q),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]===o?x=t[17]:(x=at(o),t[16]=o,t[17]=x);let S=c?`bg-success`:`bg-muted-foreground/30`,C=c?`bg-success/60 duration-2000`:null,w;t[18]!==d||t[19]!==S||t[20]!==C?(w=(0,X.jsx)(Ye,{tooltipText:d,dotClassName:S,pingClassName:C}),t[18]=d,t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;t[22]===b?T=t[23]:(T=(0,X.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:b}),t[22]=b,t[23]=T);let D;t[24]===n.current?D=t[25]:(D=n.current?(0,X.jsx)(`span`,{className:`text-[10px] 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]=D);let O;t[26]!==w||t[27]!==T||t[28]!==D?(O=(0,X.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[w,T,D]}),t[26]=w,t[27]=T,t[28]=D,t[29]=O):O=t[29];let k;t[30]!==v||t[31]!==f?(k=[f,...v],t[30]=v,t[31]=f,t[32]=k):k=t[32];let A=k.join(` · `),j;t[33]===A?j=t[34]:(j=(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:A}),t[33]=A,t[34]=j);let M;t[35]!==O||t[36]!==j?(M=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[O,j]}),t[35]=O,t[36]=j,t[37]=M):M=t[37];let N;t[38]!==n.current||t[39]!==n.sessionId||t[40]!==a||t[41]!==i?(N=n.current?null:(0,X.jsx)(E,{size:`xs`,variant:`destructive-outline`,disabled:i===n.sessionId,onClick:()=>void a(n.sessionId),children:i===n.sessionId?`Revoking…`:`Revoke`}),t[38]=n.current,t[39]=n.sessionId,t[40]=a,t[41]=i,t[42]=N):N=t[42];let P;t[43]===N?P=t[44]:(P=(0,X.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:N}),t[43]=N,t[44]=P);let F;t[45]!==M||t[46]!==P?(F=(0,X.jsxs)(`div`,{className:it,children:[M,P]}),t[45]=M,t[46]=P,t[47]=F):F=t[47];let I;return t[48]!==F||t[49]!==x?(I=(0,X.jsx)(`div`,{className:x,children:F}),t[48]=F,t[49]=x,t[50]=I):I=t[50],I}),wt=(0,U.memo)(function({clientSessions:e,isRevokingOtherClients:t,onRevokeOtherClients:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(``),[s,c]=(0,U.useState)(!1),l=(0,U.useCallback)(async()=>{c(!0);try{await R(a),o(``),i(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to create pairing URL.`;j.add(A({type:`error`,title:`Could not create pairing URL`,description:t}))}finally{c(!1)}},[a]);return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(E,{size:`xs`,variant:`destructive-outline`,disabled:t||e.every(e=>e.current),onClick:()=>void n(),children:t?`Revoking…`:`Revoke others`}),(0,X.jsxs)(ae,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,X.jsx)(se,{render:(0,X.jsxs)(E,{size:`xs`,variant:`default`,children:[(0,X.jsx)(ye,{className:`size-3`}),`Create link`]})}),(0,X.jsxs)(le,{className:`max-w-sm`,children:[(0,X.jsxs)(he,{children:[(0,X.jsx)(ue,{children:`Create pairing link`}),(0,X.jsx)(ge,{children:`Generate a one-time link that another device can use to pair with this backend as an authorized client.`})]}),(0,X.jsx)(ce,{children:(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Client label (optional)`}),(0,X.jsx)(V,{value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Living room iPad`,disabled:s,autoFocus:!0})]})}),(0,X.jsxs)(re,{variant:`bare`,children:[(0,X.jsx)(E,{variant:`outline`,disabled:s,onClick:()=>i(!1),children:`Cancel`}),(0,X.jsx)(E,{disabled:s,onClick:()=>void l(),children:s?`Creating…`:`Create link`})]})]})]})]})}),Tt=(0,U.memo)(function(e){let t=(0,W.c)(33),{endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:a,isLoading:o,pairingLinks:s,clientSessions:c,revokingPairingLinkId:l,revokingClientSessionId:u,onRevokePairingLink:d,onRevokeClientSession:f}=e,p=a===void 0?`current`:a,m;if(t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==d||t[4]!==s||t[5]!==p||t[6]!==l){let e;t[8]!==i||t[9]!==n||t[10]!==r||t[11]!==d||t[12]!==p||t[13]!==l?(e=e=>(0,X.jsx)(St,{pairingLink:e,endpointUrl:n,endpoints:r,defaultEndpointKey:i,presentation:p,revokingPairingLinkId:l,onRevoke:d},e.id),t[8]=i,t[9]=n,t[10]=r,t[11]=d,t[12]=p,t[13]=l,t[14]=e):e=t[14],m=s.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=d,t[4]=s,t[5]=p,t[6]=l,t[7]=m}else m=t[7];let h;if(t[15]!==c||t[16]!==f||t[17]!==p||t[18]!==u){let e;t[20]!==f||t[21]!==p||t[22]!==u?(e=e=>(0,X.jsx)(Ct,{clientSession:e,presentation:p,revokingClientSessionId:u,onRevokeSession:f},e.sessionId),t[20]=f,t[21]=p,t[22]=u,t[23]=e):e=t[23],h=c.map(e),t[15]=c,t[16]=f,t[17]=p,t[18]=u,t[19]=h}else h=t[19];let g;t[24]!==c.length||t[25]!==o||t[26]!==s.length||t[27]!==p?(g=s.length===0&&c.length===0&&!o?(0,X.jsx)(`div`,{className:at(p),children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`No pairing links or client sessions.`})}):null,t[24]=c.length,t[25]=o,t[26]=s.length,t[27]=p,t[28]=g):g=t[28];let _;return t[29]!==m||t[30]!==h||t[31]!==g?(_=(0,X.jsxs)(X.Fragment,{children:[m,h,g]}),t[29]=m,t[30]=h,t[31]=g,t[32]=_):_=t[32],_}),Et=(0,U.memo)(function(e){let t=(0,W.c)(58),{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=gt(n)&&n.status!==`available`,t[0]=n,t[1]=d);let f=d,p;t[2]===n.compatibility.hostedHttpsApp?p=t[3]:(p=vt(n.compatibility.hostedHttpsApp),t[2]=n.compatibility.hostedHttpsApp,t[3]=p);let m=p,h;t[4]===n.compatibility.hostedHttpsApp?h=t[5]:(h=yt(n.compatibility.hostedHttpsApp),t[4]=n.compatibility.hostedHttpsApp,t[5]=h);let g=h,_;t[6]===n?_=t[7]:(_=gt(n)&&n.status===`available`,t[6]=n,t[7]=_);let v=_,y=!f,b=l===`endpoint-rail`,x;t[8]!==u||t[9]!==l?(x=ot(l,u),t[8]=u,t[9]=l,t[10]=x):x=t[10];let S;t[11]!==r||t[12]!==b?(S=b&&r?(0,X.jsx)(`span`,{className:`absolute inset-y-2 left-0 w-1 rounded-r-full bg-primary`,"aria-hidden":!0}):null,t[11]=r,t[12]=b,t[13]=S):S=t[13];let C;t[14]===n.label?C=t[15]:(C=(0,X.jsx)(`h3`,{className:`shrink-0 text-sm leading-5 font-medium text-foreground`,children:n.label}),t[14]=n.label,t[15]=C);let w;t[16]!==n.httpBaseUrl||t[17]!==y?(w=y?(0,X.jsx)(`p`,{className:`min-w-0 truncate text-xs leading-5 text-muted-foreground`,title:n.httpBaseUrl,children:n.httpBaseUrl}):null,t[16]=n.httpBaseUrl,t[17]=y,t[18]=w):w=t[18];let T;t[19]===u?T=t[20]:(T=u?null:(0,X.jsx)(`span`,{className:`shrink-0 rounded-md border border-border/70 px-1 py-0.5 text-[10px] text-muted-foreground`,children:`Setup required`}),t[19]=u,t[20]=T);let D;t[21]!==g||t[22]!==m?(D=m?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-amber-500/30 bg-amber-500/10 px-1 py-0.5 text-[10px] text-amber-700 dark:text-amber-300`,title:g??void 0,children:[(0,X.jsx)(be,{"aria-hidden":!0,className:`size-3`}),m]}):null,t[21]=g,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==T||t[25]!==D||t[26]!==C||t[27]!==w?(O=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[C,w,T,D]}),t[24]=T,t[25]=D,t[26]=C,t[27]=w,t[28]=O):O=t[28];let k;t[29]===r?k=t[30]:(k=r?(0,X.jsx)(`span`,{className:`rounded-md border border-primary/30 bg-primary/10 px-1 py-0.5 text-[10px] text-primary`,children:`Default`}):null,t[29]=r,t[30]=k);let A;t[31]!==n||t[32]!==c||t[33]!==f||t[34]!==o?(A=f?(0,X.jsx)(E,{size:`xs`,variant:`outline`,onClick:()=>o(n),disabled:c,children:c?`Restarting…`:`Setup`}):null,t[31]=n,t[32]=c,t[33]=f,t[34]=o,t[35]=A):A=t[35];let j;t[36]!==v||t[37]!==n||t[38]!==c||t[39]!==s?(j=v?(0,X.jsx)(E,{size:`xs`,variant:`destructive-outline`,onClick:()=>s(n),disabled:c,children:c?`Restarting…`:`Disable`}):null,t[36]=v,t[37]=n,t[38]=c,t[39]=s,t[40]=j):j=t[40];let M;t[41]!==n||t[42]!==r||t[43]!==f||t[44]!==a?(M=!f&&!r?(0,X.jsx)(E,{size:`xs`,variant:`outline`,onClick:()=>a(n),children:`Set as default`}):null,t[41]=n,t[42]=r,t[43]=f,t[44]=a,t[45]=M):M=t[45];let N;t[46]!==k||t[47]!==A||t[48]!==j||t[49]!==M?(N=(0,X.jsxs)(`div`,{className:`ml-auto flex min-h-6 shrink-0 items-center justify-end gap-2`,children:[k,A,j,M]}),t[46]=k,t[47]=A,t[48]=j,t[49]=M,t[50]=N):N=t[50];let P;t[51]!==O||t[52]!==N?(P=(0,X.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:[O,N]}),t[51]=O,t[52]=N,t[53]=P):P=t[53];let F;return t[54]!==P||t[55]!==x||t[56]!==S?(F=(0,X.jsxs)(`div`,{className:x,children:[S,P]}),t[54]=P,t[55]=x,t[56]=S,t[57]=F):F=t[57],F});function Dt(e){let t=(0,W.c)(17),{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,X.jsx)(`span`,{className:`min-w-0 truncate`,children:n.httpBaseUrl}),t[0]=n.httpBaseUrl,t[1]=s);let c;t[2]===n.compatibility.hostedHttpsApp?c=t[3]:(c=vt(n.compatibility.hostedHttpsApp)?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,title:yt(n.compatibility.hostedHttpsApp)??void 0,children:[(0,X.jsx)(be,{"aria-hidden":!0,className:`size-3`}),vt(n.compatibility.hostedHttpsApp)]}):null,t[2]=n.compatibility.hostedHttpsApp,t[3]=c);let l;t[4]!==i||t[5]!==r?(l=r>0?(0,X.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:i?`Hide`:`+${r}`}):null,t[4]=i,t[5]=r,t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c||t[9]!==l?(u=(0,X.jsxs)(X.Fragment,{children:[s,c,l]}),t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10];let d=u,f;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(`span`,{className:`shrink-0`,children:`Reachable at`}),t[11]=f):f=t[11];let p;return t[12]!==i||t[13]!==r||t[14]!==a||t[15]!==d?(p=(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-1`,children:[f,r>0?(0,X.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:d}):(0,X.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full items-baseline gap-2`,children:d})]}),t[12]=i,t[13]=r,t[14]=a,t[15]=d,t[16]=p):p=t[16],p}function Ot(e){let t=(0,W.c)(57),{environmentId:n,reconnectingEnvironmentId:r,disconnectingEnvironmentId:a,removingEnvironmentId:s,onConnect:c,onDisconnect:l,onRemove:u}=e,f=Pe(1e3),p;t[0]===n?p=t[1]:(p=e=>e.byId[n]??null,t[0]=n,t[1]=p);let m=i(p),h;t[2]===n?h=t[3]:(h=e=>e.byId[n]??null,t[2]=n,t[3]=h);let g=d(h);if(!m)return null;let _=g?.connectionState??`disconnected`,v=_===`connected`,y=_===`connecting`||r===n,b=a===n,x=_===`connected`?`bg-success`:_===`connecting`?`bg-warning`:_===`error`?`bg-destructive`:`bg-muted-foreground/40`,S=g?.role?g.role===`owner`?`Owner`:`Client`:null,C=g?.descriptor?.label??null??m.label,w;t[4]!==f||t[5]!==m||t[6]!==g?(w=Xe(g,m,f),t[4]=f,t[5]=m,t[6]=g,t[7]=w):w=t[7];let T=w,D=g?.serverConfig,O;t[8]===D?O=t[9]:(O=o(D),t[8]=D,t[9]=O);let k=O,A;t[10]===m.desktopSsh?A=t[11]:(A=m.desktopSsh?`SSH ${Ze(m.desktopSsh)}`:null,t[10]=m.desktopSsh,t[11]=A);let j;t[12]===m.lastConnectedAt?j=t[13]:(j=m.lastConnectedAt?`Last connected ${Je(m.lastConnectedAt)}`:null,t[12]=m.lastConnectedAt,t[13]=j);let M;t[14]!==S||t[15]!==A||t[16]!==j?(M=[A,S,j].filter(kt),t[14]=S,t[15]=A,t[16]=j,t[17]=M):M=t[17];let N=M,P=_===`connecting`?`bg-warning/60 duration-2000`:null,F;t[18]!==x||t[19]!==T||t[20]!==P?(F=(0,X.jsx)(Ye,{tooltipText:T,dotClassName:x,pingClassName:P}),t[18]=x,t[19]=T,t[20]=P,t[21]=F):F=t[21];let I;t[22]===C?I=t[23]:(I=(0,X.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:C}),t[22]=C,t[23]=I);let L;t[24]!==F||t[25]!==I?(L=(0,X.jsxs)(`div`,{className:`flex min-h-5 items-center gap-1.5`,children:[F,I]}),t[24]=F,t[25]=I,t[26]=L):L=t[26];let R;t[27]===N?R=t[28]:(R=N.length>0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:N.join(` · `)}):null,t[27]=N,t[28]=R);let ee;t[29]===k?ee=t[30]:(ee=k?(0,X.jsxs)(`p`,{className:`flex items-center gap-1 text-warning text-xs`,children:[(0,X.jsx)(be,{className:`size-3.5 shrink-0`}),`Version drift: client `,k.clientVersion,`, server`,` `,k.serverVersion,`.`]}):null,t[29]=k,t[30]=ee);let te;t[31]!==L||t[32]!==R||t[33]!==ee?(te=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[L,R,ee]}),t[31]=L,t[32]=R,t[33]=ee,t[34]=te):te=t[34];let ne=v?b:y,re;t[35]!==n||t[36]!==v||t[37]!==c||t[38]!==l?(re=()=>void(v?l(n):c(n)),t[35]=n,t[36]=v,t[37]=c,t[38]=l,t[39]=re):re=t[39];let ie=v?b?`Disconnecting…`:`Disconnect`:y?`Connecting…`:`Connect`,ae;t[40]!==ne||t[41]!==re||t[42]!==ie?(ae=(0,X.jsx)(E,{size:`xs`,variant:`outline`,disabled:ne,onClick:re,children:ie}),t[40]=ne,t[41]=re,t[42]=ie,t[43]=ae):ae=t[43];let oe=s===n,se;t[44]!==n||t[45]!==u?(se=()=>void u(n),t[44]=n,t[45]=u,t[46]=se):se=t[46];let ce=s===n?`Removing…`:`Remove`,le;t[47]!==oe||t[48]!==se||t[49]!==ce?(le=(0,X.jsx)(E,{size:`xs`,variant:`destructive-outline`,disabled:oe,onClick:se,children:ce}),t[47]=oe,t[48]=se,t[49]=ce,t[50]=le):le=t[50];let z;t[51]!==ae||t[52]!==le?(z=(0,X.jsxs)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:[ae,le]}),t[51]=ae,t[52]=le,t[53]=z):z=t[53];let ue;return t[54]!==te||t[55]!==z?(ue=(0,X.jsx)(`div`,{className:nt,children:(0,X.jsxs)(`div`,{className:it,children:[te,z]})}),t[54]=te,t[55]=z,t[56]=ue):ue=t[56],ue}function kt(e){return e!==null}var At=(0,U.memo)(function(e){let t=(0,W.c)(24),{target:n,connectingHostAlias:r,onConnect:i}=e,a;t[0]===n?a=t[1]:(a=Ze(n),t[0]=n,t[1]=a);let o=a,s=o!==n.alias,c=r===n.alias?`Adding…`:`Add environment`,l;t[2]===n.alias?l=t[3]:(l=(0,X.jsx)(`h3`,{className:`truncate text-sm font-medium text-foreground`,children:n.alias}),t[2]=n.alias,t[3]=l);let u;t[4]!==o||t[5]!==s?(u=s?(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:o}):null,t[4]=o,t[5]=s,t[6]=u):u=t[6];let d;t[7]!==l||t[8]!==u?(d=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l,u]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f=r===n.alias,p;t[10]!==i||t[11]!==n?(p=()=>i(n),t[10]=i,t[11]=n,t[12]=p):p=t[12];let m;t[13]!==r||t[14]!==n.alias?(m=r===n.alias?(0,X.jsx)(B,{className:`size-3 animate-spin`}):null,t[13]=r,t[14]=n.alias,t[15]=m):m=t[15];let h;t[16]!==c||t[17]!==f||t[18]!==p||t[19]!==m?(h=(0,X.jsx)(`div`,{className:`flex w-full shrink-0 items-center gap-2 sm:w-auto sm:justify-end`,children:(0,X.jsxs)(E,{size:`xs`,variant:`outline`,disabled:f,onClick:p,children:[m,c]})}),t[16]=c,t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==d||t[22]!==h?(g=(0,X.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3 first:border-t-0 sm:px-5`,children:(0,X.jsxs)(`div`,{className:it,children:[d,h]})}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g});function jt(){let e=window.desktopBridge,[t,n]=(0,U.useState)(e?`owner`:null),[r,d]=(0,U.useState)(null),h=i(e=>e.byId),g=(0,U.useMemo)(()=>Object.values(h).toSorted((e,t)=>e.label.localeCompare(t.label)).map(e=>e.environmentId),[h]),_=(0,U.useMemo)(()=>Object.values(h).reduce((e,t)=>(t.desktopSsh?.alias&&(e[t.desktopSsh.alias]=t),e),{}),[h]),b=(0,U.useMemo)(()=>{let e=new Set;for(let t of Object.values(h)){let n=t.desktopSsh;n&&(e.add(n.alias),e.add(Ze(n)))}return e},[h]),[x,C]=(0,U.useState)([]),[w,T]=(0,U.useState)(!1),[O,k]=(0,U.useState)(!1),[M,N]=(0,U.useState)(null),[P,L]=(0,U.useState)(null),[R,de]=(0,U.useState)(null),[fe,pe]=(0,U.useState)([]),[me,_e]=(0,U.useState)(null),[ve,xe]=(0,U.useState)([]),[Se,Me]=(0,U.useState)([]),[Ne,Pe]=(0,U.useState)(null),[Re,W]=(0,U.useState)(!1),[ze,Be]=(0,U.useState)(null),[Ve,G]=(0,U.useState)(null),[K,q]=(0,U.useState)(!1),[J,He]=(0,U.useState)(!1),[Y,Ue]=(0,U.useState)(`remote`),[We,Ge]=(0,U.useState)(``),[qe,Je]=(0,U.useState)(``),[Ye,Xe]=(0,U.useState)(``),[rt,it]=(0,U.useState)(``),[ot,vt]=(0,U.useState)(``),[yt,Z]=(0,U.useState)(null),[bt,xt]=(0,U.useState)(!1),St=(0,U.useMemo)(()=>x.filter(e=>{let t=Ze(e);return!b.has(e.alias)&&!b.has(t)}),[x,b]),[Ct,kt]=(0,U.useState)(null),[jt,Mt]=(0,U.useState)(null),[Nt,Pt]=(0,U.useState)(null),[Ft,It]=(0,U.useState)(!1),[Lt,Rt]=(0,U.useState)(!1),[Q,zt]=(0,U.useState)(!1),[Bt,Vt]=(0,U.useState)(null),[Ht,Ut]=(0,U.useState)(!1),[Wt,Gt]=(0,U.useState)(String(Ke)),[Kt,qt]=(0,U.useState)(null),Jt=o(u()),[Yt,Xt]=(0,U.useState)(!1),Zt=y(e=>e.defaultAdvertisedEndpointKey),Qt=y(e=>e.setDefaultAdvertisedEndpointKey),$t=t===`owner`,en=e?R?.mode===`network-accessible`:r===`remote-reachable`,tn=Wt.trim(),nn=Number(tn),rn=/^\d+$/u.test(tn)&&Number.isInteger(nn)&&nn>=1&&nn<=65535,an=(0,U.useMemo)(()=>{if(!Bt)return null;if(!rn||nn===Ke)return Bt.httpBaseUrl;try{let e=new URL(Bt.httpBaseUrl);return e.port=String(nn),e.toString().replace(/\/$/u,``)}catch{return Bt.httpBaseUrl}},[rn,nn,Bt]),on=(0,U.useCallback)(async t=>{if(e){It(!0),_e(null);try{de(await e.setServerExposureMode(t?`network-accessible`:`local-only`)),Rt(!1),It(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to update network exposure.`;Rt(!1),_e(t),j.add(A({type:`error`,title:`Could not update network access`,description:t})),It(!1)}}},[e]),sn=(0,U.useCallback)(()=>{Kt!==null&&on(Kt===`network-accessible`)},[on,Kt]),cn=(0,U.useCallback)(async()=>{if(e&&rn){zt(!0),_e(null);try{de(await e.setTailscaleServeEnabled({enabled:!0,port:nn})),Vt(null)}catch(e){let t=e instanceof Error?e.message:`Failed to configure Tailscale HTTPS.`;_e(t),j.add(A({type:`error`,title:`Could not set up Tailscale HTTPS`,description:t}))}finally{zt(!1)}}},[e,rn,nn]),ln=(0,U.useCallback)(e=>{Gt(String(R?.tailscaleServePort??Ke)),Vt(e)},[R?.tailscaleServePort]),un=(0,U.useCallback)(async()=>{if(e){zt(!0),_e(null);try{de(await e.setTailscaleServeEnabled({enabled:!1,port:R?.tailscaleServePort??Ke})),Ut(!1)}catch(e){let t=e instanceof Error?e.message:`Failed to disable Tailscale HTTPS.`;_e(t),j.add(A({type:`error`,title:`Could not disable Tailscale HTTPS`,description:t}))}finally{zt(!1)}}},[e,R?.tailscaleServePort]),dn=(0,U.useCallback)(e=>{Ut(!0)},[]),fn=(0,U.useCallback)(async e=>{Be(e),Pe(null);try{await I(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke pairing link.`;Pe(t),j.add(A({type:`error`,title:`Could not revoke pairing link`,description:t}))}finally{Be(null)}},[]),pn=(0,U.useCallback)(async e=>{G(e),Pe(null);try{await F(e)}catch(e){let t=e instanceof Error?e.message:`Failed to revoke client access.`;Pe(t),j.add(A({type:`error`,title:`Could not revoke client access`,description:t}))}finally{G(null)}},[]),mn=(0,U.useCallback)(async()=>{q(!0),Pe(null);try{let e=await te();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.`;Pe(t),j.add(A({type:`error`,title:`Could not revoke other clients`,description:t}))}finally{q(!1)}},[]),hn=(0,U.useCallback)(async()=>{if(Y===`ssh`){xt(!0),Z(null);try{let e=await c(Qe({host:Ye,username:rt,port:ot}),{label:``});Ge(``),Je(``),Xe(``),it(``),vt(``),He(!1),j.add({type:`success`,title:`Environment connected`,description:`${e.label} is ready over an SSH-managed tunnel.`})}catch(e){Z(tt(e))}finally{xt(!1)}return}xt(!0),Z(null);try{let e=await l({label:``,...et({host:We,pairingCode:qe})});Ge(``),Je(``),Xe(``),it(``),vt(``),He(!1),j.add({type:`success`,title:`Backend added`,description:`${e.label} is now saved and will reconnect on app startup.`})}catch(e){let t=e instanceof Error?e.message:`Failed to add backend.`;Z(t),j.add(A({type:`error`,title:`Could not add backend`,description:t}))}finally{xt(!1)}},[We,Y,qe,Ye,ot,rt]),gn=(0,U.useCallback)(async e=>{kt(e),Z(null);try{await f(e)}catch(e){let t=e instanceof Error?e.message:`Failed to connect backend.`;Z(t),j.add(A({type:`error`,title:`Could not connect backend`,description:t}))}finally{kt(null)}},[]),_n=(0,U.useCallback)(async e=>{Mt(e),Z(null);try{await s(e)}catch(e){let t=e instanceof Error?e.message:`Failed to disconnect backend.`;Z(t),j.add(A({type:`error`,title:`Could not disconnect backend`,description:t}))}finally{Mt(null)}},[]),vn=(0,U.useCallback)(async e=>{Pt(e),Z(null);try{await a(e)}catch(e){let t=e instanceof Error?e.message:`Failed to remove backend.`;Z(t),j.add(A({type:`error`,title:`Could not remove backend`,description:t}))}finally{Pt(null)}},[]),yn=(0,U.useCallback)(async()=>{if(!e){C([]),T(!1),N(null);return}k(!0),N(null);try{C(await e.discoverSshHosts()),T(!0)}catch(e){N(e instanceof Error?e.message:`Failed to discover SSH hosts.`),T(!0)}finally{k(!1)}},[e]),bn=(0,U.useCallback)(async(e,t)=>{L(e.alias),Y===`ssh`?Z(null):N(null);try{let n=await c(e,t===void 0?void 0:{label:t});Xe(``),it(``),vt(``),He(!1),j.add({type:`success`,title:_[e.alias]?`Environment reconnected`:`Environment connected`,description:`${n.label} is ready over an SSH-managed tunnel.`})}catch(e){let t=tt(e);Y===`ssh`?Z(t):N(t)}finally{L(null)}},[Y,_]);(0,U.useEffect)(()=>{!e||!J||Y!==`ssh`||w||O||yn()},[J,e,w,O,yn,Y]),(0,U.useEffect)(()=>{if(e){n(`owner`);return}let t=!1;return ee().then(e=>{t||(n(e.authenticated?e.role??null:null),d(e.auth.policy))}).catch(()=>{t||(n(null),d(null))}),()=>{t=!0}},[e]),(0,U.useEffect)(()=>{if(!$t)return;let t=!1;W(!0);let n=p().client.server.subscribeAuthAccess(e=>{if(!t){switch(e.type){case`snapshot`:xe(st(e.payload.pairingLinks.map(e=>lt(e)))),Me(ct(e.payload.clientSessions.map(e=>ut(e))));break;case`pairingLinkUpserted`:xe(t=>dt(t,lt(e.payload)));break;case`pairingLinkRemoved`:xe(t=>ft(t,e.payload.id));break;case`clientUpserted`:Me(t=>pt(t,ut(e.payload)));break;case`clientRemoved`:Me(t=>mt(t,e.payload.sessionId));break}Pe(null),W(!1)}},{onResubscribe:()=>{t||W(!0)}});return e?(e.getServerExposureState().then(e=>{t||de(e)}).catch(e=>{t||_e(e instanceof Error?e.message:`Failed to load network exposure state.`)}),e.getAdvertisedEndpoints().then(e=>{t||pe(e)}).catch(e=>{t||_e(e instanceof Error?e.message:`Failed to load reachable endpoints.`)})):(de(null),p().client.server.getAdvertisedEndpoints().then(e=>{t||pe(e)}).catch(e=>{t||_e(e instanceof Error?e.message:`Failed to load reachable endpoints.`)})),()=>{t=!0,n()}},[$t,e]),(0,U.useEffect)(()=>{$t||(W(!1),xe([]),Me([]),Pe(null),de(null),pe([]),_e(null))},[$t]);let xn=(0,U.useMemo)(()=>ve.filter(e=>e.role===`client`),[ve]),$=(0,U.useMemo)(()=>fe.find(gt)??null,[fe]),Sn=(0,U.useMemo)(()=>en?fe.filter(e=>!gt(e)):[],[fe,en]),Cn=(0,U.useMemo)(()=>$?[...Sn,$]:Sn,[$,Sn]),wn=en||$?.status===`available`,Tn=(0,U.useMemo)(()=>ht(Sn,Zt),[Zt,Sn]),En=(0,U.useMemo)(()=>Tn??ht($?[$]:[],Zt),[Zt,Tn,$]),Dn=En?_t(En):null,On=(0,U.useCallback)(e=>{Qt(_t(e))},[Qt]),kn=(0,U.useCallback)(e=>{let t=$e(e);if(t){Ge(t.host),Je(t.pairingCode);return}Ge(e)},[]),An=e=>{let t=Y===e.mode;return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t,className:S(`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:bt,onClick:()=>{Ue(e.mode)},children:[e.icon?(0,X.jsx)(`span`,{className:S(`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,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-muted-foreground`,children:e.description})]})]})};return(0,X.jsxs)(Ie,{children:[$t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Fe,{title:`Manage local backend`,children:[Jt?(0,X.jsx)(H,{title:`Version drift`,description:(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,X.jsx)(be,{className:`size-3.5 shrink-0`}),`Client `,Jt.clientVersion,`, server`,` `,Jt.serverVersion,`. Sync them if RPC calls or reconnects fail.`]})}):null,e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{title:`Network access`,description:en?(0,X.jsx)(Dt,{endpoint:Tn,hiddenEndpointCount:Math.max(Sn.length-1,0),expanded:Yt,onToggleExpanded:()=>Xt(e=>!e),fallback:R?.endpointUrl?`Reachable at ${R.endpointUrl}`:R?.advertisedHost?`Exposed on all interfaces. Pairing links use ${R.advertisedHost}.`:`Exposed on all interfaces.`}):R?`Limited to this machine.`:`Loading…`,status:me?(0,X.jsx)(`span`,{className:`block text-destructive`,children:me}):null,control:(0,X.jsx)(ie,{checked:R?.mode===`network-accessible`,disabled:!R||Ft,onCheckedChange:e=>{qt(e?`network-accessible`:`local-only`),Rt(!0)},"aria-label":`Enable network access`})}),(e=>Yt?Sn.map(t=>(0,X.jsx)(Et,{endpoint:t,isDefault:_t(t)===Dn,presentation:e,onSetDefault:On,onSetupTailscaleServe:ln,onDisableTailscaleServe:dn,isUpdatingTailscaleServe:Q},t.id)):null)(`endpoint-rail`),(0,X.jsx)(H,{title:`Tailscale HTTPS`,description:$?$.status===`available`?$.httpBaseUrl:`Use Tailscale Serve to expose this backend through a MagicDNS HTTPS URL.`:`Start Tailscale to set up HTTPS access through MagicDNS.`,control:$?(0,X.jsx)(ie,{checked:$.status===`available`,disabled:Q,onCheckedChange:e=>{if(e){ln($);return}dn($)},"aria-label":`Enable Tailscale HTTPS`}):null})]}):(0,X.jsx)(H,{title:`Network access`,description:r===`remote-reachable`?`This backend is already configured for remote access. Network exposure changes must be made where the server is launched.`:`This backend is only reachable on this machine. Restart it with a non-loopback host to enable remote pairing.`,control:(0,X.jsxs)(D,{children:[(0,X.jsx)(v,{render:(0,X.jsx)(`span`,{className:`inline-flex`,children:(0,X.jsx)(ie,{checked:en,disabled:!0,"aria-label":`Enable network access`})})}),(0,X.jsx)(m,{side:`top`,children:`Network exposure changes restart the backend and must be controlled where the server process is launched.`})]})})]}),wn?(0,X.jsx)(Fe,{title:`Authorized clients`,headerAction:(0,X.jsx)(wt,{clientSessions:Se,isRevokingOtherClients:K,onRevokeOtherClients:mn}),children:(e=>(0,X.jsxs)(X.Fragment,{children:[Ne?(0,X.jsx)(`div`,{className:at(e),children:(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:Ne})}):null,(0,X.jsx)(Tt,{endpointUrl:R?.endpointUrl,endpoints:Cn,defaultEndpointKey:Dn,presentation:e,isLoading:Re,pairingLinks:xn,clientSessions:Se,revokingPairingLinkId:ze,revokingClientSessionId:Ve,onRevokePairingLink:fn,onRevokeClientSession:pn})]}))(`current`)}):null,(0,X.jsx)(Ae,{open:Lt,onOpenChange:e=>{Ft||Rt(e)},onOpenChangeComplete:e=>{e||qt(null)},children:(0,X.jsxs)(De,{children:[(0,X.jsxs)(we,{children:[(0,X.jsx)(ke,{children:Kt===`network-accessible`?`Enable network access?`:`Disable network access?`}),(0,X.jsx)(Oe,{children:Kt===`network-accessible`?`Ryco will restart to expose this environment over the network.`:`Ryco will restart and limit this environment back to this machine.`})]}),(0,X.jsxs)(Te,{children:[(0,X.jsx)(Ee,{disabled:Ft,render:(0,X.jsx)(E,{variant:`outline`,disabled:Ft}),children:`Cancel`}),(0,X.jsx)(E,{variant:Kt===`local-only`?`destructive`:`default`,onClick:sn,disabled:Kt===null||Ft,children:Ft?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{className:`size-3.5`}),`Restarting…`]}):Kt===`network-accessible`?`Restart and enable`:`Restart and disable`})]})]})}),(0,X.jsx)(Ae,{open:Ht,onOpenChange:e=>{Q||Ut(e)},children:(0,X.jsxs)(De,{children:[(0,X.jsxs)(we,{children:[(0,X.jsx)(ke,{children:`Disable Tailscale HTTPS?`}),(0,X.jsx)(Oe,{children:`Ryco will restart the local backend without Tailscale Serve.`})]}),(0,X.jsxs)(Te,{children:[(0,X.jsx)(Ee,{disabled:Q,render:(0,X.jsx)(E,{variant:`outline`,disabled:Q}),children:`Cancel`}),(0,X.jsx)(E,{variant:`destructive`,onClick:()=>void un(),disabled:Q,children:Q?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{className:`size-3.5`}),`Restarting…`]}):`Restart and disable`})]})]})}),(0,X.jsx)(ae,{open:Bt!==null,onOpenChange:e=>{Q||e||Vt(null)},children:(0,X.jsxs)(le,{className:`max-w-md`,children:[(0,X.jsxs)(he,{children:[(0,X.jsx)(ue,{children:`Set up Tailscale HTTPS?`}),(0,X.jsx)(ge,{children:`Ryco will restart the local backend with Tailscale Serve enabled and ask Tailscale to proxy HTTPS traffic to this backend.`})]}),(0,X.jsxs)(ce,{className:`space-y-4`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`HTTPS port`}),(0,X.jsx)(V,{className:`mt-2`,type:`number`,inputMode:`numeric`,min:1,max:65535,step:1,value:Wt,onChange:e=>Gt(e.target.value),disabled:Q})]}),rn?null:(0,X.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:`Enter a port from 1 to 65535.`}),(0,X.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-muted/20 px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`HTTPS endpoint`}),(0,X.jsx)(`p`,{className:`mt-1 truncate text-sm text-foreground`,title:an??void 0,children:an??`Pending MagicDNS endpoint`})]})]}),(0,X.jsxs)(re,{children:[(0,X.jsx)(z,{disabled:Q,render:(0,X.jsx)(E,{variant:`outline`,disabled:Q}),children:`Cancel`}),(0,X.jsx)(E,{onClick:()=>void cn(),disabled:Q||!rn,children:Q?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{className:`size-3.5`}),`Restarting…`]}):`Enable`})]})]})})]}):(0,X.jsx)(Fe,{title:`Local backend access`,children:(0,X.jsx)(H,{title:`Owner tools`,description:`Pairing links and client-session management are only available to owner sessions for this backend.`})}),(0,X.jsxs)(Fe,{title:`Remote environments`,headerAction:(0,X.jsxs)(ae,{open:J,onOpenChange:e=>{He(e),e||Z(null)},children:[(0,X.jsx)(se,{render:(0,X.jsxs)(E,{size:`xs`,variant:`outline`,children:[(0,X.jsx)(ye,{className:`size-3`}),`Add environment`]})}),(0,X.jsxs)(le,{className:`max-h-[80dvh] sm:max-w-3xl`,children:[(0,X.jsxs)(he,{children:[(0,X.jsx)(ue,{children:`Add Environment`}),(0,X.jsx)(ge,{children:`Pair another environment to this client.`})]}),(0,X.jsx)(ce,{children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[An({mode:`remote`,title:`Remote link`,description:`Enter a backend host and pairing code.`,icon:(0,X.jsx)(Le,{"aria-hidden":!0,className:`size-4`})}),e?An({mode:`ssh`,title:`SSH`,description:`Use local SSH config, agent, and tunnels for the backend.`,icon:(0,X.jsx)(ne,{"aria-hidden":!0,className:`size-4`})}):null]}),(0,X.jsx)(je,{children:Y===`ssh`?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`SSH host or alias`}),(0,X.jsx)(V,{value:Ye,onChange:e=>Xe(e.target.value),placeholder:`Search hosts or type devbox`,disabled:bt,spellCheck:!1})]}),(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem]`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Username`}),(0,X.jsx)(V,{value:rt,onChange:e=>it(e.target.value),placeholder:`root`,disabled:bt,spellCheck:!1})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Port`}),(0,X.jsx)(V,{value:ot,onChange:e=>vt(e.target.value),placeholder:`22`,inputMode:`numeric`,disabled:bt,spellCheck:!1})]})]}),yt||M?(0,X.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:yt??M}):null,(0,X.jsxs)(E,{variant:`outline`,className:`w-full`,disabled:bt,onClick:()=>void hn(),children:[(0,X.jsx)(ye,{className:`size-3.5`}),bt?`Adding…`:`Add environment`]})]}),(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border/60`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border/60 bg-muted/30 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:`Suggested hosts`}),(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`From SSH config and known hosts`})]}),(0,X.jsxs)(E,{size:`xs`,variant:`ghost`,disabled:O,onClick:()=>void yn(),children:[O?(0,X.jsx)(B,{className:`size-3 animate-spin`}):(0,X.jsx)(B,{className:`size-3`}),`Refresh`]})]}),(0,X.jsx)(Ce,{scrollFade:!0,className:`max-h-56`,children:(0,X.jsxs)(`div`,{children:[St.map(e=>(0,X.jsx)(At,{target:e,connectingHostAlias:P,onConnect:e=>void bn(e)},`${e.alias}:${e.hostname}:${e.port??``}`)),w&&!O&&St.length===0?(0,X.jsx)(`div`,{className:nt,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No new SSH hosts were discovered.`})}):null]})})]})]}):(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Host`}),(0,X.jsx)(V,{value:We,onChange:e=>kn(e.target.value),placeholder:`backend.example.com`,disabled:bt,spellCheck:!1})]}),(0,X.jsxs)(`label`,{className:`block`,children:[(0,X.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Pairing code`}),(0,X.jsx)(V,{value:qe,onChange:e=>Je(e.target.value),placeholder:`PAIRCODE`,disabled:bt,spellCheck:!1})]})]}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`span`,{className:`mt-1 block text-[11px] text-muted-foreground`,children:`Paste a full pairing URL here to fill both fields automatically. The pairing code is not kept; the browser stores a bearer token for 7 days.`})})]}),yt?(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:yt}):null,(0,X.jsxs)(E,{variant:`outline`,className:`w-full`,disabled:bt,onClick:()=>void hn(),children:[(0,X.jsx)(ye,{className:`size-3.5`}),bt?`Adding…`:`Add environment`]})]})})]})})]})]}),children:[g.map(e=>(0,X.jsx)(Ot,{environmentId:e,reconnectingEnvironmentId:Ct,disconnectingEnvironmentId:jt,removingEnvironmentId:Nt,onConnect:gn,onDisconnect:_n,onRemove:vn},e)),g.length===0?(0,X.jsx)(`div`,{className:nt,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No remote environments yet. Click “Add environment” to pair another environment.`})}):null]})]})}function Mt(e){return e.status!==`unavailable`}function Nt(e){j.add({type:`success`,title:e===`hosted-link`?`Hosted app link copied`:e===`link`?`Pairing URL copied`:`Pairing code copied`,description:e===`hosted-link`?`Open it in the browser on the device you want to connect.`:e===`link`?`Open it in the client you want to pair to this environment.`:`Paste it into another client to finish pairing.`})}function Pt(e){return xt(e)?`hosted-link`:`link`}function Ft(e){return!xt(e.url)}function It(e){return xt(e.url)}function Lt(e){return e.currentTarget.select()}function Rt(e){return e.currentTarget.select()}function Q(e){return e!==null}export{jt as ConnectionsSettings};
@@ -1 +1 @@
1
- import{i as e,t}from"./react-PSPkXoKo.js";import{t as n}from"./compiler-runtime-BNrXlsa1.js";import{Jt as r,en as i}from"./projectAtoms-DUEBb7Zz.js";import{Ni as a,Sr as o,Xr as s,br as c}from"./composerDraftStore-D12lUSfh.js";import{Ht as l,Vt as u,_ as d,zt as f}from"./providerIconUtils-uhWb4bdg.js";import{t as p}from"./play-QloDGe4R.js";import{t as m}from"./refresh-cw-DkBMGllm.js";import{t as h}from"./triangle-alert-DJef_Uvh.js";import{a as g,i as _,n as v}from"./settingsLayout-D22Mm0u3.js";var y=s(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),b=e(t(),1),x=n();function S(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||r===0?n.toFixed(0):n.toFixed(1)} ${t[r]}`}function C(e){return!Number.isFinite(e)||e<=0?`0 ms`:e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(+(e<1e4))} s`:`${(e/6e4).toFixed(1)} min`}function w(e){return e===void 0||!Number.isFinite(e)?`n/a`:`${Math.max(0,Math.min(100,e)).toFixed(1)}%`}function T(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return e;let r=Math.max(0,t-n);return r<1e3?`just now`:r<6e4?`${Math.floor(r/1e3)}s ago`:r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`}function E(e){return e.map(e=>({label:e.sampledAt,value:e.memory.rssBytes}))}function D(e){return e.map(e=>({label:e.sampledAt,value:e.cpu.utilizationPercent??0}))}function O(e){return e.map(e=>({label:e.label,value:e.count}))}function k(e){return e.slice(0,8).map(e=>({label:e.name,value:e.count}))}function A(e){let t=e.failures.latest[0];return t?t.message:`No failures`}var j=a(),M=5e3;function N(e){let t=(0,x.c)(33),{points:n,formatValue:r}=e,i;bb0:{if(n.length===0){i=``;break bb0}let e;t[0]===n?e=t[1]:(e=Math.max(...n.map(P),1),t[0]=n,t[1]=e);let r=e,a;if(t[2]!==r||t[3]!==n){let e;t[5]!==r||t[6]!==n.length?(e=(e,t)=>{let i=n.length===1?320:t/(n.length-1)*320,a=96-e.value/r*84-6;return`${t===0?`M`:`L`}${i.toFixed(2)},${a.toFixed(2)}`},t[5]=r,t[6]=n.length,t[7]=e):e=t[7],a=n.map(e).join(` `),t[2]=r,t[3]=n,t[4]=a}else a=t[4];i=a}let a=i,o,s,c,l,u;if(t[8]!==r||t[9]!==n){let e=n.at(-1)?.value??0;u=`min-w-0`,c=`mb-2 flex items-baseline justify-between gap-3`,t[15]===n.length?l=t[16]:(l=(0,j.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground/70`,children:[n.length,` samples`]}),t[15]=n.length,t[16]=l),o=`font-mono text-xs text-foreground`,s=r(e),t[8]=r,t[9]=n,t[10]=o,t[11]=s,t[12]=c,t[13]=l,t[14]=u}else o=t[10],s=t[11],c=t[12],l=t[13],u=t[14];let d;t[17]!==o||t[18]!==s?(d=(0,j.jsx)(`span`,{className:o,children:s}),t[17]=o,t[18]=s,t[19]=d):d=t[19];let f;t[20]!==c||t[21]!==l||t[22]!==d?(f=(0,j.jsxs)(`div`,{className:c,children:[l,d]}),t[20]=c,t[21]=l,t[22]=d,t[23]=f):f=t[23];let p;t[24]===a?p=t[25]:(p=(0,j.jsx)(`path`,{d:a,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`}),t[24]=a,t[25]=p);let m;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,j.jsx)(`line`,{x1:`0`,y1:95,x2:320,y2:95,className:`stroke-border`}),t[26]=m):m=t[26];let h;t[27]===p?h=t[28]:(h=(0,j.jsxs)(`svg`,{viewBox:`0 0 320 96`,className:`h-24 w-full overflow-visible text-info`,role:`img`,"aria-label":`Diagnostics history chart`,children:[p,m]}),t[27]=p,t[28]=h);let g;return t[29]!==h||t[30]!==u||t[31]!==f?(g=(0,j.jsxs)(`div`,{className:u,children:[f,h]}),t[29]=h,t[30]=u,t[31]=f,t[32]=g):g=t[32],g}function P(e){return e.value}function F(e){let t=(0,x.c)(12),{points:n,formatValue:r}=e,i=r===void 0?String:r,a;t[0]===n?a=t[1]:(a=Math.max(...n.map(I),1),t[0]=n,t[1]=a);let o=a;if(n.length===0){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No data yet.`}),t[2]=e):e=t[2],e}let s;if(t[3]!==i||t[4]!==o||t[5]!==n){let e;t[7]!==i||t[8]!==o?(e=e=>(0,j.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_5rem] items-center gap-3 px-4 py-2.5`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`mb-1 truncate text-[12px] font-medium`,children:e.label}),(0,j.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,j.jsx)(`div`,{className:`h-full rounded-full bg-info`,style:{width:`${Math.max(4,e.value/o*100)}%`}})})]}),(0,j.jsx)(`div`,{className:`text-right font-mono text-[11px] text-muted-foreground`,children:i(e.value)})]},e.label),t[7]=i,t[8]=o,t[9]=e):e=t[9],s=n.map(e),t[3]=i,t[4]=o,t[5]=n,t[6]=s}else s=t[6];let c;return t[10]===s?c=t[11]:(c=(0,j.jsx)(`div`,{className:`divide-y divide-border/60`,children:s}),t[10]=s,t[11]=c),c}function I(e){return e.value}function L(e){let t=(0,x.c)(10),{label:n,value:r,detail:i}=e,a;t[0]===n?a=t[1]:(a=(0,j.jsx)(`div`,{className:`truncate text-[11px] font-medium text-muted-foreground uppercase tracking-[0.08em]`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,j.jsx)(`div`,{className:`mt-1 truncate text-[15px] font-semibold text-foreground`,children:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,j.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,j.jsxs)(`div`,{className:`min-w-0 border-border/60 border-t px-4 py-3 first:border-t-0 sm:px-5`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function R(e){let t=(0,x.c)(5),{value:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,j.jsx)(`summary`,{className:`cursor-pointer select-none text-[11px] text-muted-foreground hover:text-foreground`,children:`raw`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=JSON.stringify(n,null,2),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,j.jsxs)(`details`,{className:`group`,children:[r,(0,j.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto rounded-md bg-muted/60 p-3 text-[11px] leading-relaxed`,children:i})]}),t[3]=i,t[4]=a),a}function z(e){let t=(0,x.c)(5),{spans:n}=e;if(n.length===0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No spans retained yet.`}),t[0]=e):e=t[0],e}let r;t[1]===n?r=t[2]:(r=n.slice(0,10).map(B),t[1]=n,t[2]=r);let i;return t[3]===r?i=t[4]:(i=(0,j.jsx)(`div`,{className:`divide-y divide-border/60`,children:r}),t[3]=r,t[4]=i),i}function B(e){return(0,j.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 sm:grid-cols-[minmax(0,1fr)_6rem_5rem] sm:items-start`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.name}),(0,j.jsx)(d,{size:`sm`,variant:e.status===`success`?`outline`:`error`,children:e.status})]}),(0,j.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,children:[e.source,` / `,e.kind,` / `,e.spanId]}),e.failureMessage?(0,j.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[11px] text-destructive`,children:e.failureMessage}):null,(0,j.jsx)(`div`,{className:`mt-2`,children:(0,j.jsx)(R,{value:e})})]}),(0,j.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground sm:text-right`,children:C(e.durationMs)}),(0,j.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground sm:text-right`,children:T(e.endTime)})]},e.id)}function V(e){let t=(0,x.c)(14),{snapshot:n,error:r}=e;if(!r&&(!n||n.warnings.length===0))return null;let i=r?`error`:`warning`,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,j.jsx)(h,{}),t[0]=a):a=t[0];let o=r?`Diagnostics refresh failed`:`Diagnostics warnings`,s;t[1]===o?s=t[2]:(s=(0,j.jsx)(l,{children:o}),t[1]=o,t[2]=s);let c;t[3]===r?c=t[4]:(c=r?(0,j.jsx)(`span`,{children:r}):null,t[3]=r,t[4]=c);let d;t[5]===n?.warnings?d=t[6]:(d=n?.warnings.slice(0,4).map(H),t[5]=n?.warnings,t[6]=d);let p;t[7]!==c||t[8]!==d?(p=(0,j.jsxs)(u,{children:[c,d]}),t[7]=c,t[8]=d,t[9]=p):p=t[9];let m;return t[10]!==i||t[11]!==s||t[12]!==p?(m=(0,j.jsxs)(f,{variant:i,children:[a,s,p]}),t[10]=i,t[11]=s,t[12]=p,t[13]=m):m=t[13],m}function H(e){return(0,j.jsxs)(`span`,{children:[e.message,e.count?` (${e.count})`:``]},`${e.code}:${e.source??``}`)}function U(){let[e,t]=(0,b.useState)(null),[n,a]=(0,b.useState)(null),[s,l]=(0,b.useState)(!0),[u,f]=(0,b.useState)(!1),h=(0,b.useRef)(!1),x=(0,b.useRef)(!1),P=(0,b.useRef)(!1),I=i(),B=g(1e3),H=(0,b.useCallback)(async()=>{if(!h.current){h.current=!0,l(e=>e&&!x.current);try{let e=await r().server.getDiagnosticsSnapshot();if(P.current)return;t(e),a(null),x.current=!0}catch(e){if(P.current)return;a(e instanceof Error?e.message:`Unable to refresh diagnostics.`)}finally{h.current=!1,P.current||l(!1)}}},[]);(0,b.useEffect)(()=>{if(P.current=!1,H(),u)return()=>{P.current=!0};let e=window.setInterval(()=>void H(),M);return()=>{P.current=!0,window.clearInterval(e)}},[u,H]);let U=(0,b.useMemo)(()=>E(e?.resources.history??[]),[e]),W=(0,b.useMemo)(()=>D(e?.resources.history??[]),[e]),G=e?A(e):`No snapshot`;return(0,j.jsxs)(v,{children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h1`,{className:`text-base font-semibold`,children:`Diagnostics`}),(0,j.jsx)(`p`,{className:`mt-1 text-muted-foreground text-xs`,children:e?`Updated ${T(e.generatedAt,B)}`:`Waiting for snapshot`})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(c,{size:`xs`,variant:`outline`,onClick:()=>f(e=>!e),children:[u?(0,j.jsx)(p,{className:`size-3.5`}):(0,j.jsx)(y,{className:`size-3.5`}),u?`Resume`:`Pause`]}),(0,j.jsxs)(c,{size:`xs`,variant:`outline`,onClick:()=>void H(),disabled:s,children:[(0,j.jsx)(m,{className:o(`size-3.5`,s&&`animate-spin`)}),`Refresh`]})]})]}),(0,j.jsx)(V,{snapshot:e,error:n}),(0,j.jsx)(_,{title:`Overview`,children:(0,j.jsxs)(`div`,{className:`grid sm:grid-cols-2 lg:grid-cols-3`,children:[(0,j.jsx)(L,{label:`Uptime`,value:e?C(e.uptimeMs):`n/a`,detail:e?`Started ${T(e.serverStartedAt,B)}`:void 0}),(0,j.jsx)(L,{label:`Memory`,value:e?S(e.resources.current.memory.rssBytes):`n/a`,detail:e?`${S(e.resources.current.memory.heapUsedBytes)} heap used`:void 0}),(0,j.jsx)(L,{label:`CPU`,value:e?w(e.resources.current.cpu.utilizationPercent):`n/a`,detail:e?.resources.current.eventLoopDelayMs===void 0?void 0:`${C(e.resources.current.eventLoopDelayMs)} event loop delay`}),(0,j.jsx)(L,{label:`Activity`,value:`${e?.liveProcesses.providers.filter(e=>e.enabled).length??0} providers`,detail:`${e?.liveProcesses.terminals.length??0} terminal sessions`}),(0,j.jsx)(L,{label:`Tracing`,value:`${e?.tracing.retainedSpanCount??0} spans`,detail:e?`${e.limits.fileTailBytes/1024} KB file tail`:void 0}),(0,j.jsx)(L,{label:`Latest failure`,value:G})]})}),(0,j.jsx)(_,{title:`Resource history`,children:(0,j.jsxs)(`div`,{className:`grid gap-0 divide-y divide-border/60 lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[(0,j.jsxs)(`div`,{className:`min-w-0 p-4`,children:[(0,j.jsx)(`div`,{className:`mb-1 text-[12px] font-semibold`,children:`RSS memory`}),(0,j.jsx)(N,{points:U,formatValue:S})]}),(0,j.jsxs)(`div`,{className:`min-w-0 p-4`,children:[(0,j.jsx)(`div`,{className:`mb-1 text-[12px] font-semibold`,children:`CPU utilization`}),(0,j.jsx)(N,{points:W,formatValue:e=>`${e.toFixed(1)}%`})]})]})}),(0,j.jsxs)(_,{title:`Tracing diagnostics`,children:[(0,j.jsxs)(`div`,{className:`grid gap-0 divide-y divide-border/60 lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Top span names`}),(0,j.jsx)(F,{points:k(e?.tracing.topSpanNames??[])})]}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Duration buckets`}),(0,j.jsx)(F,{points:O(e?.tracing.durationBuckets??[])})]})]}),(0,j.jsxs)(`div`,{className:`border-border/60 border-t`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Slowest spans`}),(0,j.jsx)(z,{spans:e?.tracing.slowestSpans??[]})]})]}),(0,j.jsx)(_,{title:`Failures`,children:(0,j.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[(e?.failures.latest??[]).slice(0,8).map(e=>(0,j.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 sm:grid-cols-[minmax(0,1fr)_6rem]`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(d,{size:`sm`,variant:`error`,children:e.category}),(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.message})]}),(0,j.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,children:[e.source,` / `,e.signature]}),(0,j.jsx)(`div`,{className:`mt-2`,children:(0,j.jsx)(R,{value:e.raw??e})})]}),(0,j.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground sm:text-right`,children:T(e.occurredAt,B)})]},e.id)),e&&e.failures.latest.length===0?(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No failures retained.`}):null]})}),(0,j.jsx)(_,{title:`Live activity`,children:(0,j.jsxs)(`div`,{className:`grid gap-0 divide-y divide-border/60 lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Providers`}),(0,j.jsx)(`div`,{className:`divide-y divide-border/60`,children:(e?.liveProcesses.providers??[]).map(e=>(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`truncate text-[13px] font-medium`,children:e.displayName??e.instanceId}),(0,j.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.driver})]}),(0,j.jsx)(d,{size:`sm`,variant:e.status===`error`?`error`:e.status===`warning`?`warning`:`outline`,children:e.status})]},e.instanceId))})]}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Terminals and slow RPCs`}),(0,j.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[(e?.liveProcesses.terminals??[]).map(e=>(0,j.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.terminalId}),(0,j.jsx)(d,{size:`sm`,variant:e.status===`error`?`error`:`outline`,children:e.status})]}),(0,j.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,children:[`pid `,e.pid??`n/a`,` / subprocess`,` `,e.hasRunningSubprocess?`yes`:`no`]})]},`${e.threadId}:${e.terminalId}`)),I.map(e=>(0,j.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,j.jsx)(`div`,{className:`truncate text-[13px] font-medium`,children:e.tag}),(0,j.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[`slow ack / `,T(e.startedAt,B)]})]},e.requestId)),(e?.liveProcesses.terminals.length??0)===0&&I.length===0?(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No live terminal or slow RPC activity.`}):null]})]})]})})]})}export{U as DiagnosticsSettings};
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{t as n}from"./compiler-runtime-BNrXlsa1.js";import{Jt as r,en as i}from"./projectAtoms-DXXpuERK.js";import{Pi as a,Sr as o,Zr as s,br as c}from"./composerDraftStore-DpPEQ6BN.js";import{It as l,Rt as u,_ as d,zt as f}from"./providerIconUtils-D-DFhem2.js";import{t as p}from"./play-DI2LZohg.js";import{t as m}from"./refresh-cw-BsQTNBXl.js";import{t as h}from"./triangle-alert-Bpz3xGu5.js";import{a as g,i as _,n as v}from"./settingsLayout-G5xVm-ZT.js";var y=s(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),b=e(t(),1),x=n();function S(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||r===0?n.toFixed(0):n.toFixed(1)} ${t[r]}`}function C(e){return!Number.isFinite(e)||e<=0?`0 ms`:e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(+(e<1e4))} s`:`${(e/6e4).toFixed(1)} min`}function w(e){return e===void 0||!Number.isFinite(e)?`n/a`:`${Math.max(0,Math.min(100,e)).toFixed(1)}%`}function T(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return e;let r=Math.max(0,t-n);return r<1e3?`just now`:r<6e4?`${Math.floor(r/1e3)}s ago`:r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`}function E(e){return e.map(e=>({label:e.sampledAt,value:e.memory.rssBytes}))}function D(e){return e.map(e=>({label:e.sampledAt,value:e.cpu.utilizationPercent??0}))}function O(e){return e.map(e=>({label:e.label,value:e.count}))}function k(e){return e.slice(0,8).map(e=>({label:e.name,value:e.count}))}function A(e){let t=e.failures.latest[0];return t?t.message:`No failures`}var j=a(),M=5e3;function N(e){let t=(0,x.c)(33),{points:n,formatValue:r}=e,i;bb0:{if(n.length===0){i=``;break bb0}let e;t[0]===n?e=t[1]:(e=Math.max(...n.map(P),1),t[0]=n,t[1]=e);let r=e,a;if(t[2]!==r||t[3]!==n){let e;t[5]!==r||t[6]!==n.length?(e=(e,t)=>{let i=n.length===1?320:t/(n.length-1)*320,a=96-e.value/r*84-6;return`${t===0?`M`:`L`}${i.toFixed(2)},${a.toFixed(2)}`},t[5]=r,t[6]=n.length,t[7]=e):e=t[7],a=n.map(e).join(` `),t[2]=r,t[3]=n,t[4]=a}else a=t[4];i=a}let a=i,o,s,c,l,u;if(t[8]!==r||t[9]!==n){let e=n.at(-1)?.value??0;u=`min-w-0`,c=`mb-2 flex items-baseline justify-between gap-3`,t[15]===n.length?l=t[16]:(l=(0,j.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground/70`,children:[n.length,` samples`]}),t[15]=n.length,t[16]=l),o=`font-mono text-xs text-foreground`,s=r(e),t[8]=r,t[9]=n,t[10]=o,t[11]=s,t[12]=c,t[13]=l,t[14]=u}else o=t[10],s=t[11],c=t[12],l=t[13],u=t[14];let d;t[17]!==o||t[18]!==s?(d=(0,j.jsx)(`span`,{className:o,children:s}),t[17]=o,t[18]=s,t[19]=d):d=t[19];let f;t[20]!==c||t[21]!==l||t[22]!==d?(f=(0,j.jsxs)(`div`,{className:c,children:[l,d]}),t[20]=c,t[21]=l,t[22]=d,t[23]=f):f=t[23];let p;t[24]===a?p=t[25]:(p=(0,j.jsx)(`path`,{d:a,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`}),t[24]=a,t[25]=p);let m;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,j.jsx)(`line`,{x1:`0`,y1:95,x2:320,y2:95,className:`stroke-border`}),t[26]=m):m=t[26];let h;t[27]===p?h=t[28]:(h=(0,j.jsxs)(`svg`,{viewBox:`0 0 320 96`,className:`h-24 w-full overflow-visible text-info`,role:`img`,"aria-label":`Diagnostics history chart`,children:[p,m]}),t[27]=p,t[28]=h);let g;return t[29]!==h||t[30]!==u||t[31]!==f?(g=(0,j.jsxs)(`div`,{className:u,children:[f,h]}),t[29]=h,t[30]=u,t[31]=f,t[32]=g):g=t[32],g}function P(e){return e.value}function F(e){let t=(0,x.c)(12),{points:n,formatValue:r}=e,i=r===void 0?String:r,a;t[0]===n?a=t[1]:(a=Math.max(...n.map(I),1),t[0]=n,t[1]=a);let o=a;if(n.length===0){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No data yet.`}),t[2]=e):e=t[2],e}let s;if(t[3]!==i||t[4]!==o||t[5]!==n){let e;t[7]!==i||t[8]!==o?(e=e=>(0,j.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_5rem] items-center gap-3 px-4 py-2.5`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`mb-1 truncate text-[12px] font-medium`,children:e.label}),(0,j.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,j.jsx)(`div`,{className:`h-full rounded-full bg-info`,style:{width:`${Math.max(4,e.value/o*100)}%`}})})]}),(0,j.jsx)(`div`,{className:`text-right font-mono text-[11px] text-muted-foreground`,children:i(e.value)})]},e.label),t[7]=i,t[8]=o,t[9]=e):e=t[9],s=n.map(e),t[3]=i,t[4]=o,t[5]=n,t[6]=s}else s=t[6];let c;return t[10]===s?c=t[11]:(c=(0,j.jsx)(`div`,{className:`divide-y divide-border/60`,children:s}),t[10]=s,t[11]=c),c}function I(e){return e.value}function L(e){let t=(0,x.c)(10),{label:n,value:r,detail:i}=e,a;t[0]===n?a=t[1]:(a=(0,j.jsx)(`div`,{className:`truncate text-[11px] font-medium text-muted-foreground uppercase tracking-[0.08em]`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,j.jsx)(`div`,{className:`mt-1 truncate text-[15px] font-semibold text-foreground`,children:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,j.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,children:i}):null,t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,j.jsxs)(`div`,{className:`min-w-0 border-border/60 border-t px-4 py-3 first:border-t-0 sm:px-5`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function R(e){let t=(0,x.c)(5),{value:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,j.jsx)(`summary`,{className:`cursor-pointer select-none text-[11px] text-muted-foreground hover:text-foreground`,children:`raw`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=JSON.stringify(n,null,2),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,j.jsxs)(`details`,{className:`group`,children:[r,(0,j.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto rounded-md bg-muted/60 p-3 text-[11px] leading-relaxed`,children:i})]}),t[3]=i,t[4]=a),a}function z(e){let t=(0,x.c)(5),{spans:n}=e;if(n.length===0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No spans retained yet.`}),t[0]=e):e=t[0],e}let r;t[1]===n?r=t[2]:(r=n.slice(0,10).map(B),t[1]=n,t[2]=r);let i;return t[3]===r?i=t[4]:(i=(0,j.jsx)(`div`,{className:`divide-y divide-border/60`,children:r}),t[3]=r,t[4]=i),i}function B(e){return(0,j.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 sm:grid-cols-[minmax(0,1fr)_6rem_5rem] sm:items-start`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.name}),(0,j.jsx)(d,{size:`sm`,variant:e.status===`success`?`outline`:`error`,children:e.status})]}),(0,j.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,children:[e.source,` / `,e.kind,` / `,e.spanId]}),e.failureMessage?(0,j.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[11px] text-destructive`,children:e.failureMessage}):null,(0,j.jsx)(`div`,{className:`mt-2`,children:(0,j.jsx)(R,{value:e})})]}),(0,j.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground sm:text-right`,children:C(e.durationMs)}),(0,j.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground sm:text-right`,children:T(e.endTime)})]},e.id)}function V(e){let t=(0,x.c)(14),{snapshot:n,error:r}=e;if(!r&&(!n||n.warnings.length===0))return null;let i=r?`error`:`warning`,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,j.jsx)(h,{}),t[0]=a):a=t[0];let o=r?`Diagnostics refresh failed`:`Diagnostics warnings`,s;t[1]===o?s=t[2]:(s=(0,j.jsx)(f,{children:o}),t[1]=o,t[2]=s);let c;t[3]===r?c=t[4]:(c=r?(0,j.jsx)(`span`,{children:r}):null,t[3]=r,t[4]=c);let d;t[5]===n?.warnings?d=t[6]:(d=n?.warnings.slice(0,4).map(H),t[5]=n?.warnings,t[6]=d);let p;t[7]!==c||t[8]!==d?(p=(0,j.jsxs)(u,{children:[c,d]}),t[7]=c,t[8]=d,t[9]=p):p=t[9];let m;return t[10]!==i||t[11]!==s||t[12]!==p?(m=(0,j.jsxs)(l,{variant:i,children:[a,s,p]}),t[10]=i,t[11]=s,t[12]=p,t[13]=m):m=t[13],m}function H(e){return(0,j.jsxs)(`span`,{children:[e.message,e.count?` (${e.count})`:``]},`${e.code}:${e.source??``}`)}function U(){let[e,t]=(0,b.useState)(null),[n,a]=(0,b.useState)(null),[s,l]=(0,b.useState)(!0),[u,f]=(0,b.useState)(!1),h=(0,b.useRef)(!1),x=(0,b.useRef)(!1),P=(0,b.useRef)(!1),I=i(),B=g(1e3),H=(0,b.useCallback)(async()=>{if(!h.current){h.current=!0,l(e=>e&&!x.current);try{let e=await r().server.getDiagnosticsSnapshot();if(P.current)return;t(e),a(null),x.current=!0}catch(e){if(P.current)return;a(e instanceof Error?e.message:`Unable to refresh diagnostics.`)}finally{h.current=!1,P.current||l(!1)}}},[]);(0,b.useEffect)(()=>{if(P.current=!1,H(),u)return()=>{P.current=!0};let e=window.setInterval(()=>void H(),M);return()=>{P.current=!0,window.clearInterval(e)}},[u,H]);let U=(0,b.useMemo)(()=>E(e?.resources.history??[]),[e]),W=(0,b.useMemo)(()=>D(e?.resources.history??[]),[e]),G=e?A(e):`No snapshot`;return(0,j.jsxs)(v,{children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h1`,{className:`text-base font-semibold`,children:`Diagnostics`}),(0,j.jsx)(`p`,{className:`mt-1 text-muted-foreground text-xs`,children:e?`Updated ${T(e.generatedAt,B)}`:`Waiting for snapshot`})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(c,{size:`xs`,variant:`outline`,onClick:()=>f(e=>!e),children:[u?(0,j.jsx)(p,{className:`size-3.5`}):(0,j.jsx)(y,{className:`size-3.5`}),u?`Resume`:`Pause`]}),(0,j.jsxs)(c,{size:`xs`,variant:`outline`,onClick:()=>void H(),disabled:s,children:[(0,j.jsx)(m,{className:o(`size-3.5`,s&&`animate-spin`)}),`Refresh`]})]})]}),(0,j.jsx)(V,{snapshot:e,error:n}),(0,j.jsx)(_,{title:`Overview`,children:(0,j.jsxs)(`div`,{className:`grid sm:grid-cols-2 lg:grid-cols-3`,children:[(0,j.jsx)(L,{label:`Uptime`,value:e?C(e.uptimeMs):`n/a`,detail:e?`Started ${T(e.serverStartedAt,B)}`:void 0}),(0,j.jsx)(L,{label:`Memory`,value:e?S(e.resources.current.memory.rssBytes):`n/a`,detail:e?`${S(e.resources.current.memory.heapUsedBytes)} heap used`:void 0}),(0,j.jsx)(L,{label:`CPU`,value:e?w(e.resources.current.cpu.utilizationPercent):`n/a`,detail:e?.resources.current.eventLoopDelayMs===void 0?void 0:`${C(e.resources.current.eventLoopDelayMs)} event loop delay`}),(0,j.jsx)(L,{label:`Activity`,value:`${e?.liveProcesses.providers.filter(e=>e.enabled).length??0} providers`,detail:`${e?.liveProcesses.terminals.length??0} terminal sessions`}),(0,j.jsx)(L,{label:`Tracing`,value:`${e?.tracing.retainedSpanCount??0} spans`,detail:e?`${e.limits.fileTailBytes/1024} KB file tail`:void 0}),(0,j.jsx)(L,{label:`Latest failure`,value:G})]})}),(0,j.jsx)(_,{title:`Resource history`,children:(0,j.jsxs)(`div`,{className:`grid gap-0 divide-y divide-border/60 lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[(0,j.jsxs)(`div`,{className:`min-w-0 p-4`,children:[(0,j.jsx)(`div`,{className:`mb-1 text-[12px] font-semibold`,children:`RSS memory`}),(0,j.jsx)(N,{points:U,formatValue:S})]}),(0,j.jsxs)(`div`,{className:`min-w-0 p-4`,children:[(0,j.jsx)(`div`,{className:`mb-1 text-[12px] font-semibold`,children:`CPU utilization`}),(0,j.jsx)(N,{points:W,formatValue:e=>`${e.toFixed(1)}%`})]})]})}),(0,j.jsxs)(_,{title:`Tracing diagnostics`,children:[(0,j.jsxs)(`div`,{className:`grid gap-0 divide-y divide-border/60 lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Top span names`}),(0,j.jsx)(F,{points:k(e?.tracing.topSpanNames??[])})]}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Duration buckets`}),(0,j.jsx)(F,{points:O(e?.tracing.durationBuckets??[])})]})]}),(0,j.jsxs)(`div`,{className:`border-border/60 border-t`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Slowest spans`}),(0,j.jsx)(z,{spans:e?.tracing.slowestSpans??[]})]})]}),(0,j.jsx)(_,{title:`Failures`,children:(0,j.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[(e?.failures.latest??[]).slice(0,8).map(e=>(0,j.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 sm:grid-cols-[minmax(0,1fr)_6rem]`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(d,{size:`sm`,variant:`error`,children:e.category}),(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.message})]}),(0,j.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,children:[e.source,` / `,e.signature]}),(0,j.jsx)(`div`,{className:`mt-2`,children:(0,j.jsx)(R,{value:e.raw??e})})]}),(0,j.jsx)(`div`,{className:`font-mono text-[11px] text-muted-foreground sm:text-right`,children:T(e.occurredAt,B)})]},e.id)),e&&e.failures.latest.length===0?(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No failures retained.`}):null]})}),(0,j.jsx)(_,{title:`Live activity`,children:(0,j.jsxs)(`div`,{className:`grid gap-0 divide-y divide-border/60 lg:grid-cols-2 lg:divide-x lg:divide-y-0`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Providers`}),(0,j.jsx)(`div`,{className:`divide-y divide-border/60`,children:(e?.liveProcesses.providers??[]).map(e=>(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`truncate text-[13px] font-medium`,children:e.displayName??e.instanceId}),(0,j.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.driver})]}),(0,j.jsx)(d,{size:`sm`,variant:e.status===`error`?`error`:e.status===`warning`?`warning`:`outline`,children:e.status})]},e.instanceId))})]}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`border-border/60 border-b px-4 py-2 text-[12px] font-semibold`,children:`Terminals and slow RPCs`}),(0,j.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[(e?.liveProcesses.terminals??[]).map(e=>(0,j.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.terminalId}),(0,j.jsx)(d,{size:`sm`,variant:e.status===`error`?`error`:`outline`,children:e.status})]}),(0,j.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground`,children:[`pid `,e.pid??`n/a`,` / subprocess`,` `,e.hasRunningSubprocess?`yes`:`no`]})]},`${e.threadId}:${e.terminalId}`)),I.map(e=>(0,j.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,j.jsx)(`div`,{className:`truncate text-[13px] font-medium`,children:e.tag}),(0,j.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[`slow ack / `,T(e.startedAt,B)]})]},e.requestId)),(e?.liveProcesses.terminals.length??0)===0&&I.length===0?(0,j.jsx)(`p`,{className:`px-4 py-4 text-muted-foreground text-sm`,children:`No live terminal or slow RPC activity.`}):null]})]})]})})]})}export{U as DiagnosticsSettings};
@@ -1 +1 @@
1
- import{Pn as e,nr as t}from"./composerDraftStore-D12lUSfh.js";import{n}from"./DialogViewport-DvjAl76K.js";var r=class{constructor(e){this.store=e??new n}open(n){let r=n?this.store.context.triggerElements.getById(n):void 0;this.store.setOpen(!0,e(t,void 0,r))}openWithPayload(n){this.store.set(`payload`,n),this.store.setOpen(!0,e(t,void 0,void 0))}close(){this.store.setOpen(!1,e(t,void 0,void 0))}get isOpen(){return this.store.state.open}};function i(){return new r}export{i as n,r as t};
1
+ import{Pn as e,nr as t}from"./composerDraftStore-DpPEQ6BN.js";import{n}from"./DialogViewport-CMV_BePU.js";var r=class{constructor(e){this.store=e??new n}open(n){let r=n?this.store.context.triggerElements.getById(n):void 0;this.store.setOpen(!0,e(t,void 0,r))}openWithPayload(n){this.store.set(`payload`,n),this.store.setOpen(!0,e(t,void 0,void 0))}close(){this.store.setOpen(!1,e(t,void 0,void 0))}get isOpen(){return this.store.state.open}};function i(){return new r}export{i as n,r as t};
@@ -1 +1 @@
1
- import{i as e,t}from"./react-PSPkXoKo.js";import{Ni as n,Ur as r,tt as i}from"./composerDraftStore-D12lUSfh.js";import{c as a,n as o,r as s,s as c}from"./DialogViewport-DvjAl76K.js";var l=e(t()),u=n();function d(e){let{children:t,open:n,defaultOpen:d=!1,onOpenChange:f,onOpenChangeComplete:p,disablePointerDismissal:m=!1,modal:h=!0,actionsRef:g,handle:_,triggerId:v,defaultTriggerId:y=null}=e,b=a(!0),x=!!b,S=r(()=>_?.store??new o({open:d,openProp:n,activeTriggerId:y,triggerIdProp:v,modal:h,disablePointerDismissal:m,nested:x})).current;i(()=>{n===void 0&&S.state.open===!1&&d===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp(`openProp`,n),S.useControlledProp(`triggerIdProp`,v),S.useSyncedValues({disablePointerDismissal:m,nested:x,modal:h}),S.useContextCallback(`onOpenChange`,f),S.useContextCallback(`onOpenChangeComplete`,p);let C=S.useState(`payload`);s({store:S,actionsRef:g,parentContext:b?.store.context,onOpenChange:f,triggerIdProp:v});let w=l.useMemo(()=>({store:S}),[S]);return(0,u.jsx)(c.Provider,{value:w,children:typeof t==`function`?t({payload:C}):t})}export{d as t};
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{Pi as n,Wr as r,tt as i}from"./composerDraftStore-DpPEQ6BN.js";import{c as a,n as o,r as s,s as c}from"./DialogViewport-CMV_BePU.js";var l=e(t()),u=n();function d(e){let{children:t,open:n,defaultOpen:d=!1,onOpenChange:f,onOpenChangeComplete:p,disablePointerDismissal:m=!1,modal:h=!0,actionsRef:g,handle:_,triggerId:v,defaultTriggerId:y=null}=e,b=a(!0),x=!!b,S=r(()=>_?.store??new o({open:d,openProp:n,activeTriggerId:y,triggerIdProp:v,modal:h,disablePointerDismissal:m,nested:x})).current;i(()=>{n===void 0&&S.state.open===!1&&d===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp(`openProp`,n),S.useControlledProp(`triggerIdProp`,v),S.useSyncedValues({disablePointerDismissal:m,nested:x,modal:h}),S.useContextCallback(`onOpenChange`,f),S.useContextCallback(`onOpenChangeComplete`,p);let C=S.useState(`payload`);s({store:S,actionsRef:g,parentContext:b?.store.context,onOpenChange:f,triggerIdProp:v});let w=l.useMemo(()=>({store:S}),[S]);return(0,u.jsx)(c.Provider,{value:w,children:typeof t==`function`?t({payload:C}):t})}export{d as t};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{$n as n,In as r,Pn as i,Pr as a,Un as o}from"./composerDraftStore-DpPEQ6BN.js";import{c as s}from"./DialogViewport-CMV_BePU.js";var c=e(t()),l=c.forwardRef(function(e,t){let{render:r,className:c,disabled:l=!1,nativeButton:u=!0,...d}=e,{store:f}=s(),p=f.useState(`open`);function m(e){p&&f.setOpen(!1,i(n,e.nativeEvent))}let{getButtonProps:h,buttonRef:g}=o({disabled:l,native:u});return a(`button`,e,{state:{disabled:l},ref:[t,g],props:[{onClick:m},d,h]})}),u=c.forwardRef(function(e,t){let{render:n,className:i,id:o,...c}=e,{store:l}=s(),u=r(o);return l.useSyncedValueWithCleanup(`descriptionElementId`,u),a(`p`,e,{ref:t,props:[{id:u},c]})}),d=c.forwardRef(function(e,t){let{render:n,className:i,id:o,...c}=e,{store:l}=s(),u=r(o);return l.useSyncedValueWithCleanup(`titleElementId`,u),a(`h2`,e,{ref:t,props:[{id:u},c]})});export{u as n,l as r,d as t};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{At as n,Bt as r,Gr as i,In as a,Ir as o,Jt as s,Pr as c,Un as l,_r as u}from"./composerDraftStore-DpPEQ6BN.js";import{c as d}from"./DialogViewport-CMV_BePU.js";var f=e(t()),p=f.forwardRef(function(e,t){let{render:p,className:m,disabled:h=!1,nativeButton:g=!0,id:_,payload:v,handle:y,...b}=e,x=d(!0),S=y?.store??x?.store;if(!S)throw Error(i(79));let C=a(_),w=S.useState(`floatingRootContext`),T=S.useState(`isOpenedByTrigger`,C),E=f.useRef(null),{registerTrigger:D,isMountedByThisTrigger:O}=r(C,E,S,{payload:v}),{getButtonProps:k,buttonRef:A}=l({disabled:h,native:g}),j=n([s(w,{enabled:w!=null})]),M={disabled:h,open:T},N=S.useState(`triggerProps`,O);return c(`button`,e,{state:M,ref:[A,t,D,E],props:[j.getReferenceProps(),N,{[o]:``,id:C},b,k],stateAttributesMapping:u})});export{p as t};
@@ -1 +1 @@
1
- import{i as e,t}from"./react-PSPkXoKo.js";import{At as n,Ft as r,It as i,Lt as a,Ni as o,Nr as s,Nt as c,On as l,Ot as u,Pn as d,Q as f,Rt as p,Sn as m,Vt as h,Wr as g,Wt as _,Xn as v,Yt as y,en as b,et as x,hr as S,ht as C,mr as w,nr as T,nt as E,qt as D,st as O,wn as k,yr as A,zt as j}from"./composerDraftStore-D12lUSfh.js";var M=e(t()),N=M.createContext(void 0);function P(e){let t=M.useContext(N);if(e===!1&&t===void 0)throw Error(g(27));return t}var F={...S,...A},I=M.forwardRef(function(e,t){let{render:n,className:r,forceRender:i=!1,...a}=e,{store:o}=P(),c=o.useState(`open`),l=o.useState(`nested`),u=o.useState(`mounted`);return s(`div`,e,{state:{open:c,transitionStatus:o.useState(`transitionStatus`)},ref:[o.context.backdropRef,t],stateAttributesMapping:F,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},a],enabled:i||!l})}),L=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),R=function(e){return e[e.open=w.open]=`open`,e[e.closed=w.closed]=`closed`,e[e.startingStyle=w.startingStyle]=`startingStyle`,e[e.endingStyle=w.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),z=M.createContext(void 0);function B(){let e=M.useContext(z);if(e===void 0)throw Error(g(26));return e}var V=o(),H={...S,...A,nestedDialogOpen(e){return e?{[R.nestedDialogOpen]:``}:null}},U=M.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,...o}=e,{store:c}=P(),u=c.useState(`descriptionElementId`),d=c.useState(`disablePointerDismissal`),f=c.useState(`floatingRootContext`),p=c.useState(`popupProps`),m=c.useState(`modal`),h=c.useState(`mounted`),g=c.useState(`nested`),_=c.useState(`nestedOpenDialogCount`),v=c.useState(`open`),b=c.useState(`openMethod`),x=c.useState(`titleElementId`),S=c.useState(`transitionStatus`),w=c.useState(`role`);B(),l({open:v,ref:c.context.popupRef,onComplete(){v&&c.context.onOpenChangeComplete?.(!0)}});function T(e){return e===`touch`?c.context.popupRef.current:!0}let E=i===void 0?T:i,D=s(`div`,e,{state:{open:v,nested:g,transitionStatus:S,nestedDialogOpen:_>0},props:[p,{"aria-labelledby":x??void 0,"aria-describedby":u??void 0,role:w,tabIndex:-1,hidden:!h,onKeyDown(e){C.has(e.key)&&e.stopPropagation()},style:{[L.nestedDialogs]:_}},o],ref:[t,c.context.popupRef,c.useStateSetter(`popupElement`)],stateAttributesMapping:H});return(0,V.jsx)(y,{context:f,openInteractionType:b,disabled:!h,closeOnFocusOut:!d,initialFocus:E,returnFocus:r,modal:m!==!1,restoreFocus:`popup`,children:D})}),W=M.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=P(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,V.jsx)(z.Provider,{value:n,children:(0,V.jsxs)(b,{ref:t,...r,children:[a&&o===!0&&(0,V.jsx)(E,{ref:i.context.internalBackdropRef,inert:O(!s)}),e.children]})}):null});function G(e){let{store:t,parentContext:r,actionsRef:i}=e,a=t.useState(`open`),o=t.useState(`disablePointerDismissal`),s=t.useState(`modal`),l=t.useState(`popupElement`),{openMethod:h,triggerProps:g}=f(a);p(t);let{forceUnmount:_}=j(a,t),y=v(e=>{let n=d(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),b=M.useCallback(()=>{t.setOpen(!1,y(T))},[t,y]);M.useImperativeHandle(i,()=>({unmount:_,close:b}),[_,b]);let S=c({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[C,w]=M.useState(0),E=C===0,O=u(S),A=D(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:s===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=k(e);if(E&&!o){let e=n;return s&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||m(e,l)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:E});x(a&&s===!0,l);let{getReferenceProps:N,getFloatingProps:P,getTriggerProps:F}=n([O,A]);t.useContextCallback(`onNestedDialogOpen`,e=>{w(e+1)}),t.useContextCallback(`onNestedDialogClose`,()=>{w(0)}),M.useEffect(()=>(r?.onNestedDialogOpen&&a&&r.onNestedDialogOpen(C),r?.onNestedDialogClose&&!a&&r.onNestedDialogClose(),()=>{r?.onNestedDialogClose&&a&&r.onNestedDialogClose()}),[a,r,C]);let I=M.useMemo(()=>N(g),[N,g]),L=M.useMemo(()=>F(g),[F,g]),R=M.useMemo(()=>P(),[P]);t.useSyncedValues({openMethod:h,activeTriggerProps:I,inactiveTriggerProps:L,popupProps:R,floatingRootContext:S,nestedOpenDialogCount:C})}var K={...i,modal:_(e=>e.modal),nested:_(e=>e.nested),nestedOpenDialogCount:_(e=>e.nestedOpenDialogCount),disablePointerDismissal:_(e=>e.disablePointerDismissal),openMethod:_(e=>e.openMethod),descriptionElementId:_(e=>e.descriptionElementId),titleElementId:_(e=>e.titleElementId),viewportElement:_(e=>e.viewportElement),role:_(e=>e.role)},q=class extends h{constructor(e){super(J(e),{popupRef:M.createRef(),backdropRef:M.createRef(),internalBackdropRef:M.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new a,onOpenChange:void 0,onOpenChangeComplete:void 0},K)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;let n={open:e,nativeEvent:t.event,reason:t.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit(`openchange`,n);let r={open:e},i=t.trigger?.id??null;(i||e)&&(r.activeTriggerId=i,r.activeTriggerElement=t.trigger??null),this.update(r)}};function J(e={}){return{...r(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:`dialog`,...e}}var Y=function(e){return e[e.open=w.open]=`open`,e[e.closed=w.closed]=`closed`,e[e.startingStyle=w.startingStyle]=`startingStyle`,e[e.endingStyle=w.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),X={...S,...A,nested(e){return e?{[Y.nested]:``}:null},nestedDialogOpen(e){return e?{[Y.nestedDialogOpen]:``}:null}},Z=M.forwardRef(function(e,t){let{className:n,render:r,children:i,...a}=e,o=B(),{store:c}=P(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`);return s(`div`,e,{enabled:o||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,c.useStateSetter(`viewportElement`)],stateAttributesMapping:X,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:i},a]})});export{U as a,P as c,W as i,q as n,I as o,G as r,N as s,Z as t};
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{At as n,Ft as r,Gr as i,It as a,Lt as o,Nt as s,On as c,Ot as l,Pi as u,Pn as d,Pr as f,Q as p,Rt as m,Sn as h,Vt as g,Wt as _,Xn as v,Yt as y,en as b,et as x,hr as S,ht as C,mr as w,nr as T,nt as E,qt as D,st as O,wn as k,yr as A,zt as j}from"./composerDraftStore-DpPEQ6BN.js";var M=e(t()),N=M.createContext(void 0);function P(e){let t=M.useContext(N);if(e===!1&&t===void 0)throw Error(i(27));return t}var F={...S,...A},I=M.forwardRef(function(e,t){let{render:n,className:r,forceRender:i=!1,...a}=e,{store:o}=P(),s=o.useState(`open`),c=o.useState(`nested`),l=o.useState(`mounted`);return f(`div`,e,{state:{open:s,transitionStatus:o.useState(`transitionStatus`)},ref:[o.context.backdropRef,t],stateAttributesMapping:F,props:[{role:`presentation`,hidden:!l,style:{userSelect:`none`,WebkitUserSelect:`none`}},a],enabled:i||!c})}),L=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),R=function(e){return e[e.open=w.open]=`open`,e[e.closed=w.closed]=`closed`,e[e.startingStyle=w.startingStyle]=`startingStyle`,e[e.endingStyle=w.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),z=M.createContext(void 0);function B(){let e=M.useContext(z);if(e===void 0)throw Error(i(26));return e}var V=u(),H={...S,...A,nestedDialogOpen(e){return e?{[R.nestedDialogOpen]:``}:null}},U=M.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,...o}=e,{store:s}=P(),l=s.useState(`descriptionElementId`),u=s.useState(`disablePointerDismissal`),d=s.useState(`floatingRootContext`),p=s.useState(`popupProps`),m=s.useState(`modal`),h=s.useState(`mounted`),g=s.useState(`nested`),_=s.useState(`nestedOpenDialogCount`),v=s.useState(`open`),b=s.useState(`openMethod`),x=s.useState(`titleElementId`),S=s.useState(`transitionStatus`),w=s.useState(`role`);B(),c({open:v,ref:s.context.popupRef,onComplete(){v&&s.context.onOpenChangeComplete?.(!0)}});function T(e){return e===`touch`?s.context.popupRef.current:!0}let E=i===void 0?T:i,D=f(`div`,e,{state:{open:v,nested:g,transitionStatus:S,nestedDialogOpen:_>0},props:[p,{"aria-labelledby":x??void 0,"aria-describedby":l??void 0,role:w,tabIndex:-1,hidden:!h,onKeyDown(e){C.has(e.key)&&e.stopPropagation()},style:{[L.nestedDialogs]:_}},o],ref:[t,s.context.popupRef,s.useStateSetter(`popupElement`)],stateAttributesMapping:H});return(0,V.jsx)(y,{context:d,openInteractionType:b,disabled:!h,closeOnFocusOut:!u,initialFocus:E,returnFocus:r,modal:m!==!1,restoreFocus:`popup`,children:D})}),W=M.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=P(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,V.jsx)(z.Provider,{value:n,children:(0,V.jsxs)(b,{ref:t,...r,children:[a&&o===!0&&(0,V.jsx)(E,{ref:i.context.internalBackdropRef,inert:O(!s)}),e.children]})}):null});function G(e){let{store:t,parentContext:r,actionsRef:i}=e,a=t.useState(`open`),o=t.useState(`disablePointerDismissal`),c=t.useState(`modal`),u=t.useState(`popupElement`),{openMethod:f,triggerProps:g}=p(a);m(t);let{forceUnmount:_}=j(a,t),y=v(e=>{let n=d(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),b=M.useCallback(()=>{t.setOpen(!1,y(T))},[t,y]);M.useImperativeHandle(i,()=>({unmount:_,close:b}),[_,b]);let S=s({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[C,w]=M.useState(0),E=C===0,O=l(S),A=D(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:c===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=k(e);if(E&&!o){let e=n;return c&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||h(e,u)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:E});x(a&&c===!0,u);let{getReferenceProps:N,getFloatingProps:P,getTriggerProps:F}=n([O,A]);t.useContextCallback(`onNestedDialogOpen`,e=>{w(e+1)}),t.useContextCallback(`onNestedDialogClose`,()=>{w(0)}),M.useEffect(()=>(r?.onNestedDialogOpen&&a&&r.onNestedDialogOpen(C),r?.onNestedDialogClose&&!a&&r.onNestedDialogClose(),()=>{r?.onNestedDialogClose&&a&&r.onNestedDialogClose()}),[a,r,C]);let I=M.useMemo(()=>N(g),[N,g]),L=M.useMemo(()=>F(g),[F,g]),R=M.useMemo(()=>P(),[P]);t.useSyncedValues({openMethod:f,activeTriggerProps:I,inactiveTriggerProps:L,popupProps:R,floatingRootContext:S,nestedOpenDialogCount:C})}var K={...a,modal:_(e=>e.modal),nested:_(e=>e.nested),nestedOpenDialogCount:_(e=>e.nestedOpenDialogCount),disablePointerDismissal:_(e=>e.disablePointerDismissal),openMethod:_(e=>e.openMethod),descriptionElementId:_(e=>e.descriptionElementId),titleElementId:_(e=>e.titleElementId),viewportElement:_(e=>e.viewportElement),role:_(e=>e.role)},q=class extends g{constructor(e){super(J(e),{popupRef:M.createRef(),backdropRef:M.createRef(),internalBackdropRef:M.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new o,onOpenChange:void 0,onOpenChangeComplete:void 0},K)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;let n={open:e,nativeEvent:t.event,reason:t.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit(`openchange`,n);let r={open:e},i=t.trigger?.id??null;(i||e)&&(r.activeTriggerId=i,r.activeTriggerElement=t.trigger??null),this.update(r)}};function J(e={}){return{...r(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:`dialog`,...e}}var Y=function(e){return e[e.open=w.open]=`open`,e[e.closed=w.closed]=`closed`,e[e.startingStyle=w.startingStyle]=`startingStyle`,e[e.endingStyle=w.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),X={...S,...A,nested(e){return e?{[Y.nested]:``}:null},nestedDialogOpen(e){return e?{[Y.nestedDialogOpen]:``}:null}},Z=M.forwardRef(function(e,t){let{className:n,render:r,children:i,...a}=e,o=B(),{store:s}=P(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`transitionStatus`),d=s.useState(`nestedOpenDialogCount`),p=s.useState(`mounted`);return f(`div`,e,{enabled:o||p,state:{open:c,nested:l,transitionStatus:u,nestedDialogOpen:d>0},ref:[t,s.useStateSetter(`viewportElement`)],stateAttributesMapping:X,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:c?void 0:`none`},children:i},a]})});export{U as a,P as c,W as i,q as n,I as o,G as r,N as s,Z as t};
@@ -1 +1 @@
1
- import{i as e,t}from"./react-PSPkXoKo.js";import{Ot as n}from"./projectAtoms-DUEBb7Zz.js";import{Ni as r,t as i}from"./composerDraftStore-D12lUSfh.js";import{t as a}from"./useNavigate-B2tgshhW.js";import{c as o}from"./toast-DE7a4wkW.js";import{a as s,c,i as l,n as u,o as d,s as f,t as p}from"./rightPanelRouteSearch-DfuWVvXN.js";import{a as m,c as h,i as g,l as _,n as v,r as y,t as b,u as x}from"./ChatRightPanel-CThudBb1.js";import{b as S,o as C}from"./sidebar-DHwNQmWp.js";import{r as w}from"./storeSelectors-Cx1IYPA4.js";var T=e(t(),1),E=r();function D({rawDraftId:e,search:t}){let r=a(),D=i.make(e),O=x(D),k=n((0,T.useMemo)(()=>w(O?.threadId??null),[O?.threadId])),A=h(k),j=(0,T.useMemo)(()=>O?.promotedTo?A?O.promotedTo:null:k?{environmentId:k.environmentId,threadId:k.id}:null,[O?.promotedTo,k,A]),M=t.diff===`1`,N=t.preview===`1`,P=p(t),F=u(t),I=t.workspaceTab===`agent`&&t.workspaceAgentKey?t.workspaceAgentKey:null,L=S(_),[R,z]=(0,T.useState)(()=>({draftId:D,hasOpenedDiff:M,hasOpenedPreview:N,hasOpenedTerminal:P===`terminal`,openedAgentKeys:I?[I]:[]})),B=R.draftId===D?R.hasOpenedDiff:M,V=R.draftId===D?R.hasOpenedPreview:N,H=R.draftId===D?R.hasOpenedTerminal:P===`terminal`,U=(0,T.useMemo)(()=>{let e=R.draftId===D?R.openedAgentKeys:I?[I]:[];return I&&!e.includes(I)?[...e,I]:e},[I,D,R]),[W,G]=(0,T.useState)(()=>P??`files`),K=(0,T.useMemo)(()=>{let e=[];return(V||P===`files`)&&e.push(`files`),(B||P===`review`)&&e.push(`review`),(H||P===`terminal`)&&e.push(`terminal`),e},[B,V,H,P]),q=(0,T.useCallback)(e=>{G(e),z(t=>{let n={draftId:D,hasOpenedDiff:(t.draftId===D?t.hasOpenedDiff:M)||e===`review`,hasOpenedPreview:(t.draftId===D?t.hasOpenedPreview:N)||e===`files`,hasOpenedTerminal:(t.draftId===D?t.hasOpenedTerminal:P===`terminal`)||e===`terminal`,openedAgentKeys:t.draftId===D?t.openedAgentKeys:U};return t.draftId===n.draftId&&t.hasOpenedDiff===n.hasOpenedDiff&&t.hasOpenedPreview===n.hasOpenedPreview&&t.hasOpenedTerminal===n.hasOpenedTerminal&&t.openedAgentKeys===n.openedAgentKeys?t:n})},[M,D,U,N,P]),J=(0,T.useCallback)(()=>{r({to:`/draft/$draftId`,params:{draftId:D},search:e=>y(e)})},[D,r]),Y=(0,T.useCallback)(()=>{r({to:`/draft/$draftId`,params:{draftId:D},search:e=>{let t=U[U.length-1];return W===`agent`&&t?l(e,t):W===`files`&&V?s(e):W===`review`&&B?d(e):W===`terminal`&&H?f(e):V?s(e):B?d(e):H?f(e):t?l(e,t):c(e)}})},[D,B,V,H,W,r,U]),X=(0,T.useCallback)(()=>{if(F){J();return}Y()},[J,Y,F]),Z=(0,T.useCallback)(e=>{if(e.mode===`agent`){let t=U.filter(t=>t!==e.agentKey);z(e=>({draftId:D,hasOpenedDiff:e.draftId===D?e.hasOpenedDiff:B,hasOpenedPreview:e.draftId===D?e.hasOpenedPreview:V,hasOpenedTerminal:e.draftId===D?e.hasOpenedTerminal:H,openedAgentKeys:t})),P===`agent`&&I===e.agentKey&&r({to:`/draft/$draftId`,params:{draftId:D},search:e=>{let n=t[t.length-1];return n?l(e,n):V?s(e):B?d(e):H?f(e):c(e)}});return}let t=e.mode===`review`?!1:B||P===`review`,n=e.mode===`files`?!1:V||P===`files`,i=e.mode===`terminal`?!1:H||P===`terminal`;z(e=>{let r={draftId:D,hasOpenedDiff:t,hasOpenedPreview:n,hasOpenedTerminal:i,openedAgentKeys:e.draftId===D?e.openedAgentKeys:U};return e.draftId===r.draftId&&e.hasOpenedDiff===r.hasOpenedDiff&&e.hasOpenedPreview===r.hasOpenedPreview&&e.hasOpenedTerminal===r.hasOpenedTerminal&&e.openedAgentKeys===r.openedAgentKeys?e:r}),P===e.mode&&r({to:`/draft/$draftId`,params:{draftId:D},search:r=>e.mode!==`files`&&n?s(r):e.mode!==`review`&&t?d(r):e.mode!==`terminal`&&i?f(r):c(r)})},[I,D,B,V,H,r,U,P]);if((0,T.useEffect)(()=>{P!==null&&(G(P),q(P))},[q,P]),(0,T.useEffect)(()=>{I&&z(e=>{let t=e.draftId===D?e.openedAgentKeys:[];return t.includes(I)?e.draftId===D?e:{draftId:D,hasOpenedDiff:B,hasOpenedPreview:V,hasOpenedTerminal:H,openedAgentKeys:t}:{draftId:D,hasOpenedDiff:e.draftId===D?e.hasOpenedDiff:M,hasOpenedPreview:e.draftId===D?e.hasOpenedPreview:N,hasOpenedTerminal:e.draftId===D?e.hasOpenedTerminal:P===`terminal`,openedAgentKeys:[...t,I]}})},[I,M,D,B,V,H,N,P]),(0,T.useEffect)(()=>{j&&r({to:`/$environmentId/$threadId`,params:o(j),replace:!0})},[j,r]),(0,T.useEffect)(()=>{O||j||r({to:`/`,replace:!0})},[j,O,r]),j)return(0,E.jsx)(C,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,E.jsx)(g,{environmentId:j.environmentId,threadId:j.threadId,routeKind:`server`})});if(!O)return null;let Q=F||P===`review`||B||P===`files`||V||P===`terminal`||H||P===`agent`||U.length>0,$=F?P:W;return L?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,E.jsx)(g,{draftId:D,environmentId:O.environmentId,threadId:O.threadId,onDiffPanelOpen:()=>q(`review`),onPreviewPanelOpen:()=>q(`files`),onTerminalPanelOpen:()=>q(`terminal`),onAgentPanelOpen:()=>q(`agent`),workspacePanelOpen:F,onToggleWorkspacePanel:X,routeKind:`draft`})}),(0,E.jsx)(m,{open:F,onClose:J,children:Q?(0,E.jsx)(b,{mode:`sheet`,panelMode:$,openedPanelModes:K,openedAgentKeys:U,onClosePanelTab:Z}):null})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,E.jsx)(g,{draftId:D,environmentId:O.environmentId,threadId:O.threadId,onDiffPanelOpen:()=>q(`review`),onPreviewPanelOpen:()=>q(`files`),onTerminalPanelOpen:()=>q(`terminal`),onAgentPanelOpen:()=>q(`agent`),workspacePanelOpen:F,onToggleWorkspacePanel:X,routeKind:`draft`})}),(0,E.jsx)(v,{open:F,panelMode:$,openedPanelModes:K,openedAgentKeys:U,onClosePanelTab:Z,onClose:J,onOpen:Y,renderContent:Q})]})}export{D as DraftChatThreadRouteView};
1
+ import{i as e,t}from"./react-PSPkXoKo.js";import{Ot as n}from"./projectAtoms-DXXpuERK.js";import{Pi as r,t as i}from"./composerDraftStore-DpPEQ6BN.js";import{t as a}from"./useNavigate-_4hWGSey.js";import{c as o}from"./toast-DmA_ziPT.js";import{a as s,c,i as l,n as u,o as d,s as f,t as p}from"./rightPanelRouteSearch-CfmZ7osj.js";import{a as m,c as h,i as g,l as _,n as v,r as y,t as b,u as x}from"./ChatRightPanel-CWHOIuiQ.js";import{o as S,x as C}from"./sidebar-_u7SGgmC.js";import{r as w}from"./storeSelectors-DhJRpdiw.js";var T=e(t(),1),E=r();function D({rawDraftId:e,search:t}){let r=a(),D=i.make(e),O=x(D),k=n((0,T.useMemo)(()=>w(O?.threadId??null),[O?.threadId])),A=h(k),j=(0,T.useMemo)(()=>O?.promotedTo?A?O.promotedTo:null:k?{environmentId:k.environmentId,threadId:k.id}:null,[O?.promotedTo,k,A]),M=t.diff===`1`,N=t.preview===`1`,P=p(t),F=u(t),I=t.workspaceTab===`agent`&&t.workspaceAgentKey?t.workspaceAgentKey:null,L=C(_),[R,z]=(0,T.useState)(()=>({draftId:D,hasOpenedDiff:M,hasOpenedPreview:N,hasOpenedTerminal:P===`terminal`,openedAgentKeys:I?[I]:[]})),B=R.draftId===D?R.hasOpenedDiff:M,V=R.draftId===D?R.hasOpenedPreview:N,H=R.draftId===D?R.hasOpenedTerminal:P===`terminal`,U=(0,T.useMemo)(()=>{let e=R.draftId===D?R.openedAgentKeys:I?[I]:[];return I&&!e.includes(I)?[...e,I]:e},[I,D,R]),[W,G]=(0,T.useState)(()=>P??`files`),K=(0,T.useMemo)(()=>{let e=[];return(V||P===`files`)&&e.push(`files`),(B||P===`review`)&&e.push(`review`),(H||P===`terminal`)&&e.push(`terminal`),e},[B,V,H,P]),q=(0,T.useCallback)(e=>{G(e),z(t=>{let n={draftId:D,hasOpenedDiff:(t.draftId===D?t.hasOpenedDiff:M)||e===`review`,hasOpenedPreview:(t.draftId===D?t.hasOpenedPreview:N)||e===`files`,hasOpenedTerminal:(t.draftId===D?t.hasOpenedTerminal:P===`terminal`)||e===`terminal`,openedAgentKeys:t.draftId===D?t.openedAgentKeys:U};return t.draftId===n.draftId&&t.hasOpenedDiff===n.hasOpenedDiff&&t.hasOpenedPreview===n.hasOpenedPreview&&t.hasOpenedTerminal===n.hasOpenedTerminal&&t.openedAgentKeys===n.openedAgentKeys?t:n})},[M,D,U,N,P]),J=(0,T.useCallback)(()=>{r({to:`/draft/$draftId`,params:{draftId:D},search:e=>y(e)})},[D,r]),Y=(0,T.useCallback)(()=>{r({to:`/draft/$draftId`,params:{draftId:D},search:e=>{let t=U[U.length-1];return W===`agent`&&t?l(e,t):W===`files`&&V?s(e):W===`review`&&B?d(e):W===`terminal`&&H?f(e):V?s(e):B?d(e):H?f(e):t?l(e,t):c(e)}})},[D,B,V,H,W,r,U]),X=(0,T.useCallback)(()=>{if(F){J();return}Y()},[J,Y,F]),Z=(0,T.useCallback)(e=>{if(e.mode===`agent`){let t=U.filter(t=>t!==e.agentKey);z(e=>({draftId:D,hasOpenedDiff:e.draftId===D?e.hasOpenedDiff:B,hasOpenedPreview:e.draftId===D?e.hasOpenedPreview:V,hasOpenedTerminal:e.draftId===D?e.hasOpenedTerminal:H,openedAgentKeys:t})),P===`agent`&&I===e.agentKey&&r({to:`/draft/$draftId`,params:{draftId:D},search:e=>{let n=t[t.length-1];return n?l(e,n):V?s(e):B?d(e):H?f(e):c(e)}});return}let t=e.mode===`review`?!1:B||P===`review`,n=e.mode===`files`?!1:V||P===`files`,i=e.mode===`terminal`?!1:H||P===`terminal`;z(e=>{let r={draftId:D,hasOpenedDiff:t,hasOpenedPreview:n,hasOpenedTerminal:i,openedAgentKeys:e.draftId===D?e.openedAgentKeys:U};return e.draftId===r.draftId&&e.hasOpenedDiff===r.hasOpenedDiff&&e.hasOpenedPreview===r.hasOpenedPreview&&e.hasOpenedTerminal===r.hasOpenedTerminal&&e.openedAgentKeys===r.openedAgentKeys?e:r}),P===e.mode&&r({to:`/draft/$draftId`,params:{draftId:D},search:r=>e.mode!==`files`&&n?s(r):e.mode!==`review`&&t?d(r):e.mode!==`terminal`&&i?f(r):c(r)})},[I,D,B,V,H,r,U,P]);if((0,T.useEffect)(()=>{P!==null&&(G(P),q(P))},[q,P]),(0,T.useEffect)(()=>{I&&z(e=>{let t=e.draftId===D?e.openedAgentKeys:[];return t.includes(I)?e.draftId===D?e:{draftId:D,hasOpenedDiff:B,hasOpenedPreview:V,hasOpenedTerminal:H,openedAgentKeys:t}:{draftId:D,hasOpenedDiff:e.draftId===D?e.hasOpenedDiff:M,hasOpenedPreview:e.draftId===D?e.hasOpenedPreview:N,hasOpenedTerminal:e.draftId===D?e.hasOpenedTerminal:P===`terminal`,openedAgentKeys:[...t,I]}})},[I,M,D,B,V,H,N,P]),(0,T.useEffect)(()=>{j&&r({to:`/$environmentId/$threadId`,params:o(j),replace:!0})},[j,r]),(0,T.useEffect)(()=>{O||j||r({to:`/`,replace:!0})},[j,O,r]),j)return(0,E.jsx)(S,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,E.jsx)(g,{environmentId:j.environmentId,threadId:j.threadId,routeKind:`server`})});if(!O)return null;let Q=F||P===`review`||B||P===`files`||V||P===`terminal`||H||P===`agent`||U.length>0,$=F?P:W;return L?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(S,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,E.jsx)(g,{draftId:D,environmentId:O.environmentId,threadId:O.threadId,onDiffPanelOpen:()=>q(`review`),onPreviewPanelOpen:()=>q(`files`),onTerminalPanelOpen:()=>q(`terminal`),onAgentPanelOpen:()=>q(`agent`),workspacePanelOpen:F,onToggleWorkspacePanel:X,routeKind:`draft`})}),(0,E.jsx)(m,{open:F,onClose:J,children:Q?(0,E.jsx)(b,{mode:`sheet`,panelMode:$,openedPanelModes:K,openedAgentKeys:U,onClosePanelTab:Z}):null})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(S,{className:`h-svh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground md:h-dvh`,children:(0,E.jsx)(g,{draftId:D,environmentId:O.environmentId,threadId:O.threadId,onDiffPanelOpen:()=>q(`review`),onPreviewPanelOpen:()=>q(`files`),onTerminalPanelOpen:()=>q(`terminal`),onAgentPanelOpen:()=>q(`agent`),workspacePanelOpen:F,onToggleWorkspacePanel:X,routeKind:`draft`})}),(0,E.jsx)(v,{open:F,panelMode:$,openedPanelModes:K,openedAgentKeys:U,onClosePanelTab:Z,onClose:J,onOpen:Y,renderContent:Q})]})}export{D as DraftChatThreadRouteView};