@vantran-se/openchamber-web 2.0.9 → 2.0.10

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 (117) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DngoXxGT.js → CodeMirrorCommentWidgets-e9rY9Jxg.js} +1 -1
  2. package/dist/assets/{DiffView-UeB7OS2J.js → DiffView-rYnmKnFF.js} +1 -1
  3. package/dist/assets/{FilesView-Cs3Y7IF5.js → FilesView-DtzJk1Ke.js} +3 -3
  4. package/dist/assets/{GitView-DsJqHet1.js → GitView-DYd5gOSc.js} +1 -1
  5. package/dist/assets/{GuestAttachDialog-CN0FTkqY.js → GuestAttachDialog-Bsi0q3M9.js} +1 -1
  6. package/dist/assets/{GuestSurfacePane-BFbUwJOB.js → GuestSurfacePane-CYMRe3EI.js} +1 -1
  7. package/dist/assets/{JsonTreeView-B2artBdi.js → JsonTreeView-DIy-frOy.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-DCcXvS3Q.js → LinearIssuesView-DDHJKaVb.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-Du-Ph58N.js → MarkdownImageGallery-BMQ4KHaO.js} +1 -1
  10. package/dist/assets/{MarkdownRendererImpl-CnXfZsIi.js → MarkdownRendererImpl-CQi_ZSPc.js} +1 -1
  11. package/dist/assets/{OnboardingScreen-DdB_pV9d.js → OnboardingScreen-DiMFS3A7.js} +1 -1
  12. package/dist/assets/{PatchDiff-JvRN2s5u.js → PatchDiff-4jmPWx6l.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-BOIbtTSo.js → PierreDiffViewer-DKHxCmze.js} +1 -1
  14. package/dist/assets/{PlanView-DYZs8zCF.js → PlanView-CN21khuJ.js} +1 -1
  15. package/dist/assets/{PluginPane-CaHXDA-2.js → PluginPane-Dx0_Dldo.js} +1 -1
  16. package/dist/assets/{SettingsView-CfFMLncG.js → SettingsView-CBGx68I6.js} +1 -1
  17. package/dist/assets/{SettingsWindow-0vSQTxkV.js → SettingsWindow-B8RpyNyO.js} +1 -1
  18. package/dist/assets/{SubmoduleDiffSummary-DhLlAYSb.js → SubmoduleDiffSummary-hkelCkS-.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-CdV4zEAG.js → ToolOutputDialog-UbbhHm0d.js} +1 -1
  20. package/dist/assets/{ToolPartDiffPreview-XL2mZzAG.js → ToolPartDiffPreview-7FbKWkeu.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-ACObo6xZ.js → VirtualizedFileDiff-DapU3oMs.js} +1 -1
  22. package/dist/assets/{WalkthroughView-B-3eK3lX.js → WalkthroughView-DhvkEmfP.js} +1 -1
  23. package/dist/assets/{appThemeRegistry-CgfpF2VR.js → appThemeRegistry-CWAKiwky.js} +1 -1
  24. package/dist/assets/{ar-SA-G6X2FPQ2-ChXWTl2B.js → ar-SA-G6X2FPQ2-DswVk5Qr.js} +1 -1
  25. package/dist/assets/{az-AZ-76LH7QW2-qjuQaC-s.js → az-AZ-76LH7QW2-DjkREsRV.js} +1 -1
  26. package/dist/assets/{bg-BG-XCXSNQG7-dsvyn4OJ.js → bg-BG-XCXSNQG7-DQo0fDKV.js} +1 -1
  27. package/dist/assets/{bn-BD-2XOGV67Q-BjdT9u1P.js → bn-BD-2XOGV67Q-CzA0IjiR.js} +1 -1
  28. package/dist/assets/{ca-ES-6MX7JW3Y-BTTmpcqZ.js → ca-ES-6MX7JW3Y-L92o9vc1.js} +1 -1
  29. package/dist/assets/{commitAndPush-dBUe7z8F.js → commitAndPush-D51hG7WM.js} +1 -1
  30. package/dist/assets/{computeVirtualFileMetrics-DfI7BTln.js → computeVirtualFileMetrics-BWISD0Ee.js} +1 -1
  31. package/dist/assets/{cs-CZ-2BRQDIVT-C5rG2tZX.js → cs-CZ-2BRQDIVT-BXRAPYTK.js} +1 -1
  32. package/dist/assets/{da-DK-5WZEPLOC-BOaJLF6Z.js → da-DK-5WZEPLOC-Be9eTSFu.js} +1 -1
  33. package/dist/assets/{de-DE-XR44H4JA-Dt-4U2No.js → de-DE-XR44H4JA-D7jcygnK.js} +1 -1
  34. package/dist/assets/{de-DoDk6ixL.js → de-Dzva6tmf.js} +1 -1
  35. package/dist/assets/{el-GR-BZB4AONW-CR60bCOY.js → el-GR-BZB4AONW-DWPB-4gi.js} +1 -1
  36. package/dist/assets/{es-uuDOJL65.js → es-Be7FJA1p.js} +1 -1
  37. package/dist/assets/{es-ES-U4NZUMDT-BxBSKTXR.js → es-ES-U4NZUMDT-BteMlYd0.js} +1 -1
  38. package/dist/assets/{eu-ES-A7QVB2H4-DCoZ1mko.js → eu-ES-A7QVB2H4-D3K4uMB7.js} +1 -1
  39. package/dist/assets/{fa-IR-HGAKTJCU-CGlSV3Cv.js → fa-IR-HGAKTJCU-D7LwSGvX.js} +1 -1
  40. package/dist/assets/{fi-FI-Z5N7JZ37-DjiU77q2.js → fi-FI-Z5N7JZ37-61Yx90sI.js} +1 -1
  41. package/dist/assets/{fr-C0viImM8.js → fr-CvtTZ_7n.js} +1 -1
  42. package/dist/assets/{fr-FR-RHASNOE6-tQI46EwI.js → fr-FR-RHASNOE6-BokbdDAr.js} +1 -1
  43. package/dist/assets/{gl-ES-HMX3MZ6V-UebXQim9.js → gl-ES-HMX3MZ6V-CfKWvFjV.js} +1 -1
  44. package/dist/assets/{he-IL-6SHJWFNN-CrEAMSem.js → he-IL-6SHJWFNN-BiuDhPeJ.js} +1 -1
  45. package/dist/assets/{hi-IN-IWLTKZ5I-CDElf1It.js → hi-IN-IWLTKZ5I-CBpbpt_D.js} +1 -1
  46. package/dist/assets/{hu-HU-A5ZG7DT2-BxrPciUB.js → hu-HU-A5ZG7DT2-YdbIKZJs.js} +1 -1
  47. package/dist/assets/{id-ID-SAP4L64H-BEUMSOdC.js → id-ID-SAP4L64H-B6lOIjuX.js} +1 -1
  48. package/dist/assets/{index-BW492zXv.js → index-BvpIhpBI.js} +1 -1
  49. package/dist/assets/{index-hsqFIGlo.js → index-CxBGclAj.js} +1 -1
  50. package/dist/assets/{isDiffPlainText-BrLxBox_.js → isDiffPlainText-DU3lrpLL.js} +1 -1
  51. package/dist/assets/{isFilePlainText-Cgi_4AsZ.js → isFilePlainText-udb3VTt2.js} +1 -1
  52. package/dist/assets/{it-IT-JPQ66NNP-DU7yvppw.js → it-IT-JPQ66NNP-Bmx3ltTW.js} +1 -1
  53. package/dist/assets/{ja-B9orD75V.js → ja-BPgcBIXr.js} +1 -1
  54. package/dist/assets/{ja-JP-DBVTYXUO-3JN7QvVc.js → ja-JP-DBVTYXUO-Ble1Hn10.js} +1 -1
  55. package/dist/assets/{kaa-6HZHGXH3-ZZvAjpex.js → kaa-6HZHGXH3-DZbQ2VK_.js} +1 -1
  56. package/dist/assets/{kab-KAB-ZGHBKWFO-C4wThQdT.js → kab-KAB-ZGHBKWFO-iJv1iHzt.js} +1 -1
  57. package/dist/assets/{kk-KZ-P5N5QNE5-DtGbDE5-.js → kk-KZ-P5N5QNE5-CVPa7-_X.js} +1 -1
  58. package/dist/assets/{km-KH-HSX4SM5Z-BBzQ-auj.js → km-KH-HSX4SM5Z-CG3n2D2z.js} +1 -1
  59. package/dist/assets/{ko-DMWq9y4E.js → ko-DavkJfF9.js} +1 -1
  60. package/dist/assets/{ko-KR-MTYHY66A-DKypF9JQ.js → ko-KR-MTYHY66A-4ypCzC-G.js} +1 -1
  61. package/dist/assets/{ku-TR-6OUDTVRD-D9ejnihQ.js → ku-TR-6OUDTVRD-rnEkr74f.js} +1 -1
  62. package/dist/assets/{lt-LT-XHIRWOB4-Dqmjn0mI.js → lt-LT-XHIRWOB4-CyRnYc4K.js} +1 -1
  63. package/dist/assets/{lv-LV-5QDEKY6T-UrP5oB7q.js → lv-LV-5QDEKY6T-ZRIiC6FR.js} +1 -1
  64. package/dist/assets/{main-xwL5wKzs.js → main-CrXZnahe.js} +2 -2
  65. package/dist/assets/{main-BjJBl7Nu.js → main-xs-JggnC.js} +4 -4
  66. package/dist/assets/{markdownCore-DSFyd8zF.js → markdownCore-CUxMtJCS.js} +1 -1
  67. package/dist/assets/{miniChat-DYbqo1MM.js → miniChat-BISrLEQj.js} +2 -2
  68. package/dist/assets/{mobile-BfD16Eag.js → mobile-C5yhjorl.js} +2 -2
  69. package/dist/assets/{mr-IN-CRQNXWMA-IPWmH5Ni.js → mr-IN-CRQNXWMA-UgSO2DIH.js} +1 -1
  70. package/dist/assets/{my-MM-5M5IBNSE-BLfvJLfS.js → my-MM-5M5IBNSE-D_F1DCJR.js} +1 -1
  71. package/dist/assets/{nb-NO-T6EIAALU-DpTcOSVU.js → nb-NO-T6EIAALU-oIGhTIX7.js} +1 -1
  72. package/dist/assets/{nl-NL-IS3SIHDZ-BnEpZrEO.js → nl-NL-IS3SIHDZ-cScIrIxG.js} +1 -1
  73. package/dist/assets/{nn-NO-6E72VCQL-cguGGiOn.js → nn-NO-6E72VCQL-CjEAl_Lv.js} +1 -1
  74. package/dist/assets/{oc-FR-POXYY2M6-DZRflDPj.js → oc-FR-POXYY2M6-1rehXYxp.js} +1 -1
  75. package/dist/assets/{pa-IN-N4M65BXN-B4LAi-bY.js → pa-IN-N4M65BXN-7iWEsMEJ.js} +1 -1
  76. package/dist/assets/{patchFileDiff-DkL8Aa2N.js → patchFileDiff-DzgiH2zi.js} +1 -1
  77. package/dist/assets/{percentages-BXMCSKIN-ChsKj3Ud.js → percentages-BXMCSKIN-nJkK2U43.js} +4 -4
  78. package/dist/assets/{pl-DOQ2hiXE.js → pl-DU7WIv6_.js} +1 -1
  79. package/dist/assets/{pl-PL-T2D74RX3-DIa8_Rxw.js → pl-PL-T2D74RX3-8-4_uRcY.js} +1 -1
  80. package/dist/assets/{pt-BR-5N22H2LF-CjvHq8Nl.js → pt-BR-5N22H2LF-5f518RJn.js} +1 -1
  81. package/dist/assets/{pt-BR-GRNT4bJk.js → pt-BR-nKukDIco.js} +1 -1
  82. package/dist/assets/{pt-PT-UZXXM6DQ-De7WYkMm.js → pt-PT-UZXXM6DQ-CX60-bds.js} +1 -1
  83. package/dist/assets/{renderElectronMiniChatApp-COuZPzkA.js → renderElectronMiniChatApp-BsUuzGo8.js} +2 -2
  84. package/dist/assets/{renderMobileApp-BO162-O8.js → renderMobileApp-4lMkhU0J.js} +3 -3
  85. package/dist/assets/{ro-RO-JPDTUUEW-8cucu0w7.js → ro-RO-JPDTUUEW-WRbjlbWZ.js} +1 -1
  86. package/dist/assets/{ru-RU-B4JR7IUQ-C-EfBvoP.js → ru-RU-B4JR7IUQ-BOe15dMj.js} +1 -1
  87. package/dist/assets/{runtimeEndpointReset-B_5A-WIc.js → runtimeEndpointReset-D56xMbiw.js} +19 -19
  88. package/dist/assets/{scheduledTasksApi-MxDvG-t3.js → scheduledTasksApi-BZMS2h6Z.js} +1 -1
  89. package/dist/assets/{shikiHighlight-B39UxQvQ.js → shikiHighlight-BPUnGgQg.js} +1 -1
  90. package/dist/assets/{si-LK-N5RQ5JYF-Dtp4SfIy.js → si-LK-N5RQ5JYF-DdWuRf76.js} +1 -1
  91. package/dist/assets/{sk-SK-C5VTKIMK-C2URq6ko.js → sk-SK-C5VTKIMK-C6bkxrp7.js} +1 -1
  92. package/dist/assets/{sl-SI-NN7IZMDC-DFa24yvi.js → sl-SI-NN7IZMDC-9Kz16LlM.js} +1 -1
  93. package/dist/assets/{subset-shared.chunk-DT8U7cSF.js → subset-shared.chunk-TyCa-VC5.js} +1 -1
  94. package/dist/assets/{subset-worker.chunk-DsFk1l-v.js → subset-worker.chunk-BEUpJy0_.js} +1 -1
  95. package/dist/assets/{sv-SE-XGPEYMSR-BW357iMU.js → sv-SE-XGPEYMSR-CEKYbCUy.js} +1 -1
  96. package/dist/assets/{ta-IN-2NMHFXQM-ByJpqKo_.js → ta-IN-2NMHFXQM-lt4RexfZ.js} +1 -1
  97. package/dist/assets/{textMateThemeFromAppTheme-Dmu3ECWz.js → textMateThemeFromAppTheme-AUvSJIJn.js} +1 -1
  98. package/dist/assets/{th-TH-HPSO5L25-oBYiL2Sw.js → th-TH-HPSO5L25-BTLJeK_p.js} +1 -1
  99. package/dist/assets/{tr-CcLlZCMC.js → tr-C7G7YZuM.js} +1 -1
  100. package/dist/assets/{tr-TR-DEFEU3FU-DuccnkGw.js → tr-TR-DEFEU3FU-D1x5-N8S.js} +1 -1
  101. package/dist/assets/{uk-DeV8vTnQ.js → uk-D-OHqF3o.js} +1 -1
  102. package/dist/assets/{uk-UA-QMV73CPH-EKbyzxQM.js → uk-UA-QMV73CPH-BoCWhdiB.js} +1 -1
  103. package/dist/assets/{useAppFontEffects-Cz-1Efdn.js → useAppFontEffects-FdVEdwq7.js} +101 -101
  104. package/dist/assets/{useInlineCommentController-BFwu6eZI.js → useInlineCommentController-Bf5t_8QQ.js} +1 -1
  105. package/dist/assets/{useRootScrollLock-sHvuqb26.js → useRootScrollLock-BhAup8Zd.js} +2 -2
  106. package/dist/assets/{vendor-codemirror-language-data-CbrKiV7x.js → vendor-codemirror-language-data-CaoLP1ZV.js} +2 -2
  107. package/dist/assets/{vi-VN-M7AON7JQ-FnoyhtCt.js → vi-VN-M7AON7JQ-BNXFIbWh.js} +1 -1
  108. package/dist/assets/{web-components-CyKxJIMp.js → web-components-BKRdx0aw.js} +1 -1
  109. package/dist/assets/{zh-CN-CytFue-5.js → zh-CN-CN_mO1LM.js} +1 -1
  110. package/dist/assets/{zh-CN-LNUGB5OW-CxzUpimL.js → zh-CN-LNUGB5OW-BzAzBoiv.js} +1 -1
  111. package/dist/assets/{zh-HK-E62DVLB3-Bm2BpZIC.js → zh-HK-E62DVLB3-gszEMx80.js} +1 -1
  112. package/dist/assets/{zh-TW-B-BGC0pY.js → zh-TW-DRymoioH.js} +1 -1
  113. package/dist/assets/{zh-TW-RAJ6MFWO-NVEuq9tQ.js → zh-TW-RAJ6MFWO-jlMY0UDt.js} +1 -1
  114. package/dist/index.html +2 -2
  115. package/dist/mini-chat.html +2 -2
  116. package/dist/mobile.html +2 -2
  117. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-B-3eK3lX.js","assets/vendor-react-C3AD0CRp.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Cz-1Efdn.js","assets/index-BW492zXv.js","assets/vendor-zod-C3BVLiwa.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-XNmn2Hnw.js","assets/vendor-use-sync-external-store-DVVwmGAS.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-ryXjyKdZ.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-CyPa587s.js","assets/vendor-clsx-C_d985j6.js","assets/vendor-base-ui-BV0ycO3d.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BERnAEiB.js","assets/vendor-floating-ui-core-DBVSD8FA.js","assets/vendor-floating-ui-react-dom-VN3-0QGl.js","assets/vendor-dnd-kit-core-B-dmENub.js","assets/vendor-dnd-kit-utilities-D2MO70n8.js","assets/vendor-dnd-kit-accessibility-vxqCsF6D.js","assets/vendor-dnd-kit-sortable-DiuAkJDx.js","assets/vendor-tanstack-react-virtual-BHz8HhxS.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.js","assets/vendor-framer-motion-0pQCvQRa.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-CMlKUx1I.js","assets/vendor-cmdk-WpnCe4Xz.js","assets/vendor-radix-ui-react-dialog-Cya58wJc.js","assets/vendor-radix-ui-primitive-DOdKROq0.js","assets/vendor-radix-ui-react-compose-refs-OwL660na.js","assets/vendor-radix-ui-react-context-BGG-1ggC.js","assets/vendor-radix-ui-react-id-CciEoFzD.js","assets/vendor-radix-ui-react-use-layout-effect-ChlApEEc.js","assets/vendor-radix-ui-react-use-controllable-state-DprBN3PW.js","assets/vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js","assets/vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js","assets/vendor-radix-ui-react-primitive-CUfg3gbV.js","assets/vendor-radix-ui-react-slot-CLI2-QJb.js","assets/vendor-babel-runtime-CF3RwP-h.js","assets/vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js","assets/vendor-radix-ui-react-focus-scope-CqvJmvlR.js","assets/vendor-radix-ui-react-portal-EaY9b0dR.js","assets/vendor-radix-ui-react-presence-DBDb0ROU.js","assets/vendor-radix-ui-react-focus-guards-DOvT22db.js","assets/vendor-react-remove-scroll-CdTdY8wV.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-DAxITgbW.js","assets/vendor-react-style-singleton-XBDcq1Ec.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-CzUV4Fx5.js","assets/vendor-use-callback-ref-h1JrcWGd.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-Cg8boEOY.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CN8Enbjc.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-Dw1gdHuT.js","assets/vendor-codemirror-lang-json-DzRRSgj9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B_seq3PB.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CcuPVz08.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-B3FiTjDN.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CbrKiV7x.js","assets/vendor-codemirror-lang-python-frX4-6UW.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-Cg3hFNyu.js","assets/vendor-legendapp-list-ZsDnss2w.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-DkL8Aa2N.js","assets/runtimeEndpointReset-B_5A-WIc.js","assets/GuestAttachDialog-CN0FTkqY.js","assets/PluginPane-CaHXDA-2.js","assets/VirtualizedFileDiff-ACObo6xZ.js","assets/web-components-CyKxJIMp.js","assets/computeVirtualFileMetrics-DfI7BTln.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-BrLxBox_.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-BOIbtTSo.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-BFwu6eZI.js","assets/appThemeRegistry-CgfpF2VR.js","assets/textMateThemeFromAppTheme-Dmu3ECWz.js","assets/vendor-katex-C8JhiARg.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-sHvuqb26.js","assets/scheduledTasksApi-MxDvG-t3.js","assets/vendor-cron-parser-B7wFT8N0.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-UeB7OS2J.js","assets/SubmoduleDiffSummary-DhLlAYSb.js","assets/changesTree-CePHbFcj.js","assets/FilesView-Cs3Y7IF5.js","assets/shikiHighlight-B39UxQvQ.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-C_NzAZis.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-B2artBdi.js","assets/Virtualizer-CtRzP13T.js","assets/isFilePlainText-Cgi_4AsZ.js","assets/vendor-react-drawio-DR5-Wn9a.js","assets/CodeMirrorCommentWidgets-DngoXxGT.js","assets/GitView-DsJqHet1.js","assets/commitAndPush-dBUe7z8F.js","assets/LinearIssuesView-DCcXvS3Q.js","assets/PlanView-DYZs8zCF.js","assets/GuestSurfacePane-BFbUwJOB.js","assets/SettingsWindow-0vSQTxkV.js","assets/SettingsView-CfFMLncG.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-BTlWCou-.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-DdB_pV9d.js"])))=>i.map(i=>d[i]);
2
- import{e as nt,R as c,j as s,r as lt,b as Vm,f as Um}from"./vendor-react-C3AD0CRp.js";import"./vendor-katex-C8JhiARg.js";import{G as mn,H as qo,bo as Hm,a6 as Gm,r as as,b as Fd,u as ye,aA as Et,aP as hl,g as qt,s as vr,aa as gt,Z as ys,y as Kr,i as An,O as Ld,bp as qm,bq as Ym,br as Qm,bs as Xm,X as _d,a as Zt,x as Nn,bt as Vr,f as hn,V as Jm,a0 as Zm,a1 as eh,a2 as th,a3 as $d,a4 as Qs,z as mr,Y as sh,a8 as pl,k as nh,d as zd,o as rh,bu as Wd,af as oh,bv as Fn,bw as $n,m as Mo,bx as Fi,by as ih,au as Pa,ac as Oo,F as lr,al as is,bz as Kd,aN as ah,bA as Li,aC as Vd,aD as Ud,an as lh,am as ch,ad as dh,bB as No,bC as Ao,bD as uh,bE as gl,a_ as fh,bF as mh,bG as hh,bH as ph,bI as bl,bJ as xl,bK as yl,bL as wl,bM as gh,A as vl,bN as bh,bO as xh,S as yh,B as wh,C as vh}from"./index-BW492zXv.js";import{_ as en}from"./vendor-vite-runtime-DD1OZmLC.js";import{a6 as Sl,ae as bi,af as Ws,ag as _i,ah as jl,ai as Sh,aj as jh,ak as kh,al as Ch,am as Nh,an as Ah,ao as Ph,ap as Dh,aq as Ih,ar as Da,o as Th,E as Hd,k as Eh,l as Rh,a1 as Gd,m as $i,I as qd,d as Mh,a as Oh,N as Bh,C as Yd,f as zi,g as Ln,h as Qd,i as Xd,e as Fh,P as Lh,J as _h,ac as $h,a9 as zh,ad as Wh,a5 as Kh,y as Jd,as as Vh,at as Uh,p as Hh,n as Zd,S as xi,au as eu,B as Gh,av as tu,z as qh,aw as Yh,v as Qh,w as Xh,ax as ir,x as yi,ay as Jh,az as kl,aA as Zh,j as Fr,q as ep,A as tp,D as sp,aB as np,K as rp,Y as op,Q as ip,aC as ap,W as lp,Z as su,_ as cp,$ as dp,a0 as up,aD as fp,a8 as mp,aE as hp,O as pp,M as gp,R as bp,V as nu,U as xp,X as yp}from"./runtimeEndpointReset-B_5A-WIc.js";import{u as At,h as De,al as _t,I as B,am as Gn,t as _e,A as vs,cm as hs,C as Ss,F as js,a4 as qn,j as gn,a2 as Yn,a3 as Pn,o as Yr,gI as Cl,kp as wp,kq as vp,ai as vt,aj as St,ak as jt,a0 as zt,Z as ot,f7 as Sp,ir as ru,kr as oo,eR as ps,c7 as Is,c4 as ou,c3 as iu,cG as Wi,ks as jp,gy as au,cH as lu,c6 as cu,kt as kp,ff as Cp,ku as Nl,kv as Al,kw as du,kx as Np,ky as Pl,kz as Ap,kA as Pp,kB as Ia,eX as Ki,gH as uu,kC as Dp,kD as Ip,kE as Tp,fC as fu,kF as Ep,kG as Rp,kH as Mp,fs as ur,kI as Op,kJ as Bp,b5 as Fp,ft as Lp,b1 as mu,kK as _p,b3 as $p,kL as zp,kM as hu,kN as pu,kO as gu,kP as bu,kQ as xu,kR as yu,kS as wu,hR as Qr,a as Ta,$ as Ea,aF as zn,b8 as Xr,b9 as Wp,e as ks,d as Cs,c as Hs,D as Ls,b as _s,bW as Qn,B as mt,S as bn,an as ms,kT as Kp,kU as Vp,cy as pn,cl as cr,cz as Ps,cB as Yo,m as vu,aH as Vi,aE as Dl,aD as Il,kV as Up,p as ln,q as cn,r as Js,v as dn,w as ds,y as Wn,gZ as Er,x as Tl,bX as Lr,aC as Hp,c0 as Qo,bJ as Gp,bL as Ra,ck as qp,bK as Yp,a1 as Xn,d9 as Su,n as ju,dj as Qp,dm as Xp,bP as Jp,dn as Zp,bZ as ku,gj as eg,gk as tg,bR as Ma,dy as sg,l as Cu,kW as hr,_ as Nu,kX as ng,a8 as Wt,fv as rg,kY as og,aS as ig,bo as Dn,kZ as ag,k_ as dr,cb as Au,cP as lg,aG as cg,dx as In,k$ as dg,l0 as ug,g1 as fg,l1 as wi,l2 as mg,l3 as hg,l4 as pg,l5 as Pu,dB as gg,l6 as Oa,l7 as bg,l8 as Du,j0 as xg,k as Ui,ko as Hi,fa as El,l9 as yg,la as Rl,lb as Rr,fm as Ur,fn as Ba,fP as wg,fM as Iu,cu as Cr,cr as Mr,lc as vg,ld as Sg,hX as jg,fK as Fa,le as kg,g0 as Cg,cw as Ng,cs as Ag,cv as Pg,ct as Dg,lf as Tu,bN as Us,b7 as Ig,lg as Eu,lh as Tg,fS as Gi,li as Eg,lj as Ru,iz as es,jH as Rg,jI as Mg,lk as Mu,ll as Og,ip as La,b2 as _a,lm as Ml,fR as Bo,fo as $a,ln as Bg,fQ as Ou,lo as Bu,lp as qi,fp as Fu,fD as za,fE as Wa,fF as Ka,lq as Fg,lr as Lg,iG as Gt,ls as _g,i0 as yr,h$ as Lu,lt as _u,lu as $u,lv as zu,lw as $g,fx as zg,lx as Wg,ly as Kg,fG as Wu,fT as Vg,lz as Ug,lA as Ol,lB as Hg,lC as Ku,c5 as Vu,ho as Gg,lD as qg,lE as Yg,lF as Qg,lG as _r,fH as Yi,lH as Xg,lI as Jg,lJ as Zg,lK as eb,fU as tb,lL as Uu,lM as Xo,lN as sb,gP as Hr,a6 as nb,fy as Jo,lO as rb,lP as ob,lQ as Bl,hZ as ib,lR as ab,fL as lb,fO as cb,iq as db,lS as ub,bs as Fl,br as Ll,bq as _l,lT as fb,bg as Qi,lU as mb,fA as hb,fB as vi,gt as pb,cp as gb,cj as bb,gv as xb,gw as yb,lV as wb,lW as vb,lX as Sb,i_ as jb,ic as kb,cq as Cb,lY as Fo,lZ as Nb,l_ as $l,l$ as Ab,go as Pb,m0 as Db,m1 as Ib,fl as Hu,eS as Xi,eT as Va,hv as Gu,m2 as Tb,m3 as Po,js as Eb,fq as Rb,jt as Mb,m4 as Ob,m5 as Bb,hF as Fb,ie as Lb,m6 as _b,iv as zl,m7 as $b,bc as zb,bd as Wb,bf as Kb,be as Vb,bl as Wl,bk as Kl,bh as Vl,bi as Ul,ga as qu,bj as Yu,bn as Ub,bx as Hb,by as Gb,bz as qb,bA as Yb,bB as Qb,gg as Xb,bt as Jb,bu as Zb,bv as ex,bw as tx}from"./useAppFontEffects-Cz-1Efdn.js";import{u as Qu,S as Hl,C as sx,t as nx,W as Xu,f as rx,G as ox,a as ix}from"./useRootScrollLock-sHvuqb26.js";import{u as En,O as Gl,c as ax,D as lx,a as cx,f as dx,d as ql,e as ux,g as fx,h as mx,r as hx}from"./scheduledTasksApi-MxDvG-t3.js";import{f as Zo,h as fn,T as ei,M as ti,D as si,j as ni,d as px,b as gx,k as bx,i as xx}from"./vendor-dnd-kit-core-B-dmENub.js";import{u as ri,S as Ua,h as yx,a as Ju,v as Zu,s as wx}from"./vendor-dnd-kit-sortable-DiuAkJDx.js";import{C as oi}from"./vendor-dnd-kit-utilities-D2MO70n8.js";import{S as ef,M as tf,C as sf,f as Ji,g as Zi,e as ea,h as nf,m as vx,n as Sx}from"./vendor-base-ui-BV0ycO3d.js";import{a as Jr,u as Un,d as jx,p as kx}from"./vendor-zustand-XNmn2Hnw.js";import{g as Cx,a as Nx,E as rf,b as Ax,c as Px,d as Dx,e as Ix,i as Tx}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as Ex}from"./PluginPane-CaHXDA-2.js";import{a as Ha,s as Hn,r as of,o as Yl,b as Ql}from"./vendor-zod-C3BVLiwa.js";import{u as Rx}from"./vendor-tanstack-react-virtual-BHz8HhxS.js";import{d as Mx}from"./vendor-tanstack-virtual-core-BoA4iGMw.js";import{d as af}from"./vendor-cron-parser-B7wFT8N0.js";const Ox="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",Bx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",Si=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Ox:t.id==="terminal"?Bx:void 0}),Xl=t=>{const e=nt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l(!0),e[2]=g):g=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=De("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},Fx=t=>{const e=nt.c(75),{directory:n,className:r}=t,{t:i}=At(),o=En(Lx),l=En(_x),a=En($x),d=En(zx),u=En(Wx),m=En(Kx),f=En(Vx);let g,y;e[0]!==u?(g=()=>{u()},y=[u],e[0]=u,e[1]=g,e[2]=y):(g=e[1],y=e[2]),c.useEffect(g,y);const b=mn()&&qo();let j;e:{let we;e[3]!==l||e[4]!==o?(we=l.find(L=>L.id===o)??l.find(Ux)??l[0]??Gl[0],e[3]=l,e[4]=o,e[5]=we):we=e[5];const fe=we;if(fe){let L;e[6]!==fe?(L=Si(fe),e[6]=fe,e[7]=L):L=e[7],j=L;break e}let Ne;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ne=Si(Gl[0]),e[8]=Ne):Ne=e[8],j=Ne}const x=j;if(!b||!n||l.length===0)return null;let h;e[9]!==n?(h=async we=>{await Hm(n,we.id,we.appName)||await Gm(n,we.appName)},e[9]=n,e[10]=h):h=e[10];const p=h;let w;e[11]!==p||e[12]!==f?(w=async we=>{await f(we.id),await p(we)},e[11]=p,e[12]=f,e[13]=w):w=e[13];const S=w;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await Gn(n)).ok&&_e.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const P=N;let C;e[17]!==r?(C=De("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=C):C=e[18];let T;e[19]!==p||e[20]!==x?(T=()=>{p(x)},e[19]=p,e[20]=x,e[21]=T):T=e[21];const R=d&&"animate-pulse";let M;e[22]!==R?(M=De("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",R),e[22]=R,e[23]=M):M=e[23];let F;e[24]!==x.label||e[25]!==i?(F=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=F):F=e[26];let K;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(K=s.jsx(Xl,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=K):K=e[30];let D;e[31]!==M||e[32]!==F||e[33]!==K||e[34]!==T?(D=s.jsx("button",{type:"button",onClick:T,className:M,"aria-label":F,children:K}),e[31]=M,e[32]=F,e[33]=K,e[34]=T,e[35]=D):D=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=De("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=U):U=e[36];let A;e[37]!==i?(A=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=A):A=e[38];let E;e[39]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=E):E=e[39];let W;e[40]!==A?(W=s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:U,"aria-label":A,children:E})}),e[40]=A,e[41]=W):W=e[41];let k;e[42]!==P?(k=()=>{P()},e[42]=P,e[43]=k):k=e[43];let v;e[44]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(B,{name:"file-copy",className:"h-4 w-4"}),e[44]=v):v=e[44];let I;e[45]!==i?(I=i("openInApp.actions.copyPath"),e[45]=i,e[46]=I):I=e[46];let H;e[47]!==I?(H=s.jsx("span",{className:"typography-ui-label text-foreground",children:I}),e[47]=I,e[48]=H):H=e[48];let $;e[49]!==k||e[50]!==H?($=s.jsxs(_t,{className:"flex items-center gap-2",onClick:k,children:[v,H]}),e[49]=k,e[50]=H,e[51]=$):$=e[51];let re;e[52]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(hs,{}),e[52]=re):re=e[52];let te;if(e[53]!==l||e[54]!==S||e[55]!==x.id){let we;e[57]!==S||e[58]!==x.id?(we=fe=>{const Ne=Si(fe);return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{S(fe)},children:[s.jsx(Xl,{label:fe.label,iconDataUrl:fe.iconDataUrl,fallbackIconDataUrl:Ne.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:fe.label}),x.id===fe.id?s.jsx(B,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},fe.id)},e[57]=S,e[58]=x.id,e[59]=we):we=e[59],te=l.map(we),e[53]=l,e[54]=S,e[55]=x.id,e[56]=te}else te=e[56];let ee;e[60]!==a||e[61]!==m||e[62]!==i?(ee=a?s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(B,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=m,e[62]=i,e[63]=ee):ee=e[63];let ue;e[64]!==$||e[65]!==te||e[66]!==ee?(ue=s.jsxs(Ss,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[$,re,te,ee]}),e[64]=$,e[65]=te,e[66]=ee,e[67]=ue):ue=e[67];let de;e[68]!==W||e[69]!==ue?(de=s.jsxs(js,{children:[W,ue]}),e[68]=W,e[69]=ue,e[70]=de):de=e[70];let Te;return e[71]!==D||e[72]!==de||e[73]!==C?(Te=s.jsxs("div",{className:C,children:[D,de]}),e[71]=D,e[72]=de,e[73]=C,e[74]=Te):Te=e[74],Te};function Lx(t){return t.selectedAppId}function _x(t){return t.availableApps}function $x(t){return t.isCacheStale}function zx(t){return t.isScanning}function Wx(t){return t.initialize}function Kx(t){return t.loadInstalledApps}function Vx(t){return t.selectApp}function Ux(t){return t.id===ax}const Lo=new Map,ta=new Set,lf=()=>{for(const t of ta)t()},ji=(t,e)=>{const n=t.trim();n&&(e.length===0?Lo.delete(n):Lo.set(n,[...e]),lf())},Hx=t=>{Lo.delete(t.trim())&&lf()},cf=[],Gx=t=>Lo.get(t.trim())??cf,qx=t=>(ta.add(t),()=>{ta.delete(t)}),Yx=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=()=>Gx(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(qx,n,Qx)};function Qx(){return cf}const Xx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Jx=["dev","start","preview","serve"];async function Zx(t,e,n){if(!t)return null;const r=sy(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=ny(n);if(i){const o=await ry(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await ey(t)){const i=await ty(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function ey(t){const e=`${t}/index.html`,n=await _o(e,t);return typeof n=="string"&&n.trim().length>0}async function ty(){try{const t=await as("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function sy(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Jx.some(i=>n.includes(i)))return e}return null}function ny(t){for(const{pattern:e}of Xx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function ry(t){const e=await _o(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await _o(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function _o(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await as(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Fd()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await as(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function oy(t){try{const e=await _o(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const Vs="__openchamber_auto_discover_preview__",iy=15e3,ay=3e3,ki=t=>t.id===Vs?"scan-2":Dh.find(n=>n.key===t.icon)?.Icon??"play",ly=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},cy=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=At(),{currentTheme:l}=qn(),{terminal:a,runtime:d}=gn(),u=Yn(),{isMobile:m}=Pn(),f=c.useMemo(()=>mn(),[]),g=Sl(X=>X.instances),y=Sl(X=>X.load),b=ye(X=>X.terminalShell),j=ye(X=>X.terminalLoginShells.includes(X.terminalShell)),x=ye(X=>X.setSettingsPage),h=ye(X=>X.setSettingsDialogOpen),p=ye(X=>X.setSettingsProjectsSelectedId),w=ye(X=>X.openContextPreview),S=Et(X=>X.ensureDirectory),N=Et(X=>X.reconcileServerSessions),P=Et(X=>X.setTabLabel),C=Et(X=>X.setTabIconKey),T=Et(X=>X.setActiveTab),R=Et(X=>X.setConnecting),M=Et(X=>X.setTabSessionId),F=Et(X=>X.setTabPurpose),K=Et(X=>X.allocateActionExecution),D=Et(X=>X.setTabLifecycle),U=Et(X=>X.setTabPreviewUrl),A=Et(X=>X.matchesActionExecution),E=Et(X=>X.captureStartedActionMutationRevisions),[W,k]=c.useState([]),v=c.useRef(null),[I,H]=c.useState(null),[$,re]=c.useState(!1),te=c.useRef({}),ee=c.useRef({}),ue=c.useRef({}),de=c.useRef(new Set),Te=c.useRef(0),[we,fe]=c.useState({}),Ne=t?.id??null,L=t?.path??"",oe=c.useMemo(()=>Ne?{id:Ne,path:L}:null,[Ne,L]);c.useEffect(()=>{f&&y().catch(()=>{})},[f,y]);const ce=c.useCallback(async X=>{await Yr(X)},[]),pe=c.useCallback(async()=>{if(!oe)return;const X=Te.current+1;Te.current=X,re(!0);try{const ae=await Cl(oe);if(Te.current!==X)return;v.current=ae;const Ae=ae.projectActions;k(Ae),H(Ge=>Ge===Vs||Ge&&Ae.some(q=>q.id===Ge)?Ge:null)}catch{if(Te.current!==X)return}finally{Te.current===X&&re(!1)}},[oe]),Y=c.useMemo(()=>bi(e||oe?.path||""),[e,oe?.path]),ve=c.useMemo(()=>bi(oe?.path||""),[oe?.path]),Ee=c.useMemo(()=>bi(u||"")||Y,[u,Y]),je=c.useRef(Ee);c.useEffect(()=>{je.current=Ee},[Ee]);const ge=Et(X=>Y?X.getDirectoryState(Y):void 0),be=Et(X=>ve&&ve!==Y?X.getDirectoryState(ve):void 0),Q=c.useMemo(()=>{const X=Y?[{directory:Y,state:ge}]:[];return ve&&ve!==Y&&X.push({directory:ve,state:be}),X},[ge,Y,ve,be]),_=c.useMemo(()=>{const X=Y?[Y]:[];return ve&&ve!==Y&&X.push(ve),X},[Y,ve]),J=c.useCallback(X=>X.id!==Vs&&X.runIn==="parent"&&ve||Y,[Y,ve]),me=c.useCallback((X,ae,Ae)=>`${X}::${ae}::${Ae}`,[]),le=c.useCallback((X,ae,Ae=Et.getState())=>X?Ae.getDirectoryState(X)?.tabs.find(Ge=>Ge.purpose.type==="project-action"&&Ge.purpose.actionId===ae)??null:null,[]),V=c.useMemo(()=>{const X={};for(const{directory:ae,state:Ae}of Q)for(const Ge of Ae?.tabs??[]){if(Ge.purpose.type!=="project-action"||!Ge.purpose.executionId||!Ge.terminalSessionId||Ge.lifecycle==="idle"||Ge.lifecycle==="exited")continue;const q=Ws(ae,Ge.purpose.actionId),Fe=me(ae,Ge.purpose.actionId,Ge.purpose.executionId);X[q]={directory:ae,actionId:Ge.purpose.actionId,tabId:Ge.id,sessionId:Ge.terminalSessionId,executionId:Ge.purpose.executionId,status:Ge.lifecycle==="stopping"?"stopping":we[Fe]?"waiting-for-preview":"running"}}return X},[me,we,Q]),Z=c.useCallback((X,ae,Ae)=>{const Ge=Ws(X,ae),q=me(X,ae,Ae),Ze=te.current[Ge]?.executionId===Ae,Je=globalThis.window,et=kt=>{Je?.clearTimeout(ue.current[kt]),delete ue.current[kt]};Ze&&(delete te.current[Ge],et(Ge)),ee.current[q]?.(),delete ee.current[q],et(q),fe(kt=>{if(!kt[q])return kt;const Qe={...kt};return delete Qe[q],Qe})},[me]),G=c.useCallback(X=>{ee.current[X]?.(),delete ee.current[X]},[]),ie=c.useCallback(X=>{window.clearTimeout(ue.current[X]),delete ue.current[X]},[]);c.useEffect(()=>{const X=ee.current,ae=ue.current;return()=>{for(const Ae of Object.keys(X))G(Ae);for(const Ae of Object.keys(ae))ie(Ae)}},[ie,G]),c.useEffect(()=>{const X=new Set(_);for(const ae of Object.values(te.current))X.has(ae.directory)||Z(ae.directory,ae.actionId,ae.executionId);for(const ae of Object.keys(ee.current)){const Ae=ae.split("::",1)[0]??"";X.has(Ae)||G(ae)}},[Z,G,_]);const Se=c.useCallback((X,ae)=>{ye.getState().openContextPanelTab(X,{mode:"terminal",targetDirectory:ae===X?null:ae})},[]),se=c.useMemo(()=>I?W.find(X=>X.id===I)??null:null,[W,I]),Me=c.useMemo(()=>({id:Vs,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),He=!m,We=c.useMemo(()=>He?[Me,...W]:W,[W,Me,He]);c.useEffect(()=>{pe()},[pe]),c.useEffect(()=>{const X=_.map(ae=>_i(a,ae,E,Ae=>N(ae,Ae.sessions,{startedActionMutationRevisions:Ae.startedActionMutationRevisions})));return()=>{for(const ae of X)ae()}},[E,N,a,_]),c.useEffect(()=>{for(const{directory:X,state:ae}of Q)if(X)for(const Ae of ae?.tabs??[]){if(Ae.purpose.type!=="project-action")continue;const Ge=Ae.purpose.actionId,q=We.find(Je=>Je.id===Ge),Fe=q?.name??Ge,Ze=q?.icon||"play";Ae.label!==Fe&&P(X,Ae.id,Fe),Ae.iconKey!==Ze&&C(X,Ae.id,Ze)}},[We,C,P,Q]),c.useEffect(()=>{const X=globalThis.window;if(!X)return;const ae=Ae=>{const Ge=Ae.detail;Ne&&(Ge?.projectId&&Ge.projectId!==Ne||pe())};return X.addEventListener(jl,ae),()=>{X.removeEventListener(jl,ae)}},[pe,Ne]),c.useEffect(()=>{I&&(I===Vs&&He||W.some(X=>X.id===I)||H(null))},[W,He,I]),c.useEffect(()=>{const X=Ae=>{delete ue.current[Ae];const Ge=te.current[Ae];if(!Ge||Ge.openedUrl)return;const q=me(Ge.directory,Ge.actionId,Ge.executionId),Fe=Ge.announced;if(Fe.length!==0){if(window.clearTimeout(ue.current[q]),delete ue.current[q],Ge.openedUrl=!0,fe(Ze=>{if(!Ze[q])return Ze;const Je={...Ze};return delete Je[q],Je}),Fe.length===1){ji(Ge.directory,[]),U(Ge.directory,Ge.tabId,Fe[0],{locked:!1,autoOpened:!0}),w(Ge.directory,Fe[0]);return}Ge.offering=!0,ji(Ge.directory,Fe),ye.getState().openContextSurface(Ge.directory,"browser"),_e.info(o("projectActions.toast.multipleServers"))}},ae=()=>{const Ae=Et.getState(),Ge=Ae.sessions,q=V;for(const[Fe,Ze]of Object.entries(q)){const et=Ge.get(Ze.directory)?.tabs.find(rt=>rt.id===Ze.tabId);if(!et||et.terminalSessionId!==Ze.sessionId){Z(Ze.directory,Ze.actionId,Ze.executionId);continue}const kt=te.current[Fe],Qe=kt?.executionId===Ze.executionId?kt:{hostDirectory:je.current||Ze.directory,directory:Ze.directory,tabId:Ze.tabId,actionId:Ze.actionId,executionId:Ze.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};te.current[Fe]=Qe;const It=We.find(rt=>rt.id===Ze.actionId),Mt=Ae.getBuffer(Ze.directory,Ze.tabId).chunks;if(!It||Mt.length===0)continue;const ke=Mt.filter(rt=>Qe.lastSeenChunkId===null||rt.id>Qe.lastSeenChunkId);if(ke.length===0)continue;const Oe=ke.map(rt=>rt.data).join(""),Re=`${Qe.tail}${Oe}`;if(Qe.openInPreview&&(!Qe.openedUrl||Qe.offering)){const rt=Ah(Re),xt=Qe.announced.length;for(const ze of rt)Qe.announced.includes(ze)||Qe.announced.push(ze);const Pe=Qe.announced.length-xt;Qe.offering&&Pe>0?ji(Ze.directory,Qe.announced):!Qe.openedUrl&&xt===0&&Qe.announced.length>0&&(window.clearTimeout(ue.current[Fe]),ue.current[Fe]=window.setTimeout(()=>X(Fe),ay))}const Be=!Qe.openedUrl&&It.autoOpenUrl===!0&&!Qe.openInPreview?Ph(Re):null,Ke=ke[ke.length-1]?.id??Qe.lastSeenChunkId;if(Qe.lastSeenChunkId=Ke,Qe.tail=Re.slice(-512),Be)if(Qe.openedUrl=!0,Qe.openInPreview){const rt=q[Fe];rt&&(U(rt.directory,rt.tabId,Be,{locked:!1,autoOpened:!1,expectedExecutionId:rt.executionId}),rt.status==="waiting-for-preview"&&fe(xt=>{const Pe=me(rt.directory,rt.actionId,rt.executionId);if(!xt[Pe])return xt;const ze={...xt};return delete ze[Pe],ze}),window.clearTimeout(ue.current[Fe]),delete ue.current[Fe],w(rt.directory,Be))}else ce(Be),_e.success(o("projectActions.toast.openedUrlFromOutput"));te.current[Fe]=Qe}for(const Fe of Object.keys(te.current))if(!q[Fe]){const Ze=te.current[Fe],Je=Ze?Ge.get(Ze.directory)?.tabs.find(kt=>kt.id===Ze.tabId):void 0;if(Je?.purpose.type==="project-action"&&Je.purpose.executionId===Ze?.executionId&&!!Je.terminalSessionId&&Je.lifecycle!=="idle"&&Je.lifecycle!=="exited")continue;delete te.current[Fe],window.clearTimeout(ue.current[Fe]),delete ue.current[Fe]}};return ae(),Et.subscribe((Ae,Ge)=>{(Ae.sessions!==Ge.sessions||Ae.buffers!==Ge.buffers)&&ae()})},[Z,je,We,me,w,ce,V,U,o]),c.useEffect(()=>{for(const{directory:X,state:ae}of Q)for(const Ae of ae?.tabs??[]){if(Ae.purpose.type!=="project-action"||!Ae.purpose.executionId||!Ae.terminalSessionId||Ae.lifecycle!=="running")continue;const Ge=Ae.purpose.actionId,q=Ae.purpose.executionId,Fe=me(X,Ge,q);if(ee.current[Fe])continue;const Ze=a.connect(Ae.terminalSessionId,{onEvent:Je=>{if(!A(X,Ae.id,q))return;Je.type==="snapshot"&&(Et.getState().replaceBuffer(X,Ae.id,Je.data??"",Je.sequence??0,hl(Je)),Je.status==="running"&&Et.getState().setTabLifecycle(X,Ae.id,"running",{expectedExecutionId:q}),Je.status==="exited"&&(Et.getState().setTabLifecycle(X,Ae.id,"exited",{expectedExecutionId:q}),Et.getState().setTabPurpose(X,Ae.id,{type:"project-action",actionId:Ge,executionId:null}),Z(X,Ge,q)));const et=Je.type==="data"?Je.data??"":"";et&&Et.getState().appendToBuffer(X,Ae.id,et,Je.sequence,Je.replayData),Je.type==="exit"&&(Et.getState().setTabLifecycle(X,Ae.id,"exited",{expectedExecutionId:q}),Et.getState().setTabPurpose(X,Ae.id,{type:"project-action",actionId:Ge,executionId:null}),Z(X,Ge,q))},onError:(Je,et)=>{!et||!A(X,Ae.id,q)||(Et.getState().setTabLifecycle(X,Ae.id,"exited",{expectedExecutionId:q}),Et.getState().setTabSessionId(X,Ae.id,null,{expectedExecutionId:q}),Et.getState().setTabPurpose(X,Ae.id,{type:"project-action",actionId:Ge,executionId:null}),Z(X,Ge,q))}},X);ee.current[Fe]=Ze.close}},[Z,me,A,a,Q]);const Le=c.useCallback(async X=>{const ae=J(X);if(!ae)throw new Error(o("projectActions.error.noActiveDirectory"));const Ae=Ws(ae,X.id);S(ae);const Ge=Et.getState(),q=le(ae,X.id,Ge),Fe=q?.id??Ge.createTab(ae);P(ae,Fe,X.name),C(ae,Fe,X.icon||"play"),q||F(ae,Fe,{type:"project-action",actionId:X.id,executionId:null}),T(ae,Fe);const Je=Et.getState().getDirectoryState(ae)?.tabs.find(et=>et.id===Fe);return{executionDirectory:ae,key:Ae,tabId:Fe,sessionId:Je?.terminalSessionId??null,executionId:Je?.purpose.type==="project-action"?Je.purpose.executionId:null}},[S,J,le,T,C,P,F,o]),Ve=c.useCallback(async X=>{if(d.isVSCode||!i&&m)return;if(!Y){_e.error(o("projectActions.error.noActiveDirectoryForAction"));return}const ae=Ws(J(X),X.id),Ae=V[ae];if(Ae&&Ae.status==="running"||de.current.has(ae))return;de.current.add(ae);let Ge=null;try{const q=X.id===Vs?await(async()=>{const[Pe,ze]=await Promise.all([wp({id:oe?.id??"",path:Y}),oy(Y)]),st=await Zx(Y,Pe.actions,ze);if(!st)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Vs,name:o("projectActions.actions.autoDiscover"),command:st.command,icon:"scan-2",autoOpenUrl:!0,openUrl:st.previewUrlHint||""}})():X,Fe=q.autoOpenUrl===!0&&(q.openUrl||"").trim().length>0,Ze=!Fe&&X.id!==Vs,Je=je.current||Y,{executionDirectory:et,key:kt,tabId:Qe}=await Le(q),It=Sh(q.command);if(!It)throw new Error(o("projectActions.error.failedToRunAction"));const Mt=q.autoOpenUrl===!0&&f&&(q.desktopOpenSshForward||"").trim().length>0,ke=q.autoOpenUrl?ly(q.openUrl):null,Oe=q.autoOpenUrl&&f?jh(q.desktopOpenSshForward,g):null;if(a.listSessions){const Pe=le(et,q.id);if(Pe?.purpose.type==="project-action"&&Pe.purpose.executionId===null){const ze=await kh(a,et,{captureStartedActionMutationRevisions:E});ze&&N(et,ze.sessions,{startedActionMutationRevisions:ze.startedActionMutationRevisions})}}const Re=le(et,q.id);let Be,Ke;if(Re?.lifecycle==="running"&&Re.terminalSessionId&&Re.purpose.type==="project-action"&&Re.purpose.executionId)Be=Re.terminalSessionId,Ke=Re.purpose.executionId;else{const Pe=Re?.purpose.type==="project-action"?Re.purpose.executionId:null;Pe&&Z(et,q.id,Pe);const ze=K(et,Qe,q.id);if(!ze)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Ge={directory:et,tabId:Qe,id:ze},R(et,Qe,!0,{expectedExecutionId:ze});const st=await Ch({terminal:a,createOptions:{cwd:et,shell:b,loginShell:j,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:It,isRunStillExpected:()=>A(et,Qe,ze),purpose:{type:"project-action",actionId:q.id,executionId:ze}});if(!A(et,Qe,ze)){st.sessionId===ze&&await a.close(st.sessionId).catch(()=>{});return}Ke=st.purpose?.type==="project-action"?st.purpose.executionId:ze,Be=st.sessionId,F(et,Qe,{type:"project-action",actionId:q.id,executionId:Ke}),M(et,Qe,Be,{expectedExecutionId:Ke}),R(et,Qe,!1,{expectedExecutionId:Ke})}Ze&&Je&&Se(Je,et),te.current[kt]={hostDirectory:Je,directory:et,tabId:Qe,actionId:q.id,executionId:Ke,lastSeenChunkId:null,openedUrl:!!Oe||!!ke||Fe,tail:"",openInPreview:q.id===Vs,announced:[],offering:!1};const rt=me(et,q.id,Ke);R(et,Qe,!0,{expectedExecutionId:Ke});const xt=a.connect(Be,{onEvent:Pe=>{if(!A(et,Qe,Ke)||Pe.purpose?.type==="project-action"&&Pe.purpose.executionId!==Ke)return;Pe.type==="snapshot"&&(Et.getState().replaceBuffer(et,Qe,Pe.data??"",Pe.sequence??0,hl(Pe)),Et.getState().setConnecting(et,Qe,!1,{expectedExecutionId:Ke}),Pe.purpose?.type==="project-action"&&Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:Pe.purpose.actionId,executionId:Pe.purpose.executionId}),Pe.status==="running"&&Et.getState().setTabLifecycle(et,Qe,"running",{expectedExecutionId:Ke}),Pe.status==="exited"&&(Et.getState().setTabLifecycle(et,Qe,"exited",{expectedExecutionId:Ke}),Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ke)));const ze=Pe.type==="data"?Pe.data??"":"";ze&&Et.getState().appendToBuffer(et,Qe,ze,Pe.sequence,Pe.replayData),Pe.type==="exit"&&(Et.getState().setTabLifecycle(et,Qe,"exited",{expectedExecutionId:Ke}),Et.getState().setConnecting(et,Qe,!1,{expectedExecutionId:Ke}),Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ke))},onError:(Pe,ze)=>{A(et,Qe,Ke)&&(Et.getState().setConnecting(et,Qe,!1,{expectedExecutionId:Ke}),ze&&(Et.getState().setTabLifecycle(et,Qe,"exited",{expectedExecutionId:Ke}),Et.getState().setTabSessionId(et,Qe,null,{expectedExecutionId:Ke}),Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ke)))}},et);if(!A(et,Qe,Ke)){xt.close();return}ee.current[rt]?.(),ee.current[rt]=xt.close,window.clearTimeout(ue.current[rt]),delete ue.current[rt],q.id===Vs&&!ke&&(fe(Pe=>({...Pe,[rt]:!0})),ue.current[rt]=window.setTimeout(()=>{delete ue.current[rt];const Pe=te.current[kt];!Pe||Pe.executionId!==Ke||Pe.openedUrl||Pe.offering||A(et,Qe,Ke)&&(fe(ze=>{if(!ze[rt])return ze;const st={...ze};return delete st[rt],st}),Et.getState().setActiveTab(et,Qe),Se(Pe.hostDirectory,et))},iy)),Oe?(U(et,Qe,null,{locked:!0,expectedExecutionId:Ke}),ce(Oe),_e.success(o("projectActions.toast.openedForwardedUrl"))):ke?(U(et,Qe,ke,{locked:!0,autoOpened:!0,expectedExecutionId:Ke}),w(Je,ke),_e.success(o("projectActions.toast.openedActionUrl"))):Fe?(U(et,Qe,null,{locked:!0,expectedExecutionId:Ke}),_e.error(o("projectActions.error.invalidCustomUrlFormat"))):Mt?(U(et,Qe,null,{locked:!0,expectedExecutionId:Ke}),_e.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):U(et,Qe,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ke})}catch(q){if(Ge&&A(Ge.directory,Ge.tabId,Ge.id)){const{directory:Fe,tabId:Ze,id:Je}=Ge;Z(Fe,X.id,Je),D(Fe,Ze,"exited",{expectedExecutionId:Je}),F(Fe,Ze,{type:"project-action",actionId:X.id,executionId:null})}if(q instanceof Error&&q.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(q instanceof Error&&(q.message==="COMMAND_MODE_UNSUPPORTED"||q.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){_e.error(o("projectActions.error.failedToCreateTerminalSession"));return}_e.error(q instanceof Error?q.message:o("projectActions.error.failedToRunAction"))}finally{de.current.delete(ae)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,je,g,Le,i,m,f,Y,j,b,ce,w,V,Se,d.isVSCode,J,A,Z,me,le,N,K,E,R,D,F,U,M,oe?.id,o,a]),O=c.useCallback(async X=>{const ae=Ws(J(X),X.id),Ae=V[ae];Ae&&await Nh({terminal:a,sessionId:Ae.sessionId,isExecutionStillCurrent:()=>A(Ae.directory,Ae.tabId,Ae.executionId),markStopping:()=>{D(Ae.directory,Ae.tabId,"stopping",{expectedExecutionId:Ae.executionId})},restoreRunning:()=>{D(Ae.directory,Ae.tabId,"running",{expectedExecutionId:Ae.executionId})},clearSession:()=>{M(Ae.directory,Ae.tabId,null,{expectedExecutionId:Ae.executionId})},finalizeExit:()=>{D(Ae.directory,Ae.tabId,"exited",{expectedExecutionId:Ae.executionId}),F(Ae.directory,Ae.tabId,{type:"project-action",actionId:Ae.actionId,executionId:null}),Z(Ae.directory,Ae.actionId,Ae.executionId)}})},[Z,J,A,V,D,F,M,a]),he=c.useCallback(()=>{const X=se??We[0];if(!X)return;const ae=Ws(J(X),X.id),Ae=V[ae];if(Ae?.status!=="stopping"){if(Ae){O(X);return}Ve(X)}},[We,J,Ve,V,se,O]),$e=c.useCallback(async X=>{if(X.source==="shared"&&oe){const ae=v.current?.trust.trusted?v.current:await Cl(oe);if(v.current=ae,!await vp(oe,ae))return;v.current={...ae,trust:{...ae.trust,trusted:!0}}}await Ve(X)},[Ve,oe]),Ue=c.useCallback((X,ae=!1)=>{if(H(X.id),!ae){$e(X);return}const Ae=Ws(J(X),X.id),Ge=V[Ae];if(Ge?.status!=="stopping"){if(Ge){O(X);return}$e(X)}},[J,$e,V,O]),ct=c.useCallback(()=>{oe?.id&&(p(oe.id),x("projects"),h(!0))},[h,x,p,oe?.id]),pt=se??We[0]??null,it=pt?V[Ws(J(pt),pt.id)]:null,ft=Et(X=>it?X.getDirectoryState(it.directory)?.tabs.find(ae=>ae.id===it.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&m||!oe||!Y)return null;const yt=se??We[0]??null;if(!yt)return null;const ht=ki(yt),bt=Ws(J(yt),yt.id),Dt=V[bt],xe=Dt?.status==="stopping",Ye=Dt?.status==="waiting-for-preview",Xe=!!(Dt&&ft),qe=()=>{!Dt||!ft||w(Dt.directory,ft)},dt=yt.id===Vs;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",disabled:$||xe,className:De("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:he,"aria-label":Dt?o("projectActions.actions.stopNamedAria",{name:yt.name}):o("projectActions.actions.runNamedAria",{name:yt.name}),children:xe||Ye?s.jsx(B,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Dt?s.jsx(B,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(B,{name:ht,className:"h-5 w-5"})})}),dt?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Xe?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:qe,children:s.jsx(B,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ss,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:ct,children:[s.jsx(B,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(hs,{}),We.map(X=>{const ae=ki(X),Ae=Ws(J(X),X.id),Ge=V[Ae],q=!!Ge,Fe=Ge?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ue(X,!0)},children:[s.jsx(B,{name:ae,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),X.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||Ge?.status==="waiting-for-preview"?s.jsx(B,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):q?s.jsx(B,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]}):s.jsxs("div",{className:De("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,disabled:$||xe,className:De("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":Dt?o("projectActions.actions.stopNamedAria",{name:yt.name}):o("projectActions.actions.runNamedAria",{name:yt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:xe||Ye?s.jsx(B,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Dt?s.jsx(B,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(B,{name:ht,className:"h-4 w-4"})})})}),dt?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Xe?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:qe,className:De(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(B,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:De(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ss,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:ct,children:[s.jsx(B,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(hs,{}),We.map(X=>{const ae=ki(X),Ae=Ws(J(X),X.id),Ge=V[Ae],q=!!Ge,Fe=Ge?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ue(X,!0)},children:[s.jsx(B,{name:ae,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),X.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||Ge?.status==="waiting-for-preview"?s.jsx(B,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):q?s.jsx(B,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]})},Or=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},dy=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Or(n??"");if(i){const o=ru(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function uy(){const t=zt(b=>b.projects),e=zt(b=>b.activeProjectId),n=ot(b=>b.availableWorktreesByProject),r=ot(b=>b.currentSessionId),i=Sp(r??null),o=ot(b=>r?b.worktreeMetadata.get(r)?.path??"":""),l=ot(b=>b.newSessionDraft?.open?Or(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Or(o||""),[o]),d=c.useMemo(()=>{const b=typeof i?.directory=="string"?i.directory:"";return Or(b||"")},[i?.directory]),u=a||d||l,m=c.useMemo(()=>dy({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>Or(u||m?.path||""),[u,m?.path]),g=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),y=c.useRef(null);return c.useEffect(()=>{g&&f&&(y.current={projectRef:g,directory:f})},[f,g]),c.useMemo(()=>g&&f?{projectRef:g,directory:f}:y.current,[g,f])}const fy=({transform:t})=>({...t,y:0}),my={Item:_t,Separator:hs},hy={Item:({className:t,...e})=>s.jsx(tf,{className:De(lu,t),...e}),Separator:({className:t,...e})=>s.jsx(ef,{className:De(au,t),...e})},py=t=>{const e=nt.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:m}=t,{t:f}=At(),[g,y]=c.useState(!1),[b,j]=c.useState(!1),[x,h]=c.useState(!1);let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:w,listeners:S,setNodeRef:N,transform:P,transition:C,isDragging:T}=ri(p);let R;e[2]!==f||e[3]!==n.session.title?(R=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=R):R=e[4];const M=R,F=!i&&(g||b),K=n.id;let D;e[5]!==n.session?(D=Is(n.session),e[5]=n.session,e[6]=D):D=e[6];const U=Da(K,D),A=ou(n.id),W=iu(n.id)>0&&!r&&!A,k=A||W;let v;e[7]!==A||e[8]!==f?(v=f(A?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=A,e[8]=f,e[9]=v):v=e[9];const I=v;let H;e[10]!==d||e[11]!==x||e[12]!==r||e[13]!==g||e[14]!==o||e[15]!==n?(H=ve=>({session:n.session,open:g||x,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:ve}),e[10]=d,e[11]=x,e[12]=r,e[13]=g,e[14]=o,e[15]=n,e[16]=H):H=e[16];const $=H;let re;e[17]!==P?(re=oi.Translate.toString(P),e[17]=P,e[18]=re):re=e[18];let te;e[19]!==re||e[20]!==C?(te={transform:re,transition:C},e[19]=re,e[20]=C,e[21]=te):te=e[21];const ee=T&&"z-10 opacity-60";let ue;e[22]!==ee?(ue=De("session-tab-slot flex h-7 w-44 shrink-0 touch-none",ee),e[22]=ee,e[23]=ue):ue=e[23];const de=r?"true":"false";let Te;e[24]!==r?(Te=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Te):Te=e[25];let we;e[26]!==u?(we=ve=>u?.(ve),e[26]=u,e[27]=we):we=e[27];let fe;e[28]!==m||e[29]!==I||e[30]!==r||e[31]!==U||e[32]!==A||e[33]!==$||e[34]!==g||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==F||e[39]!==a||e[40]!==k||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==M?(fe=s.jsx(sf,{render:ve=>s.jsxs("div",{...ve,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),o(n))},onAuxClick:Ee=>{Ee.button===1&&(Ee.preventDefault(),l(n.id))},"data-controls-open":F?"true":"false",className:De("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":De("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",F&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:De("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",F&&"pr-10"),children:[s.jsx("div",{className:De("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?m:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:M})})}),U?s.jsx(B,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):k?s.jsx(cu,{state:A?"running":"unread",label:I,className:De("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",F&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:by,onPointerDown:xy,className:De("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",F&&"flex opacity-100"),children:[s.jsxs(js,{open:g,onOpenChange:Ee=>{y(Ee),Ee&&j(!0)},onOpenChangeComplete:Ee=>{Ee||j(!1),u?.(Ee)},children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"more",className:"size-4"})})}),s.jsx(Ss,{align:"start",className:"min-w-[190px]",children:a($(my))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]})]})}),e[28]=m,e[29]=I,e[30]=r,e[31]=U,e[32]=A,e[33]=$,e[34]=g,e[35]=l,e[36]=u,e[37]=o,e[38]=F,e[39]=a,e[40]=k,e[41]=i,e[42]=f,e[43]=n,e[44]=M,e[45]=fe):fe=e[45];let Ne,L;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ne={color:"var(--surface-elevated-foreground)"},L=De(Wi,"min-w-[190px]"),e[46]=Ne,e[47]=L):(Ne=e[46],L=e[47]);let oe;e[48]!==$||e[49]!==a?(oe=a($(hy)),e[48]=$,e[49]=a,e[50]=oe):oe=e[50];let ce;e[51]!==oe?(ce=s.jsx(Ji,{children:s.jsx(Zi,{className:"app-region-no-drag z-50",children:s.jsx(ea,{"data-slot":"dropdown-menu-content",style:Ne,className:L,children:oe})})}),e[51]=oe,e[52]=ce):ce=e[52];let pe;e[53]!==x||e[54]!==we||e[55]!==fe||e[56]!==ce?(pe=s.jsxs(nf,{open:x,onOpenChange:h,onOpenChangeComplete:we,children:[fe,ce]}),e[53]=x,e[54]=we,e[55]=fe,e[56]=ce,e[57]=pe):pe=e[57];let Y;return e[58]!==w||e[59]!==S||e[60]!==N||e[61]!==ue||e[62]!==de||e[63]!==Te||e[64]!==pe||e[65]!==te?(Y=s.jsx("div",{ref:N,style:te,className:ue,"data-active":de,...Te,...w,...S,children:pe}),e[58]=w,e[59]=S,e[60]=N,e[61]=ue,e[62]=de,e[63]=Te,e[64]=pe,e[65]=te,e[66]=Y):Y=e[66],Y},gy=t=>{const e=nt.c(65),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=At(),d=oo(yy),u=oo(wy),m=oo(vy),f=oo(Sy),g=ot(jy),y=ot(ky),b=ps(Cy),j=Ih(g);let x,h;e[0]!==j||e[1]!==g||e[2]!==u?(x=()=>{g&&u(g,j)},h=[g,j,u],e[0]=j,e[1]=g,e[2]=u,e[3]=x,e[4]=h):(x=e[3],h=e[4]),c.useEffect(x,h);let p;if(e[5]!==b){p=new Map;for(const ge of b)p.set(ge.id,ge);e[5]=b,e[6]=p}else p=e[6];const w=p;let S;if(e[7]!==w||e[8]!==d){S=[];for(const ge of d){const be=w.get(ge);be&&S.push({id:ge,session:be})}e[7]=w,e[8]=d,e[9]=S}else S=e[9];const N=S;let P;e[10]!==y?(P=ge=>{y(ge.id,Is(ge.session))},e[10]=y,e[11]=P):P=e[11];const C=P,T=Ny;let R;e[12]!==m||e[13]!==g||e[14]!==C||e[15]!==N?(R=ge=>{if(m(ge),g&&g!==ge){const be=N.find(Q=>Q.id===ge);be&&C(be)}},e[12]=m,e[13]=g,e[14]=C,e[15]=N,e[16]=R):R=e[16];const M=R;let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},e[17]=F):F=e[17];let K;e[18]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{delay:200,tolerance:6}},e[18]=K):K=e[18];const D=Zo(fn(ti,F),fn(ei,K));let U;e[19]!==f?(U=ge=>{const{active:be,over:Q}=ge;Q&&be.id!==Q.id&&f(String(be.id),String(Q.id))},e[19]=f,e[20]=U):U=e[20];const A=U,E=c.useRef(null);let W;e[21]===Symbol.for("react.memo_cache_sentinel")?(W={left:!1,right:!1},e[21]=W):W=e[21];const[k,v]=c.useState(W);let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const ge=E.current;if(!ge)return;const be=ge.scrollLeft>2,Q=ge.scrollLeft+ge.clientWidth<ge.scrollWidth-2;v(_=>_.left===be&&_.right===Q?_:{left:be,right:Q})},e[22]=I):I=e[22];const H=I;let $;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>{H();const ge=E.current;if(!ge||!globalThis.ResizeObserver)return;const be=new ResizeObserver(H);return be.observe(ge),()=>be.disconnect()},e[23]=$):$=e[23];let re;e[24]!==N.length?(re=[H,N.length],e[24]=N.length,e[25]=re):re=e[25],c.useEffect($,re);let te;e[26]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{E.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[26]=te):te=e[26];let ee;e[27]!==g?(ee=[g],e[27]=g,e[28]=ee):ee=e[28],c.useEffect(te,ee);const ue=k.left&&k.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":k.left?"linear-gradient(to right, transparent, black 24px)":k.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let de;e[29]!==N?(de=N.map(Ay),e[29]=N,e[30]=de):de=e[30];const Te=de;let we;e[31]!==g||e[32]!==N?(we=!g||!N.some(ge=>ge.id===g),e[31]=g,e[32]=N,e[33]=we):we=e[33];const fe=we;let Ne;e[34]!==a?(Ne=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=Ne):Ne=e[35];let L;e[36]!==ue?(L=ue?{maskImage:ue,WebkitMaskImage:ue}:void 0,e[36]=ue,e[37]=L):L=e[37];let oe;e[38]===Symbol.for("react.memo_cache_sentinel")?(oe=[fy],e[38]=oe):oe=e[38];let ce;e[39]!==o||e[40]!==g||e[41]!==M||e[42]!==C||e[43]!==r||e[44]!==n||e[45]!==l||e[46]!==N?(ce=N.map(ge=>s.jsx(py,{tab:ge,isActive:ge.id===g,suppressControls:ge.id===g&&l,onSelect:C,onClose:T,renderMenu:n,closeOtherTabs:M,onMenuOpenChangeComplete:r,children:ge.id===g?o:null},ge.id)),e[39]=o,e[40]=g,e[41]=M,e[42]=C,e[43]=r,e[44]=n,e[45]=l,e[46]=N,e[47]=ce):ce=e[47];let pe;e[48]!==ce||e[49]!==Te?(pe=s.jsx(Ua,{items:Te,strategy:yx,children:ce}),e[48]=ce,e[49]=Te,e[50]=pe):pe=e[50];let Y;e[51]!==A||e[52]!==D||e[53]!==pe?(Y=s.jsx(si,{sensors:D,collisionDetection:ni,modifiers:oe,onDragEnd:A,children:pe}),e[51]=A,e[52]=D,e[53]=pe,e[54]=Y):Y=e[54];let ve;e[55]!==o||e[56]!==fe?(ve=fe?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[55]=o,e[56]=fe,e[57]=ve):ve=e[57];let Ee;e[58]!==L||e[59]!==Y||e[60]!==ve?(Ee=s.jsxs("div",{ref:E,onScroll:H,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:L,children:[Y,ve]}),e[58]=L,e[59]=Y,e[60]=ve,e[61]=Ee):Ee=e[61];let je;return e[62]!==Ne||e[63]!==Ee?(je=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ne,children:Ee}),e[62]=Ne,e[63]=Ee,e[64]=je):je=e[64],je};function by(t){return t.stopPropagation()}function xy(t){return t.stopPropagation()}function yy(t){return t.tabIds}function wy(t){return t.ensureTab}function vy(t){return t.closeOtherTabs}function Sy(t){return t.reorderTabs}function jy(t){return t.currentSessionId}function ky(t){return t.setCurrentSession}function Cy(t){return t.activeSessions}function Ny(t){jp(t)}function Ay(t){return t.id}function Jl(t){const e=nt.c(20),{sessionId:n,onArchive:r,Item:i}=t,{t:o}=At();let l;e[0]!==n?(l=h=>!!h.entityById.get(n)?.time.archived,e[0]=n,e[1]=l):l=e[1];const a=ps(l),d=ot(Py);let u;e[2]!==n||e[3]!==o||e[4]!==d?(u=async()=>{await d(n)?_e.success(o("sessions.sidebar.session.restore.success")):_e.error(o("sessions.sidebar.session.restore.error"))},e[2]=n,e[3]=o,e[4]=d,e[5]=u):u=e[5];const m=u;let f;e[6]!==a||e[7]!==r||e[8]!==m?(f=a?()=>{m()}:r,e[6]=a,e[7]=r,e[8]=m,e[9]=f):f=e[9];const g=a?"inbox-unarchive":"inbox-archive";let y;e[10]!==g?(y=s.jsx(B,{name:g,className:"mr-1 size-4"}),e[10]=g,e[11]=y):y=e[11];const b=a?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let j;e[12]!==o||e[13]!==b?(j=o(b),e[12]=o,e[13]=b,e[14]=j):j=e[14];let x;return e[15]!==i||e[16]!==f||e[17]!==y||e[18]!==j?(x=s.jsxs(i,{onClick:f,children:[y,j]}),e[15]=i,e[16]=f,e[17]=y,e[18]=j,e[19]=x):x=e[19],x}function Py(t){return t.unarchiveSession}const df=async t=>{const{entry:e,session:n}=t,r=qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(kp(e.action)&&Cp(e.guest,"conversation"))){await Nl(e,Al(e.action.id,i),t.t,r);return}let l=!1;const a=vr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Nl(e,Al(e.action.id,i,d),t.t,r)}};function sa(t){const e=nt.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=At(),{pending:a,disabled:d,hint:u,run:m}=Th(n,r,i),f=a?"loader-4":"ai-generate-2",g=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let y;e[0]!==f||e[1]!==g?(y=s.jsx(B,{name:f,className:g}),e[0]=f,e[1]=g,e[2]=y):y=e[2];let b;e[3]!==l?(b=l("sessions.aiRename.action"),e[3]=l,e[4]=b):b=e[4];let j;e[5]!==o||e[6]!==d||e[7]!==m||e[8]!==y||e[9]!==b?(j=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:m,className:"w-full",children:[y,b]})})}),e[5]=o,e[6]=d,e[7]=m,e[8]=y,e[9]=b,e[10]=j):j=e[10];let x;e[11]!==u?(x=s.jsx(jt,{side:"right",children:u}),e[11]=u,e[12]=x):x=e[12];let h;return e[13]!==j||e[14]!==x?(h=s.jsxs(vt,{children:[j,x]}),e[13]=j,e[14]=x,e[15]=h):h=e[15],h}const na=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class uf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const ii=Jr(()=>({pendingSessionIds:new Set})),ff=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],ii(n)},Zl=(t,e)=>{ii.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},Dy=async(t,e)=>{try{const d=(await Tp(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=gt(t),r=gt(e)??e,i=ot.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>gt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},ec=t=>{for(const e of t){const n=Ap(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class Iy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const Ty=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new Iy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},Ey=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(Pp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await du(o,n,e),ot.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},tc=async(t,e,n)=>{try{await fu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},sc=async(t,e)=>{const n=e?[t,e]:[t];try{await Ia(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},mf=async(t,e)=>{if(ii.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Zl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,ot.getState().getWorktreeMetadata(a.id)]));ec(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){ec(n.slice(a));try{await du(d,t.sourceDirectory,i.directory)}catch(u){throw Np(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&ot.getState().setWorktreeMetadata(d.id,Pl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await Ey(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await sc(t.sourceDirectory,i?.directory),u.length>0)throw Ty(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new uf(d):d}return ot.getState().setWorktreeMetadata(t.root.id,Pl(i.metadata)),await sc(t.sourceDirectory,i.directory),i.directory}finally{Zl(t.root.id,!1)}},Ry=async t=>{const e=gt(t.sourceDirectory)??t.sourceDirectory,n=gt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return mf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},My=async t=>mf(t,async()=>{const e=Ki(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await uu(t.sourceDirectory)?await Dy(t.sourceDirectory,e.path):null,r=await Dp(e,n?{startRef:n}:{});try{await Ip(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return tc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>tc(e,r,i)}}),Oy=t=>{(t.kind==="existing"?Ry({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):My({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>_e.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));_e.error(t.messages.failure,{description:r instanceof uf?t.messages.outcomeUnknown:r.message})})},ra=t=>{ii.getState().pendingSessionIds.has(t.root.id)||Oy(t)},$r="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",By=c.memo(function(e){const n=nt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,g=m===void 0?!1:m;if(!f)return null;const y=a??$r,b=g&&"bg-interactive-selection text-interactive-selection-foreground";let j;n[0]!==y||n[1]!==b?(j=De(y,b),n[0]=y,n[1]=b,n[2]=j):j=n[2];const x=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==x?(h=s.jsx(B,{name:d,className:x}),n[3]=d,n[4]=x,n[5]=h):h=n[5];let p;n[6]!==o||n[7]!==l||n[8]!==g||n[9]!==j||n[10]!==h?(p=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":g,className:j,children:h})}),n[6]=o,n[7]=l,n[8]=g,n[9]=j,n[10]=h,n[11]=p):p=n[11];let w;n[12]!==i?(w=s.jsx(jt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=w):w=n[13];let S;return n[14]!==p||n[15]!==w?(S=s.jsxs(vt,{children:[p,w]}),n[14]=p,n[15]=w,n[16]=S):S=n[16],S}),Fy=c.memo(function(e){const n=nt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:m,remoteUpdateChecking:f,remoteUpdateError:g,onOpenRemoteUpdate:y}=e,{t:b}=At();let j;n[0]!==d||n[1]!==a?(j=K=>{a(K),K&&d()},n[0]=d,n[1]=a,n[2]=j):j=n[2];let x;n[3]!==i||n[4]!==r||n[5]!==b?(x=r?b("header.services.openWithCurrent",{current:i}):b("header.services.open"),n[3]=i,n[4]=r,n[5]=b,n[6]=x):x=n[6];const h=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let p;n[7]!==h?(p=De($r,h),n[7]=h,n[8]=p):p=n[8];let w;n[9]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(B,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=w):w=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let N;n[13]!==x||n[14]!==p||n[15]!==S?(N=s.jsx(St,{asChild:!0,children:s.jsx(vs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":x,className:p,children:[w,S]})})}),n[13]=x,n[14]=p,n[15]=S,n[16]=N):N=n[16];let P;n[17]!==i||n[18]!==u||n[19]!==b?(P=b("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=b,n[20]=P):P=n[20];let C;n[21]!==P?(C=s.jsx(jt,{children:s.jsx("p",{children:P})}),n[21]=P,n[22]=C):C=n[22];let T;n[23]!==N||n[24]!==C?(T=s.jsxs(vt,{children:[N,C]}),n[23]=N,n[24]=C,n[25]=T):T=n[25];let R;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==y||n[30]!==f||n[31]!==g||n[32]!==m||n[33]!==a||n[34]!==b?(R=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:b("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:m?.available?b("header.services.remoteUpdate.available",{version:m.version||""}):f?b("header.services.remoteUpdate.checking"):g||b("header.services.remoteUpdate.upToDate")})]}),m?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:y,children:b("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Ep,{embedded:!0,open:l,onOpenChange:_y,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=y,n[30]=f,n[31]=g,n[32]=m,n[33]=a,n[34]=b,n[35]=R):R=n[35];let M;n[36]!==R?(M=s.jsx(Ss,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:R}),n[36]=R,n[37]=M):M=n[37];let F;return n[38]!==l||n[39]!==j||n[40]!==T||n[41]!==M?(F=s.jsxs(js,{open:l,onOpenChange:j,children:[T,M]}),n[38]=l,n[39]=j,n[40]=T,n[41]=M,n[42]=F):F=n[42],F}),rn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},nc=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Ly=()=>{ys("ui.header.render");const{t}=At(),e=ye(z=>z.isSidebarOpen),n=ye(z=>z.openContextOverview),r=ye(z=>z.closeContextPanel),i=ye(z=>z.shortcutOverrides),o=ye(z=>z.sessionTabsEnabled),l=ot(z=>z.getContextUsage),a=ot(z=>!!z.newSessionDraft?.open),d=ot(z=>z.currentSessionId),u=Rp(d??""),m=Mp(d??""),f=ff(d??""),g=ps(Un(c.useCallback(z=>{if(!d)return null;const Ie=[...z.activeSessions,...z.archivedSessions].find(wt=>wt.id===d);if(!Ie)return null;const tt=Ie;return{title:Ie.title??null,directory:tt.directory??null,created:Ie.time?.created??null,slug:tt.slug??null,parentId:Ie.parentID??null}},[d]))),y=zt(Un(z=>{if(!z.activeProjectId)return null;const Ie=z.projects.find(tt=>tt.id===z.activeProjectId);return Ie?{id:Ie.id,path:Ie.path,label:Ie.label}:null})),b=c.useMemo(()=>{if(!y)return null;const z=y.label?.trim();if(z)return z;const Ie=y.path.split(/[\\/]/).filter(Boolean);return Ie[Ie.length-1]??null},[y]),j=ur(z=>z.loadSettings),{isMobile:x}=Pn(),h=c.useRef(null),[p,w]=c.useState(()=>typeof window>"u"?!1:mn()),S=c.useMemo(()=>Kr(),[]),N=Op(),[P,C]=c.useState(!1),T=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:M}=Qu(),F=c.useMemo(()=>{if(typeof window>"u")return null;const z=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof z=="number"&&Number.isFinite(z)&&z>0)return z;if(typeof navigator>"u")return null;const Ie=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ie)return null;const tt=Number.parseInt(Ie[1],10),wt=Number.parseInt(Ie[2],10);return Number.isNaN(tt)?null:tt===10?wt:tt},[]);lt.useEffect(()=>{typeof window>"u"||w(mn())},[]);const{context:K,output:D}=Bp(d),U=l(K,D),[A,E]=c.useState(null),W=!d||u;lt.useEffect(()=>{if(!d){E(z=>z===null?z:null);return}if(U){E(z=>Fp(z,U)?z:U);return}W&&E(z=>z===null?z:null)},[U,d,W]);const[k,v]=c.useState(!1),[I,H]=c.useState("Local"),[$,re]=c.useState(!0),[te,ee]=c.useState(!1),[ue,de]=c.useState(null),[Te,we]=c.useState(!1),[fe,Ne]=c.useState(null),L=c.useMemo(()=>An(),[]),oe=ye(z=>z.workStatusPanelVisible),ce=ye(z=>z.workStatusPanelEnabled),pe=ye(z=>z.setWorkStatusPanelEnabled),Y=ye(z=>z.workStatusPanelFits),ve=ye(z=>z.workStatusOverlayOpen),Ee=ye(z=>z.setWorkStatusOverlayOpen),ge=ce&&Y||ve,be=c.useCallback(()=>{if(ce&&!Y){Ee(!ve);return}pe(!ce)},[Ee,pe,ve,ce,Y]),Q=!L&&!oe&&!!A,_=c.useCallback(async()=>{if(!(typeof window>"u"||!p))try{if(qo()){H("Local"),re(!0);return}re(!1);const z=await Ld(),Ie=qm(),tt=Ym([Qm(Ie),...z.hosts]);if(tt.id===Xm){H("Local"),re(!0);return}H(_d(tt.label.trim()||"Instance"))}catch{H("Local"),re(!0)}},[p]);lt.useEffect(()=>(_(),vr(()=>{_()})),[_]);const J=c.useCallback(async()=>{if($){de(null),Ne(null);return}we(!0),Ne(null);try{const z=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Ie=await as(`/api/openchamber/update-check?${z.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Ie.ok)throw new Error(`Server responded with ${Ie.status}`);const tt=await Ie.json();de({available:tt.available??!1,version:tt.version,currentVersion:tt.currentVersion??"unknown",body:tt.body,nextSuggestedCheckInSec:typeof tt.nextSuggestedCheckInSec=="number"?tt.nextSuggestedCheckInSec:void 0,packageManager:tt.packageManager,updateCommand:tt.updateCommand})}catch(z){de(null),Ne(z instanceof Error?z.message:t("header.services.remoteUpdate.error"))}finally{we(!1)}},[$,t]);c.useEffect(()=>{de(null),Ne(null),ee(!1)},[$,I]),c.useEffect(()=>{if(!p||$)return;const z=3e3,Ie=3600*1e3;let tt=!1,wt=null;const Pt=Nt=>{wt=window.setTimeout(()=>{if(tt||typeof document<"u"&&document.visibilityState!=="visible"){Pt(Ie);return}J().finally(()=>{tt||Pt(Ie)})},Nt)};return Pt(z),()=>{tt=!0,wt!==null&&window.clearTimeout(wt)}},[J,$,I,p]);const me=c.useCallback(()=>{if(ue?.available){ee(!0);return}J()},[J,ue?.available]);Lp(),c.useEffect(()=>{j()},[j]);const le=d?g??null:null,V=c.useRef(null),[Z,G]=c.useState(0);c.useEffect(()=>{if(!d){V.current&&(V.current=null,G(wt=>wt+1));return}if(le){V.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const z=V.current;if(!z||z.sessionId!==d)return;const Ie=z.expiresAt-Date.now();if(Ie<=0){V.current=null,G(wt=>wt+1);return}const tt=window.setTimeout(()=>{V.current?.sessionId===d&&(V.current=null),G(wt=>wt+1)},Ie);return()=>{window.clearTimeout(tt)}},[d,le]);const ie=(()=>{if(le)return le;if(!d)return null;const z=V.current;return z&&z.sessionId===d&&z.expiresAt>Date.now()?z.session:null})(),Se=ot(z=>d?z.worktreeMetadata.get(d)?.path??"":""),se=ot(z=>d?z.worktreeMetadata.get(d)?.branch?.trim()??null:null),Me=mu(z=>d?z.getAttachment(d):void 0),He=c.useMemo(()=>Me?_p(Me,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Me]),We=c.useMemo(()=>Me?Me.legacy?"legacy":Me.degraded?"degraded":Me.worktreeStatus==="pending"?"pending":Me.worktreeStatus==="missing"?"missing":Me.worktreeStatus==="invalid"?"invalid":Me.attentionReason?"attention":null:null,[Me]),Le=c.useMemo(()=>rn(Se||""),[Se]),Ve=c.useMemo(()=>{const z=typeof ie?.directory=="string"?ie.directory:"";return rn(z||"")},[ie?.directory]),O=Da(d??"",Ve),he=ot(z=>z.newSessionDraft?.open?rn(z.newSessionDraft.bootstrapPendingDirectory??z.newSessionDraft.directoryOverride??""):""),$e=ot(z=>z.newSessionDraft.target),Ue=ot(z=>z.newSessionDraft.selectedProjectId),ct=ot(z=>z.currentSessionDirectory),pt=Zt(z=>z.homeDirectory),it=c.useMemo(()=>Le||Ve||he,[he,Ve,Le]),ft=ye(c.useCallback(z=>{const Ie=rn(it||"");return Ie?nc(z.contextPanelByDirectory[Ie]):null},[it])),yt=ot(z=>{const Ie=rn(Le||Ve||"");if(!Ie)return null;for(const tt of z.availableWorktreesByProject.values()){const Pt=tt.find(Nt=>rn(Nt.path)===Ie)?.branch?.trim();if(Pt)return Pt}return null}),bt=$p(it||null)||se||yt,Dt=a?$e==="chat":zp(Ve||ct,pt),xe=!Dt&&!oe&&!!(b||bt||!a&&We),Ye=c.useMemo(()=>{if(!d)return b??"OpenChamber";const z=ie?.title?.trim();return z&&z.length>0?z:"Untitled Session"},[b,ie?.title,d]),Xe=hu(),qe=ot(z=>z.updateSessionTitle),dt=ot(z=>z.archiveSessions),X=ot(z=>z.deleteSessions),[ae,Ae]=c.useState(!1),[Ge,q]=c.useState(!1),Fe=c.useRef(null),[Ze,Je]=c.useState(""),[et,kt]=c.useState(null),Qe=c.useRef(null),It=c.useCallback(()=>{d&&(Je(ie?.title?.trim()||Ye),Ae(!0))},[ie?.title,d,Ye]),Mt=c.useRef(It);Mt.current=It;const ke=c.useCallback(z=>{z&&(z.focus(),z.select())},[]);c.useEffect(()=>{if(q(!1),kt(null),d&&Fe.current===d){Fe.current=null,Mt.current();return}Ae(!1),Je("")},[d]);const Oe=c.useCallback(async()=>{if(!d)return;const z=Ze.trim();z&&z!==ie?.title?.trim()&&await qe(d,z),Ae(!1)},[ie?.title,d,Ze,qe]);c.useEffect(()=>{if(!ae)return;const z=Ie=>{const tt=Ie.target;(!tt||!Qe.current?.contains(tt))&&Oe()};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[ae,Oe]);const Re=c.useCallback(z=>{z&&Gn(z).then(Ie=>{_e[Ie.ok?"success":"error"](t(Ie.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(t("sessions.sidebar.session.copyId.error")))},[t]),Be=c.useCallback(async()=>{if(!d||!it){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const z=await Xe({sessionID:d,directory:it}).catch(()=>null);if(!z){_e.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(z.length===0){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ie=pu(z,ie?.title??null),tt=gu(ie?.title??null);await bu(Ie,tt)||xu(Ie,tt),_e.success(t("sessions.sidebar.session.export.success"))},[ie?.title,d,Xe,it,t]),Ke=yu(),rt=c.useMemo(()=>wu(Ke),[Ke]),xt=c.useCallback(z=>{d&&df({entry:z,t,session:{id:d,title:ie?.title,directory:Ve??it},loadRecords:async()=>{if(!it)return null;try{return await Xe({sessionID:d,directory:it})}catch{return null}},onLoadFailed:()=>_e.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ie?.title,d,Xe,it,Ve,t]),Pe=c.useCallback(z=>rt.map(Ie=>s.jsxs(z,{onClick:()=>xt(Ie),children:[s.jsx(Qr,{icon:Ie.icon,iconSrc:Ie.iconSrc,className:"mr-1 size-4"}),Ie.action.label]},`${Ie.guest.id}:${Ie.action.id}`)),[rt,xt]),ze=m?.type==="busy"||m?.type==="retry",st=c.useCallback(()=>{if(!d||!Ve||ze||f)return;const z=ps.getState().activeSessions,Ie=z.find(Pt=>Pt.id===d);if(!Ie)return;const tt=[],wt=[d];for(let Pt=0;Pt<wt.length;Pt+=1){const Nt=wt[Pt];for(const Ft of z)Ft.parentID===Nt&&(tt.push(Ft),wt.push(Ft.id))}ra({kind:"quick",root:Ie,descendants:tt,sourceDirectory:Ve,messages:na(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,ze,f,Ve,t]),at=c.useCallback(async()=>{if(!et)return;const z=et.action,Ie=[et.sessionId,...Hd(et.sessionId,[],z==="delete")];if(kt(null),(z==="archive"?await dt(Ie):await X(Ie)).failedIds.length>0){_e.error(t(z==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}_e.success(t(z==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[dt,X,et,t]),Ct=ye(z=>z.openGuestPageId),Ot=Ta(z=>z.guests.find(Ie=>Ie.id===Ct)),Lt=ye(z=>z.isScheduledTasksDialogOpen),Kt=ye(z=>z.isArchivePageOpen),Rt=ye(z=>z.isUsageStatsPageOpen),Vt=ye(z=>z.worktreesPageProjectId),$t=ye(z=>z.runOverviewKey),Xt=Eh($t),Bt=zt(z=>{if(!Vt)return null;const Ie=z.projects.find(tt=>tt.id===Vt);return Ie?.label?.trim()||Ie?.path?.split("/").pop()||null}),ut=c.useMemo(()=>Ot?{title:Ot.pageTitle??Ot.name,subtitle:null}:Lt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Kt?{title:t("sessions.archivePage.title"),subtitle:null}:Rt?{title:t("usageStats.title"),subtitle:null}:Vt?{title:t("sessions.worktreesPage.title",{project:Bt??""}),subtitle:null}:$t?{title:Xt??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Ot,Kt,Xt,$t,Lt,Rt,t,Vt,Bt]),ts=c.useMemo(()=>rn(it||y?.path||""),[y?.path,it]),ss=uy(),fs=Ea(z=>z.planModeEnabled),Jn=ot(z=>z.isSessionPlanAvailable),Ns=fs&&d?Jn(d):!1,xn=c.useRef("");c.useEffect(()=>{if(!fs||!d)return;const z=`${d||"none"}:${Ve||"none"}:${ie?.created||0}:${ie?.slug||"none"}`;xn.current!==z&&(xn.current=z)},[fs,Ns,ie?.slug,ie?.created,d,Ve]);const gs=c.useCallback(()=>{Nn("desktop_open_draft_mini_chat_window",{directory:Dt?"":he,projectId:Dt?null:Ue,apiBaseUrl:hn(),clientToken:Vr()}).catch(z=>{console.warn("[header] failed to open draft mini chat window",z)})},[he,Ue,Dt]),yn=c.useCallback(()=>{if(a){gs();return}d&&Nn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ve||rn(ct||"")||Le,apiBaseUrl:hn(),clientToken:Vr()}).catch(z=>{console.warn("[header] failed to open session mini chat window",z)})},[d,gs,a,ct,Ve,Le]),Gs=c.useCallback(()=>{const z=rn(it||"");if(!z)return;const Ie=ye.getState().contextPanelByDirectory[z];if(nc(Ie)==="context"){r(z);return}n(z)},[r,n,it]),Tn=ft==="context",$s=$r,tn=c.useMemo(()=>p&&T&&!P?"88px":N?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||R)&&!L?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,P,T,N,L,R]);lt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",tn)},[tn]);const bs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Zn=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";lt.useEffect(()=>{if(!p||!T){C(!1);return}let z=!1;const Ie=async()=>{try{const wt=await Nn("desktop_is_window_fullscreen");z||C(wt===!0)}catch{z||C(!1)}},tt=()=>{Ie()};return Ie(),window.addEventListener("openchamber:window-resized",tt),()=>{z=!0,window.removeEventListener("openchamber:window-resized",tt)}},[p,T]);const er=c.useMemo(()=>!p||!T||F===null?"":F>=26?"h-12":F<=15?"h-14":"",[p,T,F]),zs=c.useMemo(()=>{if(!(p&&!R||L)&&!(R&&M==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[p,L,R,M]),Ts=c.useCallback(()=>{if(typeof document>"u")return;const z=h.current?.getBoundingClientRect().height;z&&document.documentElement.style.setProperty("--oc-header-height",`${z}px`)},[]);lt.useEffect(()=>{if(typeof window>"u")return;Ts();const z=h.current;if(!z||typeof ResizeObserver>"u")return()=>{};let Ie=0;const tt=()=>{Ie||(Ie=requestAnimationFrame(()=>{Ie=0,Ts()}))},wt=new ResizeObserver(tt);return wt.observe(z),window.addEventListener("resize",tt),window.addEventListener("orientationchange",tt),()=>{Ie&&cancelAnimationFrame(Ie),wt.disconnect(),window.removeEventListener("resize",tt),window.removeEventListener("orientationchange",tt)}},[Ts]),lt.useEffect(()=>{Ts()},[Ts,x,er]);const tr=c.useCallback(async z=>{const Ie=z.target;Ie.closest(".app-region-no-drag")||Ie.closest("button, a, input, select, textarea")||z.button===0&&p&&await Jm()},[p]),sn=c.useCallback(z=>zn(Xr(z,i)),[i]);Wp({rename_current_session:()=>{if(!d||x)return!1;It()},toggle_services_menu:()=>{if(k){v(!1);return}v(!0),_()}});const sr=s.jsxs(s.Fragment,{children:[ss?s.jsx(cy,{projectRef:ss.projectRef,directory:ss.directory,className:"mr-2"}):null,s.jsx(Rh,{directory:it,className:De($r,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),s.jsx(Fx,{directory:ts,className:"mr-1"}),p?s.jsx(Fy,{isDesktopApp:p,currentInstanceLabel:I,currentInstanceIsLocal:$,isDesktopServicesOpen:k,setIsDesktopServicesOpen:v,refreshCurrentInstanceLabel:_,shortcutLabel:sn,remoteUpdateInfo:ue,remoteUpdateChecking:Te,remoteUpdateError:fe,onOpenRemoteUpdate:me}):null]}),nr=S&&(a||!!d),eo=c.useCallback(({session:z,open:Ie,isActive:tt,select:wt,closeOtherTabs:Pt,components:Nt})=>{const{Item:Ft,Separator:rs}=Nt,Qt=tt&&!L&&!Dt&&ie&&!ie.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Ft,{onClick:()=>{tt||wt(),Fe.current=z.id},children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(sa,{sessionID:z.id,directory:z.directory,open:Ie,Item:Ft}),s.jsxs(Ft,{onClick:()=>Re(z.id),children:[s.jsx(B,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(rs,{}),tt?s.jsxs(Ft,{onClick:()=>{Be()},children:[s.jsx(B,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,tt?Pe(Ft):null,Qt?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ft,{disabled:!Ve||ze||f,onClick:st,className:"w-full",children:[s.jsx(B,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(rs,{}),s.jsxs(Ft,{onClick:Pt,children:[s.jsx(B,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(rs,{}),s.jsx(Jl,{sessionId:z.id,Item:Ft,onArchive:()=>kt({action:"archive",sessionId:z.id})}),s.jsxs(Ft,{className:"text-destructive focus:text-destructive",onClick:()=>kt({action:"delete",sessionId:z.id}),children:[s.jsx(B,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Re,ie,Be,Dt,ze,f,L,st,Pe,Ve,t]),to=()=>s.jsxs("div",{onMouseDown:tr,className:De("app-region-drag relative flex h-12 select-none items-center",R&&M==="right"?"pr-0":"pr-3",er),style:zs,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:bs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Zn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[ut?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(mt,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>ye.getState().closeMainSurfaces(),children:s.jsx(B,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:ut.title}),ut.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:ut.subtitle}):null]})]}):L||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[O?s.jsx(B,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Hl,{align:"start",children:s.jsx("button",{type:"button",className:$s,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(B,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[ae?s.jsxs("form",{ref:Qe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),Oe()},children:[s.jsx("input",{ref:ke,value:Ze,onChange:z=>Je(z.target.value),onKeyDown:z=>$i(z,()=>Ae(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ae(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ye}),xe?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[b?s.jsx("span",{className:"truncate",children:b}):null,bt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:bt})]}):null,!a&&We?s.jsxs("span",{className:De("inline-flex min-w-0 items-center gap-0.5",We==="attention"||We==="invalid"||We==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(B,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:He})]}):null]}):null]}),s.jsx("div",{className:De("flex h-[18px] shrink-0 items-center justify-center",xe?"self-start":"self-center"),children:d&&!a&&!ae?s.jsxs(js,{open:Ge,onOpenChange:q,onOpenChangeComplete:z=>{!z&&Fe.current&&Fe.current===d&&(Fe.current=null,It())},children:[s.jsx(vs,{asChild:!0,children:s.jsx(mt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(B,{name:"more",className:"size-4"})})}),s.jsxs(Ss,{align:"end",className:"min-w-[190px]",children:[s.jsxs(_t,{onClick:()=>{Fe.current=d},children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(sa,{sessionID:d,directory:Ve,open:Ge,Item:_t}),s.jsxs(_t,{onClick:()=>d&&Re(d),children:[s.jsx(B,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(hs,{}),s.jsxs(_t,{onClick:()=>{Be()},children:[s.jsx(B,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Pe(_t),!L&&!Dt&&ie&&!ie.parentId?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(_t,{disabled:!Ve||ze||f,onClick:st,className:"w-full",children:[s.jsx(B,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(hs,{}),s.jsx(Jl,{sessionId:d,Item:_t,onArchive:()=>kt({action:"archive",sessionId:d})}),s.jsxs(_t,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&kt({action:"delete",sessionId:d})},children:[s.jsx(B,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Hl,{align:"start",children:s.jsx("button",{type:"button",className:$s,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(B,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(gy,{renderMenu:eo,suppressActiveTabControls:ae,onMenuOpenChangeComplete:z=>{!z&&Fe.current&&Fe.current===d&&(Fe.current=null,It())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ae?s.jsxs("form",{ref:Qe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),Oe()},children:[s.jsx("input",{ref:ke,value:Ze,onChange:z=>Je(z.target.value),onKeyDown:z=>$i(z,()=>Ae(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ae(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Ye})})})]}),ut||L||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Q&&A?s.jsx(sx,{reading:nx(A),contextLimit:A.contextLimit,outputLimit:A.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Gs,pressed:Tn,className:nr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(By,{visible:nr,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:yn,className:De($s,"mr-1"),Icon:"picture-in-picture-2"}),L?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ge,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:be,className:De($r,"mr-1",ge?"text-foreground":"text-muted-foreground/50"),children:s.jsx(B,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t(ce&&!Y?ve?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ce?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),sr,s.jsx(Xu,{visible:R&&M==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:to()}),s.jsx(ks,{open:et!==null,onOpenChange:z=>{z||kt(null)},children:s.jsxs(Cs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Hs,{children:[s.jsx(Ls,{children:et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(_s,{children:et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Ye}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Ye})})]}),s.jsxs(Qn,{children:[s.jsx(mt,{variant:"outline",size:"sm",onClick:()=>kt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(mt,{variant:"destructive",size:"sm",onClick:()=>{at()},children:et?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Gd,{open:te,onOpenChange:ee,info:ue,downloading:!1,downloaded:!1,progress:null,error:fe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function _y(){}const rc=280,oc=264,ic=500,$y=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=At(),l=ye(C=>C.sidebarWidth),a=ye(C=>C.setSidebarWidth),[d,u]=c.useState(!1),m=c.useRef(0),f=c.useRef(l||rc),g=c.useRef(null),y=c.useRef(null),b=c.useRef(null),j=c.useCallback(C=>Math.min(ic,Math.max(oc,C)),[]),x=c.useCallback(C=>{const T=b.current;T&&(T.style.width=`${C}px`,T.style.minWidth=`${C}px`,T.style.maxWidth=`${C}px`,T.style.setProperty("--oc-left-sidebar-width",`${C}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(g.current=null,y.current=null)},[d]),e)return null;const h=Math.min(ic,Math.max(oc,l||rc)),p=t?h:0,w=C=>{if(t){try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}y.current=C.pointerId,u(!0),m.current=C.clientX,f.current=p,g.current=p,x(p),C.preventDefault()}},S=C=>{if(e||!d||y.current!==C.pointerId)return;const T=C.clientX-m.current,R=j(f.current+T);g.current!==R&&(g.current=R,x(R))},N=C=>{if(y.current!==C.pointerId||e)return;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}const T=j(g.current??p);y.current=null,g.current=null,u(!1),a(T)},P=d?g.current??p:p;return s.jsxs("aside",{ref:b,className:De("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${P}px`,minWidth:`${P}px`,maxWidth:`${P}px`,"--oc-left-sidebar-width":`${d?P:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||p===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:De("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:S,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:De("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(bn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(ms,{children:n})})]})]})},zy=()=>{const t=nt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},io="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",Wy=()=>{const t=nt.c(37),{t:e}=At(),n=ye(Ky),r=ye(Vy),i=ye(Uy),o=c.useRef(null),l=zn(Xr("toggle_sidebar",i)),a=Hy,{usesFramelessChrome:d,side:u}=Qu(),m=qy;let f,g;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const A=o.current;if(!A)return;const E=()=>{const k=Math.max(A.getBoundingClientRect().width,A.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(k)}px`)};if(E(),typeof ResizeObserver>"u")return;const W=new ResizeObserver(E);return W.observe(A),()=>{W.disconnect()}},g=[],t[0]=f,t[1]=g):(f=t[0],g=t[1]),c.useEffect(f,g);const y="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=b):b=t[2];const j="flex items-center gap-2";let x;t[3]!==d||t[4]!==u?(x=d&&u==="left"?s.jsx(Xu,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=x):x=t[5];let h;t[6]!==e||t[7]!==d?(h=d?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:De(io,"shrink-0"),children:s.jsx(B,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=h):h=t[8];const p=vt;let w;t[9]!==e?(w=e("header.actions.openSessionsAria"),t[9]=e,t[10]=w):w=t[10];let S,N;t[11]===Symbol.for("react.memo_cache_sentinel")?(S=De(io,"shrink-0"),N=s.jsx(B,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=S,t[12]=N):(S=t[11],N=t[12]);let P;t[13]!==w||t[14]!==n?(P=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":w,className:S,children:N})}),t[13]=w,t[14]=n,t[15]=P):P=t[15];const C=jt,T=e("header.actions.openSessionsWithShortcut",{shortcut:l});let R;t[16]!==T?(R=s.jsx("p",{children:T}),t[16]=T,t[17]=R):R=t[17];let M;t[18]!==C||t[19]!==R?(M=s.jsx(C,{children:R}),t[18]=C,t[19]=R,t[20]=M):M=t[20];let F;t[21]!==p||t[22]!==P||t[23]!==M?(F=s.jsxs(p,{children:[P,M]}),t[21]=p,t[22]=P,t[23]=M,t[24]=F):F=t[24];let K;t[25]!==a||t[26]!==r||t[27]!==e?(K=r?s.jsxs("button",{type:"button",onClick:a,className:De(io,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(B,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:De(io,"-ml-1 shrink-0"),children:s.jsx(B,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=K):K=t[28];let D;t[29]!==F||t[30]!==K||t[31]!==x||t[32]!==h?(D=s.jsxs("div",{ref:o,className:j,children:[x,h,F,K]}),t[29]=F,t[30]=K,t[31]=x,t[32]=h,t[33]=D):D=t[33];let U;return t[34]!==D||t[35]!==b?(U=s.jsx("div",{className:y,style:b,children:D}),t[34]=D,t[35]=b,t[36]=U):U=t[36],U};function Ky(t){return t.toggleSidebar}function Vy(t){return t.isSidebarOpen}function Uy(t){return t.shortcutOverrides}function Hy(){ye.getState().closeMainSurfaces(),ot.getState().openNewSessionDraft()}function Gy(t){console.warn("[titlebar] failed to open app menu",t)}function qy(t){const e=t.currentTarget.getBoundingClientRect();Nn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(Gy)}function hf(t){const e=nt.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(B,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const ac=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Yy(t,e,n){const r=nt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([Kp(t),Vp(t)]).catch(Qy);if(d)return;const f=ac(u),g=ac(m);if(!f||!g||g===f)return;const y=n||"",b=g.split("/").filter(Boolean).pop()||g;o({source:"sdk",path:g,projectDirectory:f,branch:y,label:y||b,name:b,worktreeRoot:g,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Qy(){return["",""]}const lc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Xy=async(t,e)=>{if(t)return t.authActivate(e);const n=await as("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},cc=({className:t})=>{const{t:e}=At(),{github:n}=gn(),r=pn(y=>y.status),i=pn(y=>y.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async y=>{if(!(!y||o)){l(!0);try{i(await Xy(n,y))}catch(b){console.error("Failed to switch GitHub account:",b)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,m=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),g=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(B,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return m.length<=1?s.jsx("div",{className:De(lc,t),title:f,children:g}):s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:De(lc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:g})}),s.jsxs(Ss,{align:"end",className:"w-64",children:[s.jsx(cr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(hs,{}),m.map(y=>{const b=y.user,j=!!y.current,x=y.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(_t,{className:"gap-2",disabled:o,onSelect:()=>{j||a(y.id)},children:[b?.avatarUrl?s.jsx("img",{src:b.avatarUrl,alt:b.login?e("header.github.avatarWithLogin",{login:b.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(B,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:b?.name?.trim()||b?.login||"GitHub"}),b?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:b.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:x})]}):null]}),j?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})};class ai extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const li="/api/walkthrough",pf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),gf=()=>new ai("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Jy=t=>!pf(t)&&(t.ok||t.status===404),Ga=async(t,e)=>{if(Jy(t))throw gf();const n=await t.json().catch(()=>null);throw new ai(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},bf=async t=>{if(!pf(t))throw gf();try{return await t.json()}catch{throw new ai("The server returned a malformed walkthrough response")}};async function Zy(t,e,n={}){const r=await as(li,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?bf(r):Ga(r,"Failed to load walkthrough")}async function e1(t,e,n={}){const r=await as(`${li}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?bf(r):Ga(r,"Failed to generate walkthrough")}async function t1(t,e){const n=await as(`${li}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ga(n,"Failed to cancel walkthrough generation")}async function s1(t,e,n){const r=await as(`${li}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Nr={status:"idle",stage:null,result:null,readiness:null,error:null},n1=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,wn=(t,e)=>`${qt()}\0${t}\0${n1(e)}`,dc=t=>t instanceof ai?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Ms=new Map,Ar=new Map,r1=1e3,o1=Jr()(jx((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=wn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[wn(n,r)],selectModel:(n,r,i)=>{const o=wn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[wn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[wn(n,r)]??Nr,load:async(n,r,i={})=>{if(!n)return;const o=wn(n,r);if(e().entries[o]?.status==="generating")return;Ms.get(o)?.abort();const a=new AbortController;Ms.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Nr,status:"loading",error:null}}}));try{const d=await Zy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Nr,status:"error",stage:null,error:dc(d)}}}))}finally{Ms.get(o)===a&&Ms.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=wn(n,r);Ms.get(o)?.abort();const l=new AbortController;Ms.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Nr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Ar.get(o);d!==void 0&&(clearInterval(d),Ar.delete(o))};a(),Ar.set(o,setInterval(()=>{s1(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const m=u.entries[o];return!m||m.status!=="generating"||m.stage===d?u:{entries:{...u.entries,[o]:{...m,stage:d}}}})}).catch(()=>{})},r1));try{const d=await e1(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Nr,status:"error",stage:null,error:dc(d)}}}))}finally{a(),Ms.get(o)===l&&Ms.delete(o)}},cancel:(n,r)=>{const i=wn(n,r);t1(n,r).catch(()=>{}),Ms.get(i)?.abort(),Ms.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Ms.values())n.abort();Ms.clear();for(const n of Ar.values())clearInterval(n);Ar.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),i1="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",a1=3e4,uc=20,xf=(t,e)=>JSON.stringify([qt(),t,e]),l1=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},fc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ao=new Map,c1=t=>{const e=Object.entries(t);return e.length<=uc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,uc))},mc=Jr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=xf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<a1&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const m=`${l}::${a?"details":"plain"}`,g=ao.get(`${l}::details`)??(a?null:ao.get(m));if(g&&!o?.force)return g;const y=(async()=>{t(b=>({entries:{...b.entries,[l]:{...b.entries[l]??fc(),isLoading:!0,error:null}}}));try{const b=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(j=>({entries:c1({...j.entries,[l]:{result:b,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),b}catch(b){const j=b instanceof Error?b.message:"Failed to load pull request context";return t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??fc(),isLoading:!1,error:j}}})),null}finally{ao.delete(m)}})();return ao.set(m,y),y},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=l1(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),d1=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},u1=35e3,Ci=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ni=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},hc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},f1=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},m1=[2e3,5e3],h1=600,pc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Sn=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},p1=(t,e)=>{const n=Sn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},g1=(t,e)=>`${t}::${e}`,qa=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Ai=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=qa(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},b1=t=>t.startsWith("pr-"),x1=(t,e)=>{const n=qa(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!b1(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Pr=new Map,lo=Yr;function y1(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const w1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=At(),d=ye(ne=>ne.timeFormatPreference),{github:u}=gn(),m=pn(ne=>ne.status),f=pn(ne=>ne.hasChecked),g=ye(ne=>ne.setSettingsDialogOpen),y=ye(ne=>ne.setSettingsPage),b=ot(ne=>ne.currentSessionId),j=ot(ne=>!!ne.newSessionDraft?.open),{isMobile:x,hasTouchInput:h,screenWidth:p}=Pn(),w=ye(ne=>ne.openContextSurface),S=o1(ne=>ne.requestSource),N=!x&&p>=768&&!An(),P=c.useCallback(()=>{y("integrations"),g(!0)},[g,y]),C=c.useMemo(()=>g1(t,e),[t,e]),T=c.useMemo(()=>Pr.get(C)??null,[C]),R=Ps(ne=>ne.ensureEntry),M=Ps(ne=>ne.setParams),F=Ps(ne=>ne.startWatching),K=Ps(ne=>ne.stopWatching),D=Ps(ne=>ne.refresh),U=Ps(ne=>ne.updateStatus),[A,E]=c.useState(()=>T?.title??pc(e)),[W,k]=c.useState(()=>T?.body??""),[v,I]=c.useState(()=>T?.draft??!1),[H,$]=c.useState(()=>T?.additionalContext??""),[re,te]=c.useState(()=>{const ne=typeof T?.targetBaseBranch=="string"?Sn(T.targetBaseBranch):"";return ne||Sn(n)}),[ee,ue]=c.useState("squash"),[de,Te]=c.useState(!1),[we,fe]=c.useState(!1),[Ne,L]=c.useState(!1),[oe,ce]=c.useState(!1),[pe,Y]=c.useState(!1),[ve,Ee]=c.useState(!1),[je,ge]=c.useState(null),[be,Q]=c.useState(""),[_,J]=c.useState(""),[me,le]=c.useState(!1),[V,Z]=c.useState(!1),[G,ie]=c.useState(()=>Ai(i,{selectedRemoteName:T?.selectedRemoteName,trackingBranch:r})),[Se,se]=c.useState(!1),{detectedUpstream:Me,upstreamBranches:He}=y1(t,u);c.useEffect(()=>{se(!1)},[t]);const We=i.some(ne=>ne.name==="upstream"),Ve=!!(t&&e&&n&&(e!==n||(We||Me!==null))),O=c.useMemo(()=>Yo(t,e,G?.name??null),[t,e,G?.name]),he=Ps(ne=>ne.entries[O]),$e=he?.isLoading??!1,Ue=he?.status??null,ct=he?.error??null,pt=he?.isInitialStatusResolved??!1,it=c.useMemo(()=>{const ne=Se?null:G?.name?.trim()||null,z=new Set;for(const wt of o){const Pt=p1(wt,ne);!Pt||Pt==="HEAD"||z.add(Pt)}if(Se)for(const wt of He)wt&&wt!=="HEAD"&&z.add(wt);const Ie=Sn(n);Ie&&Ie!=="HEAD"&&z.add(Ie);const tt=Sn(re);return tt&&tt!=="HEAD"&&z.add(tt),Array.from(z).sort((wt,Pt)=>wt.localeCompare(Pt))},[n,o,G?.name,re,He,Se]);c.useEffect(()=>{if(i.length===0){G&&ie(null);return}(!G||!i.some(ne=>ne.name===G.name))&&ie(Ai(i,{selectedRemoteName:T?.selectedRemoteName,trackingBranch:r}))},[T?.selectedRemoteName,i,G,r]),c.useEffect(()=>{const ne=Sn(n);if(!re&&ne){te(ne);return}if(it.length!==0&&!it.includes(re)){const z=it.includes(ne)?ne:it[0];z&&te(z)}},[it,n,re]);const[ft,yt]=c.useState(()=>T?.activeSegment??"overview"),[ht,bt]=c.useState(new Set),[Dt,xe]=c.useState(new Set),Ye=c.useRef(new Set),Xe=c.useRef(null),qe=c.useRef(!1),dt=c.useRef(new Set),X=c.useRef([]);c.useEffect(()=>{Me&&!We&&se(!0)},[Me,We]),c.useEffect(()=>{Se&&Me?.defaultBranch&&te(Me.defaultBranch)},[Se,Me?.defaultBranch]);const ae=Ue?.pr??null,Ae=ae?.state==="merged"||ae?.state==="closed",Ge=Ae?null:ae,q=Ge?xf(t,Ge.number):null,Fe=mc(ne=>q?ne.entries[q]:void 0),Ze=mc(ne=>ne.ensure),Je=Fe?.result??null,et=Fe?.isLoading??!1,kt=c.useCallback(ne=>{yt(ne);const z=Pr.get(C);z&&Pr.set(C,{...z,activeSegment:ne})},[C]);c.useEffect(()=>{!Ge||!u?.prContext||ft==="overview"||Ze(u,t,Ge.number,{includeCheckDetails:ft==="checks",sourceRepo:Ue?.repo??null})},[ft,t,Ze,u,Ge,Ue?.repo]);const Qe=Ue?.checks??null,It=(Qe?.pending??0)>0,Mt=Je?.checkRuns??null,ke=Je?.fetchedAt;c.useEffect(()=>{if(!Mt||Mt.length===0)return;const ne=d1(Mt);U(O,z=>{if(!z?.pr||typeof ke=="number"&&typeof z.fetchedAt=="number"&&ke<z.fetchedAt)return z;const Ie=z.checks;return Ie&&Ie.state===ne.state&&Ie.total===ne.total&&Ie.success===ne.success&&Ie.failure===ne.failure&&Ie.pending===ne.pending&&Ie.inProgress===ne.inProgress&&Ie.queued===ne.queued&&Ie.startedAt===ne.startedAt?z:{...z,checks:ne,...typeof ke=="number"?{fetchedAt:ke}:{}}})},[Mt,ke,O,U]),c.useEffect(()=>{if(ft!=="checks"||!It||!ae||!u?.prContext)return;const ne=window.setInterval(()=>{Ze(u,t,ae.number,{includeCheckDetails:!0,sourceRepo:Ue?.repo??null,force:!0})},u1);return()=>window.clearInterval(ne)},[ft,It,t,Ze,u,ae,Ue?.repo]);const[Oe,Re]=c.useState(()=>Date.now());c.useEffect(()=>{if(!It)return;Re(Date.now());const ne=window.setInterval(()=>Re(Date.now()),3e4);return()=>window.clearInterval(ne)},[It]);const Be=ae?`${t}#${ae.number}`:null,Ke=!!(Be&&je===Be);c.useEffect(()=>{if(!u?.prContext||!ae||typeof ae.body=="string"&&ae.body.length>0)return;const ne=`${t}#${ae.number}`;if(Ye.current.has(ne))return;Ye.current.add(ne),ge(ne);let z=!1;return Ze(u,t,ae.number,{sourceRepo:Ue?.repo??null}).then(Ie=>{if(z)return;const tt=Ie?.pr;tt&&U(O,wt=>!wt?.pr||wt.pr.number!==ae.number?wt:{...wt,pr:{...wt.pr,body:tt.body||""}})}).catch(()=>{}).finally(()=>{z||ge(Ie=>Ie===ne?null:Ie)}),()=>{z=!0}},[t,Ze,u,ae,O,Ue?.repo,U]),c.useEffect(()=>{if(!ae){Ee(!1),Q(""),J(""),Xe.current=null;return}const ne=Xe.current!==null&&Xe.current!==ae.number;ne&&Ee(!1),(!ve||ne)&&(Q(ae.title||""),J(ae.body||"")),Xe.current=ae.number},[ve,ae]);const rt=c.useCallback(ne=>{if(!ne)return"";const z=Date.parse(ne);return Number.isFinite(z)?vu(z,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ne},[d]),xt=c.useMemo(()=>{const ne=m?.user?.login;return typeof ne=="string"?ne.trim():""},[m]),Pe=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),ze=c.useCallback(ne=>{const z=xt.toLowerCase(),Ie=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ne.replace(Ie,(tt,wt,Pt)=>{const Nt=`@${Pt}`,Ft=Pt.toLowerCase();return`${wt}[${Nt}](https://github.com/${Ft}${z&&Ft===z?"?oc-self-mention=1":""})`})},[xt]),st=c.useMemo(()=>{const ne=(Je?.issueComments??[]).map(tt=>({id:`issue-${tt.id}`,body:tt.body||"",authorName:tt.author?.name||tt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:tt.author?.login||null,avatarUrl:tt.author?.avatarUrl||null,createdAt:tt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),z=(Je?.reviewComments??[]).map(tt=>({id:`review-${tt.id}`,body:tt.body||"",authorName:tt.author?.name||tt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:tt.author?.login||null,avatarUrl:tt.author?.avatarUrl||null,createdAt:tt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:tt.path||null,line:tt.line??null})),Ie=[...ne,...z];return Ie.sort((tt,wt)=>{const Pt=tt.createdAt?Date.parse(tt.createdAt):0,Nt=wt.createdAt?Date.parse(wt.createdAt):0,Ft=Number.isFinite(Pt)?Pt:0,rs=Number.isFinite(Nt)?Nt:0;return Ft-rs}),Ie},[Je,a]),at=c.useCallback(()=>{const ne=b??(j?"draft":null);return ne?{directory:t,sessionKey:ne}:(_e.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[b,t,j,a]),Ct=c.useCallback((ne,z)=>{const Ie=z.authorLogin?`@${z.authorLogin}`:z.authorName,tt=z.path?` · ${z.path}${z.line?`:${z.line}`:""}`:"";Vi.getState().addDraft(ne,{source:"pr-comment",fileLabel:`PR #${ae?.number??""} ${Ie}${tt}`,startLine:z.line??0,endLine:z.line??0,code:z.body,language:"markdown",text:""})},[ae?.number]),Ot=c.useCallback((ne,z)=>{const Ie=ne.status||"unknown",tt=ne.conclusion??void 0,wt=tt?`${Ie} / ${tt}`:Ie,Pt=ne.app?.name||ne.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:z?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[z?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ne.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Pt?`${Pt} · ${wt}`:wt})]}),ne.detailsUrl?s.jsx(mt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ne.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(B,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ne.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ne.output.title}):null,ne.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ne.output.summary}):null,ne.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:ne.output.text}):null,Array.isArray(ne.annotations)&&ne.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ne.annotations.length>20?` (showing 20/${ne.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ne.annotations.slice(0,20).map((Nt,Ft)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Nt.title||Nt.level||"Issue",Nt.path?` · ${Nt.path}`:"",typeof Nt.startLine=="number"?`:${Nt.startLine}`:"",typeof Nt.endLine=="number"&&Nt.endLine!==Nt.startLine?`-${Nt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Nt.message}),Nt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Nt.rawDetails}):null]},`${Nt.path||"file"}:${Nt.startLine||Ft}:${Ft}`))})]}):null,ne.job?.steps&&ne.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:ne.job.steps.map((Nt,Ft)=>{const rs=(Nt.conclusion||"").toLowerCase(),Qt=rs&&!["success","neutral","skipped"].includes(rs),qs=`${ne.id??"run"}:${ne.job?.jobId??"job"}:${Nt.number??Ft}:${Nt.name}`,nn=ht.has(qs);return Qt?s.jsxs(Dl,{open:nn,children:[s.jsxs("button",{type:"button",onClick:()=>{bt(di=>{const Ys=new Set(di);return Ys.has(qs)?Ys.delete(qs):Ys.add(qs),Ys})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Qt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[nn?s.jsx(B,{name:"arrow-down-s",className:"size-4"}):s.jsx(B,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Nt.name}),Nt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Nt.conclusion}):null]}),s.jsx(Il,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof Nt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Nt.number]}):null,Nt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Nt.status]}):null,Nt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Nt.conclusion]}):null,Nt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",rt(Nt.startedAt)]}):null,Nt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",rt(Nt.completedAt)]}):null]})})]},qs):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Nt.name}),Nt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Nt.conclusion}):null]},qs)})})]}):null]})},[ht,rt,a]),[Lt,Kt]=c.useState(!1),[Rt,Vt]=c.useState(!1),$t=c.useCallback(async()=>{if(!u?.prContext){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!ae)return;const ne=at();if(ne){Kt(!0);try{const z=await Ze(u,t,ae.number,{includeCheckDetails:!0,sourceRepo:Ue?.repo??null});if(!z){_e.error(a("gitView.pr.toast.loadChecksFailed"));return}const tt=(z.checkRuns??[]).filter(Pt=>Ni(Pt.conclusion));if(tt.length===0){_e.message(a("gitView.pr.toast.noFailedChecks"));return}const wt=Vi.getState();for(const Pt of tt){const Nt=(Pt.annotations??[]).map(Qt=>[[Qt.level,Qt.title].filter(Boolean).join(" "),Qt.path?`${Qt.path}${typeof Qt.startLine=="number"?`:${Qt.startLine}`:""}`:null,Qt.message,Qt.rawDetails].filter(Boolean).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-DhvkEmfP.js","assets/vendor-react-C3AD0CRp.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-FdVEdwq7.js","assets/index-BvpIhpBI.js","assets/vendor-zod-C3BVLiwa.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-XNmn2Hnw.js","assets/vendor-use-sync-external-store-DVVwmGAS.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-ryXjyKdZ.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-CyPa587s.js","assets/vendor-clsx-C_d985j6.js","assets/vendor-base-ui-BV0ycO3d.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BERnAEiB.js","assets/vendor-floating-ui-core-DBVSD8FA.js","assets/vendor-floating-ui-react-dom-VN3-0QGl.js","assets/vendor-dnd-kit-core-B-dmENub.js","assets/vendor-dnd-kit-utilities-D2MO70n8.js","assets/vendor-dnd-kit-accessibility-vxqCsF6D.js","assets/vendor-dnd-kit-sortable-DiuAkJDx.js","assets/vendor-tanstack-react-virtual-BHz8HhxS.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.js","assets/vendor-framer-motion-0pQCvQRa.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-CMlKUx1I.js","assets/vendor-cmdk-WpnCe4Xz.js","assets/vendor-radix-ui-react-dialog-Cya58wJc.js","assets/vendor-radix-ui-primitive-DOdKROq0.js","assets/vendor-radix-ui-react-compose-refs-OwL660na.js","assets/vendor-radix-ui-react-context-BGG-1ggC.js","assets/vendor-radix-ui-react-id-CciEoFzD.js","assets/vendor-radix-ui-react-use-layout-effect-ChlApEEc.js","assets/vendor-radix-ui-react-use-controllable-state-DprBN3PW.js","assets/vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js","assets/vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js","assets/vendor-radix-ui-react-primitive-CUfg3gbV.js","assets/vendor-radix-ui-react-slot-CLI2-QJb.js","assets/vendor-babel-runtime-CF3RwP-h.js","assets/vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js","assets/vendor-radix-ui-react-focus-scope-CqvJmvlR.js","assets/vendor-radix-ui-react-portal-EaY9b0dR.js","assets/vendor-radix-ui-react-presence-DBDb0ROU.js","assets/vendor-radix-ui-react-focus-guards-DOvT22db.js","assets/vendor-react-remove-scroll-CdTdY8wV.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-DAxITgbW.js","assets/vendor-react-style-singleton-XBDcq1Ec.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-CzUV4Fx5.js","assets/vendor-use-callback-ref-h1JrcWGd.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-Cg8boEOY.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CN8Enbjc.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-Dw1gdHuT.js","assets/vendor-codemirror-lang-json-DzRRSgj9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B_seq3PB.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CcuPVz08.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-B3FiTjDN.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CaoLP1ZV.js","assets/vendor-codemirror-lang-python-frX4-6UW.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-Cg3hFNyu.js","assets/vendor-legendapp-list-ZsDnss2w.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-DzgiH2zi.js","assets/runtimeEndpointReset-D56xMbiw.js","assets/GuestAttachDialog-Bsi0q3M9.js","assets/PluginPane-Dx0_Dldo.js","assets/VirtualizedFileDiff-DapU3oMs.js","assets/web-components-BKRdx0aw.js","assets/computeVirtualFileMetrics-BWISD0Ee.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-DU3lrpLL.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-DKHxCmze.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-Bf5t_8QQ.js","assets/appThemeRegistry-CWAKiwky.js","assets/textMateThemeFromAppTheme-AUvSJIJn.js","assets/vendor-katex-C8JhiARg.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-BhAup8Zd.js","assets/scheduledTasksApi-BZMS2h6Z.js","assets/vendor-cron-parser-B7wFT8N0.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-rYnmKnFF.js","assets/SubmoduleDiffSummary-hkelCkS-.js","assets/changesTree-CePHbFcj.js","assets/FilesView-DtzJk1Ke.js","assets/shikiHighlight-BPUnGgQg.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-C_NzAZis.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-DIy-frOy.js","assets/Virtualizer-CtRzP13T.js","assets/isFilePlainText-udb3VTt2.js","assets/vendor-react-drawio-DR5-Wn9a.js","assets/CodeMirrorCommentWidgets-e9rY9Jxg.js","assets/GitView-DYd5gOSc.js","assets/commitAndPush-D51hG7WM.js","assets/LinearIssuesView-DDHJKaVb.js","assets/PlanView-CN21khuJ.js","assets/GuestSurfacePane-CYMRe3EI.js","assets/SettingsWindow-B8RpyNyO.js","assets/SettingsView-CBGx68I6.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-BTlWCou-.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-DiMFS3A7.js"])))=>i.map(i=>d[i]);
2
+ import{e as nt,R as c,j as s,r as lt,b as Vm,f as Um}from"./vendor-react-C3AD0CRp.js";import"./vendor-katex-C8JhiARg.js";import{G as mn,H as qo,bo as Hm,a6 as Gm,r as as,b as Fd,u as ye,aA as Et,aP as hl,g as qt,s as vr,aa as gt,Z as ys,y as Kr,i as An,O as Ld,bp as qm,bq as Ym,br as Qm,bs as Xm,X as _d,a as Zt,x as Nn,bt as Vr,f as hn,V as Jm,a0 as Zm,a1 as eh,a2 as th,a3 as $d,a4 as Qs,z as mr,Y as sh,a8 as pl,k as nh,d as zd,o as rh,bu as Wd,af as oh,bv as Fn,bw as $n,m as Mo,bx as Fi,by as ih,au as Pa,ac as Oo,F as lr,al as is,bz as Kd,aN as ah,bA as Li,aC as Vd,aD as Ud,an as lh,am as ch,ad as dh,bB as No,bC as Ao,bD as uh,bE as gl,a_ as fh,bF as mh,bG as hh,bH as ph,bI as bl,bJ as xl,bK as yl,bL as wl,bM as gh,A as vl,bN as bh,bO as xh,S as yh,B as wh,C as vh}from"./index-BvpIhpBI.js";import{_ as en}from"./vendor-vite-runtime-DD1OZmLC.js";import{a6 as Sl,ae as bi,af as Ws,ag as _i,ah as jl,ai as Sh,aj as jh,ak as kh,al as Ch,am as Nh,an as Ah,ao as Ph,ap as Dh,aq as Ih,ar as Da,o as Th,E as Hd,k as Eh,l as Rh,a1 as Gd,m as $i,I as qd,d as Mh,a as Oh,N as Bh,C as Yd,f as zi,g as Ln,h as Qd,i as Xd,e as Fh,P as Lh,J as _h,ac as $h,a9 as zh,ad as Wh,a5 as Kh,y as Jd,as as Vh,at as Uh,p as Hh,n as Zd,S as xi,au as eu,B as Gh,av as tu,z as qh,aw as Yh,v as Qh,w as Xh,ax as ir,x as yi,ay as Jh,az as kl,aA as Zh,j as Fr,q as ep,A as tp,D as sp,aB as np,K as rp,Y as op,Q as ip,aC as ap,W as lp,Z as su,_ as cp,$ as dp,a0 as up,aD as fp,a8 as mp,aE as hp,O as pp,M as gp,R as bp,V as nu,U as xp,X as yp}from"./runtimeEndpointReset-D56xMbiw.js";import{u as At,h as De,al as _t,I as B,am as Gn,t as _e,A as vs,cm as hs,C as Ss,F as js,a4 as qn,j as gn,a2 as Yn,a3 as Pn,o as Yr,gJ as Cl,kq as wp,kr as vp,ai as vt,aj as St,ak as jt,a0 as zt,Z as ot,f7 as Sp,is as ru,ks as oo,eR as ps,c7 as Is,c4 as ou,c3 as iu,cG as Wi,kt as jp,gz as au,cH as lu,c6 as cu,ku as kp,ff as Cp,kv as Nl,kw as Al,kx as du,ky as Np,kz as Pl,kA as Ap,kB as Pp,kC as Ia,eX as Ki,gI as uu,kD as Dp,kE as Ip,kF as Tp,fC as fu,kG as Ep,kH as Rp,kI as Mp,fs as ur,kJ as Op,kK as Bp,b5 as Fp,ft as Lp,b1 as mu,kL as _p,b3 as $p,kM as zp,kN as hu,kO as pu,kP as gu,kQ as bu,kR as xu,kS as yu,kT as wu,hS as Qr,a as Ta,$ as Ea,aF as zn,b8 as Xr,b9 as Wp,e as ks,d as Cs,c as Hs,D as Ls,b as _s,bW as Qn,B as mt,S as bn,an as ms,kU as Kp,kV as Vp,cy as pn,cl as cr,cz as Ps,cB as Yo,m as vu,aH as Vi,aE as Dl,aD as Il,kW as Up,p as ln,q as cn,r as Js,v as dn,w as ds,y as Wn,g_ as Er,x as Tl,bX as Lr,aC as Hp,c0 as Qo,bJ as Gp,bL as Ra,ck as qp,bK as Yp,a1 as Xn,d9 as Su,n as ju,dj as Qp,dm as Xp,bP as Jp,dn as Zp,bZ as ku,gj as eg,gk as tg,bR as Ma,dy as sg,l as Cu,kX as hr,_ as Nu,kY as ng,a8 as Wt,fv as rg,kZ as og,aS as ig,bo as Dn,k_ as ag,k$ as dr,cb as Au,cP as lg,aG as cg,dx as In,l0 as dg,l1 as ug,g1 as fg,l2 as wi,l3 as mg,l4 as hg,l5 as pg,l6 as Pu,dB as gg,l7 as Oa,l8 as bg,l9 as Du,j1 as xg,k as Ui,kp as Hi,fa as El,la as yg,lb as Rl,lc as Rr,fm as Ur,fn as Ba,fP as wg,fM as Iu,cu as Cr,cr as Mr,ld as vg,le as Sg,hY as jg,fK as Fa,lf as kg,g0 as Cg,cw as Ng,cs as Ag,cv as Pg,ct as Dg,lg as Tu,bN as Us,b7 as Ig,lh as Eu,li as Tg,fS as Gi,lj as Eg,lk as Ru,iA as es,jI as Rg,jJ as Mg,ll as Mu,lm as Og,iq as La,b2 as _a,ln as Ml,fR as Bo,fo as $a,lo as Bg,fQ as Ou,lp as Bu,lq as qi,fp as Fu,fD as za,fE as Wa,fF as Ka,lr as Fg,ls as Lg,iH as Gt,lt as _g,i1 as yr,i0 as Lu,lu as _u,lv as $u,lw as zu,lx as $g,fx as zg,ly as Wg,lz as Kg,fG as Wu,fT as Vg,lA as Ug,lB as Ol,lC as Hg,lD as Ku,c5 as Vu,hp as Gg,lE as qg,lF as Yg,lG as Qg,lH as _r,fH as Yi,lI as Xg,lJ as Jg,lK as Zg,lL as eb,fU as tb,lM as Uu,lN as Xo,lO as sb,gQ as Hr,a6 as nb,fy as Jo,lP as rb,lQ as ob,lR as Bl,h_ as ib,lS as ab,fL as lb,fO as cb,ir as db,lT as ub,bs as Fl,br as Ll,bq as _l,lU as fb,bg as Qi,lV as mb,fA as hb,fB as vi,gu as pb,cp as gb,cj as bb,gw as xb,gx as yb,lW as wb,lX as vb,lY as Sb,i$ as jb,id as kb,cq as Cb,lZ as Fo,l_ as Nb,l$ as $l,m0 as Ab,gp as Pb,m1 as Db,m2 as Ib,fl as Hu,eS as Xi,eT as Va,hw as Gu,m3 as Tb,m4 as Po,jt as Eb,fq as Rb,ju as Mb,m5 as Ob,m6 as Bb,hG as Fb,ig as Lb,m7 as _b,iw as zl,m8 as $b,bc as zb,bd as Wb,bf as Kb,be as Vb,bl as Wl,bk as Kl,bh as Vl,bi as Ul,ga as qu,bj as Yu,bn as Ub,bx as Hb,by as Gb,bz as qb,bA as Yb,bB as Qb,gg as Xb,bt as Jb,bu as Zb,bv as ex,bw as tx}from"./useAppFontEffects-FdVEdwq7.js";import{u as Qu,S as Hl,C as sx,t as nx,W as Xu,f as rx,G as ox,a as ix}from"./useRootScrollLock-BhAup8Zd.js";import{u as En,O as Gl,c as ax,D as lx,a as cx,f as dx,d as ql,e as ux,g as fx,h as mx,r as hx}from"./scheduledTasksApi-BZMS2h6Z.js";import{f as Zo,h as fn,T as ei,M as ti,D as si,j as ni,d as px,b as gx,k as bx,i as xx}from"./vendor-dnd-kit-core-B-dmENub.js";import{u as ri,S as Ua,h as yx,a as Ju,v as Zu,s as wx}from"./vendor-dnd-kit-sortable-DiuAkJDx.js";import{C as oi}from"./vendor-dnd-kit-utilities-D2MO70n8.js";import{S as ef,M as tf,C as sf,f as Ji,g as Zi,e as ea,h as nf,m as vx,n as Sx}from"./vendor-base-ui-BV0ycO3d.js";import{a as Jr,u as Un,d as jx,p as kx}from"./vendor-zustand-XNmn2Hnw.js";import{g as Cx,a as Nx,E as rf,b as Ax,c as Px,d as Dx,e as Ix,i as Tx}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as Ex}from"./PluginPane-Dx0_Dldo.js";import{a as Ha,s as Hn,r as of,o as Yl,b as Ql}from"./vendor-zod-C3BVLiwa.js";import{u as Rx}from"./vendor-tanstack-react-virtual-BHz8HhxS.js";import{d as Mx}from"./vendor-tanstack-virtual-core-BoA4iGMw.js";import{d as af}from"./vendor-cron-parser-B7wFT8N0.js";const Ox="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",Bx="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",Si=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Ox:t.id==="terminal"?Bx:void 0}),Xl=t=>{const e=nt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l(!0),e[2]=g):g=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=De("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},Fx=t=>{const e=nt.c(75),{directory:n,className:r}=t,{t:i}=At(),o=En(Lx),l=En(_x),a=En($x),d=En(zx),u=En(Wx),m=En(Kx),f=En(Vx);let g,y;e[0]!==u?(g=()=>{u()},y=[u],e[0]=u,e[1]=g,e[2]=y):(g=e[1],y=e[2]),c.useEffect(g,y);const b=mn()&&qo();let j;e:{let we;e[3]!==l||e[4]!==o?(we=l.find(L=>L.id===o)??l.find(Ux)??l[0]??Gl[0],e[3]=l,e[4]=o,e[5]=we):we=e[5];const fe=we;if(fe){let L;e[6]!==fe?(L=Si(fe),e[6]=fe,e[7]=L):L=e[7],j=L;break e}let Ne;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ne=Si(Gl[0]),e[8]=Ne):Ne=e[8],j=Ne}const x=j;if(!b||!n||l.length===0)return null;let h;e[9]!==n?(h=async we=>{await Hm(n,we.id,we.appName)||await Gm(n,we.appName)},e[9]=n,e[10]=h):h=e[10];const p=h;let w;e[11]!==p||e[12]!==f?(w=async we=>{await f(we.id),await p(we)},e[11]=p,e[12]=f,e[13]=w):w=e[13];const S=w;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await Gn(n)).ok&&_e.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const P=N;let C;e[17]!==r?(C=De("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=C):C=e[18];let T;e[19]!==p||e[20]!==x?(T=()=>{p(x)},e[19]=p,e[20]=x,e[21]=T):T=e[21];const R=d&&"animate-pulse";let M;e[22]!==R?(M=De("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",R),e[22]=R,e[23]=M):M=e[23];let F;e[24]!==x.label||e[25]!==i?(F=i("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=i,e[26]=F):F=e[26];let K;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(K=s.jsx(Xl,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=K):K=e[30];let D;e[31]!==M||e[32]!==F||e[33]!==K||e[34]!==T?(D=s.jsx("button",{type:"button",onClick:T,className:M,"aria-label":F,children:K}),e[31]=M,e[32]=F,e[33]=K,e[34]=T,e[35]=D):D=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=De("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=U):U=e[36];let A;e[37]!==i?(A=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=A):A=e[38];let E;e[39]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=E):E=e[39];let W;e[40]!==A?(W=s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:U,"aria-label":A,children:E})}),e[40]=A,e[41]=W):W=e[41];let k;e[42]!==P?(k=()=>{P()},e[42]=P,e[43]=k):k=e[43];let v;e[44]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(B,{name:"file-copy",className:"h-4 w-4"}),e[44]=v):v=e[44];let I;e[45]!==i?(I=i("openInApp.actions.copyPath"),e[45]=i,e[46]=I):I=e[46];let H;e[47]!==I?(H=s.jsx("span",{className:"typography-ui-label text-foreground",children:I}),e[47]=I,e[48]=H):H=e[48];let $;e[49]!==k||e[50]!==H?($=s.jsxs(_t,{className:"flex items-center gap-2",onClick:k,children:[v,H]}),e[49]=k,e[50]=H,e[51]=$):$=e[51];let re;e[52]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(hs,{}),e[52]=re):re=e[52];let te;if(e[53]!==l||e[54]!==S||e[55]!==x.id){let we;e[57]!==S||e[58]!==x.id?(we=fe=>{const Ne=Si(fe);return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{S(fe)},children:[s.jsx(Xl,{label:fe.label,iconDataUrl:fe.iconDataUrl,fallbackIconDataUrl:Ne.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:fe.label}),x.id===fe.id?s.jsx(B,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},fe.id)},e[57]=S,e[58]=x.id,e[59]=we):we=e[59],te=l.map(we),e[53]=l,e[54]=S,e[55]=x.id,e[56]=te}else te=e[56];let ee;e[60]!==a||e[61]!==m||e[62]!==i?(ee=a?s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(B,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=m,e[62]=i,e[63]=ee):ee=e[63];let ue;e[64]!==$||e[65]!==te||e[66]!==ee?(ue=s.jsxs(Ss,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[$,re,te,ee]}),e[64]=$,e[65]=te,e[66]=ee,e[67]=ue):ue=e[67];let de;e[68]!==W||e[69]!==ue?(de=s.jsxs(js,{children:[W,ue]}),e[68]=W,e[69]=ue,e[70]=de):de=e[70];let Te;return e[71]!==D||e[72]!==de||e[73]!==C?(Te=s.jsxs("div",{className:C,children:[D,de]}),e[71]=D,e[72]=de,e[73]=C,e[74]=Te):Te=e[74],Te};function Lx(t){return t.selectedAppId}function _x(t){return t.availableApps}function $x(t){return t.isCacheStale}function zx(t){return t.isScanning}function Wx(t){return t.initialize}function Kx(t){return t.loadInstalledApps}function Vx(t){return t.selectApp}function Ux(t){return t.id===ax}const Lo=new Map,ta=new Set,lf=()=>{for(const t of ta)t()},ji=(t,e)=>{const n=t.trim();n&&(e.length===0?Lo.delete(n):Lo.set(n,[...e]),lf())},Hx=t=>{Lo.delete(t.trim())&&lf()},cf=[],Gx=t=>Lo.get(t.trim())??cf,qx=t=>(ta.add(t),()=>{ta.delete(t)}),Yx=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=()=>Gx(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(qx,n,Qx)};function Qx(){return cf}const Xx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Jx=["dev","start","preview","serve"];async function Zx(t,e,n){if(!t)return null;const r=sy(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=ny(n);if(i){const o=await ry(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await ey(t)){const i=await ty(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function ey(t){const e=`${t}/index.html`,n=await _o(e,t);return typeof n=="string"&&n.trim().length>0}async function ty(){try{const t=await as("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function sy(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Jx.some(i=>n.includes(i)))return e}return null}function ny(t){for(const{pattern:e}of Xx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function ry(t){const e=await _o(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await _o(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function _o(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await as(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Fd()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await as(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function oy(t){try{const e=await _o(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const Vs="__openchamber_auto_discover_preview__",iy=15e3,ay=3e3,ki=t=>t.id===Vs?"scan-2":Dh.find(n=>n.key===t.icon)?.Icon??"play",ly=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},cy=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=At(),{currentTheme:l}=qn(),{terminal:a,runtime:d}=gn(),u=Yn(),{isMobile:m}=Pn(),f=c.useMemo(()=>mn(),[]),g=Sl(X=>X.instances),y=Sl(X=>X.load),b=ye(X=>X.terminalShell),j=ye(X=>X.terminalLoginShells.includes(X.terminalShell)),x=ye(X=>X.setSettingsPage),h=ye(X=>X.setSettingsDialogOpen),p=ye(X=>X.setSettingsProjectsSelectedId),w=ye(X=>X.openContextPreview),S=Et(X=>X.ensureDirectory),N=Et(X=>X.reconcileServerSessions),P=Et(X=>X.setTabLabel),C=Et(X=>X.setTabIconKey),T=Et(X=>X.setActiveTab),R=Et(X=>X.setConnecting),M=Et(X=>X.setTabSessionId),F=Et(X=>X.setTabPurpose),K=Et(X=>X.allocateActionExecution),D=Et(X=>X.setTabLifecycle),U=Et(X=>X.setTabPreviewUrl),A=Et(X=>X.matchesActionExecution),E=Et(X=>X.captureStartedActionMutationRevisions),[W,k]=c.useState([]),v=c.useRef(null),[I,H]=c.useState(null),[$,re]=c.useState(!1),te=c.useRef({}),ee=c.useRef({}),ue=c.useRef({}),de=c.useRef(new Set),Te=c.useRef(0),[we,fe]=c.useState({}),Ne=t?.id??null,L=t?.path??"",oe=c.useMemo(()=>Ne?{id:Ne,path:L}:null,[Ne,L]);c.useEffect(()=>{f&&y().catch(()=>{})},[f,y]);const ce=c.useCallback(async X=>{await Yr(X)},[]),pe=c.useCallback(async()=>{if(!oe)return;const X=Te.current+1;Te.current=X,re(!0);try{const ae=await Cl(oe);if(Te.current!==X)return;v.current=ae;const Ae=ae.projectActions;k(Ae),H(Ge=>Ge===Vs||Ge&&Ae.some(q=>q.id===Ge)?Ge:null)}catch{if(Te.current!==X)return}finally{Te.current===X&&re(!1)}},[oe]),Y=c.useMemo(()=>bi(e||oe?.path||""),[e,oe?.path]),ve=c.useMemo(()=>bi(oe?.path||""),[oe?.path]),Ee=c.useMemo(()=>bi(u||"")||Y,[u,Y]),je=c.useRef(Ee);c.useEffect(()=>{je.current=Ee},[Ee]);const ge=Et(X=>Y?X.getDirectoryState(Y):void 0),be=Et(X=>ve&&ve!==Y?X.getDirectoryState(ve):void 0),Q=c.useMemo(()=>{const X=Y?[{directory:Y,state:ge}]:[];return ve&&ve!==Y&&X.push({directory:ve,state:be}),X},[ge,Y,ve,be]),_=c.useMemo(()=>{const X=Y?[Y]:[];return ve&&ve!==Y&&X.push(ve),X},[Y,ve]),J=c.useCallback(X=>X.id!==Vs&&X.runIn==="parent"&&ve||Y,[Y,ve]),me=c.useCallback((X,ae,Ae)=>`${X}::${ae}::${Ae}`,[]),le=c.useCallback((X,ae,Ae=Et.getState())=>X?Ae.getDirectoryState(X)?.tabs.find(Ge=>Ge.purpose.type==="project-action"&&Ge.purpose.actionId===ae)??null:null,[]),V=c.useMemo(()=>{const X={};for(const{directory:ae,state:Ae}of Q)for(const Ge of Ae?.tabs??[]){if(Ge.purpose.type!=="project-action"||!Ge.purpose.executionId||!Ge.terminalSessionId||Ge.lifecycle==="idle"||Ge.lifecycle==="exited")continue;const q=Ws(ae,Ge.purpose.actionId),Fe=me(ae,Ge.purpose.actionId,Ge.purpose.executionId);X[q]={directory:ae,actionId:Ge.purpose.actionId,tabId:Ge.id,sessionId:Ge.terminalSessionId,executionId:Ge.purpose.executionId,status:Ge.lifecycle==="stopping"?"stopping":we[Fe]?"waiting-for-preview":"running"}}return X},[me,we,Q]),Z=c.useCallback((X,ae,Ae)=>{const Ge=Ws(X,ae),q=me(X,ae,Ae),Ze=te.current[Ge]?.executionId===Ae,Je=globalThis.window,et=kt=>{Je?.clearTimeout(ue.current[kt]),delete ue.current[kt]};Ze&&(delete te.current[Ge],et(Ge)),ee.current[q]?.(),delete ee.current[q],et(q),fe(kt=>{if(!kt[q])return kt;const Qe={...kt};return delete Qe[q],Qe})},[me]),G=c.useCallback(X=>{ee.current[X]?.(),delete ee.current[X]},[]),ie=c.useCallback(X=>{window.clearTimeout(ue.current[X]),delete ue.current[X]},[]);c.useEffect(()=>{const X=ee.current,ae=ue.current;return()=>{for(const Ae of Object.keys(X))G(Ae);for(const Ae of Object.keys(ae))ie(Ae)}},[ie,G]),c.useEffect(()=>{const X=new Set(_);for(const ae of Object.values(te.current))X.has(ae.directory)||Z(ae.directory,ae.actionId,ae.executionId);for(const ae of Object.keys(ee.current)){const Ae=ae.split("::",1)[0]??"";X.has(Ae)||G(ae)}},[Z,G,_]);const Se=c.useCallback((X,ae)=>{ye.getState().openContextPanelTab(X,{mode:"terminal",targetDirectory:ae===X?null:ae})},[]),se=c.useMemo(()=>I?W.find(X=>X.id===I)??null:null,[W,I]),Me=c.useMemo(()=>({id:Vs,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),He=!m,We=c.useMemo(()=>He?[Me,...W]:W,[W,Me,He]);c.useEffect(()=>{pe()},[pe]),c.useEffect(()=>{const X=_.map(ae=>_i(a,ae,E,Ae=>N(ae,Ae.sessions,{startedActionMutationRevisions:Ae.startedActionMutationRevisions})));return()=>{for(const ae of X)ae()}},[E,N,a,_]),c.useEffect(()=>{for(const{directory:X,state:ae}of Q)if(X)for(const Ae of ae?.tabs??[]){if(Ae.purpose.type!=="project-action")continue;const Ge=Ae.purpose.actionId,q=We.find(Je=>Je.id===Ge),Fe=q?.name??Ge,Ze=q?.icon||"play";Ae.label!==Fe&&P(X,Ae.id,Fe),Ae.iconKey!==Ze&&C(X,Ae.id,Ze)}},[We,C,P,Q]),c.useEffect(()=>{const X=globalThis.window;if(!X)return;const ae=Ae=>{const Ge=Ae.detail;Ne&&(Ge?.projectId&&Ge.projectId!==Ne||pe())};return X.addEventListener(jl,ae),()=>{X.removeEventListener(jl,ae)}},[pe,Ne]),c.useEffect(()=>{I&&(I===Vs&&He||W.some(X=>X.id===I)||H(null))},[W,He,I]),c.useEffect(()=>{const X=Ae=>{delete ue.current[Ae];const Ge=te.current[Ae];if(!Ge||Ge.openedUrl)return;const q=me(Ge.directory,Ge.actionId,Ge.executionId),Fe=Ge.announced;if(Fe.length!==0){if(window.clearTimeout(ue.current[q]),delete ue.current[q],Ge.openedUrl=!0,fe(Ze=>{if(!Ze[q])return Ze;const Je={...Ze};return delete Je[q],Je}),Fe.length===1){ji(Ge.directory,[]),U(Ge.directory,Ge.tabId,Fe[0],{locked:!1,autoOpened:!0}),w(Ge.directory,Fe[0]);return}Ge.offering=!0,ji(Ge.directory,Fe),ye.getState().openContextSurface(Ge.directory,"browser"),_e.info(o("projectActions.toast.multipleServers"))}},ae=()=>{const Ae=Et.getState(),Ge=Ae.sessions,q=V;for(const[Fe,Ze]of Object.entries(q)){const et=Ge.get(Ze.directory)?.tabs.find(rt=>rt.id===Ze.tabId);if(!et||et.terminalSessionId!==Ze.sessionId){Z(Ze.directory,Ze.actionId,Ze.executionId);continue}const kt=te.current[Fe],Qe=kt?.executionId===Ze.executionId?kt:{hostDirectory:je.current||Ze.directory,directory:Ze.directory,tabId:Ze.tabId,actionId:Ze.actionId,executionId:Ze.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};te.current[Fe]=Qe;const It=We.find(rt=>rt.id===Ze.actionId),Mt=Ae.getBuffer(Ze.directory,Ze.tabId).chunks;if(!It||Mt.length===0)continue;const ke=Mt.filter(rt=>Qe.lastSeenChunkId===null||rt.id>Qe.lastSeenChunkId);if(ke.length===0)continue;const Oe=ke.map(rt=>rt.data).join(""),Re=`${Qe.tail}${Oe}`;if(Qe.openInPreview&&(!Qe.openedUrl||Qe.offering)){const rt=Ah(Re),xt=Qe.announced.length;for(const ze of rt)Qe.announced.includes(ze)||Qe.announced.push(ze);const Pe=Qe.announced.length-xt;Qe.offering&&Pe>0?ji(Ze.directory,Qe.announced):!Qe.openedUrl&&xt===0&&Qe.announced.length>0&&(window.clearTimeout(ue.current[Fe]),ue.current[Fe]=window.setTimeout(()=>X(Fe),ay))}const Be=!Qe.openedUrl&&It.autoOpenUrl===!0&&!Qe.openInPreview?Ph(Re):null,Ke=ke[ke.length-1]?.id??Qe.lastSeenChunkId;if(Qe.lastSeenChunkId=Ke,Qe.tail=Re.slice(-512),Be)if(Qe.openedUrl=!0,Qe.openInPreview){const rt=q[Fe];rt&&(U(rt.directory,rt.tabId,Be,{locked:!1,autoOpened:!1,expectedExecutionId:rt.executionId}),rt.status==="waiting-for-preview"&&fe(xt=>{const Pe=me(rt.directory,rt.actionId,rt.executionId);if(!xt[Pe])return xt;const ze={...xt};return delete ze[Pe],ze}),window.clearTimeout(ue.current[Fe]),delete ue.current[Fe],w(rt.directory,Be))}else ce(Be),_e.success(o("projectActions.toast.openedUrlFromOutput"));te.current[Fe]=Qe}for(const Fe of Object.keys(te.current))if(!q[Fe]){const Ze=te.current[Fe],Je=Ze?Ge.get(Ze.directory)?.tabs.find(kt=>kt.id===Ze.tabId):void 0;if(Je?.purpose.type==="project-action"&&Je.purpose.executionId===Ze?.executionId&&!!Je.terminalSessionId&&Je.lifecycle!=="idle"&&Je.lifecycle!=="exited")continue;delete te.current[Fe],window.clearTimeout(ue.current[Fe]),delete ue.current[Fe]}};return ae(),Et.subscribe((Ae,Ge)=>{(Ae.sessions!==Ge.sessions||Ae.buffers!==Ge.buffers)&&ae()})},[Z,je,We,me,w,ce,V,U,o]),c.useEffect(()=>{for(const{directory:X,state:ae}of Q)for(const Ae of ae?.tabs??[]){if(Ae.purpose.type!=="project-action"||!Ae.purpose.executionId||!Ae.terminalSessionId||Ae.lifecycle!=="running")continue;const Ge=Ae.purpose.actionId,q=Ae.purpose.executionId,Fe=me(X,Ge,q);if(ee.current[Fe])continue;const Ze=a.connect(Ae.terminalSessionId,{onEvent:Je=>{if(!A(X,Ae.id,q))return;Je.type==="snapshot"&&(Et.getState().replaceBuffer(X,Ae.id,Je.data??"",Je.sequence??0,hl(Je)),Je.status==="running"&&Et.getState().setTabLifecycle(X,Ae.id,"running",{expectedExecutionId:q}),Je.status==="exited"&&(Et.getState().setTabLifecycle(X,Ae.id,"exited",{expectedExecutionId:q}),Et.getState().setTabPurpose(X,Ae.id,{type:"project-action",actionId:Ge,executionId:null}),Z(X,Ge,q)));const et=Je.type==="data"?Je.data??"":"";et&&Et.getState().appendToBuffer(X,Ae.id,et,Je.sequence,Je.replayData),Je.type==="exit"&&(Et.getState().setTabLifecycle(X,Ae.id,"exited",{expectedExecutionId:q}),Et.getState().setTabPurpose(X,Ae.id,{type:"project-action",actionId:Ge,executionId:null}),Z(X,Ge,q))},onError:(Je,et)=>{!et||!A(X,Ae.id,q)||(Et.getState().setTabLifecycle(X,Ae.id,"exited",{expectedExecutionId:q}),Et.getState().setTabSessionId(X,Ae.id,null,{expectedExecutionId:q}),Et.getState().setTabPurpose(X,Ae.id,{type:"project-action",actionId:Ge,executionId:null}),Z(X,Ge,q))}},X);ee.current[Fe]=Ze.close}},[Z,me,A,a,Q]);const Le=c.useCallback(async X=>{const ae=J(X);if(!ae)throw new Error(o("projectActions.error.noActiveDirectory"));const Ae=Ws(ae,X.id);S(ae);const Ge=Et.getState(),q=le(ae,X.id,Ge),Fe=q?.id??Ge.createTab(ae);P(ae,Fe,X.name),C(ae,Fe,X.icon||"play"),q||F(ae,Fe,{type:"project-action",actionId:X.id,executionId:null}),T(ae,Fe);const Je=Et.getState().getDirectoryState(ae)?.tabs.find(et=>et.id===Fe);return{executionDirectory:ae,key:Ae,tabId:Fe,sessionId:Je?.terminalSessionId??null,executionId:Je?.purpose.type==="project-action"?Je.purpose.executionId:null}},[S,J,le,T,C,P,F,o]),Ve=c.useCallback(async X=>{if(d.isVSCode||!i&&m)return;if(!Y){_e.error(o("projectActions.error.noActiveDirectoryForAction"));return}const ae=Ws(J(X),X.id),Ae=V[ae];if(Ae&&Ae.status==="running"||de.current.has(ae))return;de.current.add(ae);let Ge=null;try{const q=X.id===Vs?await(async()=>{const[Pe,ze]=await Promise.all([wp({id:oe?.id??"",path:Y}),oy(Y)]),st=await Zx(Y,Pe.actions,ze);if(!st)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Vs,name:o("projectActions.actions.autoDiscover"),command:st.command,icon:"scan-2",autoOpenUrl:!0,openUrl:st.previewUrlHint||""}})():X,Fe=q.autoOpenUrl===!0&&(q.openUrl||"").trim().length>0,Ze=!Fe&&X.id!==Vs,Je=je.current||Y,{executionDirectory:et,key:kt,tabId:Qe}=await Le(q),It=Sh(q.command);if(!It)throw new Error(o("projectActions.error.failedToRunAction"));const Mt=q.autoOpenUrl===!0&&f&&(q.desktopOpenSshForward||"").trim().length>0,ke=q.autoOpenUrl?ly(q.openUrl):null,Oe=q.autoOpenUrl&&f?jh(q.desktopOpenSshForward,g):null;if(a.listSessions){const Pe=le(et,q.id);if(Pe?.purpose.type==="project-action"&&Pe.purpose.executionId===null){const ze=await kh(a,et,{captureStartedActionMutationRevisions:E});ze&&N(et,ze.sessions,{startedActionMutationRevisions:ze.startedActionMutationRevisions})}}const Re=le(et,q.id);let Be,Ke;if(Re?.lifecycle==="running"&&Re.terminalSessionId&&Re.purpose.type==="project-action"&&Re.purpose.executionId)Be=Re.terminalSessionId,Ke=Re.purpose.executionId;else{const Pe=Re?.purpose.type==="project-action"?Re.purpose.executionId:null;Pe&&Z(et,q.id,Pe);const ze=K(et,Qe,q.id);if(!ze)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Ge={directory:et,tabId:Qe,id:ze},R(et,Qe,!0,{expectedExecutionId:ze});const st=await Ch({terminal:a,createOptions:{cwd:et,shell:b,loginShell:j,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:It,isRunStillExpected:()=>A(et,Qe,ze),purpose:{type:"project-action",actionId:q.id,executionId:ze}});if(!A(et,Qe,ze)){st.sessionId===ze&&await a.close(st.sessionId).catch(()=>{});return}Ke=st.purpose?.type==="project-action"?st.purpose.executionId:ze,Be=st.sessionId,F(et,Qe,{type:"project-action",actionId:q.id,executionId:Ke}),M(et,Qe,Be,{expectedExecutionId:Ke}),R(et,Qe,!1,{expectedExecutionId:Ke})}Ze&&Je&&Se(Je,et),te.current[kt]={hostDirectory:Je,directory:et,tabId:Qe,actionId:q.id,executionId:Ke,lastSeenChunkId:null,openedUrl:!!Oe||!!ke||Fe,tail:"",openInPreview:q.id===Vs,announced:[],offering:!1};const rt=me(et,q.id,Ke);R(et,Qe,!0,{expectedExecutionId:Ke});const xt=a.connect(Be,{onEvent:Pe=>{if(!A(et,Qe,Ke)||Pe.purpose?.type==="project-action"&&Pe.purpose.executionId!==Ke)return;Pe.type==="snapshot"&&(Et.getState().replaceBuffer(et,Qe,Pe.data??"",Pe.sequence??0,hl(Pe)),Et.getState().setConnecting(et,Qe,!1,{expectedExecutionId:Ke}),Pe.purpose?.type==="project-action"&&Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:Pe.purpose.actionId,executionId:Pe.purpose.executionId}),Pe.status==="running"&&Et.getState().setTabLifecycle(et,Qe,"running",{expectedExecutionId:Ke}),Pe.status==="exited"&&(Et.getState().setTabLifecycle(et,Qe,"exited",{expectedExecutionId:Ke}),Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ke)));const ze=Pe.type==="data"?Pe.data??"":"";ze&&Et.getState().appendToBuffer(et,Qe,ze,Pe.sequence,Pe.replayData),Pe.type==="exit"&&(Et.getState().setTabLifecycle(et,Qe,"exited",{expectedExecutionId:Ke}),Et.getState().setConnecting(et,Qe,!1,{expectedExecutionId:Ke}),Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ke))},onError:(Pe,ze)=>{A(et,Qe,Ke)&&(Et.getState().setConnecting(et,Qe,!1,{expectedExecutionId:Ke}),ze&&(Et.getState().setTabLifecycle(et,Qe,"exited",{expectedExecutionId:Ke}),Et.getState().setTabSessionId(et,Qe,null,{expectedExecutionId:Ke}),Et.getState().setTabPurpose(et,Qe,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ke)))}},et);if(!A(et,Qe,Ke)){xt.close();return}ee.current[rt]?.(),ee.current[rt]=xt.close,window.clearTimeout(ue.current[rt]),delete ue.current[rt],q.id===Vs&&!ke&&(fe(Pe=>({...Pe,[rt]:!0})),ue.current[rt]=window.setTimeout(()=>{delete ue.current[rt];const Pe=te.current[kt];!Pe||Pe.executionId!==Ke||Pe.openedUrl||Pe.offering||A(et,Qe,Ke)&&(fe(ze=>{if(!ze[rt])return ze;const st={...ze};return delete st[rt],st}),Et.getState().setActiveTab(et,Qe),Se(Pe.hostDirectory,et))},iy)),Oe?(U(et,Qe,null,{locked:!0,expectedExecutionId:Ke}),ce(Oe),_e.success(o("projectActions.toast.openedForwardedUrl"))):ke?(U(et,Qe,ke,{locked:!0,autoOpened:!0,expectedExecutionId:Ke}),w(Je,ke),_e.success(o("projectActions.toast.openedActionUrl"))):Fe?(U(et,Qe,null,{locked:!0,expectedExecutionId:Ke}),_e.error(o("projectActions.error.invalidCustomUrlFormat"))):Mt?(U(et,Qe,null,{locked:!0,expectedExecutionId:Ke}),_e.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):U(et,Qe,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ke})}catch(q){if(Ge&&A(Ge.directory,Ge.tabId,Ge.id)){const{directory:Fe,tabId:Ze,id:Je}=Ge;Z(Fe,X.id,Je),D(Fe,Ze,"exited",{expectedExecutionId:Je}),F(Fe,Ze,{type:"project-action",actionId:X.id,executionId:null})}if(q instanceof Error&&q.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(q instanceof Error&&(q.message==="COMMAND_MODE_UNSUPPORTED"||q.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){_e.error(o("projectActions.error.failedToCreateTerminalSession"));return}_e.error(q instanceof Error?q.message:o("projectActions.error.failedToRunAction"))}finally{de.current.delete(ae)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,je,g,Le,i,m,f,Y,j,b,ce,w,V,Se,d.isVSCode,J,A,Z,me,le,N,K,E,R,D,F,U,M,oe?.id,o,a]),O=c.useCallback(async X=>{const ae=Ws(J(X),X.id),Ae=V[ae];Ae&&await Nh({terminal:a,sessionId:Ae.sessionId,isExecutionStillCurrent:()=>A(Ae.directory,Ae.tabId,Ae.executionId),markStopping:()=>{D(Ae.directory,Ae.tabId,"stopping",{expectedExecutionId:Ae.executionId})},restoreRunning:()=>{D(Ae.directory,Ae.tabId,"running",{expectedExecutionId:Ae.executionId})},clearSession:()=>{M(Ae.directory,Ae.tabId,null,{expectedExecutionId:Ae.executionId})},finalizeExit:()=>{D(Ae.directory,Ae.tabId,"exited",{expectedExecutionId:Ae.executionId}),F(Ae.directory,Ae.tabId,{type:"project-action",actionId:Ae.actionId,executionId:null}),Z(Ae.directory,Ae.actionId,Ae.executionId)}})},[Z,J,A,V,D,F,M,a]),he=c.useCallback(()=>{const X=se??We[0];if(!X)return;const ae=Ws(J(X),X.id),Ae=V[ae];if(Ae?.status!=="stopping"){if(Ae){O(X);return}Ve(X)}},[We,J,Ve,V,se,O]),$e=c.useCallback(async X=>{if(X.source==="shared"&&oe){const ae=v.current?.trust.trusted?v.current:await Cl(oe);if(v.current=ae,!await vp(oe,ae))return;v.current={...ae,trust:{...ae.trust,trusted:!0}}}await Ve(X)},[Ve,oe]),Ue=c.useCallback((X,ae=!1)=>{if(H(X.id),!ae){$e(X);return}const Ae=Ws(J(X),X.id),Ge=V[Ae];if(Ge?.status!=="stopping"){if(Ge){O(X);return}$e(X)}},[J,$e,V,O]),ct=c.useCallback(()=>{oe?.id&&(p(oe.id),x("projects"),h(!0))},[h,x,p,oe?.id]),pt=se??We[0]??null,it=pt?V[Ws(J(pt),pt.id)]:null,ft=Et(X=>it?X.getDirectoryState(it.directory)?.tabs.find(ae=>ae.id===it.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&m||!oe||!Y)return null;const yt=se??We[0]??null;if(!yt)return null;const ht=ki(yt),bt=Ws(J(yt),yt.id),Dt=V[bt],xe=Dt?.status==="stopping",Ye=Dt?.status==="waiting-for-preview",Xe=!!(Dt&&ft),qe=()=>{!Dt||!ft||w(Dt.directory,ft)},dt=yt.id===Vs;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",disabled:$||xe,className:De("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:he,"aria-label":Dt?o("projectActions.actions.stopNamedAria",{name:yt.name}):o("projectActions.actions.runNamedAria",{name:yt.name}),children:xe||Ye?s.jsx(B,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Dt?s.jsx(B,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(B,{name:ht,className:"h-5 w-5"})})}),dt?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Xe?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:qe,children:s.jsx(B,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ss,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:ct,children:[s.jsx(B,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(hs,{}),We.map(X=>{const ae=ki(X),Ae=Ws(J(X),X.id),Ge=V[Ae],q=!!Ge,Fe=Ge?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ue(X,!0)},children:[s.jsx(B,{name:ae,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),X.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||Ge?.status==="waiting-for-preview"?s.jsx(B,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):q?s.jsx(B,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]}):s.jsxs("div",{className:De("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:he,disabled:$||xe,className:De("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":Dt?o("projectActions.actions.stopNamedAria",{name:yt.name}):o("projectActions.actions.runNamedAria",{name:yt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:xe||Ye?s.jsx(B,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Dt?s.jsx(B,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(B,{name:ht,className:"h-4 w-4"})})})}),dt?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Xe?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:qe,className:De(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(B,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:De(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ss,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:ct,children:[s.jsx(B,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(hs,{}),We.map(X=>{const ae=ki(X),Ae=Ws(J(X),X.id),Ge=V[Ae],q=!!Ge,Fe=Ge?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ue(X,!0)},children:[s.jsx(B,{name:ae,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),X.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||Ge?.status==="waiting-for-preview"?s.jsx(B,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):q?s.jsx(B,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]})},Or=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},dy=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Or(n??"");if(i){const o=ru(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function uy(){const t=zt(b=>b.projects),e=zt(b=>b.activeProjectId),n=ot(b=>b.availableWorktreesByProject),r=ot(b=>b.currentSessionId),i=Sp(r??null),o=ot(b=>r?b.worktreeMetadata.get(r)?.path??"":""),l=ot(b=>b.newSessionDraft?.open?Or(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Or(o||""),[o]),d=c.useMemo(()=>{const b=typeof i?.directory=="string"?i.directory:"";return Or(b||"")},[i?.directory]),u=a||d||l,m=c.useMemo(()=>dy({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>Or(u||m?.path||""),[u,m?.path]),g=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),y=c.useRef(null);return c.useEffect(()=>{g&&f&&(y.current={projectRef:g,directory:f})},[f,g]),c.useMemo(()=>g&&f?{projectRef:g,directory:f}:y.current,[g,f])}const fy=({transform:t})=>({...t,y:0}),my={Item:_t,Separator:hs},hy={Item:({className:t,...e})=>s.jsx(tf,{className:De(lu,t),...e}),Separator:({className:t,...e})=>s.jsx(ef,{className:De(au,t),...e})},py=t=>{const e=nt.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:m}=t,{t:f}=At(),[g,y]=c.useState(!1),[b,j]=c.useState(!1),[x,h]=c.useState(!1);let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:w,listeners:S,setNodeRef:N,transform:P,transition:C,isDragging:T}=ri(p);let R;e[2]!==f||e[3]!==n.session.title?(R=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=R):R=e[4];const M=R,F=!i&&(g||b),K=n.id;let D;e[5]!==n.session?(D=Is(n.session),e[5]=n.session,e[6]=D):D=e[6];const U=Da(K,D),A=ou(n.id),W=iu(n.id)>0&&!r&&!A,k=A||W;let v;e[7]!==A||e[8]!==f?(v=f(A?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=A,e[8]=f,e[9]=v):v=e[9];const I=v;let H;e[10]!==d||e[11]!==x||e[12]!==r||e[13]!==g||e[14]!==o||e[15]!==n?(H=ve=>({session:n.session,open:g||x,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:ve}),e[10]=d,e[11]=x,e[12]=r,e[13]=g,e[14]=o,e[15]=n,e[16]=H):H=e[16];const $=H;let re;e[17]!==P?(re=oi.Translate.toString(P),e[17]=P,e[18]=re):re=e[18];let te;e[19]!==re||e[20]!==C?(te={transform:re,transition:C},e[19]=re,e[20]=C,e[21]=te):te=e[21];const ee=T&&"z-10 opacity-60";let ue;e[22]!==ee?(ue=De("session-tab-slot flex h-7 w-44 shrink-0 touch-none",ee),e[22]=ee,e[23]=ue):ue=e[23];const de=r?"true":"false";let Te;e[24]!==r?(Te=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Te):Te=e[25];let we;e[26]!==u?(we=ve=>u?.(ve),e[26]=u,e[27]=we):we=e[27];let fe;e[28]!==m||e[29]!==I||e[30]!==r||e[31]!==U||e[32]!==A||e[33]!==$||e[34]!==g||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==F||e[39]!==a||e[40]!==k||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==M?(fe=s.jsx(sf,{render:ve=>s.jsxs("div",{...ve,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),o(n))},onAuxClick:Ee=>{Ee.button===1&&(Ee.preventDefault(),l(n.id))},"data-controls-open":F?"true":"false",className:De("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":De("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",F&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:De("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",F&&"pr-10"),children:[s.jsx("div",{className:De("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?m:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:M})})}),U?s.jsx(B,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):k?s.jsx(cu,{state:A?"running":"unread",label:I,className:De("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",F&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:by,onPointerDown:xy,className:De("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",F&&"flex opacity-100"),children:[s.jsxs(js,{open:g,onOpenChange:Ee=>{y(Ee),Ee&&j(!0)},onOpenChangeComplete:Ee=>{Ee||j(!1),u?.(Ee)},children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"more",className:"size-4"})})}),s.jsx(Ss,{align:"start",className:"min-w-[190px]",children:a($(my))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]})]})}),e[28]=m,e[29]=I,e[30]=r,e[31]=U,e[32]=A,e[33]=$,e[34]=g,e[35]=l,e[36]=u,e[37]=o,e[38]=F,e[39]=a,e[40]=k,e[41]=i,e[42]=f,e[43]=n,e[44]=M,e[45]=fe):fe=e[45];let Ne,L;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ne={color:"var(--surface-elevated-foreground)"},L=De(Wi,"min-w-[190px]"),e[46]=Ne,e[47]=L):(Ne=e[46],L=e[47]);let oe;e[48]!==$||e[49]!==a?(oe=a($(hy)),e[48]=$,e[49]=a,e[50]=oe):oe=e[50];let ce;e[51]!==oe?(ce=s.jsx(Ji,{children:s.jsx(Zi,{className:"app-region-no-drag z-50",children:s.jsx(ea,{"data-slot":"dropdown-menu-content",style:Ne,className:L,children:oe})})}),e[51]=oe,e[52]=ce):ce=e[52];let pe;e[53]!==x||e[54]!==we||e[55]!==fe||e[56]!==ce?(pe=s.jsxs(nf,{open:x,onOpenChange:h,onOpenChangeComplete:we,children:[fe,ce]}),e[53]=x,e[54]=we,e[55]=fe,e[56]=ce,e[57]=pe):pe=e[57];let Y;return e[58]!==w||e[59]!==S||e[60]!==N||e[61]!==ue||e[62]!==de||e[63]!==Te||e[64]!==pe||e[65]!==te?(Y=s.jsx("div",{ref:N,style:te,className:ue,"data-active":de,...Te,...w,...S,children:pe}),e[58]=w,e[59]=S,e[60]=N,e[61]=ue,e[62]=de,e[63]=Te,e[64]=pe,e[65]=te,e[66]=Y):Y=e[66],Y},gy=t=>{const e=nt.c(65),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=At(),d=oo(yy),u=oo(wy),m=oo(vy),f=oo(Sy),g=ot(jy),y=ot(ky),b=ps(Cy),j=Ih(g);let x,h;e[0]!==j||e[1]!==g||e[2]!==u?(x=()=>{g&&u(g,j)},h=[g,j,u],e[0]=j,e[1]=g,e[2]=u,e[3]=x,e[4]=h):(x=e[3],h=e[4]),c.useEffect(x,h);let p;if(e[5]!==b){p=new Map;for(const ge of b)p.set(ge.id,ge);e[5]=b,e[6]=p}else p=e[6];const w=p;let S;if(e[7]!==w||e[8]!==d){S=[];for(const ge of d){const be=w.get(ge);be&&S.push({id:ge,session:be})}e[7]=w,e[8]=d,e[9]=S}else S=e[9];const N=S;let P;e[10]!==y?(P=ge=>{y(ge.id,Is(ge.session))},e[10]=y,e[11]=P):P=e[11];const C=P,T=Ny;let R;e[12]!==m||e[13]!==g||e[14]!==C||e[15]!==N?(R=ge=>{if(m(ge),g&&g!==ge){const be=N.find(Q=>Q.id===ge);be&&C(be)}},e[12]=m,e[13]=g,e[14]=C,e[15]=N,e[16]=R):R=e[16];const M=R;let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},e[17]=F):F=e[17];let K;e[18]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{delay:200,tolerance:6}},e[18]=K):K=e[18];const D=Zo(fn(ti,F),fn(ei,K));let U;e[19]!==f?(U=ge=>{const{active:be,over:Q}=ge;Q&&be.id!==Q.id&&f(String(be.id),String(Q.id))},e[19]=f,e[20]=U):U=e[20];const A=U,E=c.useRef(null);let W;e[21]===Symbol.for("react.memo_cache_sentinel")?(W={left:!1,right:!1},e[21]=W):W=e[21];const[k,v]=c.useState(W);let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const ge=E.current;if(!ge)return;const be=ge.scrollLeft>2,Q=ge.scrollLeft+ge.clientWidth<ge.scrollWidth-2;v(_=>_.left===be&&_.right===Q?_:{left:be,right:Q})},e[22]=I):I=e[22];const H=I;let $;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>{H();const ge=E.current;if(!ge||!globalThis.ResizeObserver)return;const be=new ResizeObserver(H);return be.observe(ge),()=>be.disconnect()},e[23]=$):$=e[23];let re;e[24]!==N.length?(re=[H,N.length],e[24]=N.length,e[25]=re):re=e[25],c.useEffect($,re);let te;e[26]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{E.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[26]=te):te=e[26];let ee;e[27]!==g?(ee=[g],e[27]=g,e[28]=ee):ee=e[28],c.useEffect(te,ee);const ue=k.left&&k.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":k.left?"linear-gradient(to right, transparent, black 24px)":k.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let de;e[29]!==N?(de=N.map(Ay),e[29]=N,e[30]=de):de=e[30];const Te=de;let we;e[31]!==g||e[32]!==N?(we=!g||!N.some(ge=>ge.id===g),e[31]=g,e[32]=N,e[33]=we):we=e[33];const fe=we;let Ne;e[34]!==a?(Ne=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=Ne):Ne=e[35];let L;e[36]!==ue?(L=ue?{maskImage:ue,WebkitMaskImage:ue}:void 0,e[36]=ue,e[37]=L):L=e[37];let oe;e[38]===Symbol.for("react.memo_cache_sentinel")?(oe=[fy],e[38]=oe):oe=e[38];let ce;e[39]!==o||e[40]!==g||e[41]!==M||e[42]!==C||e[43]!==r||e[44]!==n||e[45]!==l||e[46]!==N?(ce=N.map(ge=>s.jsx(py,{tab:ge,isActive:ge.id===g,suppressControls:ge.id===g&&l,onSelect:C,onClose:T,renderMenu:n,closeOtherTabs:M,onMenuOpenChangeComplete:r,children:ge.id===g?o:null},ge.id)),e[39]=o,e[40]=g,e[41]=M,e[42]=C,e[43]=r,e[44]=n,e[45]=l,e[46]=N,e[47]=ce):ce=e[47];let pe;e[48]!==ce||e[49]!==Te?(pe=s.jsx(Ua,{items:Te,strategy:yx,children:ce}),e[48]=ce,e[49]=Te,e[50]=pe):pe=e[50];let Y;e[51]!==A||e[52]!==D||e[53]!==pe?(Y=s.jsx(si,{sensors:D,collisionDetection:ni,modifiers:oe,onDragEnd:A,children:pe}),e[51]=A,e[52]=D,e[53]=pe,e[54]=Y):Y=e[54];let ve;e[55]!==o||e[56]!==fe?(ve=fe?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[55]=o,e[56]=fe,e[57]=ve):ve=e[57];let Ee;e[58]!==L||e[59]!==Y||e[60]!==ve?(Ee=s.jsxs("div",{ref:E,onScroll:H,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:L,children:[Y,ve]}),e[58]=L,e[59]=Y,e[60]=ve,e[61]=Ee):Ee=e[61];let je;return e[62]!==Ne||e[63]!==Ee?(je=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ne,children:Ee}),e[62]=Ne,e[63]=Ee,e[64]=je):je=e[64],je};function by(t){return t.stopPropagation()}function xy(t){return t.stopPropagation()}function yy(t){return t.tabIds}function wy(t){return t.ensureTab}function vy(t){return t.closeOtherTabs}function Sy(t){return t.reorderTabs}function jy(t){return t.currentSessionId}function ky(t){return t.setCurrentSession}function Cy(t){return t.activeSessions}function Ny(t){jp(t)}function Ay(t){return t.id}function Jl(t){const e=nt.c(20),{sessionId:n,onArchive:r,Item:i}=t,{t:o}=At();let l;e[0]!==n?(l=h=>!!h.entityById.get(n)?.time.archived,e[0]=n,e[1]=l):l=e[1];const a=ps(l),d=ot(Py);let u;e[2]!==n||e[3]!==o||e[4]!==d?(u=async()=>{await d(n)?_e.success(o("sessions.sidebar.session.restore.success")):_e.error(o("sessions.sidebar.session.restore.error"))},e[2]=n,e[3]=o,e[4]=d,e[5]=u):u=e[5];const m=u;let f;e[6]!==a||e[7]!==r||e[8]!==m?(f=a?()=>{m()}:r,e[6]=a,e[7]=r,e[8]=m,e[9]=f):f=e[9];const g=a?"inbox-unarchive":"inbox-archive";let y;e[10]!==g?(y=s.jsx(B,{name:g,className:"mr-1 size-4"}),e[10]=g,e[11]=y):y=e[11];const b=a?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let j;e[12]!==o||e[13]!==b?(j=o(b),e[12]=o,e[13]=b,e[14]=j):j=e[14];let x;return e[15]!==i||e[16]!==f||e[17]!==y||e[18]!==j?(x=s.jsxs(i,{onClick:f,children:[y,j]}),e[15]=i,e[16]=f,e[17]=y,e[18]=j,e[19]=x):x=e[19],x}function Py(t){return t.unarchiveSession}const df=async t=>{const{entry:e,session:n}=t,r=qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(kp(e.action)&&Cp(e.guest,"conversation"))){await Nl(e,Al(e.action.id,i),t.t,r);return}let l=!1;const a=vr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Nl(e,Al(e.action.id,i,d),t.t,r)}};function sa(t){const e=nt.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=At(),{pending:a,disabled:d,hint:u,run:m}=Th(n,r,i),f=a?"loader-4":"ai-generate-2",g=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let y;e[0]!==f||e[1]!==g?(y=s.jsx(B,{name:f,className:g}),e[0]=f,e[1]=g,e[2]=y):y=e[2];let b;e[3]!==l?(b=l("sessions.aiRename.action"),e[3]=l,e[4]=b):b=e[4];let j;e[5]!==o||e[6]!==d||e[7]!==m||e[8]!==y||e[9]!==b?(j=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:m,className:"w-full",children:[y,b]})})}),e[5]=o,e[6]=d,e[7]=m,e[8]=y,e[9]=b,e[10]=j):j=e[10];let x;e[11]!==u?(x=s.jsx(jt,{side:"right",children:u}),e[11]=u,e[12]=x):x=e[12];let h;return e[13]!==j||e[14]!==x?(h=s.jsxs(vt,{children:[j,x]}),e[13]=j,e[14]=x,e[15]=h):h=e[15],h}const na=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class uf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const ii=Jr(()=>({pendingSessionIds:new Set})),ff=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],ii(n)},Zl=(t,e)=>{ii.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},Dy=async(t,e)=>{try{const d=(await Tp(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=gt(t),r=gt(e)??e,i=ot.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>gt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},ec=t=>{for(const e of t){const n=Ap(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class Iy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const Ty=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new Iy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},Ey=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(Pp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await du(o,n,e),ot.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},tc=async(t,e,n)=>{try{await fu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},sc=async(t,e)=>{const n=e?[t,e]:[t];try{await Ia(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},mf=async(t,e)=>{if(ii.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Zl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,ot.getState().getWorktreeMetadata(a.id)]));ec(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){ec(n.slice(a));try{await du(d,t.sourceDirectory,i.directory)}catch(u){throw Np(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&ot.getState().setWorktreeMetadata(d.id,Pl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await Ey(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await sc(t.sourceDirectory,i?.directory),u.length>0)throw Ty(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new uf(d):d}return ot.getState().setWorktreeMetadata(t.root.id,Pl(i.metadata)),await sc(t.sourceDirectory,i.directory),i.directory}finally{Zl(t.root.id,!1)}},Ry=async t=>{const e=gt(t.sourceDirectory)??t.sourceDirectory,n=gt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return mf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},My=async t=>mf(t,async()=>{const e=Ki(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await uu(t.sourceDirectory)?await Dy(t.sourceDirectory,e.path):null,r=await Dp(e,n?{startRef:n}:{});try{await Ip(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return tc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>tc(e,r,i)}}),Oy=t=>{(t.kind==="existing"?Ry({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):My({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>_e.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));_e.error(t.messages.failure,{description:r instanceof uf?t.messages.outcomeUnknown:r.message})})},ra=t=>{ii.getState().pendingSessionIds.has(t.root.id)||Oy(t)},$r="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",By=c.memo(function(e){const n=nt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,g=m===void 0?!1:m;if(!f)return null;const y=a??$r,b=g&&"bg-interactive-selection text-interactive-selection-foreground";let j;n[0]!==y||n[1]!==b?(j=De(y,b),n[0]=y,n[1]=b,n[2]=j):j=n[2];const x=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==x?(h=s.jsx(B,{name:d,className:x}),n[3]=d,n[4]=x,n[5]=h):h=n[5];let p;n[6]!==o||n[7]!==l||n[8]!==g||n[9]!==j||n[10]!==h?(p=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":g,className:j,children:h})}),n[6]=o,n[7]=l,n[8]=g,n[9]=j,n[10]=h,n[11]=p):p=n[11];let w;n[12]!==i?(w=s.jsx(jt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=w):w=n[13];let S;return n[14]!==p||n[15]!==w?(S=s.jsxs(vt,{children:[p,w]}),n[14]=p,n[15]=w,n[16]=S):S=n[16],S}),Fy=c.memo(function(e){const n=nt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:m,remoteUpdateChecking:f,remoteUpdateError:g,onOpenRemoteUpdate:y}=e,{t:b}=At();let j;n[0]!==d||n[1]!==a?(j=K=>{a(K),K&&d()},n[0]=d,n[1]=a,n[2]=j):j=n[2];let x;n[3]!==i||n[4]!==r||n[5]!==b?(x=r?b("header.services.openWithCurrent",{current:i}):b("header.services.open"),n[3]=i,n[4]=r,n[5]=b,n[6]=x):x=n[6];const h=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let p;n[7]!==h?(p=De($r,h),n[7]=h,n[8]=p):p=n[8];let w;n[9]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(B,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=w):w=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let N;n[13]!==x||n[14]!==p||n[15]!==S?(N=s.jsx(St,{asChild:!0,children:s.jsx(vs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":x,className:p,children:[w,S]})})}),n[13]=x,n[14]=p,n[15]=S,n[16]=N):N=n[16];let P;n[17]!==i||n[18]!==u||n[19]!==b?(P=b("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=b,n[20]=P):P=n[20];let C;n[21]!==P?(C=s.jsx(jt,{children:s.jsx("p",{children:P})}),n[21]=P,n[22]=C):C=n[22];let T;n[23]!==N||n[24]!==C?(T=s.jsxs(vt,{children:[N,C]}),n[23]=N,n[24]=C,n[25]=T):T=n[25];let R;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==y||n[30]!==f||n[31]!==g||n[32]!==m||n[33]!==a||n[34]!==b?(R=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:b("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:m?.available?b("header.services.remoteUpdate.available",{version:m.version||""}):f?b("header.services.remoteUpdate.checking"):g||b("header.services.remoteUpdate.upToDate")})]}),m?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:y,children:b("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Ep,{embedded:!0,open:l,onOpenChange:_y,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=y,n[30]=f,n[31]=g,n[32]=m,n[33]=a,n[34]=b,n[35]=R):R=n[35];let M;n[36]!==R?(M=s.jsx(Ss,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:R}),n[36]=R,n[37]=M):M=n[37];let F;return n[38]!==l||n[39]!==j||n[40]!==T||n[41]!==M?(F=s.jsxs(js,{open:l,onOpenChange:j,children:[T,M]}),n[38]=l,n[39]=j,n[40]=T,n[41]=M,n[42]=F):F=n[42],F}),rn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},nc=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Ly=()=>{ys("ui.header.render");const{t}=At(),e=ye(z=>z.isSidebarOpen),n=ye(z=>z.openContextOverview),r=ye(z=>z.closeContextPanel),i=ye(z=>z.shortcutOverrides),o=ye(z=>z.sessionTabsEnabled),l=ot(z=>z.getContextUsage),a=ot(z=>!!z.newSessionDraft?.open),d=ot(z=>z.currentSessionId),u=Rp(d??""),m=Mp(d??""),f=ff(d??""),g=ps(Un(c.useCallback(z=>{if(!d)return null;const Ie=[...z.activeSessions,...z.archivedSessions].find(wt=>wt.id===d);if(!Ie)return null;const tt=Ie;return{title:Ie.title??null,directory:tt.directory??null,created:Ie.time?.created??null,slug:tt.slug??null,parentId:Ie.parentID??null}},[d]))),y=zt(Un(z=>{if(!z.activeProjectId)return null;const Ie=z.projects.find(tt=>tt.id===z.activeProjectId);return Ie?{id:Ie.id,path:Ie.path,label:Ie.label}:null})),b=c.useMemo(()=>{if(!y)return null;const z=y.label?.trim();if(z)return z;const Ie=y.path.split(/[\\/]/).filter(Boolean);return Ie[Ie.length-1]??null},[y]),j=ur(z=>z.loadSettings),{isMobile:x}=Pn(),h=c.useRef(null),[p,w]=c.useState(()=>typeof window>"u"?!1:mn()),S=c.useMemo(()=>Kr(),[]),N=Op(),[P,C]=c.useState(!1),T=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:M}=Qu(),F=c.useMemo(()=>{if(typeof window>"u")return null;const z=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof z=="number"&&Number.isFinite(z)&&z>0)return z;if(typeof navigator>"u")return null;const Ie=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ie)return null;const tt=Number.parseInt(Ie[1],10),wt=Number.parseInt(Ie[2],10);return Number.isNaN(tt)?null:tt===10?wt:tt},[]);lt.useEffect(()=>{typeof window>"u"||w(mn())},[]);const{context:K,output:D}=Bp(d),U=l(K,D),[A,E]=c.useState(null),W=!d||u;lt.useEffect(()=>{if(!d){E(z=>z===null?z:null);return}if(U){E(z=>Fp(z,U)?z:U);return}W&&E(z=>z===null?z:null)},[U,d,W]);const[k,v]=c.useState(!1),[I,H]=c.useState("Local"),[$,re]=c.useState(!0),[te,ee]=c.useState(!1),[ue,de]=c.useState(null),[Te,we]=c.useState(!1),[fe,Ne]=c.useState(null),L=c.useMemo(()=>An(),[]),oe=ye(z=>z.workStatusPanelVisible),ce=ye(z=>z.workStatusPanelEnabled),pe=ye(z=>z.setWorkStatusPanelEnabled),Y=ye(z=>z.workStatusPanelFits),ve=ye(z=>z.workStatusOverlayOpen),Ee=ye(z=>z.setWorkStatusOverlayOpen),ge=ce&&Y||ve,be=c.useCallback(()=>{if(ce&&!Y){Ee(!ve);return}pe(!ce)},[Ee,pe,ve,ce,Y]),Q=!L&&!oe&&!!A,_=c.useCallback(async()=>{if(!(typeof window>"u"||!p))try{if(qo()){H("Local"),re(!0);return}re(!1);const z=await Ld(),Ie=qm(),tt=Ym([Qm(Ie),...z.hosts]);if(tt.id===Xm){H("Local"),re(!0);return}H(_d(tt.label.trim()||"Instance"))}catch{H("Local"),re(!0)}},[p]);lt.useEffect(()=>(_(),vr(()=>{_()})),[_]);const J=c.useCallback(async()=>{if($){de(null),Ne(null);return}we(!0),Ne(null);try{const z=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Ie=await as(`/api/openchamber/update-check?${z.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Ie.ok)throw new Error(`Server responded with ${Ie.status}`);const tt=await Ie.json();de({available:tt.available??!1,version:tt.version,currentVersion:tt.currentVersion??"unknown",body:tt.body,nextSuggestedCheckInSec:typeof tt.nextSuggestedCheckInSec=="number"?tt.nextSuggestedCheckInSec:void 0,packageManager:tt.packageManager,updateCommand:tt.updateCommand})}catch(z){de(null),Ne(z instanceof Error?z.message:t("header.services.remoteUpdate.error"))}finally{we(!1)}},[$,t]);c.useEffect(()=>{de(null),Ne(null),ee(!1)},[$,I]),c.useEffect(()=>{if(!p||$)return;const z=3e3,Ie=3600*1e3;let tt=!1,wt=null;const Pt=Nt=>{wt=window.setTimeout(()=>{if(tt||typeof document<"u"&&document.visibilityState!=="visible"){Pt(Ie);return}J().finally(()=>{tt||Pt(Ie)})},Nt)};return Pt(z),()=>{tt=!0,wt!==null&&window.clearTimeout(wt)}},[J,$,I,p]);const me=c.useCallback(()=>{if(ue?.available){ee(!0);return}J()},[J,ue?.available]);Lp(),c.useEffect(()=>{j()},[j]);const le=d?g??null:null,V=c.useRef(null),[Z,G]=c.useState(0);c.useEffect(()=>{if(!d){V.current&&(V.current=null,G(wt=>wt+1));return}if(le){V.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const z=V.current;if(!z||z.sessionId!==d)return;const Ie=z.expiresAt-Date.now();if(Ie<=0){V.current=null,G(wt=>wt+1);return}const tt=window.setTimeout(()=>{V.current?.sessionId===d&&(V.current=null),G(wt=>wt+1)},Ie);return()=>{window.clearTimeout(tt)}},[d,le]);const ie=(()=>{if(le)return le;if(!d)return null;const z=V.current;return z&&z.sessionId===d&&z.expiresAt>Date.now()?z.session:null})(),Se=ot(z=>d?z.worktreeMetadata.get(d)?.path??"":""),se=ot(z=>d?z.worktreeMetadata.get(d)?.branch?.trim()??null:null),Me=mu(z=>d?z.getAttachment(d):void 0),He=c.useMemo(()=>Me?_p(Me,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Me]),We=c.useMemo(()=>Me?Me.legacy?"legacy":Me.degraded?"degraded":Me.worktreeStatus==="pending"?"pending":Me.worktreeStatus==="missing"?"missing":Me.worktreeStatus==="invalid"?"invalid":Me.attentionReason?"attention":null:null,[Me]),Le=c.useMemo(()=>rn(Se||""),[Se]),Ve=c.useMemo(()=>{const z=typeof ie?.directory=="string"?ie.directory:"";return rn(z||"")},[ie?.directory]),O=Da(d??"",Ve),he=ot(z=>z.newSessionDraft?.open?rn(z.newSessionDraft.bootstrapPendingDirectory??z.newSessionDraft.directoryOverride??""):""),$e=ot(z=>z.newSessionDraft.target),Ue=ot(z=>z.newSessionDraft.selectedProjectId),ct=ot(z=>z.currentSessionDirectory),pt=Zt(z=>z.homeDirectory),it=c.useMemo(()=>Le||Ve||he,[he,Ve,Le]),ft=ye(c.useCallback(z=>{const Ie=rn(it||"");return Ie?nc(z.contextPanelByDirectory[Ie]):null},[it])),yt=ot(z=>{const Ie=rn(Le||Ve||"");if(!Ie)return null;for(const tt of z.availableWorktreesByProject.values()){const Pt=tt.find(Nt=>rn(Nt.path)===Ie)?.branch?.trim();if(Pt)return Pt}return null}),bt=$p(it||null)||se||yt,Dt=a?$e==="chat":zp(Ve||ct,pt),xe=!Dt&&!oe&&!!(b||bt||!a&&We),Ye=c.useMemo(()=>{if(!d)return b??"OpenChamber";const z=ie?.title?.trim();return z&&z.length>0?z:"Untitled Session"},[b,ie?.title,d]),Xe=hu(),qe=ot(z=>z.updateSessionTitle),dt=ot(z=>z.archiveSessions),X=ot(z=>z.deleteSessions),[ae,Ae]=c.useState(!1),[Ge,q]=c.useState(!1),Fe=c.useRef(null),[Ze,Je]=c.useState(""),[et,kt]=c.useState(null),Qe=c.useRef(null),It=c.useCallback(()=>{d&&(Je(ie?.title?.trim()||Ye),Ae(!0))},[ie?.title,d,Ye]),Mt=c.useRef(It);Mt.current=It;const ke=c.useCallback(z=>{z&&(z.focus(),z.select())},[]);c.useEffect(()=>{if(q(!1),kt(null),d&&Fe.current===d){Fe.current=null,Mt.current();return}Ae(!1),Je("")},[d]);const Oe=c.useCallback(async()=>{if(!d)return;const z=Ze.trim();z&&z!==ie?.title?.trim()&&await qe(d,z),Ae(!1)},[ie?.title,d,Ze,qe]);c.useEffect(()=>{if(!ae)return;const z=Ie=>{const tt=Ie.target;(!tt||!Qe.current?.contains(tt))&&Oe()};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[ae,Oe]);const Re=c.useCallback(z=>{z&&Gn(z).then(Ie=>{_e[Ie.ok?"success":"error"](t(Ie.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(t("sessions.sidebar.session.copyId.error")))},[t]),Be=c.useCallback(async()=>{if(!d||!it){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const z=await Xe({sessionID:d,directory:it}).catch(()=>null);if(!z){_e.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(z.length===0){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ie=pu(z,ie?.title??null),tt=gu(ie?.title??null);await bu(Ie,tt)||xu(Ie,tt),_e.success(t("sessions.sidebar.session.export.success"))},[ie?.title,d,Xe,it,t]),Ke=yu(),rt=c.useMemo(()=>wu(Ke),[Ke]),xt=c.useCallback(z=>{d&&df({entry:z,t,session:{id:d,title:ie?.title,directory:Ve??it},loadRecords:async()=>{if(!it)return null;try{return await Xe({sessionID:d,directory:it})}catch{return null}},onLoadFailed:()=>_e.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ie?.title,d,Xe,it,Ve,t]),Pe=c.useCallback(z=>rt.map(Ie=>s.jsxs(z,{onClick:()=>xt(Ie),children:[s.jsx(Qr,{icon:Ie.icon,iconSrc:Ie.iconSrc,className:"mr-1 size-4"}),Ie.action.label]},`${Ie.guest.id}:${Ie.action.id}`)),[rt,xt]),ze=m?.type==="busy"||m?.type==="retry",st=c.useCallback(()=>{if(!d||!Ve||ze||f)return;const z=ps.getState().activeSessions,Ie=z.find(Pt=>Pt.id===d);if(!Ie)return;const tt=[],wt=[d];for(let Pt=0;Pt<wt.length;Pt+=1){const Nt=wt[Pt];for(const Ft of z)Ft.parentID===Nt&&(tt.push(Ft),wt.push(Ft.id))}ra({kind:"quick",root:Ie,descendants:tt,sourceDirectory:Ve,messages:na(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,ze,f,Ve,t]),at=c.useCallback(async()=>{if(!et)return;const z=et.action,Ie=[et.sessionId,...Hd(et.sessionId,[],z==="delete")];if(kt(null),(z==="archive"?await dt(Ie):await X(Ie)).failedIds.length>0){_e.error(t(z==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}_e.success(t(z==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[dt,X,et,t]),Ct=ye(z=>z.openGuestPageId),Ot=Ta(z=>z.guests.find(Ie=>Ie.id===Ct)),Lt=ye(z=>z.isScheduledTasksDialogOpen),Kt=ye(z=>z.isArchivePageOpen),Rt=ye(z=>z.isUsageStatsPageOpen),Vt=ye(z=>z.worktreesPageProjectId),$t=ye(z=>z.runOverviewKey),Xt=Eh($t),Bt=zt(z=>{if(!Vt)return null;const Ie=z.projects.find(tt=>tt.id===Vt);return Ie?.label?.trim()||Ie?.path?.split("/").pop()||null}),ut=c.useMemo(()=>Ot?{title:Ot.pageTitle??Ot.name,subtitle:null}:Lt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Kt?{title:t("sessions.archivePage.title"),subtitle:null}:Rt?{title:t("usageStats.title"),subtitle:null}:Vt?{title:t("sessions.worktreesPage.title",{project:Bt??""}),subtitle:null}:$t?{title:Xt??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Ot,Kt,Xt,$t,Lt,Rt,t,Vt,Bt]),ts=c.useMemo(()=>rn(it||y?.path||""),[y?.path,it]),ss=uy(),fs=Ea(z=>z.planModeEnabled),Jn=ot(z=>z.isSessionPlanAvailable),Ns=fs&&d?Jn(d):!1,xn=c.useRef("");c.useEffect(()=>{if(!fs||!d)return;const z=`${d||"none"}:${Ve||"none"}:${ie?.created||0}:${ie?.slug||"none"}`;xn.current!==z&&(xn.current=z)},[fs,Ns,ie?.slug,ie?.created,d,Ve]);const gs=c.useCallback(()=>{Nn("desktop_open_draft_mini_chat_window",{directory:Dt?"":he,projectId:Dt?null:Ue,apiBaseUrl:hn(),clientToken:Vr()}).catch(z=>{console.warn("[header] failed to open draft mini chat window",z)})},[he,Ue,Dt]),yn=c.useCallback(()=>{if(a){gs();return}d&&Nn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ve||rn(ct||"")||Le,apiBaseUrl:hn(),clientToken:Vr()}).catch(z=>{console.warn("[header] failed to open session mini chat window",z)})},[d,gs,a,ct,Ve,Le]),Gs=c.useCallback(()=>{const z=rn(it||"");if(!z)return;const Ie=ye.getState().contextPanelByDirectory[z];if(nc(Ie)==="context"){r(z);return}n(z)},[r,n,it]),Tn=ft==="context",$s=$r,tn=c.useMemo(()=>p&&T&&!P?"88px":N?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||R)&&!L?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,P,T,N,L,R]);lt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",tn)},[tn]);const bs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Zn=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";lt.useEffect(()=>{if(!p||!T){C(!1);return}let z=!1;const Ie=async()=>{try{const wt=await Nn("desktop_is_window_fullscreen");z||C(wt===!0)}catch{z||C(!1)}},tt=()=>{Ie()};return Ie(),window.addEventListener("openchamber:window-resized",tt),()=>{z=!0,window.removeEventListener("openchamber:window-resized",tt)}},[p,T]);const er=c.useMemo(()=>!p||!T||F===null?"":F>=26?"h-12":F<=15?"h-14":"",[p,T,F]),zs=c.useMemo(()=>{if(!(p&&!R||L)&&!(R&&M==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[p,L,R,M]),Ts=c.useCallback(()=>{if(typeof document>"u")return;const z=h.current?.getBoundingClientRect().height;z&&document.documentElement.style.setProperty("--oc-header-height",`${z}px`)},[]);lt.useEffect(()=>{if(typeof window>"u")return;Ts();const z=h.current;if(!z||typeof ResizeObserver>"u")return()=>{};let Ie=0;const tt=()=>{Ie||(Ie=requestAnimationFrame(()=>{Ie=0,Ts()}))},wt=new ResizeObserver(tt);return wt.observe(z),window.addEventListener("resize",tt),window.addEventListener("orientationchange",tt),()=>{Ie&&cancelAnimationFrame(Ie),wt.disconnect(),window.removeEventListener("resize",tt),window.removeEventListener("orientationchange",tt)}},[Ts]),lt.useEffect(()=>{Ts()},[Ts,x,er]);const tr=c.useCallback(async z=>{const Ie=z.target;Ie.closest(".app-region-no-drag")||Ie.closest("button, a, input, select, textarea")||z.button===0&&p&&await Jm()},[p]),sn=c.useCallback(z=>zn(Xr(z,i)),[i]);Wp({rename_current_session:()=>{if(!d||x)return!1;It()},toggle_services_menu:()=>{if(k){v(!1);return}v(!0),_()}});const sr=s.jsxs(s.Fragment,{children:[ss?s.jsx(cy,{projectRef:ss.projectRef,directory:ss.directory,className:"mr-2"}):null,s.jsx(Rh,{directory:it,className:De($r,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),s.jsx(Fx,{directory:ts,className:"mr-1"}),p?s.jsx(Fy,{isDesktopApp:p,currentInstanceLabel:I,currentInstanceIsLocal:$,isDesktopServicesOpen:k,setIsDesktopServicesOpen:v,refreshCurrentInstanceLabel:_,shortcutLabel:sn,remoteUpdateInfo:ue,remoteUpdateChecking:Te,remoteUpdateError:fe,onOpenRemoteUpdate:me}):null]}),nr=S&&(a||!!d),eo=c.useCallback(({session:z,open:Ie,isActive:tt,select:wt,closeOtherTabs:Pt,components:Nt})=>{const{Item:Ft,Separator:rs}=Nt,Qt=tt&&!L&&!Dt&&ie&&!ie.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Ft,{onClick:()=>{tt||wt(),Fe.current=z.id},children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(sa,{sessionID:z.id,directory:z.directory,open:Ie,Item:Ft}),s.jsxs(Ft,{onClick:()=>Re(z.id),children:[s.jsx(B,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(rs,{}),tt?s.jsxs(Ft,{onClick:()=>{Be()},children:[s.jsx(B,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,tt?Pe(Ft):null,Qt?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Ft,{disabled:!Ve||ze||f,onClick:st,className:"w-full",children:[s.jsx(B,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(rs,{}),s.jsxs(Ft,{onClick:Pt,children:[s.jsx(B,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(rs,{}),s.jsx(Jl,{sessionId:z.id,Item:Ft,onArchive:()=>kt({action:"archive",sessionId:z.id})}),s.jsxs(Ft,{className:"text-destructive focus:text-destructive",onClick:()=>kt({action:"delete",sessionId:z.id}),children:[s.jsx(B,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Re,ie,Be,Dt,ze,f,L,st,Pe,Ve,t]),to=()=>s.jsxs("div",{onMouseDown:tr,className:De("app-region-drag relative flex h-12 select-none items-center",R&&M==="right"?"pr-0":"pr-3",er),style:zs,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:bs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Zn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[ut?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(mt,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>ye.getState().closeMainSurfaces(),children:s.jsx(B,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:ut.title}),ut.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:ut.subtitle}):null]})]}):L||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[O?s.jsx(B,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Hl,{align:"start",children:s.jsx("button",{type:"button",className:$s,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(B,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[ae?s.jsxs("form",{ref:Qe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),Oe()},children:[s.jsx("input",{ref:ke,value:Ze,onChange:z=>Je(z.target.value),onKeyDown:z=>$i(z,()=>Ae(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ae(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ye}),xe?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[b?s.jsx("span",{className:"truncate",children:b}):null,bt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:bt})]}):null,!a&&We?s.jsxs("span",{className:De("inline-flex min-w-0 items-center gap-0.5",We==="attention"||We==="invalid"||We==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(B,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:He})]}):null]}):null]}),s.jsx("div",{className:De("flex h-[18px] shrink-0 items-center justify-center",xe?"self-start":"self-center"),children:d&&!a&&!ae?s.jsxs(js,{open:Ge,onOpenChange:q,onOpenChangeComplete:z=>{!z&&Fe.current&&Fe.current===d&&(Fe.current=null,It())},children:[s.jsx(vs,{asChild:!0,children:s.jsx(mt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(B,{name:"more",className:"size-4"})})}),s.jsxs(Ss,{align:"end",className:"min-w-[190px]",children:[s.jsxs(_t,{onClick:()=>{Fe.current=d},children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(sa,{sessionID:d,directory:Ve,open:Ge,Item:_t}),s.jsxs(_t,{onClick:()=>d&&Re(d),children:[s.jsx(B,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(hs,{}),s.jsxs(_t,{onClick:()=>{Be()},children:[s.jsx(B,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Pe(_t),!L&&!Dt&&ie&&!ie.parentId?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(_t,{disabled:!Ve||ze||f,onClick:st,className:"w-full",children:[s.jsx(B,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ze?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(hs,{}),s.jsx(Jl,{sessionId:d,Item:_t,onArchive:()=>kt({action:"archive",sessionId:d})}),s.jsxs(_t,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&kt({action:"delete",sessionId:d})},children:[s.jsx(B,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Hl,{align:"start",children:s.jsx("button",{type:"button",className:$s,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(B,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(gy,{renderMenu:eo,suppressActiveTabControls:ae,onMenuOpenChangeComplete:z=>{!z&&Fe.current&&Fe.current===d&&(Fe.current=null,It())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ae?s.jsxs("form",{ref:Qe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),Oe()},children:[s.jsx("input",{ref:ke,value:Ze,onChange:z=>Je(z.target.value),onKeyDown:z=>$i(z,()=>Ae(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ae(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Ye})})})]}),ut||L||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Q&&A?s.jsx(sx,{reading:nx(A),contextLimit:A.contextLimit,outputLimit:A.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Gs,pressed:Tn,className:nr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(By,{visible:nr,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:yn,className:De($s,"mr-1"),Icon:"picture-in-picture-2"}),L?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ge,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:be,className:De($r,"mr-1",ge?"text-foreground":"text-muted-foreground/50"),children:s.jsx(B,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t(ce&&!Y?ve?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ce?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),sr,s.jsx(Xu,{visible:R&&M==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:to()}),s.jsx(ks,{open:et!==null,onOpenChange:z=>{z||kt(null)},children:s.jsxs(Cs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Hs,{children:[s.jsx(Ls,{children:et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(_s,{children:et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Ye}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Ye})})]}),s.jsxs(Qn,{children:[s.jsx(mt,{variant:"outline",size:"sm",onClick:()=>kt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(mt,{variant:"destructive",size:"sm",onClick:()=>{at()},children:et?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Gd,{open:te,onOpenChange:ee,info:ue,downloading:!1,downloaded:!1,progress:null,error:fe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function _y(){}const rc=280,oc=264,ic=500,$y=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=At(),l=ye(C=>C.sidebarWidth),a=ye(C=>C.setSidebarWidth),[d,u]=c.useState(!1),m=c.useRef(0),f=c.useRef(l||rc),g=c.useRef(null),y=c.useRef(null),b=c.useRef(null),j=c.useCallback(C=>Math.min(ic,Math.max(oc,C)),[]),x=c.useCallback(C=>{const T=b.current;T&&(T.style.width=`${C}px`,T.style.minWidth=`${C}px`,T.style.maxWidth=`${C}px`,T.style.setProperty("--oc-left-sidebar-width",`${C}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(g.current=null,y.current=null)},[d]),e)return null;const h=Math.min(ic,Math.max(oc,l||rc)),p=t?h:0,w=C=>{if(t){try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}y.current=C.pointerId,u(!0),m.current=C.clientX,f.current=p,g.current=p,x(p),C.preventDefault()}},S=C=>{if(e||!d||y.current!==C.pointerId)return;const T=C.clientX-m.current,R=j(f.current+T);g.current!==R&&(g.current=R,x(R))},N=C=>{if(y.current!==C.pointerId||e)return;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}const T=j(g.current??p);y.current=null,g.current=null,u(!1),a(T)},P=d?g.current??p:p;return s.jsxs("aside",{ref:b,className:De("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${P}px`,minWidth:`${P}px`,maxWidth:`${P}px`,"--oc-left-sidebar-width":`${d?P:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||p===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:De("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:S,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:De("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(bn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(ms,{children:n})})]})]})},zy=()=>{const t=nt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},io="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",Wy=()=>{const t=nt.c(37),{t:e}=At(),n=ye(Ky),r=ye(Vy),i=ye(Uy),o=c.useRef(null),l=zn(Xr("toggle_sidebar",i)),a=Hy,{usesFramelessChrome:d,side:u}=Qu(),m=qy;let f,g;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const A=o.current;if(!A)return;const E=()=>{const k=Math.max(A.getBoundingClientRect().width,A.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(k)}px`)};if(E(),typeof ResizeObserver>"u")return;const W=new ResizeObserver(E);return W.observe(A),()=>{W.disconnect()}},g=[],t[0]=f,t[1]=g):(f=t[0],g=t[1]),c.useEffect(f,g);const y="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=b):b=t[2];const j="flex items-center gap-2";let x;t[3]!==d||t[4]!==u?(x=d&&u==="left"?s.jsx(Xu,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=x):x=t[5];let h;t[6]!==e||t[7]!==d?(h=d?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:De(io,"shrink-0"),children:s.jsx(B,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=h):h=t[8];const p=vt;let w;t[9]!==e?(w=e("header.actions.openSessionsAria"),t[9]=e,t[10]=w):w=t[10];let S,N;t[11]===Symbol.for("react.memo_cache_sentinel")?(S=De(io,"shrink-0"),N=s.jsx(B,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=S,t[12]=N):(S=t[11],N=t[12]);let P;t[13]!==w||t[14]!==n?(P=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":w,className:S,children:N})}),t[13]=w,t[14]=n,t[15]=P):P=t[15];const C=jt,T=e("header.actions.openSessionsWithShortcut",{shortcut:l});let R;t[16]!==T?(R=s.jsx("p",{children:T}),t[16]=T,t[17]=R):R=t[17];let M;t[18]!==C||t[19]!==R?(M=s.jsx(C,{children:R}),t[18]=C,t[19]=R,t[20]=M):M=t[20];let F;t[21]!==p||t[22]!==P||t[23]!==M?(F=s.jsxs(p,{children:[P,M]}),t[21]=p,t[22]=P,t[23]=M,t[24]=F):F=t[24];let K;t[25]!==a||t[26]!==r||t[27]!==e?(K=r?s.jsxs("button",{type:"button",onClick:a,className:De(io,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(B,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:De(io,"-ml-1 shrink-0"),children:s.jsx(B,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=K):K=t[28];let D;t[29]!==F||t[30]!==K||t[31]!==x||t[32]!==h?(D=s.jsxs("div",{ref:o,className:j,children:[x,h,F,K]}),t[29]=F,t[30]=K,t[31]=x,t[32]=h,t[33]=D):D=t[33];let U;return t[34]!==D||t[35]!==b?(U=s.jsx("div",{className:y,style:b,children:D}),t[34]=D,t[35]=b,t[36]=U):U=t[36],U};function Ky(t){return t.toggleSidebar}function Vy(t){return t.isSidebarOpen}function Uy(t){return t.shortcutOverrides}function Hy(){ye.getState().closeMainSurfaces(),ot.getState().openNewSessionDraft()}function Gy(t){console.warn("[titlebar] failed to open app menu",t)}function qy(t){const e=t.currentTarget.getBoundingClientRect();Nn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(Gy)}function hf(t){const e=nt.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(B,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const ac=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Yy(t,e,n){const r=nt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([Kp(t),Vp(t)]).catch(Qy);if(d)return;const f=ac(u),g=ac(m);if(!f||!g||g===f)return;const y=n||"",b=g.split("/").filter(Boolean).pop()||g;o({source:"sdk",path:g,projectDirectory:f,branch:y,label:y||b,name:b,worktreeRoot:g,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Qy(){return["",""]}const lc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Xy=async(t,e)=>{if(t)return t.authActivate(e);const n=await as("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},cc=({className:t})=>{const{t:e}=At(),{github:n}=gn(),r=pn(y=>y.status),i=pn(y=>y.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async y=>{if(!(!y||o)){l(!0);try{i(await Xy(n,y))}catch(b){console.error("Failed to switch GitHub account:",b)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,m=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),g=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(B,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return m.length<=1?s.jsx("div",{className:De(lc,t),title:f,children:g}):s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:De(lc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:g})}),s.jsxs(Ss,{align:"end",className:"w-64",children:[s.jsx(cr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(hs,{}),m.map(y=>{const b=y.user,j=!!y.current,x=y.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(_t,{className:"gap-2",disabled:o,onSelect:()=>{j||a(y.id)},children:[b?.avatarUrl?s.jsx("img",{src:b.avatarUrl,alt:b.login?e("header.github.avatarWithLogin",{login:b.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(B,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:b?.name?.trim()||b?.login||"GitHub"}),b?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:b.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:x})]}):null]}),j?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},y.id)})]})]})};class ai extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const li="/api/walkthrough",pf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),gf=()=>new ai("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Jy=t=>!pf(t)&&(t.ok||t.status===404),Ga=async(t,e)=>{if(Jy(t))throw gf();const n=await t.json().catch(()=>null);throw new ai(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},bf=async t=>{if(!pf(t))throw gf();try{return await t.json()}catch{throw new ai("The server returned a malformed walkthrough response")}};async function Zy(t,e,n={}){const r=await as(li,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?bf(r):Ga(r,"Failed to load walkthrough")}async function e1(t,e,n={}){const r=await as(`${li}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?bf(r):Ga(r,"Failed to generate walkthrough")}async function t1(t,e){const n=await as(`${li}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ga(n,"Failed to cancel walkthrough generation")}async function s1(t,e,n){const r=await as(`${li}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Nr={status:"idle",stage:null,result:null,readiness:null,error:null},n1=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,wn=(t,e)=>`${qt()}\0${t}\0${n1(e)}`,dc=t=>t instanceof ai?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Ms=new Map,Ar=new Map,r1=1e3,o1=Jr()(jx((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=wn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[wn(n,r)],selectModel:(n,r,i)=>{const o=wn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[wn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[wn(n,r)]??Nr,load:async(n,r,i={})=>{if(!n)return;const o=wn(n,r);if(e().entries[o]?.status==="generating")return;Ms.get(o)?.abort();const a=new AbortController;Ms.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Nr,status:"loading",error:null}}}));try{const d=await Zy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Nr,status:"error",stage:null,error:dc(d)}}}))}finally{Ms.get(o)===a&&Ms.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=wn(n,r);Ms.get(o)?.abort();const l=new AbortController;Ms.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Nr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Ar.get(o);d!==void 0&&(clearInterval(d),Ar.delete(o))};a(),Ar.set(o,setInterval(()=>{s1(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const m=u.entries[o];return!m||m.status!=="generating"||m.stage===d?u:{entries:{...u.entries,[o]:{...m,stage:d}}}})}).catch(()=>{})},r1));try{const d=await e1(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Nr,status:"error",stage:null,error:dc(d)}}}))}finally{a(),Ms.get(o)===l&&Ms.delete(o)}},cancel:(n,r)=>{const i=wn(n,r);t1(n,r).catch(()=>{}),Ms.get(i)?.abort(),Ms.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Ms.values())n.abort();Ms.clear();for(const n of Ar.values())clearInterval(n);Ar.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),i1="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",a1=3e4,uc=20,xf=(t,e)=>JSON.stringify([qt(),t,e]),l1=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},fc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ao=new Map,c1=t=>{const e=Object.entries(t);return e.length<=uc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,uc))},mc=Jr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=xf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<a1&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const m=`${l}::${a?"details":"plain"}`,g=ao.get(`${l}::details`)??(a?null:ao.get(m));if(g&&!o?.force)return g;const y=(async()=>{t(b=>({entries:{...b.entries,[l]:{...b.entries[l]??fc(),isLoading:!0,error:null}}}));try{const b=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(j=>({entries:c1({...j.entries,[l]:{result:b,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),b}catch(b){const j=b instanceof Error?b.message:"Failed to load pull request context";return t(x=>({entries:{...x.entries,[l]:{...x.entries[l]??fc(),isLoading:!1,error:j}}})),null}finally{ao.delete(m)}})();return ao.set(m,y),y},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=l1(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),d1=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},u1=35e3,Ci=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ni=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},hc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},f1=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},m1=[2e3,5e3],h1=600,pc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Sn=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},p1=(t,e)=>{const n=Sn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},g1=(t,e)=>`${t}::${e}`,qa=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Ai=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=qa(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},b1=t=>t.startsWith("pr-"),x1=(t,e)=>{const n=qa(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!b1(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Pr=new Map,lo=Yr;function y1(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const w1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=At(),d=ye(ne=>ne.timeFormatPreference),{github:u}=gn(),m=pn(ne=>ne.status),f=pn(ne=>ne.hasChecked),g=ye(ne=>ne.setSettingsDialogOpen),y=ye(ne=>ne.setSettingsPage),b=ot(ne=>ne.currentSessionId),j=ot(ne=>!!ne.newSessionDraft?.open),{isMobile:x,hasTouchInput:h,screenWidth:p}=Pn(),w=ye(ne=>ne.openContextSurface),S=o1(ne=>ne.requestSource),N=!x&&p>=768&&!An(),P=c.useCallback(()=>{y("integrations"),g(!0)},[g,y]),C=c.useMemo(()=>g1(t,e),[t,e]),T=c.useMemo(()=>Pr.get(C)??null,[C]),R=Ps(ne=>ne.ensureEntry),M=Ps(ne=>ne.setParams),F=Ps(ne=>ne.startWatching),K=Ps(ne=>ne.stopWatching),D=Ps(ne=>ne.refresh),U=Ps(ne=>ne.updateStatus),[A,E]=c.useState(()=>T?.title??pc(e)),[W,k]=c.useState(()=>T?.body??""),[v,I]=c.useState(()=>T?.draft??!1),[H,$]=c.useState(()=>T?.additionalContext??""),[re,te]=c.useState(()=>{const ne=typeof T?.targetBaseBranch=="string"?Sn(T.targetBaseBranch):"";return ne||Sn(n)}),[ee,ue]=c.useState("squash"),[de,Te]=c.useState(!1),[we,fe]=c.useState(!1),[Ne,L]=c.useState(!1),[oe,ce]=c.useState(!1),[pe,Y]=c.useState(!1),[ve,Ee]=c.useState(!1),[je,ge]=c.useState(null),[be,Q]=c.useState(""),[_,J]=c.useState(""),[me,le]=c.useState(!1),[V,Z]=c.useState(!1),[G,ie]=c.useState(()=>Ai(i,{selectedRemoteName:T?.selectedRemoteName,trackingBranch:r})),[Se,se]=c.useState(!1),{detectedUpstream:Me,upstreamBranches:He}=y1(t,u);c.useEffect(()=>{se(!1)},[t]);const We=i.some(ne=>ne.name==="upstream"),Ve=!!(t&&e&&n&&(e!==n||(We||Me!==null))),O=c.useMemo(()=>Yo(t,e,G?.name??null),[t,e,G?.name]),he=Ps(ne=>ne.entries[O]),$e=he?.isLoading??!1,Ue=he?.status??null,ct=he?.error??null,pt=he?.isInitialStatusResolved??!1,it=c.useMemo(()=>{const ne=Se?null:G?.name?.trim()||null,z=new Set;for(const wt of o){const Pt=p1(wt,ne);!Pt||Pt==="HEAD"||z.add(Pt)}if(Se)for(const wt of He)wt&&wt!=="HEAD"&&z.add(wt);const Ie=Sn(n);Ie&&Ie!=="HEAD"&&z.add(Ie);const tt=Sn(re);return tt&&tt!=="HEAD"&&z.add(tt),Array.from(z).sort((wt,Pt)=>wt.localeCompare(Pt))},[n,o,G?.name,re,He,Se]);c.useEffect(()=>{if(i.length===0){G&&ie(null);return}(!G||!i.some(ne=>ne.name===G.name))&&ie(Ai(i,{selectedRemoteName:T?.selectedRemoteName,trackingBranch:r}))},[T?.selectedRemoteName,i,G,r]),c.useEffect(()=>{const ne=Sn(n);if(!re&&ne){te(ne);return}if(it.length!==0&&!it.includes(re)){const z=it.includes(ne)?ne:it[0];z&&te(z)}},[it,n,re]);const[ft,yt]=c.useState(()=>T?.activeSegment??"overview"),[ht,bt]=c.useState(new Set),[Dt,xe]=c.useState(new Set),Ye=c.useRef(new Set),Xe=c.useRef(null),qe=c.useRef(!1),dt=c.useRef(new Set),X=c.useRef([]);c.useEffect(()=>{Me&&!We&&se(!0)},[Me,We]),c.useEffect(()=>{Se&&Me?.defaultBranch&&te(Me.defaultBranch)},[Se,Me?.defaultBranch]);const ae=Ue?.pr??null,Ae=ae?.state==="merged"||ae?.state==="closed",Ge=Ae?null:ae,q=Ge?xf(t,Ge.number):null,Fe=mc(ne=>q?ne.entries[q]:void 0),Ze=mc(ne=>ne.ensure),Je=Fe?.result??null,et=Fe?.isLoading??!1,kt=c.useCallback(ne=>{yt(ne);const z=Pr.get(C);z&&Pr.set(C,{...z,activeSegment:ne})},[C]);c.useEffect(()=>{!Ge||!u?.prContext||ft==="overview"||Ze(u,t,Ge.number,{includeCheckDetails:ft==="checks",sourceRepo:Ue?.repo??null})},[ft,t,Ze,u,Ge,Ue?.repo]);const Qe=Ue?.checks??null,It=(Qe?.pending??0)>0,Mt=Je?.checkRuns??null,ke=Je?.fetchedAt;c.useEffect(()=>{if(!Mt||Mt.length===0)return;const ne=d1(Mt);U(O,z=>{if(!z?.pr||typeof ke=="number"&&typeof z.fetchedAt=="number"&&ke<z.fetchedAt)return z;const Ie=z.checks;return Ie&&Ie.state===ne.state&&Ie.total===ne.total&&Ie.success===ne.success&&Ie.failure===ne.failure&&Ie.pending===ne.pending&&Ie.inProgress===ne.inProgress&&Ie.queued===ne.queued&&Ie.startedAt===ne.startedAt?z:{...z,checks:ne,...typeof ke=="number"?{fetchedAt:ke}:{}}})},[Mt,ke,O,U]),c.useEffect(()=>{if(ft!=="checks"||!It||!ae||!u?.prContext)return;const ne=window.setInterval(()=>{Ze(u,t,ae.number,{includeCheckDetails:!0,sourceRepo:Ue?.repo??null,force:!0})},u1);return()=>window.clearInterval(ne)},[ft,It,t,Ze,u,ae,Ue?.repo]);const[Oe,Re]=c.useState(()=>Date.now());c.useEffect(()=>{if(!It)return;Re(Date.now());const ne=window.setInterval(()=>Re(Date.now()),3e4);return()=>window.clearInterval(ne)},[It]);const Be=ae?`${t}#${ae.number}`:null,Ke=!!(Be&&je===Be);c.useEffect(()=>{if(!u?.prContext||!ae||typeof ae.body=="string"&&ae.body.length>0)return;const ne=`${t}#${ae.number}`;if(Ye.current.has(ne))return;Ye.current.add(ne),ge(ne);let z=!1;return Ze(u,t,ae.number,{sourceRepo:Ue?.repo??null}).then(Ie=>{if(z)return;const tt=Ie?.pr;tt&&U(O,wt=>!wt?.pr||wt.pr.number!==ae.number?wt:{...wt,pr:{...wt.pr,body:tt.body||""}})}).catch(()=>{}).finally(()=>{z||ge(Ie=>Ie===ne?null:Ie)}),()=>{z=!0}},[t,Ze,u,ae,O,Ue?.repo,U]),c.useEffect(()=>{if(!ae){Ee(!1),Q(""),J(""),Xe.current=null;return}const ne=Xe.current!==null&&Xe.current!==ae.number;ne&&Ee(!1),(!ve||ne)&&(Q(ae.title||""),J(ae.body||"")),Xe.current=ae.number},[ve,ae]);const rt=c.useCallback(ne=>{if(!ne)return"";const z=Date.parse(ne);return Number.isFinite(z)?vu(z,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ne},[d]),xt=c.useMemo(()=>{const ne=m?.user?.login;return typeof ne=="string"?ne.trim():""},[m]),Pe=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),ze=c.useCallback(ne=>{const z=xt.toLowerCase(),Ie=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ne.replace(Ie,(tt,wt,Pt)=>{const Nt=`@${Pt}`,Ft=Pt.toLowerCase();return`${wt}[${Nt}](https://github.com/${Ft}${z&&Ft===z?"?oc-self-mention=1":""})`})},[xt]),st=c.useMemo(()=>{const ne=(Je?.issueComments??[]).map(tt=>({id:`issue-${tt.id}`,body:tt.body||"",authorName:tt.author?.name||tt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:tt.author?.login||null,avatarUrl:tt.author?.avatarUrl||null,createdAt:tt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),z=(Je?.reviewComments??[]).map(tt=>({id:`review-${tt.id}`,body:tt.body||"",authorName:tt.author?.name||tt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:tt.author?.login||null,avatarUrl:tt.author?.avatarUrl||null,createdAt:tt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:tt.path||null,line:tt.line??null})),Ie=[...ne,...z];return Ie.sort((tt,wt)=>{const Pt=tt.createdAt?Date.parse(tt.createdAt):0,Nt=wt.createdAt?Date.parse(wt.createdAt):0,Ft=Number.isFinite(Pt)?Pt:0,rs=Number.isFinite(Nt)?Nt:0;return Ft-rs}),Ie},[Je,a]),at=c.useCallback(()=>{const ne=b??(j?"draft":null);return ne?{directory:t,sessionKey:ne}:(_e.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[b,t,j,a]),Ct=c.useCallback((ne,z)=>{const Ie=z.authorLogin?`@${z.authorLogin}`:z.authorName,tt=z.path?` · ${z.path}${z.line?`:${z.line}`:""}`:"";Vi.getState().addDraft(ne,{source:"pr-comment",fileLabel:`PR #${ae?.number??""} ${Ie}${tt}`,startLine:z.line??0,endLine:z.line??0,code:z.body,language:"markdown",text:""})},[ae?.number]),Ot=c.useCallback((ne,z)=>{const Ie=ne.status||"unknown",tt=ne.conclusion??void 0,wt=tt?`${Ie} / ${tt}`:Ie,Pt=ne.app?.name||ne.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:z?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[z?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ne.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Pt?`${Pt} · ${wt}`:wt})]}),ne.detailsUrl?s.jsx(mt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ne.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(B,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ne.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ne.output.title}):null,ne.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ne.output.summary}):null,ne.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:ne.output.text}):null,Array.isArray(ne.annotations)&&ne.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ne.annotations.length>20?` (showing 20/${ne.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ne.annotations.slice(0,20).map((Nt,Ft)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Nt.title||Nt.level||"Issue",Nt.path?` · ${Nt.path}`:"",typeof Nt.startLine=="number"?`:${Nt.startLine}`:"",typeof Nt.endLine=="number"&&Nt.endLine!==Nt.startLine?`-${Nt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Nt.message}),Nt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Nt.rawDetails}):null]},`${Nt.path||"file"}:${Nt.startLine||Ft}:${Ft}`))})]}):null,ne.job?.steps&&ne.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:ne.job.steps.map((Nt,Ft)=>{const rs=(Nt.conclusion||"").toLowerCase(),Qt=rs&&!["success","neutral","skipped"].includes(rs),qs=`${ne.id??"run"}:${ne.job?.jobId??"job"}:${Nt.number??Ft}:${Nt.name}`,nn=ht.has(qs);return Qt?s.jsxs(Dl,{open:nn,children:[s.jsxs("button",{type:"button",onClick:()=>{bt(di=>{const Ys=new Set(di);return Ys.has(qs)?Ys.delete(qs):Ys.add(qs),Ys})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Qt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[nn?s.jsx(B,{name:"arrow-down-s",className:"size-4"}):s.jsx(B,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Nt.name}),Nt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Nt.conclusion}):null]}),s.jsx(Il,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof Nt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Nt.number]}):null,Nt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Nt.status]}):null,Nt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Nt.conclusion]}):null,Nt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",rt(Nt.startedAt)]}):null,Nt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",rt(Nt.completedAt)]}):null]})})]},qs):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Nt.name}),Nt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Nt.conclusion}):null]},qs)})})]}):null]})},[ht,rt,a]),[Lt,Kt]=c.useState(!1),[Rt,Vt]=c.useState(!1),$t=c.useCallback(async()=>{if(!u?.prContext){_e.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!ae)return;const ne=at();if(ne){Kt(!0);try{const z=await Ze(u,t,ae.number,{includeCheckDetails:!0,sourceRepo:Ue?.repo??null});if(!z){_e.error(a("gitView.pr.toast.loadChecksFailed"));return}const tt=(z.checkRuns??[]).filter(Pt=>Ni(Pt.conclusion));if(tt.length===0){_e.message(a("gitView.pr.toast.noFailedChecks"));return}const wt=Vi.getState();for(const Pt of tt){const Nt=(Pt.annotations??[]).map(Qt=>[[Qt.level,Qt.title].filter(Boolean).join(" "),Qt.path?`${Qt.path}${typeof Qt.startLine=="number"?`:${Qt.startLine}`:""}`:null,Qt.message,Qt.rawDetails].filter(Boolean).join(`
3
3
  `)),Ft=(Pt.job?.steps??[]).filter(Qt=>Ni(Qt.conclusion)).map(Qt=>`step ${Qt.number??"?"}: ${Qt.name} → ${Qt.conclusion}`),rs=[`check: ${Pt.job?.workflowName?`${Pt.job.workflowName} / ${Pt.name}`:Pt.name}`,`status: ${Pt.status??"unknown"} / ${Pt.conclusion??"unknown"}`,Pt.detailsUrl?`url: ${Pt.detailsUrl}`:null,Pt.output?.title?`title: ${Pt.output.title}`:null,Pt.output?.summary?`summary:
4
4
  ${Pt.output.summary}`:null,Ft.length>0?`failed steps:
5
5
  ${Ft.join(`
@@ -875,12 +875,12 @@ ${t}
875
875
  styles: styles
876
876
  };
877
877
  `),Av=t=>{const e=nt.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=At();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(g,y)=>s.jsxs("div",{role:"option","aria-selected":y===r,className:De("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",y===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),i(g.url)},onPointerEnter:()=>l(y),children:[s.jsx(B,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:g.title||Ja(g.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:g.url})]}),s.jsx("button",{type:"button",className:De("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),o(g.url)},children:s.jsx(B,{name:"close",className:"size-3","aria-hidden":"true"})})]},g.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let m;return e[15]!==d||e[16]!==u?(m=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=m):m=e[17],m},Bs=t=>{const e=nt.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=De("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let m;e[2]!==n?(m=s.jsx(B,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=m):m=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==m?(f=s.jsx(St,{asChild:!0,children:s.jsx(mt,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:m})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=m,e[11]=f):f=e[11];let g;e[12]!==r?(g=s.jsx(jt,{sideOffset:6,children:r}),e[12]=r,e[13]=g):g=e[13];let y;return e[14]!==f||e[15]!==g?(y=s.jsxs(vt,{children:[f,g]}),e[14]=f,e[15]=g,e[16]=y):y=e[16],y},Ff=t=>{const e=nt.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:m,canGoBack:f,canGoForward:g,isLoading:y,onAnnotate:b,onOpenDevTools:j,isAnnotating:x,onHardReload:h,onZoomIn:p,onZoomOut:w,onZoomReset:S,zoomPercent:N,onClearCookies:P,onClearCache:C,onToggleDeviceBar:T,isDeviceBarOpen:R}=t;let M;e[0]!==r?(M=r===void 0?[]:r,e[0]=r,e[1]=M):M=e[1];const F=M,K=N===void 0?100:N,{t:D}=At(),[U,A]=c.useState(!1),[E,W]=c.useState(-1);let k;e[2]!==U||e[3]!==F?(k=U?F:[],e[2]=U,e[3]=F,e[4]=k):k=e[4];const v=k;let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{W(-1)},e[5]=I):I=e[5];let H;e[6]!==n||e[7]!==U?(H=[n,U],e[6]=n,e[7]=U,e[8]=H):H=e[8],c.useEffect(I,H);let $;e[9]!==l?($=We=>{A(!1),W(-1),l(We)},e[9]=l,e[10]=$):$=e[10];const re=$;let te;e[11]!==E||e[12]!==re||e[13]!==v?(te=We=>{if(v.length!==0){if(We.key==="ArrowDown"||We.key==="ArrowUp"){We.preventDefault();const Le=We.key==="ArrowDown"?1:-1,Ve=v.length;W(O=>{const he=O+Le;return he<-1?Ve-1:he>=Ve?-1:he});return}if(We.key==="Escape"&&E>=0){We.preventDefault(),W(-1);return}if(We.key==="Enter"&&E>=0){We.preventDefault();const Le=v[E];Le&&re(Le.url)}}},e[11]=E,e[12]=re,e[13]=v,e[14]=te):te=e[14];const ee=te;let ue;e[15]!==D?(ue=D("contextPanel.browser.back"),e[15]=D,e[16]=ue):ue=e[16];const de=!f;let Te;e[17]!==a||e[18]!==de||e[19]!==ue?(Te=s.jsx(Bs,{icon:"arrow-left",label:ue,onClick:a,disabled:de}),e[17]=a,e[18]=de,e[19]=ue,e[20]=Te):Te=e[20];let we;e[21]!==D?(we=D("contextPanel.browser.forward"),e[21]=D,e[22]=we):we=e[22];const fe=!g;let Ne;e[23]!==d||e[24]!==we||e[25]!==fe?(Ne=s.jsx(Bs,{icon:"arrow-right",label:we,onClick:d,disabled:fe}),e[23]=d,e[24]=we,e[25]=fe,e[26]=Ne):Ne=e[26];let L;e[27]!==y||e[28]!==D?(L=D(y?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=y,e[28]=D,e[29]=L):L=e[29];let oe;e[30]!==u||e[31]!==L?(oe=s.jsx(Bs,{icon:"refresh",label:L,onClick:u}),e[30]=u,e[31]=L,e[32]=oe):oe=e[32];let ce;e[33]!==h||e[34]!==D?(ce=h?s.jsx(Bs,{icon:"restart",label:D("contextPanel.browser.hardReload"),onClick:h}):null,e[33]=h,e[34]=D,e[35]=ce):ce=e[35];let pe;e[36]!==n||e[37]!==re?(pe=We=>{We.preventDefault(),re(n)},e[36]=n,e[37]=re,e[38]=pe):pe=e[38];let Y;e[39]!==o?(Y=We=>o(We.target.value),e[39]=o,e[40]=Y):Y=e[40];let ve,Ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(ve=()=>A(!0),Ee=()=>A(!1),e[41]=ve,e[42]=Ee):(ve=e[41],Ee=e[42]);const je=v.length>0;let ge;e[43]===Symbol.for("react.memo_cache_sentinel")?(ge=De("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=ge):ge=e[43];let be;e[44]!==D?(be=D("contextPanel.browser.addressAria"),e[44]=D,e[45]=be):be=e[45];let Q;e[46]!==n||e[47]!==ee||e[48]!==Y||e[49]!==je||e[50]!==be?(Q=s.jsx("input",{value:n,onChange:Y,onFocus:ve,onBlur:Ee,onKeyDown:ee,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":je,"aria-controls":"openchamber-browser-address-suggestions",className:ge,"aria-label":be}),e[46]=n,e[47]=ee,e[48]=Y,e[49]=je,e[50]=be,e[51]=Q):Q=e[51];let _;e[52]!==i?(_=We=>i?.(We),e[52]=i,e[53]=_):_=e[53];let J;e[54]!==E||e[55]!==re||e[56]!==_||e[57]!==v?(J=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Av,{entries:v,activeIndex:E,onSelect:re,onForget:_,onHighlight:W})}),e[54]=E,e[55]=re,e[56]=_,e[57]=v,e[58]=J):J=e[58];let me;e[59]!==pe||e[60]!==Q||e[61]!==J?(me=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:pe,children:[Q,J]}),e[59]=pe,e[60]=Q,e[61]=J,e[62]=me):me=e[62];let le;e[63]!==p||e[64]!==w||e[65]!==S||e[66]!==D||e[67]!==K?(le=w&&p?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(Bs,{icon:"subtract",label:D("contextPanel.browser.zoomOut"),onClick:w}),K!==100&&S?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(mt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:S,"aria-label":D("contextPanel.browser.zoomReset"),children:[K,"%"]})}),s.jsx(jt,{sideOffset:6,children:D("contextPanel.browser.zoomReset")})]}):null,s.jsx(Bs,{icon:"add",label:D("contextPanel.browser.zoomIn"),onClick:p})]}):null,e[63]=p,e[64]=w,e[65]=S,e[66]=D,e[67]=K,e[68]=le):le=e[68];let V;e[69]!==P||e[70]!==D?(V=P?s.jsx(Bs,{icon:"delete-bin",label:D("contextPanel.browser.clearCookies"),onClick:P}):null,e[69]=P,e[70]=D,e[71]=V):V=e[71];let Z;e[72]!==C||e[73]!==D?(Z=C?s.jsx(Bs,{icon:"database-2",label:D("contextPanel.browser.clearCache"),onClick:C}):null,e[72]=C,e[73]=D,e[74]=Z):Z=e[74];let G;e[75]!==R||e[76]!==T||e[77]!==D?(G=T?s.jsx(Bs,{icon:"smartphone",label:D("contextPanel.browser.deviceToolbar"),onClick:T,pressed:R}):null,e[75]=R,e[76]=T,e[77]=D,e[78]=G):G=e[78];let ie;e[79]!==x||e[80]!==b||e[81]!==D?(ie=b?s.jsx(Bs,{icon:"markup",label:D("contextPanel.browser.annotate.toggle"),onClick:b,pressed:x}):null,e[79]=x,e[80]=b,e[81]=D,e[82]=ie):ie=e[82];let Se;e[83]!==j||e[84]!==D?(Se=j?s.jsx(Bs,{icon:"terminal-box",label:D("contextPanel.browser.devTools"),onClick:j}):null,e[83]=j,e[84]=D,e[85]=Se):Se=e[85];let se;e[86]!==D?(se=D("contextPanel.browser.openExternal"),e[86]=D,e[87]=se):se=e[87];let Me;e[88]!==m||e[89]!==se?(Me=s.jsx(Bs,{icon:"external-link",label:se,onClick:m}),e[88]=m,e[89]=se,e[90]=Me):Me=e[90];let He;return e[91]!==Te||e[92]!==Ne||e[93]!==oe||e[94]!==ce||e[95]!==me||e[96]!==le||e[97]!==V||e[98]!==Z||e[99]!==G||e[100]!==ie||e[101]!==Se||e[102]!==Me?(He=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Te,Ne,oe,ce,me,le,V,Z,G,ie,Se,Me]}),e[91]=Te,e[92]=Ne,e[93]=oe,e[94]=ce,e[95]=me,e[96]=le,e[97]=V,e[98]=Z,e[99]=G,e[100]=ie,e[101]=Se,e[102]=Me,e[103]=He):He=e[103],He},$o={kind:"fill"},Pc=240,Pv=3840,Lf=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],Dc=t=>Number.isFinite(t)?Math.round(Math.min(Pv,Math.max(Pc,t))):Pc,zo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},_f=t=>{const e=Lf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Dv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},Iv=(t,e)=>{const n=zo(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},Tv=["mobile","tablet","desktop","fill"],Ev={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Ic=t=>typeof t=="string"&&Tv.includes(t),ma=t=>t==="fill"?$o:_f(Ev[t])??$o,mo=t=>{const e=zo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=ma(n),i=zo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Rv=t=>{const e=nt.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=At();let d;e[0]!==n?(d=zo(n),e[0]=n,e[1]=d):d=e[1];const u=d,m=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(de,Te)=>{const we=Number.parseInt(Te,10);if(!Number.isFinite(we))return;const fe=u??{width:1280,height:800};r({kind:"custom",width:Dc(de==="width"?we:fe.width),height:Dc(de==="height"?we:fe.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const g=f;let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=De("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=y):y=e[5];const b=y;let j;e[6]!==r?(j=de=>{const Te=_f(de.target.value);r(Te??$o)},e[6]=r,e[7]=j):j=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=De("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=h):h=e[10];let p;e[11]!==a?(p=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=p):p=e[12];let w;e[13]!==p?(w=s.jsx("option",{value:"",children:p}),e[13]=p,e[14]=w):w=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=Lf.map(Mv),e[15]=S):S=e[15];let N;e[16]!==m||e[17]!==j||e[18]!==x||e[19]!==w?(N=s.jsxs("select",{value:m,onChange:j,"aria-label":x,className:h,children:[w,S]}),e[16]=m,e[17]=j,e[18]=x,e[19]=w,e[20]=N):N=e[20];const P=u?String(u.width):"";let C;e[21]!==g?(C=de=>g("width",de.target.value),e[21]=g,e[22]=C):C=e[22];let T;e[23]!==a?(T=a("contextPanel.browser.device.width"),e[23]=a,e[24]=T):T=e[24];let R;e[25]!==P||e[26]!==C||e[27]!==T?(R=s.jsx("input",{value:P,onChange:C,placeholder:"—",inputMode:"numeric","aria-label":T,className:b}),e[25]=P,e[26]=C,e[27]=T,e[28]=R):R=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=M):M=e[29];const F=u?String(u.height):"";let K;e[30]!==g?(K=de=>g("height",de.target.value),e[30]=g,e[31]=K):K=e[31];let D;e[32]!==a?(D=a("contextPanel.browser.device.height"),e[32]=a,e[33]=D):D=e[33];let U;e[34]!==F||e[35]!==K||e[36]!==D?(U=s.jsx("input",{value:F,onChange:K,placeholder:"—",inputMode:"numeric","aria-label":D,className:b}),e[34]=F,e[35]=K,e[36]=D,e[37]=U):U=e[37];let A;e[38]!==r||e[39]!==n?(A=()=>r(Dv(n)),e[38]=r,e[39]=n,e[40]=A):A=e[40];const E=!u;let W;e[41]!==a?(W=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=W):W=e[42];let k;e[43]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(B,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=k):k=e[43];let v;e[44]!==A||e[45]!==E||e[46]!==W?(v=s.jsx(St,{asChild:!0,children:s.jsx(mt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:A,disabled:E,"aria-label":W,children:k})}),e[44]=A,e[45]=E,e[46]=W,e[47]=v):v=e[47];let I;e[48]!==a?(I=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=I):I=e[49];let H;e[50]!==I?(H=s.jsx(jt,{sideOffset:6,children:I}),e[50]=I,e[51]=H):H=e[51];let $;e[52]!==v||e[53]!==H?($=s.jsxs(vt,{children:[v,H]}),e[52]=v,e[53]=H,e[54]=$):$=e[54];let re;e[55]!==l||e[56]!==u?(re=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=re):re=e[57];let te;e[58]===Symbol.for("react.memo_cache_sentinel")?(te=["system","light","dark"],e[58]=te):te=e[58];let ee;e[59]!==i||e[60]!==o||e[61]!==a?(ee=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:te.map(de=>s.jsx(mt,{type:"button",variant:i===de?"secondary":"ghost",size:"xs",className:De("shrink-0 rounded-full px-2.5 typography-micro",i===de?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(de),"aria-pressed":i===de,children:a(de==="system"?"contextPanel.browser.device.schemeSystem":de==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},de))}),e[59]=i,e[60]=o,e[61]=a,e[62]=ee):ee=e[62];let ue;return e[63]!==N||e[64]!==R||e[65]!==U||e[66]!==$||e[67]!==re||e[68]!==ee?(ue=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,R,M,U,$,re,ee]}),e[63]=N,e[64]=R,e[65]=U,e[66]=$,e[67]=re,e[68]=ee,e[69]=ue):ue=e[69],ue};function Mv(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Ov=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Bv=2e3,Fv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=hn();if(!t)return!1;try{return!Sr(new URL(t,window.location.href).toString())}catch{return!1}},$f=t=>{const e=nt.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=At();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=Yx(i),[m]=c.useState(Fv);let f,g;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let R=!0,M=null;const F=new AbortController,K=()=>{Iw(F.signal).then(D=>{R&&(d(D),M=setTimeout(K,Bv))})};return K(),()=>{R=!1,M&&clearTimeout(M),F.abort()}},g=[],e[1]=f,e[2]=g):(f=e[1],g=e[2]),c.useEffect(f,g);const y=a.kind==="ready"?a.servers:null;let b;e[3]!==u||e[4]!==y?(b=Rw({announced:u,discovered:y}),e[3]=u,e[4]=y,e[5]=b):b=e[5];const j=b;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Au,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=x):x=e[6];let h;e[7]!==o?(h=o("contextPanel.browser.empty"),e[7]=o,e[8]=h):h=e[8];let p;e[9]!==h?(p=s.jsx("span",{className:"typography-ui-header text-foreground",children:h}),e[9]=h,e[10]=p):p=e[10];let w;e[11]!==o?(w=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=w):w=e[12];let S;e[13]!==w?(S=s.jsx("span",{className:"typography-micro text-muted-foreground",children:w}),e[13]=w,e[14]=S):S=e[14];let N;e[15]!==S||e[16]!==p?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[p,S]}),e[15]=S,e[16]=p,e[17]=N):N=e[17];let P;e[18]!==u||e[19]!==j||e[20]!==i||e[21]!==n||e[22]!==m||e[23]!==o?(P=j.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),m?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:j.map(R=>s.jsxs(mt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{Hx(i),n(R.url)},children:[s.jsx(B,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Ja(R.url)||R.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Ov(R.url)})]},R.port))})]}):null,e[18]=u,e[19]=j,e[20]=i,e[21]=n,e[22]=m,e[23]=o,e[24]=P):P=e[24];let C;e[25]!==j.length||e[26]!==a.kind||e[27]!==o?(C=j.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=j.length,e[26]=a.kind,e[27]=o,e[28]=C):C=e[28];let T;return e[29]!==N||e[30]!==P||e[31]!==C?(T=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[x,N,P,C]}),e[29]=N,e[30]=P,e[31]=C,e[32]=T):T=e[32],T},ws=t=>Math.round(t),Lv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${ws(l.x)}, y=${ws(l.y)}, width=${ws(l.width)}, height=${ws(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},_v=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${ws(n.x)}, y=${ws(n.y)}, width=${ws(n.width)}, height=${ws(n.height)}`},$v=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${ws(n.x)}, y=${ws(n.y)}, width=${ws(n.width)}, height=${ws(n.height)}`},zv=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${ws(t.viewport.width)}x${ws(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...Lv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(_v(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push($v(l,a)))),o.filter(l=>typeof l=="string").join(`
878
- `)},Wv=t=>{const e=nt.c(7),{t:n}=At(),r=ot(Vv),i=ot(Uv),o=Vi(Hv),l=lg(Gv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){_e.error(n("contextPanel.browser.annotate.noSession"));return}let m=!1;if(d.screenshot)try{await l(d.screenshot),m=!0}catch{m=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:zv({payload:d.payload,screenshotAttached:m,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),_e.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Kv=()=>{const t=nt.c(16),{t:e}=At();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Vv(t){return t.currentSessionId}function Uv(t){return t.newSessionDraft?.open}function Hv(t){return t.addDraft}function Gv(t){return t.addAttachedFile}const qv=3e4,Yv=3,Qv=250,Xv={attempts:0,windowStartedAt:null},Jv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=qv,r=n?0:t.attempts;return r>=Yv?null:{delayMs:Qv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Zv=-3,ho=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",fr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},eS=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Bw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,m]=c.useState(!1),[f,g]=c.useState(!1),y=c.useRef(n);y.current=n;const b=c.useRef(Xv);return c.useEffect(()=>{if(!t)return;const j=()=>{try{const M=t.getURL();return ho(M)?M:""}catch{return""}},x=()=>{try{m(t.canGoBack()),g(t.canGoForward())}catch{}},h=M=>{ho(M)&&(l(M),y.current(M))},p=()=>{const M=j();i({kind:"loading",url:M})},w=()=>{const M=j();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),h(M),x(),i(K=>K.kind==="failed"?K:{kind:"ready",url:M,title:F})},S=M=>{const F=fr(M);ho(F.url)&&(h(F.url),x())},N=M=>{const F=fr(M),K=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",D=j();K&&D&&kf.getState().resolve(D,K)},P=M=>{const F=fr(M);typeof F.title=="string"&&d(F.title)},C=M=>{const F=fr(M);if(F.isMainFrame===!1)return;const K=typeof F.errorCode=="number"?F.errorCode:0;K!==Zv&&i({kind:"failed",url:ho(F.validatedURL)?F.validatedURL:j(),code:K,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let T=null;const R=()=>{const M=j(),F=Jv(b.current,Date.now());if(!F){i({kind:"failed",url:M,code:0,description:"",crashed:!0});return}b.current=F.state,i({kind:"loading",url:M}),T=setTimeout(()=>{T=null;try{t.reload()}catch{i({kind:"failed",url:M,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",w),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",P),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",C),t.addEventListener("render-process-gone",R),t.addEventListener("crashed",R);try{!t.isLoading()&&j()&&w()}catch{}return()=>{T!==null&&clearTimeout(T),t.removeEventListener("render-process-gone",R),t.removeEventListener("crashed",R),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",w),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",P),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",C)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},tS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,sS=4e4,po=.5,nS=-3,rS=4,oS="persist:openchamber-browser",Tc=20,iS=600,aS=2e4,lS=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=At(),{currentTheme:i}=qn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(V=>{o.current=V,a(V)},[]),u=ye(V=>V.setContextPanelTabTargetPath),m=c.useRef(gr(t)),f=m.current!==Fs?m.current:"",[g,y]=c.useState(f?null:Fs),[b,j]=c.useState(f),[x,h]=c.useState(!1),[p,w]=c.useState(!1),[S,N]=c.useState(0),P=c.useRef(0),[C,T]=c.useState(!1),[R,M]=c.useState($o),F=c.useRef(R);F.current=R;const K=c.useRef([]),[D,U]=c.useState("system"),[A,E]=c.useState({width:0,height:0}),W=c.useRef(null),k=c.useRef(null),v=c.useRef(!1),I=c.useRef(Date.now()),H=c.useCallback(V=>{!V||V===Fs||!e||!n||u(e,n,V)},[e,n,u]),$=eS(l,{initialUrl:f,onUrlChange:c.useCallback(V=>{const Z=ar(V);j(Z),H(Z)},[H])}),[re,te]=c.useState(null),ee=Wv(e),ue=Kv(),de=$.status.kind==="loading",Te=br(Rf(e)),we=br(V=>V.recordVisit),fe=br(V=>V.forget);c.useEffect(()=>{$.status.kind==="ready"&&we(e,{url:ar($.status.url),title:$.status.title})},[e,$.status,we]);const Ne=c.useMemo(()=>Ef(Te,b),[Te,b]),L=c.useCallback(V=>{const Z=gr(V);Z!==Fs&&(j(Z),te(null),Cc(Z).then(G=>{const ie=o.current;if(!ie){y(G);return}try{ie.loadURL(G)}catch{y(G)}}).catch(G=>{G instanceof Wr&&te(Z)}))},[]);c.useEffect(()=>{if(!f)return;let V=!0;return Cc(f).then(Z=>{V&&y(Z)}).catch(Z=>{if(V){if(Z instanceof Wr){te(f),y(Fs);return}y(f)}}),()=>{V=!1}},[]);const oe=c.useMemo(()=>({executeJavaScript:async(V,Z)=>{const G=o.current;if(!G)throw new Error("Browser view is not available");return G.executeJavaScript(V,Z)},capturePage:async()=>{const V=o.current;if(!V)return null;const Z=V.getWebContentsId();return Number.isFinite(Z)?await hr("desktop_browser_capture_page",{webContentsId:Z}):null}}),[]),ce=c.useCallback(()=>{if(x){h(!1),Io(oe);return}if(!$.url){_e.error(r("contextPanel.browser.annotate.noPage"));return}const V=Qw(i.metadata.variant==="light"?"light":"dark");h(!0),qw({host:oe,theme:V,labels:ue}).then(async Z=>{h(!1),Z&&await ee(Z)}).catch(()=>{h(!1),_e.error(r("contextPanel.browser.annotate.failed"))})},[oe,ee,i,x,$.url,ue,r]);c.useEffect(()=>{if(!x)return;const V=Z=>{cg(Z)||Z.key!=="Escape"||(Z.preventDefault(),Z.stopImmediatePropagation(),h(!1),Io(oe))};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[oe,x]);const pe=c.useCallback(async(V=8e3)=>{const Z=Date.now();for(;;){const G=o.current;if(!G)return!1;let ie=!1;try{ie=G.isLoading()}catch{return!1}if(!ie)return!0;if(Date.now()-Z>V)return!1;await new Promise(Se=>setTimeout(Se,120))}},[]),Y=c.useCallback(async(V,Z)=>{const G=o.current;if(!G)throw new Error("The browser panel is not ready");const ie=()=>{Ic(Z.viewport)&&(M(ma(Z.viewport)),T(!0))};if(V==="browser.back"||V==="browser.forward"){const Le=V==="browser.back";if(!(Le?G.canGoBack():G.canGoForward()))throw new Error(Le?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Le?G.goBack():G.goForward(),await new Promise(he=>setTimeout(he,150)),await pe();let O="";try{O=G.getTitle()||""}catch{O=""}return{url:ar(G.getURL()),title:O}}if(V==="browser.capture"){const Le=ye.getState(),Ve=Fn(e),O=Le.contextPanelByDirectory[Ve],he=!!(O?.isOpen&&O.activeTabId===n);he||Le.setActiveContextPanelTab(e,n);const $e=()=>{if(he||!O)return;const Ue=ye.getState(),ct=Ue.contextPanelByDirectory[Ve];!ct?.isOpen||ct.activeTabId!==n||(O.activeTabId&&O.activeTabId!==n&&Ue.setActiveContextPanelTab(e,O.activeTabId),O.isOpen||Ue.closeContextPanel(e))};try{const Ue=Date.now()+1200;let ct=0,pt=0;for(;pt<2&&Date.now()<Ue;){const yt=G.getBoundingClientRect().width;pt=yt>=2&&Math.abs(yt-ct)<.5?pt+1:0,ct=yt,await new Promise(ht=>setTimeout(ht,50))}await new Promise(yt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>yt()))}),await pe();const it=await oe.capturePage();if(!it)throw new Error("The page could not be captured");let ft="";try{ft=G.getTitle()||""}catch{ft=""}return{...it,url:ar(G.getURL()),title:ft,viewport:mo(F.current)}}finally{$e()}}if(V==="browser.resize"){if(!Ic(Z.viewport))throw new Error("viewport is required");return ie(),await new Promise(Le=>setTimeout(Le,200)),await pe(),{viewport:mo(ma(Z.viewport))}}if(V==="browser.open"){const Le=typeof Z.url=="string"?Z.url:"";if(!Le)throw new Error("url is required");ie(),L(Le),await new Promise(he=>setTimeout(he,150));const Ve=await pe(25e3);let O="";try{O=G.getTitle()||""}catch{O=""}return{url:gr(Le),title:O,opened:!0,settled:Ve,viewport:mo(F.current)}}await pe();const Se=Le=>typeof Le=="string"&&Le?Le:void 0,Me=(()=>{switch(V){case"browser.snapshot":return vv({selector:Se(Z.selector)});case"browser.click":return Sv({selector:Se(Z.selector),text:Se(Z.text)});case"browser.type":return jv({selector:String(Z.selector??""),value:String(Z.value??""),submit:Z.submit===!0});case"browser.inspect":return Nv({selector:String(Z.selector??"")});case"browser.scroll":return kv({selector:Se(Z.selector),direction:Se(Z.direction)});default:return null}})();if(!Me)throw new Error(`Unsupported browser action: ${V}`);const He=await G.executeJavaScript(Me,!0);if(!He||typeof He!="object")throw new Error("The page returned no result");const We=He;if(We.ok!==!0)throw new Error(typeof We.error=="string"&&We.error?We.error:"Browser action failed");if(V==="browser.snapshot"){const Le=K.current;return{...We,viewport:mo(F.current),...Le.length>0?{consoleProblems:[...Le]}:{}}}return(V==="browser.click"||V==="browser.type"&&Z.submit===!0)&&(await new Promise(Le=>setTimeout(Le,150)),await pe()),He},[oe,e,L,n,pe]),ve=c.useCallback(()=>{const V=o.current;if(!V)return{title:"",url:""};let Z="",G="";try{Z=V.getTitle()||""}catch{Z=""}try{G=ar(V.getURL())}catch{G=""}return{title:Z,url:G}},[]);c.useEffect(()=>rv({tabId:n,describe:ve,run:Y}),[ve,Y,n]),c.useEffect(()=>{const V=oe;return()=>{Io(V)}},[oe]),c.useEffect(()=>{if(!l)return;const V=G=>{const ie=G;if(typeof ie.level!="number"||ie.level<2)return;const Se=ie.sourceId?`${ie.sourceId}${ie.line?`:${ie.line}`:""}`:"";K.current.push({level:ie.level>=3?"error":"warning",message:String(ie.message??"").slice(0,400),source:Se}),K.current.length>Tc&&K.current.splice(0,K.current.length-Tc)},Z=()=>{K.current=[]};return l.addEventListener("console-message",V),l.addEventListener("did-start-loading",Z),()=>{l.removeEventListener("console-message",V),l.removeEventListener("did-start-loading",Z)}},[l]);const Ee=c.useRef(new Set),je=c.useCallback(V=>{Ee.current.clear(),L(V)},[L]);c.useEffect(()=>{if(!l)return;const V=G=>{const ie=fr(G),Se=typeof ie.url=="string"?ie.url:"";!Se||!Nc(Se)||(G.preventDefault(),L(Se))},Z=G=>{const ie=fr(G);if(ie.isMainFrame===!1||ie.errorCode===-3)return;const Se=typeof ie.validatedURL=="string"?ie.validatedURL:"";!Se||!Nc(Se)||Ee.current.has(Se)||(Ee.current.add(Se),L(Se))};return l.addEventListener("will-navigate",V),l.addEventListener("did-fail-load",Z),()=>{l.removeEventListener("will-navigate",V),l.removeEventListener("did-fail-load",Z)}},[L,l]),c.useEffect(()=>{if(!l)return;const V=Z=>{const G=Z.detail;Z.preventDefault(),G?.url&&L(G.url)};return l.addEventListener("new-window",V),()=>l.removeEventListener("new-window",V)},[L,l]);const ge=c.useCallback(V=>{const Z=Math.min(rS,Math.max(nS,V));P.current=Z,N(Z);try{o.current?.setZoomLevel(Z)}catch{}},[]);c.useEffect(()=>{const V=Z=>{if(!(Z instanceof CustomEvent))return;const G=Z.detail,ie=o.current;!ie||document.activeElement!==ie||(G==="zoom-in"?ge(P.current+po):G==="zoom-out"?ge(P.current-po):G==="zoom-reset"&&ge(0))};return window.addEventListener("openchamber:zoom",V),()=>window.removeEventListener("openchamber:zoom",V)},[ge]);const be=c.useCallback(V=>{hr("desktop_browser_clear_data",{partition:oS,cookies:V==="cookies",cache:V==="cache"}).then(()=>{_e.success(r(V==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>_e.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const V=W.current;if(!V||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(G=>{const ie=G[0]?.contentRect;ie&&E({width:ie.width,height:ie.height})});return Z.observe(V),()=>Z.disconnect()},[]);const Q=c.useCallback(V=>{U(V);const Z=o.current;if(!Z)return;let G=-1;try{G=Z.getWebContentsId()}catch{return}hr("desktop_browser_set_color_scheme",{webContentsId:G,scheme:V}).catch(ie=>{U("system"),_e.error(ie instanceof Error?ie.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),_=c.useCallback(()=>{try{de?o.current?.stop():o.current?.reload()}catch{}},[de]),J=$.status;c.useEffect(()=>{const V=()=>{w(!0);const ie=setTimeout(()=>{try{o.current?.reload()}catch{}},iS);return()=>clearTimeout(ie)};if(J.kind==="failed"){if(!Pw(J.code,J.url)){w(!1);return}const ie=Date.now(),Se=k.current?.url===J.url?k.current:{url:J.url,startedAt:ie};if(k.current=Se,ie-Se.startedAt>sS){w(!1);return}return V()}if(J.kind==="loading")return;if(k.current=null,J.kind!=="ready"||!J.url||!Sr(J.url)){v.current=!0,w(!1);return}if(v.current||Date.now()-I.current>aS){v.current=!0,w(!1);return}let Z=!1,G=null;return Tw(ar(J.url)).then(ie=>{if(!Z){if(ie===null||ie<500){v.current=!0,w(!1);return}G=V()}}),()=>{Z=!0,G?.()}},[J]);const me=$.status.kind==="failed"&&!p?$.status:null,le=Iv(R,A);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Ff,{address:b,onAddressChange:j,onSubmit:je,suggestions:Ne,onForgetSuggestion:V=>fe(e,V),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:_,onOpenExternal:()=>{Yr($.url||b)},canGoBack:$.canGoBack,canGoForward:$.canGoForward,isLoading:de,onAnnotate:ce,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ge(S+po),onZoomOut:()=>ge(S-po),onZoomReset:()=>ge(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>be("cookies"),onClearCache:()=>be("cache"),onToggleDeviceBar:()=>T(V=>!V),isDeviceBarOpen:C}),C?s.jsx(Rv,{viewport:R,onViewportChange:M,colorScheme:D,onColorSchemeChange:Q,scale:le?.scale??1}):null,s.jsxs("div",{ref:W,className:De("relative min-h-0 flex-1 bg-background",le&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:d,src:g,partition:"persist:openchamber-browser",allowpopups:!0,style:le?{width:`${le.width}px`,height:`${le.height}px`,transform:`scale(${le.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!f&&!$.url&&!de?s.jsx($f,{onOpen:je,directory:e}):null,p?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:re})})]}):null,me&&!re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:me.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:me.crashed?r("contextPanel.browser.crashedHint"):me.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,de?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},cS=t=>{const e=nt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=At(),l=ye(uS);let a;e[0]!==n?(a=gr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==Fs?d:"",[m,f]=c.useState(u),[g,y]=c.useState(u);let b;e[2]!==u?(b=u?[u]:[],e[2]=u,e[3]=b):b=e[3];const[j,x]=c.useState(b),[h,p]=c.useState(u?0:-1),[w,S]=c.useReducer(fS,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=ue=>{!ue||ue===Fs||!r||!i||l(r,i,ue)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const P=N;let C;e[8]!==r?(C=Rf(r),e[8]=r,e[9]=C):C=e[9];const T=br(C),R=br(mS),M=br(hS);let F;e[10]!==m||e[11]!==T?(F=Ef(T,m),e[10]=m,e[11]=T,e[12]=F):F=e[12];const K=F;let D;e[13]!==r||e[14]!==h||e[15]!==P||e[16]!==R?(D=ue=>{const de=gr(ue);de!==Fs&&(f(de),y(de),P(de),R(r,{url:de}),x(Te=>{const we=h>=0?Te.slice(0,h+1):[];return we[we.length-1]===de?(p(we.length-1),we):(p(we.length),[...we,de])}))},e[13]=r,e[14]=h,e[15]=P,e[16]=R,e[17]=D):D=e[17];const U=D;let A;e[18]!==j||e[19]!==P?(A=ue=>{const de=j[ue];de&&(p(ue),f(de),y(de),P(de))},e[18]=j,e[19]=P,e[20]=A):A=e[20];const E=A;let W;e[21]!==r||e[22]!==M?(W=ue=>M(r,ue),e[21]=r,e[22]=M,e[23]=W):W=e[23];let k,v;e[24]!==E||e[25]!==h?(v=()=>E(h-1),k=()=>E(h+1),e[24]=E,e[25]=h,e[26]=k,e[27]=v):(k=e[26],v=e[27]);let I;e[28]!==m||e[29]!==g?(I=()=>{Yr(g||m)},e[28]=m,e[29]=g,e[30]=I):I=e[30];const H=h>0,$=h>=0&&h<j.length-1;let re;e[31]!==m||e[32]!==U||e[33]!==K||e[34]!==k||e[35]!==I||e[36]!==H||e[37]!==$||e[38]!==W||e[39]!==v?(re=s.jsx(Ff,{address:m,onAddressChange:f,onSubmit:U,suggestions:K,onForgetSuggestion:W,onBack:v,onForward:k,onReload:S,onOpenExternal:I,canGoBack:H,canGoForward:$,isLoading:!1}),e[31]=m,e[32]=U,e[33]=K,e[34]=k,e[35]=I,e[36]=H,e[37]=$,e[38]=W,e[39]=v,e[40]=re):re=e[40];let te;e[41]!==g||e[42]!==U||e[43]!==w||e[44]!==o?(te=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${w}`):s.jsx($f,{onOpen:U})}),e[41]=g,e[42]=U,e[43]=w,e[44]=o,e[45]=te):te=e[45];let ee;return e[46]!==re||e[47]!==te?(ee=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[re,te]}),e[46]=re,e[47]=te,e[48]=ee):ee=e[48],ee},dS=t=>{const e=nt.c(3),[n]=c.useState(tS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(lS,{...t}):s.jsx(cS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function uS(t){return t.setContextPanelTabTargetPath}function fS(t){return t+1}function mS(t){return t.recordVisit}function hS(t){return t.forget}const pS=In(()=>en(()=>import("./WalkthroughView-B-3eK3lX.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128])).then(t=>({default:t.WalkthroughView}))),gS=In(()=>en(()=>import("./DiffView-UeB7OS2J.js"),__vite__mapDeps([129,1,2,4,5,6,7,8,9,10,84,3,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,130,118,119,120,121,122,131,123,124,125,126,127,128])).then(t=>({default:t.DiffView}))),bS=In(()=>en(()=>import("./FilesView-Cs3Y7IF5.js").then(t=>t.F),__vite__mapDeps([132,6,1,2,4,5,7,8,9,10,3,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,133,134,135,136,137,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,138,139,121,122,119,140,126,120,141])).then(t=>({default:t.FilesView}))),xS=In(()=>en(()=>import("./GitView-DsJqHet1.js"),__vite__mapDeps([142,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,143,131,118,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,88,116,117,119,120,121,122,123,124,125,126,127,128])).then(t=>({default:t.GitView}))),yS=In(()=>en(()=>import("./LinearIssuesView-DCcXvS3Q.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.LinearIssuesView}))),wS=In(()=>en(()=>import("./PlanView-DYZs8zCF.js"),__vite__mapDeps([145,1,2,4,5,6,7,8,9,10,133,58,59,60,61,62,63,80,56,57,64,134,135,136,3,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,81,82,83,120,141,121,122,107,108,92,93,94,95,96,97,98,99,100,101,102,103,104,105,85,86,87])).then(t=>({default:t.PlanView}))),zf=c.lazy(()=>en(()=>import("./PluginPane-CaHXDA-2.js").then(t=>t.p),__vite__mapDeps([87,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.PluginPane}))),Wf={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},vS=t=>{const e=nt.c(12),{mode:n,docking:r}=t,[i,o]=c.useState(null),l=Wf[r.dock],a=Math.max(gg,i??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=De("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let m;e[3]!==l.vertical||e[4]!==a?(m=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=m):m=e[5];let f;e[6]!==n?(f=s.jsx(zf,{mode:n,onResize:o}),e[6]=n,e[7]=f):f=e[7];let g;return e[8]!==u||e[9]!==m||e[10]!==f?(g=s.jsx("div",{className:u,style:m,children:f}),e[8]=u,e[9]=m,e[10]=f,e[11]=g):g=e[11],g},Ec=c.lazy(()=>en(()=>import("./GuestSurfacePane-BFbUwJOB.js"),__vite__mapDeps([146,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,87])).then(t=>({default:t.GuestSurfacePane}))),Kf=320,el=600,SS=400,jS=100,kS=24,Wo=new Map,CS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Rc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Kf,Math.round(t))):el,Mc=t=>{const e=t??(typeof window<"u"?window.innerWidth:el*2);return Math.max(Kf,e-SS)},NS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},AS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Vf=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):$n(t)?Ta.getState().guests.find(r=>r.id===Mo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),PS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},DS=(t,e,n)=>{if(t.mode==="chat"){const r=ha(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?Ja(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?PS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Vf(t.mode,n)},IS=t=>{const e=nt.c(8),{mode:n}=t,r=Oa();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=m=>m.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??bg,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Qr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Oc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Ma,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(hf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(B,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(B,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(B,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(B,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(B,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(B,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(B,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(B,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(B,{name:"chat-4",className:"h-3.5 w-3.5"});if($n(t.mode))return s.jsx(IS,{mode:t.mode});if(t.mode==="browser"){const n=TS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(B,{name:"global",className:"h-3.5 w-3.5"})}},TS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},ES=({visible:t,active:e,fill:n=!1})=>{const{t:r}=At(),i=ye(p=>p.contextEditorTreeWidth),o=ye(p=>p.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),m=c.useRef(null),f=c.useRef(null),g=c.useRef(null),y=c.useCallback(p=>{const w=g.current;w&&(w.style.width=`${p}px`,w.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),b=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}f.current=p.pointerId,a(!0),d.current=p.clientX,u.current=i,m.current=i,p.preventDefault()}},j=p=>{if(!l||f.current!==p.pointerId)return;const w=d.current-p.clientX,S=Fi(u.current+w);m.current!==S&&(m.current=S,y(S))},x=p=>{if(f.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const w=Fi(m.current??i);f.current=null,m.current=null,a(!1),o(w)},h=t?i:0;return s.jsxs("div",{ref:g,className:De("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?m.current??h:h}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?m.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:De("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:j,onPointerUp:x,onPointerCancel:x,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:De("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(q1,{visible:t&&e})})]})},ha=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,RS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},MS=(t,e)=>{if(e.length===0)return Wo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Wo:r},OS=(t,e)=>{const n=pg(t),r=c.useRef(Wo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=MS(n.getState().session,i.current);return RS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Wo)},BS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,FS=()=>{const{t}=At(),e=Yn()??"",n=c.useMemo(()=>CS(e),[e]),r=ye(q=>n?q.contextPanelByDirectory[n]:void 0),i=ye(q=>q.closeContextPanel),o=ye(q=>q.closeContextPanelTab),l=ye(q=>q.openContextPanelTab),a=ye(q=>q.toggleContextPanelExpanded),d=ye(q=>q.setContextPanelWidth),u=ye(q=>q.setActiveContextPanelTab),m=ye(q=>q.openAgentBrowserTab);c.useEffect(()=>{if(e)return iv(q=>m(e,q))},[e,m]);const f=ye(q=>q.openContextFile);c.useEffect(()=>Dn(q=>{if(q.type!=="file-open-request")return;const Fe=q.directory??e;Fe&&f(Fe,q.path)}),[e,f]);const g=ye(q=>q.reorderContextPanelTabs),y=Qs(q=>q.setSelectedPath),b=ye(q=>q.contextEditorTreeVisible),j=ye(q=>q.contextEditorTreeWidth),x=ye(q=>q.setContextEditorTreeWidth),h=ye(q=>q.toggleContextEditorTree),p=ye(q=>q.contextEditorVisible),w=ye(q=>q.toggleContextEditor),S=ye(q=>q.openNewContextBrowserTab),N=kf(q=>q.byOrigin),P=ye(q=>q.allowPromptingSubagentSessions),{themeMode:C,setThemeMode:T,lightThemeId:R,darkThemeId:M,currentTheme:F}=qn(),K=c.useMemo(()=>r?.tabs??[],[r?.tabs]),D=K.find(q=>q.id===r?.activeTabId)??K[K.length-1]??null,U=D?.mode==="browser"?D.id:null;c.useEffect(()=>{U&&ov(U)},[U]);const A=!!(r?.isOpen&&D),[E,W]=c.useState(null),k=c.useMemo(()=>K.some(q=>q.mode==="file"&&q.targetPath),[K]),v=k&&(p||!b),I=D?.mode??null,H=I==="file"&&!v,$=!!(A&&r?.expanded&&!H),re=I?r?.widthByMode?.[I]:void 0,te=I?r?.widthFractionByMode?.[I]:void 0,ee=I?dg(I):.5,ue=E??(typeof window<"u"?window.innerWidth:el*2),de=te!=null&&E!=null?Math.round(te*E):re,Te=H?j:Rc(de??Math.round(ee*ue),Mc(E??ue));c.useEffect(()=>{!n||!I||H||te!=null||re==null||E==null||d(n,I,re,E)},[I,E,n,H,re,te,d]);const we=c.useMemo(()=>{const q=[];for(const Fe of K){if(Fe.mode!=="chat")continue;const Ze=ha(Fe.dedupeKey);Ze&&!q.includes(Ze)&&q.push(Ze)}return q},[K]),fe=OS(n||void 0,we),[Ne,L]=c.useState(!1),oe=c.useRef(0),ce=c.useRef(Te),pe=c.useRef(null),Y=c.useRef(null),ve=c.useRef(null),Ee=c.useRef(new Map),je=c.useRef(new Map),ge=c.useRef(!1);c.useLayoutEffect(()=>{const q=ve.current?.parentElement;if(!q||typeof ResizeObserver>"u")return;const Fe=new ResizeObserver(()=>{W(q.clientWidth||null)});return Fe.observe(q),W(q.clientWidth||null),()=>Fe.disconnect()},[]),c.useEffect(()=>{if(!A||ge.current){ge.current=A;return}const q=window.requestAnimationFrame(()=>{ve.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(q)},[A]);const be=c.useRef(null),Q=c.useRef(null),_=c.useCallback(()=>{Q.current=null;const q=ve.current,Fe=pe.current;!q||Fe===null||q.style.setProperty("--oc-context-panel-width",`${Fe}px`)},[]);c.useEffect(()=>()=>{Q.current!==null&&clearTimeout(Q.current)},[]);const J=c.useCallback(q=>{const Fe=be.current,Ze=H?Fi(q):Rc(q,Mc(Fe));return Fe===null?Ze:Math.min(Ze,Math.max(1,Fe))},[H]),me=c.useCallback(q=>{!A||$||!n||(Y.current=q.pointerId,L(!0),oe.current=q.clientX,ce.current=Te,pe.current=Te,be.current=NS(ve.current),document.documentElement.style.cursor="col-resize",q.preventDefault())},[n,$,A,Te]),le=c.useCallback(()=>{const q=J(pe.current??Te),Fe=be.current;pe.current=null,be.current=null,Q.current!==null&&(clearTimeout(Q.current),Q.current=null),document.documentElement.style.cursor="",H?x(q):n&&I&&d(n,I,q,Fe??void 0),L(!1),Y.current=null},[I,J,n,H,x,d,Te]);c.useEffect(()=>{if(!Ne)return;const q=Je=>{if(Y.current!==Je.pointerId)return;const et=oe.current-Je.clientX,kt=J(ce.current+et);pe.current!==kt&&(pe.current=kt,Q.current===null&&(Q.current=setTimeout(_,jS)))},Fe=Je=>{Y.current===Je.pointerId&&le()},Ze=()=>{le()};return window.addEventListener("pointermove",q),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",Ze),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",Ze)}},[_,J,le,Ne]),c.useEffect(()=>{Ne||(pe.current=null,document.documentElement.style.cursor="")},[Ne]);const V=c.useCallback(()=>{n&&i(n)},[i,n]),Z=c.useCallback(()=>{n&&a(n)},[n,a]),G=c.useCallback(q=>{q.key==="Escape"&&(q.target instanceof Node&&!q.currentTarget.contains(q.target)||ug(q.target)||fg(q.target)||(q.preventDefault(),q.stopPropagation(),V()))},[V]);c.useEffect(()=>{if(!(!n||!D)&&D.mode==="file"&&D.targetPath){y(n,D.targetPath,{allowOutsideRoot:!0});return}},[D,n,y]);const ie=c.useMemo(()=>K.filter(q=>q.mode==="chat"),[K]),Se=A&&D?.mode==="chat"?D.id:null,se=A&&D?.mode==="chat"?ha(D.dedupeKey):null,Me=Cx(ie,Se);c.useEffect(()=>{if(!A||!n||!se||typeof window>"u")return;const q=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){wi(n,se,!1);return}Pu(se),wi(n,se,!0)};q();const Fe=window.setInterval(q,1e4);return window.addEventListener("focus",q),window.addEventListener("blur",q),document.addEventListener("visibilitychange",q),()=>{window.clearInterval(Fe),window.removeEventListener("focus",q),window.removeEventListener("blur",q),document.removeEventListener("visibilitychange",q),wi(n,se,!1)}},[se,n,A]);const He=c.useCallback((q,Fe,Ze)=>Nx(je.current,q,Fe,n||null,Ze,{mode:C,lightThemeId:R,darkThemeId:M,currentTheme:F},{allowPromptingSubagentSessions:P}),[P,F,M,n,R,C]),We=Me&&se?He(Me.id,se,Me.readOnly):null;c.useEffect(()=>{const q=new Set(K.map(Fe=>Fe.id));for(const Fe of je.current.keys())q.has(Fe)||je.current.delete(Fe)},[K]);const Le=c.useCallback(q=>{!n||D?.mode!=="diff"||l(n,{mode:"diff",targetPath:D.targetPath,stagedDiff:q==="staged",diffScope:q})},[D,n,l]),Ve=c.useCallback(()=>{if(typeof window>"u")return;const q={themeMode:C,lightThemeId:R,darkThemeId:M,currentTheme:F};for(const Fe of Ee.current.values()){const Ze=Fe.contentWindow;Ze&&Ze.postMessage({type:"openchamber:theme-sync",payload:q},window.location.origin)}},[F,M,R,C]),O=c.useCallback(()=>{if(typeof window>"u")return;const q={allowPromptingSubagentSessions:P};for(const Fe of Ee.current.values()){const Ze=Fe.contentWindow;Ze&&Ze.postMessage({type:"openchamber:chat-settings-sync",payload:q},window.location.origin)}},[P]),he=c.useCallback((q,Fe,Ze)=>{const Je=Fe.contentWindow;Je&&Je.postMessage({type:rf,payload:{visible:Se===q}},Ze)},[Se]),$e=c.useCallback(()=>{if(!(typeof window>"u"))for(const[q,Fe]of Ee.current.entries())he(q,Fe,window.location.origin)},[he]);c.useEffect(()=>{if(typeof window>"u")return;const q=Fe=>{if(Fe.origin!==window.location.origin)return;const Ze=Array.from(Ee.current.entries()).find(([,It])=>It.contentWindow===Fe.source);if(!Ze)return;const Je=Fe.data;if(Je?.type===Ax){const[It,Mt]=Ze;he(It,Mt,Fe.origin);return}if(Je?.type===Px){if(typeof Je.requestId!="string"||!Je.requestId)return;const It=qt(),Mt={apiBaseUrl:hn(),clientToken:Vr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Wd(),relayHostId:It.startsWith("host:")?It.slice(5):"",relay:ih()??void 0};Fe.source?.postMessage({type:Dx,requestId:Je.requestId,payload:Mt},Fe.origin);return}if(Je?.type==="openchamber:theme-sync-request"){Ve();return}if(Je?.type==="openchamber:chat-settings-request"){O();return}if(Je?.type!=="openchamber:cycle-theme-request")return;const et=["light","dark","system"],Qe=(et.indexOf(C)+1)%et.length;T(et[Qe])};return window.addEventListener("message",q),()=>window.removeEventListener("message",q)},[O,he,Ve,T,C]),c.useLayoutEffect(()=>{K.some(Fe=>Fe.mode==="chat")&&(Ve(),O(),$e())},[M,R,O,$e,Ve,K,C]);const Ue=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",ct=c.useMemo(()=>D?K.filter(q=>q.mode===D.mode):[],[D,K]),pt=c.useMemo(()=>ct.map(q=>{const Fe=DS(q,fe,t),Ze=BS(Fe,kS),Je=AS(q.targetPath,e);return{id:q.id,label:Ze,icon:Oc(q,N),title:Je?`${Fe}: ${Je}`:Fe,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ze})}}),[ct,e,N,fe,t]),it=D?.mode==="context"?s.jsx(mw,{}):D?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(xS,{isActive:A})}):D?.mode==="pr"?s.jsx(v1,{}):D?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(yS,{})}):D?.mode==="notes"?s.jsx(Lh,{}):D?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(wS,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,ft=c.useMemo(()=>K.filter(q=>q.mode==="browser"),[K]),yt=c.useMemo(()=>K.filter(q=>q.mode==="diff"),[K]),ht=c.useMemo(()=>K.find(q=>q.mode==="terminal")??null,[K]),bt=c.useMemo(()=>K.some(q=>q.mode==="walkthrough"),[K]),Dt=c.useMemo(()=>K.filter(q=>$n(q.mode)),[K]),xe=Ta(q=>q.guests),Ye=c.useMemo(()=>new Set(xe.filter(mg).map(q=>q.id)),[xe]),Xe=c.useMemo(()=>{const q=new Map;for(const Fe of xe){const Ze=hg(Fe);Ze&&q.set(Fe.id,Ze)}return q},[xe]),qe=c.useMemo(()=>K.some(q=>q.mode==="file"),[K]),dt=D?.mode==="file",X=ye(q=>q.closeContextPanelTabs),ae=c.useCallback(q=>{if(!n)return null;const{id:Fe,index:Ze,allIds:Je,close:et}=q,kt=()=>X(n,Je.filter(Be=>Be!==Fe)),Qe=()=>X(n,Je.slice(0,Ze)),It=()=>X(n,Je.slice(Ze+1)),Mt=()=>X(n,Je),ke=Je.length>1,Oe=Ze===0,Re=Ze===Je.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Ln,{onClick:et,children:[s.jsx(B,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(zi,{}),s.jsxs(Ln,{onClick:kt,disabled:!ke,children:[s.jsx(B,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Ln,{onClick:Qe,disabled:Oe,children:[s.jsx(B,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Ln,{onClick:It,disabled:Re,children:[s.jsx(B,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(zi,{}),s.jsxs(Ln,{onClick:Mt,disabled:!ke,children:[s.jsx(B,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[X,n,t]),Ae=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ue?s.jsx(qd,{items:pt,activeId:D?.id??null,onSelect:q=>{n&&u(n,q)},onClose:q=>{n&&o(n,q)},onReorder:(q,Fe)=>{n&&g(n,q,Fe)},layoutMode:"scrollable",variant:"default",tabContextMenu:ae}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[D?Oc(D,N):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?Vf(D.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?.mode==="browser"?s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(B,{name:"add",className:"h-3.5 w-3.5"})}):null,dt&&k?s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":v,children:s.jsx(B,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,dt?s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(B,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,H?null:s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:Z,className:"h-7 w-7 p-0",title:t($?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t($?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:$?s.jsx(B,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(B,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:V,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(B,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ge=A?$?{"--oc-context-panel-width":E!==null?`${E}px`:"100%",width:E!==null?`${E}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Te}px`}:{"--oc-context-panel-width":`${Te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:ve,"data-context-panel":"true",tabIndex:-1,inert:!A||void 0,className:De("flex min-h-0 flex-col overflow-hidden bg-background",$?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!A&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:G,style:Ge,children:[A&&!$&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),A&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!$&&s.jsx("div",{className:De("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Ne&&"bg-[var(--interactive-border)]"),onPointerDown:me,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:De("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!A&&"pointer-events-none select-none opacity-0"),style:{width:$?E!==null?`${E}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!A,children:[Ae,s.jsxs("div",{className:De("relative min-h-0 flex-1 overflow-hidden",Ne&&"pointer-events-none"),children:[qe?s.jsxs("div",{className:De("absolute inset-0 flex",dt?"flex":"hidden"),children:[k||!b?s.jsx("div",{className:De("h-full min-w-0 flex-1",k&&!v&&"hidden"),children:k?s.jsx(c.Suspense,{fallback:null,children:s.jsx(bS,{mode:"editor-only",visible:A&&dt&&v})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(B,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(ES,{visible:b,active:A&&dt,fill:!v})]}):null,Me&&se&&We?s.jsx("iframe",{ref:q=>{if(!q){Ee.current.delete(Me.id);return}Ee.current.set(Me.id,q)},src:We,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:se}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Ve(),O(),$e()}},Me.id):null,ft.map(q=>s.jsx("div",{className:De("absolute inset-0",D?.id!==q.id&&"invisible pointer-events-none"),"aria-hidden":D?.id!==q.id||void 0,children:s.jsx(dS,{initialUrl:q.targetPath??"",directory:n,tabID:q.id})},q.id)),yt.map(q=>s.jsx("div",{className:De("absolute inset-0",D?.id!==q.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(gS,{visible:A&&D?.id===q.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:q.diffScope??(q.stagedDiff?"staged":"working"),onDiffScopeChange:Le,targetFilePath:q.targetPath,flushContent:!0})})},q.id)),ht?s.jsx("div",{className:De("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:s.jsx(_h,{visible:A&&D?.mode==="terminal",directory:ht.targetDirectory})}):null,bt?s.jsx("div",{className:De("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(pS,{directory:e,visible:A&&D?.mode==="walkthrough"})})}):null,Dt.map(q=>{if(!$n(q.mode))return null;const Fe=Mo(q.mode),Ze=Ye.has(Fe),Je=Xe.get(Fe),et=D?.id===q.id,kt=et&&A;return Ze&&!Je&&!kt?null:s.jsx("div",{className:De("absolute inset-0",et?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ze?Je?s.jsxs("div",{className:De("flex h-full",Wf[Je.dock].container),children:[s.jsx(vS,{mode:q.mode,docking:Je}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:kt?s.jsx(Ec,{mode:q.mode}):null})]}):s.jsx(Ec,{mode:q.mode}):s.jsx(zf,{mode:q.mode})})},q.id)}),D?.mode!=="chat"&&!dt&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"&&!(D&&$n(D.mode))?it:null]})]})]})},LS=t=>{const e=nt.c(43),{open:n,onOpenChange:r}=t,{t:i}=At(),o=ye(_S),l=ye($S),a=ye(zS),d=ye(WS),u=Oa();let m;e[0]!==o||e[1]!==u?(m=Du(o,u),e[0]=o,e[1]=u,e[2]=m):m=e[2];const f=m,g=l.length===0;let y;if(e[3]!==l||e[4]!==f){let R;e[6]!==l?(R=M=>l.includes(M.id),e[6]=l,e[7]=R):R=e[7],y=f.every(R),e[3]=l,e[4]=f,e[5]=y}else y=e[5];const b=y;let j;e[8]!==i?(j=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=j):j=e[9];let x;e[10]!==j?(x=s.jsx(Ls,{children:j}),e[10]=j,e[11]=x):x=e[11];let h;e[12]!==i?(h=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=h):h=e[13];let p;e[14]!==h?(p=s.jsx(_s,{children:h}),e[14]=h,e[15]=p):p=e[15];let w;e[16]!==x||e[17]!==p?(w=s.jsxs(Hs,{children:[x,p]}),e[16]=x,e[17]=p,e[18]=w):w=e[18];let S;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let R;e[24]!==l||e[25]!==a||e[26]!==i?(R=M=>s.jsx(xg,{settingsItem:`layout.context-rail.surface.${M.id}`,checked:!l.includes(M.id),onChange:F=>a(M.id,F),label:M.label??i(M.labelKey),ariaLabel:M.label??i(M.labelKey)},M.id),e[24]=l,e[25]=a,e[26]=i,e[27]=R):R=e[27],S=f.map(R),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=S}else S=e[23];let N;e[28]!==S?(N=s.jsx("div",{className:"flex flex-col",children:S}),e[28]=S,e[29]=N):N=e[29];let P;e[30]!==g||e[31]!==b||e[32]!==d||e[33]!==i?(P=g?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(mt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=g,e[31]=b,e[32]=d,e[33]=i,e[34]=P):P=e[34];let C;e[35]!==P||e[36]!==w||e[37]!==N?(C=s.jsxs(Cs,{className:"max-w-md",children:[w,N,P]}),e[35]=P,e[36]=w,e[37]=N,e[38]=C):C=e[38];let T;return e[39]!==r||e[40]!==n||e[41]!==C?(T=s.jsx(ks,{open:n,onOpenChange:r,children:C}),e[39]=r,e[40]=n,e[41]=C,e[42]=T):T=e[42],T};function _S(t){return t.contextRailOrder}function $S(t){return t.contextRailHiddenSurfaces}function zS(t){return t.setContextRailSurfaceVisible}function WS(t){return t.setContextRailHiddenSurfaces}const Uf=150,KS=500,VS=[],US=t=>t>99?"99+":String(t),HS=t=>{const e=nt.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:m,showOrderNumber:f,onSelect:g}=t;let y;e[0]!==n.id?(y={id:n.id},e[0]=n.id,e[1]=y):y=e[1];const{attributes:b,listeners:j,setNodeRef:x,transform:h,transition:p,isDragging:w}=ri(y);let S;e[2]!==a?(S=a!=null&&a>0?US(a):null,e[2]=a,e[3]=S):S=e[3];const N=S;let P;e[4]!==h?(P=oi.Translate.toString(h),e[4]=h,e[5]=P):P=e[5];let C;e[6]!==P||e[7]!==p?(C={transform:P,transition:p},e[6]=P,e[7]=p,e[8]=C):C=e[8];const T=w&&"z-10 opacity-70";let R;e[9]!==T?(R=De("relative",T),e[9]=T,e[10]=R):R=e[10];let M;e[11]!==g||e[12]!==n?(M=()=>g(n),e[11]=g,e[12]=n,e[13]=M):M=e[13];const F=d??o,K=r?"text-primary":"text-muted-foreground hover:text-foreground";let D;e[14]!==K?(D=De("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",K),e[14]=K,e[15]=D):D=e[15];let U;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(U=n.id==="diff"?s.jsx(hf,{className:"h-[18px] w-[18px]"}):s.jsx(Qr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=U):U=e[19];let A;e[20]!==N||e[21]!==m||e[22]!==i||e[23]!==f?(A=f&&m!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:m===10?"0":m}):N?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:N}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=N,e[21]=m,e[22]=i,e[23]=f,e[24]=A):A=e[24];let E;e[25]!==b||e[26]!==r||e[27]!==j||e[28]!==D||e[29]!==U||e[30]!==A||e[31]!==M||e[32]!==F?(E=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...b,...j,onClick:M,"aria-label":F,"aria-pressed":r,className:D,children:[U,A]})}),e[25]=b,e[26]=r,e[27]=j,e[28]=D,e[29]=U,e[30]=A,e[31]=M,e[32]=F,e[33]=E):E=e[33];let W;e[34]!==o?(W=s.jsx("span",{children:o}),e[34]=o,e[35]=W):W=e[35];let k;e[36]!==l?(k=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=k):k=e[37];let v;e[38]!==u?(v=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=v):v=e[39];let I;e[40]!==W||e[41]!==k||e[42]!==v?(I=s.jsx(jt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[W,k,v]})}),e[40]=W,e[41]=k,e[42]=v,e[43]=I):I=e[43];let H;e[44]!==E||e[45]!==I?(H=s.jsxs(vt,{delayDuration:Uf,children:[E,I]}),e[44]=E,e[45]=I,e[46]=H):H=e[46];let $;return e[47]!==x||e[48]!==H||e[49]!==C||e[50]!==R?($=s.jsx("div",{ref:x,style:C,className:R,children:H}),e[47]=x,e[48]=H,e[49]=C,e[50]=R,e[51]=$):$=e[51],$},GS=()=>{const t=nt.c(92),{t:e}=At(),n=Yn();let r;t[0]!==n?(r=n?Fn(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=ye(o),a=ye(qS),d=ye(YS),u=ye(QS),m=ye(XS),f=ye(JS),g=ye(ZS),y=ye(ej),b=Ea(tj),j=Ui(sj),x=Ui(nj),h=pn(rj),p=pn(oj),{screenWidth:w}=Pn(),S=Ra(i||null);let N;t[4]!==y?(N=Hi("switch_context_surface",y),t[4]=y,t[5]=N):N=t[5];const P=N,[C,T]=c.useState(!1);let R,M;t[6]!==P?(R=()=>{const le=new Set;let V=null,Z=!1;const G=ij,ie=()=>{Rl(P,le)?!Z&&V===null&&(V=setTimeout(()=>T(!0),KS)):(Z=!1,V!==null&&(clearTimeout(V),V=null),T(!1))},Se=He=>{if(le.add(He.key.toLowerCase()),G(He.key)&&Rl(P,le)){Z=!0,V!==null&&(clearTimeout(V),V=null),T(!1);return}ie()},se=He=>{le.delete(He.key.toLowerCase()),ie()},Me=()=>{le.clear(),Z=!1,V!==null&&(clearTimeout(V),V=null),T(!1)};return window.addEventListener("keydown",Se,!0),window.addEventListener("keyup",se,!0),window.addEventListener("blur",Me),()=>{window.removeEventListener("keydown",Se,!0),window.removeEventListener("keyup",se,!0),window.removeEventListener("blur",Me),V!==null&&clearTimeout(V)}},M=[P],t[6]=P,t[7]=R,t[8]=M):(R=t[7],M=t[8]),c.useEffect(R,M);let F;t[9]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},t[9]=F):F=t[9];let K;t[10]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{delay:200,tolerance:6}},t[10]=K):K=t[10];const D=Zo(fn(ti,F),fn(ei,K)),U=Oa(),A=El(aj),E=El(lj),W=l?.tabs??VS;let k;t[11]!==l?.activeTabId||t[12]!==W?(k=W.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=W,t[13]=k):k=t[13];const v=k,I=l?.isOpen?v?.mode??null:null,H=S?.files.length??0;let $;t[14]!==u||t[15]!==d||t[16]!==p||t[17]!==U||t[18]!==x||t[19]!==b||t[20]!==w||t[21]!==W?($=yg({railOrder:d,hiddenSurfaces:u,planModeEnabled:b,isVSCode:An(),screenWidth:w,tabs:W,linearConnected:x,githubConnected:p,extras:U}),t[14]=u,t[15]=d,t[16]=p,t[17]=U,t[18]=x,t[19]=b,t[20]=w,t[21]=W,t[22]=$):$=t[22];const re=$;let te,ee;t[23]!==I||t[24]!==g||t[25]!==i||t[26]!==j||t[27]!==x?(ee=()=>{!i||!j||x||I!=="linear"||g(i)},te=[I,g,i,j,x],t[23]=I,t[24]=g,t[25]=i,t[26]=j,t[27]=x,t[28]=te,t[29]=ee):(te=t[28],ee=t[29]),c.useEffect(ee,te);let ue,de;t[30]!==I||t[31]!==g||t[32]!==i||t[33]!==h||t[34]!==p?(ue=()=>{!i||!h||p||I!=="pr"||g(i)},de=[I,g,i,h,p],t[30]=I,t[31]=g,t[32]=i,t[33]=h,t[34]=p,t[35]=ue,t[36]=de):(ue=t[35],de=t[36]),c.useEffect(ue,de);const[Te,we]=c.useState(!1);let fe;t[37]!==U||t[38]!==m?(fe=le=>{const{active:V,over:Z}=le;if(!Z||V.id===Z.id)return;const G=Du(ye.getState().contextRailOrder,U).map(cj),ie=G.indexOf(V.id),Se=G.indexOf(Z.id);ie===-1||Se===-1||m(Ju(G,ie,Se))},t[37]=U,t[38]=m,t[39]=fe):fe=t[39];const Ne=fe;if(!i)return null;let L;t[40]!==e?(L=e("contextRail.aria.rail"),t[40]=e,t[41]=L):L=t[41];let oe;t[42]!==re?(oe=re.map(dj),t[42]=re,t[43]=oe):oe=t[43];let ce;if(t[44]!==I||t[45]!==H||t[46]!==E||t[47]!==i||t[48]!==A||t[49]!==f||t[50]!==C||t[51]!==re||t[52]!==e||t[53]!==a){let le;t[55]!==I||t[56]!==H||t[57]!==E||t[58]!==i||t[59]!==A||t[60]!==f||t[61]!==C||t[62]!==e||t[63]!==a?(le=(V,Z)=>{const G=V.label??e(V.labelKey),ie=V.id==="git"&&!a?H:0,Se=$n(V.mode)&&I!==V.mode?A[Mo(V.mode)]??0:0,se=ie>0?ie:Se>0?Se:null,Me=se!==null&&ie===0;return s.jsx(HS,{surface:V,isActive:I===V.mode,showActivityDot:!1,label:G,description:e(V.descriptionKey),badgeCount:se,badgeAriaLabel:se!==null?e(Me?se===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":se===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:G,count:se}):null,badgeDescription:se!==null?e(Me?se===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":se===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:se}):null,orderNumber:Z+1,showOrderNumber:C,onSelect:He=>{$n(He.mode)&&E(Mo(He.mode)),f(i,He.mode)}},V.id)},t[55]=I,t[56]=H,t[57]=E,t[58]=i,t[59]=A,t[60]=f,t[61]=C,t[62]=e,t[63]=a,t[64]=le):le=t[64],ce=re.map(le),t[44]=I,t[45]=H,t[46]=E,t[47]=i,t[48]=A,t[49]=f,t[50]=C,t[51]=re,t[52]=e,t[53]=a,t[54]=ce}else ce=t[54];let pe;t[65]!==oe||t[66]!==ce?(pe=s.jsx(Ua,{items:oe,strategy:Zu,children:ce}),t[65]=oe,t[66]=ce,t[67]=pe):pe=t[67];let Y;t[68]!==Ne||t[69]!==D||t[70]!==pe?(Y=s.jsx(si,{sensors:D,collisionDetection:ni,onDragEnd:Ne,children:pe}),t[68]=Ne,t[69]=D,t[70]=pe,t[71]=Y):Y=t[71];let ve;t[72]!==e?(ve=e("contextRail.configure.open"),t[72]=e,t[73]=ve):ve=t[73];let Ee;t[74]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>we(!0),t[74]=Ee):Ee=t[74];let je;t[75]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(B,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=je):je=t[75];let ge;t[76]!==ve?(ge=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":ve,onClick:Ee,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:je})}),t[76]=ve,t[77]=ge):ge=t[77];let be;t[78]!==e?(be=e("contextRail.configure.open"),t[78]=e,t[79]=be):be=t[79];let Q;t[80]!==be?(Q=s.jsx(jt,{side:"left",sideOffset:8,children:be}),t[80]=be,t[81]=Q):Q=t[81];let _;t[82]!==ge||t[83]!==Q?(_=s.jsxs(vt,{delayDuration:Uf,children:[ge,Q]}),t[82]=ge,t[83]=Q,t[84]=_):_=t[84];let J;t[85]!==Te?(J=s.jsx(LS,{open:Te,onOpenChange:we}),t[85]=Te,t[86]=J):J=t[86];let me;return t[87]!==L||t[88]!==Y||t[89]!==_||t[90]!==J?(me=s.jsxs("nav",{"aria-label":L,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[Y,_,J]}),t[87]=L,t[88]=Y,t[89]=_,t[90]=J,t[91]=me):me=t[91],me};function qS(t){return t.workStatusPanelVisible}function YS(t){return t.contextRailOrder}function QS(t){return t.contextRailHiddenSurfaces}function XS(t){return t.setContextRailOrder}function JS(t){return t.openContextSurface}function ZS(t){return t.closeContextPanel}function ej(t){return t.shortcutOverrides}function tj(t){return t.planModeEnabled}function sj(t){return t.hasChecked}function nj(t){return t.status?.connected===!0}function rj(t){return t.hasChecked}function oj(t){return t.status?.connected===!0}function ij(t){return t.length===1&&t>="0"&&t<="9"}function aj(t){return t.countByGuest}function lj(t){return t.clearBadge}function cj(t){return t.id}function dj(t){return t.id}const uj=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),fj=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Rr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),mj=new Set,hj=[],pa=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},pj=()=>{const t=nt.c(182),{t:e}=At(),n=ye(gj),r=ye(bj),i=ye(xj),o=ye(yj),l=ye(wj),a=ye(vj),d=ye(Sj),u=ye(jj),m=ye(kj),f=ye(Cj),g=ye(Nj),y=ye(Aj),b=ot(Pj),j=ot(Dj),x=ot(Ij),h=Ur(Tj);let p;t[0]!==n?(p=Re=>n?Re.activeSessions:hj,t[0]=n,t[1]=p):p=t[1];const w=ps(p);let S;t[2]!==n?(S=Re=>n?Re.ids:mj,t[2]=n,t[3]=S):S=t[3];const N=Ur(S);let P;t[4]!==n?(P=Re=>n?Re.rankById:Fa,t[4]=n,t[5]=P):P=t[5];const C=Ba(P),T=Zt(Ej),R=zt(Rj),M=zt(Mj),F=Yn(),K=$d(Oj),{files:D,git:U}=gn(),A=Xn(Bj),{isMobile:E}=Pn();let W;t[6]!==F?(W=F?pa(F):null,t[6]=F,t[7]=W):W=t[7];const k=W,[v,I]=c.useState(""),$=Cu(v,200).trim();let re;t[8]!==v?(re=v.trim(),t[8]=v,t[9]=re):re=t[9];const te=re;let ee,ue;t[10]!==n?(ee=()=>{n&&I("")},ue=[n],t[10]=n,t[11]=ee,t[12]=ue):(ee=t[11],ue=t[12]),c.useEffect(ee,ue);let de,Te;t[13]!==w||t[14]!==A||t[15]!==U||t[16]!==n?(de=()=>{if(!n||!U)return;const Re=setTimeout(()=>{const Be=new Set;for(const Ke of w){const rt=Is(Ke);!rt||Be.has(rt)||(Be.add(rt),A(rt,U))}},0);return()=>clearTimeout(Re)},Te=[n,w,U,A],t[13]=w,t[14]=A,t[15]=U,t[16]=n,t[17]=de,t[18]=Te):(de=t[17],Te=t[18]),c.useEffect(de,Te);let we;t[19]!==r?(we=()=>r(!1),t[19]=r,t[20]=we):we=t[20];const fe=we;let Ne;t[21]!==fe?(Ne=Re=>()=>{fe(),Re()},t[21]=fe,t[22]=Ne):Ne=t[22];const L=Ne;let oe;t[23]!==R?.id||t[24]!==R?.path||t[25]!==T||t[26]!==x||t[27]!==E||t[28]!==d||t[29]!==u||t[30]!==b||t[31]!==L||t[32]!==g||t[33]!==y||t[34]!==l||t[35]!==i||t[36]!==e||t[37]!==h||t[38]!==a?(oe=()=>{const Re=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(B,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:L(()=>{l(!1),b()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(B,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:L(Fj)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(B,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:L(Lj)},{id:"toggle-sidebar",title:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(B,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:L(()=>{if(E){const{isSessionSwitcherOpen:Be}=ye.getState();l(!Be)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(B,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:L(()=>{T&&u(T,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(B,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:L(()=>{T&&d(T)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(B,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:L(_j)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(B,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:L($j)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(B,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:L(()=>i(!0))}];return Re.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(B,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:L(()=>{x&&T&&h({directory:T,sessionId:x})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(B,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:L(()=>{x&&Gn(x).then(Be=>{if(Be.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(B,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:L(()=>{l(!1),kg()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(B,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:L(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(B,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:L(()=>{T&&(y("notes"),u(T,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(B,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:L(()=>{T&&(y("todos"),u(T,"notes"))})}),An()||Re.push({id:"restart-opencode",secondary:!0,title:e("commandPalette.item.restartOpenCode"),icon:s.jsx(B,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.restartOpenCode"),onSelect:L(()=>{zh(e)})}),Re.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(B,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:L(zj)}),Kr()&&Re.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(B,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:L(()=>{Nn("desktop_open_draft_mini_chat_window",{directory:pa(T||R?.path||""),projectId:R?.id??null}).catch(Wj)})}),Re},t[23]=R?.id,t[24]=R?.path,t[25]=T,t[26]=x,t[27]=E,t[28]=d,t[29]=u,t[30]=b,t[31]=L,t[32]=g,t[33]=y,t[34]=l,t[35]=i,t[36]=e,t[37]=h,t[38]=a,t[39]=oe):oe=t[39],R?.id,R?.path;let ce;t[40]!==oe?(ce=oe(),t[40]=oe,t[41]=ce):ce=t[41];const pe=ce,Y=ye(Kj);let ve;t[42]===Symbol.for("react.memo_cache_sentinel")?(ve=mn(),t[42]=ve):ve=t[42];const Ee=ve;let je,ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(je=An(),ge=!Ee&&Pa(),t[43]=je,t[44]=ge):(je=t[43],ge=t[44]);let be;t[45]!==E||t[46]!==Y?(be={isVSCode:je,isWeb:ge,isDesktop:Ee,isMobile:E,routingAvailable:Y},t[45]=E,t[46]=Y,t[47]=be):be=t[47];const Q=be;let _;if(t[48]!==L||t[49]!==i||t[50]!==o||t[51]!==Q){let Re;t[53]!==Q?(Re=Ke=>Ke.isAvailable?Ke.isAvailable(Q):!0,t[53]=Q,t[54]=Re):Re=t[54];let Be;t[55]!==L||t[56]!==i||t[57]!==o?(Be=Ke=>{const rt=Wh(Ke.slug)??"settings-3",xt=(Ke.keywords??[]).join(" ");return{id:`settings:${Ke.slug}`,title:Ke.title,icon:Ke.slug==="mcp"?s.jsx(Cg,{className:"mr-2 h-4 w-4"}):s.jsx(B,{name:rt,className:"mr-2 h-4 w-4"}),searchText:`${Ke.title} ${Ke.group} ${xt}`,onSelect:L(()=>{o(Ke.slug),i(!0)})}},t[55]=L,t[56]=i,t[57]=o,t[58]=Be):Be=t[58],_=$h.filter(Vj).filter(Re).map(Be),t[48]=L,t[49]=i,t[50]=o,t[51]=Q,t[52]=_}else _=t[52];const J=_;let me;if(t[59]!==w||t[60]!==N||t[61]!==C){const Re=w.filter(Uj);me=wg(Re,N,C),t[59]=w,t[60]=N,t[61]=C,t[62]=me}else me=t[62];const le=me,V=Iu(),Z=ot(Hj);let G;t[63]!==V||t[64]!==Z?(G=(Re,Be)=>{const Ke=Z.get(Re);return Ke?.branch?Ke.branch.trim()||null:Be&&V.get(Be)?.trim()||null},t[63]=V,t[64]=Z,t[65]=G):G=t[65];const ie=G;let Se;t[66]===Symbol.for("react.memo_cache_sentinel")?(Se=[],t[66]=Se):Se=t[66];const[se,Me]=c.useState(Se),[He,We]=c.useState(""),Le=uj(k,$);let Ve;t[67]!==k||t[68]!==Le||t[69]!==n||t[70]!==K||t[71]!==Me||t[72]!==We||t[73]!==$?(Ve=()=>{if(!n){Me([]),We("");return}if(!Le){Me([]),We("");return}if(!k){Me([]),We("");return}let Re=!1;return K(k,$,40,{type:"file"}).then(Be=>{Re||(Me(Be.map(Gj)),We(Le))}).catch(()=>{Re||(Me([]),We(Le))}),()=>{Re=!0}},t[67]=k,t[68]=Le,t[69]=n,t[70]=K,t[71]=Me,t[72]=We,t[73]=$,t[74]=Ve):Ve=t[74];let O;t[75]!==k||t[76]!==Le||t[77]!==n||t[78]!==K||t[79]!==$?(O=[n,k,$,Le,K],t[75]=k,t[76]=Le,t[77]=n,t[78]=K,t[79]=$,t[80]=O):O=t[80],c.useEffect(Ve,O);const he=te.length>0;let $e;e:{if(!he){let Be;t[81]!==pe?(Be=pe.filter(qj).map(Yj),t[81]=pe,t[82]=Be):Be=t[82],$e=Be;break e}let Re;t[83]!==pe||t[84]!==te?(Re=Rr(pe,te,Qj,{limit:7,noFuzzy:!0}),t[83]=pe,t[84]=te,t[85]=Re):Re=t[85],$e=Re}const Ue=$e;let ct;e:{if(!he){let Be;t[86]===Symbol.for("react.memo_cache_sentinel")?(Be=[],t[86]=Be):Be=t[86],ct=Be;break e}let Re;t[87]!==te||t[88]!==J?(Re=Rr(J,te,Xj,{limit:7,noFuzzy:!0}),t[87]=te,t[88]=J,t[89]=Re):Re=t[89],ct=Re}const pt=ct;let it;e:{if(!he){let Be;t[90]!==le?(Be=le.slice(0,5).map(Jj),t[90]=le,t[91]=Be):Be=t[91],it=Be;break e}let Re;t[92]!==te||t[93]!==le?(Re=Rr(le,te,Zj,{limit:7,threshold:.2}),t[92]=te,t[93]=le,t[94]=Re):Re=t[94],it=Re}const ft=it;let yt;e:{if(!n){let Be;t[95]===Symbol.for("react.memo_cache_sentinel")?(Be=[],t[95]=Be):Be=t[95],yt=Be;break e}let Re;t[96]!==se||t[97]!==He||t[98]!==Le||t[99]!==$?(Re=fj(se,$,Le,He),t[96]=se,t[97]=He,t[98]=Le,t[99]=$,t[100]=Re):Re=t[100],yt=Re}const ht=yt,bt=n&&Le.length>0&&He!==Le;let Dt;e:{if(!he){let Be;t[101]===Symbol.for("react.memo_cache_sentinel")?(Be=[],t[101]=Be):Be=t[101],Dt=Be;break e}let Re;if(t[102]!==te||t[103]!==M){const Be=M.map(e0);Re=Rr(Be,te,t0,{limit:7,threshold:.4}),t[102]=te,t[103]=M,t[104]=Re}else Re=t[104];Dt=Re}const xe=Dt;let Ye,Xe,qe,dt,X,ae,Ae,Ge,q,Fe,Ze,Je,et,kt;if(t[105]!==ie||t[106]!==fe||t[107]!==k||t[108]!==D||t[109]!==he||t[110]!==n||t[111]!==m||t[112]!==b||t[113]!==v||t[114]!==Ue||t[115]!==ht||t[116]!==xe||t[117]!==ft||t[118]!==pt||t[119]!==r||t[120]!==j||t[121]!==f||t[122]!==e){const Re=Ue.map(s0),Be=pt.map(n0),Ke=ft.map(r0),rt=he?ht.map(o0):[],xt=he?xe.map(i0):[];let Pe;e:{if(!he){Pe=["commands","sessions"];break e}const Bt=a0,ut=[{key:"commands",score:Bt(Ue)},{key:"settings",score:Bt(pt)},{key:"sessions",score:Bt(ft)},{key:"files",score:Bt(ht)},{key:"projects",score:Bt(xe)}];ut.sort(l0),Pe=ut.map(c0)}const ze=Pe,st=Bt=>{fe(),j(Bt.id,Is(Bt))},at=async Bt=>{if(!k)return;const ut=await yf(D,Bt,{directory:k});if(!ut.ok){_e.error(wf(ut.reason));return}m(k,Bt),fe()},Ct=(Bt,ut)=>{fe(),b({selectedProjectId:Bt,directoryOverride:ut})},Ot=Bt=>zn(Xr(Bt,f));dt=ks,Je=n,et=r;let Lt;t[137]!==e?(Lt=e("commandPalette.title"),t[137]=e,t[138]=Lt):Lt=t[138];let Kt;t[139]!==Lt?(Kt=s.jsx(Ls,{children:Lt}),t[139]=Lt,t[140]=Kt):Kt=t[140];let Rt;t[141]!==e?(Rt=e("commandPalette.description"),t[141]=e,t[142]=Rt):Rt=t[142];let Vt;t[143]!==Rt?(Vt=s.jsx(_s,{children:Rt}),t[143]=Rt,t[144]=Vt):Vt=t[144],t[145]!==Kt||t[146]!==Vt?(kt=s.jsxs(Hs,{className:"sr-only",children:[Kt,Vt]}),t[145]=Kt,t[146]=Vt,t[147]=kt):kt=t[147],qe=Cs,Fe="overflow-hidden p-0",Ze=!0,Xe=Ng,Ae=!1,Ge="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let $t;t[148]!==e?($t=e("commandPalette.input.placeholder"),t[148]=e,t[149]=$t):$t=t[149],t[150]!==v||t[151]!==$t?(q=s.jsx(Ag,{value:v,onValueChange:I,placeholder:$t}),t[150]=v,t[151]=$t,t[152]=q):q=t[152],Ye=Pg;let Xt;t[153]!==e?(Xt=e("commandPalette.empty.noResults"),t[153]=e,t[154]=Xt):Xt=t[154],t[155]!==Xt?(X=s.jsx(Dg,{children:Xt}),t[155]=Xt,t[156]=X):X=t[156],ae=ze.map(Bt=>Bt==="commands"&&Re.length>0?s.jsx(Cr,{children:Re.map(ut=>s.jsxs(Mr,{value:ut.id,onSelect:ut.onSelect,children:[ut.icon,s.jsx("span",{children:ut.title}),ut.shortcutId?s.jsx(vg,{children:Ot(ut.shortcutId)}):null]},ut.id))},"commands"):Bt==="settings"&&Be.length>0?s.jsx(Cr,{children:Be.map(d0)},"settings"):Bt==="sessions"&&Ke.length>0?s.jsx(Cr,{children:Ke.map(ut=>{const ts=ut.title||e("commandPalette.session.untitled"),ss=Is(ut),fs=ie(ut.id,ss);return s.jsxs(Mr,{value:`session:${ut.id}`,onSelect:()=>st(ut),children:[s.jsx(B,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:ts}),fs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:fs})]}):null]},ut.id)})},"sessions"):Bt==="files"&&rt.length>0?s.jsx(Cr,{children:rt.map(ut=>{const ts=Sg(ut.relativePath||ut.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${ut.path}`,onSelect:()=>{at(ut.path)},children:[s.jsx(Ma,{filePath:ut.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":ut.relativePath,children:ts})]},`file:${ut.path}`)})},"files"):Bt==="projects"&&xt.length>0?s.jsx(Cr,{children:xt.map(ut=>{const ts=ut.displayName;return s.jsxs(Mr,{value:`project:${ut.id}`,onSelect:()=>Ct(ut.id,ut.path),children:[s.jsx(B,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:ts}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:ut.path})]},`project:${ut.id}`)})},"projects"):null),t[105]=ie,t[106]=fe,t[107]=k,t[108]=D,t[109]=he,t[110]=n,t[111]=m,t[112]=b,t[113]=v,t[114]=Ue,t[115]=ht,t[116]=xe,t[117]=ft,t[118]=pt,t[119]=r,t[120]=j,t[121]=f,t[122]=e,t[123]=Ye,t[124]=Xe,t[125]=qe,t[126]=dt,t[127]=X,t[128]=ae,t[129]=Ae,t[130]=Ge,t[131]=q,t[132]=Fe,t[133]=Ze,t[134]=Je,t[135]=et,t[136]=kt}else Ye=t[123],Xe=t[124],qe=t[125],dt=t[126],X=t[127],ae=t[128],Ae=t[129],Ge=t[130],q=t[131],Fe=t[132],Ze=t[133],Je=t[134],et=t[135],kt=t[136];let Qe;t[157]!==bt||t[158]!==e?(Qe=bt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=bt,t[158]=e,t[159]=Qe):Qe=t[159];let It;t[160]!==Ye||t[161]!==X||t[162]!==ae||t[163]!==Qe?(It=s.jsxs(Ye,{children:[X,ae,Qe]}),t[160]=Ye,t[161]=X,t[162]=ae,t[163]=Qe,t[164]=It):It=t[164];let Mt;t[165]!==Xe||t[166]!==Ae||t[167]!==Ge||t[168]!==q||t[169]!==It?(Mt=s.jsxs(Xe,{shouldFilter:Ae,className:Ge,children:[q,It]}),t[165]=Xe,t[166]=Ae,t[167]=Ge,t[168]=q,t[169]=It,t[170]=Mt):Mt=t[170];let ke;t[171]!==qe||t[172]!==Fe||t[173]!==Ze||t[174]!==Mt?(ke=s.jsx(qe,{className:Fe,showCloseButton:Ze,children:Mt}),t[171]=qe,t[172]=Fe,t[173]=Ze,t[174]=Mt,t[175]=ke):ke=t[175];let Oe;return t[176]!==dt||t[177]!==Je||t[178]!==et||t[179]!==kt||t[180]!==ke?(Oe=s.jsxs(dt,{open:Je,onOpenChange:et,children:[kt,ke]}),t[176]=dt,t[177]=Je,t[178]=et,t[179]=kt,t[180]=ke,t[181]=Oe):Oe=t[181],Oe};function gj(t){return t.isCommandPaletteOpen}function bj(t){return t.setCommandPaletteOpen}function xj(t){return t.setSettingsDialogOpen}function yj(t){return t.setSettingsPage}function wj(t){return t.setSessionSwitcherOpen}function vj(t){return t.toggleSidebar}function Sj(t){return t.openContextOverview}function jj(t){return t.openContextSurface}function kj(t){return t.openContextFile}function Cj(t){return t.shortcutOverrides}function Nj(t){return t.setArchivePageOpen}function Aj(t){return t.setProjectContextTab}function Pj(t){return t.openNewSessionDraft}function Dj(t){return t.setCurrentSession}function Ij(t){return t.currentSessionId}function Tj(t){return t.toggle}function Ej(t){return t.currentDirectory}function Rj(t){return t.getActiveProject()}function Mj(t){return t.projects}function Oj(t){return t.searchFiles}function Bj(t){return t.ensureStatus}function Fj(){Tu()}function Lj(){Us.requestDirectoryDialog()}function _j(){Ig.invoke("cycle_theme")}function $j(){Eu()}function zj(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function Wj(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function Kj(t){return t.routingFeatureAvailable}function Vj(t){return t.slug!=="home"}function Uj(t){return!jg(t)}function Hj(t){return t.worktreeMetadata}function Gj(t){return{path:pa(t.path),name:t.name,relativePath:t.relativePath}}function qj(t){return!t.secondary}function Yj(t){return{item:t,score:0}}function Qj(t){return t.searchText}function Xj(t){return t.searchText}function Jj(t){return{item:t,score:0}}function Zj(t){return t.title||""}function e0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function t0(t){return t.searchText}function s0(t){return t.item}function n0(t){return t.item}function r0(t){return t.item}function o0(t){return t.item}function i0(t){return t.item}function a0(t){return t.length?t[0].score:1/0}function l0(t,e){return t.score-e.score}function c0(t){return t.key}function d0(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Bc=(t,e,n)=>zn(Xr(t,e),n),u0=()=>{const t=nt.c(47),{t:e}=At(),n=ye(f0),r=ye(m0),i=ye(h0);let o,l,a,d,u,m,f,g,y,b,j,x;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==e){const N=[{categoryKey:"helpDialog.section.navigationCommands",column:"left",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[zn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",column:"right",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",column:"right",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${zn(Hi("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${zn(Hi("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",column:"left",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}],P=K=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(K.categoryKey)}),s.jsx("div",{className:"space-y-1",children:K.items.map(D=>{const U=D.id?Tg(D.id):void 0,A=D.descriptionKey??(U?.customizable?U.settingsLabelKey:void 0);if(!A||D.id&&!Xr(D.id,i))return null;const E=D.id?Bc(D.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(D.keys)?D.keys:D.keys.split(" / ");return s.jsxs("div",{className:"flex items-center gap-3 py-1 px-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[D.icon&&s.jsx(B,{name:D.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(A)})]}),s.jsx("div",{"aria-hidden":!0,className:"min-w-4 flex-1 border-b border-dotted border-border"}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:(Array.isArray(E)?E:[E]).map((W,k)=>s.jsxs(c.Fragment,{children:[k>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:W})]},`${W}-${k}`))})]},D.id||A)})})]},K.categoryKey);a=ks,j=n,x=r,l=Cs,y="max-w-6xl w-[min(72rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let C;t[16]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(B,{name:"command",className:"h-5 w-5"}),t[16]=C):C=t[16];let T;t[17]!==e?(T=e("helpDialog.title"),t[17]=e,t[18]=T):T=t[18];let R;t[19]!==T?(R=s.jsxs(Ls,{className:"flex items-center gap-2",children:[C,T]}),t[19]=T,t[20]=R):R=t[20];let M;t[21]!==e?(M=e("helpDialog.description"),t[21]=e,t[22]=M):M=t[22];let F;t[23]!==M?(F=s.jsx(_s,{children:M}),t[23]=M,t[24]=F):F=t[24],t[25]!==R||t[26]!==F?(b=s.jsxs(Hs,{children:[R,F]}),t[25]=R,t[26]=F,t[27]=b):b=t[27],o=bn,m="flex-1 min-h-0 mt-3",f="pr-1",g=!0,d="grid grid-cols-1 gap-x-12 gap-y-4 lg:grid-cols-2",u=["left","right"].map(K=>s.jsxs("div",{className:"space-y-4",children:[N.filter(D=>D.column===K).map(P),K==="right"&&s.jsxs("ul",{className:"space-y-0.5 px-2 typography-meta text-muted-foreground",children:[s.jsxs("li",{children:["• ",e("helpDialog.proTips.commandPalette",{shortcut:Bc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))})]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.recentSessions")]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.leaderSequences")]})]})]},K)),t[0]=n,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=m,t[10]=f,t[11]=g,t[12]=y,t[13]=b,t[14]=j,t[15]=x}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],m=t[9],f=t[10],g=t[11],y=t[12],b=t[13],j=t[14],x=t[15];let h;t[28]!==d||t[29]!==u?(h=s.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=h):h=t[30];let p;t[31]!==o||t[32]!==m||t[33]!==f||t[34]!==g||t[35]!==h?(p=s.jsx(o,{outerClassName:m,className:f,disableHorizontal:g,children:h}),t[31]=o,t[32]=m,t[33]=f,t[34]=g,t[35]=h,t[36]=p):p=t[36];let w;t[37]!==l||t[38]!==p||t[39]!==y||t[40]!==b?(w=s.jsxs(l,{className:y,children:[b,p]}),t[37]=l,t[38]=p,t[39]=y,t[40]=b,t[41]=w):w=t[41];let S;return t[42]!==a||t[43]!==w||t[44]!==j||t[45]!==x?(S=s.jsx(a,{open:j,onOpenChange:x,children:w}),t[42]=a,t[43]=w,t[44]=j,t[45]=x,t[46]=S):S=t[46],S};function f0(t){return t.isHelpDialogOpen}function m0(t){return t.setHelpDialogOpen}function h0(t){return t.shortcutOverrides}const p0=()=>{const t=nt.c(32),{t:e}=At(),n=ye(g0),r=ye(b0),i=ye(x0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await Gn(i)).ok){_e.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}_e.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Ls,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==u?(m=s.jsx(_s,{children:u}),t[9]=u,t[10]=m):m=t[10];let f;t[11]!==d||t[12]!==m?(f=s.jsxs(Hs,{children:[d,m]}),t[11]=d,t[12]=m,t[13]=f):f=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let y;t[16]!==l||t[17]!==g?(y=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:g})}),t[16]=l,t[17]=g,t[18]=y):y=t[18];let b;t[19]!==i||t[20]!==e?(b=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=b):b=t[21];let j;t[22]!==b?(j=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:b}),t[22]=b,t[23]=j):j=t[23];let x;t[24]!==f||t[25]!==y||t[26]!==j?(x=s.jsxs(Cs,{className:"max-w-2xl",children:[f,y,j]}),t[24]=f,t[25]=y,t[26]=j,t[27]=x):x=t[27];let h;return t[28]!==n||t[29]!==r||t[30]!==x?(h=s.jsx(ks,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=h):h=t[31],h};function g0(t){return t.isOpenCodeStatusDialogOpen}function b0(t){return t.setOpenCodeStatusDialogOpen}function x0(t){return t.openCodeStatusText}const y0=t=>{const e=nt.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const b=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(b)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let m,f;e[5]!==a||e[6]!==o||e[7]!==i?(m=()=>{if(!a||typeof window>"u")return;const b=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",b),()=>window.removeEventListener("openchamber:sidebar-session-search",b)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=m,e[9]=f):(m=e[8],f=e[9]),c.useEffect(m,f);let g,y;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(g=()=>{if(!a||!r||typeof document>"u")return;const b=j=>{l.current&&(l.current.contains(j.target)||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},y=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=g,e[15]=y):(g=e[14],y=e[15]),c.useEffect(g,y)},w0=t=>{const e=nt.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(v0)),u=[];a.forEach(g=>{const y=d.get(g);y&&(u.push(y),d.delete(g))});const m=[],f=[];return l.forEach(g=>{d.has(g.id)&&(g.isArchivedBucket?f.push(g):m.push(g))}),[...m,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function v0(t){return[t.id,t]}const go="oc.sessions.projectCollapse",Fc="oc.sessions.groupOrder",Lc="oc.sessions.groupCollapse",_c=t=>{if(!t)return new Set;try{const e=Ha(Hn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},S0=t=>{if(!t)return new Map;try{const e=of(Hn(),Ha(Hn())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},j0=t=>{const e=nt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Oo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>_c(o.getItem(go)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>_c(o.getItem(Lc)),e[2]=u):u=e[2];const[m,f]=c.useState(u);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>S0(o.getItem(Fc)),e[3]=g):g=e[3];const[y,b]=c.useState(g),j=c.useRef(0),x=c.useRef(!1),h=c.useRef(!1),p=c.useRef(null),w=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const fe=w.current;if(w.current=null,p.current=null,!fe)return;const{projects:Ne}=zt.getState(),L=Ne.map(oe=>({...oe,sidebarCollapsed:fe.has(oe.id)}));lr({projects:L}).catch(k0)},e[4]=n,e[5]=S):S=e[5];const N=S;let P;e[6]!==N||e[7]!==n?(P=fe=>{!globalThis.window||n||(w.current=fe,p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=P):P=e[8];const C=P;let T,R;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>()=>{globalThis.window&&p.current!==null&&window.clearTimeout(p.current),p.current=null,w.current=null},R=[],e[9]=T,e[10]=R):(T=e[9],R=e[10]),c.useEffect(T,R);let M,F;e[11]!==y?(F=()=>{if(h.current)try{o.setItem(Fc,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},M=[y,o],e[11]=y,e[12]=M,e[13]=F):(M=e[12],F=e[13]),c.useEffect(F,M);let K,D;e[14]!==m?(K=()=>{if(x.current)try{o.setItem(Lc,JSON.stringify(Array.from(m)))}catch{}},D=[m,o],e[14]=m,e[15]=K,e[16]=D):(K=e[15],D=e[16]),c.useEffect(K,D);let U;e[17]!==r||e[18]!==C?(U=()=>{j.current=Date.now()+150,x.current=!0,f(new Set),d(()=>{const fe=new Set(r.map(C0));try{o.setItem(go,JSON.stringify(Array.from(fe)))}catch{}return C(fe),fe})},e[17]=r,e[18]=C,e[19]=U):U=e[19];const A=U;let E;e[20]!==C?(E=()=>{j.current=Date.now()+150,x.current=!0,f(new Set),d(()=>{const fe=new Set;try{o.setItem(go,JSON.stringify([]))}catch{}return C(fe),fe})},e[20]=C,e[21]=E):E=e[21];const W=E;let k;e[22]!==C?(k=fe=>{j.current=Date.now()+150,d(Ne=>{const L=new Set(Ne);L.has(fe)?L.delete(fe):L.add(fe);try{o.setItem(go,JSON.stringify(Array.from(L)))}catch{}return C(L),L})},e[22]=C,e[23]=k):k=e[23];const v=k;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=fe=>{x.current=!0,f(Ne=>{const L=new Set(Ne);return L.has(fe)?L.delete(fe):L.add(fe),L})},e[24]=I):I=e[24];const H=I;let $;e[25]===Symbol.for("react.memo_cache_sentinel")?($=fe=>{h.current=!0,b(fe)},e[25]=$):$=e[25];const re=$,{getOrderedGroups:te}=w0(y);let ee;e[26]!==m||e[27]!==a||e[28]!==y?(ee={collapsedProjects:a,collapsedGroups:m,groupOrderByProject:y},e[26]=m,e[27]=a,e[28]=y,e[29]=ee):ee=e[29];const ue=ee;let de;e[30]!==A||e[31]!==W||e[32]!==te||e[33]!==C||e[34]!==v?(de={setCollapsedProjects:d,toggleProject:v,collapseAllProjects:A,expandAllProjects:W,scheduleCollapsedProjectsPersist:C,setCollapsedGroups:f,toggleGroup:H,setGroupOrderByProject:re,getOrderedGroups:te},e[30]=A,e[31]=W,e[32]=te,e[33]=C,e[34]=v,e[35]=de):de=e[35];const Te=de;let we;return e[36]!==Te||e[37]!==ue?(we={state:ue,actions:Te},e[36]=Te,e[37]=ue,e[38]=we):we=e[38],we};function k0(){}function C0(t){return t.id}const N0=5*6e4,A0=t=>{const e=nt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=gn(),u=Xn(P0);let m,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(m=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(P=>{Gi(()=>u(P.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=m,e[6]=f):(m=e[5],f=e[6]),c.useEffect(m,f);let g,y;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(g=()=>{if(!a)return;const P=new Map;n.forEach(C=>{P.set(C.id,i.get(C.normalizedPath)?.isGitRepo??null)}),o(P)},y=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=g,e[12]=y):(g=e[11],y=e[12]),c.useEffect(g,y);let b;if(e[13]!==i||e[14]!==n){let P;e[16]!==i?(P=C=>{const T=i.get(C.normalizedPath)?.branch??"";return`${C.id}:${T}`},e[16]=i,e[17]=P):P=e[17],b=n.map(P).join("|"),e[13]=i,e[14]=n,e[15]=b}else b=e[15];const j=b;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const h=c.useRef(x);let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const w=c.useRef(p);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let P=!1;const C=setTimeout(()=>{(async()=>{const R=new Set(n.map(D0));for(const A of h.current.keys())R.has(A)||(h.current.delete(A),w.current.delete(A));const M=Date.now(),F=n.filter(A=>{const E=i.get(A.normalizedPath);if(E?.isGitRepo===!1)return h.current.delete(A.id),w.current.delete(A.id),!1;if(E?.isGitRepo!==!0||E.branch===null)return!1;const W=E.branch.trim(),k=`${A.normalizedPath}\0${W}`,v=h.current.get(A.id);if(v===k){const I=w.current.get(A.id);return I&&(I.at=M),!1}return!(v!==void 0&&M-(w.current.get(A.id)?.at??0)<N0)});if(F.length===0)return;const K=await Eg(F,2,async A=>{const E=i.get(A.normalizedPath)?.branch?.trim()??"",W=`${A.normalizedPath}\0${E}`,k=await Gi(()=>Su(A.normalizedPath,E?{knownBranch:E}:void 0)).catch(I0);return{id:A.id,inputKey:W,branch:k}});if(P)return;const D=K.filter(T0);if(D.length===0)return;const U=Date.now();l(A=>{const E=new Map(A);return D.forEach(W=>{const{id:k,branch:v}=W;v&&E.set(k,v)}),E}),D.forEach(A=>{const{id:E,inputKey:W,branch:k}=A;h.current.set(E,W),k&&w.current.set(E,{branch:k,at:U})})})()},150);return()=>{P=!0,clearTimeout(C)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==j||e[29]!==l?(N=[a,n,j,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=j,e[29]=l,e[30]=N):N=e[30],c.useEffect(S,N)};function P0(t){return t.ensureStatus}function D0(t){return t.id}function I0(){return null}function T0(t){return t.branch}const E0=t=>{const e=nt.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Kh,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(Cs,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(bn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(ks,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function R0(t){const e=nt.c(179),{t:n}=At(),r=Ru(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenArchive:u,headerActionIconClass:m,headerActionButtonClass:f,isSessionSearchOpen:g,setIsSessionSearchOpen:y,sessionSearchInputRef:b,sessionSearchQuery:j,setSessionSearchQuery:x,hasSessionSearchQuery:h,searchMatchCount:p,collapseAllProjects:w,expandAllProjects:S}=t,N=es(G0),P=es(H0),C=is(U0),T=is(V0),R=is(K0),M=is(W0),F=is(z0),K=is($0),D=is(_0),U=is(L0),A=is(F0),E=is(B0),W=o&&A==="single",k=o&&D==="timeline";if(i)return null;let v;e[0]!==f?(v=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=f,e[1]=v):v=e[1];let I;e[2]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=I):I=e[3];let H;e[4]!==m?(H=s.jsx(B,{name:"folder-add",className:m}),e[4]=m,e[5]=H):H=e[5];let $;e[6]!==a||e[7]!==v||e[8]!==I||e[9]!==H?($=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:v,"aria-label":I,children:H})}),e[6]=a,e[7]=v,e[8]=I,e[9]=H,e[10]=$):$=e[10];let re;e[11]!==n?(re=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=re):re=e[12];let te;e[13]!==re?(te=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:re})}),e[13]=re,e[14]=te):te=e[14];let ee;e[15]!==$||e[16]!==te?(ee=s.jsxs(vt,{children:[$,te]}),e[15]=$,e[16]=te,e[17]=ee):ee=e[17];let ue;e[18]!==f?(ue=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=f,e[19]=ue):ue=e[19];let de;e[20]!==n?(de=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=de):de=e[21];let Te;e[22]!==m?(Te=s.jsx(B,{name:"calendar-schedule",className:m}),e[22]=m,e[23]=Te):Te=e[23];let we;e[24]!==d||e[25]!==ue||e[26]!==de||e[27]!==Te?(we=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:ue,"aria-label":de,children:Te})}),e[24]=d,e[25]=ue,e[26]=de,e[27]=Te,e[28]=we):we=e[28];let fe;e[29]!==n?(fe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=fe):fe=e[30];let Ne;e[31]!==fe?(Ne=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[31]=fe,e[32]=Ne):Ne=e[32];let L;e[33]!==we||e[34]!==Ne?(L=s.jsxs(vt,{children:[we,Ne]}),e[33]=we,e[34]=Ne,e[35]=L):L=e[35];let oe;e[36]!==f?(oe=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=f,e[37]=oe):oe=e[37];let ce;e[38]!==n?(ce=n("sessions.sidebar.nav.archive"),e[38]=n,e[39]=ce):ce=e[39];let pe;e[40]!==m?(pe=s.jsx(B,{name:"archive",className:m}),e[40]=m,e[41]=pe):pe=e[41];let Y;e[42]!==u||e[43]!==oe||e[44]!==ce||e[45]!==pe?(Y=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:oe,"aria-label":ce,children:pe})}),e[42]=u,e[43]=oe,e[44]=ce,e[45]=pe,e[46]=Y):Y=e[46];let ve;e[47]!==n?(ve=n("sessions.sidebar.nav.archive"),e[47]=n,e[48]=ve):ve=e[48];let Ee;e[49]!==ve?(Ee=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ve})}),e[49]=ve,e[50]=Ee):Ee=e[50];let je;e[51]!==Y||e[52]!==Ee?(je=s.jsxs(vt,{children:[Y,Ee]}),e[51]=Y,e[52]=Ee,e[53]=je):je=e[53];let ge;e[54]!==r||e[55]!==m||e[56]!==n?(ge=r.length>0&&s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx(mt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(B,{name:"apps",className:m})})}),s.jsxs(Ss,{align:"start",children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(O0)]})]}),e[54]=r,e[55]=m,e[56]=n,e[57]=ge):ge=e[57];let be;e[58]!==L||e[59]!==je||e[60]!==ge||e[61]!==ee?(be=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ee,L,je,ge]}),e[58]=L,e[59]=je,e[60]=ge,e[61]=ee,e[62]=be):be=e[62];let Q;e[63]!==y?(Q=()=>y(M0),e[63]=y,e[64]=Q):Q=e[64];let _;e[65]!==f?(_=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[65]=f,e[66]=_):_=e[66];let J;e[67]!==n?(J=n("sessions.sidebar.header.actions.searchSessions"),e[67]=n,e[68]=J):J=e[68];let me;e[69]!==m?(me=s.jsx(B,{name:"search",className:m}),e[69]=m,e[70]=me):me=e[70];let le;e[71]!==g||e[72]!==Q||e[73]!==_||e[74]!==J||e[75]!==me?(le=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Q,className:_,"aria-label":J,"aria-expanded":g,children:me})}),e[71]=g,e[72]=Q,e[73]=_,e[74]=J,e[75]=me,e[76]=le):le=e[76];let V;e[77]!==n?(V=n("sessions.sidebar.header.actions.searchSessions"),e[77]=n,e[78]=V):V=e[78];let Z;e[79]!==V?(Z=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V})}),e[79]=V,e[80]=Z):Z=e[80];let G;e[81]!==le||e[82]!==Z?(G=s.jsxs(vt,{children:[le,Z]}),e[81]=le,e[82]=Z,e[83]=G):G=e[83];const ie=N&&"bg-interactive-hover text-primary";let Se;e[84]!==f||e[85]!==ie?(Se=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent",ie),e[84]=f,e[85]=ie,e[86]=Se):Se=e[86];let se;e[87]!==N||e[88]!==n?(se=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[87]=N,e[88]=n,e[89]=se):se=e[89];let Me;e[90]!==m?(Me=s.jsx(B,{name:"checkbox-multiple",className:m}),e[90]=m,e[91]=Me):Me=e[91];let He;e[92]!==N||e[93]!==Se||e[94]!==se||e[95]!==Me||e[96]!==P?(He=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:P,className:Se,"aria-label":se,"aria-pressed":N,children:Me})}),e[92]=N,e[93]=Se,e[94]=se,e[95]=Me,e[96]=P,e[97]=He):He=e[97];let We;e[98]!==N||e[99]!==n?(We=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[98]=N,e[99]=n,e[100]=We):We=e[100];let Le;e[101]!==We?(Le=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:We})}),e[101]=We,e[102]=Le):Le=e[102];let Ve;e[103]!==He||e[104]!==Le?(Ve=s.jsxs(vt,{children:[He,Le]}),e[103]=He,e[104]=Le,e[105]=Ve):Ve=e[105];let O;e[106]!==f?(O=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[106]=f,e[107]=O):O=e[107];let he;e[108]!==n?(he=n("sessions.sidebar.header.displayMode.label"),e[108]=n,e[109]=he):he=e[109];let $e;e[110]!==m?($e=s.jsx(B,{name:"equalizer-2",className:m}),e[110]=m,e[111]=$e):$e=e[111];let Ue;e[112]!==O||e[113]!==he||e[114]!==$e?(Ue=s.jsx(St,{asChild:!0,children:s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:O,"aria-label":he,children:$e})})}),e[112]=O,e[113]=he,e[114]=$e,e[115]=Ue):Ue=e[115];let ct;e[116]!==n?(ct=n("sessions.sidebar.header.displayMode.label"),e[116]=n,e[117]=ct):ct=e[117];let pt;e[118]!==ct?(pt=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ct})}),e[118]=ct,e[119]=pt):pt=e[119];let it;e[120]!==Ue||e[121]!==pt?(it=s.jsxs(vt,{children:[Ue,pt]}),e[120]=Ue,e[121]=pt,e[122]=it):it=e[122];let ft;e[123]!==U||e[124]!==o||e[125]!==D||e[126]!==n||e[127]!==k?(ft=o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{U(ae),lr({sidebarViewMode:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),D===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),k?null:s.jsx(hs,{})]}):null,e[123]=U,e[124]=o,e[125]=D,e[126]=n,e[127]=k,e[128]=ft):ft=e[128];let yt;e[129]!==A||e[130]!==R||e[131]!==E||e[132]!==M||e[133]!==K||e[134]!==o||e[135]!==n||e[136]!==k||e[137]!==F?(yt=k?null:s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{M(ae),lr({sidebarProjectSortOrder:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),R===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(hs,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{K(ae),lr({sidebarWorktreeSortOrder:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),F===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(hs,{})]}):null,o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{E(ae),lr({sidebarProjectDisplayMode:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),A===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(hs,{})]}):null]}),e[129]=A,e[130]=R,e[131]=E,e[132]=M,e[133]=K,e[134]=o,e[135]=n,e[136]=k,e[137]=F,e[138]=yt):yt=e[138];let ht;e[139]!==W||e[140]!==l||e[141]!==C||e[142]!==n||e[143]!==k||e[144]!==T?(ht=!k&&l&&!W?s.jsxs(_t,{onClick:()=>{T(),lr({sidebarShowRecentSection:!C})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),C?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[139]=W,e[140]=l,e[141]=C,e[142]=n,e[143]=k,e[144]=T,e[145]=ht):ht=e[145];let bt;e[146]!==w||e[147]!==S||e[148]!==W||e[149]!==n||e[150]!==k?(bt=!k&&!W?s.jsxs(s.Fragment,{children:[s.jsx(hs,{}),s.jsxs(_t,{onClick:w,className:"flex items-center gap-2",children:[s.jsx(B,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(_t,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(B,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[146]=w,e[147]=S,e[148]=W,e[149]=n,e[150]=k,e[151]=bt):bt=e[151];let Dt;e[152]!==ft||e[153]!==yt||e[154]!==ht||e[155]!==bt?(Dt=s.jsxs(Ss,{align:"end",className:"min-w-[180px]",children:[ft,yt,ht,bt]}),e[152]=ft,e[153]=yt,e[154]=ht,e[155]=bt,e[156]=Dt):Dt=e[156];let xe;e[157]!==it||e[158]!==Dt?(xe=s.jsxs(js,{children:[it,Dt]}),e[157]=it,e[158]=Dt,e[159]=xe):xe=e[159];let Ye;e[160]!==G||e[161]!==Ve||e[162]!==xe?(Ye=s.jsxs("div",{className:"flex items-center gap-1.5",children:[G,Ve,xe]}),e[160]=G,e[161]=Ve,e[162]=xe,e[163]=Ye):Ye=e[163];let Xe;e[164]!==be||e[165]!==Ye?(Xe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[be,Ye]}),e[164]=be,e[165]=Ye,e[166]=Xe):Xe=e[166];let qe;e[167]!==h||e[168]!==g||e[169]!==p||e[170]!==b||e[171]!==j||e[172]!==y||e[173]!==x||e[174]!==n?(qe=g?s.jsx("div",{className:"pb-1",children:s.jsx(Jd,{inputRef:b,value:j,onSearch:x,onClose:()=>y(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:h?p===1?n("sessions.sidebar.header.search.matchCountSingle",{count:p}):n("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[167]=h,e[168]=g,e[169]=p,e[170]=b,e[171]=j,e[172]=y,e[173]=x,e[174]=n,e[175]=qe):qe=e[175];let dt;return e[176]!==Xe||e[177]!==qe?(dt=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Xe,qe]})}),e[176]=Xe,e[177]=qe,e[178]=dt):dt=e[178],dt}function M0(t){return!t}function O0(t){return s.jsxs(_t,{onSelect:()=>ye.getState().setOpenGuestPage(t.id),children:[s.jsx(Qr,{icon:Mg(t.icon),iconSrc:Rg(t.id,t.icon,zd().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function B0(t){return t.setProjectDisplayMode}function F0(t){return t.projectDisplayMode}function L0(t){return t.setSidebarViewMode}function _0(t){return t.sidebarViewMode}function $0(t){return t.setWorktreeSortOrder}function z0(t){return t.worktreeSortOrder}function W0(t){return t.setProjectSortOrder}function K0(t){return t.projectSortOrder}function V0(t){return t.toggleRecentSection}function U0(t){return t.showRecentSection}function H0(t){return t.toggleMode}function G0(t){return t.enabled}const bo="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function q0(t){const e=nt.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,m=d===void 0?!0:d,{t:f}=At();if(!u&&!m)return null;let g;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(g=u?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:bo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(B,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:bo,"aria-label":f("usageStats.openAction"),children:s.jsx(B,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:bo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(B,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:bo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(B,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=g):g=e[6];let y;e[7]!==l||e[8]!==m||e[9]!==f?(y=m?s.jsx(mt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=m,e[9]=f,e[10]=y):y=e[10];let b;return e[11]!==g||e[12]!==y?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[g,y]}),e[11]=g,e[12]=y,e[13]=b):b=e[13],b}const Y0=t=>{for(const e of t.sessions.values())if(e.tabs.some(Kd))return!0;return!1},Q0=()=>{const t=nt.c(4),{terminal:e}=gn(),n=Et(Y0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=X0,l=J0;if(n)return _i(e,"",l,o);let a=Z0;return a=_i(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function X0(t){const e=Et.getState(),n=Vh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function J0(){return new Map(Et.getState().actionMutationRevisions)}function Z0(){}const ek=t=>{const e=nt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:m,addSessionToFolder:f}=t,g=r===void 0?!0:r;let y,b;e[0]!==f||e[1]!==m||e[2]!==g||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(y=()=>{!g||o||!l||a||n.forEach(j=>{if(d.has(j.normalizedPath))return;const x=Mu(j.normalizedPath),h=i.archivedSessionsByProject.get(j.id)??[],p=u[x]??[],w=new Map(p.map(tk));h.forEach(S=>{const N=Og(S,j.normalizedPath),P=N.toLowerCase();let C=w.get(P);C||(C=m(x,N),w.set(P,C)),C.sessionIds.includes(S.id)||f(x,C.id,S.id)})})},b=[n,g,i,o,l,a,d,u,m,f],e[0]=f,e[1]=m,e[2]=g,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=y,e[11]=b):(y=e[10],b=e[11]),c.useEffect(y,b)};function tk(t){return[t.name.toLowerCase(),t]}function sk({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([m,f])=>m!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const nk=t=>{const e=nt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:m,openNewSessionDraft:f,setSessionSwitcherOpen:g}=t;let y,b;if(e[0]!==n){b=new Map,y=new Map;const P=(C,T,R,M)=>{b.has(C)||b.set(C,new Map);const F=b.get(C);M.forEach(K=>{const D=gt(K.worktree?.path??K.session.directory??R??T);F.set(K.session.id,{directory:D}),y.has(C)||y.set(C,{id:K.session.id,directory:D}),K.children.length>0&&P(C,T,D,K.children)})};n.forEach(C=>{C.groups.forEach(T=>{P(C.project.id,C.project.normalizedPath,T.directory,T.sessions)})}),e[0]=n,e[1]=y,e[2]=b}else y=e[1],b=e[2];let j;e[3]!==y||e[4]!==b?(j={metaByProject:b,firstSessionByProject:y},e[3]=y,e[4]=b,e[5]=j):j=e[5];const x=j,h=c.useRef(null);let p,w;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==m||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==g?(p=()=>{if(!r||u||ye.getState().isNewWorktreeDialogOpen||h.current===r)return;const P=n.find(M=>M.project.id===r);if(!P)return;const C=x.metaByProject.get(r);if(l&&C&&C.has(l)){h.current=r,o(M=>{if(M.get(r)===l)return M;const F=new Map(M);return F.set(r,l),F});return}const T=sk({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:C,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(T.kind==="preserve-current"){a===r&&(h.current=r);return}if(h.current=r,T.kind==="open-draft"){m&&g(!1),f({selectedProjectId:P.project.id,directoryOverride:P.project.normalizedPath});return}if(T.kind!=="select-session")return;const R=C?.get(T.sessionId)?.directory??null;d(T.sessionId,R)},w=[r,i,l,a,d,u,m,f,n,x,g,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=m,e[12]=u,e[13]=f,e[14]=n,e[15]=x,e[16]=o,e[17]=g,e[18]=p,e[19]=w):(p=e[18],w=e[19]),c.useLayoutEffect(p,w);let S,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(S=()=>{if(!r||!l)return;const P=x.metaByProject.get(r);!P||!P.has(l)||o(C=>{if(C.get(r)===l)return C;const T=new Map(C);return T.set(r,l),T})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=S,e[25]=N):(S=e[24],N=e[25]),c.useEffect(S,N)},rk=t=>{const e=nt.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=ot(ok),a=ot(ik);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let m;e[8]!==r?(m=()=>new Map(r),e[8]=r,e[9]=m):m=e[9];const[f,g]=c.useState(m);let y;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(y={...n,activeSessionByProject:f,setActiveSessionByProject:g,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=y):y=e[15],nk(y);let b,j;return e[16]!==f||e[17]!==i?(b=()=>{i(f)},j=[f,i],e[16]=f,e[17]=i,e[18]=b,e[19]=j):(b=e[18],j=e[19]),c.useEffect(b,j),null};function ok(t){return t.currentSessionId}function ik(t){return!!t.newSessionDraft?.open}const ak=t=>{const e=nt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Bn=(t,e)=>`${t}\0${e}`,kn=(t,e)=>t??La(e)??gt(e??null),Gr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??gt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},tl=t=>t.startsWith("__archived__:"),lk=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===n.id:o.isMain}))},$c=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},wr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(wr(n,e))return!0;return!1},ck=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!_a(r),dk=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,uk=(t,e,n)=>{const r=new Map,i=o=>{const l=Is(o.session)??gt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},ga=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Hf=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},Gf=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const g=i.get(u.parentId)??[];g.push(u.id),i.set(u.parentId,g)}const m=new Set;let f=u.id;for(;f;){if(m.has(f)){o.add(u.id);break}m.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const m=r.get(u);if(!m)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&m.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(m.nodeCount>0||!n&&Bo([m.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},zc=new WeakMap;let Wc=1;const fk=t=>{const e=zc.get(t);if(e!==void 0)return e;const n=Wc;return Wc+=1,zc.set(t,n),n},Ko=t=>t.children.length===0?"":t.children.map(n=>{const r=fk(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Ko(n)}`}).join("|"),qf=(t,e,n,r,i,o)=>{const l=qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const m=d.session.directory??i,f=u.session.directory??o,g=Ml(l,m??"",d.session.id),y=Ml(l,f??"",u.session.id);return(g?n.has(g):!1)!==(y?r.has(y):!1)?!0:d.children.some((b,j)=>a(b,u.children[j]))};return a(t,e)},mk=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,hk=(t,e)=>t?t.branchLabel??null:e??null,pk=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=gt(t?.path??null);return n&&r?Yo(r,n):null},Vo=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},xo=t=>"run"in t,gk=(t,e)=>`${t}:active:run:${e}`,Ti=(t,e,n)=>{if(n||e.runKeyBySessionId.size===0)return[...t];const r=[],i=new Map;for(const o of t){const l=e.runKeyBySessionId.get(o.session.id),a=l?e.runs.get(l):void 0;if(!a){r.push(o);continue}const d=i.get(a.key);if(d){d.lanes.push(o);continue}const u={run:a,lanes:[o]};i.set(a.key,u),r.push(u)}for(const o of i.values()){const l=new Map(o.run.memberIds.map((a,d)=>[a,d]));o.lanes.sort((a,d)=>(l.get(a.session.id)??0)-(l.get(d.session.id)??0))}return r},Yf=(t,e)=>{const n=e.trim().toLowerCase(),r=n.startsWith("ses_"),i=o=>o.reduce((l,a)=>l+(!r||a.session.id.toLowerCase()===n?1:0)+i(a.children),0);return i(t)},bk=[],xk=new Set,Kc=32,Vc=64,yk=3,wk=7,yo=32,Rn=28,Uc=(t,e,n,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return $a(t.session,e.session,n,Fa)},wo=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const m=l.node.children[u];m&&o.push({node:m,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},vk=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,Sk=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},jk=t=>{const e=[],n=[],r=[],i=[],o=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),m=t.workSessionIds??xk;let f=0;const y=[...[...t.authoritativeSections.flatMap(A=>A.groups.flatMap(E=>E.sessions)),...t.chatGroup?.sessions??[]]];for(;y.length>0;){const A=y.pop();A&&(l.set(A.session.id,A.session),y.push(...A.children))}const b=A=>{const E=a.get(A)??0;return a.set(A,E+1),E===0?A:`${A}:${E}`},j=A=>{e.push(Object.freeze(A))},x=t.runIndex??Bg,h=(A,E)=>{const W=gk(E.renderContext,A.run.key),k=E.renderContext!=="timeline"&&(d||t.expandedParents.has(W)),v=A.lanes[0]?.session.id,I=v&&E.getSecondaryMeta?E.getSecondaryMeta(v):E.secondaryMeta;j({kind:"run",key:b(`${E.containerKey}:run:${A.run.key}`),estimateSize:E.renderContext==="timeline"?Vc:Kc,run:A.run,laneNodes:Object.freeze([...A.lanes]),projectId:E.projectId,projectLabel:I?.projectLabel??null,groupDirectory:E.groupDirectory,renderContext:E.renderContext,expansionKey:W,expanded:k,forceExpanded:d}),k&&w(A.lanes,1,E)},p=A=>{for(const E of Ti(A.nodes,x,A.archived))xo(E)?h(E,A):w([E],0,A)},w=(A,E,W)=>{const k=[...A].reverse().map(v=>({node:v,depth:E,directory:W.groupDirectory}));for(;k.length>0;){const v=k.pop();if(!v)continue;const I=b(`${W.containerKey}:session:${v.node.session.id}`),H=v.node.session.directory??v.directory;l.set(v.node.session.id,v.node.session),j({kind:"session",key:I,estimateSize:W.renderContext==="timeline"?Vc:Kc,node:v.node,depth:v.depth,projectId:W.projectId,groupDirectory:v.directory,ownerKey:W.ownerKey,selectionScopeKey:W.selectionScopeKey,archived:W.archived,renderContext:W.renderContext,secondaryMeta:W.getSecondaryMeta?W.getSecondaryMeta(v.node.session.id):W.secondaryMeta??null});const $=W.indexedNodes?.subtreeRangeByNode.get(v.node),re=$&&$[1]>$[0]+1?Object.freeze([(W.selectionPoolOffset??0)+$[0]+1,(W.selectionPoolOffset??0)+$[1]]):void 0;if(n.push(Object.freeze({id:v.node.session.id,rowKey:I,scopeKey:W.selectionScopeKey,archived:W.archived,descendantRange:re})),!(!d&&!t.expandedParents.has(vk(W.renderContext,W.archived,v.node.session.id))))for(let te=v.node.children.length-1;te>=0;te-=1){const ee=v.node.children[te];ee&&k.push({node:ee,depth:v.depth+1,directory:H})}}},S=A=>{const E=t.groupSearchDataByGroup.get(A);if(E?.hasMatch!==!0)return 0;const W=m.size>0?E.filteredNodes.filter(v=>m.has(v.session.id)):[];return Math.max(0,E.matchedSessionCount-Yf(W,t.normalizedQuery))+E.folderNameMatchCount+(E.groupMatches?1:0)},N=(A,E,W,k,v)=>{const I=t.groupSearchDataByGroup.get(A);if(d){const se=S(A);if(se===0)return;f+=se}const H=(d?I?.filteredNodes??[]:A.sessions).filter(se=>!m.has(se.session.id)).sort((se,Me)=>Uc(se,Me,u,t.sessionOrderIndex)),$=wo(H),re=r.length;r.push(...$.preorderIds);for(const[se,Me]of $.sessionsById)l.set(se,Me);const te=kn(W,A.directory),ee=!d&&t.collapsedGroups.has(E);if(!k){const se=$.preorderIds.flatMap(Me=>$.sessionsById.get(Me)??[]);j({kind:"group-header",key:`${E}:header`,estimateSize:yo,group:A,groupKey:E,projectId:W,collapsed:ee,forceExpanded:d,allSessions:Object.freeze(se)})}if(ee)return;const ue=Gr(A).flatMap(({scopeKey:se,directory:Me})=>(t.foldersMap[se]??bk).map(He=>({folder:He,scopeKey:se,scopeDirectory:Me,ownerKey:te,nodes:ga(He.sessionIds,$.byId).sort((We,Le)=>Uc(We,Le,u,t.sessionOrderIndex))}))),de=Gf(ue.map(se=>({id:se.folder.id,name:se.folder.name,parentId:se.folder.parentId,nodeCount:se.nodes.length})),{archivedBucket:A.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),Te=ue.filter(se=>de.has(se.folder.id)),we=new Map(Te.map(se=>[Bn(se.scopeKey,se.folder.id),se])),fe=new Map;for(const se of Te){if(!se.folder.parentId)continue;const Me=Bn(se.scopeKey,se.folder.parentId),He=fe.get(Me)??[];He.push(se),fe.set(Me,He)}const Ne=Hf(Te.map(se=>({...se.folder,scopeKey:se.scopeKey}))).map(se=>we.get(Bn(se.scopeKey??"",se.id))).filter(se=>!!se),L=new Set(Te.flatMap(se=>se.folder.sessionIds)),oe=H.filter(se=>!L.has(se.session.id)),ce=new Map,pe=Ne.map(se=>({folder:se,visited:!1})),Y=new Set;for(;pe.length>0;){const se=pe.pop();if(!se)continue;const Me=Bn(se.folder.scopeKey,se.folder.folder.id);if(!se.visited){if(Y.has(Me))continue;Y.add(Me),pe.push({folder:se.folder,visited:!0});for(const We of fe.get(Me)??[])pe.push({folder:We,visited:!1});continue}const He=se.folder.nodes.flatMap(We=>{const Le=$.subtreeRangeByNode.get(We);return Le?$.preorderIds.slice(Le[0],Le[1]).flatMap(Ve=>$.sessionsById.get(Ve)??[]):[We.session]});for(const We of fe.get(Me)??[])He.push(...ce.get(Bn(We.scopeKey,We.folder.id))??[]);ce.set(Me,Object.freeze(He))}const ve=new Set,Ee=(se,Me)=>{const He=Bn(se.scopeKey,se.folder.id);if(ve.has(He))return;ve.add(He);const We=Me?`${Me} / ${se.folder.name}`:se.folder.name,Le=`${E}:folder:${He}`,Ve=!d&&t.collapsedFolders.has(se.folder.id),O=ce.get(He)??[],he=Ve&&!A.isArchivedBucket?ga([...new Set(O.map(ct=>ct.id))],$.byId):[],$e=te?t.folderAuthorityByOwner.get(te):void 0,Ue=!!te&&!A.isArchivedBucket&&!tl(se.scopeKey)&&$e?.complete===!0&&$e.scopeKeys.includes(se.scopeKey);if(j({kind:"folder-header",key:Le,estimateSize:yo,group:A,folder:se.folder,displayName:We,scopeKey:se.scopeKey,scopeDirectory:se.scopeDirectory,ownerKey:te,nodes:se.nodes,activityNodes:he,projectId:W,archived:A.isArchivedBucket===!0,collapsed:Ve,forceExpanded:d,deleteSessions:O,subFolderCount:fe.get(He)?.length??0,dropEnabled:Ue}),te&&o.push(Object.freeze({rowKey:Le,scopeKey:se.scopeKey,folderId:se.folder.id,ownerKey:te,enabled:Ue})),!Ve){p({nodes:se.nodes,containerKey:Le,projectId:W,groupDirectory:se.scopeDirectory??A.directory,ownerKey:te,selectionScopeKey:te,archived:A.isArchivedBucket===!0,renderContext:"project",indexedNodes:$,selectionPoolOffset:re});for(const ct of fe.get(He)??[])Ee(ct,We)}};for(const se of Ne)Ee(se,"");const je=W?t.sessionBatchSize:void 0,ge=v?.initial??je??(t.hideDirectoryControls?10:5),be=v?.increment??je??7,Q=Math.max(ge,t.visibleCountByContainer.get(E)??ge),_=se=>!xo(se)&&v?.pinnedAlwaysVisible===!0&&Ou(u,se.session.directory??A.directory,se.session.id),J=Ti(oe,x,A.isArchivedBucket===!0),me=J.filter(se=>!_(se));let le=Q;const V=A.isArchivedBucket||d?J:J.filter(se=>_(se)?!0:le<=0?!1:(le-=1,!0)),Z=V.flatMap(se=>xo(se)?se.lanes:[se]);p({nodes:Z,containerKey:E,projectId:W,groupDirectory:A.directory,ownerKey:te,selectionScopeKey:te,archived:A.isArchivedBucket===!0,renderContext:v?.renderContext??"project",indexedNodes:$,selectionPoolOffset:re});const G=J.length-V.length,ie=Q-le;!d&&!A.isArchivedBucket&&G>0?j({kind:"show-control",key:`${E}:more`,estimateSize:Rn,control:"more",containerKey:E,currentCount:ie,increment:be}):!d&&!A.isArchivedBucket&&me.length>ge&&G===0&&j({kind:"show-control",key:`${E}:fewer`,estimateSize:Rn,control:"fewer",containerKey:E,currentCount:ie,increment:be});const Se=t.groupStatusByKey.get(E);H.length===0&&Te.length===0?Se&&Se.state!=="ready"?j({kind:"status",key:`${E}:status`,estimateSize:Rn,status:Se,group:A,groupKey:E}):j({kind:"empty",key:`${E}:empty`,estimateSize:Rn,emptyKind:A.isArchivedBucket?"archived":"group",group:A,projectId:W}):Se&&Se.state!=="ready"&&Se.state!=="loading"&&j({kind:"status",key:`${E}:status`,estimateSize:Rn,status:Se,group:A,groupKey:E})},P=A=>{const E=!d&&t.collapsedActivities.has(A),W=e.length;return j({kind:"activity-header",key:`activity:${A}:header`,estimateSize:yo,activityKey:A,collapsed:E,forceExpanded:d}),i.push(Object.freeze({rowIndex:W,kind:"activity",id:A})),E},C=t.viewMode==="timeline",T=A=>"run"in A,R=A=>{const E=Ti(A.map(k=>k.node),x,!1),W=new Map(A.map(k=>[k.node,k]));return E.flatMap(k=>{if(!xo(k)){const v=W.get(k);return v?[v]:[]}return[{run:k.run,items:k.lanes.flatMap(v=>W.get(v)??[])}]})},M=(A,E,W,k)=>{const v=A.items[0];if(!v)return;const I=A.items.map(ee=>ee.node),H=wo(I),$=r.length;r.push(...H.preorderIds);const re=kn(v.projectId,v.groupDirectory),te=new Map(A.items.map(ee=>[ee.node.session.id,ee.getSecondaryMeta?ee.getSecondaryMeta(ee.node.session.id):ee.secondaryMeta]));h({run:A.run,lanes:I},{nodes:I,containerKey:E,projectId:v.projectId,groupDirectory:v.groupDirectory,ownerKey:re,selectionScopeKey:k?re:null,archived:!1,renderContext:W,getSecondaryMeta:ee=>te.get(ee)??null,indexedNodes:H,selectionPoolOffset:$})},F=(A,E,W,k,v=()=>1)=>{for(const I of R(A)){if(T(I)){M(I,E,W,k),d&&(f+=I.items.reduce((ee,ue)=>ee+v(ue),0));continue}const H=I,$=wo([H.node]),re=r.length;r.push(...$.preorderIds);const te=kn(H.projectId,H.groupDirectory);p({nodes:[H.node],containerKey:E,projectId:H.projectId,groupDirectory:H.groupDirectory,ownerKey:te,selectionScopeKey:null,archived:!1,renderContext:W,secondaryMeta:H.secondaryMeta,getSecondaryMeta:H.getSecondaryMeta,indexedNodes:$,selectionPoolOffset:re}),d&&(f+=v(H))}};t.chatGroup&&(!d||S(t.chatGroup)>0)&&(P("chats")||N(t.chatGroup,"activity:chats",null,!0,C?{initial:yk,increment:wk,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0));const K=t.workItems??[];if(K.length>0&&(P("work")||F(K,"activity:work",C?"timeline":"recent",!1,E=>Uh(E.node,t.normalizedQuery))),C){const A=(t.timelineItems??[]).filter(E=>!m.has(E.node.session.id));A.length>0&&(P("timeline")||F(A,"activity:timeline","timeline",!1))}if(!C&&t.showRecentSection)for(const A of t.recentSections){const E={...A,items:A.items.filter(te=>!m.has(te.node.session.id))};if(E.items.length===0||P("active-now"))continue;const k=`activity:${E.key}`,v=7,I=Math.max(v,t.visibleCountByContainer.get(k)??v),H=R(E.items),$=d?H:H.slice(0,I);for(const te of $){if(T(te)){M(te,k,"recent",!0),d&&(f+=te.items.length);continue}const ee=te,ue=wo([ee.node]),de=r.length;r.push(...ue.preorderIds),p({nodes:[ee.node],containerKey:k,projectId:ee.projectId,groupDirectory:ee.groupDirectory,ownerKey:kn(ee.projectId,ee.groupDirectory),selectionScopeKey:kn(ee.projectId,ee.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:ee.secondaryMeta,getSecondaryMeta:ee.getSecondaryMeta,indexedNodes:ue,selectionPoolOffset:de}),d&&(f+=1)}const re=H.length-$.length;!d&&re>0?j({kind:"show-control",key:`${k}:more`,estimateSize:Rn,control:"more",containerKey:k,currentCount:$.length,increment:7}):!d&&H.length>v&&j({kind:"show-control",key:`${k}:fewer`,estimateSize:Rn,control:"fewer",containerKey:k,currentCount:$.length,increment:7})}let D=C?[]:t.singleProjectMode?t.sections.filter(A=>A.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const A=D.find(E=>E.project.id===t.activeProjectId)??D[0];D=A?[A]:[]}for(const A of D){const E=lk(A,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!E.some(k=>S(k.group)>0))continue;const W=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(A.project.id);if(!t.showOnlyMainWorkspace){const k=e.length;j({kind:"project-header",key:`project:${A.project.id}:header`,estimateSize:yo,section:A,collapsed:W,forceExpanded:d}),i.push(Object.freeze({rowIndex:k,kind:"project",id:A.project.id}))}if(!W)for(const k of E)N(k.group,k.groupKey,k.projectId,k.hideGroupLabel)}e.length===0&&j({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const U=new Map;return e.forEach((A,E)=>U.set(A.key,E)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:U,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?f:0})},kk=(t,e)=>t.map(n=>{const r=gt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
878
+ `)},Wv=t=>{const e=nt.c(7),{t:n}=At(),r=ot(Vv),i=ot(Uv),o=Vi(Hv),l=lg(Gv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){_e.error(n("contextPanel.browser.annotate.noSession"));return}let m=!1;if(d.screenshot)try{await l(d.screenshot),m=!0}catch{m=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:zv({payload:d.payload,screenshotAttached:m,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),_e.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Kv=()=>{const t=nt.c(16),{t:e}=At();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Vv(t){return t.currentSessionId}function Uv(t){return t.newSessionDraft?.open}function Hv(t){return t.addDraft}function Gv(t){return t.addAttachedFile}const qv=3e4,Yv=3,Qv=250,Xv={attempts:0,windowStartedAt:null},Jv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=qv,r=n?0:t.attempts;return r>=Yv?null:{delayMs:Qv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Zv=-3,ho=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",fr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},eS=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Bw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,m]=c.useState(!1),[f,g]=c.useState(!1),y=c.useRef(n);y.current=n;const b=c.useRef(Xv);return c.useEffect(()=>{if(!t)return;const j=()=>{try{const M=t.getURL();return ho(M)?M:""}catch{return""}},x=()=>{try{m(t.canGoBack()),g(t.canGoForward())}catch{}},h=M=>{ho(M)&&(l(M),y.current(M))},p=()=>{const M=j();i({kind:"loading",url:M})},w=()=>{const M=j();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),h(M),x(),i(K=>K.kind==="failed"?K:{kind:"ready",url:M,title:F})},S=M=>{const F=fr(M);ho(F.url)&&(h(F.url),x())},N=M=>{const F=fr(M),K=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",D=j();K&&D&&kf.getState().resolve(D,K)},P=M=>{const F=fr(M);typeof F.title=="string"&&d(F.title)},C=M=>{const F=fr(M);if(F.isMainFrame===!1)return;const K=typeof F.errorCode=="number"?F.errorCode:0;K!==Zv&&i({kind:"failed",url:ho(F.validatedURL)?F.validatedURL:j(),code:K,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let T=null;const R=()=>{const M=j(),F=Jv(b.current,Date.now());if(!F){i({kind:"failed",url:M,code:0,description:"",crashed:!0});return}b.current=F.state,i({kind:"loading",url:M}),T=setTimeout(()=>{T=null;try{t.reload()}catch{i({kind:"failed",url:M,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",w),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",P),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",C),t.addEventListener("render-process-gone",R),t.addEventListener("crashed",R);try{!t.isLoading()&&j()&&w()}catch{}return()=>{T!==null&&clearTimeout(T),t.removeEventListener("render-process-gone",R),t.removeEventListener("crashed",R),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",w),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",P),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",C)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},tS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,sS=4e4,po=.5,nS=-3,rS=4,oS="persist:openchamber-browser",Tc=20,iS=600,aS=2e4,lS=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=At(),{currentTheme:i}=qn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(V=>{o.current=V,a(V)},[]),u=ye(V=>V.setContextPanelTabTargetPath),m=c.useRef(gr(t)),f=m.current!==Fs?m.current:"",[g,y]=c.useState(f?null:Fs),[b,j]=c.useState(f),[x,h]=c.useState(!1),[p,w]=c.useState(!1),[S,N]=c.useState(0),P=c.useRef(0),[C,T]=c.useState(!1),[R,M]=c.useState($o),F=c.useRef(R);F.current=R;const K=c.useRef([]),[D,U]=c.useState("system"),[A,E]=c.useState({width:0,height:0}),W=c.useRef(null),k=c.useRef(null),v=c.useRef(!1),I=c.useRef(Date.now()),H=c.useCallback(V=>{!V||V===Fs||!e||!n||u(e,n,V)},[e,n,u]),$=eS(l,{initialUrl:f,onUrlChange:c.useCallback(V=>{const Z=ar(V);j(Z),H(Z)},[H])}),[re,te]=c.useState(null),ee=Wv(e),ue=Kv(),de=$.status.kind==="loading",Te=br(Rf(e)),we=br(V=>V.recordVisit),fe=br(V=>V.forget);c.useEffect(()=>{$.status.kind==="ready"&&we(e,{url:ar($.status.url),title:$.status.title})},[e,$.status,we]);const Ne=c.useMemo(()=>Ef(Te,b),[Te,b]),L=c.useCallback(V=>{const Z=gr(V);Z!==Fs&&(j(Z),te(null),Cc(Z).then(G=>{const ie=o.current;if(!ie){y(G);return}try{ie.loadURL(G)}catch{y(G)}}).catch(G=>{G instanceof Wr&&te(Z)}))},[]);c.useEffect(()=>{if(!f)return;let V=!0;return Cc(f).then(Z=>{V&&y(Z)}).catch(Z=>{if(V){if(Z instanceof Wr){te(f),y(Fs);return}y(f)}}),()=>{V=!1}},[]);const oe=c.useMemo(()=>({executeJavaScript:async(V,Z)=>{const G=o.current;if(!G)throw new Error("Browser view is not available");return G.executeJavaScript(V,Z)},capturePage:async()=>{const V=o.current;if(!V)return null;const Z=V.getWebContentsId();return Number.isFinite(Z)?await hr("desktop_browser_capture_page",{webContentsId:Z}):null}}),[]),ce=c.useCallback(()=>{if(x){h(!1),Io(oe);return}if(!$.url){_e.error(r("contextPanel.browser.annotate.noPage"));return}const V=Qw(i.metadata.variant==="light"?"light":"dark");h(!0),qw({host:oe,theme:V,labels:ue}).then(async Z=>{h(!1),Z&&await ee(Z)}).catch(()=>{h(!1),_e.error(r("contextPanel.browser.annotate.failed"))})},[oe,ee,i,x,$.url,ue,r]);c.useEffect(()=>{if(!x)return;const V=Z=>{cg(Z)||Z.key!=="Escape"||(Z.preventDefault(),Z.stopImmediatePropagation(),h(!1),Io(oe))};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[oe,x]);const pe=c.useCallback(async(V=8e3)=>{const Z=Date.now();for(;;){const G=o.current;if(!G)return!1;let ie=!1;try{ie=G.isLoading()}catch{return!1}if(!ie)return!0;if(Date.now()-Z>V)return!1;await new Promise(Se=>setTimeout(Se,120))}},[]),Y=c.useCallback(async(V,Z)=>{const G=o.current;if(!G)throw new Error("The browser panel is not ready");const ie=()=>{Ic(Z.viewport)&&(M(ma(Z.viewport)),T(!0))};if(V==="browser.back"||V==="browser.forward"){const Le=V==="browser.back";if(!(Le?G.canGoBack():G.canGoForward()))throw new Error(Le?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Le?G.goBack():G.goForward(),await new Promise(he=>setTimeout(he,150)),await pe();let O="";try{O=G.getTitle()||""}catch{O=""}return{url:ar(G.getURL()),title:O}}if(V==="browser.capture"){const Le=ye.getState(),Ve=Fn(e),O=Le.contextPanelByDirectory[Ve],he=!!(O?.isOpen&&O.activeTabId===n);he||Le.setActiveContextPanelTab(e,n);const $e=()=>{if(he||!O)return;const Ue=ye.getState(),ct=Ue.contextPanelByDirectory[Ve];!ct?.isOpen||ct.activeTabId!==n||(O.activeTabId&&O.activeTabId!==n&&Ue.setActiveContextPanelTab(e,O.activeTabId),O.isOpen||Ue.closeContextPanel(e))};try{const Ue=Date.now()+1200;let ct=0,pt=0;for(;pt<2&&Date.now()<Ue;){const yt=G.getBoundingClientRect().width;pt=yt>=2&&Math.abs(yt-ct)<.5?pt+1:0,ct=yt,await new Promise(ht=>setTimeout(ht,50))}await new Promise(yt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>yt()))}),await pe();const it=await oe.capturePage();if(!it)throw new Error("The page could not be captured");let ft="";try{ft=G.getTitle()||""}catch{ft=""}return{...it,url:ar(G.getURL()),title:ft,viewport:mo(F.current)}}finally{$e()}}if(V==="browser.resize"){if(!Ic(Z.viewport))throw new Error("viewport is required");return ie(),await new Promise(Le=>setTimeout(Le,200)),await pe(),{viewport:mo(ma(Z.viewport))}}if(V==="browser.open"){const Le=typeof Z.url=="string"?Z.url:"";if(!Le)throw new Error("url is required");ie(),L(Le),await new Promise(he=>setTimeout(he,150));const Ve=await pe(25e3);let O="";try{O=G.getTitle()||""}catch{O=""}return{url:gr(Le),title:O,opened:!0,settled:Ve,viewport:mo(F.current)}}await pe();const Se=Le=>typeof Le=="string"&&Le?Le:void 0,Me=(()=>{switch(V){case"browser.snapshot":return vv({selector:Se(Z.selector)});case"browser.click":return Sv({selector:Se(Z.selector),text:Se(Z.text)});case"browser.type":return jv({selector:String(Z.selector??""),value:String(Z.value??""),submit:Z.submit===!0});case"browser.inspect":return Nv({selector:String(Z.selector??"")});case"browser.scroll":return kv({selector:Se(Z.selector),direction:Se(Z.direction)});default:return null}})();if(!Me)throw new Error(`Unsupported browser action: ${V}`);const He=await G.executeJavaScript(Me,!0);if(!He||typeof He!="object")throw new Error("The page returned no result");const We=He;if(We.ok!==!0)throw new Error(typeof We.error=="string"&&We.error?We.error:"Browser action failed");if(V==="browser.snapshot"){const Le=K.current;return{...We,viewport:mo(F.current),...Le.length>0?{consoleProblems:[...Le]}:{}}}return(V==="browser.click"||V==="browser.type"&&Z.submit===!0)&&(await new Promise(Le=>setTimeout(Le,150)),await pe()),He},[oe,e,L,n,pe]),ve=c.useCallback(()=>{const V=o.current;if(!V)return{title:"",url:""};let Z="",G="";try{Z=V.getTitle()||""}catch{Z=""}try{G=ar(V.getURL())}catch{G=""}return{title:Z,url:G}},[]);c.useEffect(()=>rv({tabId:n,describe:ve,run:Y}),[ve,Y,n]),c.useEffect(()=>{const V=oe;return()=>{Io(V)}},[oe]),c.useEffect(()=>{if(!l)return;const V=G=>{const ie=G;if(typeof ie.level!="number"||ie.level<2)return;const Se=ie.sourceId?`${ie.sourceId}${ie.line?`:${ie.line}`:""}`:"";K.current.push({level:ie.level>=3?"error":"warning",message:String(ie.message??"").slice(0,400),source:Se}),K.current.length>Tc&&K.current.splice(0,K.current.length-Tc)},Z=()=>{K.current=[]};return l.addEventListener("console-message",V),l.addEventListener("did-start-loading",Z),()=>{l.removeEventListener("console-message",V),l.removeEventListener("did-start-loading",Z)}},[l]);const Ee=c.useRef(new Set),je=c.useCallback(V=>{Ee.current.clear(),L(V)},[L]);c.useEffect(()=>{if(!l)return;const V=G=>{const ie=fr(G),Se=typeof ie.url=="string"?ie.url:"";!Se||!Nc(Se)||(G.preventDefault(),L(Se))},Z=G=>{const ie=fr(G);if(ie.isMainFrame===!1||ie.errorCode===-3)return;const Se=typeof ie.validatedURL=="string"?ie.validatedURL:"";!Se||!Nc(Se)||Ee.current.has(Se)||(Ee.current.add(Se),L(Se))};return l.addEventListener("will-navigate",V),l.addEventListener("did-fail-load",Z),()=>{l.removeEventListener("will-navigate",V),l.removeEventListener("did-fail-load",Z)}},[L,l]),c.useEffect(()=>{if(!l)return;const V=Z=>{const G=Z.detail;Z.preventDefault(),G?.url&&L(G.url)};return l.addEventListener("new-window",V),()=>l.removeEventListener("new-window",V)},[L,l]);const ge=c.useCallback(V=>{const Z=Math.min(rS,Math.max(nS,V));P.current=Z,N(Z);try{o.current?.setZoomLevel(Z)}catch{}},[]);c.useEffect(()=>{const V=Z=>{if(!(Z instanceof CustomEvent))return;const G=Z.detail,ie=o.current;!ie||document.activeElement!==ie||(G==="zoom-in"?ge(P.current+po):G==="zoom-out"?ge(P.current-po):G==="zoom-reset"&&ge(0))};return window.addEventListener("openchamber:zoom",V),()=>window.removeEventListener("openchamber:zoom",V)},[ge]);const be=c.useCallback(V=>{hr("desktop_browser_clear_data",{partition:oS,cookies:V==="cookies",cache:V==="cache"}).then(()=>{_e.success(r(V==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>_e.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const V=W.current;if(!V||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(G=>{const ie=G[0]?.contentRect;ie&&E({width:ie.width,height:ie.height})});return Z.observe(V),()=>Z.disconnect()},[]);const Q=c.useCallback(V=>{U(V);const Z=o.current;if(!Z)return;let G=-1;try{G=Z.getWebContentsId()}catch{return}hr("desktop_browser_set_color_scheme",{webContentsId:G,scheme:V}).catch(ie=>{U("system"),_e.error(ie instanceof Error?ie.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),_=c.useCallback(()=>{try{de?o.current?.stop():o.current?.reload()}catch{}},[de]),J=$.status;c.useEffect(()=>{const V=()=>{w(!0);const ie=setTimeout(()=>{try{o.current?.reload()}catch{}},iS);return()=>clearTimeout(ie)};if(J.kind==="failed"){if(!Pw(J.code,J.url)){w(!1);return}const ie=Date.now(),Se=k.current?.url===J.url?k.current:{url:J.url,startedAt:ie};if(k.current=Se,ie-Se.startedAt>sS){w(!1);return}return V()}if(J.kind==="loading")return;if(k.current=null,J.kind!=="ready"||!J.url||!Sr(J.url)){v.current=!0,w(!1);return}if(v.current||Date.now()-I.current>aS){v.current=!0,w(!1);return}let Z=!1,G=null;return Tw(ar(J.url)).then(ie=>{if(!Z){if(ie===null||ie<500){v.current=!0,w(!1);return}G=V()}}),()=>{Z=!0,G?.()}},[J]);const me=$.status.kind==="failed"&&!p?$.status:null,le=Iv(R,A);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Ff,{address:b,onAddressChange:j,onSubmit:je,suggestions:Ne,onForgetSuggestion:V=>fe(e,V),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:_,onOpenExternal:()=>{Yr($.url||b)},canGoBack:$.canGoBack,canGoForward:$.canGoForward,isLoading:de,onAnnotate:ce,isAnnotating:x,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ge(S+po),onZoomOut:()=>ge(S-po),onZoomReset:()=>ge(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>be("cookies"),onClearCache:()=>be("cache"),onToggleDeviceBar:()=>T(V=>!V),isDeviceBarOpen:C}),C?s.jsx(Rv,{viewport:R,onViewportChange:M,colorScheme:D,onColorSchemeChange:Q,scale:le?.scale??1}):null,s.jsxs("div",{ref:W,className:De("relative min-h-0 flex-1 bg-background",le&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:d,src:g,partition:"persist:openchamber-browser",allowpopups:!0,style:le?{width:`${le.width}px`,height:`${le.height}px`,transform:`scale(${le.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!f&&!$.url&&!de?s.jsx($f,{onOpen:je,directory:e}):null,p?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:re})})]}):null,me&&!re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:me.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:me.crashed?r("contextPanel.browser.crashedHint"):me.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,de?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},cS=t=>{const e=nt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=At(),l=ye(uS);let a;e[0]!==n?(a=gr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==Fs?d:"",[m,f]=c.useState(u),[g,y]=c.useState(u);let b;e[2]!==u?(b=u?[u]:[],e[2]=u,e[3]=b):b=e[3];const[j,x]=c.useState(b),[h,p]=c.useState(u?0:-1),[w,S]=c.useReducer(fS,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=ue=>{!ue||ue===Fs||!r||!i||l(r,i,ue)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const P=N;let C;e[8]!==r?(C=Rf(r),e[8]=r,e[9]=C):C=e[9];const T=br(C),R=br(mS),M=br(hS);let F;e[10]!==m||e[11]!==T?(F=Ef(T,m),e[10]=m,e[11]=T,e[12]=F):F=e[12];const K=F;let D;e[13]!==r||e[14]!==h||e[15]!==P||e[16]!==R?(D=ue=>{const de=gr(ue);de!==Fs&&(f(de),y(de),P(de),R(r,{url:de}),x(Te=>{const we=h>=0?Te.slice(0,h+1):[];return we[we.length-1]===de?(p(we.length-1),we):(p(we.length),[...we,de])}))},e[13]=r,e[14]=h,e[15]=P,e[16]=R,e[17]=D):D=e[17];const U=D;let A;e[18]!==j||e[19]!==P?(A=ue=>{const de=j[ue];de&&(p(ue),f(de),y(de),P(de))},e[18]=j,e[19]=P,e[20]=A):A=e[20];const E=A;let W;e[21]!==r||e[22]!==M?(W=ue=>M(r,ue),e[21]=r,e[22]=M,e[23]=W):W=e[23];let k,v;e[24]!==E||e[25]!==h?(v=()=>E(h-1),k=()=>E(h+1),e[24]=E,e[25]=h,e[26]=k,e[27]=v):(k=e[26],v=e[27]);let I;e[28]!==m||e[29]!==g?(I=()=>{Yr(g||m)},e[28]=m,e[29]=g,e[30]=I):I=e[30];const H=h>0,$=h>=0&&h<j.length-1;let re;e[31]!==m||e[32]!==U||e[33]!==K||e[34]!==k||e[35]!==I||e[36]!==H||e[37]!==$||e[38]!==W||e[39]!==v?(re=s.jsx(Ff,{address:m,onAddressChange:f,onSubmit:U,suggestions:K,onForgetSuggestion:W,onBack:v,onForward:k,onReload:S,onOpenExternal:I,canGoBack:H,canGoForward:$,isLoading:!1}),e[31]=m,e[32]=U,e[33]=K,e[34]=k,e[35]=I,e[36]=H,e[37]=$,e[38]=W,e[39]=v,e[40]=re):re=e[40];let te;e[41]!==g||e[42]!==U||e[43]!==w||e[44]!==o?(te=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${w}`):s.jsx($f,{onOpen:U})}),e[41]=g,e[42]=U,e[43]=w,e[44]=o,e[45]=te):te=e[45];let ee;return e[46]!==re||e[47]!==te?(ee=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[re,te]}),e[46]=re,e[47]=te,e[48]=ee):ee=e[48],ee},dS=t=>{const e=nt.c(3),[n]=c.useState(tS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(lS,{...t}):s.jsx(cS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function uS(t){return t.setContextPanelTabTargetPath}function fS(t){return t+1}function mS(t){return t.recordVisit}function hS(t){return t.forget}const pS=In(()=>en(()=>import("./WalkthroughView-DhvkEmfP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128])).then(t=>({default:t.WalkthroughView}))),gS=In(()=>en(()=>import("./DiffView-rYnmKnFF.js"),__vite__mapDeps([129,1,2,4,5,6,7,8,9,10,84,3,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,130,118,119,120,121,122,131,123,124,125,126,127,128])).then(t=>({default:t.DiffView}))),bS=In(()=>en(()=>import("./FilesView-DtzJk1Ke.js").then(t=>t.F),__vite__mapDeps([132,6,1,2,4,5,7,8,9,10,3,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,133,134,135,136,137,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,138,139,121,122,119,140,126,120,141])).then(t=>({default:t.FilesView}))),xS=In(()=>en(()=>import("./GitView-DYd5gOSc.js"),__vite__mapDeps([142,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,143,131,118,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,88,116,117,119,120,121,122,123,124,125,126,127,128])).then(t=>({default:t.GitView}))),yS=In(()=>en(()=>import("./LinearIssuesView-DDHJKaVb.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.LinearIssuesView}))),wS=In(()=>en(()=>import("./PlanView-CN21khuJ.js"),__vite__mapDeps([145,1,2,4,5,6,7,8,9,10,133,58,59,60,61,62,63,80,56,57,64,134,135,136,3,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,81,82,83,120,141,121,122,107,108,92,93,94,95,96,97,98,99,100,101,102,103,104,105,85,86,87])).then(t=>({default:t.PlanView}))),zf=c.lazy(()=>en(()=>import("./PluginPane-Dx0_Dldo.js").then(t=>t.p),__vite__mapDeps([87,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.PluginPane}))),Wf={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},vS=t=>{const e=nt.c(12),{mode:n,docking:r}=t,[i,o]=c.useState(null),l=Wf[r.dock],a=Math.max(gg,i??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=De("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let m;e[3]!==l.vertical||e[4]!==a?(m=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=m):m=e[5];let f;e[6]!==n?(f=s.jsx(zf,{mode:n,onResize:o}),e[6]=n,e[7]=f):f=e[7];let g;return e[8]!==u||e[9]!==m||e[10]!==f?(g=s.jsx("div",{className:u,style:m,children:f}),e[8]=u,e[9]=m,e[10]=f,e[11]=g):g=e[11],g},Ec=c.lazy(()=>en(()=>import("./GuestSurfacePane-CYMRe3EI.js"),__vite__mapDeps([146,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,87])).then(t=>({default:t.GuestSurfacePane}))),Kf=320,el=600,SS=400,jS=100,kS=24,Wo=new Map,CS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Rc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Kf,Math.round(t))):el,Mc=t=>{const e=t??(typeof window<"u"?window.innerWidth:el*2);return Math.max(Kf,e-SS)},NS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},AS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Vf=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):$n(t)?Ta.getState().guests.find(r=>r.id===Mo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),PS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},DS=(t,e,n)=>{if(t.mode==="chat"){const r=ha(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?Ja(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?PS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Vf(t.mode,n)},IS=t=>{const e=nt.c(8),{mode:n}=t,r=Oa();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=m=>m.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??bg,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Qr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Oc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Ma,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(hf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(B,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(B,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(B,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(B,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(B,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(B,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(B,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(B,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(B,{name:"chat-4",className:"h-3.5 w-3.5"});if($n(t.mode))return s.jsx(IS,{mode:t.mode});if(t.mode==="browser"){const n=TS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(B,{name:"global",className:"h-3.5 w-3.5"})}},TS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},ES=({visible:t,active:e,fill:n=!1})=>{const{t:r}=At(),i=ye(p=>p.contextEditorTreeWidth),o=ye(p=>p.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),m=c.useRef(null),f=c.useRef(null),g=c.useRef(null),y=c.useCallback(p=>{const w=g.current;w&&(w.style.width=`${p}px`,w.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),b=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}f.current=p.pointerId,a(!0),d.current=p.clientX,u.current=i,m.current=i,p.preventDefault()}},j=p=>{if(!l||f.current!==p.pointerId)return;const w=d.current-p.clientX,S=Fi(u.current+w);m.current!==S&&(m.current=S,y(S))},x=p=>{if(f.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const w=Fi(m.current??i);f.current=null,m.current=null,a(!1),o(w)},h=t?i:0;return s.jsxs("div",{ref:g,className:De("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?m.current??h:h}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?m.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:De("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:j,onPointerUp:x,onPointerCancel:x,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:De("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(q1,{visible:t&&e})})]})},ha=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,RS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},MS=(t,e)=>{if(e.length===0)return Wo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Wo:r},OS=(t,e)=>{const n=pg(t),r=c.useRef(Wo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=MS(n.getState().session,i.current);return RS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Wo)},BS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,FS=()=>{const{t}=At(),e=Yn()??"",n=c.useMemo(()=>CS(e),[e]),r=ye(q=>n?q.contextPanelByDirectory[n]:void 0),i=ye(q=>q.closeContextPanel),o=ye(q=>q.closeContextPanelTab),l=ye(q=>q.openContextPanelTab),a=ye(q=>q.toggleContextPanelExpanded),d=ye(q=>q.setContextPanelWidth),u=ye(q=>q.setActiveContextPanelTab),m=ye(q=>q.openAgentBrowserTab);c.useEffect(()=>{if(e)return iv(q=>m(e,q))},[e,m]);const f=ye(q=>q.openContextFile);c.useEffect(()=>Dn(q=>{if(q.type!=="file-open-request")return;const Fe=q.directory??e;Fe&&f(Fe,q.path)}),[e,f]);const g=ye(q=>q.reorderContextPanelTabs),y=Qs(q=>q.setSelectedPath),b=ye(q=>q.contextEditorTreeVisible),j=ye(q=>q.contextEditorTreeWidth),x=ye(q=>q.setContextEditorTreeWidth),h=ye(q=>q.toggleContextEditorTree),p=ye(q=>q.contextEditorVisible),w=ye(q=>q.toggleContextEditor),S=ye(q=>q.openNewContextBrowserTab),N=kf(q=>q.byOrigin),P=ye(q=>q.allowPromptingSubagentSessions),{themeMode:C,setThemeMode:T,lightThemeId:R,darkThemeId:M,currentTheme:F}=qn(),K=c.useMemo(()=>r?.tabs??[],[r?.tabs]),D=K.find(q=>q.id===r?.activeTabId)??K[K.length-1]??null,U=D?.mode==="browser"?D.id:null;c.useEffect(()=>{U&&ov(U)},[U]);const A=!!(r?.isOpen&&D),[E,W]=c.useState(null),k=c.useMemo(()=>K.some(q=>q.mode==="file"&&q.targetPath),[K]),v=k&&(p||!b),I=D?.mode??null,H=I==="file"&&!v,$=!!(A&&r?.expanded&&!H),re=I?r?.widthByMode?.[I]:void 0,te=I?r?.widthFractionByMode?.[I]:void 0,ee=I?dg(I):.5,ue=E??(typeof window<"u"?window.innerWidth:el*2),de=te!=null&&E!=null?Math.round(te*E):re,Te=H?j:Rc(de??Math.round(ee*ue),Mc(E??ue));c.useEffect(()=>{!n||!I||H||te!=null||re==null||E==null||d(n,I,re,E)},[I,E,n,H,re,te,d]);const we=c.useMemo(()=>{const q=[];for(const Fe of K){if(Fe.mode!=="chat")continue;const Ze=ha(Fe.dedupeKey);Ze&&!q.includes(Ze)&&q.push(Ze)}return q},[K]),fe=OS(n||void 0,we),[Ne,L]=c.useState(!1),oe=c.useRef(0),ce=c.useRef(Te),pe=c.useRef(null),Y=c.useRef(null),ve=c.useRef(null),Ee=c.useRef(new Map),je=c.useRef(new Map),ge=c.useRef(!1);c.useLayoutEffect(()=>{const q=ve.current?.parentElement;if(!q||typeof ResizeObserver>"u")return;const Fe=new ResizeObserver(()=>{W(q.clientWidth||null)});return Fe.observe(q),W(q.clientWidth||null),()=>Fe.disconnect()},[]),c.useEffect(()=>{if(!A||ge.current){ge.current=A;return}const q=window.requestAnimationFrame(()=>{ve.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(q)},[A]);const be=c.useRef(null),Q=c.useRef(null),_=c.useCallback(()=>{Q.current=null;const q=ve.current,Fe=pe.current;!q||Fe===null||q.style.setProperty("--oc-context-panel-width",`${Fe}px`)},[]);c.useEffect(()=>()=>{Q.current!==null&&clearTimeout(Q.current)},[]);const J=c.useCallback(q=>{const Fe=be.current,Ze=H?Fi(q):Rc(q,Mc(Fe));return Fe===null?Ze:Math.min(Ze,Math.max(1,Fe))},[H]),me=c.useCallback(q=>{!A||$||!n||(Y.current=q.pointerId,L(!0),oe.current=q.clientX,ce.current=Te,pe.current=Te,be.current=NS(ve.current),document.documentElement.style.cursor="col-resize",q.preventDefault())},[n,$,A,Te]),le=c.useCallback(()=>{const q=J(pe.current??Te),Fe=be.current;pe.current=null,be.current=null,Q.current!==null&&(clearTimeout(Q.current),Q.current=null),document.documentElement.style.cursor="",H?x(q):n&&I&&d(n,I,q,Fe??void 0),L(!1),Y.current=null},[I,J,n,H,x,d,Te]);c.useEffect(()=>{if(!Ne)return;const q=Je=>{if(Y.current!==Je.pointerId)return;const et=oe.current-Je.clientX,kt=J(ce.current+et);pe.current!==kt&&(pe.current=kt,Q.current===null&&(Q.current=setTimeout(_,jS)))},Fe=Je=>{Y.current===Je.pointerId&&le()},Ze=()=>{le()};return window.addEventListener("pointermove",q),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",Ze),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",Ze)}},[_,J,le,Ne]),c.useEffect(()=>{Ne||(pe.current=null,document.documentElement.style.cursor="")},[Ne]);const V=c.useCallback(()=>{n&&i(n)},[i,n]),Z=c.useCallback(()=>{n&&a(n)},[n,a]),G=c.useCallback(q=>{q.key==="Escape"&&(q.target instanceof Node&&!q.currentTarget.contains(q.target)||ug(q.target)||fg(q.target)||(q.preventDefault(),q.stopPropagation(),V()))},[V]);c.useEffect(()=>{if(!(!n||!D)&&D.mode==="file"&&D.targetPath){y(n,D.targetPath,{allowOutsideRoot:!0});return}},[D,n,y]);const ie=c.useMemo(()=>K.filter(q=>q.mode==="chat"),[K]),Se=A&&D?.mode==="chat"?D.id:null,se=A&&D?.mode==="chat"?ha(D.dedupeKey):null,Me=Cx(ie,Se);c.useEffect(()=>{if(!A||!n||!se||typeof window>"u")return;const q=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){wi(n,se,!1);return}Pu(se),wi(n,se,!0)};q();const Fe=window.setInterval(q,1e4);return window.addEventListener("focus",q),window.addEventListener("blur",q),document.addEventListener("visibilitychange",q),()=>{window.clearInterval(Fe),window.removeEventListener("focus",q),window.removeEventListener("blur",q),document.removeEventListener("visibilitychange",q),wi(n,se,!1)}},[se,n,A]);const He=c.useCallback((q,Fe,Ze)=>Nx(je.current,q,Fe,n||null,Ze,{mode:C,lightThemeId:R,darkThemeId:M,currentTheme:F},{allowPromptingSubagentSessions:P}),[P,F,M,n,R,C]),We=Me&&se?He(Me.id,se,Me.readOnly):null;c.useEffect(()=>{const q=new Set(K.map(Fe=>Fe.id));for(const Fe of je.current.keys())q.has(Fe)||je.current.delete(Fe)},[K]);const Le=c.useCallback(q=>{!n||D?.mode!=="diff"||l(n,{mode:"diff",targetPath:D.targetPath,stagedDiff:q==="staged",diffScope:q})},[D,n,l]),Ve=c.useCallback(()=>{if(typeof window>"u")return;const q={themeMode:C,lightThemeId:R,darkThemeId:M,currentTheme:F};for(const Fe of Ee.current.values()){const Ze=Fe.contentWindow;Ze&&Ze.postMessage({type:"openchamber:theme-sync",payload:q},window.location.origin)}},[F,M,R,C]),O=c.useCallback(()=>{if(typeof window>"u")return;const q={allowPromptingSubagentSessions:P};for(const Fe of Ee.current.values()){const Ze=Fe.contentWindow;Ze&&Ze.postMessage({type:"openchamber:chat-settings-sync",payload:q},window.location.origin)}},[P]),he=c.useCallback((q,Fe,Ze)=>{const Je=Fe.contentWindow;Je&&Je.postMessage({type:rf,payload:{visible:Se===q}},Ze)},[Se]),$e=c.useCallback(()=>{if(!(typeof window>"u"))for(const[q,Fe]of Ee.current.entries())he(q,Fe,window.location.origin)},[he]);c.useEffect(()=>{if(typeof window>"u")return;const q=Fe=>{if(Fe.origin!==window.location.origin)return;const Ze=Array.from(Ee.current.entries()).find(([,It])=>It.contentWindow===Fe.source);if(!Ze)return;const Je=Fe.data;if(Je?.type===Ax){const[It,Mt]=Ze;he(It,Mt,Fe.origin);return}if(Je?.type===Px){if(typeof Je.requestId!="string"||!Je.requestId)return;const It=qt(),Mt={apiBaseUrl:hn(),clientToken:Vr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Wd(),relayHostId:It.startsWith("host:")?It.slice(5):"",relay:ih()??void 0};Fe.source?.postMessage({type:Dx,requestId:Je.requestId,payload:Mt},Fe.origin);return}if(Je?.type==="openchamber:theme-sync-request"){Ve();return}if(Je?.type==="openchamber:chat-settings-request"){O();return}if(Je?.type!=="openchamber:cycle-theme-request")return;const et=["light","dark","system"],Qe=(et.indexOf(C)+1)%et.length;T(et[Qe])};return window.addEventListener("message",q),()=>window.removeEventListener("message",q)},[O,he,Ve,T,C]),c.useLayoutEffect(()=>{K.some(Fe=>Fe.mode==="chat")&&(Ve(),O(),$e())},[M,R,O,$e,Ve,K,C]);const Ue=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",ct=c.useMemo(()=>D?K.filter(q=>q.mode===D.mode):[],[D,K]),pt=c.useMemo(()=>ct.map(q=>{const Fe=DS(q,fe,t),Ze=BS(Fe,kS),Je=AS(q.targetPath,e);return{id:q.id,label:Ze,icon:Oc(q,N),title:Je?`${Fe}: ${Je}`:Fe,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ze})}}),[ct,e,N,fe,t]),it=D?.mode==="context"?s.jsx(mw,{}):D?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(xS,{isActive:A})}):D?.mode==="pr"?s.jsx(v1,{}):D?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(yS,{})}):D?.mode==="notes"?s.jsx(Lh,{}):D?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(wS,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,ft=c.useMemo(()=>K.filter(q=>q.mode==="browser"),[K]),yt=c.useMemo(()=>K.filter(q=>q.mode==="diff"),[K]),ht=c.useMemo(()=>K.find(q=>q.mode==="terminal")??null,[K]),bt=c.useMemo(()=>K.some(q=>q.mode==="walkthrough"),[K]),Dt=c.useMemo(()=>K.filter(q=>$n(q.mode)),[K]),xe=Ta(q=>q.guests),Ye=c.useMemo(()=>new Set(xe.filter(mg).map(q=>q.id)),[xe]),Xe=c.useMemo(()=>{const q=new Map;for(const Fe of xe){const Ze=hg(Fe);Ze&&q.set(Fe.id,Ze)}return q},[xe]),qe=c.useMemo(()=>K.some(q=>q.mode==="file"),[K]),dt=D?.mode==="file",X=ye(q=>q.closeContextPanelTabs),ae=c.useCallback(q=>{if(!n)return null;const{id:Fe,index:Ze,allIds:Je,close:et}=q,kt=()=>X(n,Je.filter(Be=>Be!==Fe)),Qe=()=>X(n,Je.slice(0,Ze)),It=()=>X(n,Je.slice(Ze+1)),Mt=()=>X(n,Je),ke=Je.length>1,Oe=Ze===0,Re=Ze===Je.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Ln,{onClick:et,children:[s.jsx(B,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(zi,{}),s.jsxs(Ln,{onClick:kt,disabled:!ke,children:[s.jsx(B,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Ln,{onClick:Qe,disabled:Oe,children:[s.jsx(B,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Ln,{onClick:It,disabled:Re,children:[s.jsx(B,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(zi,{}),s.jsxs(Ln,{onClick:Mt,disabled:!ke,children:[s.jsx(B,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[X,n,t]),Ae=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ue?s.jsx(qd,{items:pt,activeId:D?.id??null,onSelect:q=>{n&&u(n,q)},onClose:q=>{n&&o(n,q)},onReorder:(q,Fe)=>{n&&g(n,q,Fe)},layoutMode:"scrollable",variant:"default",tabContextMenu:ae}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[D?Oc(D,N):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?Vf(D.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?.mode==="browser"?s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(B,{name:"add",className:"h-3.5 w-3.5"})}):null,dt&&k?s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":v,children:s.jsx(B,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,dt?s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(B,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,H?null:s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:Z,className:"h-7 w-7 p-0",title:t($?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t($?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:$?s.jsx(B,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(B,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:V,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(B,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ge=A?$?{"--oc-context-panel-width":E!==null?`${E}px`:"100%",width:E!==null?`${E}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Te}px`}:{"--oc-context-panel-width":`${Te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:ve,"data-context-panel":"true",tabIndex:-1,inert:!A||void 0,className:De("flex min-h-0 flex-col overflow-hidden bg-background",$?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!A&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:G,style:Ge,children:[A&&!$&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),A&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!$&&s.jsx("div",{className:De("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Ne&&"bg-[var(--interactive-border)]"),onPointerDown:me,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:De("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!A&&"pointer-events-none select-none opacity-0"),style:{width:$?E!==null?`${E}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!A,children:[Ae,s.jsxs("div",{className:De("relative min-h-0 flex-1 overflow-hidden",Ne&&"pointer-events-none"),children:[qe?s.jsxs("div",{className:De("absolute inset-0 flex",dt?"flex":"hidden"),children:[k||!b?s.jsx("div",{className:De("h-full min-w-0 flex-1",k&&!v&&"hidden"),children:k?s.jsx(c.Suspense,{fallback:null,children:s.jsx(bS,{mode:"editor-only",visible:A&&dt&&v})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(B,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(ES,{visible:b,active:A&&dt,fill:!v})]}):null,Me&&se&&We?s.jsx("iframe",{ref:q=>{if(!q){Ee.current.delete(Me.id);return}Ee.current.set(Me.id,q)},src:We,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:se}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Ve(),O(),$e()}},Me.id):null,ft.map(q=>s.jsx("div",{className:De("absolute inset-0",D?.id!==q.id&&"invisible pointer-events-none"),"aria-hidden":D?.id!==q.id||void 0,children:s.jsx(dS,{initialUrl:q.targetPath??"",directory:n,tabID:q.id})},q.id)),yt.map(q=>s.jsx("div",{className:De("absolute inset-0",D?.id!==q.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(gS,{visible:A&&D?.id===q.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:q.diffScope??(q.stagedDiff?"staged":"working"),onDiffScopeChange:Le,targetFilePath:q.targetPath,flushContent:!0})})},q.id)),ht?s.jsx("div",{className:De("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:s.jsx(_h,{visible:A&&D?.mode==="terminal",directory:ht.targetDirectory})}):null,bt?s.jsx("div",{className:De("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(pS,{directory:e,visible:A&&D?.mode==="walkthrough"})})}):null,Dt.map(q=>{if(!$n(q.mode))return null;const Fe=Mo(q.mode),Ze=Ye.has(Fe),Je=Xe.get(Fe),et=D?.id===q.id,kt=et&&A;return Ze&&!Je&&!kt?null:s.jsx("div",{className:De("absolute inset-0",et?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ze?Je?s.jsxs("div",{className:De("flex h-full",Wf[Je.dock].container),children:[s.jsx(vS,{mode:q.mode,docking:Je}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:kt?s.jsx(Ec,{mode:q.mode}):null})]}):s.jsx(Ec,{mode:q.mode}):s.jsx(zf,{mode:q.mode})})},q.id)}),D?.mode!=="chat"&&!dt&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"&&!(D&&$n(D.mode))?it:null]})]})]})},LS=t=>{const e=nt.c(43),{open:n,onOpenChange:r}=t,{t:i}=At(),o=ye(_S),l=ye($S),a=ye(zS),d=ye(WS),u=Oa();let m;e[0]!==o||e[1]!==u?(m=Du(o,u),e[0]=o,e[1]=u,e[2]=m):m=e[2];const f=m,g=l.length===0;let y;if(e[3]!==l||e[4]!==f){let R;e[6]!==l?(R=M=>l.includes(M.id),e[6]=l,e[7]=R):R=e[7],y=f.every(R),e[3]=l,e[4]=f,e[5]=y}else y=e[5];const b=y;let j;e[8]!==i?(j=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=j):j=e[9];let x;e[10]!==j?(x=s.jsx(Ls,{children:j}),e[10]=j,e[11]=x):x=e[11];let h;e[12]!==i?(h=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=h):h=e[13];let p;e[14]!==h?(p=s.jsx(_s,{children:h}),e[14]=h,e[15]=p):p=e[15];let w;e[16]!==x||e[17]!==p?(w=s.jsxs(Hs,{children:[x,p]}),e[16]=x,e[17]=p,e[18]=w):w=e[18];let S;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let R;e[24]!==l||e[25]!==a||e[26]!==i?(R=M=>s.jsx(xg,{settingsItem:`layout.context-rail.surface.${M.id}`,checked:!l.includes(M.id),onChange:F=>a(M.id,F),label:M.label??i(M.labelKey),ariaLabel:M.label??i(M.labelKey)},M.id),e[24]=l,e[25]=a,e[26]=i,e[27]=R):R=e[27],S=f.map(R),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=S}else S=e[23];let N;e[28]!==S?(N=s.jsx("div",{className:"flex flex-col",children:S}),e[28]=S,e[29]=N):N=e[29];let P;e[30]!==g||e[31]!==b||e[32]!==d||e[33]!==i?(P=g?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(mt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=g,e[31]=b,e[32]=d,e[33]=i,e[34]=P):P=e[34];let C;e[35]!==P||e[36]!==w||e[37]!==N?(C=s.jsxs(Cs,{className:"max-w-md",children:[w,N,P]}),e[35]=P,e[36]=w,e[37]=N,e[38]=C):C=e[38];let T;return e[39]!==r||e[40]!==n||e[41]!==C?(T=s.jsx(ks,{open:n,onOpenChange:r,children:C}),e[39]=r,e[40]=n,e[41]=C,e[42]=T):T=e[42],T};function _S(t){return t.contextRailOrder}function $S(t){return t.contextRailHiddenSurfaces}function zS(t){return t.setContextRailSurfaceVisible}function WS(t){return t.setContextRailHiddenSurfaces}const Uf=150,KS=500,VS=[],US=t=>t>99?"99+":String(t),HS=t=>{const e=nt.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:m,showOrderNumber:f,onSelect:g}=t;let y;e[0]!==n.id?(y={id:n.id},e[0]=n.id,e[1]=y):y=e[1];const{attributes:b,listeners:j,setNodeRef:x,transform:h,transition:p,isDragging:w}=ri(y);let S;e[2]!==a?(S=a!=null&&a>0?US(a):null,e[2]=a,e[3]=S):S=e[3];const N=S;let P;e[4]!==h?(P=oi.Translate.toString(h),e[4]=h,e[5]=P):P=e[5];let C;e[6]!==P||e[7]!==p?(C={transform:P,transition:p},e[6]=P,e[7]=p,e[8]=C):C=e[8];const T=w&&"z-10 opacity-70";let R;e[9]!==T?(R=De("relative",T),e[9]=T,e[10]=R):R=e[10];let M;e[11]!==g||e[12]!==n?(M=()=>g(n),e[11]=g,e[12]=n,e[13]=M):M=e[13];const F=d??o,K=r?"text-primary":"text-muted-foreground hover:text-foreground";let D;e[14]!==K?(D=De("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",K),e[14]=K,e[15]=D):D=e[15];let U;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(U=n.id==="diff"?s.jsx(hf,{className:"h-[18px] w-[18px]"}):s.jsx(Qr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=U):U=e[19];let A;e[20]!==N||e[21]!==m||e[22]!==i||e[23]!==f?(A=f&&m!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:m===10?"0":m}):N?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:N}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=N,e[21]=m,e[22]=i,e[23]=f,e[24]=A):A=e[24];let E;e[25]!==b||e[26]!==r||e[27]!==j||e[28]!==D||e[29]!==U||e[30]!==A||e[31]!==M||e[32]!==F?(E=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...b,...j,onClick:M,"aria-label":F,"aria-pressed":r,className:D,children:[U,A]})}),e[25]=b,e[26]=r,e[27]=j,e[28]=D,e[29]=U,e[30]=A,e[31]=M,e[32]=F,e[33]=E):E=e[33];let W;e[34]!==o?(W=s.jsx("span",{children:o}),e[34]=o,e[35]=W):W=e[35];let k;e[36]!==l?(k=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=k):k=e[37];let v;e[38]!==u?(v=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=v):v=e[39];let I;e[40]!==W||e[41]!==k||e[42]!==v?(I=s.jsx(jt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[W,k,v]})}),e[40]=W,e[41]=k,e[42]=v,e[43]=I):I=e[43];let H;e[44]!==E||e[45]!==I?(H=s.jsxs(vt,{delayDuration:Uf,children:[E,I]}),e[44]=E,e[45]=I,e[46]=H):H=e[46];let $;return e[47]!==x||e[48]!==H||e[49]!==C||e[50]!==R?($=s.jsx("div",{ref:x,style:C,className:R,children:H}),e[47]=x,e[48]=H,e[49]=C,e[50]=R,e[51]=$):$=e[51],$},GS=()=>{const t=nt.c(92),{t:e}=At(),n=Yn();let r;t[0]!==n?(r=n?Fn(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=ye(o),a=ye(qS),d=ye(YS),u=ye(QS),m=ye(XS),f=ye(JS),g=ye(ZS),y=ye(ej),b=Ea(tj),j=Ui(sj),x=Ui(nj),h=pn(rj),p=pn(oj),{screenWidth:w}=Pn(),S=Ra(i||null);let N;t[4]!==y?(N=Hi("switch_context_surface",y),t[4]=y,t[5]=N):N=t[5];const P=N,[C,T]=c.useState(!1);let R,M;t[6]!==P?(R=()=>{const le=new Set;let V=null,Z=!1;const G=ij,ie=()=>{Rl(P,le)?!Z&&V===null&&(V=setTimeout(()=>T(!0),KS)):(Z=!1,V!==null&&(clearTimeout(V),V=null),T(!1))},Se=He=>{if(le.add(He.key.toLowerCase()),G(He.key)&&Rl(P,le)){Z=!0,V!==null&&(clearTimeout(V),V=null),T(!1);return}ie()},se=He=>{le.delete(He.key.toLowerCase()),ie()},Me=()=>{le.clear(),Z=!1,V!==null&&(clearTimeout(V),V=null),T(!1)};return window.addEventListener("keydown",Se,!0),window.addEventListener("keyup",se,!0),window.addEventListener("blur",Me),()=>{window.removeEventListener("keydown",Se,!0),window.removeEventListener("keyup",se,!0),window.removeEventListener("blur",Me),V!==null&&clearTimeout(V)}},M=[P],t[6]=P,t[7]=R,t[8]=M):(R=t[7],M=t[8]),c.useEffect(R,M);let F;t[9]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},t[9]=F):F=t[9];let K;t[10]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{delay:200,tolerance:6}},t[10]=K):K=t[10];const D=Zo(fn(ti,F),fn(ei,K)),U=Oa(),A=El(aj),E=El(lj),W=l?.tabs??VS;let k;t[11]!==l?.activeTabId||t[12]!==W?(k=W.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=W,t[13]=k):k=t[13];const v=k,I=l?.isOpen?v?.mode??null:null,H=S?.files.length??0;let $;t[14]!==u||t[15]!==d||t[16]!==p||t[17]!==U||t[18]!==x||t[19]!==b||t[20]!==w||t[21]!==W?($=yg({railOrder:d,hiddenSurfaces:u,planModeEnabled:b,isVSCode:An(),screenWidth:w,tabs:W,linearConnected:x,githubConnected:p,extras:U}),t[14]=u,t[15]=d,t[16]=p,t[17]=U,t[18]=x,t[19]=b,t[20]=w,t[21]=W,t[22]=$):$=t[22];const re=$;let te,ee;t[23]!==I||t[24]!==g||t[25]!==i||t[26]!==j||t[27]!==x?(ee=()=>{!i||!j||x||I!=="linear"||g(i)},te=[I,g,i,j,x],t[23]=I,t[24]=g,t[25]=i,t[26]=j,t[27]=x,t[28]=te,t[29]=ee):(te=t[28],ee=t[29]),c.useEffect(ee,te);let ue,de;t[30]!==I||t[31]!==g||t[32]!==i||t[33]!==h||t[34]!==p?(ue=()=>{!i||!h||p||I!=="pr"||g(i)},de=[I,g,i,h,p],t[30]=I,t[31]=g,t[32]=i,t[33]=h,t[34]=p,t[35]=ue,t[36]=de):(ue=t[35],de=t[36]),c.useEffect(ue,de);const[Te,we]=c.useState(!1);let fe;t[37]!==U||t[38]!==m?(fe=le=>{const{active:V,over:Z}=le;if(!Z||V.id===Z.id)return;const G=Du(ye.getState().contextRailOrder,U).map(cj),ie=G.indexOf(V.id),Se=G.indexOf(Z.id);ie===-1||Se===-1||m(Ju(G,ie,Se))},t[37]=U,t[38]=m,t[39]=fe):fe=t[39];const Ne=fe;if(!i)return null;let L;t[40]!==e?(L=e("contextRail.aria.rail"),t[40]=e,t[41]=L):L=t[41];let oe;t[42]!==re?(oe=re.map(dj),t[42]=re,t[43]=oe):oe=t[43];let ce;if(t[44]!==I||t[45]!==H||t[46]!==E||t[47]!==i||t[48]!==A||t[49]!==f||t[50]!==C||t[51]!==re||t[52]!==e||t[53]!==a){let le;t[55]!==I||t[56]!==H||t[57]!==E||t[58]!==i||t[59]!==A||t[60]!==f||t[61]!==C||t[62]!==e||t[63]!==a?(le=(V,Z)=>{const G=V.label??e(V.labelKey),ie=V.id==="git"&&!a?H:0,Se=$n(V.mode)&&I!==V.mode?A[Mo(V.mode)]??0:0,se=ie>0?ie:Se>0?Se:null,Me=se!==null&&ie===0;return s.jsx(HS,{surface:V,isActive:I===V.mode,showActivityDot:!1,label:G,description:e(V.descriptionKey),badgeCount:se,badgeAriaLabel:se!==null?e(Me?se===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":se===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:G,count:se}):null,badgeDescription:se!==null?e(Me?se===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":se===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:se}):null,orderNumber:Z+1,showOrderNumber:C,onSelect:He=>{$n(He.mode)&&E(Mo(He.mode)),f(i,He.mode)}},V.id)},t[55]=I,t[56]=H,t[57]=E,t[58]=i,t[59]=A,t[60]=f,t[61]=C,t[62]=e,t[63]=a,t[64]=le):le=t[64],ce=re.map(le),t[44]=I,t[45]=H,t[46]=E,t[47]=i,t[48]=A,t[49]=f,t[50]=C,t[51]=re,t[52]=e,t[53]=a,t[54]=ce}else ce=t[54];let pe;t[65]!==oe||t[66]!==ce?(pe=s.jsx(Ua,{items:oe,strategy:Zu,children:ce}),t[65]=oe,t[66]=ce,t[67]=pe):pe=t[67];let Y;t[68]!==Ne||t[69]!==D||t[70]!==pe?(Y=s.jsx(si,{sensors:D,collisionDetection:ni,onDragEnd:Ne,children:pe}),t[68]=Ne,t[69]=D,t[70]=pe,t[71]=Y):Y=t[71];let ve;t[72]!==e?(ve=e("contextRail.configure.open"),t[72]=e,t[73]=ve):ve=t[73];let Ee;t[74]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>we(!0),t[74]=Ee):Ee=t[74];let je;t[75]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(B,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=je):je=t[75];let ge;t[76]!==ve?(ge=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":ve,onClick:Ee,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:je})}),t[76]=ve,t[77]=ge):ge=t[77];let be;t[78]!==e?(be=e("contextRail.configure.open"),t[78]=e,t[79]=be):be=t[79];let Q;t[80]!==be?(Q=s.jsx(jt,{side:"left",sideOffset:8,children:be}),t[80]=be,t[81]=Q):Q=t[81];let _;t[82]!==ge||t[83]!==Q?(_=s.jsxs(vt,{delayDuration:Uf,children:[ge,Q]}),t[82]=ge,t[83]=Q,t[84]=_):_=t[84];let J;t[85]!==Te?(J=s.jsx(LS,{open:Te,onOpenChange:we}),t[85]=Te,t[86]=J):J=t[86];let me;return t[87]!==L||t[88]!==Y||t[89]!==_||t[90]!==J?(me=s.jsxs("nav",{"aria-label":L,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[Y,_,J]}),t[87]=L,t[88]=Y,t[89]=_,t[90]=J,t[91]=me):me=t[91],me};function qS(t){return t.workStatusPanelVisible}function YS(t){return t.contextRailOrder}function QS(t){return t.contextRailHiddenSurfaces}function XS(t){return t.setContextRailOrder}function JS(t){return t.openContextSurface}function ZS(t){return t.closeContextPanel}function ej(t){return t.shortcutOverrides}function tj(t){return t.planModeEnabled}function sj(t){return t.hasChecked}function nj(t){return t.status?.connected===!0}function rj(t){return t.hasChecked}function oj(t){return t.status?.connected===!0}function ij(t){return t.length===1&&t>="0"&&t<="9"}function aj(t){return t.countByGuest}function lj(t){return t.clearBadge}function cj(t){return t.id}function dj(t){return t.id}const uj=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),fj=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Rr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),mj=new Set,hj=[],pa=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},pj=()=>{const t=nt.c(182),{t:e}=At(),n=ye(gj),r=ye(bj),i=ye(xj),o=ye(yj),l=ye(wj),a=ye(vj),d=ye(Sj),u=ye(jj),m=ye(kj),f=ye(Cj),g=ye(Nj),y=ye(Aj),b=ot(Pj),j=ot(Dj),x=ot(Ij),h=Ur(Tj);let p;t[0]!==n?(p=Re=>n?Re.activeSessions:hj,t[0]=n,t[1]=p):p=t[1];const w=ps(p);let S;t[2]!==n?(S=Re=>n?Re.ids:mj,t[2]=n,t[3]=S):S=t[3];const N=Ur(S);let P;t[4]!==n?(P=Re=>n?Re.rankById:Fa,t[4]=n,t[5]=P):P=t[5];const C=Ba(P),T=Zt(Ej),R=zt(Rj),M=zt(Mj),F=Yn(),K=$d(Oj),{files:D,git:U}=gn(),A=Xn(Bj),{isMobile:E}=Pn();let W;t[6]!==F?(W=F?pa(F):null,t[6]=F,t[7]=W):W=t[7];const k=W,[v,I]=c.useState(""),$=Cu(v,200).trim();let re;t[8]!==v?(re=v.trim(),t[8]=v,t[9]=re):re=t[9];const te=re;let ee,ue;t[10]!==n?(ee=()=>{n&&I("")},ue=[n],t[10]=n,t[11]=ee,t[12]=ue):(ee=t[11],ue=t[12]),c.useEffect(ee,ue);let de,Te;t[13]!==w||t[14]!==A||t[15]!==U||t[16]!==n?(de=()=>{if(!n||!U)return;const Re=setTimeout(()=>{const Be=new Set;for(const Ke of w){const rt=Is(Ke);!rt||Be.has(rt)||(Be.add(rt),A(rt,U))}},0);return()=>clearTimeout(Re)},Te=[n,w,U,A],t[13]=w,t[14]=A,t[15]=U,t[16]=n,t[17]=de,t[18]=Te):(de=t[17],Te=t[18]),c.useEffect(de,Te);let we;t[19]!==r?(we=()=>r(!1),t[19]=r,t[20]=we):we=t[20];const fe=we;let Ne;t[21]!==fe?(Ne=Re=>()=>{fe(),Re()},t[21]=fe,t[22]=Ne):Ne=t[22];const L=Ne;let oe;t[23]!==R?.id||t[24]!==R?.path||t[25]!==T||t[26]!==x||t[27]!==E||t[28]!==d||t[29]!==u||t[30]!==b||t[31]!==L||t[32]!==g||t[33]!==y||t[34]!==l||t[35]!==i||t[36]!==e||t[37]!==h||t[38]!==a?(oe=()=>{const Re=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(B,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:L(()=>{l(!1),b()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(B,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:L(Fj)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(B,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:L(Lj)},{id:"toggle-sidebar",title:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(B,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:L(()=>{if(E){const{isSessionSwitcherOpen:Be}=ye.getState();l(!Be)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(B,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:L(()=>{T&&u(T,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(B,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:L(()=>{T&&d(T)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(B,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:L(_j)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(B,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:L($j)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(B,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:L(()=>i(!0))}];return Re.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(B,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:L(()=>{x&&T&&h({directory:T,sessionId:x})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(B,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:L(()=>{x&&Gn(x).then(Be=>{if(Be.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(B,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:L(()=>{l(!1),kg()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(B,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:L(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(B,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:L(()=>{T&&(y("notes"),u(T,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(B,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:L(()=>{T&&(y("todos"),u(T,"notes"))})}),An()||Re.push({id:"restart-opencode",secondary:!0,title:e("commandPalette.item.restartOpenCode"),icon:s.jsx(B,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.restartOpenCode"),onSelect:L(()=>{zh(e)})}),Re.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(B,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:L(zj)}),Kr()&&Re.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(B,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:L(()=>{Nn("desktop_open_draft_mini_chat_window",{directory:pa(T||R?.path||""),projectId:R?.id??null}).catch(Wj)})}),Re},t[23]=R?.id,t[24]=R?.path,t[25]=T,t[26]=x,t[27]=E,t[28]=d,t[29]=u,t[30]=b,t[31]=L,t[32]=g,t[33]=y,t[34]=l,t[35]=i,t[36]=e,t[37]=h,t[38]=a,t[39]=oe):oe=t[39],R?.id,R?.path;let ce;t[40]!==oe?(ce=oe(),t[40]=oe,t[41]=ce):ce=t[41];const pe=ce,Y=ye(Kj);let ve;t[42]===Symbol.for("react.memo_cache_sentinel")?(ve=mn(),t[42]=ve):ve=t[42];const Ee=ve;let je,ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(je=An(),ge=!Ee&&Pa(),t[43]=je,t[44]=ge):(je=t[43],ge=t[44]);let be;t[45]!==E||t[46]!==Y?(be={isVSCode:je,isWeb:ge,isDesktop:Ee,isMobile:E,routingAvailable:Y},t[45]=E,t[46]=Y,t[47]=be):be=t[47];const Q=be;let _;if(t[48]!==L||t[49]!==i||t[50]!==o||t[51]!==Q){let Re;t[53]!==Q?(Re=Ke=>Ke.isAvailable?Ke.isAvailable(Q):!0,t[53]=Q,t[54]=Re):Re=t[54];let Be;t[55]!==L||t[56]!==i||t[57]!==o?(Be=Ke=>{const rt=Wh(Ke.slug)??"settings-3",xt=(Ke.keywords??[]).join(" ");return{id:`settings:${Ke.slug}`,title:Ke.title,icon:Ke.slug==="mcp"?s.jsx(Cg,{className:"mr-2 h-4 w-4"}):s.jsx(B,{name:rt,className:"mr-2 h-4 w-4"}),searchText:`${Ke.title} ${Ke.group} ${xt}`,onSelect:L(()=>{o(Ke.slug),i(!0)})}},t[55]=L,t[56]=i,t[57]=o,t[58]=Be):Be=t[58],_=$h.filter(Vj).filter(Re).map(Be),t[48]=L,t[49]=i,t[50]=o,t[51]=Q,t[52]=_}else _=t[52];const J=_;let me;if(t[59]!==w||t[60]!==N||t[61]!==C){const Re=w.filter(Uj);me=wg(Re,N,C),t[59]=w,t[60]=N,t[61]=C,t[62]=me}else me=t[62];const le=me,V=Iu(),Z=ot(Hj);let G;t[63]!==V||t[64]!==Z?(G=(Re,Be)=>{const Ke=Z.get(Re);return Ke?.branch?Ke.branch.trim()||null:Be&&V.get(Be)?.trim()||null},t[63]=V,t[64]=Z,t[65]=G):G=t[65];const ie=G;let Se;t[66]===Symbol.for("react.memo_cache_sentinel")?(Se=[],t[66]=Se):Se=t[66];const[se,Me]=c.useState(Se),[He,We]=c.useState(""),Le=uj(k,$);let Ve;t[67]!==k||t[68]!==Le||t[69]!==n||t[70]!==K||t[71]!==Me||t[72]!==We||t[73]!==$?(Ve=()=>{if(!n){Me([]),We("");return}if(!Le){Me([]),We("");return}if(!k){Me([]),We("");return}let Re=!1;return K(k,$,40,{type:"file"}).then(Be=>{Re||(Me(Be.map(Gj)),We(Le))}).catch(()=>{Re||(Me([]),We(Le))}),()=>{Re=!0}},t[67]=k,t[68]=Le,t[69]=n,t[70]=K,t[71]=Me,t[72]=We,t[73]=$,t[74]=Ve):Ve=t[74];let O;t[75]!==k||t[76]!==Le||t[77]!==n||t[78]!==K||t[79]!==$?(O=[n,k,$,Le,K],t[75]=k,t[76]=Le,t[77]=n,t[78]=K,t[79]=$,t[80]=O):O=t[80],c.useEffect(Ve,O);const he=te.length>0;let $e;e:{if(!he){let Be;t[81]!==pe?(Be=pe.filter(qj).map(Yj),t[81]=pe,t[82]=Be):Be=t[82],$e=Be;break e}let Re;t[83]!==pe||t[84]!==te?(Re=Rr(pe,te,Qj,{limit:7,noFuzzy:!0}),t[83]=pe,t[84]=te,t[85]=Re):Re=t[85],$e=Re}const Ue=$e;let ct;e:{if(!he){let Be;t[86]===Symbol.for("react.memo_cache_sentinel")?(Be=[],t[86]=Be):Be=t[86],ct=Be;break e}let Re;t[87]!==te||t[88]!==J?(Re=Rr(J,te,Xj,{limit:7,noFuzzy:!0}),t[87]=te,t[88]=J,t[89]=Re):Re=t[89],ct=Re}const pt=ct;let it;e:{if(!he){let Be;t[90]!==le?(Be=le.slice(0,5).map(Jj),t[90]=le,t[91]=Be):Be=t[91],it=Be;break e}let Re;t[92]!==te||t[93]!==le?(Re=Rr(le,te,Zj,{limit:7,threshold:.2}),t[92]=te,t[93]=le,t[94]=Re):Re=t[94],it=Re}const ft=it;let yt;e:{if(!n){let Be;t[95]===Symbol.for("react.memo_cache_sentinel")?(Be=[],t[95]=Be):Be=t[95],yt=Be;break e}let Re;t[96]!==se||t[97]!==He||t[98]!==Le||t[99]!==$?(Re=fj(se,$,Le,He),t[96]=se,t[97]=He,t[98]=Le,t[99]=$,t[100]=Re):Re=t[100],yt=Re}const ht=yt,bt=n&&Le.length>0&&He!==Le;let Dt;e:{if(!he){let Be;t[101]===Symbol.for("react.memo_cache_sentinel")?(Be=[],t[101]=Be):Be=t[101],Dt=Be;break e}let Re;if(t[102]!==te||t[103]!==M){const Be=M.map(e0);Re=Rr(Be,te,t0,{limit:7,threshold:.4}),t[102]=te,t[103]=M,t[104]=Re}else Re=t[104];Dt=Re}const xe=Dt;let Ye,Xe,qe,dt,X,ae,Ae,Ge,q,Fe,Ze,Je,et,kt;if(t[105]!==ie||t[106]!==fe||t[107]!==k||t[108]!==D||t[109]!==he||t[110]!==n||t[111]!==m||t[112]!==b||t[113]!==v||t[114]!==Ue||t[115]!==ht||t[116]!==xe||t[117]!==ft||t[118]!==pt||t[119]!==r||t[120]!==j||t[121]!==f||t[122]!==e){const Re=Ue.map(s0),Be=pt.map(n0),Ke=ft.map(r0),rt=he?ht.map(o0):[],xt=he?xe.map(i0):[];let Pe;e:{if(!he){Pe=["commands","sessions"];break e}const Bt=a0,ut=[{key:"commands",score:Bt(Ue)},{key:"settings",score:Bt(pt)},{key:"sessions",score:Bt(ft)},{key:"files",score:Bt(ht)},{key:"projects",score:Bt(xe)}];ut.sort(l0),Pe=ut.map(c0)}const ze=Pe,st=Bt=>{fe(),j(Bt.id,Is(Bt))},at=async Bt=>{if(!k)return;const ut=await yf(D,Bt,{directory:k});if(!ut.ok){_e.error(wf(ut.reason));return}m(k,Bt),fe()},Ct=(Bt,ut)=>{fe(),b({selectedProjectId:Bt,directoryOverride:ut})},Ot=Bt=>zn(Xr(Bt,f));dt=ks,Je=n,et=r;let Lt;t[137]!==e?(Lt=e("commandPalette.title"),t[137]=e,t[138]=Lt):Lt=t[138];let Kt;t[139]!==Lt?(Kt=s.jsx(Ls,{children:Lt}),t[139]=Lt,t[140]=Kt):Kt=t[140];let Rt;t[141]!==e?(Rt=e("commandPalette.description"),t[141]=e,t[142]=Rt):Rt=t[142];let Vt;t[143]!==Rt?(Vt=s.jsx(_s,{children:Rt}),t[143]=Rt,t[144]=Vt):Vt=t[144],t[145]!==Kt||t[146]!==Vt?(kt=s.jsxs(Hs,{className:"sr-only",children:[Kt,Vt]}),t[145]=Kt,t[146]=Vt,t[147]=kt):kt=t[147],qe=Cs,Fe="overflow-hidden p-0",Ze=!0,Xe=Ng,Ae=!1,Ge="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let $t;t[148]!==e?($t=e("commandPalette.input.placeholder"),t[148]=e,t[149]=$t):$t=t[149],t[150]!==v||t[151]!==$t?(q=s.jsx(Ag,{value:v,onValueChange:I,placeholder:$t}),t[150]=v,t[151]=$t,t[152]=q):q=t[152],Ye=Pg;let Xt;t[153]!==e?(Xt=e("commandPalette.empty.noResults"),t[153]=e,t[154]=Xt):Xt=t[154],t[155]!==Xt?(X=s.jsx(Dg,{children:Xt}),t[155]=Xt,t[156]=X):X=t[156],ae=ze.map(Bt=>Bt==="commands"&&Re.length>0?s.jsx(Cr,{children:Re.map(ut=>s.jsxs(Mr,{value:ut.id,onSelect:ut.onSelect,children:[ut.icon,s.jsx("span",{children:ut.title}),ut.shortcutId?s.jsx(vg,{children:Ot(ut.shortcutId)}):null]},ut.id))},"commands"):Bt==="settings"&&Be.length>0?s.jsx(Cr,{children:Be.map(d0)},"settings"):Bt==="sessions"&&Ke.length>0?s.jsx(Cr,{children:Ke.map(ut=>{const ts=ut.title||e("commandPalette.session.untitled"),ss=Is(ut),fs=ie(ut.id,ss);return s.jsxs(Mr,{value:`session:${ut.id}`,onSelect:()=>st(ut),children:[s.jsx(B,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:ts}),fs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:fs})]}):null]},ut.id)})},"sessions"):Bt==="files"&&rt.length>0?s.jsx(Cr,{children:rt.map(ut=>{const ts=Sg(ut.relativePath||ut.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${ut.path}`,onSelect:()=>{at(ut.path)},children:[s.jsx(Ma,{filePath:ut.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":ut.relativePath,children:ts})]},`file:${ut.path}`)})},"files"):Bt==="projects"&&xt.length>0?s.jsx(Cr,{children:xt.map(ut=>{const ts=ut.displayName;return s.jsxs(Mr,{value:`project:${ut.id}`,onSelect:()=>Ct(ut.id,ut.path),children:[s.jsx(B,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:ts}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:ut.path})]},`project:${ut.id}`)})},"projects"):null),t[105]=ie,t[106]=fe,t[107]=k,t[108]=D,t[109]=he,t[110]=n,t[111]=m,t[112]=b,t[113]=v,t[114]=Ue,t[115]=ht,t[116]=xe,t[117]=ft,t[118]=pt,t[119]=r,t[120]=j,t[121]=f,t[122]=e,t[123]=Ye,t[124]=Xe,t[125]=qe,t[126]=dt,t[127]=X,t[128]=ae,t[129]=Ae,t[130]=Ge,t[131]=q,t[132]=Fe,t[133]=Ze,t[134]=Je,t[135]=et,t[136]=kt}else Ye=t[123],Xe=t[124],qe=t[125],dt=t[126],X=t[127],ae=t[128],Ae=t[129],Ge=t[130],q=t[131],Fe=t[132],Ze=t[133],Je=t[134],et=t[135],kt=t[136];let Qe;t[157]!==bt||t[158]!==e?(Qe=bt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[157]=bt,t[158]=e,t[159]=Qe):Qe=t[159];let It;t[160]!==Ye||t[161]!==X||t[162]!==ae||t[163]!==Qe?(It=s.jsxs(Ye,{children:[X,ae,Qe]}),t[160]=Ye,t[161]=X,t[162]=ae,t[163]=Qe,t[164]=It):It=t[164];let Mt;t[165]!==Xe||t[166]!==Ae||t[167]!==Ge||t[168]!==q||t[169]!==It?(Mt=s.jsxs(Xe,{shouldFilter:Ae,className:Ge,children:[q,It]}),t[165]=Xe,t[166]=Ae,t[167]=Ge,t[168]=q,t[169]=It,t[170]=Mt):Mt=t[170];let ke;t[171]!==qe||t[172]!==Fe||t[173]!==Ze||t[174]!==Mt?(ke=s.jsx(qe,{className:Fe,showCloseButton:Ze,children:Mt}),t[171]=qe,t[172]=Fe,t[173]=Ze,t[174]=Mt,t[175]=ke):ke=t[175];let Oe;return t[176]!==dt||t[177]!==Je||t[178]!==et||t[179]!==kt||t[180]!==ke?(Oe=s.jsxs(dt,{open:Je,onOpenChange:et,children:[kt,ke]}),t[176]=dt,t[177]=Je,t[178]=et,t[179]=kt,t[180]=ke,t[181]=Oe):Oe=t[181],Oe};function gj(t){return t.isCommandPaletteOpen}function bj(t){return t.setCommandPaletteOpen}function xj(t){return t.setSettingsDialogOpen}function yj(t){return t.setSettingsPage}function wj(t){return t.setSessionSwitcherOpen}function vj(t){return t.toggleSidebar}function Sj(t){return t.openContextOverview}function jj(t){return t.openContextSurface}function kj(t){return t.openContextFile}function Cj(t){return t.shortcutOverrides}function Nj(t){return t.setArchivePageOpen}function Aj(t){return t.setProjectContextTab}function Pj(t){return t.openNewSessionDraft}function Dj(t){return t.setCurrentSession}function Ij(t){return t.currentSessionId}function Tj(t){return t.toggle}function Ej(t){return t.currentDirectory}function Rj(t){return t.getActiveProject()}function Mj(t){return t.projects}function Oj(t){return t.searchFiles}function Bj(t){return t.ensureStatus}function Fj(){Tu()}function Lj(){Us.requestDirectoryDialog()}function _j(){Ig.invoke("cycle_theme")}function $j(){Eu()}function zj(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function Wj(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function Kj(t){return t.routingFeatureAvailable}function Vj(t){return t.slug!=="home"}function Uj(t){return!jg(t)}function Hj(t){return t.worktreeMetadata}function Gj(t){return{path:pa(t.path),name:t.name,relativePath:t.relativePath}}function qj(t){return!t.secondary}function Yj(t){return{item:t,score:0}}function Qj(t){return t.searchText}function Xj(t){return t.searchText}function Jj(t){return{item:t,score:0}}function Zj(t){return t.title||""}function e0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function t0(t){return t.searchText}function s0(t){return t.item}function n0(t){return t.item}function r0(t){return t.item}function o0(t){return t.item}function i0(t){return t.item}function a0(t){return t.length?t[0].score:1/0}function l0(t,e){return t.score-e.score}function c0(t){return t.key}function d0(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Bc=(t,e,n)=>zn(Xr(t,e),n),u0=()=>{const t=nt.c(47),{t:e}=At(),n=ye(f0),r=ye(m0),i=ye(h0);let o,l,a,d,u,m,f,g,y,b,j,x;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==e){const N=[{categoryKey:"helpDialog.section.navigationCommands",column:"left",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[zn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",column:"right",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",column:"right",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${zn(Hi("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${zn(Hi("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",column:"left",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}],P=K=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(K.categoryKey)}),s.jsx("div",{className:"space-y-1",children:K.items.map(D=>{const U=D.id?Tg(D.id):void 0,A=D.descriptionKey??(U?.customizable?U.settingsLabelKey:void 0);if(!A||D.id&&!Xr(D.id,i))return null;const E=D.id?Bc(D.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(D.keys)?D.keys:D.keys.split(" / ");return s.jsxs("div",{className:"flex items-center gap-3 py-1 px-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[D.icon&&s.jsx(B,{name:D.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(A)})]}),s.jsx("div",{"aria-hidden":!0,className:"min-w-4 flex-1 border-b border-dotted border-border"}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:(Array.isArray(E)?E:[E]).map((W,k)=>s.jsxs(c.Fragment,{children:[k>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:W})]},`${W}-${k}`))})]},D.id||A)})})]},K.categoryKey);a=ks,j=n,x=r,l=Cs,y="max-w-6xl w-[min(72rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let C;t[16]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(B,{name:"command",className:"h-5 w-5"}),t[16]=C):C=t[16];let T;t[17]!==e?(T=e("helpDialog.title"),t[17]=e,t[18]=T):T=t[18];let R;t[19]!==T?(R=s.jsxs(Ls,{className:"flex items-center gap-2",children:[C,T]}),t[19]=T,t[20]=R):R=t[20];let M;t[21]!==e?(M=e("helpDialog.description"),t[21]=e,t[22]=M):M=t[22];let F;t[23]!==M?(F=s.jsx(_s,{children:M}),t[23]=M,t[24]=F):F=t[24],t[25]!==R||t[26]!==F?(b=s.jsxs(Hs,{children:[R,F]}),t[25]=R,t[26]=F,t[27]=b):b=t[27],o=bn,m="flex-1 min-h-0 mt-3",f="pr-1",g=!0,d="grid grid-cols-1 gap-x-12 gap-y-4 lg:grid-cols-2",u=["left","right"].map(K=>s.jsxs("div",{className:"space-y-4",children:[N.filter(D=>D.column===K).map(P),K==="right"&&s.jsxs("ul",{className:"space-y-0.5 px-2 typography-meta text-muted-foreground",children:[s.jsxs("li",{children:["• ",e("helpDialog.proTips.commandPalette",{shortcut:Bc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))})]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.recentSessions")]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.leaderSequences")]})]})]},K)),t[0]=n,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=m,t[10]=f,t[11]=g,t[12]=y,t[13]=b,t[14]=j,t[15]=x}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],m=t[9],f=t[10],g=t[11],y=t[12],b=t[13],j=t[14],x=t[15];let h;t[28]!==d||t[29]!==u?(h=s.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=h):h=t[30];let p;t[31]!==o||t[32]!==m||t[33]!==f||t[34]!==g||t[35]!==h?(p=s.jsx(o,{outerClassName:m,className:f,disableHorizontal:g,children:h}),t[31]=o,t[32]=m,t[33]=f,t[34]=g,t[35]=h,t[36]=p):p=t[36];let w;t[37]!==l||t[38]!==p||t[39]!==y||t[40]!==b?(w=s.jsxs(l,{className:y,children:[b,p]}),t[37]=l,t[38]=p,t[39]=y,t[40]=b,t[41]=w):w=t[41];let S;return t[42]!==a||t[43]!==w||t[44]!==j||t[45]!==x?(S=s.jsx(a,{open:j,onOpenChange:x,children:w}),t[42]=a,t[43]=w,t[44]=j,t[45]=x,t[46]=S):S=t[46],S};function f0(t){return t.isHelpDialogOpen}function m0(t){return t.setHelpDialogOpen}function h0(t){return t.shortcutOverrides}const p0=()=>{const t=nt.c(32),{t:e}=At(),n=ye(g0),r=ye(b0),i=ye(x0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await Gn(i)).ok){_e.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}_e.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Ls,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==u?(m=s.jsx(_s,{children:u}),t[9]=u,t[10]=m):m=t[10];let f;t[11]!==d||t[12]!==m?(f=s.jsxs(Hs,{children:[d,m]}),t[11]=d,t[12]=m,t[13]=f):f=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let y;t[16]!==l||t[17]!==g?(y=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:g})}),t[16]=l,t[17]=g,t[18]=y):y=t[18];let b;t[19]!==i||t[20]!==e?(b=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=b):b=t[21];let j;t[22]!==b?(j=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:b}),t[22]=b,t[23]=j):j=t[23];let x;t[24]!==f||t[25]!==y||t[26]!==j?(x=s.jsxs(Cs,{className:"max-w-2xl",children:[f,y,j]}),t[24]=f,t[25]=y,t[26]=j,t[27]=x):x=t[27];let h;return t[28]!==n||t[29]!==r||t[30]!==x?(h=s.jsx(ks,{open:n,onOpenChange:r,children:x}),t[28]=n,t[29]=r,t[30]=x,t[31]=h):h=t[31],h};function g0(t){return t.isOpenCodeStatusDialogOpen}function b0(t){return t.setOpenCodeStatusDialogOpen}function x0(t){return t.openCodeStatusText}const y0=t=>{const e=nt.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const b=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(b)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let m,f;e[5]!==a||e[6]!==o||e[7]!==i?(m=()=>{if(!a||typeof window>"u")return;const b=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",b),()=>window.removeEventListener("openchamber:sidebar-session-search",b)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=m,e[9]=f):(m=e[8],f=e[9]),c.useEffect(m,f);let g,y;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(g=()=>{if(!a||!r||typeof document>"u")return;const b=j=>{l.current&&(l.current.contains(j.target)||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},y=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=g,e[15]=y):(g=e[14],y=e[15]),c.useEffect(g,y)},w0=t=>{const e=nt.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(v0)),u=[];a.forEach(g=>{const y=d.get(g);y&&(u.push(y),d.delete(g))});const m=[],f=[];return l.forEach(g=>{d.has(g.id)&&(g.isArchivedBucket?f.push(g):m.push(g))}),[...m,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function v0(t){return[t.id,t]}const go="oc.sessions.projectCollapse",Fc="oc.sessions.groupOrder",Lc="oc.sessions.groupCollapse",_c=t=>{if(!t)return new Set;try{const e=Ha(Hn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},S0=t=>{if(!t)return new Map;try{const e=of(Hn(),Ha(Hn())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},j0=t=>{const e=nt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Oo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>_c(o.getItem(go)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>_c(o.getItem(Lc)),e[2]=u):u=e[2];const[m,f]=c.useState(u);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>S0(o.getItem(Fc)),e[3]=g):g=e[3];const[y,b]=c.useState(g),j=c.useRef(0),x=c.useRef(!1),h=c.useRef(!1),p=c.useRef(null),w=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const fe=w.current;if(w.current=null,p.current=null,!fe)return;const{projects:Ne}=zt.getState(),L=Ne.map(oe=>({...oe,sidebarCollapsed:fe.has(oe.id)}));lr({projects:L}).catch(k0)},e[4]=n,e[5]=S):S=e[5];const N=S;let P;e[6]!==N||e[7]!==n?(P=fe=>{!globalThis.window||n||(w.current=fe,p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=P):P=e[8];const C=P;let T,R;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>()=>{globalThis.window&&p.current!==null&&window.clearTimeout(p.current),p.current=null,w.current=null},R=[],e[9]=T,e[10]=R):(T=e[9],R=e[10]),c.useEffect(T,R);let M,F;e[11]!==y?(F=()=>{if(h.current)try{o.setItem(Fc,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},M=[y,o],e[11]=y,e[12]=M,e[13]=F):(M=e[12],F=e[13]),c.useEffect(F,M);let K,D;e[14]!==m?(K=()=>{if(x.current)try{o.setItem(Lc,JSON.stringify(Array.from(m)))}catch{}},D=[m,o],e[14]=m,e[15]=K,e[16]=D):(K=e[15],D=e[16]),c.useEffect(K,D);let U;e[17]!==r||e[18]!==C?(U=()=>{j.current=Date.now()+150,x.current=!0,f(new Set),d(()=>{const fe=new Set(r.map(C0));try{o.setItem(go,JSON.stringify(Array.from(fe)))}catch{}return C(fe),fe})},e[17]=r,e[18]=C,e[19]=U):U=e[19];const A=U;let E;e[20]!==C?(E=()=>{j.current=Date.now()+150,x.current=!0,f(new Set),d(()=>{const fe=new Set;try{o.setItem(go,JSON.stringify([]))}catch{}return C(fe),fe})},e[20]=C,e[21]=E):E=e[21];const W=E;let k;e[22]!==C?(k=fe=>{j.current=Date.now()+150,d(Ne=>{const L=new Set(Ne);L.has(fe)?L.delete(fe):L.add(fe);try{o.setItem(go,JSON.stringify(Array.from(L)))}catch{}return C(L),L})},e[22]=C,e[23]=k):k=e[23];const v=k;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=fe=>{x.current=!0,f(Ne=>{const L=new Set(Ne);return L.has(fe)?L.delete(fe):L.add(fe),L})},e[24]=I):I=e[24];const H=I;let $;e[25]===Symbol.for("react.memo_cache_sentinel")?($=fe=>{h.current=!0,b(fe)},e[25]=$):$=e[25];const re=$,{getOrderedGroups:te}=w0(y);let ee;e[26]!==m||e[27]!==a||e[28]!==y?(ee={collapsedProjects:a,collapsedGroups:m,groupOrderByProject:y},e[26]=m,e[27]=a,e[28]=y,e[29]=ee):ee=e[29];const ue=ee;let de;e[30]!==A||e[31]!==W||e[32]!==te||e[33]!==C||e[34]!==v?(de={setCollapsedProjects:d,toggleProject:v,collapseAllProjects:A,expandAllProjects:W,scheduleCollapsedProjectsPersist:C,setCollapsedGroups:f,toggleGroup:H,setGroupOrderByProject:re,getOrderedGroups:te},e[30]=A,e[31]=W,e[32]=te,e[33]=C,e[34]=v,e[35]=de):de=e[35];const Te=de;let we;return e[36]!==Te||e[37]!==ue?(we={state:ue,actions:Te},e[36]=Te,e[37]=ue,e[38]=we):we=e[38],we};function k0(){}function C0(t){return t.id}const N0=5*6e4,A0=t=>{const e=nt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=gn(),u=Xn(P0);let m,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(m=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(P=>{Gi(()=>u(P.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=m,e[6]=f):(m=e[5],f=e[6]),c.useEffect(m,f);let g,y;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(g=()=>{if(!a)return;const P=new Map;n.forEach(C=>{P.set(C.id,i.get(C.normalizedPath)?.isGitRepo??null)}),o(P)},y=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=g,e[12]=y):(g=e[11],y=e[12]),c.useEffect(g,y);let b;if(e[13]!==i||e[14]!==n){let P;e[16]!==i?(P=C=>{const T=i.get(C.normalizedPath)?.branch??"";return`${C.id}:${T}`},e[16]=i,e[17]=P):P=e[17],b=n.map(P).join("|"),e[13]=i,e[14]=n,e[15]=b}else b=e[15];const j=b;let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[18]=x):x=e[18];const h=c.useRef(x);let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const w=c.useRef(p);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let P=!1;const C=setTimeout(()=>{(async()=>{const R=new Set(n.map(D0));for(const A of h.current.keys())R.has(A)||(h.current.delete(A),w.current.delete(A));const M=Date.now(),F=n.filter(A=>{const E=i.get(A.normalizedPath);if(E?.isGitRepo===!1)return h.current.delete(A.id),w.current.delete(A.id),!1;if(E?.isGitRepo!==!0||E.branch===null)return!1;const W=E.branch.trim(),k=`${A.normalizedPath}\0${W}`,v=h.current.get(A.id);if(v===k){const I=w.current.get(A.id);return I&&(I.at=M),!1}return!(v!==void 0&&M-(w.current.get(A.id)?.at??0)<N0)});if(F.length===0)return;const K=await Eg(F,2,async A=>{const E=i.get(A.normalizedPath)?.branch?.trim()??"",W=`${A.normalizedPath}\0${E}`,k=await Gi(()=>Su(A.normalizedPath,E?{knownBranch:E}:void 0)).catch(I0);return{id:A.id,inputKey:W,branch:k}});if(P)return;const D=K.filter(T0);if(D.length===0)return;const U=Date.now();l(A=>{const E=new Map(A);return D.forEach(W=>{const{id:k,branch:v}=W;v&&E.set(k,v)}),E}),D.forEach(A=>{const{id:E,inputKey:W,branch:k}=A;h.current.set(E,W),k&&w.current.set(E,{branch:k,at:U})})})()},150);return()=>{P=!0,clearTimeout(C)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==j||e[29]!==l?(N=[a,n,j,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=j,e[29]=l,e[30]=N):N=e[30],c.useEffect(S,N)};function P0(t){return t.ensureStatus}function D0(t){return t.id}function I0(){return null}function T0(t){return t.branch}const E0=t=>{const e=nt.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Kh,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(Cs,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(bn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(ks,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function R0(t){const e=nt.c(179),{t:n}=At(),r=Ru(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenArchive:u,headerActionIconClass:m,headerActionButtonClass:f,isSessionSearchOpen:g,setIsSessionSearchOpen:y,sessionSearchInputRef:b,sessionSearchQuery:j,setSessionSearchQuery:x,hasSessionSearchQuery:h,searchMatchCount:p,collapseAllProjects:w,expandAllProjects:S}=t,N=es(G0),P=es(H0),C=is(U0),T=is(V0),R=is(K0),M=is(W0),F=is(z0),K=is($0),D=is(_0),U=is(L0),A=is(F0),E=is(B0),W=o&&A==="single",k=o&&D==="timeline";if(i)return null;let v;e[0]!==f?(v=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=f,e[1]=v):v=e[1];let I;e[2]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=I):I=e[3];let H;e[4]!==m?(H=s.jsx(B,{name:"folder-add",className:m}),e[4]=m,e[5]=H):H=e[5];let $;e[6]!==a||e[7]!==v||e[8]!==I||e[9]!==H?($=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:v,"aria-label":I,children:H})}),e[6]=a,e[7]=v,e[8]=I,e[9]=H,e[10]=$):$=e[10];let re;e[11]!==n?(re=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=re):re=e[12];let te;e[13]!==re?(te=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:re})}),e[13]=re,e[14]=te):te=e[14];let ee;e[15]!==$||e[16]!==te?(ee=s.jsxs(vt,{children:[$,te]}),e[15]=$,e[16]=te,e[17]=ee):ee=e[17];let ue;e[18]!==f?(ue=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=f,e[19]=ue):ue=e[19];let de;e[20]!==n?(de=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=de):de=e[21];let Te;e[22]!==m?(Te=s.jsx(B,{name:"calendar-schedule",className:m}),e[22]=m,e[23]=Te):Te=e[23];let we;e[24]!==d||e[25]!==ue||e[26]!==de||e[27]!==Te?(we=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:ue,"aria-label":de,children:Te})}),e[24]=d,e[25]=ue,e[26]=de,e[27]=Te,e[28]=we):we=e[28];let fe;e[29]!==n?(fe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=fe):fe=e[30];let Ne;e[31]!==fe?(Ne=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[31]=fe,e[32]=Ne):Ne=e[32];let L;e[33]!==we||e[34]!==Ne?(L=s.jsxs(vt,{children:[we,Ne]}),e[33]=we,e[34]=Ne,e[35]=L):L=e[35];let oe;e[36]!==f?(oe=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=f,e[37]=oe):oe=e[37];let ce;e[38]!==n?(ce=n("sessions.sidebar.nav.archive"),e[38]=n,e[39]=ce):ce=e[39];let pe;e[40]!==m?(pe=s.jsx(B,{name:"archive",className:m}),e[40]=m,e[41]=pe):pe=e[41];let Y;e[42]!==u||e[43]!==oe||e[44]!==ce||e[45]!==pe?(Y=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:oe,"aria-label":ce,children:pe})}),e[42]=u,e[43]=oe,e[44]=ce,e[45]=pe,e[46]=Y):Y=e[46];let ve;e[47]!==n?(ve=n("sessions.sidebar.nav.archive"),e[47]=n,e[48]=ve):ve=e[48];let Ee;e[49]!==ve?(Ee=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ve})}),e[49]=ve,e[50]=Ee):Ee=e[50];let je;e[51]!==Y||e[52]!==Ee?(je=s.jsxs(vt,{children:[Y,Ee]}),e[51]=Y,e[52]=Ee,e[53]=je):je=e[53];let ge;e[54]!==r||e[55]!==m||e[56]!==n?(ge=r.length>0&&s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsx(mt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(B,{name:"apps",className:m})})}),s.jsxs(Ss,{align:"start",children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(O0)]})]}),e[54]=r,e[55]=m,e[56]=n,e[57]=ge):ge=e[57];let be;e[58]!==L||e[59]!==je||e[60]!==ge||e[61]!==ee?(be=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ee,L,je,ge]}),e[58]=L,e[59]=je,e[60]=ge,e[61]=ee,e[62]=be):be=e[62];let Q;e[63]!==y?(Q=()=>y(M0),e[63]=y,e[64]=Q):Q=e[64];let _;e[65]!==f?(_=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[65]=f,e[66]=_):_=e[66];let J;e[67]!==n?(J=n("sessions.sidebar.header.actions.searchSessions"),e[67]=n,e[68]=J):J=e[68];let me;e[69]!==m?(me=s.jsx(B,{name:"search",className:m}),e[69]=m,e[70]=me):me=e[70];let le;e[71]!==g||e[72]!==Q||e[73]!==_||e[74]!==J||e[75]!==me?(le=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Q,className:_,"aria-label":J,"aria-expanded":g,children:me})}),e[71]=g,e[72]=Q,e[73]=_,e[74]=J,e[75]=me,e[76]=le):le=e[76];let V;e[77]!==n?(V=n("sessions.sidebar.header.actions.searchSessions"),e[77]=n,e[78]=V):V=e[78];let Z;e[79]!==V?(Z=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V})}),e[79]=V,e[80]=Z):Z=e[80];let G;e[81]!==le||e[82]!==Z?(G=s.jsxs(vt,{children:[le,Z]}),e[81]=le,e[82]=Z,e[83]=G):G=e[83];const ie=N&&"bg-interactive-hover text-primary";let Se;e[84]!==f||e[85]!==ie?(Se=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent",ie),e[84]=f,e[85]=ie,e[86]=Se):Se=e[86];let se;e[87]!==N||e[88]!==n?(se=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[87]=N,e[88]=n,e[89]=se):se=e[89];let Me;e[90]!==m?(Me=s.jsx(B,{name:"checkbox-multiple",className:m}),e[90]=m,e[91]=Me):Me=e[91];let He;e[92]!==N||e[93]!==Se||e[94]!==se||e[95]!==Me||e[96]!==P?(He=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:P,className:Se,"aria-label":se,"aria-pressed":N,children:Me})}),e[92]=N,e[93]=Se,e[94]=se,e[95]=Me,e[96]=P,e[97]=He):He=e[97];let We;e[98]!==N||e[99]!==n?(We=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[98]=N,e[99]=n,e[100]=We):We=e[100];let Le;e[101]!==We?(Le=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:We})}),e[101]=We,e[102]=Le):Le=e[102];let Ve;e[103]!==He||e[104]!==Le?(Ve=s.jsxs(vt,{children:[He,Le]}),e[103]=He,e[104]=Le,e[105]=Ve):Ve=e[105];let O;e[106]!==f?(O=De(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[106]=f,e[107]=O):O=e[107];let he;e[108]!==n?(he=n("sessions.sidebar.header.displayMode.label"),e[108]=n,e[109]=he):he=e[109];let $e;e[110]!==m?($e=s.jsx(B,{name:"equalizer-2",className:m}),e[110]=m,e[111]=$e):$e=e[111];let Ue;e[112]!==O||e[113]!==he||e[114]!==$e?(Ue=s.jsx(St,{asChild:!0,children:s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:O,"aria-label":he,children:$e})})}),e[112]=O,e[113]=he,e[114]=$e,e[115]=Ue):Ue=e[115];let ct;e[116]!==n?(ct=n("sessions.sidebar.header.displayMode.label"),e[116]=n,e[117]=ct):ct=e[117];let pt;e[118]!==ct?(pt=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ct})}),e[118]=ct,e[119]=pt):pt=e[119];let it;e[120]!==Ue||e[121]!==pt?(it=s.jsxs(vt,{children:[Ue,pt]}),e[120]=Ue,e[121]=pt,e[122]=it):it=e[122];let ft;e[123]!==U||e[124]!==o||e[125]!==D||e[126]!==n||e[127]!==k?(ft=o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{U(ae),lr({sidebarViewMode:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),D===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),k?null:s.jsx(hs,{})]}):null,e[123]=U,e[124]=o,e[125]=D,e[126]=n,e[127]=k,e[128]=ft):ft=e[128];let yt;e[129]!==A||e[130]!==R||e[131]!==E||e[132]!==M||e[133]!==K||e[134]!==o||e[135]!==n||e[136]!==k||e[137]!==F?(yt=k?null:s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{M(ae),lr({sidebarProjectSortOrder:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),R===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(hs,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{K(ae),lr({sidebarWorktreeSortOrder:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),F===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(hs,{})]}):null,o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(X=>{const[ae,Ae]=X;return s.jsxs(_t,{onClick:()=>{E(ae),lr({sidebarProjectDisplayMode:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Ae)}),A===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(hs,{})]}):null]}),e[129]=A,e[130]=R,e[131]=E,e[132]=M,e[133]=K,e[134]=o,e[135]=n,e[136]=k,e[137]=F,e[138]=yt):yt=e[138];let ht;e[139]!==W||e[140]!==l||e[141]!==C||e[142]!==n||e[143]!==k||e[144]!==T?(ht=!k&&l&&!W?s.jsxs(_t,{onClick:()=>{T(),lr({sidebarShowRecentSection:!C})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),C?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[139]=W,e[140]=l,e[141]=C,e[142]=n,e[143]=k,e[144]=T,e[145]=ht):ht=e[145];let bt;e[146]!==w||e[147]!==S||e[148]!==W||e[149]!==n||e[150]!==k?(bt=!k&&!W?s.jsxs(s.Fragment,{children:[s.jsx(hs,{}),s.jsxs(_t,{onClick:w,className:"flex items-center gap-2",children:[s.jsx(B,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(_t,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(B,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[146]=w,e[147]=S,e[148]=W,e[149]=n,e[150]=k,e[151]=bt):bt=e[151];let Dt;e[152]!==ft||e[153]!==yt||e[154]!==ht||e[155]!==bt?(Dt=s.jsxs(Ss,{align:"end",className:"min-w-[180px]",children:[ft,yt,ht,bt]}),e[152]=ft,e[153]=yt,e[154]=ht,e[155]=bt,e[156]=Dt):Dt=e[156];let xe;e[157]!==it||e[158]!==Dt?(xe=s.jsxs(js,{children:[it,Dt]}),e[157]=it,e[158]=Dt,e[159]=xe):xe=e[159];let Ye;e[160]!==G||e[161]!==Ve||e[162]!==xe?(Ye=s.jsxs("div",{className:"flex items-center gap-1.5",children:[G,Ve,xe]}),e[160]=G,e[161]=Ve,e[162]=xe,e[163]=Ye):Ye=e[163];let Xe;e[164]!==be||e[165]!==Ye?(Xe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[be,Ye]}),e[164]=be,e[165]=Ye,e[166]=Xe):Xe=e[166];let qe;e[167]!==h||e[168]!==g||e[169]!==p||e[170]!==b||e[171]!==j||e[172]!==y||e[173]!==x||e[174]!==n?(qe=g?s.jsx("div",{className:"pb-1",children:s.jsx(Jd,{inputRef:b,value:j,onSearch:x,onClose:()=>y(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:h?p===1?n("sessions.sidebar.header.search.matchCountSingle",{count:p}):n("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[167]=h,e[168]=g,e[169]=p,e[170]=b,e[171]=j,e[172]=y,e[173]=x,e[174]=n,e[175]=qe):qe=e[175];let dt;return e[176]!==Xe||e[177]!==qe?(dt=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Xe,qe]})}),e[176]=Xe,e[177]=qe,e[178]=dt):dt=e[178],dt}function M0(t){return!t}function O0(t){return s.jsxs(_t,{onSelect:()=>ye.getState().setOpenGuestPage(t.id),children:[s.jsx(Qr,{icon:Mg(t.icon),iconSrc:Rg(t.id,t.icon,zd().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function B0(t){return t.setProjectDisplayMode}function F0(t){return t.projectDisplayMode}function L0(t){return t.setSidebarViewMode}function _0(t){return t.sidebarViewMode}function $0(t){return t.setWorktreeSortOrder}function z0(t){return t.worktreeSortOrder}function W0(t){return t.setProjectSortOrder}function K0(t){return t.projectSortOrder}function V0(t){return t.toggleRecentSection}function U0(t){return t.showRecentSection}function H0(t){return t.toggleMode}function G0(t){return t.enabled}const bo="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function q0(t){const e=nt.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,m=d===void 0?!0:d,{t:f}=At();if(!u&&!m)return null;let g;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(g=u?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:bo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(B,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:bo,"aria-label":f("usageStats.openAction"),children:s.jsx(B,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:bo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(B,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:bo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(B,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=g):g=e[6];let y;e[7]!==l||e[8]!==m||e[9]!==f?(y=m?s.jsx(mt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=m,e[9]=f,e[10]=y):y=e[10];let b;return e[11]!==g||e[12]!==y?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[g,y]}),e[11]=g,e[12]=y,e[13]=b):b=e[13],b}const Y0=t=>{for(const e of t.sessions.values())if(e.tabs.some(Kd))return!0;return!1},Q0=()=>{const t=nt.c(4),{terminal:e}=gn(),n=Et(Y0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=X0,l=J0;if(n)return _i(e,"",l,o);let a=Z0;return a=_i(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function X0(t){const e=Et.getState(),n=Vh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function J0(){return new Map(Et.getState().actionMutationRevisions)}function Z0(){}const ek=t=>{const e=nt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:m,addSessionToFolder:f}=t,g=r===void 0?!0:r;let y,b;e[0]!==f||e[1]!==m||e[2]!==g||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(y=()=>{!g||o||!l||a||n.forEach(j=>{if(d.has(j.normalizedPath))return;const x=Mu(j.normalizedPath),h=i.archivedSessionsByProject.get(j.id)??[],p=u[x]??[],w=new Map(p.map(tk));h.forEach(S=>{const N=Og(S,j.normalizedPath),P=N.toLowerCase();let C=w.get(P);C||(C=m(x,N),w.set(P,C)),C.sessionIds.includes(S.id)||f(x,C.id,S.id)})})},b=[n,g,i,o,l,a,d,u,m,f],e[0]=f,e[1]=m,e[2]=g,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=y,e[11]=b):(y=e[10],b=e[11]),c.useEffect(y,b)};function tk(t){return[t.name.toLowerCase(),t]}function sk({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([m,f])=>m!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const nk=t=>{const e=nt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:m,openNewSessionDraft:f,setSessionSwitcherOpen:g}=t;let y,b;if(e[0]!==n){b=new Map,y=new Map;const P=(C,T,R,M)=>{b.has(C)||b.set(C,new Map);const F=b.get(C);M.forEach(K=>{const D=gt(K.worktree?.path??K.session.directory??R??T);F.set(K.session.id,{directory:D}),y.has(C)||y.set(C,{id:K.session.id,directory:D}),K.children.length>0&&P(C,T,D,K.children)})};n.forEach(C=>{C.groups.forEach(T=>{P(C.project.id,C.project.normalizedPath,T.directory,T.sessions)})}),e[0]=n,e[1]=y,e[2]=b}else y=e[1],b=e[2];let j;e[3]!==y||e[4]!==b?(j={metaByProject:b,firstSessionByProject:y},e[3]=y,e[4]=b,e[5]=j):j=e[5];const x=j,h=c.useRef(null);let p,w;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==m||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==x||e[16]!==o||e[17]!==g?(p=()=>{if(!r||u||ye.getState().isNewWorktreeDialogOpen||h.current===r)return;const P=n.find(M=>M.project.id===r);if(!P)return;const C=x.metaByProject.get(r);if(l&&C&&C.has(l)){h.current=r,o(M=>{if(M.get(r)===l)return M;const F=new Map(M);return F.set(r,l),F});return}const T=sk({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:C,metaByProject:x.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(T.kind==="preserve-current"){a===r&&(h.current=r);return}if(h.current=r,T.kind==="open-draft"){m&&g(!1),f({selectedProjectId:P.project.id,directoryOverride:P.project.normalizedPath});return}if(T.kind!=="select-session")return;const R=C?.get(T.sessionId)?.directory??null;d(T.sessionId,R)},w=[r,i,l,a,d,u,m,f,n,x,g,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=m,e[12]=u,e[13]=f,e[14]=n,e[15]=x,e[16]=o,e[17]=g,e[18]=p,e[19]=w):(p=e[18],w=e[19]),c.useLayoutEffect(p,w);let S,N;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==o?(S=()=>{if(!r||!l)return;const P=x.metaByProject.get(r);!P||!P.has(l)||o(C=>{if(C.get(r)===l)return C;const T=new Map(C);return T.set(r,l),T})},N=[r,l,x,o],e[20]=r,e[21]=l,e[22]=x,e[23]=o,e[24]=S,e[25]=N):(S=e[24],N=e[25]),c.useEffect(S,N)},rk=t=>{const e=nt.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=ot(ok),a=ot(ik);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let m;e[8]!==r?(m=()=>new Map(r),e[8]=r,e[9]=m):m=e[9];const[f,g]=c.useState(m);let y;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(y={...n,activeSessionByProject:f,setActiveSessionByProject:g,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=y):y=e[15],nk(y);let b,j;return e[16]!==f||e[17]!==i?(b=()=>{i(f)},j=[f,i],e[16]=f,e[17]=i,e[18]=b,e[19]=j):(b=e[18],j=e[19]),c.useEffect(b,j),null};function ok(t){return t.currentSessionId}function ik(t){return!!t.newSessionDraft?.open}const ak=t=>{const e=nt.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Bn=(t,e)=>`${t}\0${e}`,kn=(t,e)=>t??La(e)??gt(e??null),Gr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??gt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},tl=t=>t.startsWith("__archived__:"),lk=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===n.id:o.isMain}))},$c=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},wr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(wr(n,e))return!0;return!1},ck=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!_a(r),dk=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,uk=(t,e,n)=>{const r=new Map,i=o=>{const l=Is(o.session)??gt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},ga=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Hf=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},Gf=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const g=i.get(u.parentId)??[];g.push(u.id),i.set(u.parentId,g)}const m=new Set;let f=u.id;for(;f;){if(m.has(f)){o.add(u.id);break}m.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const m=r.get(u);if(!m)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&m.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(m.nodeCount>0||!n&&Bo([m.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},zc=new WeakMap;let Wc=1;const fk=t=>{const e=zc.get(t);if(e!==void 0)return e;const n=Wc;return Wc+=1,zc.set(t,n),n},Ko=t=>t.children.length===0?"":t.children.map(n=>{const r=fk(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Ko(n)}`}).join("|"),qf=(t,e,n,r,i,o)=>{const l=qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const m=d.session.directory??i,f=u.session.directory??o,g=Ml(l,m??"",d.session.id),y=Ml(l,f??"",u.session.id);return(g?n.has(g):!1)!==(y?r.has(y):!1)?!0:d.children.some((b,j)=>a(b,u.children[j]))};return a(t,e)},mk=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,hk=(t,e)=>t?t.branchLabel??null:e??null,pk=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=gt(t?.path??null);return n&&r?Yo(r,n):null},Vo=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},xo=t=>"run"in t,gk=(t,e)=>`${t}:active:run:${e}`,Ti=(t,e,n)=>{if(n||e.runKeyBySessionId.size===0)return[...t];const r=[],i=new Map;for(const o of t){const l=e.runKeyBySessionId.get(o.session.id),a=l?e.runs.get(l):void 0;if(!a){r.push(o);continue}const d=i.get(a.key);if(d){d.lanes.push(o);continue}const u={run:a,lanes:[o]};i.set(a.key,u),r.push(u)}for(const o of i.values()){const l=new Map(o.run.memberIds.map((a,d)=>[a,d]));o.lanes.sort((a,d)=>(l.get(a.session.id)??0)-(l.get(d.session.id)??0))}return r},Yf=(t,e)=>{const n=e.trim().toLowerCase(),r=n.startsWith("ses_"),i=o=>o.reduce((l,a)=>l+(!r||a.session.id.toLowerCase()===n?1:0)+i(a.children),0);return i(t)},bk=[],xk=new Set,Kc=32,Vc=64,yk=3,wk=7,yo=32,Rn=28,Uc=(t,e,n,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return $a(t.session,e.session,n,Fa)},wo=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const m=l.node.children[u];m&&o.push({node:m,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},vk=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,Sk=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},jk=t=>{const e=[],n=[],r=[],i=[],o=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),m=t.workSessionIds??xk;let f=0;const y=[...[...t.authoritativeSections.flatMap(A=>A.groups.flatMap(E=>E.sessions)),...t.chatGroup?.sessions??[]]];for(;y.length>0;){const A=y.pop();A&&(l.set(A.session.id,A.session),y.push(...A.children))}const b=A=>{const E=a.get(A)??0;return a.set(A,E+1),E===0?A:`${A}:${E}`},j=A=>{e.push(Object.freeze(A))},x=t.runIndex??Bg,h=(A,E)=>{const W=gk(E.renderContext,A.run.key),k=E.renderContext!=="timeline"&&(d||t.expandedParents.has(W)),v=A.lanes[0]?.session.id,I=v&&E.getSecondaryMeta?E.getSecondaryMeta(v):E.secondaryMeta;j({kind:"run",key:b(`${E.containerKey}:run:${A.run.key}`),estimateSize:E.renderContext==="timeline"?Vc:Kc,run:A.run,laneNodes:Object.freeze([...A.lanes]),projectId:E.projectId,projectLabel:I?.projectLabel??null,groupDirectory:E.groupDirectory,renderContext:E.renderContext,expansionKey:W,expanded:k,forceExpanded:d}),k&&w(A.lanes,1,E)},p=A=>{for(const E of Ti(A.nodes,x,A.archived))xo(E)?h(E,A):w([E],0,A)},w=(A,E,W)=>{const k=[...A].reverse().map(v=>({node:v,depth:E,directory:W.groupDirectory}));for(;k.length>0;){const v=k.pop();if(!v)continue;const I=b(`${W.containerKey}:session:${v.node.session.id}`),H=v.node.session.directory??v.directory;l.set(v.node.session.id,v.node.session),j({kind:"session",key:I,estimateSize:W.renderContext==="timeline"?Vc:Kc,node:v.node,depth:v.depth,projectId:W.projectId,groupDirectory:v.directory,ownerKey:W.ownerKey,selectionScopeKey:W.selectionScopeKey,archived:W.archived,renderContext:W.renderContext,secondaryMeta:W.getSecondaryMeta?W.getSecondaryMeta(v.node.session.id):W.secondaryMeta??null});const $=W.indexedNodes?.subtreeRangeByNode.get(v.node),re=$&&$[1]>$[0]+1?Object.freeze([(W.selectionPoolOffset??0)+$[0]+1,(W.selectionPoolOffset??0)+$[1]]):void 0;if(n.push(Object.freeze({id:v.node.session.id,rowKey:I,scopeKey:W.selectionScopeKey,archived:W.archived,descendantRange:re})),!(!d&&!t.expandedParents.has(vk(W.renderContext,W.archived,v.node.session.id))))for(let te=v.node.children.length-1;te>=0;te-=1){const ee=v.node.children[te];ee&&k.push({node:ee,depth:v.depth+1,directory:H})}}},S=A=>{const E=t.groupSearchDataByGroup.get(A);if(E?.hasMatch!==!0)return 0;const W=m.size>0?E.filteredNodes.filter(v=>m.has(v.session.id)):[];return Math.max(0,E.matchedSessionCount-Yf(W,t.normalizedQuery))+E.folderNameMatchCount+(E.groupMatches?1:0)},N=(A,E,W,k,v)=>{const I=t.groupSearchDataByGroup.get(A);if(d){const se=S(A);if(se===0)return;f+=se}const H=(d?I?.filteredNodes??[]:A.sessions).filter(se=>!m.has(se.session.id)).sort((se,Me)=>Uc(se,Me,u,t.sessionOrderIndex)),$=wo(H),re=r.length;r.push(...$.preorderIds);for(const[se,Me]of $.sessionsById)l.set(se,Me);const te=kn(W,A.directory),ee=!d&&t.collapsedGroups.has(E);if(!k){const se=$.preorderIds.flatMap(Me=>$.sessionsById.get(Me)??[]);j({kind:"group-header",key:`${E}:header`,estimateSize:yo,group:A,groupKey:E,projectId:W,collapsed:ee,forceExpanded:d,allSessions:Object.freeze(se)})}if(ee)return;const ue=Gr(A).flatMap(({scopeKey:se,directory:Me})=>(t.foldersMap[se]??bk).map(He=>({folder:He,scopeKey:se,scopeDirectory:Me,ownerKey:te,nodes:ga(He.sessionIds,$.byId).sort((We,Le)=>Uc(We,Le,u,t.sessionOrderIndex))}))),de=Gf(ue.map(se=>({id:se.folder.id,name:se.folder.name,parentId:se.folder.parentId,nodeCount:se.nodes.length})),{archivedBucket:A.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),Te=ue.filter(se=>de.has(se.folder.id)),we=new Map(Te.map(se=>[Bn(se.scopeKey,se.folder.id),se])),fe=new Map;for(const se of Te){if(!se.folder.parentId)continue;const Me=Bn(se.scopeKey,se.folder.parentId),He=fe.get(Me)??[];He.push(se),fe.set(Me,He)}const Ne=Hf(Te.map(se=>({...se.folder,scopeKey:se.scopeKey}))).map(se=>we.get(Bn(se.scopeKey??"",se.id))).filter(se=>!!se),L=new Set(Te.flatMap(se=>se.folder.sessionIds)),oe=H.filter(se=>!L.has(se.session.id)),ce=new Map,pe=Ne.map(se=>({folder:se,visited:!1})),Y=new Set;for(;pe.length>0;){const se=pe.pop();if(!se)continue;const Me=Bn(se.folder.scopeKey,se.folder.folder.id);if(!se.visited){if(Y.has(Me))continue;Y.add(Me),pe.push({folder:se.folder,visited:!0});for(const We of fe.get(Me)??[])pe.push({folder:We,visited:!1});continue}const He=se.folder.nodes.flatMap(We=>{const Le=$.subtreeRangeByNode.get(We);return Le?$.preorderIds.slice(Le[0],Le[1]).flatMap(Ve=>$.sessionsById.get(Ve)??[]):[We.session]});for(const We of fe.get(Me)??[])He.push(...ce.get(Bn(We.scopeKey,We.folder.id))??[]);ce.set(Me,Object.freeze(He))}const ve=new Set,Ee=(se,Me)=>{const He=Bn(se.scopeKey,se.folder.id);if(ve.has(He))return;ve.add(He);const We=Me?`${Me} / ${se.folder.name}`:se.folder.name,Le=`${E}:folder:${He}`,Ve=!d&&t.collapsedFolders.has(se.folder.id),O=ce.get(He)??[],he=Ve&&!A.isArchivedBucket?ga([...new Set(O.map(ct=>ct.id))],$.byId):[],$e=te?t.folderAuthorityByOwner.get(te):void 0,Ue=!!te&&!A.isArchivedBucket&&!tl(se.scopeKey)&&$e?.complete===!0&&$e.scopeKeys.includes(se.scopeKey);if(j({kind:"folder-header",key:Le,estimateSize:yo,group:A,folder:se.folder,displayName:We,scopeKey:se.scopeKey,scopeDirectory:se.scopeDirectory,ownerKey:te,nodes:se.nodes,activityNodes:he,projectId:W,archived:A.isArchivedBucket===!0,collapsed:Ve,forceExpanded:d,deleteSessions:O,subFolderCount:fe.get(He)?.length??0,dropEnabled:Ue}),te&&o.push(Object.freeze({rowKey:Le,scopeKey:se.scopeKey,folderId:se.folder.id,ownerKey:te,enabled:Ue})),!Ve){p({nodes:se.nodes,containerKey:Le,projectId:W,groupDirectory:se.scopeDirectory??A.directory,ownerKey:te,selectionScopeKey:te,archived:A.isArchivedBucket===!0,renderContext:"project",indexedNodes:$,selectionPoolOffset:re});for(const ct of fe.get(He)??[])Ee(ct,We)}};for(const se of Ne)Ee(se,"");const je=W?t.sessionBatchSize:void 0,ge=v?.initial??je??(t.hideDirectoryControls?10:5),be=v?.increment??je??7,Q=Math.max(ge,t.visibleCountByContainer.get(E)??ge),_=se=>!xo(se)&&v?.pinnedAlwaysVisible===!0&&Ou(u,se.session.directory??A.directory,se.session.id),J=Ti(oe,x,A.isArchivedBucket===!0),me=J.filter(se=>!_(se));let le=Q;const V=A.isArchivedBucket||d?J:J.filter(se=>_(se)?!0:le<=0?!1:(le-=1,!0)),Z=V.flatMap(se=>xo(se)?se.lanes:[se]);p({nodes:Z,containerKey:E,projectId:W,groupDirectory:A.directory,ownerKey:te,selectionScopeKey:te,archived:A.isArchivedBucket===!0,renderContext:v?.renderContext??"project",indexedNodes:$,selectionPoolOffset:re});const G=J.length-V.length,ie=Q-le;!d&&!A.isArchivedBucket&&G>0?j({kind:"show-control",key:`${E}:more`,estimateSize:Rn,control:"more",containerKey:E,currentCount:ie,increment:be}):!d&&!A.isArchivedBucket&&me.length>ge&&G===0&&j({kind:"show-control",key:`${E}:fewer`,estimateSize:Rn,control:"fewer",containerKey:E,currentCount:ie,increment:be});const Se=t.groupStatusByKey.get(E);H.length===0&&Te.length===0?Se&&Se.state!=="ready"?j({kind:"status",key:`${E}:status`,estimateSize:Rn,status:Se,group:A,groupKey:E}):j({kind:"empty",key:`${E}:empty`,estimateSize:Rn,emptyKind:A.isArchivedBucket?"archived":"group",group:A,projectId:W}):Se&&Se.state!=="ready"&&Se.state!=="loading"&&j({kind:"status",key:`${E}:status`,estimateSize:Rn,status:Se,group:A,groupKey:E})},P=A=>{const E=!d&&t.collapsedActivities.has(A),W=e.length;return j({kind:"activity-header",key:`activity:${A}:header`,estimateSize:yo,activityKey:A,collapsed:E,forceExpanded:d}),i.push(Object.freeze({rowIndex:W,kind:"activity",id:A})),E},C=t.viewMode==="timeline",T=A=>"run"in A,R=A=>{const E=Ti(A.map(k=>k.node),x,!1),W=new Map(A.map(k=>[k.node,k]));return E.flatMap(k=>{if(!xo(k)){const v=W.get(k);return v?[v]:[]}return[{run:k.run,items:k.lanes.flatMap(v=>W.get(v)??[])}]})},M=(A,E,W,k)=>{const v=A.items[0];if(!v)return;const I=A.items.map(ee=>ee.node),H=wo(I),$=r.length;r.push(...H.preorderIds);const re=kn(v.projectId,v.groupDirectory),te=new Map(A.items.map(ee=>[ee.node.session.id,ee.getSecondaryMeta?ee.getSecondaryMeta(ee.node.session.id):ee.secondaryMeta]));h({run:A.run,lanes:I},{nodes:I,containerKey:E,projectId:v.projectId,groupDirectory:v.groupDirectory,ownerKey:re,selectionScopeKey:k?re:null,archived:!1,renderContext:W,getSecondaryMeta:ee=>te.get(ee)??null,indexedNodes:H,selectionPoolOffset:$})},F=(A,E,W,k,v=()=>1)=>{for(const I of R(A)){if(T(I)){M(I,E,W,k),d&&(f+=I.items.reduce((ee,ue)=>ee+v(ue),0));continue}const H=I,$=wo([H.node]),re=r.length;r.push(...$.preorderIds);const te=kn(H.projectId,H.groupDirectory);p({nodes:[H.node],containerKey:E,projectId:H.projectId,groupDirectory:H.groupDirectory,ownerKey:te,selectionScopeKey:null,archived:!1,renderContext:W,secondaryMeta:H.secondaryMeta,getSecondaryMeta:H.getSecondaryMeta,indexedNodes:$,selectionPoolOffset:re}),d&&(f+=v(H))}};t.chatGroup&&(!d||S(t.chatGroup)>0)&&(P("chats")||N(t.chatGroup,"activity:chats",null,!0,C?{initial:yk,increment:wk,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0));const K=t.workItems??[];if(K.length>0&&(P("work")||F(K,"activity:work",C?"timeline":"recent",!1,E=>Uh(E.node,t.normalizedQuery))),C){const A=(t.timelineItems??[]).filter(E=>!m.has(E.node.session.id));A.length>0&&(P("timeline")||F(A,"activity:timeline","timeline",!1))}if(!C&&t.showRecentSection)for(const A of t.recentSections){const E={...A,items:A.items.filter(te=>!m.has(te.node.session.id))};if(E.items.length===0||P("active-now"))continue;const k=`activity:${E.key}`,v=7,I=Math.max(v,t.visibleCountByContainer.get(k)??v),H=R(E.items),$=d?H:H.slice(0,I);for(const te of $){if(T(te)){M(te,k,"recent",!0),d&&(f+=te.items.length);continue}const ee=te,ue=wo([ee.node]),de=r.length;r.push(...ue.preorderIds),p({nodes:[ee.node],containerKey:k,projectId:ee.projectId,groupDirectory:ee.groupDirectory,ownerKey:kn(ee.projectId,ee.groupDirectory),selectionScopeKey:kn(ee.projectId,ee.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:ee.secondaryMeta,getSecondaryMeta:ee.getSecondaryMeta,indexedNodes:ue,selectionPoolOffset:de}),d&&(f+=1)}const re=H.length-$.length;!d&&re>0?j({kind:"show-control",key:`${k}:more`,estimateSize:Rn,control:"more",containerKey:k,currentCount:$.length,increment:7}):!d&&H.length>v&&j({kind:"show-control",key:`${k}:fewer`,estimateSize:Rn,control:"fewer",containerKey:k,currentCount:$.length,increment:7})}let D=C?[]:t.singleProjectMode?t.sections.filter(A=>A.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const A=D.find(E=>E.project.id===t.activeProjectId)??D[0];D=A?[A]:[]}for(const A of D){const E=lk(A,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!E.some(k=>S(k.group)>0))continue;const W=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(A.project.id);if(!t.showOnlyMainWorkspace){const k=e.length;j({kind:"project-header",key:`project:${A.project.id}:header`,estimateSize:yo,section:A,collapsed:W,forceExpanded:d}),i.push(Object.freeze({rowIndex:k,kind:"project",id:A.project.id}))}if(!W)for(const k of E)N(k.group,k.groupKey,k.projectId,k.hideGroupLabel)}e.length===0&&j({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const U=new Map;return e.forEach((A,E)=>U.set(A.key,E)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:U,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?f:0})},kk=(t,e)=>t.map(n=>{const r=gt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
879
879
  `),Ck=[],Nk=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:m,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:g,buildGroupSearchText:y,foldersMap:b,standaloneGroups:j}=t,x=c.useRef(new Map),h=c.useMemo(()=>{const R=x.current,M=new Map;let F=0,K=0;const D=(A,E)=>A.length===E.length&&A.every((W,k)=>W===E[k]),U=e.map(A=>{const E=n(A.id),W=r(A.id),k=i.get(A.normalizedPath)??Ck,v=o.has(A.id)?!!o.get(A.id):d,I=l.get(A.id)??null,H=kk(k,a),$=R.get(A.id);if($&&$.project===A&&D($.activeSessions,E)&&D($.archivedSessions,W)&&$.availableWorktrees===k&&$.rootBranch===I&&$.worktreeBranchesKey===H&&$.isRepo===v&&$.buildGroupedSessions===u)return F+=1,M.set(A.id,$),$.section;if(K+=1,$){const ue=$.project!==A?"project":D($.activeSessions,E)?D($.archivedSessions,W)?$.availableWorktrees!==k?"worktrees":$.rootBranch!==I?"branch":$.worktreeBranchesKey!==H?"worktreeBranches":$.isRepo!==v?"repo":"builder":"archived":"sessions";ys(`ui.sidebar.project_section.rebuilt_reason.${ue}`)}const re=Bu([...E,...W]),te=u(re,A.normalizedPath,k,I,v),ee={project:A,groups:te};return M.set(A.id,{project:A,activeSessions:E,archivedSessions:W,availableWorktrees:k,rootBranch:I,worktreeBranchesKey:H,isRepo:v,buildGroupedSessions:u,section:ee}),ee});return x.current=M,F>0&&ys("ui.sidebar.project_section.reused",F),K>0&&ys("ui.sidebar.project_section.rebuilt",K),U},[e,n,r,i,o,d,u,l,a]),p=c.useMemo(()=>h,[h]),w=c.useMemo(()=>{const R=new WeakMap;if(!m)return R;const F=f.trim().toLowerCase().startsWith("ses_"),K=D=>{const U=g(D.sessions,f),A=Yf(U,f),E=!F&&Bo([y(D)],f),W=Gr(D).flatMap(({scopeKey:v})=>b[v]??[]),k=F?0:W.filter(v=>Bo([v.name],f)).length;R.set(D,{filteredNodes:U,matchedSessionCount:A,folderNameMatchCount:k,groupMatches:E,hasMatch:E||A>0||k>0})};return p.forEach(D=>{D.groups.forEach(K)}),j.forEach(K),R},[m,p,j,g,f,y,b]),S=c.useMemo(()=>m?p.map(R=>({...R,groups:R.groups.filter(M=>w.get(M)?.hasMatch===!0)})).filter(R=>R.groups.length>0):p,[m,p,w]),N=m?S:p,P=c.useRef(new WeakMap),C=c.useMemo(()=>{const R=P.current;return N.map(M=>{const F=R.get(M);if(F&&F.query===f)return F.section;const K=M.groups.filter(v=>!v.isArchivedBucket),D=M.groups.filter(v=>v.isArchivedBucket),U=K.flatMap(v=>m?w.get(v)?.filteredNodes??[]:v.sessions),A=K.map(v=>({scopeKey:v.folderScopeKey??gt(v.directory??null),directory:v.directory??null})).filter(v=>!!v.scopeKey),E=K.find(v=>v.isMain)??null,W={id:"flat",label:E?.label??"",branch:E?.branch??null,description:E?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:E?.directory??M.project.normalizedPath,folderScopeKey:E?.folderScopeKey??M.project.normalizedPath,folderScopes:A,sessions:U};if(m){const v=K.map(I=>w.get(I)).filter(I=>!!I);w.set(W,{filteredNodes:U,matchedSessionCount:v.reduce((I,H)=>I+H.matchedSessionCount,0),folderNameMatchCount:v.reduce((I,H)=>I+H.folderNameMatchCount,0),groupMatches:v.some(I=>I.groupMatches),hasMatch:v.some(I=>I.hasMatch)})}const k={project:M.project,groups:[W,...D]};return R.set(M,{query:f,section:k}),k})},[w,m,f,N]),T=c.useMemo(()=>{if(!m)return 0;const R=(F,K)=>{const D=w.get(K);if(!D)return F;const U=D.folderNameMatchCount+(D.groupMatches?1:0);return F+D.matchedSessionCount+U},M=N.reduce((F,K)=>K.groups.reduce(R,F),0);return j.reduce(R,M)},[m,N,j,w]);return{projectSections:h,visibleProjectSections:p,groupSearchDataByGroup:w,searchableProjectSections:S,sectionsForRender:N,flatSectionsForRender:C,searchMatchCount:T}},Ak=180,Hc=150,Pk=2,Dk=8,Gc=[-1,1],Ei=t=>`${t.directory}
880
880
  ${t.sessionId}`,Ik=t=>t?.directory?.trim()||null,Tk=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>An(),[]),m=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(y=>window.clearTimeout(y)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<Pk&&l.current.length>0;){const y=l.current.shift();if(!y)break;if(y.generation!==d.current||ot.getState().currentSessionId===y.sessionId||qi(y.sessionId,y.directory).renderable)continue;const j=Ei(y);a.current.add(j),i({directory:y.directory,sessionID:y.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(j),f()})}},[t,u,i]),g=c.useCallback(y=>{const b=y?.id,j=Ik(y);if(!t||u||!b||!j||b===e)return;const x={sessionId:b,directory:j,generation:d.current},h=Ei(x);if(qi(b,j).renderable||a.current.has(h)||l.current.some(S=>Ei(S)===h))return;const p=o.current.get(h);p!==void 0&&window.clearTimeout(p);const w=window.setTimeout(()=>{if(o.current.delete(h),x.generation!==d.current)return;const S=l.current;S.length>=Dk&&S.shift(),S.push(x),f()},Ak);o.current.set(h,w)},[e,t,u,f]);c.useEffect(()=>{m()},[m,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const y=window.setTimeout(()=>{const b=n.findIndex(j=>j.id===e);if(!(b<0))for(const j of Gc)g(n[b+j])},Hc);return()=>window.clearTimeout(y)},[e,t,u,g,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const y=window.setTimeout(()=>{const b=r.findIndex(j=>j.id===e);if(!(b<0))for(const j of Gc)g(r[b+j])},Hc);return()=>window.clearTimeout(y)},[e,t,u,r,g]),c.useEffect(()=>m,[m])},Ek=t=>{const e=nt.c(3),n=ot(Rk);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],Tk(r),null};function Rk(t){return t.currentSessionId}const Mk=t=>{const e=nt.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:m,children:f,renderBody:g,mobileVariant:y,alwaysShowActions:b,isRenaming:j,renameDraft:x,onRenameDraftChange:h,onRenameSave:p,onRenameCancel:w,droppableRef:S,isDropTarget:N,onNewSession:P,depth:C,hideActions:T,archivedBucket:R}=t,M=a===void 0?null:a,F=g===void 0?!0:g,D=b===void 0?y===void 0?!1:y:b,U=j===void 0?!1:j,A=x===void 0?"":x,E=N===void 0?!1:N,W=T===void 0?!1:T,k=R===void 0?!1:R,{t:v}=At(),[I,H]=c.useState(!1),[$,re]=c.useState(""),te=c.useRef(null),ee=U||I,ue=U?A:$;let de;e[0]!==n.name?(de=()=>{re(n.name),H(!0)},e[0]=n.name,e[1]=de):de=e[1];const Te=de;let we;e[2]!==ue||e[3]!==n.name||e[4]!==U||e[5]!==u||e[6]!==p?(we=()=>{const Le=ue.trim();Le&&Le!==n.name&&u(Le),U&&p&&p(),H(!1),re("")},e[2]=ue,e[3]=n.name,e[4]=U,e[5]=u,e[6]=p,e[7]=we):we=e[7];const fe=we;let Ne;e[8]!==U||e[9]!==w?(Ne=()=>{U&&w&&w(),H(!1),re("")},e[8]=U,e[9]=w,e[10]=Ne):Ne=e[10];const L=Ne;let oe;e[11]!==U||e[12]!==h?(oe=Le=>{U&&h?h(Le):re(Le)},e[11]=U,e[12]=h,e[13]=oe):oe=e[13];const ce=oe;let pe,Y;e[14]!==U?(pe=()=>{if(!U)return;const Le=()=>{const he=te.current;he&&(he.focus(),he.select())},Ve=requestAnimationFrame(Le),O=window.setTimeout(Le,0);return()=>{cancelAnimationFrame(Ve),window.clearTimeout(O)}},Y=[U],e[14]=U,e[15]=pe,e[16]=Y):(pe=e[15],Y=e[16]),c.useEffect(pe,Y);const ve=l?"folder":"folder-open",Ee=E&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let je;e[17]!==Ee?(je=De("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Ee),e[17]=Ee,e[18]=je):je=e[18];let ge;e[19]!==d||e[20]!==ee?(ge=ee?void 0:Le=>{Le.currentTarget.blur(),d()},e[19]=d,e[20]=ee,e[21]=ge):ge=e[21];const be=ee?void 0:"button",Q=ee?void 0:0;let _;e[22]!==d||e[23]!==ee?(_=ee?void 0:Le=>{(Le.key==="Enter"||Le.key===" ")&&(Le.preventDefault(),d())},e[22]=d,e[23]=ee,e[24]=_):_=e[24];let J;e[25]!==n.name||e[26]!==l||e[27]!==v?(J=l?v("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):v("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=v,e[28]=J):J=e[28];const me=k?D?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":D?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let le;e[29]!==me?(le=De("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",me),e[29]=me,e[30]=le):le=e[30];const V=E?"text-primary":"text-muted-foreground";let Z;e[31]!==V?(Z=De("h-3.5 w-3.5 flex-shrink-0",V),e[31]=V,e[32]=Z):Z=e[32];let G;e[33]!==ve||e[34]!==Z?(G=s.jsx(B,{name:ve,className:Z}),e[33]=ve,e[34]=Z,e[35]=G):G=e[35];let ie;e[36]!==M||e[37]!==r||e[38]!==ue||e[39]!==n.name||e[40]!==L||e[41]!==ce||e[42]!==fe||e[43]!==l||e[44]!==E||e[45]!==ee||e[46]!==i||e[47]!==v?(ie=ee?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:Ok,onMouseDown:Bk,onSubmit:Le=>{Le.preventDefault(),fe()},children:[s.jsx("input",{ref:te,value:ue,onChange:Le=>ce(Le.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:v("sessions.sidebar.folderItem.namePlaceholder"),onClick:Fk,onPointerDown:Lk,onMouseDown:_k,onKeyDown:Le=>{if(Le.key==="Escape"){Le.stopPropagation(),L();return}(Le.key===" "||Le.key==="Enter")&&Le.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:$k,onPointerDown:zk,onMouseDown:Wk,children:s.jsx(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Le=>{Le.stopPropagation(),L()},onPointerDown:Kk,onMouseDown:Vk,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:De("typography-ui-label font-semibold truncate",E?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(jt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),M?s.jsx(Hh,{state:M}):null,l?s.jsx(B,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=M,e[37]=r,e[38]=ue,e[39]=n.name,e[40]=L,e[41]=ce,e[42]=fe,e[43]=l,e[44]=E,e[45]=ee,e[46]=i,e[47]=v,e[48]=ie):ie=e[48];let Se;e[49]!==le||e[50]!==G||e[51]!==ie?(Se=s.jsxs("div",{className:le,children:[G,ie]}),e[49]=le,e[50]=G,e[51]=ie,e[52]=Se):Se=e[52];let se;e[53]!==D||e[54]!==k||e[55]!==n.name||e[56]!==Te||e[57]!==W||e[58]!==m||e[59]!==P||e[60]!==ee||e[61]!==v?(se=!ee&&(!W||k)?s.jsx("div",{className:De("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",D?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!k&&P?s.jsx("button",{type:"button",onClick:Le=>{Le.stopPropagation(),P()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":v("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:v("sessions.sidebar.project.actions.newSession"),children:s.jsx(B,{name:"add",className:"h-3.5 w-3.5"})}):null,k?null:s.jsx("button",{type:"button",onClick:Le=>{Le.stopPropagation(),Te()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":v("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(B,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Le=>{Le.stopPropagation(),m()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":k?v("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):v("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=D,e[54]=k,e[55]=n.name,e[56]=Te,e[57]=W,e[58]=m,e[59]=P,e[60]=ee,e[61]=v,e[62]=se):se=e[62];let Me;e[63]!==S||e[64]!==je||e[65]!==ge||e[66]!==be||e[67]!==Q||e[68]!==_||e[69]!==J||e[70]!==Se||e[71]!==se?(Me=s.jsxs("div",{ref:S,className:je,onClick:ge,role:be,tabIndex:Q,onKeyDown:_,"aria-label":J,children:[Se,se]}),e[63]=S,e[64]=je,e[65]=ge,e[66]=be,e[67]=Q,e[68]=_,e[69]=J,e[70]=Se,e[71]=se,e[72]=Me):Me=e[72];let He;e[73]!==f||e[74]!==l||e[75]!==F||e[76]!==i||e[77]!==o||e[78]!==v?(He=!l&&F?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:v("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=F,e[76]=i,e[77]=o,e[78]=v,e[79]=He):He=e[79];let We;return e[80]!==Me||e[81]!==He?(We=s.jsxs("div",{className:"oc-folder",children:[Me,He]}),e[80]=Me,e[81]=He,e[82]=We):We=e[82],We},Qf=c.memo(Mk);function Ok(t){return t.stopPropagation()}function Bk(t){return t.stopPropagation()}function Fk(t){return t.stopPropagation()}function Lk(t){return t.stopPropagation()}function _k(t){return t.stopPropagation()}function $k(t){return t.stopPropagation()}function zk(t){return t.stopPropagation()}function Wk(t){return t.stopPropagation()}function Kk(t){return t.stopPropagation()}function Vk(t){return t.stopPropagation()}function Uk(t){const e=nt.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=Zd(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(Qf,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const qr=t=>{const e=nt.c(13),{directory:n,className:r}=t,{t:i}=At();let o;e[0]!==n?(o=ah(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=j=>j.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Et(a)?.tabs.some(Kd))return null;let m;e[4]!==i?(m=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=m):m=e[5];const f=m;let g;e[6]!==r?(g=De("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=g):g=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(B,{name:"pulse",className:"size-3.5"}),e[8]=y):y=e[8];let b;return e[9]!==l||e[10]!==f||e[11]!==g?(b=s.jsx("span",{className:g,role:"img","aria-label":f,title:f,"data-action-directory":l,children:y}),e[9]=l,e[10]=f,e[11]=g,e[12]=b):b=e[12],b},Hk=t=>{const e=nt.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,m=a===void 0?!1:a,f=`session-drag:${r??n}`;let g;e[0]!==m||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(g={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:m},e[0]=m,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=g):g=e[5];let y;e[6]!==m||e[7]!==f||e[8]!==g?(y={id:f,disabled:m,data:g},e[6]=m,e[7]=f,e[8]=g,e[9]=y):y=e[9];const{attributes:b,listeners:j,setNodeRef:x,isDragging:h}=px(y);let p;e[10]!==j?(p=P=>{P.stopPropagation(),j?.onPointerDown&&j.onPointerDown(P)},e[10]=j,e[11]=p):p=e[11];const w=p,S=`touch-pan-y select-none${h?" opacity-30":""}`;let N;return e[12]!==b||e[13]!==d||e[14]!==w||e[15]!==j||e[16]!==x||e[17]!==S?(N=s.jsx("div",{ref:x,...b,...j,onPointerDown:w,className:S,children:d}),e[12]=b,e[13]=d,e[14]=w,e[15]=j,e[16]=x,e[17]=S,e[18]=N):N=e[18],N},Xf=t=>{const e=nt.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=Bn(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let m;e[3]!==a||e[4]!==r?(m=a||tl(r),e[3]=a,e[4]=r,e[5]=m):m=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let g;e[10]!==u||e[11]!==m||e[12]!==f?(g={id:u,disabled:m,data:f},e[10]=u,e[11]=m,e[12]=f,e[13]=g):g=e[13];const{setNodeRef:y,isOver:b}=gx(g);let j;e[14]!==l||e[15]!==b||e[16]!==y?(j=l(y,b),e[14]=l,e[15]=b,e[16]=y,e[17]=j):j=e[17];let x;return e[18]!==j?(x=s.jsx(s.Fragment,{children:j}),e[18]=j,e[19]=x):x=e[19],x},Gk=t=>{const e=nt.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const m=Zo(fn(ti,d),fn(ei,u)),[f,g]=c.useState(null),[y,b]=c.useState("Session"),[j,x]=c.useState(null),[h,p]=c.useState(null);if(!n){let M;return e[2]!==l?(M=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=M):M=e[3],M}let w;e[4]!==o||e[5]!==a?(w=M=>{g(null),x(null),p(null);const{active:F,over:K}=M;if(!K)return;const D=F.data.current,U=K.data.current;D?.type!=="session"||!D.sessionId||!D.ownerKey||D.archivedBucket===!0||a&&D.ownerKey!==a||U?.type!=="folder"||!U.folderId||!U.scopeKey||!U.ownerKey||tl(U.scopeKey)||U.ownerKey!==D.ownerKey||o(D.sessionId,{folderId:U.folderId,scopeKey:U.scopeKey,ownerKey:U.ownerKey},D.ownerKey)},e[4]=o,e[5]=a,e[6]=w):w=e[6];const S=w;let N,P;e[7]===Symbol.for("react.memo_cache_sentinel")?(N=M=>{const F=M.active.data.current;if(F?.type==="session"&&F.sessionId){g(F.sessionId),b(F.sessionTitle??"Session");const K=M.active.rect.current.initial?.width,D=M.active.rect.current.initial?.height;x(K??null),p(D??null)}},P=()=>{g(null),x(null),p(null)},e[7]=N,e[8]=P):(N=e[7],P=e[8]);let C;e[9]!==h||e[10]!==f||e[11]!==y||e[12]!==j||e[13]!==i?(C=f&&i?s.jsxs("div",{style:{width:j?`${j}px`:"auto",height:h?`${h}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(B,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:y})]}):null,e[9]=h,e[10]=f,e[11]=y,e[12]=j,e[13]=i,e[14]=C):C=e[14];let T;e[15]!==C?(T=s.jsx(bx,{children:C}),e[15]=C,e[16]=T):T=e[16];let R;return e[17]!==l||e[18]!==S||e[19]!==m||e[20]!==T?(R=s.jsxs(si,{sensors:m,collisionDetection:ni,onDragStart:N,onDragCancel:P,onDragEnd:S,children:[l,T]}),e[17]=l,e[18]=S,e[19]=m,e[20]=T,e[21]=R):R=e[21],R},Jf=c.createContext(null),qk=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Jf.Provider,{value:a.current,children:r})},Zf=()=>c.useContext(Jf),Yk=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const m of u)l.has(m)||(l.add(m),o.push(m))}return o.length>0?{ids:o,scopeKey:i}:null},em=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},Qk=t=>{const e=nt.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[m,f]=c.useState(!1),g=i===n&&!m,y=r?i===r&&!m:d;let b;e[0]!==l||e[1]!==i||e[2]!==o?(b=R=>{if(i===R){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=b):b=e[3];const j=b;let x;e[4]!==n||e[5]!==j||e[6]!==o?(x=R=>{if(R){u(!1),f(!1),o(n);return}j(n)},e[4]=n,e[5]=j,e[6]=o,e[7]=x):x=e[7];const h=x;let p;e[8]!==r||e[9]!==j||e[10]!==o?(p=R=>{if(!r){u(R);return}if(R){f(!1),o(r);return}j(r)},e[8]=r,e[9]=j,e[10]=o,e[11]=p):p=e[11];const w=p;let S;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(S=R=>{R||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=S):S=e[17];const N=S;let P;e[18]!==g||e[19]!==n||e[20]!==o?(P=()=>{f(!1),o(g?null:n)},e[18]=g,e[19]=n,e[20]=o,e[21]=P):P=e[21];const C=P;let T;return e[22]!==w||e[23]!==h||e[24]!==N||e[25]!==y||e[26]!==g||e[27]!==C?(T={isMenuOpen:g,isContextMenuOpen:y,handleMenuOpenChange:h,handleContextMenuOpenChange:w,handleMenuOpenChangeComplete:N,toggleMenu:C},e[22]=w,e[23]=h,e[24]=N,e[25]=y,e[26]=g,e[27]=C,e[28]=T):T=e[28],T},Xk=t=>{const e=nt.c(10),{project:n,fallback:r}=t,{currentTheme:i}=qn(),o=n.iconImage??null;let l;e[0]!==n.id||e[1]!==o?(l={id:n.id,iconImage:o},e[0]=n.id,e[1]=o,e[2]=l):l=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=s.jsx(Ka,{project:l,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},Jk=t=>{const e=nt.c(13),{project:n}=t,r=n?.icon?za[n.icon]:null,i=n?.color?Wa[n.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?s.jsx(B,{name:r,className:De("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):s.jsx(B,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!n?.iconImage){let m;return e[3]!==l?(m=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=m):m=e[4],m}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==n?(d=s.jsx(Xk,{project:n,fallback:l}),e[7]=l,e[8]=n,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},ba=t=>{const e=nt.c(46),{compact:n,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,thirdLineLead:d,statusDot:u,pinnedMarker:m,timeSlot:f,directoryIndicator:g,prBadge:y,zombieIndicator:b,badges:j,doneHint:x,providerId:h,metaPaddingClass:p,hideMetaOnHoverClass:w}=t,S=n===void 0?!1:n,N=d===void 0?null:d,P=x===void 0?null:x,C=!S&&(!!a||!!N||!!y||!!b||!!j||!!h);let T;e[0]!==w||e[1]!==p?(T=De("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",p,w),e[0]=w,e[1]=p,e[2]=T):T=e[2];const R=S?j:null;let M;e[3]!==f?(M=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:f}),e[3]=f,e[4]=M):M=e[4];let F;e[5]!==g||e[6]!==P||e[7]!==m||e[8]!==u||e[9]!==T||e[10]!==R||e[11]!==M?(F=s.jsxs("span",{className:T,children:[R,g,m,P,u,M]}),e[5]=g,e[6]=P,e[7]=m,e[8]=u,e[9]=T,e[10]=R,e[11]=M,e[12]=F):F=e[12];const K=F;if(S){let I;e[13]!==l?(I=De("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[13]=l,e[14]=I):I=e[14];let H;e[15]!==I||e[16]!==o?(H=s.jsx("div",{className:I,children:o}),e[15]=I,e[16]=o,e[17]=H):H=e[17];let $;return e[18]!==K||e[19]!==H?($=s.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[H,K]}),e[18]=K,e[19]=H,e[20]=$):$=e[20],$}let D;e[21]!==r?(D=s.jsx(Jk,{project:r}),e[21]=r,e[22]=D):D=e[22];let U;e[23]!==i?(U=i?s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[23]=i,e[24]=U):U=e[24];let A;e[25]!==K||e[26]!==D||e[27]!==U?(A=s.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[D,U,K]}),e[25]=K,e[26]=D,e[27]=U,e[28]=A):A=e[28];let E;e[29]!==l?(E=De("w-full min-w-0 truncate typography-ui-label font-normal",l),e[29]=l,e[30]=E):E=e[30];let W;e[31]!==E||e[32]!==o?(W=s.jsx("div",{className:E,children:o}),e[31]=E,e[32]=o,e[33]=W):W=e[33];let k;e[34]!==j||e[35]!==a||e[36]!==C||e[37]!==y||e[38]!==h||e[39]!==N||e[40]!==b?(k=C?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[N??(a?s.jsxs(s.Fragment,{children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null),s.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[b??y,j,h?s.jsx(Fu,{providerId:h,className:"h-4 w-4 flex-shrink-0 opacity-45"}):null]})]}):null,e[34]=j,e[35]=a,e[36]=C,e[37]=y,e[38]=h,e[39]=N,e[40]=b,e[41]=k):k=e[41];let v;return e[42]!==A||e[43]!==W||e[44]!==k?(v=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[A,W,k]}),e[42]=A,e[43]=W,e[44]=k,e[45]=v):v=e[45],v};let xa=!1;const ya=new Set;let qc=!1;function Zk(){for(const t of ya)t()}function sl(t){xa!==t&&(xa=t,Zk())}function e2(t){t.key==="Shift"&&sl(!0)}function t2(t){t.key==="Shift"&&sl(!1)}function s2(){sl(!1)}function n2(){qc||typeof window>"u"||(qc=!0,window.addEventListener("keydown",e2),window.addEventListener("keyup",t2),window.addEventListener("blur",s2))}function r2(t){return n2(),ya.add(t),()=>{ya.delete(t)}}function o2(){return xa}function i2(){return!1}function a2(){return lt.useSyncExternalStore(r2,o2,i2)}const tm=async(t,e,n)=>{const r=n.getRuntimeKey(),i=gt(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=n.getCurrentProjects(),a=l.find(b=>b.id===t.id)??null;if(!a||gt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=nl({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(b=>Uo(b));u.sort((b,j)=>sm({metadata:b},{metadata:j}));const m=Fg(d.worktreesByProject,i,u,e?.projectDirectory);l2(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:m};const f=n.getPublishedWorktreesByProject(),g=Lg(n.partitionWorktreesByRegisteredProject(l,m),f),y=[...g.values()].flat();return n.recordWorktreesSeen(y.map(b=>b.path),n.now()),n.worktreeMapsEqual(g,f)||n.publishTopology({availableWorktrees:y,availableWorktreesByProject:g}),u},l2=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),c2=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Uo(r))])),nl=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:c2(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),sm=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},Yc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Uo=t=>({...t,path:gt(t.path)??t.path,projectDirectory:gt(t.projectDirectory)??t.projectDirectory,worktreeRoot:gt(t.worktreeRoot??t.path)??t.worktreeRoot}),Qc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=gt(e?.path??null)===n,a=l?e?.branch??"":i??"",d={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Yc(n):i||Yc(n),name:l?e?.name:void 0,worktreeRoot:l?gt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...d}:d},Xc=t=>{const e=gt(t.projectPath??null),n=gt(t.sourceDirectory??null)??gt(t.currentWorktree?.path??null),r=gt(t.discoveredWorktrees.find(m=>gt(m.projectDirectory??null))?.projectDirectory??null),i=gt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=m=>{const f=gt(m.metadata.path??null);!f||l.has(f)||l.set(f,{...m,metadata:Uo({...m.metadata,path:f})})};for(const m of t.discoveredWorktrees){const f=gt(m.path??null);f&&a({metadata:Uo({...m,path:f,projectDirectory:gt(m.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:Qc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:Qc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const d=[],u=[];for(const m of l.values()){if(m.isPrimary){d.push(m);continue}u.push(m)}return d.sort((m,f)=>m.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),u.sort(sm),[...d,...u]},nm=(t,e)=>{const n=t.projectId?e.projects.find(o=>o.id===t.projectId)??null:null;if(n)return n;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const i=t.currentWorktree?.projectDirectory??null;return i?e.resolveProject(i):null},d2=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=nl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),o=nm(t,e),l=gt(o?.path??null);return{cachedTargets:Xc({projectPath:l,discoveredWorktrees:l?i.worktreesByProject.get(l)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!o||!l)throw new Error("Unable to resolve worktree project");const d=await tm(o,t.currentWorktree,e);return Xc({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},u2=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},f2=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),m2=(t,e)=>gt(t.worktree?.path??null)===gt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,Br=6,vo=14,Jc=Br+14+6,Ri=new WeakMap,h2=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Ri.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,Ri.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,ys("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(d)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Ri.set(n,a),l=window.requestAnimationFrame(d)},p2=c.memo(function(e){const n=nt.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:m}=e,f=a2(),g=f?i:r;let y;n[0]!==u||n[1]!==m||n[2]!==f?(y=P=>{if(f||P.shiftKey){m(P);return}u(P)},n[0]=u,n[1]=m,n[2]=f,n[3]=y):y=n[3];const b=y,j=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;n[4]!==o||n[5]!==j?(x=De("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",j,o),n[4]=o,n[5]=j,n[6]=x):x=n[6];const h=f?"delete-bin":"archive";let p;n[7]!==l||n[8]!==h?(p=s.jsx(B,{name:h,className:l}),n[7]=l,n[8]=h,n[9]=p):p=n[9];let w;n[10]!==b||n[11]!==g||n[12]!==d||n[13]!==a||n[14]!==x||n[15]!==p?(w=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:x,"aria-label":g,onPointerDown:a,onMouseDown:d,onClick:b,onKeyDown:k2,children:p})}),n[10]=b,n[11]=g,n[12]=d,n[13]=a,n[14]=x,n[15]=p,n[16]=w):w=n[16];let S;n[17]!==g?(S=s.jsx(jt,{side:"left",sideOffset:8,children:g}),n[17]=g,n[18]=S):S=n[18];let N;return n[19]!==w||n[20]!==S?(N=s.jsxs(vt,{children:[w,S]}),n[19]=w,n[20]=S,n[21]=N):N=n[21],N});function g2(t){ys("ui.sidebar_session_node.render");const{t:e}=At(),{node:n,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:m,hasSessionSearchQuery:f,normalizedSessionSearchQuery:g,notifyOnSubtasks:y,editingId:b,editingRowKey:j,setEditingId:x,setEditingRowKey:h,editTitle:p,setEditTitle:w,handleSaveEdit:S,handleCancelEdit:N,toggleParent:P,handleSessionSelect:C,handleSessionDoubleClick:T,handleCopySessionId:R,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,createFolderAndStartRename:K,handleDeleteSession:D,handleRestoreSession:U,startSessionWorktreeMenuLoad:A,onEditProject:E,mobileVariant:W,alwaysShowActions:k,secondaryMeta:v,renderContext:I="project",rowKey:H,dragKey:$,children:re}=t,te=Ur(Ce=>Ce.toggle),ee=Gt(Ce=>Ce.getFoldersForScope),ue=Gt(Ce=>Ce.getSessionFolderId),de=Gt(Ce=>Ce.removeSessionFromFolder),Te=Gt(Ce=>Ce.addSessionToFolder),we=ye(Ce=>Ce.openContextPanelTab),fe=c.useMemo(()=>An(),[]),Ne=c.useMemo(()=>Kr(),[]),L=c.useContext(_g),oe=fe?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto",ce=fe?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",pe=fe,Y=!d&&!W,ve=ye(Ce=>Ce.sessionWorkEnabled),Ee=ye(Ce=>Ce.sessionRecapEnabled),je=ve&&!d&&!n.session.parentID&&!_a(n.session.directory),ge=je&&!k,be=(ge?1:0)+(Y?1:0)+(pe?1:0),Q=fe?["group-hover:pr-8","group-hover:pr-14","group-hover:pr-18","group-hover:pr-22"][be]:["group-hover:pr-3 group-has-[:focus-visible]:pr-3","group-hover:pr-7 group-has-[:focus-visible]:pr-7","group-hover:pr-11 group-has-[:focus-visible]:pr-11"][be],_=Y?"pr-13":"pr-7",J=fe?["pr-8","pr-14","pr-18","pr-22"][be]:["pr-3","pr-7","pr-11"][be],me=c.useRef(!1),[le,V]=c.useState(!1),Z=c.useRef(b);Z.current=b;const G=c.useRef(null),ie=c.useRef(!1),Se=c.useRef(S);Se.current=S;const se=p,Me=c.useRef(se);Me.current=se;const He=c.useRef(null),We=c.useRef(!1),Le=c.useRef(null),Ve=c.useRef(null),O=n.session,he=O,$e=zt(c.useCallback(Ce=>{if(v?.projectLabel||!o)return null;const Tt=Ce.projects.find(Ut=>Ut.id===o);return Tt?Tt.label?.trim()||yr(gt(Tt.path)??Tt.path,null)||Tt.path:null},[o,v?.projectLabel])),Ue=I==="timeline"||I==="timeline-chat",ct=I==="timeline-chat",pt=zt(c.useCallback(Ce=>!Ue||!o?null:Ce.projects.find(Tt=>Tt.id===o)??null,[Ue,o])),it=v?.projectLabel??($e?Lu($e):null),ft=hk(v,n.worktree?.branch??null),yt=c.useMemo(()=>pk(n.worktree,fe),[fe,n.worktree]),ht=_u(yt),bt=ht?`var(--pr-${ht.visualState})`:void 0,Dt=!!ft&&I==="recent",xe=c.useMemo(()=>{if(!ht)return null;switch(ht.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return ht.canMerge===!0||ht.mergeableState==="clean"||ht.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return ht.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[ht,e]),Ye=ot(Ce=>Ce.currentSessionId===O.id),Xe=gt(O.directory??null)??gt(i??null),qe=a!==void 0?a:o??Xe??null,dt=hu(),X=$u(),ae=fe,Ae=es(Ce=>Ce.enabled),Ge=es(c.useCallback(Ce=>Ce.selectedIds.has(O.id),[O.id])),q=es(Ce=>Ce.toggleSelected),Fe=es(Ce=>Ce.setRange),Ze=Zf(),Je=H??O.id,et=b===O.id&&j===Je,kt=c.useCallback(Ce=>{const Tt=[],Ut=Jt=>{Jt.children.forEach(ls=>{Tt.push(ls.session.id),Ut(ls)})};return Ut(Ce),Tt},[]),Qe=c.useCallback(Ce=>{const Tt=[],Ut=Jt=>{Jt.children.forEach(ls=>{Tt.push(ls.session),Ut(ls)})};return Ut(Ce),Tt},[]),[It,Mt]=c.useState(!1),[ke,Oe]=c.useState(!0),Re=`${I}:${d?"archived":"active"}:${O.id}`,Be=H?`session-menu:${H}`:Re,Ke=H?`session-context:${H}`:null,rt=zu(c.useCallback(Ce=>!!Ce.sessionMemoryState.get($g(O.id))?.isZombie,[O.id])),xt=ou(O.id),Pe=zg(O.id,xt),ze=ff(O.id),st=Da(O.id,Xe),at=ze||st,Ct=n.worktree??ot.getState().getWorktreeMetadata(O.id)??null,[Ot,Lt]=c.useState([]),[Kt,Rt]=c.useState(!1),[Vt,$t]=c.useState(!1),Xt=c.useRef(!1),Bt=c.useRef(0),ut=Wg(O.id,Xe??void 0,{bootstrap:!1}),ts=Kg(he),ss=je&&Wu(he),fs=ss&&!xt&&Vg(he),Jn=e(ss?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),Ns=async()=>{try{await tb(O.id,Xe,ss?"done":"open")}catch{_e.error(e("sessions.sidebar.session.work.updateFailed"))}},xn=ts?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Ol[ts.status]),"aria-label":e(Ol[ts.status]),children:s.jsx(B,{name:"target",className:"h-3 w-3",style:{color:Ug[ts.status]}})}):null,gs=he.title||e("sessions.sidebar.session.untitled"),yn=!Ue&&n.children.length>0,Gs=Ou(u,Xe,O.id),Tn=Re,$s=f?!0:m.has(Tn),tn=c.useMemo(()=>uk(n,$s,Xe),[$s,n,Xe]),bs=Hg(tn),Zn=!!he.parentID,zs=iu(O.id)>0&&(!Zn||y),Ts=he.time?.updated||he.time?.created||Date.now(),tr=Ku(Ts),sn=Vu(Ts),{isMenuOpen:sr,isContextMenuOpen:nr,handleMenuOpenChange:eo,handleContextMenuOpenChange:to,handleMenuOpenChangeComplete:ne,toggleMenu:z}=Qk({menuInstanceKey:Be,contextMenuInstanceKey:Ke,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,hasDeferredCloseWork:()=>G.current!==null,onCloseComplete:()=>{if(!G.current)return;const{id:Ce,title:Tt}=G.current;G.current=null,x(Ce),h(Je),w(Tt)}}),Ie=sr||nr,tt=c.useMemo(()=>Gg(he)?.key??null,[he]),wt=c.useMemo(()=>kt(n).length,[kt,n]),Pt=c.useCallback(async Ce=>{const Tt=[];let Ut=0;for(const Jt of Ce)try{if(!Xe)throw new Error("Session directory is required for export");const ls=await dt({directory:Xe,sessionID:Jt.session.id});if(!ls)throw new Error("Session runtime changed during export");const Ht=Jt.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Es=Jt.session.agent,Yt=await Pt(Jt.children);Ut+=Yt.skipped,Tt.push({title:Ht,agent:Es,records:ls,children:Yt.children})}catch{Ut+=kt(Jt).length+1}return{children:Tt,skipped:Ut}},[kt,dt,Xe,e]),Nt=c.useCallback(Ce=>{Ce<=0||_e.warning(Ce===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ce}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ce}))},[e]),Ft=c.useCallback(async Ce=>{if(!Xe){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Tt=await dt({directory:Xe,sessionID:O.id}).catch(()=>null);if(!Tt){_e.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Tt.length===0){_e.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Ut,Jt=0;if(Ce&&n.children.length>0){const Yt=await Pt(n.children);Ut=Yt.children,Jt=Yt.skipped}const ls=pu(Tt,he.title??null,Ut),Ht=gu(he.title??null),Es=await bu(ls,Ht);if(Es){_e.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Yg()),onClick:()=>{qg(Es).then(Yt=>{Yt||_e.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Nt(Jt);return}xu(ls,Ht),_e.success(e("sessions.sidebar.session.export.success")),Nt(Jt)},[Pt,dt,n.children,he.title,O.id,Xe,Nt,e]),rs=yu(),Qt=c.useMemo(()=>wu(rs),[rs]),qs=c.useCallback(Ce=>{df({entry:Ce,t:e,session:{id:O.id,title:he.title,directory:Xe},loadRecords:()=>Xe?dt({directory:Xe,sessionID:O.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>_e.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[dt,he.title,O.id,Xe,e]),nn=c.useCallback(async()=>{if(n.children.length>0){Oe(!0),Mt(!0);return}await Ft(!1)},[Ft,n.children.length]),di=c.useCallback(()=>{Xe&&Nn("desktop_open_session_mini_chat_window",{sessionId:O.id,directory:Xe,apiBaseUrl:hn(),clientToken:Vr()}).catch(Ce=>{console.warn("[session-sidebar] failed to open mini chat window",Ce)})},[O.id,Xe]);if(c.useEffect(()=>{if(!et)return;const Ce=Tt=>{const Jt=(Tt.target instanceof HTMLElement?Tt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Je)}"]`);Ve.current&&!Jt&&Se.current(Me.current)};return document.addEventListener("mousedown",Ce),()=>document.removeEventListener("mousedown",Ce)},[et,Je]),c.useLayoutEffect(()=>{if(!et){He.current===Je&&(He.current=null);return}He.current!==Je&&(He.current=Je,We.current=!0)},[p,et,Je]),c.useLayoutEffect(()=>{if(!et||!We.current)return;const Ce=Le.current;!Ce||Ce.value!==p||(We.current=!1,Ce.focus(),Ce.select())},[p,et,se]),et){const Ce=s.jsxs("form",{ref:Ve,"data-session-rename-form":Je,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Tt=>{Tt.preventDefault(),S(se)},children:[s.jsx("input",{ref:Le,value:se,onChange:Tt=>w(Tt.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Tt=>$i(Tt,N)}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"check",className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:N,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-3.5"})})]});return Ue?s.jsx("div",{style:{paddingLeft:Br+4},className:De("group relative my-0.5 flex items-center rounded-md pr-2.5",ct?"py-1":"py-1.5",Ye&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:s.jsx(ba,{compact:ct,project:pt,projectLabel:it,title:Ce,titleClassName:"text-foreground",branchLabel:ft,statusDot:null,pinnedMarker:null,timeSlot:sn,directoryIndicator:null,prBadge:ht?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 typography-micro",style:bt?{color:bt}:void 0,children:[s.jsx(B,{name:"git-pull-request",className:"h-3 w-3",style:bt?{color:bt}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",ht.number]})]}):null,zombieIndicator:null,badges:null,hideMetaOnHoverClass:""})},O.id):s.jsx("div",{style:{paddingLeft:Jc+r*vo},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:Ce})},O.id)}const Ys=ut.length,so=bs===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:bs}),ui=mk({actionsAlwaysVisible:k&&!fe,menuOpen:Ie,hideOnHoverClass:ce}),rl=!at&&!xt&&zs&&!Ye,rr=xt||rl,wm=e(xt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),ol=s.jsx(cu,{state:xt?"running":"unread",label:wm}),no=(xt||rl)&&Pe,vm=!k&&yn&&(at||rr||Gs),il=Gs&&!at&&!rr,al=s.jsx(B,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),Sm=at||rr||il?s.jsx("span",{style:{left:Br+r*vo},className:De("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",vm?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:at?s.jsx(B,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(st?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):rr?ol:il?al:null}):null,jm=yn&&!k&&(at||rr||Gs),km=yn?s.jsx("span",{role:"button",tabIndex:0,onClick:Ce=>{Ce.stopPropagation(),Ce.currentTarget.blur(),P(Tn)},onKeyDown:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),Ce.stopPropagation(),P(Tn))},style:{minWidth:14,minHeight:14,left:Br+r*vo},className:De("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",jm?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto":""),"aria-label":e($s?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:$s?s.jsx(B,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(B,{name:"arrow-right-s",className:"h-3 w-3"})}):null,fi=rt?s.jsx(B,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Cm=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),z()},Nm=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},Am=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},mi=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},hi=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},Pm=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),F(null),D(O,{archivedBucket:d})},Dm=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),F(null),D(O,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},Im=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},Tm=Ce=>{Ce.preventDefault(),Ce.stopPropagation()},Em=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),L?.vscode?.executeCommand("openchamber.openSessionInEditor",O.id,gs)},ll=Ce=>{if(me.current){me.current=!1;return}if(Ae){if(Ce?.preventDefault(),Ce?.stopPropagation(),Ce?.shiftKey){const Tt=Ze?.getEntries(),Ut=Tt??Array.from(document.querySelectorAll("[data-session-row]")).map(Ht=>Ht.getAttribute("data-session-row")).filter(Ht=>!!Ht).map(Ht=>({id:Ht,rowKey:Ht,scopeKey:qe,archived:d})),Jt=Tt?es.getState().anchorRowKey:es.getState().anchorId,ls=new Map;ls.set(O.id,kt(n)),Fe(Jt,Je,Ut,Ze?.getDescendantIds()??[],qe,ls);return}q(O.id,qe,kt(n),Je);return}Ce?.currentTarget&&h2(Ce.currentTarget),C(O.id,Xe)},Rm=Ce=>{Ce.defaultPrevented||(Ce.target instanceof HTMLElement?Ce.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||ll(Ce)},Mm=Ce=>{(Ce.button===2||Ce.button===0&&Ce.ctrlKey&&!Ae)&&(me.current=!0)},Om=Ce=>{W&&Ce.pointerType==="touch"&&V(!0),Ce.button===0&&!Ye&&!Ae&&!ae&&Xe&&!qi(O.id,Xe).renderable&&X({directory:Xe,sessionID:O.id}).catch(()=>{})},cl=Ce=>{W&&Ce.pointerType==="touch"&&V(!1)},Bm=Ce=>{Xt.current=Ce,Bt.current+=1;const Tt=Bt.current;if(!Ce){Rt(!1),$t(!1);return}const Ut=A({projectId:o??null,sourceDirectory:Xe,currentWorktree:Ct});Lt(Ut.cachedTargets),Rt(!0),$t(!1),Ut.refreshTargets.then(Jt=>{!Xt.current||Bt.current!==Tt||(Lt(Jt),Rt(!1),$t(!1))}).catch(()=>{!Xt.current||Bt.current!==Tt||(Rt(!1),$t(!0))})},dl=({Item:Ce,Separator:Tt,Sub:Ut,SubTrigger:Jt,SubContent:ls})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ce,{onClick:()=>{G.current={id:O.id,title:gs}},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(sa,{sessionID:O.id,directory:Xe,open:Ie,Item:Ce}),s.jsxs(Ce,{onClick:()=>R(O.id),className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Ce,{onClick:()=>Xe&&te({directory:Xe,sessionId:O.id}),className:"[&>svg]:mr-1",children:[Gs?s.jsx(B,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(B,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(Gs?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),je?s.jsxs(Ce,{onClick:()=>{Ns()},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:ss?"check":"eye",className:"mr-1 h-4 w-4"}),e(ss?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]}):null,s.jsxs(Ce,{onClick:()=>{nn()},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),Qt.map(Ht=>s.jsxs(Ce,{onClick:()=>qs(Ht),className:"[&>svg]:mr-1",children:[s.jsx(Qr,{icon:Ht.icon,iconSrc:Ht.iconSrc,className:"mr-1 size-4"}),Ht.action.label]},`${Ht.guest.id}:${Ht.action.id}`)),Ue&&o&&E?s.jsxs(Ce,{onClick:()=>E(o),className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,ck({isSubtaskSession:Zn,archivedBucket:!!d,isVSCode:fe,sessionDirectory:Xe})?(()=>{const Ht=dk({sessionDirectory:Xe,isStreaming:xt,isMovingToWorktree:ze}),Es=f2({targets:Ot,isRefreshing:Kt,loadFailed:Vt});return s.jsxs(Ut,{onOpenChange:Bm,children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(Jt,{disabled:Ht,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":O.id,children:[s.jsx(B,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(jt,{side:"right",className:"max-w-72",children:e(ze?"sessions.sidebar.session.moveToWorktree.tooltipMoving":xt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(ls,{className:"min-w-[220px]","data-session-worktree-submenu":O.id,children:[Ot.map(Yt=>{const Rs=gt(Yt.metadata.path??null)??Yt.metadata.path,kr=Yt.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):Yt.metadata.label||Yt.metadata.branch||Yt.metadata.name||Yt.metadata.path,os=Yt.isCurrent||Yt.metadata.worktreeStatus!=="ready";return s.jsxs(Ce,{disabled:os,title:Yt.metadata.path,"data-session-worktree-target":Rs,onClick:()=>{os||!Xe||ra({kind:"existing",root:he,descendants:Qe(n),sourceDirectory:Xe,destination:Yt.metadata,messages:na(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:kr}),Yt.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),Yt.isCurrent?s.jsx(B,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Rs)}),Es.refreshState==="loading"?s.jsx(Ce,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,Es.refreshState==="error"?s.jsx(Ce,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Tt,{}),s.jsxs(Ce,{disabled:Ht,"data-session-worktree-new-action":"true",onClick:()=>{Ht||!Xe||ra({kind:"quick",root:he,descendants:Qe(n),sourceDirectory:Xe,messages:na(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,tt?s.jsxs(Ce,{onClick:()=>ye.getState().setRunOverviewKey(tt),className:"[&>svg]:mr-1",children:[s.jsx(Yi,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]}):null,Xe&&!d&&!Ue?(()=>{const Ht=[],Es=os=>{const us=gt(os??null);us&&!Ht.includes(us)&&Ht.push(us)};if(o&&!fe){const os=zt.getState().projects.find(or=>or.id===o),us=gt(os?.path??null);Es(us),us&&(ot.getState().availableWorktreesByProject.get(us)??[]).forEach(or=>Es(or.path))}Es(La(Xe)),Es(Xe);const Yt=Ht.flatMap(os=>ee(os).map(us=>({scope:os,folder:us}))),Rs=Yt.find(({scope:os,folder:us})=>ue(os,O.id)===us.id)??null,kr=Ht[0]??Xe;return s.jsxs(s.Fragment,{children:[s.jsx(Tt,{}),s.jsxs(Ut,{children:[s.jsxs(Jt,{className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(ls,{className:"min-w-[180px]",children:[Yt.length===0?s.jsx(Ce,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Yt.map(({scope:os,folder:us})=>{const or=Rs?.folder.id===us.id;return s.jsxs(Ce,{onClick:()=>{if(or){de(os,O.id);return}Rs&&Rs.scope!==os&&de(Rs.scope,O.id),Te(os,us.id,O.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:us.name}),or?s.jsx(B,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},us.id)}),s.jsx(Tt,{}),s.jsxs(Ce,{onClick:()=>{const os=K(kr);os&&(ie.current=!0,Rs&&Rs.scope!==kr&&de(Rs.scope,O.id),Te(kr,os.id,O.id))},children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Rs?s.jsxs(Ce,{onClick:()=>{de(Rs.scope,O.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(B,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,fe?null:s.jsxs(Ce,{disabled:!Xe,onClick:()=>{Xe&&we(Xe,{mode:"chat",dedupeKey:`session:${O.id}`,label:gs,sessionTitleFallback:gs})},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),Ne?s.jsxs(Ce,{disabled:!Xe,onClick:di,className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Tt,{}),d?null:s.jsxs(Ce,{className:"[&>svg]:mr-1",onClick:()=>D(O,{archivedBucket:d}),children:[s.jsx(B,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),d?s.jsxs(Ce,{className:"[&>svg]:mr-1",onClick:()=>U(O),children:[s.jsx(B,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Ce,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>D(O,{archivedBucket:d,hardDelete:!0}),children:[s.jsx(B,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Fm=Ce=>{Ce.preventDefault(),Ce.stopPropagation(),Ns()},pi=k?"h-6 w-6":Ue&&!ct?"h-5 w-5":"h-4 w-4",ro=k?"h-3.5 w-3.5":Ue&&!ct?"h-3 w-3":"h-2.5 w-2.5",Lm=k?"h-4 w-4":Ue&&!ct?"h-3.5 w-3.5":"h-3 w-3",ul=Ee&&!xt&&Qg(he)?.recap||null,fl=e("sessions.sidebar.session.work.doneSuggested"),gi=Ce=>fs?s.jsx("span",{className:De("inline-flex flex-shrink-0 items-center text-muted-foreground/75",Ce),title:fl,"aria-label":fl,children:s.jsx(B,{name:"check",className:"h-3.5 w-3.5"})}):null,ml=!Ue&&fs,_m=Ys>0||bs>0||ml?s.jsxs(s.Fragment,{children:[ml?gi():null,Ys>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(B,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ys})]}):null,bs>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info",title:so,"aria-label":so,children:[s.jsx(B,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:bs})]}):null]}):null,$m=Ue&&ht?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex flex-shrink-0 items-center gap-1 rounded typography-micro hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",style:bt?{color:bt}:void 0,disabled:!ht.url,"aria-label":xe?`#${ht.number} · ${xe}`:`#${ht.number}`,onPointerDown:mi,onMouseDown:hi,onClick:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),ht.url&&Yr(ht.url)},onKeyDown:Ce=>Ce.stopPropagation(),children:[s.jsx(B,{name:"git-pull-request",className:"h-3 w-3",style:bt?{color:bt}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",ht.number]})]})}),s.jsx(jt,{side:"top",sideOffset:6,children:s.jsx("p",{children:xe?`#${ht.number} · ${xe}`:`#${ht.number}`})})]}):null,zm=Ue?s.jsx(ba,{compact:ct,project:pt,projectLabel:it,title:_r(gs,g),titleClassName:Ye||Ge?"text-interactive-selection-foreground":zs?"text-foreground":"text-foreground/80",branchLabel:ft,statusDot:rr?ol:null,pinnedMarker:Gs&&!at?al:null,timeSlot:no?s.jsx(xi,{sessionId:O.id,running:xt,className:"typography-micro"}):sn,directoryIndicator:!d&&Xe?s.jsx(qr,{directory:Xe}):null,prBadge:$m,zombieIndicator:fi,badges:_m,doneHint:gi(),providerId:he.model?.providerID??null,metaPaddingClass:k?Y?"pr-13":"pr-7":void 0,hideMetaOnHoverClass:k&&!fe?"":De(ce,Ie&&"opacity-0")}):null,Wm=s.jsx(Ss,{align:"end",className:"min-w-[180px]",finalFocus:()=>ie.current?(ie.current=!1,!1):!Z.current,children:dl({Item:_t,Separator:hs,Sub:Jg,SubTrigger:Zg,SubContent:eb})}),Km=s.jsx(Ji,{children:s.jsx(Zi,{className:"app-region-no-drag z-50",children:s.jsx(ea,{"data-slot":"dropdown-menu-content",finalFocus:()=>ie.current?(ie.current=!1,!1):!Z.current,style:{color:"var(--surface-elevated-foreground)"},className:De(Wi,"min-w-[180px]"),children:dl({Item:({className:Ce,...Tt})=>s.jsx(tf,{className:De(lu,Ce),...Tt}),Separator:({className:Ce,...Tt})=>s.jsx(ef,{className:De(au,Ce),...Tt}),Sub:vx,SubTrigger:({className:Ce,children:Tt,...Ut})=>s.jsxs(Sx,{className:De(Xg,Ce),...Ut,children:[Tt,s.jsx(B,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ce,children:Tt,...Ut})=>s.jsx(Ji,{children:s.jsx(Zi,{className:"app-region-no-drag z-50",children:s.jsx(ea,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:De(Wi,Ce),...Ut,children:Tt})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(Hk,{sessionId:O.id,dragKey:$??Je,ownerKey:l??qe,sessionDirectory:Xe??null,sessionTitle:gs,archivedBucket:d,children:s.jsxs(nf,{open:nr,onOpenChange:to,onOpenChangeComplete:ne,children:[s.jsxs(sf,{render:s.jsx("div",{"data-session-row":O.id,"data-session-scope":qe??"","data-session-archived":d?"1":"0","aria-current":Ye?"page":void 0,onClick:Rm,style:{paddingLeft:Ue?Br+4:Jc+r*vo},className:De("group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",Ue&&!ct?"py-1.5":"py-1",Ue&&!(Ye||Ge)&&"hover:bg-interactive-hover/60",(Ye||Ge)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Ge&&"ring-1 ring-inset ring-border")}),children:[Ue?null:Sm,Ue?null:km,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-pressed":Ae?Ge:void 0,onPointerDown:Om,onPointerUp:cl,onPointerCancel:cl,onMouseDown:Mm,onClick:Ce=>ll(Ce),onDoubleClick:Ce=>{Ce.stopPropagation(),T(O.id,gs)},className:De("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none transition-[padding]",le&&"bg-interactive-hover/70",Ue?void 0:k?fe?Q:_:Ie?J:Q),children:Ue?zm:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:De("block min-w-0 flex-1 truncate typography-ui-label font-normal",Ye||Ge?"text-interactive-selection-foreground":zs?"text-foreground":"text-foreground/80"),children:_r(gs,g)}),!d&&Xe&&I==="recent"?s.jsx(qr,{directory:Xe,className:k?void 0:Ie?"mr-1":fe?"group-hover:mr-1":"group-hover:mr-1 group-has-[:focus-visible]:mr-1"}):null,gi(De(ui,k?"ml-2":"ml-1")),k?s.jsx("span",{className:De("inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",!fs&&"ml-2"),children:no?s.jsx(xi,{sessionId:O.id,running:xt}):s.jsxs(s.Fragment,{children:[xn,Dt?s.jsx(B,{name:"git-branch",className:De("h-3 w-3",!bt&&"text-muted-foreground/60"),style:bt?{color:bt}:void 0}):null,sn]})}):no||xn||Dt||I==="recent"?s.jsx("div",{className:De("relative flex h-4 flex-shrink-0 items-center justify-end",!fs&&"ml-1",Ie?"hidden":fe?"group-hover:hidden":"group-hover:hidden group-has-[:focus-visible]:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:no?s.jsx(xi,{sessionId:O.id,running:xt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[xn,Dt?s.jsx(B,{name:"git-branch",className:De("h-3 w-3",!bt&&"text-muted-foreground/60"),style:bt?{color:bt}:void 0}):null,I==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:sn}):null]})})}):null,Ys>0?s.jsxs("span",{className:De("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",ui),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(B,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ys})]}):null,bs>0?s.jsxs("span",{className:De("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",ui),title:so,"aria-label":so,children:[s.jsx(B,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:bs})]}):null]})})}),!fe&&!Ue?s.jsx(jt,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:gs}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:tr,children:sn})]}),it&&!Ue?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(B,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:it})]}):null,ft?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:bt?{color:bt}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:ft})]}):null,ht&&xe?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(B,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:bt?{color:bt}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:bt?{color:bt}:void 0,children:["#",ht.number," · ",xe]})]}):null,ul?s.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:ul}):null]})}):null]})}),fi&&!W&&!Ue?s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:fi}):null,s.jsxs("div",{className:De("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",Ue&&!ct?"top-1.5 h-5":"top-1/2 -translate-y-1/2",Ie||k&&!fe?"opacity-100":De("opacity-0",oe)),children:[ge?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",pi,ss?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":Jn,onPointerDown:mi,onMouseDown:hi,onClick:Fm,onKeyDown:Ce=>Ce.stopPropagation(),children:s.jsx(B,{name:ss?"check":"eye",className:ss?Lm:ro})})}),s.jsx(jt,{side:"left",sideOffset:8,children:Jn})]}):null,Y?s.jsx(p2,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:pi,iconSizeClass:ro,onPointerDown:mi,onMouseDown:hi,onArchive:Pm,onDelete:Dm}):null,pe?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",pi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Im,onMouseDown:Tm,onClick:Em,onKeyDown:Ce=>Ce.stopPropagation(),children:s.jsx(B,{name:"external-link",className:ro})})}),s.jsx(jt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(js,{open:sr,onOpenChange:eo,onOpenChangeComplete:ne,children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:De("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",k?"h-6 w-6 opacity-100":Ie?"h-4 w-4 opacity-100":De("h-4 w-4 opacity-0",oe)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Nm,onMouseDown:Am,onClick:Cm,onKeyDown:Ce=>Ce.stopPropagation(),children:s.jsx(B,{name:"more-2",className:ro})})}),Wm]})]})]}),Km]})}),yn&&$s?re:null,s.jsx(ks,{open:It,onOpenChange:Mt,children:s.jsxs(Cs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Hs,{children:[s.jsx(Ls,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(_s,{children:wt===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:wt}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:wt})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ke,onChange:Ce=>Oe(Ce.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(Qn,{children:[s.jsx(mt,{type:"button",onClick:()=>Mt(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(mt,{type:"button",onClick:()=>{Mt(!1),Ft(ke)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},O.id)}const Zc=t=>gt(t.session.directory??null),b2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),x2=t=>{if(!t.openSidebarMenuKey)return null;if(t.rowKey&&(t.openSidebarMenuKey===`session-menu:${t.rowKey}`||t.openSidebarMenuKey===`session-context:${t.rowKey}`))return t.node.session.id;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},ed=t=>t.menuOpenSessionId??x2(t),So=(t,e,n)=>e?n.has(t.node.session.id)?!0:wr(t.node,e):!1,wa=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(wa(t.children[l],e.children[l],n,r,i))return!0;return!1},y2=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return wa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||wa(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},w2=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived&&t.time?.idle===e.time?.idle&&t.metadata===e.metadata&&Uu(t,e),v2=(t,e)=>{if(t.node.session.id!==e.node.session.id||!w2(t.node.session,e.node.session)||!m2(t.node,e.node))return"node";if(t.depth!==e.depth)return"depth";if(t.groupDirectory!==e.groupDirectory)return"groupDirectory";if(t.projectId!==e.projectId)return"projectId";if(t.archivedBucket!==e.archivedBucket)return"archivedBucket";if((t.renderContext??"project")!==(e.renderContext??"project"))return"renderContext";if(t.mobileVariant!==e.mobileVariant)return"mobileVariant";if(t.alwaysShowActions!==e.alwaysShowActions)return"alwaysShowActions";if(t.hasSessionSearchQuery!==e.hasSessionSearchQuery)return"hasSessionSearchQuery";if(t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery)return"normalizedSessionSearchQuery";if(t.notifyOnSubtasks!==e.notifyOnSubtasks)return"notifyOnSubtasks";if(t.nodeStructureKey!==e.nodeStructureKey)return"nodeStructureKey";if(t.relativeTimeTick!==e.relativeTimeTick)return"relativeTimeTick";if(Zc(t.node)!==Zc(e.node))return"nodeDirectory";if(!b2(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&qf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&y2(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(So(t,t.editingId,t.subtreeContainsEditing)||So(e,e.editingId,e.subtreeContainsEditing)))return"editingId";if(t.editingRowKey!==e.editingRowKey&&(t.editingRowKey===t.rowKey||e.editingRowKey===e.rowKey))return"editingRowKey";if(t.editTitle!==e.editTitle&&(So(t,t.editingId,t.subtreeContainsEditing)||So(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=ed(t),i=ed(e);if(wr(t.node,r)||wr(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleCopySessionId===e.handleCopySessionId&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.onEditProject===e.onEditProject&&t.children===e.children?null:"callbacks"},S2=(t,e)=>{const n=v2(t,e);return n===null?!0:(ys(`ui.sidebar_session_node.props_changed.${n}`),!1)},j2=c.memo(g2,S2);function k2(t){return t.stopPropagation()}const C2=t=>{const{t:e}=At(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=ye(v=>v.setSessionSwitcherOpen),a=ot(v=>v.setCurrentSession),d=ot(v=>v.updateSessionTitle),u=ot(v=>v.deleteSession),m=ot(v=>v.deleteSessions),f=ot(v=>v.archiveSession),g=ot(v=>v.archiveSessions),y=ot(v=>v.unarchiveSession),{mobileVariant:b,allowReselect:j,onSessionSelected:x,resetSessionSearch:h,descendantIds:p,showDeletionDialog:w,setDeleteSessionConfirm:S,setEditingId:N,setEditingRowKey:P,editingSessionId:C,editingOccurrenceKey:T,setEditTitle:R}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const M=c.useCallback((v,I)=>{if(Li("navigation.session_select"),ye.getState().closeMainSurfaces(),b&&l(!1),v===ot.getState().currentSessionId){j&&x?.(v),h();return}Li("navigation.session_state_set"),a(v,I??null),x?.(v),h()},[j,b,x,h,a,l]),F=c.useCallback((v,I)=>{N(v),P(T),R(I)},[T,R,N,P]),K=c.useCallback(async v=>{if(!r.current)return;const H=(v??i.current).trim();if(H)try{await d(C,H)}catch($){console.error("[session-actions] rename failed",$),_e.error(e("sessions.sidebar.session.rename.error",{detail:eu($ instanceof Error?$:new Error(String($)),e)}))}N(null),P(null),R("")},[C,R,N,P,e,d]),D=c.useCallback(()=>{N(null),P(null),R("")},[R,N,P]),U=c.useCallback(v=>{Gn(v).then(I=>{if(I.ok){_e.success(e("sessions.sidebar.session.copyId.success"));return}_e.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(e("sessions.sidebar.session.copyId.error")))},[e]),A=c.useCallback(async(v,I,H)=>{const $=I?.archivedBucket===!0||I?.hardDelete===!0,re=H?.descendantIds??p;await Gh($?"delete":"archive",v,re,{archiveSession:f,archiveSessions:g,deleteSession:u,deleteSessions:m},e)},[f,g,u,m,p,e]),E=c.useCallback((v,I)=>{const H=I?.archivedBucket===!0||I?.hardDelete===!0,$=Hd(v.id,p,H);if(!w||I?.skipConfirm===!0){A(v,I,{descendantIds:$});return}S({session:v,descendantCount:$.length,descendantIds:$,archivedBucket:H})},[p,A,S,w]),W=c.useCallback(async()=>{const v=o.current;if(!v)return;const{session:I,archivedBucket:H,descendantIds:$}=v;S(null),await A(I,{archivedBucket:H},{descendantIds:$})},[A,S]),k=c.useCallback(async v=>{await y(v.id)?_e.success(e("sessions.sidebar.session.restore.success")):_e.error(e("sessions.sidebar.session.restore.error"))},[e,y]);return c.useMemo(()=>({handleSessionSelect:M,handleSessionDoubleClick:F,handleSaveEdit:K,handleCancelEdit:D,handleCopySessionId:U,handleDeleteSession:E,handleRestoreSession:k,confirmDeleteSession:W}),[D,U,E,k,K,F,M,W])};function N2(t){const e=nt.c(71),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,m,f,g,y,b,j,x,h;if(e[0]!==i||e[1]!==n||e[2]!==r){const v=n("sessions.sidebar.session.untitled");f=ks,x=!!r,e[13]!==i?(h=H=>{H||i(null)},e[13]=i,e[14]=h):h=e[14],m=Cs,b=!1,j="max-w-sm gap-5",u=Hs;let I;e[15]!==n||e[16]!==r?.archivedBucket?(I=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=I):I=e[17],e[18]!==I?(y=s.jsx(Ls,{children:I}),e[18]=I,e[19]=y):y=e[19],d=_s,g=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||v,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||v,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||v,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||v,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||v}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||v}),e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=m,e[6]=f,e[7]=g,e[8]=y,e[9]=b,e[10]=j,e[11]=x,e[12]=h}else d=e[3],u=e[4],m=e[5],f=e[6],g=e[7],y=e[8],b=e[9],j=e[10],x=e[11],h=e[12];let p;e[20]!==d||e[21]!==g?(p=s.jsx(d,{children:g}),e[20]=d,e[21]=g,e[22]=p):p=e[22];let w;e[23]!==u||e[24]!==y||e[25]!==p?(w=s.jsxs(u,{children:[y,p]}),e[23]=u,e[24]=y,e[25]=p,e[26]=w):w=e[26];let S;e[27]!==l||e[28]!==o?(S=()=>l(!o),e[27]=l,e[28]=o,e[29]=S):S=e[29];const N=!o;let P;e[30]!==o?(P=o?s.jsx(B,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(B,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=P):P=e[31];let C;e[32]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=C):C=e[33];let T;e[34]!==P||e[35]!==C||e[36]!==S||e[37]!==N?(T=s.jsxs("button",{type:"button",onClick:S,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":N,children:[P,C]}),e[34]=P,e[35]=C,e[36]=S,e[37]=N,e[38]=T):T=e[38];let R;e[39]!==i?(R=()=>i(null),e[39]=i,e[40]=R):R=e[40];let M;e[41]!==n?(M=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=M):M=e[42];let F;e[43]!==R||e[44]!==M?(F=s.jsx("button",{type:"button",onClick:R,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:M}),e[43]=R,e[44]=M,e[45]=F):F=e[45];let K;e[46]!==a?(K=()=>{a()},e[46]=a,e[47]=K):K=e[47];let D;e[48]!==n||e[49]!==r?.archivedBucket?(D=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=D):D=e[50];let U;e[51]!==K||e[52]!==D?(U=s.jsx("button",{type:"button",onClick:K,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:D}),e[51]=K,e[52]=D,e[53]=U):U=e[53];let A;e[54]!==F||e[55]!==U?(A=s.jsxs("div",{className:"flex items-center gap-2",children:[F,U]}),e[54]=F,e[55]=U,e[56]=A):A=e[56];let E;e[57]!==T||e[58]!==A?(E=s.jsxs(Qn,{className:"w-full sm:items-center sm:justify-between",children:[T,A]}),e[57]=T,e[58]=A,e[59]=E):E=e[59];let W;e[60]!==m||e[61]!==b||e[62]!==E||e[63]!==j||e[64]!==w?(W=s.jsxs(m,{showCloseButton:b,className:j,children:[w,E]}),e[60]=m,e[61]=b,e[62]=E,e[63]=j,e[64]=w,e[65]=W):W=e[65];let k;return e[66]!==f||e[67]!==W||e[68]!==x||e[69]!==h?(k=s.jsx(f,{open:x,onOpenChange:h,children:W}),e[66]=f,e[67]=W,e[68]=x,e[69]=h,e[70]=k):k=e[70],k}function A2(t){const e=nt.c(57),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let m;e[0]!==d||e[1]!==u||e[2]!==n?(m=n(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=n,e[3]=m):m=e[3];const f=m;let g;e[4]!==d||e[5]!==u||e[6]!==n?(g=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=g):g=e[7];const y=g,b=!!r;let j;e[8]!==i?(j=k=>{k||i(null)},e[8]=i,e[9]=j):j=e[9];let x;e[10]!==f?(x=s.jsx(Ls,{children:f}),e[10]=f,e[11]=x):x=e[11];let h;e[12]!==y?(h=s.jsx(_s,{children:y}),e[12]=y,e[13]=h):h=e[13];let p;e[14]!==x||e[15]!==h?(p=s.jsxs(Hs,{children:[x,h]}),e[14]=x,e[15]=h,e[16]=p):p=e[16];let w;e[17]!==l||e[18]!==o?(w=()=>l(!o),e[17]=l,e[18]=o,e[19]=w):w=e[19];const S=!o;let N;e[20]!==o?(N=o?s.jsx(B,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(B,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=N):N=e[21];let P;e[22]!==n?(P=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=P):P=e[23];let C;e[24]!==P||e[25]!==w||e[26]!==S||e[27]!==N?(C=s.jsxs("button",{type:"button",onClick:w,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":S,children:[N,P]}),e[24]=P,e[25]=w,e[26]=S,e[27]=N,e[28]=C):C=e[28];let T;e[29]!==i?(T=()=>i(null),e[29]=i,e[30]=T):T=e[30];let R;e[31]!==n?(R=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=R):R=e[32];let M;e[33]!==T||e[34]!==R?(M=s.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:R}),e[33]=T,e[34]=R,e[35]=M):M=e[35];let F;e[36]!==a?(F=()=>{a()},e[36]=a,e[37]=F):F=e[37];let K;e[38]!==d||e[39]!==n?(K=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=K):K=e[40];let D;e[41]!==F||e[42]!==K?(D=s.jsx("button",{type:"button",onClick:F,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:K}),e[41]=F,e[42]=K,e[43]=D):D=e[43];let U;e[44]!==M||e[45]!==D?(U=s.jsxs("div",{className:"flex items-center gap-2",children:[M,D]}),e[44]=M,e[45]=D,e[46]=U):U=e[46];let A;e[47]!==C||e[48]!==U?(A=s.jsxs(Qn,{className:"w-full sm:items-center sm:justify-between",children:[C,U]}),e[47]=C,e[48]=U,e[49]=A):A=e[49];let E;e[50]!==A||e[51]!==p?(E=s.jsxs(Cs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,A]}),e[50]=A,e[51]=p,e[52]=E):E=e[52];let W;return e[53]!==b||e[54]!==E||e[55]!==j?(W=s.jsx(ks,{open:b,onOpenChange:j,children:E}),e[53]=b,e[54]=E,e[55]=j,e[56]=W):W=e[56],W}function rm(t){const e=nt.c(36),{t:n}=At(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=N=>{N||i(null)},e[0]=i,e[1]=a):a=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(Ls,{children:d}),e[4]=d,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==r?(m=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=m):m=e[8];let f;e[9]!==m?(f=s.jsx(_s,{children:m}),e[9]=m,e[10]=f):f=e[10];let g;e[11]!==u||e[12]!==f?(g=s.jsxs(Hs,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=g):g=e[13];let y;e[14]!==i?(y=()=>i(null),e[14]=i,e[15]=y):y=e[15];let b;e[16]!==n?(b=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=b):b=e[17];let j;e[18]!==y||e[19]!==b?(j=s.jsx("button",{type:"button",onClick:y,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:b}),e[18]=y,e[19]=b,e[20]=j):j=e[20];let x;e[21]!==n?(x=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=x):x=e[22];let h;e[23]!==o||e[24]!==x?(h=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:x}),e[23]=o,e[24]=x,e[25]=h):h=e[25];let p;e[26]!==h||e[27]!==j?(p=s.jsxs(Qn,{children:[j,h]}),e[26]=h,e[27]=j,e[28]=p):p=e[28];let w;e[29]!==p||e[30]!==g?(w=s.jsxs(Cs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,p]}),e[29]=p,e[30]=g,e[31]=w):w=e[31];let S;return e[32]!==l||e[33]!==a||e[34]!==w?(S=s.jsx(ks,{open:l,onOpenChange:a,children:w}),e[32]=l,e[33]=a,e[34]=w,e[35]=S):S=e[35],S}const P2=new Set;function D2(t){const e=nt.c(113),{node:n,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:m,rowKey:f,dragKey:g,renderExtras:y,pinnedSessionIds:b,expandedParents:j,hasSessionSearchQuery:x,normalizedSessionSearchQuery:h,notifyOnSubtasks:p,editingId:w,editingRowKey:S,setEditingId:N,setEditingRowKey:P,editTitle:C,setEditTitle:T,toggleParent:R,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,allowReselect:K,onSessionSelected:D,resetSessionSearch:U,deleteSessionConfirm:A,setDeleteSessionConfirm:E,startFolderRename:W,startSessionWorktreeMenuLoad:k,onEditProject:v,mobileVariant:I,alwaysShowActions:H,renderChildren:$}=t,re=r===void 0?0:r,te=d===void 0?!1:d,ee=m===void 0?"project":m,ue=$===void 0?!0:$;ys("ui.sidebar_tree_item.render");const de=f??`${ee}:${te?"archived":"active"}:${n.session.id}`,Te=Gt(R2),we=Gt(E2),fe=ye(T2),Ne=ye(I2);let L;if(e[0]!==n){L=[];const Me=He=>He.children.forEach(We=>{L.push(We.session.id),Me(We)});Me(n),e[0]=n,e[1]=L}else L=e[1];const oe=L.join(`
881
881
  `);let ce;e[2]!==oe?(ce=oe?oe.split(`
882
882
  `):[],e[2]=oe,e[3]=ce):ce=e[3];const pe=ce;let Y;e[4]!==Te||e[5]!==W||e[6]!==we?(Y=(Me,He)=>{if(!Me)return null;He&&Gt.getState().collapsedFolderIds.has(He)&&we(He);const We=Te(Me,"New folder",He);return W(Me,We),We},e[4]=Te,e[5]=W,e[6]=we,e[7]=Y):Y=e[7];const ve=Y;let Ee;e[8]!==K||e[9]!==A||e[10]!==pe||e[11]!==C||e[12]!==w||e[13]!==de||e[14]!==I||e[15]!==n.session.id||e[16]!==D||e[17]!==U||e[18]!==E||e[19]!==T||e[20]!==N||e[21]!==P||e[22]!==fe?(Ee={mobileVariant:I,allowReselect:K,onSessionSelected:D,resetSessionSearch:U,descendantIds:pe,showDeletionDialog:fe,setDeleteSessionConfirm:E,deleteSessionConfirm:A,editingId:w,setEditingId:N,setEditingRowKey:P,editingSessionId:n.session.id,editingOccurrenceKey:de,editTitle:C,setEditTitle:T},e[8]=K,e[9]=A,e[10]=pe,e[11]=C,e[12]=w,e[13]=de,e[14]=I,e[15]=n.session.id,e[16]=D,e[17]=U,e[18]=E,e[19]=T,e[20]=N,e[21]=P,e[22]=fe,e[23]=Ee):Ee=e[23];const je=C2(Ee),ge=y?.childRenderExtrasFor,be=n.session.directory??i;let Q;e[24]!==te||e[25]!==o||e[26]!==ee||e[27]!==be?(Q={groupDirectory:be,projectId:o,archivedBucket:te,renderContext:ee},e[24]=te,e[25]=o,e[26]=ee,e[27]=be,e[28]=Q):Q=e[28];const _=Q,J=g??f??n.session.id,me=y?.subtreeContainsEditing??P2,le=y?.menuOpenSessionId??null,V=y?.nodeStructureKey??"",Z=y?.relativeTimeTick;let G;e[29]!==K||e[30]!==H||e[31]!==_||e[32]!==ge||e[33]!==A||e[34]!==re||e[35]!==C||e[36]!==w||e[37]!==S||e[38]!==j||e[39]!==l||e[40]!==x||e[41]!==I||e[42]!==n.children||e[43]!==h||e[44]!==p||e[45]!==D||e[46]!==M||e[47]!==b||e[48]!==ue||e[49]!==U||e[50]!==a||e[51]!==E||e[52]!==T||e[53]!==N||e[54]!==P||e[55]!==F||e[56]!==W||e[57]!==k||e[58]!==R?(G=ue?n.children.map(Me=>s.jsx(Ho,{node:Me,pinnedSessionIds:b,expandedParents:j,hasSessionSearchQuery:x,normalizedSessionSearchQuery:h,notifyOnSubtasks:p,editingId:w,editingRowKey:S,setEditingId:N,setEditingRowKey:P,editTitle:C,setEditTitle:T,toggleParent:R,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,allowReselect:K,onSessionSelected:D,resetSessionSearch:U,deleteSessionConfirm:A,setDeleteSessionConfirm:E,startFolderRename:W,startSessionWorktreeMenuLoad:k,mobileVariant:I,alwaysShowActions:H,depth:re+1,folderOwnerKey:l,selectionScopeKey:a,..._,renderExtras:ge?.(Me)},Me.session.id)):null,e[29]=K,e[30]=H,e[31]=_,e[32]=ge,e[33]=A,e[34]=re,e[35]=C,e[36]=w,e[37]=S,e[38]=j,e[39]=l,e[40]=x,e[41]=I,e[42]=n.children,e[43]=h,e[44]=p,e[45]=D,e[46]=M,e[47]=b,e[48]=ue,e[49]=U,e[50]=a,e[51]=E,e[52]=T,e[53]=N,e[54]=P,e[55]=F,e[56]=W,e[57]=k,e[58]=R,e[59]=G):G=e[59];let ie;e[60]!==H||e[61]!==te||e[62]!==ve||e[63]!==re||e[64]!==C||e[65]!==w||e[66]!==S||e[67]!==de||e[68]!==j||e[69]!==l||e[70]!==i||e[71]!==x||e[72]!==I||e[73]!==n||e[74]!==h||e[75]!==p||e[76]!==v||e[77]!==M||e[78]!==b||e[79]!==o||e[80]!==ee||e[81]!==u||e[82]!==a||e[83]!==je.handleCancelEdit||e[84]!==je.handleCopySessionId||e[85]!==je.handleDeleteSession||e[86]!==je.handleRestoreSession||e[87]!==je.handleSaveEdit||e[88]!==je.handleSessionDoubleClick||e[89]!==je.handleSessionSelect||e[90]!==T||e[91]!==N||e[92]!==P||e[93]!==F||e[94]!==k||e[95]!==J||e[96]!==me||e[97]!==le||e[98]!==V||e[99]!==Z||e[100]!==G||e[101]!==R?(ie=s.jsx(j2,{expandedParents:j,hasSessionSearchQuery:x,normalizedSessionSearchQuery:h,notifyOnSubtasks:p,editingId:w,editingRowKey:S,setEditingId:N,setEditingRowKey:P,editTitle:C,setEditTitle:T,handleSaveEdit:je.handleSaveEdit,handleCancelEdit:je.handleCancelEdit,toggleParent:R,handleSessionSelect:je.handleSessionSelect,handleSessionDoubleClick:je.handleSessionDoubleClick,handleCopySessionId:je.handleCopySessionId,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,createFolderAndStartRename:ve,handleDeleteSession:je.handleDeleteSession,handleRestoreSession:je.handleRestoreSession,startSessionWorktreeMenuLoad:k,onEditProject:v,mobileVariant:I,alwaysShowActions:H,pinnedSessionIds:b,node:n,depth:re,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:te,secondaryMeta:u,renderContext:ee,rowKey:de,dragKey:J,subtreeContainsEditing:me,menuOpenSessionId:le,nodeStructureKey:V,relativeTimeTick:Z,children:G}),e[60]=H,e[61]=te,e[62]=ve,e[63]=re,e[64]=C,e[65]=w,e[66]=S,e[67]=de,e[68]=j,e[69]=l,e[70]=i,e[71]=x,e[72]=I,e[73]=n,e[74]=h,e[75]=p,e[76]=v,e[77]=M,e[78]=b,e[79]=o,e[80]=ee,e[81]=u,e[82]=a,e[83]=je.handleCancelEdit,e[84]=je.handleCopySessionId,e[85]=je.handleDeleteSession,e[86]=je.handleRestoreSession,e[87]=je.handleSaveEdit,e[88]=je.handleSessionDoubleClick,e[89]=je.handleSessionSelect,e[90]=T,e[91]=N,e[92]=P,e[93]=F,e[94]=k,e[95]=J,e[96]=me,e[97]=le,e[98]=V,e[99]=Z,e[100]=G,e[101]=R,e[102]=ie):ie=e[102];let Se;e[103]!==A||e[104]!==n.session.id||e[105]!==je.confirmDeleteSession||e[106]!==E||e[107]!==Ne||e[108]!==fe?(Se=A?.session.id===n.session.id?s.jsx(N2,{value:A,setValue:E,showDeletionDialog:fe,setShowDeletionDialog:Ne,onConfirm:je.confirmDeleteSession}):null,e[103]=A,e[104]=n.session.id,e[105]=je.confirmDeleteSession,e[106]=E,e[107]=Ne,e[108]=fe,e[109]=Se):Se=e[109];let se;return e[110]!==ie||e[111]!==Se?(se=s.jsxs(s.Fragment,{children:[ie,Se]}),e[110]=ie,e[111]=Se,e[112]=se):se=e[112],se}function I2(t){return t.setShowDeletionDialog}function T2(t){return t.showDeletionDialog}function E2(t){return t.toggleFolderCollapse}function R2(t){return t.createFolder}const M2=(t,e)=>t.session.id===e.session.id&&t.session.title===e.session.title&&t.session.directory===e.session.directory&&t.session.parentID===e.session.parentID&&t.session.time?.created===e.session.time?.created&&t.session.time?.updated===e.session.time?.updated&&t.session.time?.archived===e.session.time?.archived&&Uu(t.session,e.session)&&gt(t.worktree?.path??null)===gt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,O2=(t,e)=>{if(t.node!==e.node&&!M2(t.node,e.node)||(t.renderExtras?.nodeStructureKey??"")!==(e.renderExtras?.nodeStructureKey??"")||(t.renderExtras?.menuOpenSessionId??null)!==(e.renderExtras?.menuOpenSessionId??null)||t.renderExtras?.relativeTimeTick!==e.renderExtras?.relativeTimeTick)return!1;const n=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(n)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(n)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null))return!1;const r=["depth","groupDirectory","projectId","folderOwnerKey","selectionScopeKey","archivedBucket","renderContext","rowKey","dragKey","renderChildren","hasSessionSearchQuery","normalizedSessionSearchQuery","notifyOnSubtasks","editingId","editingRowKey","editTitle","openSidebarMenuKey","mobileVariant","alwaysShowActions","allowReselect","pinnedSessionIds","expandedParents","deleteSessionConfirm","setEditingId","setEditingRowKey","setEditTitle","toggleParent","setOpenSidebarMenuKey","startSessionWorktreeMenuLoad","onEditProject","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const i of r)if(t[i]!==e[i])return!1;return!0},Ho=c.memo(D2,O2),va=6,B2=va+14+6,F2=4;function td(t){const e=nt.c(7),{providerIDs:n,ringClass:r}=t;let i;if(e[0]!==n||e[1]!==r){let l;e[3]!==r?(l=a=>s.jsx("span",{className:De("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:s.jsx(Fu,{providerId:a,className:"h-3 w-3"})},a),e[3]=r,e[4]=l):l=e[4],i=n.slice(0,F2).map(l),e[0]=n,e[1]=r,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=s.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[5]=i,e[6]=o):o=e[6],o}function L2(t){const e=nt.c(91),{run:n,laneNodes:r,renderContext:i,projectId:o,projectLabel:l,expansionKey:a,expanded:d,forceExpanded:u,notifyOnSubtasks:m,toggleParent:f}=t,{t:g}=At();let y;e[0]!==n.key?(y=oe=>oe.runOverviewKey===n.key,e[0]=n.key,e[1]=y):y=e[1];const b=ye(y),j=i==="timeline";let x;e[2]!==j||e[3]!==o?(x=oe=>j&&o?oe.projects.find(ce=>ce.id===o)??null:null,e[2]=j,e[3]=o,e[4]=x):x=e[4];const h=zt(x),p=n.lanes.length;let w;e[5]!==p||e[6]!==g?(w=p===1?g("sessions.sidebar.run.laneCountSingle",{count:p}):g("sessions.sidebar.run.laneCountPlural",{count:p}),e[5]=p,e[6]=g,e[7]=w):w=e[7];const S=w;let N;e[8]!==r?(N=[...r],e[8]=r,e[9]=N):N=e[9];const P=N;let C;e[10]!==P||e[11]!==m?(C=s.jsx(tu,{nodes:P,includeUnreadSubtasks:m}),e[10]=P,e[11]=m,e[12]=C):C=e[12];const T=C,R=b?"text-interactive-selection-foreground":"text-foreground/80";let M;e[13]!==n.key?(M=()=>ye.getState().setRunOverviewKey(n.key),e[13]=n.key,e[14]=M):M=e[14];const F=M;if(j){const oe=n.key,ce=b?"page":void 0;let pe;e[15]!==n.title||e[16]!==g?(pe=g("sessions.sidebar.run.openOverviewAria",{title:n.title}),e[15]=n.title,e[16]=g,e[17]=pe):pe=e[17];let Y;e[18]===Symbol.for("react.memo_cache_sentinel")?(Y={paddingLeft:va+4},e[18]=Y):Y=e[18];const ve=b?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let Ee;e[19]!==ve?(Ee=De("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md py-1.5 pr-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",ve),e[19]=ve,e[20]=Ee):Ee=e[20];const je=n.title;let ge;e[21]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(Yi,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[21]=ge):ge=e[21];let be;e[22]!==S?(be=s.jsxs(s.Fragment,{children:[ge,s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:S})]}),e[22]=S,e[23]=be):be=e[23];let Q;e[24]!==n.lastActivity?(Q=Vu(n.lastActivity),e[24]=n.lastActivity,e[25]=Q):Q=e[25];let _;e[26]!==n.providerIDs?(_=s.jsx(td,{providerIDs:n.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[26]=n.providerIDs,e[27]=_):_=e[27];let J;e[28]!==T||e[29]!==l||e[30]!==n.title||e[31]!==be||e[32]!==Q||e[33]!==_||e[34]!==h||e[35]!==R?(J=s.jsx(ba,{project:h,projectLabel:l,title:je,titleClassName:R,branchLabel:null,thirdLineLead:be,statusDot:T,pinnedMarker:null,timeSlot:Q,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:_,hideMetaOnHoverClass:""}),e[28]=T,e[29]=l,e[30]=n.title,e[31]=be,e[32]=Q,e[33]=_,e[34]=h,e[35]=R,e[36]=J):J=e[36];let me;return e[37]!==F||e[38]!==n.key||e[39]!==Ee||e[40]!==J||e[41]!==ce||e[42]!==pe?(me=s.jsx("button",{type:"button","data-run-row":oe,"aria-current":ce,"aria-label":pe,onClick:F,style:Y,className:Ee,children:J}),e[37]=F,e[38]=n.key,e[39]=Ee,e[40]=J,e[41]=ce,e[42]=pe,e[43]=me):me=e[43],me}let K;e[44]!==a||e[45]!==u||e[46]!==f?(K=oe=>{oe.stopPropagation(),u||f(a)},e[44]=a,e[45]=u,e[46]=f,e[47]=K):K=e[47];const D=K,U=n.key,A=b?"page":void 0;let E;e[48]===Symbol.for("react.memo_cache_sentinel")?(E={paddingLeft:B2},e[48]=E):E=e[48];const W=b?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let k;e[49]!==W?(k=De("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-2.5",W),e[49]=W,e[50]=k):k=e[50];let v;e[51]!==D?(v=oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),D(oe))},e[51]=D,e[52]=v):v=e[52];let I;e[53]===Symbol.for("react.memo_cache_sentinel")?(I={left:va},e[53]=I):I=e[53];let H;e[54]!==d||e[55]!==g?(H=g(d?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[54]=d,e[55]=g,e[56]=H):H=e[56];const $=d?"arrow-down-s":"arrow-right-s";let re;e[57]!==$?(re=s.jsx(B,{name:$,className:"h-3 w-3"}),e[57]=$,e[58]=re):re=e[58];let te;e[59]!==d||e[60]!==v||e[61]!==H||e[62]!==re||e[63]!==D?(te=s.jsx("button",{type:"button",onClick:D,onKeyDown:v,style:I,className:"absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":d,"aria-label":H,children:re}),e[59]=d,e[60]=v,e[61]=H,e[62]=re,e[63]=D,e[64]=te):te=e[64];let ee;e[65]!==F?(ee=oe=>{oe.stopPropagation(),F()},e[65]=F,e[66]=ee):ee=e[66];let ue;e[67]!==n.title||e[68]!==g?(ue=g("sessions.sidebar.run.openOverviewAria",{title:n.title}),e[67]=n.title,e[68]=g,e[69]=ue):ue=e[69];let de;e[70]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(Yi,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[70]=de):de=e[70];let Te;e[71]!==R?(Te=De("block min-w-0 flex-1 truncate typography-ui-label font-normal",R),e[71]=R,e[72]=Te):Te=e[72];let we;e[73]!==n.title||e[74]!==Te?(we=s.jsx("span",{className:Te,children:n.title}),e[73]=n.title,e[74]=Te,e[75]=we):we=e[75];let fe;e[76]!==n.providerIDs?(fe=s.jsx(td,{providerIDs:n.providerIDs,ringClass:"ring-sidebar"}),e[76]=n.providerIDs,e[77]=fe):fe=e[77];let Ne;e[78]!==T||e[79]!==ee||e[80]!==ue||e[81]!==we||e[82]!==fe?(Ne=s.jsxs("button",{type:"button",onClick:ee,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":ue,children:[de,we,fe,T]}),e[78]=T,e[79]=ee,e[80]=ue,e[81]=we,e[82]=fe,e[83]=Ne):Ne=e[83];let L;return e[84]!==F||e[85]!==n.key||e[86]!==k||e[87]!==te||e[88]!==Ne||e[89]!==A?(L=s.jsxs("div",{"data-run-row":U,"aria-current":A,onClick:F,style:E,className:k,children:[te,Ne]}),e[84]=F,e[85]=n.key,e[86]=k,e[87]=te,e[88]=Ne,e[89]=A,e[90]=L):L=e[90],L}const _2=c.memo(L2),$2=24,z2=t=>Array.from({length:Math.min(t,$2)},(e,n)=>n),W2=(t,e,n)=>{const r=new Set(t);for(const i of e)i>=0&&i<n&&r.add(i);return[...r].sort((i,o)=>i-o)},K2=(t,e)=>t.find(n=>n.end>e)?.index??0;function sd(t,e){return e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function V2({model:t,scrollElement:e,pinnedRowIndexes:n,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,l=c.useCallback(()=>e,[e]),a=c.useCallback(x=>o[x]?.estimateSize??32,[o]),d=c.useCallback(x=>o[x]?.key??x,[o]),u=c.useCallback(x=>W2(Mx(x),n,o.length),[n,o.length]),m=Rx({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:d,overscan:8,rangeExtractor:u}),f=m.getVirtualItems(),g=e?m.getTotalSize():0,y=e?Math.max(g-e.clientHeight,0):0,b=e?Math.min(e.scrollTop,y):0,j=K2(f,b);if(c.useLayoutEffect(()=>{i(j)},[j,i]),!e){const x=z2(o.length),h=x.reduce((w,S)=>w+(o[S]?.estimateSize??0),0),p=o.reduce((w,S)=>w+S.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[x.map(w=>{const S=o[w];return S?s.jsx("div",{className:sd(S,o[w+1]),children:r(S,w)},S.key):null}),p>h?s.jsx("div",{"aria-hidden":"true",style:{height:p-h}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:g,position:"relative"},children:f.map(x=>{const h=o[x.index];return h?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${sd(h,o[x.index+1])??""}`,"data-index":x.index,"data-sidebar-virtual-start":x.start,ref:m.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${x.start}px)`},children:r(h,x.index)},h.key):null})})}const U2={work:"eye",chats:"chat-4","active-now":"history",timeline:"folder"},nd={work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle","active-now":"sessions.sidebar.activity.recentTitle",timeline:"sessions.sidebar.activity.timelineTitle"},H2=t=>{const e=nt.c(48),{activityKey:n,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a,timelineView:d}=t,u=d===void 0?!1:d,{t:m}=At(),f=n==="chats";if(u){const K=i?void 0:l;let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=De("group flex w-full items-center gap-1 py-2 pl-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","pr-3.5"),e[0]=D):D=e[0];const U=!r,A=nd[n];let E;e[1]!==m||e[2]!==A?(E=m(A),e[1]=m,e[2]=A,e[3]=E):E=e[3];let W;e[4]!==E?(W=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:E}),e[4]=E,e[5]=W):W=e[5];let k;e[6]!==r||e[7]!==i?(k=i?null:s.jsx(B,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5 text-muted-foreground"}),e[6]=r,e[7]=i,e[8]=k):k=e[8];let v;return e[9]!==i||e[10]!==K||e[11]!==U||e[12]!==W||e[13]!==k?(v=s.jsx("div",{className:"relative group/chats -mr-2",children:s.jsxs("button",{type:"button",onClick:K,disabled:i,className:D,"aria-expanded":U,children:[W,k]})}),e[9]=i,e[10]=K,e[11]=U,e[12]=W,e[13]=k,e[14]=v):v=e[14],v}const g=i?void 0:l,y=f?"pr-10":"pr-3.5";let b;e[15]!==y?(b=De("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",y),e[15]=y,e[16]=b):b=e[16];const j=!r,x=U2[n],h=!i&&"group-hover:hidden";let p;e[17]!==h?(p=De("h-3.5 w-3.5 text-muted-foreground/80",h),e[17]=h,e[18]=p):p=e[18];let w;e[19]!==x||e[20]!==p?(w=s.jsx(B,{name:x,className:p}),e[19]=x,e[20]=p,e[21]=w):w=e[21];let S;e[22]!==r||e[23]!==i?(S=i?null:s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:s.jsx(B,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[22]=r,e[23]=i,e[24]=S):S=e[24];let N;e[25]!==S||e[26]!==w?(N=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[w,S]}),e[25]=S,e[26]=w,e[27]=N):N=e[27];const P=nd[n];let C;e[28]!==m||e[29]!==P?(C=m(P),e[28]=m,e[29]=P,e[30]=C):C=e[30];let T;e[31]!==C?(T=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:C}),e[31]=C,e[32]=T):T=e[32];let R;e[33]!==i||e[34]!==N||e[35]!==T||e[36]!==g||e[37]!==b||e[38]!==j?(R=s.jsxs("button",{type:"button",onClick:g,disabled:i,className:b,"aria-expanded":j,children:[N,T]}),e[33]=i,e[34]=N,e[35]=T,e[36]=g,e[37]=b,e[38]=j,e[39]=R):R=e[39];let M;e[40]!==o||e[41]!==f||e[42]!==a||e[43]!==m?(M=f?s.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),a()},className:De("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":m("sessions.sidebar.header.actions.newSession"),children:s.jsx(B,{name:"add",className:"h-4 w-4"})}):null,e[40]=o,e[41]=f,e[42]=a,e[43]=m,e[44]=M):M=e[44];let F;return e[45]!==R||e[46]!==M?(F=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[R,M]}),e[45]=R,e[46]=M,e[47]=F):F=e[47],F},om=c.createContext(null);function rd(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const o=n.offsetParent;n=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function G2(t){const e=nt.c(14),{enabled:n,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,d=i===void 0?"":i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const m=c.useRef(u),f=c.useRef(null);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=p=>(m.current.add(p),f.current?.(),()=>{m.current.delete(p),f.current?.()}),e[1]=g):g=e[1];const y=g;let b;e[2]!==n||e[3]!==o||e[4]!==a?(b=()=>{const p=o.current;if(!n||a||!p)return;const w=document.createElement("div");w.dataset.sidebarCrossfadeLayer="true",w.className="pointer-events-none sticky top-0 z-30 h-0",w.style.marginBlock="0px",p.prepend(w);let S=null,N=null,P=null,C=0;const T=new Set;let R=[];const M=window.matchMedia("(prefers-reduced-motion: reduce)"),F=Y2,K=()=>{P?.cancel(),P=null,N?.remove(),N=null},D=()=>{let k=null,v=-1/0;for(const{entry:I,top:H}of R)H<=p.scrollTop&&H>=v&&(v=H,k=I);if(S!==k){if(K(),S&&k&&!M.matches){const I=S.host.cloneNode(!0);I instanceof HTMLElement&&(I.inert=!0,I.setAttribute("aria-hidden","true"),I.querySelectorAll("[id]").forEach(q2),I.className="pointer-events-none absolute inset-x-0 top-0 z-30",N=I)}S&&(F(S,S.slot),S.slot.style.removeProperty("height")),S=k,w.hidden=!k,k&&(k.slot.style.height=`${k.host.getBoundingClientRect().height}px`,F(k,w),N&&(w.append(N),P=N.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),P.onfinish=K))}},U=()=>{S&&(S.slot.style.height=`${S.host.getBoundingClientRect().height}px`);const k=rd(p)+p.clientTop;R=Array.from(m.current,v=>({entry:v,top:rd(v.slot)-k})),D()},A=new ResizeObserver(U),E=new MutationObserver(()=>{cancelAnimationFrame(C),C=requestAnimationFrame(U)});A.observe(p);const W=()=>{E.disconnect();for(const k of T)m.current.has(k)||(A.unobserve(k.host),k.slot.parentElement&&A.unobserve(k.slot.parentElement),T.delete(k));for(const k of m.current){const v=k.slot.closest("[data-sidebar-virtual-start]");v&&E.observe(v,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),T.has(k)||(A.observe(k.host),k.slot.parentElement&&A.observe(k.slot.parentElement),T.add(k))}cancelAnimationFrame(C),C=requestAnimationFrame(U)};return f.current=W,p.addEventListener("scroll",D,{passive:!0}),W(),U(),()=>{f.current=null,cancelAnimationFrame(C),p.removeEventListener("scroll",D),A.disconnect(),E.disconnect(),K(),w.hidden=!0,S&&(F(S,S.slot),S.slot.style.removeProperty("height")),w.remove()}},e[2]=n,e[3]=o,e[4]=a,e[5]=b):b=e[5];let j;e[6]!==n||e[7]!==d||e[8]!==o||e[9]!==a?(j=[n,a,d,o],e[6]=n,e[7]=d,e[8]=o,e[9]=a,e[10]=j):j=e[10],c.useLayoutEffect(b,j);const x=n?y:null;let h;return e[11]!==l||e[12]!==x?(h=s.jsx(om.Provider,{value:x,children:l}),e[11]=l,e[12]=x,e[13]=h):h=e[13],h}function q2(t){return t.removeAttribute("id")}function Y2(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function Q2(t){const e=nt.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(X2);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const g=i.current;if(!g)return;g.append(o);const y=r({slot:g,host:o});return()=>{y(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("div",{ref:i}),e[7]=d):d=e[7];let u;e[8]!==n?(u=s.jsx("div",{...n}),e[8]=n,e[9]=u):u=e[9];let m;e[10]!==o||e[11]!==u?(m=Vm.createPortal(u,o),e[10]=o,e[11]=u,e[12]=m):m=e[12];let f;return e[13]!==m?(f=s.jsxs(s.Fragment,{children:[d,m]}),e[13]=m,e[14]=f):f=e[14],f}function X2(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function im(t){const e=nt.c(3),n=c.useContext(om);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(Q2,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const J2=t=>{const e=nt.c(3),[n,r]=c.useState(!1);let i,o;return e[0]!==t?(i=()=>{if(!t){r(!1);return}let l=!0;const a=()=>{mr.getDirectoryAvailability(t).then(d=>{l&&d!=="unknown"&&r(d==="missing")})};return a(),window.addEventListener("focus",a),()=>{l=!1,window.removeEventListener("focus",a)}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),c.useEffect(i,o),n},Mi=t=>{const e=nt.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,m=u===void 0?!1:u,{currentTheme:f}=qn(),g=i?za[i]:null,y=o?Wa[o]??null:null,b=d!==void 0,j=b?m?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let x;e[0]!==m||e[1]!==b||e[2]!==d?(x=b?s.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center text-muted-foreground",m?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(B,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=m,e[1]=b,e[2]=d,e[3]=x):x=e[3];let h;e[4]!==m||e[5]!==f||e[6]!==b||e[7]!==y||e[8]!==j||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==g?(h=l?s.jsx("span",{className:De("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",b&&m?"hidden":"inline-flex",j),style:a?{backgroundColor:a}:void 0,children:s.jsx(Ka,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?s.jsx(B,{name:g,className:"h-3.5 w-3.5",style:y?{color:y}:void 0}):s.jsx(B,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:y?{color:y}:void 0})})}):g?s.jsx(B,{name:g,className:De("h-3.5 w-3.5",j),style:y?{color:y}:void 0}):s.jsx(B,{name:"folder",className:De("h-3.5 w-3.5 text-muted-foreground/80",j),style:y?{color:y}:void 0}),e[4]=m,e[5]=f,e[6]=b,e[7]=y,e[8]=j,e[9]=n,e[10]=a,e[11]=l,e[12]=g,e[13]=h):h=e[13];let p;e[14]!==x||e[15]!==h?(p=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,h]}),e[14]=x,e[15]=h,e[16]=p):p=e[16];let w;e[17]!==r?(w=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=w):w=e[18];let S;return e[19]!==p||e[20]!==w?(S=s.jsxs(s.Fragment,{children:[p,w]}),e[19]=p,e[20]=w,e[21]=S):S=e[21],S},Z2=t=>{const e=nt.c(61),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,isRepo:g,hideDirectoryControls:y,alwaysShowActions:b,onToggle:j,onNewSession:x,onNewWorktreeSession:h,onManageWorktrees:p,onRenameStart:w,onClose:S,children:N,showCreateButtons:P,hideHeader:C,statusIndicator:T,openSidebarMenuKey:R,setOpenSidebarMenuKey:M,projectPickerOptions:F,onProjectSelect:K}=t,D=r===void 0?!1:r,U=P===void 0?!0:P,A=C===void 0?!1:C,E=T===void 0?null:T,{t:W}=At(),k=J2(l);let v;e[0]!==D||e[1]!==n?(v={id:n,disabled:D},e[0]=D,e[1]=n,e[2]=v):v=e[2];const{attributes:I,listeners:H,setNodeRef:$,transform:re,transition:te,isDragging:ee}=ri(v),ue=c.useRef(!1),de=`project:${n}`,Te=R===de,[we,fe]=c.useState(!1),Ne=!!(F&&K);let L;e[3]!==de||e[4]!==M?(L=G=>{G&&fe(!1),M(G?de:null)},e[3]=de,e[4]=M,e[5]=L):L=e[5];const oe=L;let ce;e[6]!==y||e[7]!==g||e[8]!==S||e[9]!==p||e[10]!==x||e[11]!==w||e[12]!==U||e[13]!==W?(ce=G=>s.jsxs(s.Fragment,{children:[U&&!g&&!y&&x&&s.jsxs(G,{onClick:x,children:[s.jsx(B,{name:"add",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.newSession")]}),g&&!y&&p&&s.jsxs(G,{onClick:p,children:[s.jsx(B,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(G,{onClick:w,children:[s.jsx(B,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.edit")]}),s.jsxs(G,{onClick:S,className:"text-destructive focus:text-destructive",children:[s.jsx(B,{name:"close",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=y,e[7]=g,e[8]=S,e[9]=p,e[10]=x,e[11]=w,e[12]=U,e[13]=W,e[14]=ce):ce=e[14];const pe=ce,Y=sC,ve=nC,Ee=rC;let je;e[15]===Symbol.for("react.memo_cache_sentinel")?(je=G=>{(G.button===2||G.button===0&&G.ctrlKey)&&(ue.current=!0)},e[15]=je):je=e[15];const ge=je;let be;e[16]!==j?(be=G=>{if(G.currentTarget.blur(),ue.current){ue.current=!1;return}j()},e[16]=j,e[17]=be):be=e[17];const Q=be;let _;e[18]!==re?(_=oi.Transform.toString(re),e[18]=re,e[19]=_):_=e[19];let J;e[20]!==_||e[21]!==te?(J={transform:_,transition:te},e[20]=_,e[21]=te,e[22]=J):J=e[22];const me=ee&&"opacity-30";let le;e[23]!==me?(le=De("relative",me),e[23]=me,e[24]=le):le=e[24];let V;e[25]!==b||e[26]!==I||e[27]!==k||e[28]!==oe||e[29]!==Q||e[30]!==y||e[31]!==A||e[32]!==n||e[33]!==f||e[34]!==we||e[35]!==Te||e[36]!==Ne||e[37]!==g||e[38]!==H||e[39]!==x||e[40]!==h||e[41]!==K||e[42]!==d||e[43]!==o||e[44]!==l||e[45]!==a||e[46]!==m||e[47]!==u||e[48]!==i||e[49]!==F||e[50]!==pe||e[51]!==U||e[52]!==E||e[53]!==W?(V=A?null:s.jsx(s.Fragment,{children:s.jsxs(Xd,{open:we,onOpenChange:fe,children:[s.jsx(Qd,{render:s.jsx(im,{className:De("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:G=>{y||(G.preventDefault(),fe(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...I,children:[Ne?s.jsxs(js,{children:[s.jsx(vs,{asChild:!0,children:s.jsxs("button",{type:"button",className:De("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-[padding]",g&&!y?b||Te?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":b||Te?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":W("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(Mi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m}),s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(qr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Ss,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:F?.map(G=>s.jsxs(_t,{onClick:()=>K?.(G.id),className:"flex items-center justify-between gap-3",title:G.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(Mi,{...G})}),G.id===n?s.jsx(B,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},G.id))})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:ge,onClick:Q,...H,className:De("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing transition-[padding]",g&&!y?b||Te?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":b||Te?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(Mi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,alwaysShowActions:b}),k?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:W("sessions.sidebar.project.folderMissing"),"aria-label":W("sessions.sidebar.project.folderMissing"),children:s.jsx(B,{name:"alert",className:"h-3 w-3"})}):null,E?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:E}):null,l?s.jsx(qr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(jt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:De("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",U?"right-7":"right-0.5"),children:[U&&g&&!y&&h?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),h()},className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground transition-opacity",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":W("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(B,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,y?null:s.jsxs(js,{open:Te,onOpenChange:oe,children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground",Te?"opacity-100 pointer-events-auto":b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":W("sessions.sidebar.project.actions.projectMenu"),onPointerDown:ve,onMouseDown:Ee,onClick:Y,children:s.jsx(B,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ss,{align:"end",className:"min-w-[180px]",children:pe(_t)})]})]}),U&&x?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),x()},className:De("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":W(g?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(B,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W(g?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(Yd,{className:"min-w-[180px]",children:pe(Ln)})]})}),e[25]=b,e[26]=I,e[27]=k,e[28]=oe,e[29]=Q,e[30]=y,e[31]=A,e[32]=n,e[33]=f,e[34]=we,e[35]=Te,e[36]=Ne,e[37]=g,e[38]=H,e[39]=x,e[40]=h,e[41]=K,e[42]=d,e[43]=o,e[44]=l,e[45]=a,e[46]=m,e[47]=u,e[48]=i,e[49]=F,e[50]=pe,e[51]=U,e[52]=E,e[53]=W,e[54]=V):V=e[54];let Z;return e[55]!==N||e[56]!==$||e[57]!==J||e[58]!==le||e[59]!==V?(Z=s.jsxs("div",{ref:$,style:J,className:le,children:[V,N]}),e[55]=N,e[56]=$,e[57]=J,e[58]=le,e[59]=V,e[60]=Z):Z=e[60],Z},eC=t=>{const e=nt.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:m,transition:f,isDragging:g}=ri(l);let y;e[3]!==a||e[4]!==u?(y={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=y):y=e[5];const b=y;let j;e[6]!==m?(j=oi.Transform.toString(m),e[6]=m,e[7]=j):j=e[7];let x;e[8]!==j||e[9]!==f?(x={transform:j,transition:f},e[8]=j,e[9]=f,e[10]=x):x=e[10];const h=g&&"opacity-50";let p;e[11]!==h?(p=De("space-y-0.5 rounded-md",h),e[11]=h,e[12]=p):p=e[12];let w;e[13]!==i||e[14]!==b?(w=i(b),e[13]=i,e[14]=b,e[15]=w):w=e[15];let S;return e[16]!==d||e[17]!==x||e[18]!==p||e[19]!==w?(S=s.jsx("div",{ref:d,style:x,className:p,children:w}),e[16]=d,e[17]=x,e[18]=p,e[19]=w,e[20]=S):S=e[20],S},tC=c.memo(eC);function sC(t){t.stopPropagation()}function nC(t){t.stopPropagation()}function rC(t){t.stopPropagation()}const od=[],oC=t=>{const e=nt.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=Zd(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},Oi=(t,e)=>e?t.sessions.some(n=>wr(n,e)):!1,iC=(t,e,n)=>t.sessions.some(r=>qf(r,r,e,n,t.directory,t.directory)),aC=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},lC=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},cC=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.sessionBatchSize!==e.sessionBatchSize||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&iC(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&aC(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&lC(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Oi(e.group,t.editingId)||Oi(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Oi(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Vo(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Vo(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??gt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.renderBody===e.renderBody&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.resetSessionSearch===e.resetSessionSearch&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function dC(t){const{t:e}=At(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,groupSearchDataByGroup:u,visibleSessionCount:m,sessionBatchSize:f,collapsedGroups:g,hideDirectoryControls:y,showMoreGroupSessions:b,resetGroupSessionLimit:j,mobileVariant:x,alwaysShowActions:h,activeProjectId:p,setActiveProjectIdOnly:w,setSessionSwitcherOpen:S,openNewSessionDraft:N,pinnedSessionIds:P,sessionOrderIndex:C,notifyOnSubtasks:T,onToggleCollapsedGroup:R,dragHandleProps:M,compactBodyPadding:F=!1,expandedParents:K,editingId:D,editingRowKey:U,openSidebarMenuKey:A,editTitle:E,folderRename:W,setFolderRenameDraft:k,clearFolderRename:v}=t,I=Gt(Pe=>Pe.toggleFolderCollapse),H=Gt(Pe=>Pe.renameFolder),$=Gt(Pe=>Pe.deleteFolder),re=Gt(Pe=>Pe.addSessionToFolder),te=ye(Pe=>Pe.showDeletionDialog),[ee,ue]=c.useState(null),de=c.useCallback((Pe,ze)=>{const st=C.get(Pe.session.id),at=C.get(ze.session.id);if(st!==void 0||at!==void 0){if(st===void 0)return 1;if(at===void 0)return-1;if(st!==at)return st-at}return $a(Pe.session,ze.session,P,Fa)},[P,C]),Te=a?u.get(n):null,we=a?!1:g.has(r),fe=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Pe=gt(n.directory??null),ze=n.branch?.trim();return Pe&&ze?Yo(Pe,ze):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),Ne=_u(fe),L=Ne?`var(--pr-${Ne.visualState})`:void 0,oe=Xo(),ce=c.useMemo(()=>{const Pe=n.folderScopes?.map(ze=>gt(ze.directory))??[gt(n.directory??null)];return[...new Set(Pe.filter(ze=>!!ze))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Pe=>ce.length>0?oe.subscribeBootstrap(Pe):()=>{},[ce.length,oe]),c.useCallback(()=>ce.map(Pe=>`${Pe}\0${oe.getBootstrapState(Pe)??""}\0${oe.getBootstrapFailure(Pe)??""}\0${oe.getInitializationState(Pe)??""}\0${oe.getInitializationFailure(Pe)??""}`).join(""),[ce,oe]),c.useCallback(()=>"",[]));const pe=ce.some(Pe=>{const ze=oe.getBootstrapState(Pe);return ze==="queued"||ze==="running"}),Y=ce.find(Pe=>oe.getBootstrapState(Pe)==="failed"||oe.getInitializationState(Pe)==="failed")??null,ve=Y!==null&&oe.getBootstrapState(Y)==="failed",Ee=Y?ve?oe.getBootstrapFailure(Y):oe.getInitializationFailure(Y):void 0,je=Ee==="os-permission"&&Vd(),[ge,be]=c.useState(!1),Q=c.useCallback(()=>{Y&&oe.requestBootstrap({directory:Y,priority:we?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[oe,Y,n.isMain,we]),_=c.useCallback(async()=>{if(!(!Y||!je||ge)){be(!0);try{(await Ud(Y)).success&&Q()}finally{be(!1)}}},[je,Y,ge,Q]),J=f??(y?10:5),me=Math.max(J,m??J),le=a?Te?.groupMatches===!0:!1,V=a,Z=c.useMemo(()=>[...V?Te?.filteredNodes??[]:n.sessions].sort(de),[de,n.sessions,Te?.filteredNodes,V]),G=n.folderScopeKey??gt(n.directory??null),ie=kn(i,n.directory),Se=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:G?[{scopeKey:G,directory:n.directory??null}]:[],[G,n.directory,n.folderScopes]),se=Gt(Un(c.useCallback(Pe=>Se.map(({scopeKey:ze})=>Pe.foldersMap[ze]??od),[Se]))),Me=c.useMemo(()=>Se.flatMap(({scopeKey:Pe,directory:ze},st)=>(se[st]??od).map(Ct=>({folder:Ct,scopeKey:Pe,scopeDirectory:ze}))),[se,Se]),He=Gt(Un(c.useCallback(Pe=>new Set(se.flatMap(ze=>ze.filter(st=>Pe.collapsedFolderIds.has(st.id)).map(st=>st.id))),[se]))),We=c.useMemo(()=>{const Pe=new Map,ze=st=>{st.forEach(at=>{Pe.set(at.session.id,at),at.children.length>0&&ze(at.children)})};return ze(Z),Pe},[Z]),Le=c.useMemo(()=>Me.map(({folder:Pe,scopeKey:ze,scopeDirectory:st})=>{const at=ga(Pe.sessionIds,We).sort(de);return{folder:Pe,scopeKey:ze,scopeDirectory:st,nodes:at}}),[Me,We,de]),Ve=c.useMemo(()=>{const Pe=Gf(Le.map(({folder:ze,nodes:st})=>({id:ze.id,name:ze.name,parentId:ze.parentId,nodeCount:st.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?d:""});return Le.filter(({folder:ze})=>Pe.has(ze.id))},[Le,n.isArchivedBucket,a,d]),O=D,he=A,$e=c.useMemo(()=>new Set(Ve.flatMap(Pe=>Pe.folder.sessionIds)),[Ve]),Ue=c.useMemo(()=>Z.filter(Pe=>!$e.has(Pe.session.id)),[Z,$e]),ct=c.useMemo(()=>{const Pe=new Map(Ve.map(ze=>[ze.folder.id,ze]));return Hf(Ve.map(ze=>ze.folder)).map(ze=>Pe.get(ze.id)).filter(ze=>!!ze)},[Ve]),pt=c.useMemo(()=>{const Pe=new Map;return Ve.forEach(ze=>{if(!ze.folder.parentId)return;const st=Pe.get(ze.folder.parentId)??[];st.push(ze),Pe.set(ze.folder.parentId,st)}),Pe},[Ve]),it=c.useMemo(()=>{const Pe=new Map(Ve.map(at=>[at.folder.id,at])),ze=new Map,st=(at,Ct)=>{const Ot=ze.get(at);if(Ot!==void 0)return Ot;if(Ct.has(at))return[];Ct.add(at);const Lt=Pe.get(at),Kt=Lt?[...Lt.nodes]:[];for(const Rt of pt.get(at)??[])Kt.push(...st(Rt.folder.id,Ct));return ze.set(at,Kt),Kt};return Ve.forEach(({folder:at})=>st(at.id,new Set)),ze},[Ve,pt]),ft="project",yt=c.useMemo(()=>{const Pe=new Set;return $c(Z,O,Pe),Ve.forEach(({nodes:ze})=>{$c(ze,O,Pe)}),Pe},[Z,Ve,O]),ht=c.useMemo(()=>{if(!he)return null;const Pe=Vo(Z,he,ft,!!n.isArchivedBucket);if(Pe)return Pe;for(const{nodes:ze}of Ve){const st=Vo(ze,he,ft,!!n.isArchivedBucket);if(st)return st}return null},[he,Z,Ve,n.isArchivedBucket]),bt=c.useCallback(Pe=>{const ze=new WeakMap,st=at=>{ze.set(at,Ko(at));for(const Ct of at.children)st(Ct)};return Pe.forEach(st),ze},[]),Dt=c.useMemo(()=>bt(Z),[bt,Z]),xe=c.useMemo(()=>{const Pe=new WeakMap;return Ve.forEach(({nodes:ze})=>{ze.forEach(st=>Pe.set(st,Ko(st)))}),Pe},[Ve]),Ye=c.useCallback(Pe=>Dt.get(Pe)??xe.get(Pe)??"",[Dt,xe]),Xe=c.useCallback(Pe=>({subtreeContainsEditing:yt,menuOpenSessionId:ht,nodeStructureKey:Ye(Pe)}),[yt,ht,Ye]),qe=Ue.length,dt=n.isArchivedBucket||a?Ue:Ue.slice(0,me),X=qe-dt.length,ae=!n.isArchivedBucket&&!a&&qe>J&&X===0,Ae=c.useCallback(Pe=>{const ze=[],st=at=>{at.forEach(Ct=>{ze.push(Ct.session),Ct.children.length>0&&st(Ct.children)})};return st(Pe),ze},[]),Ge=c.useMemo(()=>Ae(Z),[Ae,Z]),q=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Pe=new Map,ze=new Map;for(const{folder:at}of Ve){if(!at.parentId)continue;const Ct=ze.get(at.parentId)??[];Ct.push(at.id),ze.set(at.parentId,Ct)}const st=(at,Ct)=>{if(Ct.has(at))return[];Ct.add(at);const Ot=Ve.find(({folder:Rt})=>Rt.id===at),Lt=Ot?Ae(Ot.nodes):[],Kt=ze.get(at)??[];for(const Rt of Kt)Lt.push(...st(Rt,Ct));return Lt};for(const{folder:at}of Ve)Pe.set(at.id,st(at.id,new Set));return Pe},[Ve,Ae,n.isArchivedBucket]);if(a&&!le&&ct.length===0&&Ue.length===0)return null;const Fe=!n.isMain&&!!n.branch,Ze=n.branch&&sb(n.branch,n.label)?{label:n.branch}:null,Je=we?s.jsx(tu,{nodes:Z,includeUnreadSubtasks:T}):null,et=(Pe,ze)=>{const{folder:st,scopeKey:at,scopeDirectory:Ct,nodes:Ot}=Pe,Lt=q.get(st.id)??[],Kt=W?.folderId===st.id&&W?.scopeKey===at,Rt=a?!1:He.has(st.id),Vt=$t=>s.jsx(Xf,{folderId:st.id,scopeKey:at,ownerKey:ie,children:(Xt,Bt)=>s.jsx(Qf,{folder:st,displayName:ze,sessions:Ot,isCollapsed:Rt,collapsedActivityState:$t,onToggle:()=>I(st.id),onRename:ut=>{H(at,st.id,ut)},onDelete:()=>{if(n.isArchivedBucket){Us.requestDelete({sessions:Lt,mode:"session"});return}if(!te){$(at,st.id);return}const ut=Ve.filter(({folder:ss})=>ss.parentId===st.id).length,ts=Ot.length;ue({scopeKey:at,folderId:st.id,folderName:st.name,subFolderCount:ut,sessionCount:ts})},groupDirectory:Ct??n.directory,projectId:i,mobileVariant:x,alwaysShowActions:h,isRenaming:Kt,renameDraft:Kt?W?.draft:void 0,onRenameDraftChange:k,onRenameSave:()=>{const ut=W?.draft.trim()??"";ut&&H(at,st.id,ut),v()},onRenameCancel:v,droppableRef:Xt,isDropTarget:Bt,depth:0,onNewSession:()=>{i&&i!==p&&w(i),x&&S(!1),N({selectedProjectId:i,directoryOverride:Ct??n.directory,targetFolderId:st.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:Ot.map(ut=>s.jsx(Ho,{node:ut,pinnedSessionIds:P,expandedParents:K,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:T,editingId:D,editingRowKey:U,editTitle:E,openSidebarMenuKey:A,mobileVariant:x,alwaysShowActions:h,groupDirectory:Ct??n.directory,projectId:i,folderOwnerKey:ie,selectionScopeKey:ie,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:yt,menuOpenSessionId:ht,nodeStructureKey:Ye(ut),childRenderExtrasFor:Xe},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},ut.session.id))})},st.id);return Rt?s.jsx(oC,{nodes:it.get(st.id)??Ot,includeUnreadSubtasks:T,children:Vt},st.id):Vt(null)},kt=()=>{const Pe=new Map;for(const Ct of Ve){const Ot=Ct.folder.parentId;if(!Ot)continue;const Lt=Pe.get(Ot);Lt?Lt.push(Ct):Pe.set(Ot,[Ct])}const ze=[],st=new Set,at=(Ct,Ot)=>{if(st.has(Ct.folder.id))return;st.add(Ct.folder.id);const Lt=Ot?`${Ot} / ${Ct.folder.name}`:Ct.folder.name;ze.push(et(Ct,Lt)),!(!a&&He.has(Ct.folder.id))&&(Pe.get(Ct.folder.id)??[]).forEach(Rt=>at(Rt,Lt))};return ct.forEach(Ct=>at(Ct,"")),ze},Qe=!!(!n.isMain&&n.worktree),It=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(B,{name:"alert",className:"h-3 w-3"})}):null,Mt=n.space&&n.space.state!=="complete"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.spaceStale"),"aria-label":e("sessions.sidebar.group.spaceStale"),children:s.jsx(B,{name:"alert",className:"h-3 w-3"})}):null,ke=Qe||!!n.space,Oe=h?ke?"pr-14":"pr-7":ke?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",Re=Y?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Ee==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":ve?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),je?s.jsx(mt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ge,onClick:()=>{_()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(mt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:Q,children:e("sessions.sidebar.group.empty.retry")})]}):null,Be=Pe=>s.jsx(Ho,{node:Pe,pinnedSessionIds:P,expandedParents:K,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:T,editingId:D,editingRowKey:U,editTitle:E,openSidebarMenuKey:A,mobileVariant:x,alwaysShowActions:h,groupDirectory:n.directory,projectId:i,folderOwnerKey:ie,selectionScopeKey:ie,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:yt,menuOpenSessionId:ht,nodeStructureKey:Ye(Pe),childRenderExtrasFor:Xe},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Pe.session.id),Ke=s.jsxs(Gk,{scopeKey:Se[0]?.scopeKey??G,ownerKey:ie,hasFolders:Ve.length>0,onSessionDroppedOnFolder:(Pe,ze)=>{const st=Ve.find(({folder:Ct,scopeKey:Ot})=>Ct.id===ze.folderId&&Ot===ze.scopeKey);if(!st)return;const at=Gt.getState();for(const{scopeKey:Ct}of Se)Ct!==st.scopeKey&&at.getSessionFolderId(Ct,Pe)&&at.removeSessionFromFolder(Ct,Pe);re(st.scopeKey,ze.folderId,Pe)},children:[kt(),dt.map(Be),qe===0&&Ve.length===0?!n.isArchivedBucket&&!pe&&!Re&&n.directory&&!n.emptyMessage?s.jsx(mt,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{i&&i!==p&&w(i),x&&S(!1),N({selectedProjectId:i,directoryOverride:n.directory,target:n.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):pe?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Re||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,qe>0&&Re?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Re}):null,X>0?s.jsx("button",{type:"button",onClick:()=>b(r,dt.length,f??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,ae?s.jsx("button",{type:"button",onClick:()=>j(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),rt="pb-2",xt=s.jsx(rm,{value:ee,setValue:ue,onConfirm:()=>{const Pe=ee;Pe&&($(Pe.scopeKey,Pe.folderId),ue(null))}});return o?l?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:De("oc-group-body",rt),children:Ke})}),xt]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:De("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>R(r),role:"button",tabIndex:0,onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key===" ")&&(Pe.preventDefault(),R(r))},"aria-label":we?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!we,children:[s.jsxs("div",{ref:M?.setActivatorNodeRef,className:De("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Oe),...M?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(B,{name:"archive",className:De("h-3.5 w-3.5 shrink-0 text-muted-foreground",h?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:De("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:we?s.jsx(B,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:_r(n.label,d)}),It,Je]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(B,{name:n.space?"box-3":"git-branch",className:De("h-3.5 w-3.5 shrink-0",!L&&"text-muted-foreground",h?"hidden":"group-hover/gh:hidden"),style:L?{color:L}:void 0,"aria-label":n.space?e("sessions.sidebar.group.space"):void 0}),s.jsx("span",{className:De("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:we?s.jsx(B,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:_r(n.label,d)}),It,Mt,Je,Ne?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:L?{color:L}:void 0,children:["#",Ne.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:_r(n.label,d)}),Je]})}),Fe&&Ze?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(B,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(B,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Ze.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(qr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&Ge.length>0?s.jsx("div",{className:De("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),Us.requestDelete({sessions:Ge,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(B,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:De("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),Us.requestDelete({sessions:Ge,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(B,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.space?s.jsx("div",{className:De("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),n.space&&lh.getState().openAccessDialog(n.space.id)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("spaces.group.access.giveAria",{label:n.label}),children:s.jsx(B,{name:"key",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,n.directory?s.jsx("div",{className:De("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),i&&i!==p&&w(i),x&&S(!1),N({selectedProjectId:i,directoryOverride:n.directory,preserveDirectoryOverride:!!n.space})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(B,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),n.space?s.jsx(qh,{spaceId:n.space.id,className:"pb-1 pl-5"}):null,!we&&l?s.jsx("div",{className:De("oc-group-body",rt),children:Ke}):null]}),xt]})}const uC=c.memo(dC,cC),jo=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&n&&i(!1)},id=(t,e)=>Lu(t.label?.trim()||yr(t.normalizedPath,e)||t.normalizedPath);function fC(t){const e=nt.c(104),{model:n,view:r,actions:i}=t;ys("ui.sidebar_projects_list.render");const{t:o}=At(),l=Xo(),a=Gt(jC),d=Gt(SC),u=Gt(vC),m=Gt(wC),f=ye(yC),[g,y]=c.useState(null),[b,j]=c.useState(null),[x,h]=c.useState(null),[p,w]=c.useState(null),[S,N]=c.useState(!1),P=c.useRef(null);let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C={activationConstraint:{distance:8}},e[0]=C):C=e[0];let T;e[1]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},e[1]=T):T=e[1];let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R={coordinateGetter:wx},e[2]=R):R=e[2];const M=Zo(fn(ti,C),fn(ei,T),fn(xx,R));let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=_=>{P.current=_,w(_)},e[3]=F):F=e[3];const K=F;let D;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let _;e[7]!==r.homeDirectory?(_=J=>({id:J.project.id,projectLabel:id(J.project,r.homeDirectory),projectDescription:Hr(J.project.normalizedPath,r.homeDirectory),projectIcon:J.project.icon,projectColor:J.project.color,projectIconImage:J.project.iconImage,projectIconBackground:J.project.iconBackground}),e[7]=r.homeDirectory,e[8]=_):_=e[8],D=n.projectSections.map(_),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=D}else D=e[6];const U=D;let A;e:{if(!r.stickyZoneHeaders){A=-1;break e}let _;if(e[9]!==n.rowModel.stickyHeaders||e[10]!==b){let J;e[12]!==b?(J=me=>`${me.kind}:${me.id}`===b,e[12]=b,e[13]=J):J=e[13],_=n.rowModel.stickyHeaders.findIndex(J),e[9]=n.rowModel.stickyHeaders,e[10]=b,e[11]=_}else _=e[11];A=_}const E=A;let W;if(e[14]!==x||e[15]!==n.groupProps.editingRowKey||e[16]!==n.rowModel.rowIndexByKey||e[17]!==n.rowModel.rows||e[18]!==n.rowModel.stickyHeaders||e[19]!==n.state.openSidebarMenuKey||e[20]!==E){if(W=new Set,x){let _;e[22]!==x||e[23]!==n.rowModel.rowIndexByKey?(_=n.rowModel.rowIndexByKey.get(x),e[22]=x,e[23]=n.rowModel.rowIndexByKey,e[24]=_):_=e[24];const J=_;J!==void 0&&W.add(J)}for(let _=0;_<n.rowModel.rows.length;_=_+1,_){const J=n.rowModel.rows[_];J?.kind==="session"&&(n.groupProps.editingRowKey===J.key||n.state.openSidebarMenuKey===`session-menu:${J.key}`||n.state.openSidebarMenuKey===`session-context:${J.key}`)&&W.add(_)}if(E>=0){const _=Math.max(0,E-1),J=Math.min(n.rowModel.stickyHeaders.length-1,E+1);for(let me=_;me<=J;me=me+1,me){const le=n.rowModel.stickyHeaders[me];le&&W.add(le.rowIndex)}}e[14]=x,e[15]=n.groupProps.editingRowKey,e[16]=n.rowModel.rowIndexByKey,e[17]=n.rowModel.rows,e[18]=n.rowModel.stickyHeaders,e[19]=n.state.openSidebarMenuKey,e[20]=E,e[21]=W}else W=e[21];const k=W;let v;e[25]!==n.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(v=_=>{const J=r.stickyZoneHeaders?Sk(n.rowModel.stickyHeaders,_):null,me=J?`${J.kind}:${J.id}`:null;j(le=>le===me?le:me)},e[25]=n.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=v):v=e[27];const I=v;let H;e[28]!==l||e[29]!==o?(H=_=>{const J=()=>{if(!_.status.directory){Jo();return}l.requestBootstrap({directory:_.status.directory,priority:"expanded",reason:_.group.isMain?"project-expanded":"worktree-expanded",force:!0})},me=async()=>{if(!_.status.directory)return;(await Ud(_.status.directory)).success&&J()};let le;e:switch(_.status.state){case"permission-denied":{le=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{le=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{le=o("sessions.sidebar.group.empty.initializationFailed");break e}default:le=o("sessions.sidebar.group.empty.loadingSessions")}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[_.status.state==="loading"?s.jsx(B,{name:"loader-4",className:"size-3 animate-spin"}):null,le,_.status.canGrantAccess?s.jsx(mt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{me()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,_.status.state!=="loading"?s.jsx(mt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:J,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[28]=l,e[29]=o,e[30]=H):H=e[30];const $=H;let re;e[31]!==i||e[32]!==u||e[33]!==n.emptyState||e[34]!==n.groupProps||e[35]!==n.projectRepoStatus||e[36]!==n.searchEmptyState||e[37]!==n.singleProjectMode||e[38]!==n.state||e[39]!==U||e[40]!==d||e[41]!==$||e[42]!==f||e[43]!==o||e[44]!==a||e[45]!==r.alwaysShowActions||e[46]!==r.hideDirectoryControls||e[47]!==r.homeDirectory||e[48]!==r.mobileVariant||e[49]!==r.projectSortOrder||e[50]!==r.stickyZoneHeaders||e[51]!==r.timelineView||e[52]!==r.worktreeSortOrder?(re=_=>{if(_.kind==="activity-header")return s.jsx(im,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(H2,{activityKey:_.activityKey,collapsed:_.collapsed,forceExpanded:_.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!_.collapsed){const J=`activity:${_.activityKey}`;i.group.resetGroupSessionLimit(J),n.state.setVisibleActivityCountByKey(me=>{if(!me.has(J))return me;const le=new Map(me);return le.delete(J),le})}n.state.setCollapsedActivityKeys(J=>{const me=new Set(J);return me.has(_.activityKey)?me.delete(_.activityKey):me.add(_.activityKey),me})},onNewChat:()=>{ye.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:nb,directoryOverride:null})}})});if(_.kind==="project-header"){const J=_.section.project,me=id(J,r.homeDirectory);return s.jsx(Z2,{id:J.id,disabled:n.singleProjectMode||_.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:me,projectDescription:Hr(J.normalizedPath,r.homeDirectory),projectDirectory:J.normalizedPath,projectIcon:J.icon,projectColor:J.color,projectIconImage:J.iconImage,projectIconBackground:J.iconBackground,isCollapsed:_.collapsed,isRepo:!!n.projectRepoStatus.get(J.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:_.collapsed?i.renderProjectStatusIndicator?.(J.id,_.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?U:void 0,onProjectSelect:n.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!_.forceExpanded&&!n.singleProjectMode&&i.toggleProject(J.id)},onNewSession:()=>{jo({projectId:J.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:J.id,directoryOverride:J.normalizedPath})},onNewWorktreeSession:()=>{jo({projectId:J.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(J.id),onRenameStart:()=>i.openProjectEditDialog(J.id),onClose:()=>i.removeProject(J.id),showCreateButtons:!0})}if(_.kind==="group-header")return s.jsx(tC,{id:_.groupKey,disabled:_.forceExpanded||n.state.editingId!==null||r.worktreeSortOrder!=="manual",children:J=>s.jsx(uC,{...n.groupProps,...i.group,group:_.group,groupKey:_.groupKey,projectId:_.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get(_.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:J,renderBody:!1})});if(_.kind==="folder-header"){const J=n.groupProps.folderRename?.folderId===_.folder.id&&n.groupProps.folderRename.scopeKey===_.scopeKey;return s.jsx(Xf,{folderId:_.folder.id,scopeKey:_.scopeKey,ownerKey:_.ownerKey,disabled:!_.dropEnabled,children:(me,le)=>s.jsx(Uk,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:_.activityNodes,folder:_.folder,displayName:_.displayName,sessions:_.nodes,isCollapsed:_.collapsed,onToggle:_.forceExpanded?xC:()=>a(_.folder.id),onRename:V=>d(_.scopeKey,_.folder.id,V),onDelete:()=>{_.archived?Us.requestDelete({sessions:[..._.deleteSessions],mode:"session"}):f?y({scopeKey:_.scopeKey,folderId:_.folder.id,folderName:_.folder.name,subFolderCount:_.subFolderCount,sessionCount:_.nodes.length}):u(_.scopeKey,_.folder.id)},renderBody:!1,groupDirectory:_.scopeDirectory??_.group.directory,projectId:_.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:J,renameDraft:J?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const V=n.groupProps.folderRename?.draft.trim();V&&d(_.scopeKey,_.folder.id,V),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:me,isDropTarget:le,onNewSession:()=>{jo({projectId:_.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:_.projectId,directoryOverride:_.scopeDirectory??_.group.directory,targetFolderId:_.folder.id,target:_.group.draftTarget})},archivedBucket:_.archived})})}if(_.kind==="session"){const J=new Set;return wr(_.node,n.state.editingId)&&J.add(_.node.session.id),s.jsx("div",{onFocusCapture:()=>h(_.key),onBlurCapture:()=>h(me=>me===_.key?null:me),children:s.jsx(Ho,{...n.groupProps,node:_.node,depth:_.depth,groupDirectory:_.groupDirectory,projectId:_.projectId,folderOwnerKey:_.ownerKey,selectionScopeKey:_.selectionScopeKey,archivedBucket:_.archived,renderContext:_.renderContext,rowKey:_.key,dragKey:_.key,secondaryMeta:_.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:J,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${_.key}`||n.state.openSidebarMenuKey===`session-context:${_.key}`?_.node.session.id:null,nodeStructureKey:Ko(_.node)}})})}if(_.kind==="run")return s.jsx(_2,{run:_.run,laneNodes:_.laneNodes,renderContext:_.renderContext,projectId:_.projectId,projectLabel:_.projectLabel,expansionKey:_.expansionKey,expanded:_.expanded,forceExpanded:_.forceExpanded,notifyOnSubtasks:n.groupProps.notifyOnSubtasks,toggleParent:n.groupProps.toggleParent});if(_.kind==="show-control")return s.jsx("button",{type:"button",className:De("mt-0.5 flex items-center justify-start rounded-md pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",r.timelineView?"pl-[10px]":"pl-[26px]"),onClick:()=>{_.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(J=>{const me=new Map(J);return _.control==="more"?me.set(_.containerKey,_.currentCount+_.increment):me.delete(_.containerKey),me}):_.control==="more"?i.group.showMoreGroupSessions(_.containerKey,_.currentCount,_.increment):i.group.resetGroupSessionLimit(_.containerKey)},children:o(_.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if(_.kind==="status")return $(_);if(_.emptyKind==="sidebar")return n.emptyState;if(_.emptyKind==="search")return n.searchEmptyState;if(_.emptyKind==="group"&&_.group?.directory&&!_.group.emptyMessage){const J=_.group;return s.jsx(mt,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{jo({projectId:_.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:_.projectId,directoryOverride:J.directory,target:J.draftTarget})},children:o("sessions.sidebar.group.empty.startSession")})}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:_.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):_.group?.emptyMessage??o("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[31]=i,e[32]=u,e[33]=n.emptyState,e[34]=n.groupProps,e[35]=n.projectRepoStatus,e[36]=n.searchEmptyState,e[37]=n.singleProjectMode,e[38]=n.state,e[39]=U,e[40]=d,e[41]=$,e[42]=f,e[43]=o,e[44]=a,e[45]=r.alwaysShowActions,e[46]=r.hideDirectoryControls,e[47]=r.homeDirectory,e[48]=r.mobileVariant,e[49]=r.projectSortOrder,e[50]=r.stickyZoneHeaders,e[51]=r.timelineView,e[52]=r.worktreeSortOrder,e[53]=re):re=e[53];const te=re;let ee;e[54]!==n.rowModel.rows?(ee=n.rowModel.rows.flatMap(bC),e[54]=n.rowModel.rows,e[55]=ee):ee=e[55];const ue=ee;let de;e[56]!==n.sectionsForRender?(de=new Set(n.sectionsForRender.map(gC)),e[56]=n.sectionsForRender,e[57]=de):de=e[57];const Te=de;let we;e[58]!==n.rowModel.stickyHeaders?(we=n.rowModel.stickyHeaders.map(pC).join(""),e[58]=n.rowModel.stickyHeaders,e[59]=we):we=e[59];const fe=we,Ne=!r.timelineView;let L;e[60]!==Te?(L=_=>{N(Te.has(String(_.active.id)))},e[60]=Te,e[61]=L):L=e[61];let oe;e[62]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>N(!1),e[62]=oe):oe=e[62];let ce;e[63]!==i||e[64]!==m||e[65]!==n.rowModel.folderAuthorityByOwner||e[66]!==n.rowModel.folderDropTargets||e[67]!==n.rowModel.rows||e[68]!==n.sectionsForRender||e[69]!==n.state||e[70]!==r.hasSessionSearchQuery||e[71]!==r.projectSortOrder?(ce=_=>{if(N(!1),!_.over)return;const J=_.active.data.current,me=_.over.data.current;if(J?.type==="session"&&J.sessionId&&J.ownerKey&&J.archivedBucket!==!0&&me?.type==="folder"&&me.folderId&&me.scopeKey&&me.ownerKey===J.ownerKey){const Ve=n.rowModel.folderDropTargets.find($e=>$e.folderId===me.folderId&&$e.scopeKey===me.scopeKey&&$e.ownerKey===J.ownerKey),O=n.rowModel.folderAuthorityByOwner.get(J.ownerKey);if(!Ve?.enabled||O?.complete!==!0)return;const he=Gt.getState();for(const $e of O.scopeKeys)$e!==me.scopeKey&&he.removeSessionFromFolder($e,J.sessionId);m(me.scopeKey,me.folderId,J.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||_.active.id===_.over.id)return;const le=String(_.active.id),V=String(_.over.id),Z=n.sectionsForRender.map(hC),G=Z.indexOf(le),ie=Z.indexOf(V);if(G>=0&&ie>=0&&r.projectSortOrder==="manual"){i.reorderProjects(G,ie);return}const Se=n.rowModel.rows.find(Ve=>Ve.kind==="group-header"&&Ve.groupKey===le),se=n.rowModel.rows.find(Ve=>Ve.kind==="group-header"&&Ve.groupKey===V);if(!Se||!se||Se.projectId!==se.projectId||!Se.projectId)return;const Me=Se.projectId,He=n.sectionsForRender.find(Ve=>Ve.project.id===Me);if(!He)return;const We=He.groups.findIndex(Ve=>Ve.id===Se.group.id),Le=He.groups.findIndex(Ve=>Ve.id===se.group.id);We<0||Le<0||i.setGroupOrderByProject(Ve=>new Map(Ve).set(Me,Ju(He.groups,We,Le).map(mC)))},e[63]=i,e[64]=m,e[65]=n.rowModel.folderAuthorityByOwner,e[66]=n.rowModel.folderDropTargets,e[67]=n.rowModel.rows,e[68]=n.sectionsForRender,e[69]=n.state,e[70]=r.hasSessionSearchQuery,e[71]=r.projectSortOrder,e[72]=ce):ce=e[72];let pe;e[73]!==I||e[74]!==n.rowModel||e[75]!==k||e[76]!==te||e[77]!==p?(pe=s.jsx(V2,{model:n.rowModel,scrollElement:p,pinnedRowIndexes:k,renderRow:te,onFirstVisibleIndexChange:I}),e[73]=I,e[74]=n.rowModel,e[75]=k,e[76]=te,e[77]=p,e[78]=pe):pe=e[78];let Y;e[79]!==ue||e[80]!==pe?(Y=s.jsx(Ua,{items:ue,strategy:Zu,children:pe}),e[79]=ue,e[80]=pe,e[81]=Y):Y=e[81];let ve;e[82]!==M||e[83]!==L||e[84]!==ce||e[85]!==Y?(ve=s.jsx(si,{sensors:M,collisionDetection:ni,onDragStart:L,onDragCancel:oe,onDragEnd:ce,children:Y}),e[82]=M,e[83]=L,e[84]=ce,e[85]=Y,e[86]=ve):ve=e[86];let Ee;e[87]!==Ne||e[88]!==ve?(Ee=s.jsx(bn,{ref:K,useScrollShadow:!0,hideTopScrollShadow:Ne,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:ve}),e[87]=Ne,e[88]=ve,e[89]=Ee):Ee=e[89];let je;e[90]!==S||e[91]!==Ee||e[92]!==r.stickyZoneHeaders||e[93]!==fe?(je=s.jsx(G2,{enabled:r.stickyZoneHeaders,suspended:S,layoutKey:fe,scrollRef:P,children:Ee}),e[90]=S,e[91]=Ee,e[92]=r.stickyZoneHeaders,e[93]=fe,e[94]=je):je=e[94];let ge;e[95]!==u||e[96]!==g?(ge=()=>{g&&(u(g.scopeKey,g.folderId),y(null))},e[95]=u,e[96]=g,e[97]=ge):ge=e[97];let be;e[98]!==g||e[99]!==ge?(be=s.jsx(rm,{value:g,setValue:y,onConfirm:ge}),e[98]=g,e[99]=ge,e[100]=be):be=e[100];let Q;return e[101]!==je||e[102]!==be?(Q=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[je,be]}),e[101]=je,e[102]=be,e[103]=Q):Q=e[103],Q}function mC(t){return t.id}function hC(t){return t.project.id}function pC(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function gC(t){return t.project.id}function bC(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function xC(){}function yC(t){return t.showDeletionDialog}function wC(t){return t.addSessionToFolder}function vC(t){return t.deleteFolder}function SC(t){return t.renameFolder}function jC(t){return t.toggleFolderCollapse}const kC=c.memo(fC),Sa=new Map,ad=(t,e)=>{for(const n of t){const r=gt(n??null);r&&!Sa.has(r)&&Sa.set(r,e)}},ld=t=>{const e=gt(t??null);return e?Sa.get(e)??0:0},Dr=t=>!!t.time?.archived,CC=t=>{const{t:e}=At(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const d=gt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),o=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),m=u.startsWith("ses_");return a.flatMap(f=>{if(m&&Dr(f.session))return[];if(m?f.session.id.toLowerCase()===u:Bo([i(f.session)],d))return[f];const y=o(f.children,d);return y.length===0?[]:[{...f,children:y}]})},[i]),l=c.useCallback((a,d,u,m,f)=>{const g=gt(d??null),y=Bu(a),b=new Map(y.map(v=>[v.id,v])),j=new Map;y.forEach(v=>{const I=v.parentID;if(!I)return;const H=b.get(I);if(!H||Dr(H)!==Dr(v))return;const $=j.get(I)??[];$.push(v),j.set(I,$)});const x=rb(u,g),h=(g&&!t.isVSCode?t.spacesByProject?.get(g):void 0)??[],p=new Map;for(const v of h){const I=gt(v.directory);I&&p.set(I,v)}const w=v=>{const I=gt(v.directory??null),H=t.worktreeMetadata.get(v.id)??null;if(H)return H;if(I){const $=x.get(I)??null;if($&&I!==g)return $}return null},S=new Set,N=v=>{S.add(v.id);const I=j.get(v.id)??[],H=[];for(const $ of I)S.has($.id)||H.push(N($));return{session:v,children:H,worktree:w(v)}},P=y.filter(v=>{const I=v.parentID;if(!I)return!0;const H=b.get(I);return H?Dr(H)!==Dr(v):!0}),C=[],T=v=>{S.has(v.id)||C.push(N(v))};P.forEach(T),y.forEach(T);const R=new Map,M="__archived__",F=v=>{if(v.time?.archived)return M;if(t.isVSCode||t.runKeyBySessionId?.has(v.id))return g??"__project_root__";const I=t.sessionOwners?.get(v.id)?.scopeDirectory;if(I){if(I===g)return g??"__project_root__";if(x.has(I)||p.has(I))return I}const $=gt(t.worktreeMetadata.get(v.id)?.path??null)??Is(v);return $&&$!==g&&x.has($)?$:g??"__project_root__"};C.forEach(v=>{const I=F(v.session);R.has(I)||R.set(I,[]),R.get(I)?.push(v)});const K=g??"__project_root__",D=[{id:"root",label:f&&m&&m!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:m}):e("sessions.sidebar.grouping.projectRoot"),branch:m??null,description:g?Hr(g,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:g,folderScopeKey:g,sessions:R.get(K)??[]}],U=new Map;u.forEach(v=>{const I=gt(v.path)??v.path,H=R.get(I)??[],$=H.length>0,re=H.reduce((te,ee)=>{const ue=ob(ee.session,t.sessionOrderRanks);return Number.isFinite(ue)?Math.max(te,ue):te},0);U.set(I,{hasActiveSession:$,lastUpdatedAt:re})});const A=(v,I)=>{const H=(v.label||v.branch||v.name||v.path||"").toLowerCase(),$=(I.label||I.branch||I.name||I.path||"").toLowerCase();return H.localeCompare($)},E=t.worktreeSortOrder!=="recent"?[...u].sort(A):[...u].sort((v,I)=>{const H=gt(v.path)??v.path,$=gt(I.path)??I.path,re=U.get(H)??{hasActiveSession:!1,lastUpdatedAt:0},te=U.get($)??{hasActiveSession:!1,lastUpdatedAt:0};if(re.hasActiveSession!==te.hasActiveSession)return re.hasActiveSession?-1:1;if(re.hasActiveSession&&te.hasActiveSession)return te.lastUpdatedAt-re.lastUpdatedAt;const ee=ld(v.path),ue=ld(I.path);return ee!==ue?ue-ee:A(v,I)});(t.isVSCode?[]:E).forEach(v=>{const I=gt(v.path)??v.path,H=n.current.get(I)?.trim()||null,$=v.branch?.trim()||null,te=!!(H&&$&&v.label&&Bl(v.label)===Bl($))?H:v.label||v.name||yr(I,t.homeDirectory)||I;D.push({id:`worktree:${I}`,label:te,branch:H||$,description:Hr(I,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:v,directory:I,folderScopeKey:I,sessions:R.get(I)??[]})});for(const[v,I]of p)D.push({id:`space:${I.id}`,label:I.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:I,directory:v,folderScopeKey:v,sessions:R.get(v)??[]});const k=R.get(M)??[];return k.length>0&&D.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&g?Mu(g):null,sessions:k}),D},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.worktreeSortOrder,t.sessionOwners,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},NC=t=>{const e=nt.c(60),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:m,onArchive:f,onDelete:g,onDone:y}=t,{t:b}=At(),j=n>0,x=j&&!!r&&!o;let h;e[0]!==n||e[1]!==b?(h=b("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[0]=n,e[1]=b,e[2]=h):h=e[2];let p;e[3]!==h?(p=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:h}),e[3]=h,e[4]=p):p=e[4];let w;e[5]!==x||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==b?(w=x?s.jsxs(js,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(B,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ss,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(_t,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):i.map($=>s.jsx(_t,{onClick:()=>l($.id),children:s.jsx("span",{className:"flex-1 truncate",children:$.name})},$.id)),s.jsx(hs,{}),s.jsxs(_t,{onClick:a,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(_t,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(B,{name:"close",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=x,e[6]=u,e[7]=a,e[8]=l,e[9]=d,e[10]=i,e[11]=b,e[12]=w):w=e[12];let S;e[13]!==o||e[14]!==j||e[15]!==m||e[16]!==b?(S=o?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,disabled:!j,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.restore"),children:s.jsx(B,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=o,e[14]=j,e[15]=m,e[16]=b,e[17]=S):S=e[17];let N;e[18]!==o||e[19]!==j||e[20]!==f||e[21]!==b?(N=o?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,disabled:!j,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.archive"),children:s.jsx(B,{name:"archive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=o,e[19]=j,e[20]=f,e[21]=b,e[22]=N):N=e[22];const P=!j;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=De("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50 disabled:pointer-events-none disabled:opacity-40"),e[23]=C):C=e[23];let T;e[24]!==b?(T=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=T):T=e[25];let R;e[26]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(B,{name:"delete-bin",className:"h-4 w-4"}),e[26]=R):R=e[26];let M;e[27]!==g||e[28]!==P||e[29]!==T?(M=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:g,disabled:P,className:C,"aria-label":T,children:R})}),e[27]=g,e[28]=P,e[29]=T,e[30]=M):M=e[30];let F;e[31]!==b?(F=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=F):F=e[32];let K;e[33]!==F?(K=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:F})}),e[33]=F,e[34]=K):K=e[34];let D;e[35]!==M||e[36]!==K?(D=s.jsxs(vt,{children:[M,K]}),e[35]=M,e[36]=K,e[37]=D):D=e[37];let U;e[38]!==b?(U=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=U):U=e[39];let A;e[40]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(B,{name:"close",className:"h-4 w-4"}),e[40]=A):A=e[40];let E;e[41]!==y||e[42]!==U?(E=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:y,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":U,children:A})}),e[41]=y,e[42]=U,e[43]=E):E=e[43];let W;e[44]!==b?(W=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=W):W=e[45];let k;e[46]!==W?(k=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W})}),e[46]=W,e[47]=k):k=e[47];let v;e[48]!==E||e[49]!==k?(v=s.jsxs(vt,{children:[E,k]}),e[48]=E,e[49]=k,e[50]=v):v=e[50];let I;e[51]!==D||e[52]!==v||e[53]!==w||e[54]!==S||e[55]!==N?(I=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[w,S,N,D,v]}),e[51]=D,e[52]=v,e[53]=w,e[54]=S,e[55]=N,e[56]=I):I=e[56];let H;return e[57]!==p||e[58]!==I?(H=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[p,I]}),e[57]=p,e[58]=I,e[59]=H):H=e[59],H},cd=new Map,AC=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},PC=(t,e)=>{const n=t.sessionIds.filter(o=>e.has(o));if(n.length===0)return{ready:!1,value:null};const r=t.archivedBucket||em(new Set(n),e),i={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},DC=t=>{const e=nt.c(89),{t:n}=At();let r;e[0]!==n?(r=le=>{const V=ib(le);return V?{description:eu(V,n)}:void 0},e[0]=n,e[1]=r):r=e[1];const i=r,{isInlineEditing:o,showDeletionDialog:l,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:m,createFolderAndStartRename:f,archiveSessions:g,unarchiveSessions:y,deleteSessions:b,bulkDeleteConfirm:j,setBulkDeleteConfirm:x}=t,h=es(IC),p=es(TC),w=p>0,S=es(EC),N=es(RC),P=Zf(),C=MC,T=OC;let R;e[2]!==w||e[3]!==P||e[4]!==S?(R=w&&em(S,P?.getSessionsById()??cd),e[2]=w,e[3]=P,e[4]=S,e[5]=R):R=e[5];const M=R;let F;e:{if(N){F=N;break e}F=null}const K=F;let D;e[6]!==K||e[7]!==d?(D=AC(K,d),e[6]=K,e[7]=d,e[8]=D):D=e[8];const U=D;let A;if(e[9]!==a||e[10]!==U){let le;e[12]!==a?(le=V=>a[V]??[],e[12]=a,e[13]=le):le=e[13],A=U.flatMap(le),e[9]=a,e[10]=U,e[11]=A}else A=e[11];const E=A;let W;e[14]!==a||e[15]!==U?(W=le=>{for(const V of U)if((a[V]??[]).some(Z=>Z.id===le))return V;return null},e[14]=a,e[15]=U,e[16]=W):W=e[16];const k=W;let v;e:{if(!w){v=!1;break e}for(const le of U)for(const V of a[le]??[])for(const Z of V.sessionIds)if(S.has(Z)){v=!0;break e}v=!1}const I=v;let H;e[17]!==u||e[18]!==m||e[19]!==S||e[20]!==U?(H=(le,V)=>{const Z=Array.from(S);for(const G of U)G!==le&&m(G,Z);u(le,V,Z)},e[17]=u,e[18]=m,e[19]=S,e[20]=U,e[21]=H):H=e[21];const $=H;let re;e[22]!==w||e[23]!==$||e[24]!==k?(re=le=>{if(!w)return;const V=k(le);V&&$(V,le)},e[22]=w,e[23]=$,e[24]=k,e[25]=re):re=e[25];const te=re;let ee;e[26]!==f||e[27]!==w||e[28]!==$||e[29]!==U?(ee=()=>{const le=U[0];if(!le||!w)return;const V=f(le);V&&$(le,V.id)},e[26]=f,e[27]=w,e[28]=$,e[29]=U,e[30]=ee):ee=e[30];const ue=ee;let de;e[31]!==w||e[32]!==m||e[33]!==S||e[34]!==U?(de=()=>{if(!w)return;const le=Array.from(S);for(const V of U)m(V,le)},e[31]=w,e[32]=m,e[33]=S,e[34]=U,e[35]=de):de=e[35];const Te=de;let we;e[36]!==g||e[37]!==b||e[38]!==i||e[39]!==n?(we=async(le,V)=>{if(le.length!==0)if(V){const{deletedIds:Z,failedIds:G}=await b(le);Z.length>0&&_e.success(Z.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:Z.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:Z.length})),G.length>0&&_e.error(G.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:G.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:G.length}),i(G)),es.getState().removeMany(Z)}else{const{archivedIds:Z,failedIds:G}=await g(le);Z.length>0&&_e.success(Z.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:Z.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:Z.length})),G.length>0&&_e.error(G.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:G.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:G.length}),i(G)),es.getState().removeMany(Z)}},e[36]=g,e[37]=b,e[38]=i,e[39]=n,e[40]=we):we=e[40];const fe=we;let Ne;e[41]!==fe||e[42]!==w||e[43]!==S||e[44]!==x||e[45]!==l?(Ne=le=>{if(!w)return;const V=Array.from(S);if(!l){fe(V,le);return}x({sessionIds:V,sessionCount:V.length,archivedBucket:le})},e[41]=fe,e[42]=w,e[43]=S,e[44]=x,e[45]=l,e[46]=Ne):Ne=e[46];const L=Ne;let oe;e[47]!==M||e[48]!==L?(oe=()=>L(M),e[47]=M,e[48]=L,e[49]=oe):oe=e[49];const ce=oe;let pe;e[50]!==L?(pe=()=>L(!1),e[50]=L,e[51]=pe):pe=e[51];const Y=pe;let ve;e[52]!==L?(ve=()=>L(!0),e[52]=L,e[53]=ve):ve=e[53];const Ee=ve;let je;e[54]!==M||e[55]!==i||e[56]!==w||e[57]!==S||e[58]!==n||e[59]!==y?(je=async()=>{if(!w||!M)return;const le=Array.from(S),{restoredIds:V,failedIds:Z}=await y(le);V.length>0&&_e.success(V.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:V.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:V.length})),Z.length>0&&_e.error(Z.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:Z.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:Z.length}),i(Z)),es.getState().removeMany(V)},e[54]=M,e[55]=i,e[56]=w,e[57]=S,e[58]=n,e[59]=y,e[60]=je):je=e[60];const ge=je;let be;e[61]!==j||e[62]!==fe||e[63]!==P||e[64]!==x?(be=async()=>{if(!j)return;const le=P?.getSessionsById()??cd,V=PC(j,le);if(!V.ready){x(V.value);return}x(null),await fe(V.value.sessionIds,V.value.archivedBucket)},e[61]=j,e[62]=fe,e[63]=P,e[64]=x,e[65]=be):be=e[65];const Q=be;let _,J;e[66]!==j||e[67]!==ce||e[68]!==o||e[69]!==P||e[70]!==h?(_=()=>{if(!h)return;const le=/Macintosh|Mac OS X/.test(navigator.userAgent||""),V=Z=>{if(j||o)return;const G=Z.target instanceof HTMLElement?Z.target:null;if(G&&(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.isContentEditable))return;const ie=le?Z.metaKey:Z.ctrlKey;if(Z.key==="Escape"){Z.preventDefault(),es.getState().disable();return}if(ie&&Z.key==="Backspace"){Z.preventDefault(),ce();return}if(ie&&(Z.key==="a"||Z.key==="A")){const Se=Yk(P?.getEntries()??[],P?.getDescendantIds()??[],es.getState().scopeKey);if(!Se)return;Z.preventDefault(),es.getState().replaceAll(Se.ids,Se.scopeKey)}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},J=[j,ce,o,P,h],e[66]=j,e[67]=ce,e[68]=o,e[69]=P,e[70]=h,e[71]=_,e[72]=J):(_=e[71],J=e[72]),c.useEffect(_,J);let me;return e[73]!==I||e[74]!==E||e[75]!==M||e[76]!==Q||e[77]!==K||e[78]!==Y||e[79]!==ue||e[80]!==ce||e[81]!==Ee||e[82]!==te||e[83]!==Te||e[84]!==ge||e[85]!==w||e[86]!==p||e[87]!==h?(me={selectionModeEnabled:h,hasSelection:w,selectedIdsSize:p,bulkScopeIsArchived:M,derivedSelectionScope:K,bulkScopeFolders:E,bulkCanRemoveFromFolder:I,handleToggleSelectionMode:C,handleExitSelectionMode:T,handleBulkMoveToFolder:te,handleBulkCreateFolderAndMove:ue,handleBulkRemoveFromFolder:Te,handleBulkDelete:ce,handleBulkArchive:Y,handleBulkHardDelete:Ee,handleBulkRestore:ge,confirmBulkDelete:Q},e[73]=I,e[74]=E,e[75]=M,e[76]=Q,e[77]=K,e[78]=Y,e[79]=ue,e[80]=ce,e[81]=Ee,e[82]=te,e[83]=Te,e[84]=ge,e[85]=w,e[86]=p,e[87]=h,e[88]=me):me=e[88],me};function IC(t){return t.enabled}function TC(t){return t.selectedIds.size}function EC(t){return t.selectedIds}function RC(t){return t.scopeKey}function MC(){es.getState().toggleMode()}function OC(){es.getState().disable()}function BC(t){const e=nt.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=ye(UC),d=ye(VC),u=Gt(KC),m=Gt(WC),f=Gt(zC),g=Gt($C),y=ot(_C),b=ot(LC),j=ot(FC);let x;e[0]!==m||e[1]!==i?(x=P=>{const C=m(P,"New folder");return i(P,C),C},e[0]=m,e[1]=i,e[2]=x):x=e[2];let h;e[3]!==f||e[4]!==y||e[5]!==o||e[6]!==j||e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==g||e[11]!==a||e[12]!==x||e[13]!==b?(h={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:g,createFolderAndStartRename:x,archiveSessions:y,unarchiveSessions:b,deleteSessions:j,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=f,e[4]=y,e[5]=o,e[6]=j,e[7]=u,e[8]=n,e[9]=r,e[10]=g,e[11]=a,e[12]=x,e[13]=b,e[14]=h):h=e[14];const p=DC(h);let w;e[15]!==p.bulkCanRemoveFromFolder||e[16]!==p.bulkScopeFolders||e[17]!==p.bulkScopeIsArchived||e[18]!==p.derivedSelectionScope||e[19]!==p.handleBulkArchive||e[20]!==p.handleBulkCreateFolderAndMove||e[21]!==p.handleBulkHardDelete||e[22]!==p.handleBulkMoveToFolder||e[23]!==p.handleBulkRemoveFromFolder||e[24]!==p.handleBulkRestore||e[25]!==p.handleExitSelectionMode||e[26]!==p.selectedIdsSize||e[27]!==p.selectionModeEnabled?(w=p.selectionModeEnabled?s.jsx(NC,{selectedCount:p.selectedIdsSize,scopeKey:p.derivedSelectionScope,scopeFolders:p.bulkScopeFolders,archivedBucket:p.bulkScopeIsArchived,onMoveToFolder:p.handleBulkMoveToFolder,onCreateFolderAndMove:p.handleBulkCreateFolderAndMove,onRemoveFromFolder:p.handleBulkRemoveFromFolder,canRemoveFromFolder:p.bulkCanRemoveFromFolder,onRestore:p.handleBulkRestore,onArchive:p.handleBulkArchive,onDelete:p.handleBulkHardDelete,onDone:p.handleExitSelectionMode}):null,e[15]=p.bulkCanRemoveFromFolder,e[16]=p.bulkScopeFolders,e[17]=p.bulkScopeIsArchived,e[18]=p.derivedSelectionScope,e[19]=p.handleBulkArchive,e[20]=p.handleBulkCreateFolderAndMove,e[21]=p.handleBulkHardDelete,e[22]=p.handleBulkMoveToFolder,e[23]=p.handleBulkRemoveFromFolder,e[24]=p.handleBulkRestore,e[25]=p.handleExitSelectionMode,e[26]=p.selectedIdsSize,e[27]=p.selectionModeEnabled,e[28]=w):w=e[28];let S;e[29]!==p.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(S=s.jsx(A2,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:p.confirmBulkDelete}),e[29]=p.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=S):S=e[33];let N;return e[34]!==w||e[35]!==S?(N=s.jsxs(s.Fragment,{children:[w,S]}),e[34]=w,e[35]=S,e[36]=N):N=e[36],N}function FC(t){return t.deleteSessions}function LC(t){return t.unarchiveSessions}function _C(t){return t.archiveSessions}function $C(t){return t.removeSessionsFromFolders}function zC(t){return t.addSessionsToFolder}function WC(t){return t.createFolder}function KC(t){return t.foldersMap}function VC(t){return t.setShowDeletionDialog}function UC(t){return t.showDeletionDialog}const am="oc.sessions.expandedParents.v3",HC=Ha(Hn()),GC=()=>{try{const t=globalThis.localStorage.getItem(am);if(t===null)return new Set;const e=HC.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},qC=()=>{const[t,e]=c.useState(GC),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=ab(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(am,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},YC=t=>{const e=nt.c(22),{childStores:n,sections:r,chatGroup:i,canGrantAccess:o}=t,l=ps(QC),a=ps(XC);let d;e[0]!==i||e[1]!==r?(d=[...r.flatMap(JC),...i?[{key:"activity:chats",group:i}]:[]].map(t4),e[0]=i,e[1]=r,e[2]=d):d=e[2];const u=d;let m;e[3]!==u?(m=new Set(u.flatMap(s4)),e[3]=u,e[4]=m):m=e[4];let f;e[5]!==m?(f=[...m],e[5]=m,e[6]=f):f=e[6];const g=f;let y;e[7]!==n||e[8]!==g.length?(y=w=>g.length>0?n.subscribeBootstrap(w):n4,e[7]=n,e[8]=g.length,e[9]=y):y=e[9];let b;e[10]!==n||e[11]!==g?(b=()=>g.map(w=>`${w}\0${n.getBootstrapState(w)??""}\0${n.getBootstrapFailure(w)??""}\0${n.getInitializationState(w)??""}\0${n.getInitializationFailure(w)??""}`).join(""),e[10]=n,e[11]=g,e[12]=b):b=e[12];const j=c.useSyncExternalStore(y,b,r4);let x;if(e[13]!==o||e[14]!==n||e[15]!==l||e[16]!==u||e[17]!==a){x=new Map;for(const{key:w,archived:S,directories:N}of u){const P=N.find(C=>n.getBootstrapState(C)==="failed"||n.getInitializationState(C)==="failed");if(P){const C=n.getBootstrapState(P)==="failed",T=C?n.getBootstrapFailure(P):n.getInitializationFailure(P);x.set(w,{state:T==="os-permission"?"permission-denied":C?"load-failed":"initialization-failed",directory:P,canGrantAccess:T==="os-permission"&&o})}else{const C=a||!S&&N.length>0&&N.every(T=>n.getBootstrapState(T)==="complete");x.set(w,{state:C?"ready":l==="error"?"load-failed":"loading",directory:C?N[0]??null:null,canGrantAccess:!1})}}e[13]=o,e[14]=n,e[15]=l,e[16]=u,e[17]=a,e[18]=x}else x=e[18];const h=x;let p;return e[19]!==j||e[20]!==h?(p={groupStatusByKey:h,bootstrapSnapshot:j},e[19]=j,e[20]=h,e[21]=p):p=e[21],p};function QC(t){return t.status}function XC(t){return t.hasLoaded}function JC(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function ZC(t){return gt(t.directory)}function e4(t){return!!t}function t4(t){const{key:e,group:n}=t;return{key:e,archived:n.isArchivedBucket===!0,directories:Gr(n).map(ZC).filter(e4)}}function s4(t){return t.directories}function n4(){}function r4(){return""}const o4=5*6e4,i4=[],dd=[],ud=[],a4=t=>!t.parentID,l4=({topology:t,view:e,actions:n})=>{const{alwaysShowActions:r,notifyOnSubtasks:i,projectViewActions:o,rowActions:l,...a}=n,d=Gt(Oe=>Oe.foldersMap),u=Gt(Oe=>Oe.collapsedFolderIds),m=Gt(Oe=>Oe.createFolder),f=Gt(Oe=>Oe.addSessionToFolder),g=e.projectView,{getOrderedGroups:y,setGroupOrderByProject:b,toggleGroup:j,toggleProject:x}=o,h=Yh({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),p=lb(Oe=>Oe.projects),w=ch(),S=c.useMemo(()=>new Map(w.map(Oe=>[Oe.id,Oe.name])),[w]),N=c.useMemo(()=>{const Oe=new Map;for(const Re of w){const Be=gt(Re.projectDirectory);if(!Be)continue;const Ke=Oe.get(Be);Ke?Ke.push(Re):Oe.set(Be,[Re])}return Oe},[w]),P=c.useMemo(()=>Qh(h.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,h.archivedSessions,p,w),[p,h.archivedSessions,h.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[C,T]=c.useState(new Map),[R,M]=c.useState(new Set),[F,K]=c.useState(new Map),D=c.useCallback((Oe,Re,Be=7)=>{T(Ke=>new Map(Ke).set(Oe,Re+Be))},[]),U=c.useCallback(Oe=>{T(Re=>{if(!Re.has(Oe))return Re;const Be=new Map(Re);return Be.delete(Oe),Be})},[]),A=is(Oe=>Oe.showRecentSection),E=is(Oe=>Oe.projectDisplayMode),W=is(Oe=>Oe.singleProjectId),k=is(Oe=>Oe.setSingleProjectId),I=!t.isVSCode&&!dh()&&E==="single",H=e.sidebarViewMode==="timeline"&&!t.isVSCode,$=Xh({enabled:A&&!I&&!H,isVSCode:t.isVSCode,pinnedSessionIds:h.pinnedSessionIds,sessionOrderRanks:h.sessionOrderRanks,sessions:h.rootSessions}),re=c.useMemo(()=>cb(h.rootSessions,Oe=>gt(t.worktreeMetadata.get(Oe.id)?.projectDirectory??Oe.directory??null)),[h.rootSessions,t.worktreeMetadata]),te=c.useRef(null),ee=c.useMemo(()=>{const Oe=Array.from(re.runKeyBySessionId,([Re,Be])=>`${Re}\0${Be}`).sort().join("");return te.current?.signature!==Oe&&(te.current={signature:Oe,map:re.runKeyBySessionId}),te.current.map},[re]),[ue,de]=c.useState(null),[Te,we]=c.useState(null),[fe,Ne]=c.useState(""),[L,oe]=c.useState(null),[ce,pe]=c.useState(null),[Y,ve]=c.useState(null),Ee=c.useCallback((Oe,Re)=>{ve({scopeKey:Oe,folderId:Re.id,draft:Re.name})},[]),je=c.useCallback(Oe=>{ve(Re=>Re?{...Re,draft:Oe}:null)},[]),ge=c.useCallback(()=>ve(null),[]),{expandedParents:be,toggleParent:Q}=qC(),_=ot(Oe=>Oe.setCurrentSession),J=c.useCallback((Oe,Re)=>{Oe!==ot.getState().currentSessionId&&_(Oe,Re)},[_]),me=$u(),le=is(Oe=>Oe.worktreeSortOrder),{buildGroupedSessions:V,filterSessionNodesForSearch:Z,buildGroupSearchText:G}=CC({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:h.pinnedSessionIds,sessionOrderRanks:h.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:le,sessionOwners:P.bySessionId,spacesByProject:N,runKeyBySessionId:ee}),{getSessionsForProject:ie,getArchivedSessionsForProject:Se}=ak({ownership:P}),se=c.useMemo(()=>{if(t.isVSCode)return null;const Oe=db(e.homeDirectory)??h.chatSessions.map(Be=>La(Be.directory)).find(Boolean)??null;if(!Oe)return null;const Re=Array.from(new Set([Oe,...h.chatSessions.map(Be=>gt(Be.directory??null)).filter(Boolean)])).filter(Be=>!!Be).map(Be=>({scopeKey:Be,directory:Be}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Oe,folderScopeKey:Oe,folderScopes:Re,draftTarget:"chat",sessions:h.chatSessions.filter(Be=>!Be.time?.archived&&a4(Be)).map(Be=>ir(h.childrenMap,Be))}},[h.chatSessions,h.childrenMap,t.isVSCode,e.homeDirectory]),Me=c.useMemo(()=>se?[se]:i4,[se]),{projectSections:He,groupSearchDataByGroup:We,sectionsForRender:Le,flatSectionsForRender:Ve}=Nk({normalizedProjects:t.projects,getSessionsForProject:ie,getArchivedSessionsForProject:Se,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:V,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:Z,buildGroupSearchText:G,foldersMap:d,standaloneGroups:Me}),O=e.onSearchMatchCountChange;c.useEffect(()=>()=>O(0),[O]);const he=Xo(),$e=e.useGroupedSections?Le:Ve,Ue=c.useMemo(()=>e.showInlineArchived?$e:$e.map(Oe=>Oe.groups.some(Re=>Re.isArchivedBucket)?{...Oe,groups:Oe.groups.filter(Re=>!Re.isArchivedBucket)}:Oe),[$e,e.showInlineArchived]),ct=c.useCallback(Oe=>Ve.find(Be=>Be.project.id===Oe)?.groups.find(Be=>!Be.isArchivedBucket)?.folderScopes??[],[Ve]);ek({enabled:!0,normalizedProjects:t.projects,ownership:P,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:h.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:m,addSessionToFolder:f});const{github:pt}=gn(),it=pn(Oe=>Oe.status),ft=pn(Oe=>Oe.hasChecked),yt=Ps(Oe=>Oe.ensureEntry),ht=Ps(Oe=>Oe.setParams),bt=Ps(Oe=>Oe.refreshTargets),Dt=c.useRef(new Set);c.useEffect(()=>{if(!pt||!ft||!it?.connected)return;const Oe=new Map,Re=Date.now();He.forEach(Be=>{g.collapsedProjects.has(Be.project.id)||Be.groups.forEach(Ke=>{if(Ke.isArchivedBucket||Ke.isMain)return;const rt=gt(Ke.directory??null),xt=Ke.branch?.trim()||t.gitBranches.get(rt||"")?.trim();if(!rt||!xt)return;const Pe=Yo(rt,xt),ze=Ps.getState().entries[Pe],st=ze?.status?.pr?.state==="closed"||ze?.status?.pr?.state==="merged",at=`${rt}::${xt}`,Ct=Math.max(ze?.lastRefreshAt??0,ze?.lastDiscoveryPollAt??0),Ot=!!(ze?.isInitialStatusResolved&&(!ze.status?.pr||st)&&(!Dt.current.has(at)||Re-Ct>=o4));(!ze||!ze.isInitialStatusResolved||Ot)&&(Ot&&Dt.current.add(at),Oe.set(Pe,{directory:rt,branch:xt}))})}),Oe.forEach((Be,Ke)=>{yt(Ke),ht(Ke,{...Be,remoteName:null,canShow:!0,github:pt,githubAuthChecked:ft,githubConnected:it.connected})}),Oe.size&&bt([...Oe.values()],{silent:!0,markInitialResolved:!0})},[yt,pt,ft,it?.connected,He,g.collapsedProjects,bt,ht,t.gitBranches]);const xe=c.useMemo(()=>new Map(h.orderedSessions.map((Oe,Re)=>[Oe.id,Re])),[h.orderedSessions]),Ye=c.useMemo(()=>le!=="manual"?Ue:Ue.map(Oe=>{const Re=y(Oe.project.id,Oe.groups);return Re===Oe.groups?Oe:{...Oe,groups:Re}}),[y,Ue,le]),Xe=c.useMemo(()=>{const Oe=new Map($.map(rt=>[rt.id,ir(h.childrenMap,rt)])),Re=[...Oe.values()],Be=[];for(;Re.length>0;){const rt=Re.pop();if(!rt)break;Be.push(rt.session),Re.push(...rt.children)}const Ke=yi({sessions:Be,projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,hideBranchMatchingProjectLabel:!0});return Jh({sessions:$,getSessionLocation:rt=>Ke.get(rt)??null,getSessionNode:rt=>Oe.get(rt.id)??ir(h.childrenMap,rt),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[h.childrenMap,P.bySessionId,$,S,t.availableWorktreesByProject,t.gitBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),qe=c.useMemo(()=>{if(!H)return dd;const Oe=new Set(h.rootSessions.map(Ke=>Ke.id)),Re=h.orderedSessions.filter(Ke=>Oe.has(Ke.id)&&!Ke.time?.archived),Be=yi({sessions:Re,projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return kl({sessions:Re,getSessionLocation:Ke=>Be.get(Ke)??null,getSessionNode:Ke=>({...ir(h.childrenMap,Ke),children:[],worktree:Be.get(Ke.id)?.worktree??null}),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[h.childrenMap,h.orderedSessions,h.rootSessions,P.bySessionId,S,H,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),dt=ye(Oe=>Oe.sessionWorkEnabled),X=c.useMemo(()=>{if(!dt)return ud;const Oe=h.orderedSessions.filter(Re=>!Re.parentID&&!Re.time?.archived&&!_a(Re.directory)&&Wu(Re));return Oe.length>0?Oe:ud},[h.orderedSessions,dt]),ae=c.useMemo(()=>new Set(X.map(Oe=>Oe.id)),[X]),Ae=c.useMemo(()=>{if(X.length===0)return dd;const Oe=yi({sessions:[...X],projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!H}),Re=new Map(X.map(rt=>{const xt=ir(h.childrenMap,rt),Pe={...xt,children:H?[]:xt.children,worktree:Oe.get(rt.id)?.worktree??null};return[rt.id,Pe]})),Be=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",Ke=Be?X.filter(rt=>{const xt=Re.get(rt.id);return xt?Zh(xt,Be):!1}):[...X];return kl({sessions:Ke,getSessionLocation:rt=>Oe.get(rt)??null,getSessionNode:rt=>Re.get(rt.id)??ir(h.childrenMap,rt),query:""})},[h.childrenMap,P.bySessionId,S,H,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery,X]),{groupStatusByKey:Ge,bootstrapSnapshot:q}=YC({childStores:he,sections:Ye,chatGroup:se,canGrantAccess:Vd()});let Fe=null;I&&(He.some(Oe=>Oe.project.id===W)?Fe=W:He.some(Oe=>Oe.project.id===e.activeProjectId)?Fe=e.activeProjectId:Fe=He[0]?.project.id??null);const Ze=c.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:We,collapsedGroups:g.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:i,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:xe,expandedParents:be,editingId:ue,editingRowKey:Te,editTitle:fe,sessionBatchSize:I&&!e.useGroupedSections?20:void 0,setEditingId:de,setEditingRowKey:we,setEditTitle:Ne,toggleParent:Q,allowReselect:l.allowReselect,onSessionSelected:l.onSessionSelected,resetSessionSearch:l.resetSessionSearch,deleteSessionConfirm:ce,setDeleteSessionConfirm:pe,startFolderRename:Ee,startSessionWorktreeMenuLoad:n.startSessionWorktreeMenuLoad,onEditProject:H?a.openProjectEditDialog:void 0,folderRename:Y,setFolderRenameDraft:je,clearFolderRename:ge}),[h.pinnedSessionIds,r,i,g.collapsedGroups,We,xe,fe,ue,Te,be,Y,je,ge,Ee,ce,n.startSessionWorktreeMenuLoad,a.openProjectEditDialog,H,l,Q,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,I]),Je=c.useMemo(()=>({showMoreGroupSessions:D,resetGroupSessionLimit:U,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:j}),[U,D,j,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),et=c.useMemo(()=>{const Oe=new Map;for(const Re of Ye)for(const Be of Re.groups){const Ke=kn(Re.project.id,Be.directory);if(!Ke)continue;const rt=Gr(Be),xt=Oe.get(Ke),Pe=[...new Set([...xt?.scopeKeys??[],...rt.map(st=>st.scopeKey)])],ze=h.hasAuthoritativeGlobalSessions&&rt.every(st=>{const at=gt(st.directory);return!at||he.getBootstrapState(at)==="complete"});Oe.set(Ke,{scopeKeys:Pe,complete:(xt?.complete??!0)&&ze})}if(se){const Re=kn(null,se.directory);Re&&Oe.set(Re,{scopeKeys:Gr(se).map(Be=>Be.scopeKey),complete:h.hasAuthoritativeGlobalSessions})}return Oe},[q,se,he,h.hasAuthoritativeGlobalSessions,Ye]),kt=c.useMemo(()=>new Map([...C,...F]),[F,C]),Qe=c.useMemo(()=>jk({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:H?"timeline":"projects",sections:Ye,authoritativeSections:He,chatGroup:se,recentSections:Xe,timelineItems:qe,workItems:Ae,workSessionIds:ae,showRecentSection:A&&!I&&!H,foldersMap:d,groupSearchDataByGroup:We,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:g.collapsedProjects,collapsedGroups:g.collapsedGroups,collapsedFolders:u,collapsedActivities:R,expandedParents:be,visibleCountByContainer:kt,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:xe,groupStatusByKey:Ge,folderAuthorityByOwner:et,activeProjectId:e.activeProjectId,singleProjectMode:I&&!H,singleProjectId:Fe,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:I&&!e.useGroupedSections?20:void 0,runIndex:re}),[re,se,R,qe,H,Ae,ae,u,h.pinnedSessionIds,be,et,d,We,Ge,Ye,He,g.collapsedGroups,g.collapsedProjects,Xe,Fe,xe,A,I,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,kt]);c.useEffect(()=>{O(Qe.searchMatchCount)},[O,Qe.searchMatchCount]);const It=c.useMemo(()=>({rowModel:Qe,sectionsForRender:Ye,projectSections:He,singleProjectMode:I,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:ue,openSidebarMenuKey:L,setOpenSidebarMenuKey:oe,visibleSessionCountByGroup:C,collapsedActivityKeys:R,setCollapsedActivityKeys:M,visibleActivityCountByKey:F,setVisibleActivityCountByKey:K},groupProps:Ze}),[Ze,ue,L,He,Ye,Qe,t.projectRepoStatus,e.emptyState,e.searchEmptyState,C,F,R,I]),Mt=c.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,stickyZoneHeaders:e.stickyZoneHeaders,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:le,timelineView:H}),[H,le,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder,e.stickyZoneHeaders]),ke=c.useMemo(()=>({group:Je,toggleProject:x,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,openNewWorktreeDialog:a.openNewWorktreeDialog,openWorktreesPage:a.openWorktreesPage,openProjectEditDialog:a.openProjectEditDialog,removeProject:a.removeProject,reorderProjects:a.reorderProjects,setGroupOrderByProject:b,renderProjectStatusIndicator:a.renderProjectStatusIndicator,setSingleProjectId:k}),[Je,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,b,x,a.renderProjectStatusIndicator,k]);return s.jsxs(s.Fragment,{children:[s.jsx(Q0,{}),s.jsx(rk,{projectSections:He,activeProjectId:e.activeProjectId,initialActiveSessionByProject:n.initialActiveSessionByProject,persistActiveSessionByProject:n.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:n.openNewSessionDraft,setSessionSwitcherOpen:n.setSessionSwitcherOpen,sessionOwnerBySessionId:P.bySessionId,handleSessionSelect:J}),s.jsx(Ek,{sortedSessions:h.orderedSessions,recentSessions:$,prefetchSession:me}),s.jsxs(qk,{entries:Qe.selectionEntries,descendantIds:Qe.selectionDescendantIds,sessionsById:Qe.sessionById,children:[s.jsx(BC,{getFolderScopesForProject:ct,isInlineEditing:ue!==null,startFolderRename:Ee}),s.jsx(kC,{model:It,view:Mt,actions:ke})]})]})},c4=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(l4,{...t}):null,e[0]=t,e[1]=n):n=e[1],n},lm=(t,e,n)=>{const r=new Set;for(const i of t){const o=gt(i.path);o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=gt(o.path);l&&r.add(l)}return r},fd="oc.sessions.activeSessionByProject",d4=[],u4=of(Hn(),Hn().min(1).catch("")),f4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{Li("react.session_sidebar_render"),ys("ui.session_sidebar.render"),ys(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),ys(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=At(),[a,d]=c.useState(!1),[u,m]=c.useState(""),f=c.useCallback(()=>{m(""),d(!1)},[]),[g,y]=c.useState(0),b=c.useRef(null),j=c.useRef(null),[x,h]=c.useState(null),p=c.useMemo(()=>Oo(),[]),[w,S]=c.useState(new Map),N=ye(ke=>ke.isNewWorktreeDialogOpen),P=ye(ke=>ke.setNewWorktreeDialogOpen),[C,T]=c.useState(!1),R=c.useMemo(()=>{try{const ke=p.getItem(fd);if(!ke)return new Map;const Oe=u4.safeParse(JSON.parse(ke));if(!Oe.success)return new Map;const Re=new Map;return Object.entries(Oe.data).forEach(([Be,Ke])=>{Ke&&Re.set(Be,Ke)}),Re}catch{return new Map}},[p]),M=c.useCallback(ke=>{try{p.setItem(fd,JSON.stringify(Object.fromEntries(ke.entries())))}catch{}},[p]),[F,K]=c.useState(new Map),D=Zt(ke=>ke.homeDirectory),U=zt(ke=>ke.projects),A=zt(ke=>ke.activeProjectId),E=zt(ke=>ke.removeProject),W=zt(ke=>ke.setActiveProjectIdOnly),k=zt(ke=>ke.updateProjectMeta),v=zt(ke=>ke.reorderProjects),I=ye(ke=>ke.setSettingsDialogOpen),H=ye(ke=>ke.toggleHelpDialog),$=ye(ke=>ke.setAboutDialogOpen),re=ye(ke=>ke.setSessionSwitcherOpen),te=ye(ke=>ke.setScheduledTasksDialogOpen),ee=ye(ke=>ke.setArchivePageOpen),ue=ye(ke=>ke.setUsageStatsPageOpen),de=ye(ke=>ke.setWorktreesPageProjectId),Te=ye(ke=>ke.notifyOnSubtasks),we=c.useMemo(()=>u.trim().toLowerCase(),[u]),fe=we.length>0;y0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:j,sessionSearchContainerRef:b});const Ne=Iu(t),L=c.useMemo(()=>An(),[]),oe=ot(ke=>ke.setCurrentSession),ce=ot(ke=>ke.worktreeMetadata),pe=ot(ke=>ke.availableWorktreesByProject),Y=ot(ke=>ke.openNewSessionDraft),ve=c.useMemo(()=>lm(U,pe,{includeWorktrees:!L}),[pe,L,U]),Ee=c.useCallback(ke=>{ye.getState().closeMainSurfaces(),Y(ke),L&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[L,Y]),je=Fr(Un(ke=>({checkForUpdates:ke.checkForUpdates,available:ke.available,runtimeType:ke.runtimeType,info:ke.info,downloading:ke.downloading,downloaded:ke.downloaded,progress:ke.progress,error:ke.error,downloadUpdate:ke.downloadUpdate,restartToUpdate:ke.restartToUpdate}))),ge=qt(),be=c.useMemo(()=>`${ge}|${U.map(ke=>`${ke.id}:${gt(ke.path)??""}`).join("|")}`,[U,ge]),[Q,_]=c.useState(L?be:null),[J,me]=c.useReducer(ke=>ke+1,0),le=!L&&Q!==be,[V,Z]=c.useState(new Set),G=c.useRef(V);G.current=V;const ie=Wt(ke=>ke.isConnected),Se=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let ke=!1;return(async()=>{const Re=ge,Be=Wt.getState().isConnected,Ke=zt.getState().projects;if(ot.setState({worktreeDiscoveryByProject:new Map(Ke.map(Rt=>[gt(Rt.path)??Rt.path,"loading"]))}),Ke.length===0||L){ke||(Se.current={runtimeKey:null,revision:0,worktreesByProject:new Map},Z(new Set),_(be));return}const rt=ot.getState().availableWorktreesByProject,xt=nl({rawWorktreesByProjectRef:Se,publishedWorktreesByProject:rt,runtimeKey:Re}),Pe=xt.revision,ze=new Map(xt.worktreesByProject),st=new Set,at=3;let Ct=0;const Ot=Array.from({length:at},async()=>{for(;;){const Rt=Ct;if(Ct+=1,Rt>=Ke.length)return;const Vt=Ke[Rt],$t=gt(Vt.path);if($t)try{const Xt=await Gi(async()=>Xn.getState().directories.get($t)?.isGitRepo??await uu($t)?_l({id:Vt.id,path:$t}):null);if(Xt===null){ze.delete($t);continue}if(ke)return;Xt.length===0?ze.delete($t):ze.set($t,Xt)}catch{st.add($t)}}});if(await Promise.all(Ot),ke||qt()!==Re)return;const Lt=new Set(Ke.map(Rt=>gt(Rt.path)).filter(Boolean));for(const Rt of ze.keys())Lt.has(Rt)||ze.delete(Rt);u2({rawWorktreesByProjectRef:Se,runtimeKey:Re,capturedRevision:Pe,nextRawWorktreesByProject:ze,publishedWorktreesByProject:rt,partitionWorktreesByRegisteredProject:Ll,projects:Ke,worktreeMapsEqual:Fl,recordWorktreesSeen:ad,publishTopology:Rt=>{ot.setState(Rt)},requestRediscovery:()=>{me()},now:()=>Date.now()})&&(Z(st),ot.setState({worktreeDiscoveryByProject:new Map(Ke.map(Rt=>{const Vt=gt(Rt.path)??Rt.path;return[Vt,st.has(Vt)?"error":"ready"]}))}),_(be),st.size>0&&!Be&&Wt.getState().isConnected&&me())})(),()=>{ke=!0}},[L,be,ge,J]),c.useEffect(()=>{ie&&G.current.size>0&&me()},[ie]);const se=c.useMemo(()=>mn(),[]),{isTablet:Me}=Pn(),He=e||Me,We=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),Le=c.useMemo(()=>U.find(ke=>ke.id===x)??null,[U,x]),Ve=c.useCallback(ke=>{x&&k(x,{label:ke.label,icon:ke.icon,color:ke.color,iconBackground:ke.iconBackground,defaultAgent:ke.defaultAgent??null,defaultModel:ke.defaultModel??null,defaultVariant:ke.defaultVariant??null})},[x,k]),O=c.useCallback(()=>{P(!0)},[P]),he=c.useCallback(()=>{const ke=Fr.getState();if(ke.available&&ke.info){T(!0);return}je.checkForUpdates().then(()=>{const{available:Oe,error:Re}=Fr.getState();if(Re){_e.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:Re});return}if(!Oe){_e.success(l("sessions.sidebar.updateCheck.latestVersion"));return}T(!0)})},[l,je]),$e=c.useCallback(()=>{e&&re(!1),I(!0)},[e,re,I]),Ue=je.available&&(je.runtimeType==="desktop"||je.runtimeType==="web"),ct=c.useCallback(()=>{Us.requestDirectoryDialog()},[]),pt=c.useMemo(()=>U.flatMap(ke=>{const Oe=gt(ke.path);return Oe?[{id:ke.id,path:ke.path,label:ke.label,normalizedPath:Oe,icon:ke.icon??void 0,color:ke.color??void 0,iconImage:ke.iconImage??void 0,iconBackground:ke.iconBackground??void 0,addedAt:ke.addedAt,lastOpenedAt:ke.lastOpenedAt,sidebarCollapsed:ke.sidebarCollapsed}]:[]}),[U]),it=c.useMemo(()=>pt.map(ke=>ke.normalizedPath),[pt]),ft=ub(t?it:d4);A0({enabled:t,normalizedProjects:pt,gitRepoStatus:ft,setProjectRepoStatus:S,setProjectRootBranches:K});const yt=ot(ke=>ke.isLoading),ht=c.useRef(!1);A&&w.has(A)&&(ht.current=!!w.get(A));const bt=is(ke=>ke.showArchivedSessions),Dt=is(ke=>ke.projectSortOrder),xe=is(ke=>ke.sidebarViewMode),Ye=zt(ke=>ke.manualProjectOrder),Xe={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:Me,projects:U,activeProjectId:A,manualProjectOrder:Ye,worktreeMetadata:ce,availableWorktreesByProject:pe,gitBranches:Ne,gitRepoStatus:ft,updateStore:je,showArchivedSessions:bt,projectSortOrder:Dt,projectRepoStatus:w,projectRootBranches:F,resolvedWorktreeTopologyKey:Q,unresolvedWorktreeProjectPaths:V,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:x,updateDialogOpen:C},qe=c.useRef(null),dt=qe.current;if(dt){let ke=!1;for(const Oe of Object.keys(Xe))Object.is(dt[Oe],Xe[Oe])||(ys(`ui.session_sidebar.source.${Oe}`),ke=!0);ke||ys("ui.session_sidebar.source.parent_or_context")}qe.current=Xe;const X=c.useMemo(()=>ep(pt,Dt,Ye),[pt,Dt,Ye]),ae=j0({isVSCode:L,projects:X}),Ae=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),Ge=L&&bt,q=!L,Fe=L?"projects":xe,Ze=Fe==="projects",kt=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed",Qe="h-4.5 w-4.5",It=c.useMemo(()=>({projects:U,getCurrentProjects:()=>zt.getState().projects,rawWorktreesByProjectRef:Se,getPublishedWorktreesByProject:()=>ot.getState().availableWorktreesByProject,resolveProject:ke=>Ki(ke),listProjectWorktrees:_l,partitionWorktreesByRegisteredProject:Ll,worktreeMapsEqual:Fl,recordWorktreesSeen:ad,publishTopology:ke=>{ot.setState(ke)},getRuntimeKey:qt,now:()=>Date.now()}),[U]),Mt=c.useCallback(ke=>{const Oe=nm(ke,{projects:U,resolveProject:Ki});return d2(ke,{...It,projectRootBranch:Oe?F.get(Oe.id)??null:null})},[F,U,It]);return c.useEffect(()=>{if(!L)return Dn(ke=>{if(ke.type==="session-created"){me();return}if(ke.type==="worktree-changed")for(const Oe of fb(ke.directories)){const Re=gt(Oe.path),Be=qt(),Ke=rt=>{!Re||qt()!==Be||ot.setState(xt=>({worktreeDiscoveryByProject:new Map(xt.worktreeDiscoveryByProject).set(Re,rt)}))};Ke("loading"),tm(Oe,null,It).then(()=>{!Re||qt()!==Be||(Ke("ready"),Z(rt=>{if(!rt.has(Re))return rt;const xt=new Set(rt);return xt.delete(Re),xt}))}).catch(()=>{!Re||qt()!==Be||(Ke("error"),Z(rt=>new Set(rt).add(Re)))})}})},[L,It]),s.jsx(Qi,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:b,className:De("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[s.jsx(R0,{hideDirectoryControls:i,showProjectDisplayControls:!L,showRecentControls:!L,handleOpenDirectoryDialog:ct,onOpenScheduled:()=>{e&&re(!1),te(!0)},onOpenArchive:()=>{e&&re(!1),ee(!0)},headerActionIconClass:Qe,headerActionButtonClass:kt,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:j,sessionSearchQuery:u,setSessionSearchQuery:m,hasSessionSearchQuery:fe,searchMatchCount:g,collapseAllProjects:ae.actions.collapseAllProjects,expandAllProjects:ae.actions.expandAllProjects}),s.jsx(c4,{topology:{projects:X,availableWorktreesByProject:pe,knownDirectories:ve,isVSCode:L,worktreeMetadata:ce,gitBranches:Ne,projectRepoStatus:w,projectRootBranches:F,lastRepoStatus:ht.current},view:{isVisible:t,hasSessionSearchQuery:fe,normalizedSessionSearchQuery:we,activeProjectId:A,showInlineArchived:Ge,useGroupedSections:q,homeDirectory:D,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:se,stickyZoneHeaders:Ze,projectSortOrder:Dt,sidebarViewMode:Fe,emptyState:We,searchEmptyState:Ae,isSessionsLoading:yt,isWorktreeTopologyLoading:le,unresolvedWorktreeProjectPaths:V,projectView:ae.state,onSearchMatchCountChange:y},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:f},alwaysShowActions:He,notifyOnSubtasks:Te,setActiveProjectIdOnly:W,setSessionSwitcherOpen:re,openNewSessionDraft:Ee,openNewWorktreeDialog:O,openWorktreesPage:ke=>{e&&re(!1),de(ke)},openProjectEditDialog:h,removeProject:E,reorderProjects:v,startSessionWorktreeMenuLoad:Mt,initialActiveSessionByProject:R,persistActiveSessionByProject:M,projectViewActions:ae.actions}}),s.jsx(q0,{onOpenSettings:$e,onOpenUsage:()=>ue(!0),onOpenShortcuts:H,onOpenAbout:()=>$(!0),onOpenUpdate:he,showRuntimeButtons:!L,showUpdateButton:Ue}),s.jsx(Gd,{open:C,onOpenChange:T,info:je.info,downloading:je.downloading,downloaded:je.downloaded,progress:je.progress,error:je.error,onDownload:je.downloadUpdate,onRestart:je.restartToUpdate,runtimeType:je.runtimeType}),s.jsx(E0,{open:!!Le,onOpenChange:ke=>{ke||h(null)},project:Le,onSave:Ve}),s.jsx(tp,{open:N,onOpenChange:P,onWorktreeCreated:(ke,Oe)=>{if(ye.getState().closeMainSurfaces(),e&&re(!1),Oe?.sessionId){oe(Oe.sessionId,ke);return}Y({directoryOverride:ke,preserveDirectoryOverride:!0})}})]})})},m4=c.memo(f4),on=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Ks=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},h4=()=>{const{t}=At(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,m]=c.useState(!1),[f,g]=c.useState(!1),[y,b]=c.useState(!1),[j,x]=c.useState(!1),[h,p]=c.useState(new Set),w=ot(Q=>Q.getWorktreeMetadata),S=ot(Q=>Q.newSessionDraft),N=ot(Q=>Q.setNewSessionDraftTarget),P=ot(Q=>Q.setDraftBootstrapPendingDirectory),C=mb,T=ot(Q=>Q.deleteSessions),R=ot(Q=>Q.archiveSessions),M=ye(Q=>Q.showDeletionDialog),F=ye(Q=>Q.setShowDeletionDialog),K=Zt(Q=>Q.currentDirectory),D=Zt(Q=>Q.homeDirectory),U=Zt(Q=>Q.isHomeReady),A=zt(Q=>Q.projects),E=zt(Q=>Q.activeProjectId),{isMobile:W,isTablet:k,hasTouchInput:v}=Pn(),I=W||k||v,H=c.useMemo(()=>{const _=(E?A.find(J=>J.id===E)??null:null)?.path??K;return Ks(_)},[E,K,A]),$=c.useCallback(Q=>{const J=Ks(Q.projectDirectory)||H;return{id:(A.find(le=>Ks(le.path)===J)??null)?.id??`path:${J}`,path:J}},[H,A]),re=j&&h.size>0,te=c.useMemo(()=>{const Q=o?.worktree;return Q&&typeof Q.branch=="string"&&Q.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:_})=>typeof _.branch=="string"&&_.branch.trim().length>0)},[o?.worktree,a]),ee=o?.mode==="worktree",ue=ee,de=y||!ee||!te,Te=y||!ee;c.useEffect(()=>{r||!U||A.length>0||(i(!0),n(!0))},[r,U,A.length]);const we=c.useCallback(Q=>{l({sessions:Q.sessions,dateLabel:Q.dateLabel,mode:Q.mode??"session",worktree:Q.worktree??null})},[]),fe=c.useCallback(()=>{l(null),d([]),m(!1),g(!1),b(!1),x(!1),p(new Set)},[]),Ne=c.useCallback(async Q=>{if(Q.sessions.length===0)return;if(Q.sessions.length===1){const le=Q.sessions[0];await C(le.id)?_e.success(t("sessions.sidebar.session.delete.success")):_e.error(t("sessions.sidebar.session.delete.error"));return}const _=Q.sessions.map(le=>le.id),{deletedIds:J,failedIds:me}=await T(_);if(J.length>0){const le=me.length>0?me.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:me.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:me.length}):Q.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:Q.dateLabel}):void 0;_e.success(J.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:J.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:J.length}),{description:on(le)})}me.length>0&&_e.error(me.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:me.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:me.length}),{description:on(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[C,T,t]);c.useEffect(()=>Us.onDeleteRequest(Q=>{if(!M&&(Q.mode??"session")==="session"){Ne(Q);return}we(Q)}),[we,M,Ne]),c.useEffect(()=>Us.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){d([]),m(!1),g(!1),x(!1),p(new Set);return}const Q=o.sessions.map(me=>{const le=w(me.id);return le?{session:me,metadata:le}:null}).filter(me=>!!me);d(Q),m(!1),x(!1),p(new Set);const _=new Map;if(o.worktree?.path&&_.set(Ks(o.worktree.path),o.worktree),Q.forEach(({metadata:me})=>{me.path&&_.set(Ks(me.path),me)}),_.size===0){x(!0);return}let J=!1;return(async()=>{const me=new Map,le=new Set;await Promise.all(Array.from(_.entries()).map(async([V,Z])=>{try{const G=await hb(Z.path);me.set(V,G),G?.isDirty&&le.add(V)}catch{Z.status&&(me.set(V,Z.status),Z.status.isDirty&&le.add(V))}})).catch(V=>{console.warn("Failed to inspect worktree status before deletion:",V)}),!J&&(p(le),x(!0),l(V=>{if(!V?.worktree?.path)return V;const Z=Ks(V.worktree.path),G=me.get(Z);if(!G)return V;const ie=V.worktree.status;return ie?.isDirty===G.isDirty&&ie?.ahead===G.ahead&&ie?.behind===G.behind&&ie?.upstream===G.upstream?V:{...V,worktree:{...V.worktree,status:G}}}),d(V=>V.map(Z=>{const G=Ks(Z.metadata.path),ie=me.get(G);return ie?{session:Z.session,metadata:{...Z.metadata,status:ie}}:Z})))})(),()=>{J=!0}},[o,w]),c.useEffect(()=>{te||m(!1)},[te]);const L=c.useCallback(async(Q,_,J)=>{const me=u&&te,le=$(Q),V=Ks(Q.path),Z=Ks(le.path);try{await fu(le,Q,{deleteRemoteBranch:me,deleteLocalBranch:_});const G=Ks(S?.directoryOverride);return S?.open&&V&&G===V&&Z&&(P(null),N({projectId:le.id,directoryOverride:Z},{force:!0})),Ks(K)===V&&Z&&Zt.getState().setDirectory(Z,{showOverlay:!1}),!0}catch(G){return _e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:vi(Q)}),{id:J,description:on(G instanceof Error?G.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[te,K,u,$,S?.directoryOverride,S?.open,P,N,t]),oe=c.useCallback((Q,_,J)=>{const me=u&&te,le=_e.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:vi(Q)}));(async()=>{try{if(_.length>0){const{failedIds:G}=await R(_);if(G.length>0){_e.error(G.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:G.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:G.length}),{id:le,description:on(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await L(Q,J,le))return;const Z=t(me?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");_e.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:vi(Q)}),{id:le,description:on(Z)})}catch(V){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:le,description:on(V instanceof Error?V.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[R,te,u,L,t]),ce=c.useCallback(async()=>{if(o){b(!0);try{const Q=ue,_=Q&&u,J=Q&&f;if(ee&&o.worktree){oe(o.worktree,o.sessions.map(me=>me.id),J),fe();return}if(o.sessions.length===1){const me=o.sessions[0];if(!await C(me.id)){_e.error(t("sessions.sidebar.session.delete.error")),b(!1);return}const V=!ee&&Q?t(_?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;_e.success(t("sessions.sidebar.session.delete.success"),{description:on(V),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const me=o.sessions.map(G=>G.id);let le=[],V=[];const Z=await T(me);if(le=Z.deletedIds,V=Z.failedIds,le.length>0){const G=!ee&&Q?t(_?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,Se=[V.length>0?V.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:V.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:V.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,G].filter(Boolean).join(" ");_e.success(le.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:le.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:le.length}),{description:on(Se||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(V.length>0&&(_e.error(V.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:V.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:V.length}),{description:on(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),le.length===0)){b(!1);return}}fe()}finally{b(!1)}}},[o,u,f,C,T,fe,ue,ee,oe,t]),pe=o?.worktree??a[0]?.metadata??null,Y=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",ve=o?s.jsxs("div",{className:De(ee?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:De(ee?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[ee&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:De(ee?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(Q=>s.jsxs("li",{className:De(ee?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:De(!ee&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:Q.title||t("sessions.sidebar.session.untitled")})]},Q.id)),o.sessions.length>5&&s.jsx("li",{className:De(ee?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),ee?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(B,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),pe?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:pe.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:pe?Hr(pe.path,D):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),re&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Ee=ee?te?s.jsxs("button",{type:"button",onClick:()=>{de||m(Q=>!Q)},disabled:de,className:De("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",de?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?s.jsx(B,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(B,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,je=ee?s.jsxs("button",{type:"button",onClick:()=>{Te||g(Q=>!Q)},disabled:Te,className:De("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Te?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?s.jsx(B,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(B,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,ge=ee?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[je,Ee]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mt,{variant:"ghost",onClick:fe,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(mt,{variant:"destructive",onClick:ce,disabled:y,children:t(y?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>F(!M),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":!M,children:[M?s.jsx(B,{name:"checkbox-blank",className:"size-4"}):s.jsx(B,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mt,{variant:"ghost",onClick:fe,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(mt,{variant:"destructive",onClick:ce,disabled:y,children:y?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),be=ee?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[I?s.jsx(Qo,{open:!!o,onClose:()=>{y||fe()},title:be,footer:s.jsx("div",{className:"flex justify-end gap-2",children:ge}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Y&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Y}),ve]})}):s.jsx(ks,{open:!!o,onOpenChange:Q=>{if(!Q){if(y)return;fe()}},children:s.jsxs(Cs,{className:De(ee?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Hs,{children:[s.jsxs(Ls,{className:De(ee&&"flex items-center gap-2"),children:[ee&&s.jsx(B,{name:"delete-bin",className:"h-5 w-5"}),be]}),Y&&s.jsx(_s,{children:Y})]}),s.jsx("div",{className:De(ee&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:ve}),s.jsx(Qn,{className:"mt-2 gap-2 pt-1 pb-1",children:ge})]})}),s.jsx(sp,{open:e,onOpenChange:n})]})};function cm(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return af.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function p4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=af.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const g4=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],b4={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},_n=t=>b4[t]??t,dm=[0,1,2,3,4,5,6],md="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",ja=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(_n))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],hd=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},Eo=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},pd=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},x4=(t,e,n)=>{const r=Eo(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},gd=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),y4=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),d=new Date(n,r,0).getDate(),u=[];for(let m=0;m<42;m+=1){const f=m-l+1;if(f<=0){const g=d+f;u.push({date:new Date(n,r-1,g),inCurrentMonth:!1});continue}if(f>a){u.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}u.push({date:new Date(n,r,f),inCurrentMonth:!0})}return u},w4=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},Mn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},jr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},bd=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:jr(t,{min:1,max:12}),ko=t=>/^[0-5][0-9]$/.test(t)?t:jr(t,{max:59}),v4=(t,e)=>jr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),xd=(t,e)=>jr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),S4=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},j4=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},k4=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return dm.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},C4=(t,e)=>[...t.slice(e),...t.slice(0,e)],xs=t=>{const e=nt.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},yd=t=>{const e=nt.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let m;e[0]!==n?(m=w4(n),e[0]=n,e[1]=m):m=e[1];const f=m,g=lt.useRef(null),y=lt.useRef(null),[b,j]=lt.useState(null),[x,h]=lt.useState(null),p=lt.useRef(null),w=lt.useRef(null);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=Q=>{p.current=Q,j(Q)},e[2]=S):S=e[2];const N=S;let P;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=Q=>{w.current=Q,h(Q)},e[3]=P):P=e[3];const C=P,T=E4,R=R4,M=M4;let F;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(F=Q=>{const _=Q.replace(/\D/g,"").slice(0,2);N(_),_.length===2&&(r(i?M(T(_),f.minute):Mn(bd(_),f.minute,f.meridiem)),N(null),y.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=F):F=e[8];const K=F;let D;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(D=()=>{const Q=p.current;if(Q!==null&&(N(null),Q.length!==0)){if(i){r(M(T(Q.padStart(2,"0")),f.minute));return}r(Mn(bd(Q.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=D):D=e[13];const U=D;let A;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(A=Q=>{const _=Q.replace(/\D/g,"").slice(0,2);C(_),_.length===2&&(r(i?M(f.hour24,ko(_)):Mn(f.hour12,ko(_),f.meridiem)),C(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=A):A=e[19];const E=A;let W;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(W=()=>{const Q=w.current;Q!==null&&(C(null),Q.length!==0&&r(i?M(f.hour24,ko(Q.padStart(2,"0"))):Mn(f.hour12,ko(Q.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=i,e[25]=W):W=e[25];const k=W;let v;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(v=Q=>r(i?M(R(f.hour24,Q),f.minute):Mn(v4(f.hour12,Q),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=i,e[32]=v):v=e[32];const I=v;let H;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(H=Q=>r(i?M(f.hour24,xd(f.minute,Q)):Mn(f.hour12,xd(f.minute,Q),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=i,e[39]=H):H=e[39];const $=H;let re;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(re=Q=>{Q!==f.meridiem&&r(Mn(f.hour12,f.minute,Q))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=re):re=e[44];const te=re;let ee;e[45]!==U||e[46]!==I?(ee=Q=>{if(Q.key==="ArrowRight"){Q.preventDefault(),U(),y.current?.focus();return}(Q.key==="ArrowUp"||Q.key==="ArrowDown")&&(Q.preventDefault(),N(null),I(Q.key==="ArrowUp"?1:-1))},e[45]=U,e[46]=I,e[47]=ee):ee=e[47];const ue=ee;let de;e[48]!==k||e[49]!==$?(de=Q=>{if(Q.key==="ArrowLeft"&&(Q.currentTarget.selectionStart??0)===0){Q.preventDefault(),k(),g.current?.focus();return}(Q.key==="ArrowUp"||Q.key==="ArrowDown")&&(Q.preventDefault(),C(null),$(Q.key==="ArrowUp"?1:-1))},e[48]=k,e[49]=$,e[50]=de):de=e[50];const Te=de,we=i?"px-2":"pl-2 pr-1";let fe;e[51]!==we?(fe=De("oc-surface-elevated inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-surface-elevated focus-within:ring-1 focus-within:ring-ring focus-within:border-ring",we),e[51]=we,e[52]=fe):fe=e[52];const Ne=b??(i?f.hour24:f.hour12);let L;e[53]!==K?(L=Q=>K(Q.target.value),e[53]=K,e[54]=L):L=e[54];let oe;e[55]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>N(""),e[55]=oe):oe=e[55];let ce;e[56]!==U||e[57]!==o||e[58]!==ue||e[59]!==Ne||e[60]!==L?(ce=s.jsx("input",{ref:g,inputMode:"numeric",value:Ne,onChange:L,onKeyDown:ue,onFocus:oe,onBlur:U,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=U,e[57]=o,e[58]=ue,e[59]=Ne,e[60]=L,e[61]=ce):ce=e[61];let pe;e[62]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=pe):pe=e[62];const Y=x??f.minute;let ve;e[63]!==E?(ve=Q=>E(Q.target.value),e[63]=E,e[64]=ve):ve=e[64];let Ee;e[65]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>C(""),e[65]=Ee):Ee=e[65];let je;e[66]!==k||e[67]!==l||e[68]!==Te||e[69]!==Y||e[70]!==ve?(je=s.jsx("input",{ref:y,inputMode:"numeric",value:Y,onChange:ve,onKeyDown:Te,onFocus:Ee,onBlur:k,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=k,e[67]=l,e[68]=Te,e[69]=Y,e[70]=ve,e[71]=je):je=e[71];let ge;e[72]!==d||e[73]!==f.meridiem||e[74]!==a||e[75]!==u||e[76]!==te||e[77]!==i?(ge=i?null:s.jsxs(ln,{value:f.meridiem,onValueChange:Q=>te(Q),children:[s.jsx(cn,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(Js,{})}),s.jsxs(dn,{children:[s.jsx(ds,{value:"AM",children:d}),s.jsx(ds,{value:"PM",children:u})]})]}),e[72]=d,e[73]=f.meridiem,e[74]=a,e[75]=u,e[76]=te,e[77]=i,e[78]=ge):ge=e[78];let be;return e[79]!==fe||e[80]!==ce||e[81]!==je||e[82]!==ge?(be=s.jsxs("div",{className:fe,children:[ce,pe,je,ge]}),e[79]=fe,e[80]=ce,e[81]=je,e[82]=ge,e[83]=be):be=e[83],be},wd=t=>new Date(t.getFullYear(),t.getMonth(),1),N4=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},vd=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),A4=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},Sd=(t,e)=>{const n=_n(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:A4(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:hd(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:_n(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:hd(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},P4=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!cm(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},D4=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},I4=t=>{const e=nt.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?cm(l):null,e[0]=l,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!l.trim()){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[2]=v):v=e[2],u=v;break e}let k;e[3]!==l||e[4]!==n.schedule.timezone?(k=p4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=k):k=e[5],u=k}const m=u;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=k=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(k),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const g=f;let y;e[9]!==o?(y=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=y):y=e[10];let b;e[11]!==y?(b=s.jsx(xs,{htmlFor:"sched-cron",required:!0,children:y}),e[11]=y,e[12]=b):b=e[12];let j;e[13]!==r?(j=k=>r(v=>({...v,schedule:{...v.schedule,cronExpression:k.target.value}})),e[13]=r,e[14]=j):j=e[14];let x;e[15]!==o?(x=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=x):x=e[16];let h;e[17]!==l||e[18]!==j||e[19]!==x?(h=s.jsx(Wn,{id:"sched-cron",value:l,onChange:j,placeholder:x,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=j,e[19]=x,e[20]=h):h=e[20];let p;e[21]!==l||e[22]!==d||e[23]!==o?(p=d&&!d.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=d,e[23]=o,e[24]=p):p=e[24];let w;e[25]!==b||e[26]!==h||e[27]!==p?(w=s.jsxs("div",{className:"flex flex-col gap-1",children:[b,h,p]}),e[25]=b,e[26]=h,e[27]=p,e[28]=w):w=e[28];let S;e[29]!==g||e[30]!==m||e[31]!==o?(S=m.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:m.map(g).join(", ")})]}):null,e[29]=g,e[30]=m,e[31]=o,e[32]=S):S=e[32];let N;e[33]!==o?(N=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=N):N=e[34];let P;e[35]!==N?(P=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=P):P=e[36];let C;e[37]!==r||e[38]!==o?(C=g4.map(k=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(v=>({...v,schedule:{...v.schedule,cronExpression:k.expression}})),children:[s.jsx("span",{className:"font-mono",children:k.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(k.labelKey)})]},k.expression)),e[37]=r,e[38]=o,e[39]=C):C=e[39];let T;e[40]!==C?(T=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:C}),e[40]=C,e[41]=T):T=e[41];let R;e[42]!==P||e[43]!==T?(R=s.jsxs("div",{className:"flex flex-col gap-1",children:[P,T]}),e[42]=P,e[43]=T,e[44]=R):R=e[44];let M;e[45]!==o?(M=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=M):M=e[46];let F;e[47]!==M?(F=s.jsx(xs,{children:M}),e[47]=M,e[48]=F):F=e[48];let K;e[49]!==r?(K=k=>{r(v=>({...v,schedule:{...v.schedule,timezone:k}}))},e[49]=r,e[50]=K):K=e[50];let D;e[51]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{})}),e[51]=D):D=e[51];let U;e[52]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(dn,{children:ja.map(O4)}),e[52]=U):U=e[52];let A;e[53]!==n.schedule.timezone||e[54]!==K?(A=s.jsxs(ln,{value:n.schedule.timezone,onValueChange:K,children:[D,U]}),e[53]=n.schedule.timezone,e[54]=K,e[55]=A):A=e[55];let E;e[56]!==F||e[57]!==A?(E=s.jsxs("div",{className:"flex flex-col gap-1",children:[F,A]}),e[56]=F,e[57]=A,e[58]=E):E=e[58];let W;return e[59]!==w||e[60]!==S||e[61]!==R||e[62]!==E?(W=s.jsxs("div",{className:"flex flex-col gap-3",children:[w,S,R,E]}),e[59]=w,e[60]=S,e[61]=R,e[62]=E,e[63]=W):W=e[63],W};function T4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=At(),a=Wt(O=>O.loadProviders),d=Wt(O=>O.loadAgents),u=Wt(O=>O.providers),m=Wt(O=>O.currentProviderId),f=Wt(O=>O.currentModelId),g=Wt(O=>O.currentVariant||""),y=Wt(O=>O.currentAgentName||""),b=ye(O=>O.timeFormatPreference),j=ye(O=>O.weekStartPreference),x=ye(O=>O.isMobile),[h,p]=lt.useState(()=>Sd(n,{providerID:m,modelID:f,variant:g,agent:y})),[w,S]=lt.useState(!1),[N,P]=lt.useState(!1),[C,T]=lt.useState(!1),[R,M]=lt.useState(""),[F,K]=lt.useState(!1),[D,U]=lt.useState(""),[A,E]=lt.useState(!1),[W,k]=lt.useState(""),[v,I]=lt.useState(()=>{const O=Eo(n?.schedule?.date||"")||new Date;return new Date(O.getFullYear(),O.getMonth(),1)}),H=lt.useRef(null),$=lt.useRef(null),re=lt.useRef(null),te=lt.useRef(null),ee=lt.useRef(null),ue=lt.useMemo(()=>j4(l),[l]),de=lt.useMemo(()=>S4(l),[l]),Te=lt.useMemo(()=>b==="24h"?!0:b==="12h"?!1:ue,[b,ue]),we=lt.useMemo(()=>j==="sunday"?0:j==="monday"?1:de,[j,de]),fe=lt.useMemo(()=>{const O=k4(l);return C4(dm.map(he=>({value:he,label:O[he]||""})),we)},[l,we]);lt.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),lt.useEffect(()=>{if(!e)return;p(Sd(n,{providerID:m,modelID:f,variant:g,agent:y}));const O=Eo(n?.schedule?.date||"")||new Date;I(new Date(O.getFullYear(),O.getMonth(),1)),P(!1),K(!1),T(!1),U(""),M("")},[e,n,m,f,g,y]),lt.useEffect(()=>{if(!N)return;const O=he=>{H.current&&!H.current.contains(he.target)&&P(!1)};return document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[N]);const Ne=lt.useMemo(()=>{const he=u.find($e=>$e.id===h.execution.providerID)?.models?.find($e=>$e.id===h.execution.modelID);return pb(he?.variants)},[u,h.execution.providerID,h.execution.modelID]),L=Ne.length>0,oe=lt.useMemo(()=>!L||!h.execution.variant?"__default":Ne.includes(h.execution.variant)?h.execution.variant:"__default",[h.execution.variant,L,Ne]);lt.useEffect(()=>{L||!h.execution.variant||p(O=>({...O,execution:{...O.execution,variant:""}}))},[L,h.execution.variant]);const ce=lt.useCallback((O,he)=>{p($e=>{const Ue=new Set($e.schedule.weekdays);return he?Ue.add(O):Ue.delete(O),{...$e,schedule:{...$e.schedule,weekdays:Array.from(Ue).sort((ct,pt)=>ct-pt)}}})},[]),pe=lt.useCallback((O,he)=>{p($e=>{const Ue=$e.schedule.times.slice();return Ue[O]=he,{...$e,schedule:{...$e.schedule,times:Ue}}})},[]),Y=lt.useCallback(O=>{p(he=>{const $e=he.schedule.times.filter((Ue,ct)=>ct!==O);return{...he,schedule:{...he.schedule,times:$e.length>0?$e:["09:00"]}}})},[]),ve=lt.useCallback(()=>{p(O=>({...O,schedule:{...O.schedule,times:[...O.schedule.times,"12:00"]}}))},[]),Ee=lt.useMemo(()=>N4(),[]),je=lt.useMemo(()=>wd(Ee),[Ee]),ge=lt.useMemo(()=>{const O=Eo(h.schedule.onceDate);return O?vd(O,Ee)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(O):null},[h.schedule.onceDate,l,o,Ee]),be=lt.useMemo(()=>wd(v).getTime()<=je.getTime(),[v,je]),Q=lt.useMemo(()=>fe.map(O=>O.label),[fe]),_=lt.useCallback(O=>{p(he=>({...he,schedule:{...he.schedule,onceDate:O}}))},[]),J=lt.useCallback((O,he)=>{if(O.startsWith("/")){const pt=O.indexOf(" "),it=O.indexOf(`
883
883
  `),ft=Math.min(pt===-1?O.length:pt,it===-1?O.length:it);if(he<=ft&&pt===-1){U(O.substring(1,ft)),K(!0),T(!1),E(!1);return}}K(!1);const $e=O.substring(0,he),Ue=$e.lastIndexOf("#");if(Ue!==-1){const pt=Ue>0?$e[Ue-1]:null,it=$e.substring(Ue+1);if((!pt||/\s/.test(pt))&&!it.includes(" ")&&!it.includes(`
884
884
  `)){k(it),E(!0),T(!1);return}}E(!1);const ct=$e.lastIndexOf("@");if(ct!==-1){const pt=ct>0?$e[ct-1]:null,it=$e.substring(ct+1);(!pt||/\s/.test(pt))&&!it.includes(" ")&&!it.includes(`
885
- `)?(M(it),T(!0)):T(!1);return}T(!1)},[]),me=lt.useCallback(O=>{p(he=>({...he,execution:{...he.execution,prompt:O}}))},[]),le=lt.useCallback(O=>{const he=h.execution.prompt,Ue=$.current?.selectionStart??he.length,pt=he.substring(0,Ue).lastIndexOf("@"),it=O.relativePath&&O.relativePath.trim().length>0?O.relativePath.trim():O.path||O.name,ft=pt!==-1?pt:Ue,yt=`${he.substring(0,ft)}@${it} ${he.substring(Ue)}`,ht=ft+it.length+2;me(yt),T(!1),M(""),requestAnimationFrame(()=>{const bt=$.current;bt&&(bt.selectionStart=ht,bt.selectionEnd=ht,bt.focus()),J(yt,ht)})},[h.execution.prompt,me,J]),V=lt.useCallback(O=>{const he=h.execution.prompt,Ue=$.current?.selectionStart??he.length,pt=he.substring(0,Ue).lastIndexOf("@"),it=pt!==-1?pt:Ue,ft=`${he.substring(0,it)}@${O} ${he.substring(Ue)}`,yt=it+O.length+2;me(ft),T(!1),M(""),requestAnimationFrame(()=>{const ht=$.current;ht&&(ht.selectionStart=yt,ht.selectionEnd=yt,ht.focus()),J(ft,yt)})},[h.execution.prompt,me,J]),Z=lt.useCallback(O=>{const he=`/${O.name} `;me(he),K(!1),U(""),E(!1),requestAnimationFrame(()=>{const $e=$.current;$e&&($e.focus(),$e.selectionStart=$e.value.length,$e.selectionEnd=$e.value.length),J(he,he.length)})},[me,J]),G=lt.useCallback((O,he)=>{const $e=h.execution.prompt,ct=$.current?.selectionStart??$e.length,it=$e.substring(0,ct).lastIndexOf("#"),ft=it!==-1?it:ct,yt=`${$e.substring(0,ft)}#${he} ${$e.substring(ct)}`,ht=ft+he.length+2;me(yt),E(!1),k(""),requestAnimationFrame(()=>{const bt=$.current;bt&&(bt.selectionStart=ht,bt.selectionEnd=ht,bt.focus()),J(yt,ht)})},[h.execution.prompt,me,J]),ie=lt.useCallback(O=>{if(F&&te.current&&(O.key==="Enter"||O.key==="ArrowUp"||O.key==="ArrowDown"||O.key==="Escape"||O.key==="Tab")){O.preventDefault(),te.current.handleKeyDown(O.key);return}C&&re.current&&(O.key==="Enter"||O.key==="ArrowUp"||O.key==="ArrowDown"||O.key==="Escape"||O.key==="Tab")&&(O.preventDefault(),re.current.handleKeyDown(O.key)),A&&ee.current&&(O.key==="Enter"||O.key==="ArrowUp"||O.key==="ArrowDown"||O.key==="Escape"||O.key==="Tab")&&(O.preventDefault(),ee.current.handleKeyDown(O.key))},[F,C,A]),Se=lt.useCallback(async()=>{const O=P4(h,o);if(O){_e.error(O);return}const he={...h.id?{id:h.id}:{},name:h.name.trim(),enabled:h.enabled,schedule:{kind:h.schedule.kind,timezone:h.schedule.timezone.trim(),...h.schedule.kind==="cron"?{cron:h.schedule.cronExpression.trim()}:h.schedule.kind==="once"?{date:h.schedule.onceDate,time:h.schedule.onceTime}:{times:D4(h.schedule.times),...h.schedule.kind==="weekly"?{weekdays:h.schedule.weekdays}:{}}},execution:{prompt:h.execution.prompt,providerID:h.execution.providerID,modelID:h.execution.modelID,...h.execution.variant.trim()?{variant:h.execution.variant.trim()}:{},...h.execution.agent.trim()?{agent:h.execution.agent.trim()}:{},...h.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...h.execution.goalEnabled?{goalEnabled:!0}:{},...h.execution.goalEnabled&&h.execution.goalTokenBudget?{goalTokenBudget:h.execution.goalTokenBudget}:{}},...h.state?{state:h.state}:{}};S(!0);try{await i(he),r(!1)}catch($e){_e.error($e instanceof Error?$e.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[h,r,i,o]),se=lt.useId(),Me=lt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),He=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),We=o("sessions.scheduledTasks.editor.description"),Le=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Wn,{id:"sched-name",value:h.name,onChange:O=>p(he=>({...he,name:O.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(ln,{value:h.schedule.kind,onValueChange:O=>{p(he=>({...he,schedule:{...he.schedule,kind:O,...O==="cron"&&!he.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{children:O=>o(O==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":O==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":O==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(dn,{children:[s.jsx(ds,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ds,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ds,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ds,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),h.schedule.kind==="cron"?s.jsx(I4,{draft:h,setDraft:p,locale:l,t:o}):h.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:H,children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:De(gb({size:"default"}),"w-fit max-w-full"),onClick:()=>P(O=>!O),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(B,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:x4(h.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>I(O=>gd(O,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:be,children:s.jsx(B,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(v)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>I(O=>gd(O,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(B,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:Q.map((O,he)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:O},`${O}-${he}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:y4(v,we).map(({date:O,inCurrentMonth:he})=>{const $e=pd(O),Ue=$e===h.schedule.onceDate,ct=vd(O,Ee),pt=O.getTime()<Ee.getTime(),it=Ue?"bg-interactive-selection text-interactive-selection-foreground":pt?"text-muted-foreground/40":he?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{pt||(_($e),P(!1))},disabled:pt,className:["h-8 rounded-md typography-ui-label",it,ct&&!Ue?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",pt?"cursor-not-allowed opacity-45":""].join(" "),children:O.getDate()},$e)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:ge||""}),s.jsx(mt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{_(pd(Ee)),I(new Date(Ee.getFullYear(),Ee.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(yd,{value:h.schedule.onceTime,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:O=>p(he=>({...he,schedule:{...he.schedule,onceTime:O}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ln,{value:h.schedule.timezone,onValueChange:O=>{p(he=>({...he,schedule:{...he.schedule,timezone:O}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{})}),s.jsx(dn,{children:ja.map(O=>s.jsx(ds,{value:O,children:O},O))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[h.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:fe.map(O=>{const he=h.schedule.weekdays.includes(O.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",he?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(Lr,{checked:he,onChange:$e=>ce(O.value,$e),ariaLabel:O.label}),s.jsx("button",{type:"button",onClick:()=>ce(O.value,!he),className:"group-hover:text-foreground",children:O.label})]},O.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:h.schedule.times.map((O,he)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yd,{value:O,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:$e=>pe(he,$e)}),h.schedule.times.length>1?s.jsx(mt,{type:"button",size:"icon",variant:"ghost",onClick:()=>Y(he),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(B,{name:"close",className:"h-4 w-4"})}):null]},he))}),s.jsx("div",{children:s.jsxs(mt,{type:"button",size:"sm",variant:"outline",onClick:ve,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ln,{value:h.schedule.timezone,onValueChange:O=>{p(he=>({...he,schedule:{...he.schedule,timezone:O}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{})}),s.jsx(dn,{children:ja.map(O=>s.jsx(ds,{value:O,children:O},O))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(bb,{providerId:h.execution.providerID,modelId:h.execution.modelID,onChange:(O,he)=>{p($e=>({...$e,execution:{...$e.execution,providerID:O,modelID:he,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(ln,{value:oe,disabled:!L,onValueChange:O=>{p(he=>({...he,execution:{...he.execution,variant:O==="__default"?"":O}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{children:O=>O==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):O})}),s.jsxs(dn,{children:[s.jsx(ds,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Ne.map(O=>s.jsx(ds,{value:O,children:O},O))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(xb,{agentName:h.execution.agent,filter:O=>yb(O.mode),onChange:O=>p(he=>({...he,execution:{...he.execution,agent:O}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(Er,{id:"sched-prompt",ref:$,value:h.execution.prompt,onChange:O=>{const he=O.target.value;me(he);const $e=O.target.selectionStart??he.length;J(he,$e)},onKeyDown:ie,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),F?s.jsx(wb,{ref:te,searchQuery:D,onCommandSelect:Z,onClose:()=>K(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,C?s.jsx(vb,{ref:re,searchQuery:R,onFileSelect:le,onAgentSelect:V,onClose:()=>T(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,A?s.jsx(Sb,{ref:ee,searchQuery:W,onSnippetSelect:G,onClose:()=>E(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),h.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(Lr,{checked:h.execution.goalTokenBudget!==null,onChange:O=>p(he=>({...he,execution:{...he.execution,goalTokenBudget:O?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),h.execution.goalTokenBudget!==null?s.jsx(jb,{value:h.execution.goalTokenBudget,onValueChange:O=>{typeof O=="number"&&Number.isFinite(O)&&O>0&&p(he=>({...he,execution:{...he.execution,goalTokenBudget:Math.floor(O)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Ve=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(Lr,{checked:h.enabled,onChange:O=>p(he=>({...he,enabled:O})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:De(md),onClick:()=>p(O=>({...O,execution:{...O.execution,permissionAutoAccept:!O.execution.permissionAutoAccept}})),"aria-pressed":h.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:h.execution.permissionAutoAccept?s.jsx(B,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(B,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:De(md,h.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>p(O=>({...O,execution:{...O.execution,goalEnabled:!O.execution.goalEnabled}})),"aria-pressed":h.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:h.execution.goalEnabled?s.jsx(B,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(B,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:w,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(mt,{type:"button",size:"sm",onClick:Se,disabled:w,children:o(w?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return x?s.jsx(Qo,{open:e,title:He,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:O=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:He}),O]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:We})]}),footer:Ve,children:Le}):s.jsx(ks,{open:e,onOpenChange:O=>{!O&&Me()||r(O)},children:s.jsxs(Cs,{"aria-describedby":se,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(_s,{id:se,className:"sr-only",children:We}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Ls,{className:"typography-ui-label font-medium text-foreground",children:He}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:We})]})}),s.jsx(ju,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Le})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:Ve})})]})})}function E4(t){return jr(t,{min:0,max:23})}function R4(t,e){return jr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function M4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function O4(t){return s.jsx(ds,{value:t,children:t},t)}const B4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},F4=(t,e)=>{const n=B4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},L4=(t,e)=>!t||!Number.isFinite(t)?"":kb(t,e),jd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),g=Math.round(r%o/i),y=g>0?`${f}h ${g}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:y}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:y})}const d=Math.floor(r/l),u=Math.round(r%l/o),m=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:m}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:m})},_4={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},$4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function z4(){const{t}=At(),e=ye(k=>k.isScheduledTasksDialogOpen),n=ye(k=>k.setScheduledTasksDialogOpen),r=ye(k=>k.isMobile),i=ye(k=>k.timeFormatPreference),o=zt(k=>k.projects),l=zt(k=>k.getActiveProject()),a=Zt(k=>k.homeDirectory),{currentTheme:d}=qn(),[u,m]=lt.useState(""),[f,g]=lt.useState([]),[y,b]=lt.useState(!0),[j,x]=lt.useState(!1),[h,p]=lt.useState(null),[w,S]=lt.useState(null),N=lt.useMemo(()=>o.find(k=>k.id===u)||null,[o,u]),P=lt.useCallback(k=>{const v=k.label?.trim()||yr(k.path,a||void 0),I=k.icon?za[k.icon]:null,H=k.color?Wa[k.color]:void 0,$=I?s.jsx(B,{name:I,className:"h-3.5 w-3.5 shrink-0",style:H?{color:H}:void 0}):s.jsx(B,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:H?{color:H}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:k.iconBackground?{backgroundColor:k.iconBackground}:void 0,children:s.jsx(Ka,{project:{id:k.id,iconImage:k.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:$})}):$,s.jsx("span",{className:"truncate",children:v})]})},[a,d.metadata.variant,d.colors.surface.foreground]),C=lt.useCallback(async(k,v)=>{if(!k){g([]);return}v?.silent||b(!0);try{const I=await dx(k);I.sort((H,$)=>{if(H.enabled!==$.enabled)return H.enabled?-1:1;const re=H.name.localeCompare($.name);return re!==0?re:(H.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-($.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),g(I)}catch(I){_e.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),v?.silent||g([])}finally{v?.silent||b(!1)}},[t]);lt.useEffect(()=>{if(!e)return;const k=l?.id||o[0]?.id||"";m(k),k?C(k):(g([]),b(!1))},[e,l,o,C]),lt.useEffect(()=>{if(!e)return;let k=null;const v=Dn(I=>{I.type==="scheduled-task-ran"&&I.projectId===u&&(k&&clearTimeout(k),k=setTimeout(()=>{C(u,{silent:!0})},400))});return()=>{k&&clearTimeout(k),v()}},[e,u,C]);const T=lt.useCallback(async k=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await ql(u,k),await C(u),_e.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,C,t]),R=lt.useCallback(async(k,v)=>{if(u){S(k.id),g(I=>I.map(H=>H.id===k.id?{...H,enabled:v}:H));try{k.loopFile?await ux(u,k.id,v):await ql(u,{...k,enabled:v}),await C(u,{silent:!0})}catch(I){_e.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await C(u,{silent:!0})}finally{S(null)}}},[u,C,t]),M=lt.useCallback(async k=>{if(!(!u||!window.confirm(k.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:k.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:k.name})))){S(k.id);try{k.loopFile?await fx(u,k.id):await mx(u,k.id),await C(u,{silent:!0}),_e.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(I){_e.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[u,C,t]),F=lt.useCallback(k=>{if(!k.loopFile){p(k),x(!0);return}N?.path&&(n(!1),Qs.getState().setSelectedPath(N.path,k.loopFile,{allowOutsideRoot:!0}),ye.getState().openContextFile(N.path,k.loopFile))},[N?.path,n]),K=lt.useCallback(async k=>{if(u){S(k.id);try{const{sessionId:v,persistError:I}=await hx(u,k.id);if(await Promise.all([C(u,{silent:!0}),Jo()]),I?_e.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):_e.success(t("sessions.scheduledTasks.dialog.toast.started")),v){const H=o.find($=>$.id===u);ot.getState().setCurrentSession(v,H?.path??null)}}catch(v){_e.error(v instanceof Error?v.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[u,o,C,t]),D=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(ln,{value:u||"__none",onValueChange:k=>{const v=k==="__none"?"":k;m(v),v?C(v):g([])},children:[s.jsx(cn,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Js,{children:P(N)}):s.jsx(Js,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(dn,{children:[o.length===0?s.jsx(ds,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(k=>s.jsx(ds,{value:k.id,children:P(k)},k.id))]})]})]}),U=()=>{p(null),x(!0)},A=k=>{m(k),k?C(k):g([])},E=s.jsx("div",{className:"min-h-[280px]",children:y?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(B,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(k=>{const v=w===k.id,I=k.state?.lastStatus||"idle",H=_4[I],$=t(I==="success"?"sessions.scheduledTasks.dialog.status.success":I==="error"?"sessions.scheduledTasks.dialog.status.error":I==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),re=k.state?.nextRunAt,te=k.state?.lastRunAt;return s.jsxs("div",{className:De("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:De("min-w-0",!k.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:k.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:F4(k,t)}),k.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:k.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:k.loopFile})}):null]}),s.jsxs("div",{className:De("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!k.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),re?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:jd(re,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:L4(re,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),I==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(B,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):te?s.jsxs(s.Fragment,{children:[H.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${H.tone})`},children:[s.jsx(B,{name:H.Icon,className:"h-3.5 w-3.5"}),$]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:jd(te,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),k.state?.lastError?s.jsxs("div",{className:De("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!k.enabled&&"opacity-60"),style:$4("error"),children:[s.jsx(B,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:k.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:De("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",k.enabled?"text-foreground":"text-muted-foreground",v&&"cursor-not-allowed opacity-50"),children:[s.jsx(Lr,{checked:k.enabled,onChange:ee=>{R(k,ee)},ariaLabel:k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:k.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:k.name}),disabled:v}),k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(mt,{variant:"outline",size:"sm",onClick:()=>{K(k)},disabled:v,children:[s.jsx(B,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(mt,{variant:"outline",size:"sm",onClick:()=>F(k),disabled:v,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:k.name}),children:[s.jsx(B,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(mt,{variant:"destructive",size:"sm",onClick:()=>{M(k)},disabled:v,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:k.name}),children:s.jsx(B,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},k.id)})})}),W=s.jsxs("div",{className:"space-y-4",children:[D,E]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Qo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:k=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),k]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(mt,{className:"w-full",onClick:U,disabled:!u,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:W}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(k=>s.jsx("button",{type:"button",onClick:()=>A(k.id),className:De("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===k.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:P(k)},k.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(mt,{size:"sm",onClick:U,disabled:!u,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:E})})]})]})}):null,s.jsx(T4,{open:j,task:h,onOpenChange:x,onSave:T})]})}const Ro=100;function W4(){const t=nt.c(108),{t:e}=At(),n=ye(X4),r=ye(Q4),i=ot(Y4),o=ot(q4),l=Zt(G4);let a;t[0]!==n?(a=re=>n?re.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=ps(Un(a)),[u,m]=c.useState(""),[f,g]=c.useState(null),[y,b]=c.useState(Ro);let j;t[2]!==u?(j=u.trim().toLowerCase(),t[2]=u,t[3]=j):j=t[3];const x=j;let h;e:{if(!n){let te;t[4]===Symbol.for("react.memo_cache_sentinel")?(te=[],t[4]=te):te=t[4],h=te;break e}let re;t[5]!==d?(re=[...d].sort(H4),t[5]=d,t[6]=re):re=t[6],h=re}const p=h;let w;if(t[7]!==l||t[8]!==p||t[9]!==e){const re=new Map;for(const te of p){const ee=gt(Is(te))??"",ue=re.get(ee);if(ue){ue.sessions.push(te);continue}re.set(ee,{directory:ee,label:ee?yr(ee,l)||ee:e("sessions.archivePage.otherProjects"),sessions:[te]})}w=[...re.values()].sort(U4),t[7]=l,t[8]=p,t[9]=e,t[10]=w}else w=t[10];const S=w;let N;e:{if(x){if(x.startsWith("ses_")){let ee;if(t[11]!==x||t[12]!==p){let ue;t[14]!==x?(ue=de=>de.id.toLowerCase()===x,t[14]=x,t[15]=ue):ue=t[15],ee=p.filter(ue),t[11]=x,t[12]=p,t[13]=ee}else ee=t[13];N=ee;break e}let te;t[16]!==x||t[17]!==p?(te=Cb(p,x,V4),t[16]=x,t[17]=p,t[18]=te):te=t[18],N=te;break e}if(f===null){N=p;break e}let re;t[19]!==S||t[20]!==f?(re=S.find(te=>te.directory===f)?.sessions??[],t[19]=S,t[20]=f,t[21]=re):re=t[21],N=re}const P=N;let C,T,R,M,F,K,D,U,A,E;if(t[22]!==d.length||t[23]!==S||t[24]!==P||t[25]!==l||t[26]!==x||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==y){F=Symbol.for("react.early_return_sentinel");e:{const re=P.slice(0,y);C=P.length-re.length;const te=d.length;let ee;t[45]===Symbol.for("react.memo_cache_sentinel")?(ee=be=>{g(be),b(Ro)},t[45]=ee):ee=t[45];const ue=ee;let de;t[46]!==i||t[47]!==r?(de=be=>{const Q=gt(Is(be));i(be.id,Q??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=de):de=t[48];const Te=de;let we;t[49]!==e||t[50]!==o?(we=be=>{o(be.id).then(Q=>{Q?_e.success(e("sessions.sidebar.session.restore.success")):_e.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=we):we=t[51];const fe=we;if(!n){F=null;break e}let Ne;t[52]!==e?(Ne=(be,Q,_,J,me,le,V)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:me,title:le,className:De("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",V?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",J?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:_})]}),V?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>Us.requestDelete({sessions:V,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:Q}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},be),t[52]=e,t[53]=Ne):Ne=t[53];const L=Ne;M="absolute inset-0 z-10 flex flex-col bg-background",T="flex min-h-0 flex-1";let oe;if(t[54]!==L||t[55]!==f||t[56]!==e||t[57]!==te){let be;t[59]===Symbol.for("react.memo_cache_sentinel")?(be=()=>ue(null),t[59]=be):be=t[59],oe=L("__all__",e("sessions.archivePage.allDirectories"),te,f===null,be),t[54]=L,t[55]=f,t[56]=e,t[57]=te,t[58]=oe}else oe=t[58];let ce;if(t[60]!==S||t[61]!==L||t[62]!==f){let be;t[64]!==L||t[65]!==f?(be=Q=>L(Q.directory||"__none__",Q.label,Q.sessions.length,f===Q.directory,()=>ue(Q.directory),Q.directory||void 0,Q.sessions),t[64]=L,t[65]=f,t[66]=be):be=t[66],ce=S.map(be),t[60]=S,t[61]=L,t[62]=f,t[63]=ce}else ce=t[63];t[67]!==oe||t[68]!==ce?(R=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[oe,ce]})}),t[67]=oe,t[68]=ce,t[69]=R):R=t[69],A="flex min-w-0 flex-1 flex-col";let pe;t[70]===Symbol.for("react.memo_cache_sentinel")?(pe=be=>{m(be),b(Ro)},t[70]=pe):pe=t[70];let Y;t[71]!==e?(Y=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=Y):Y=t[72];let ve;t[73]!==e?(ve=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=ve):ve=t[74];let Ee;t[75]!==u||t[76]!==Y||t[77]!==ve?(Ee=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Jd,{value:u,onSearch:pe,placeholder:Y,clearLabel:ve})}),t[75]=u,t[76]=Y,t[77]=ve,t[78]=Ee):Ee=t[78];let je;t[79]!==P.length||t[80]!==e?(je=P.length===1?e("sessions.archivePage.countSingle",{count:P.length}):e("sessions.archivePage.countPlural",{count:P.length}),t[79]=P.length,t[80]=e,t[81]=je):je=t[81];let ge;t[82]!==je?(ge=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:je}),t[82]=je,t[83]=ge):ge=t[83],t[84]!==Ee||t[85]!==ge?(E=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Ee,ge]}),t[84]=Ee,t[85]=ge,t[86]=E):E=t[86],U="min-h-0 flex-1 overflow-y-auto px-6 py-3",K="mx-auto w-full max-w-3xl space-y-0.5",D=re.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(x?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):re.map(be=>{const Q=gt(Is(be))??"",_=Q?yr(Q,l)||Q:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Te(be),role:"button",tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),Te(be))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:be.title||e("sessions.sidebar.session.untitled")}),x&&_?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:Q,children:_}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Ku(be.time?.archived??be.time?.updated??be.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),fe(be)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(B,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),Us.requestDelete({sessions:[be],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},be.id)})}t[22]=d.length,t[23]=S,t[24]=P,t[25]=l,t[26]=x,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=y,t[35]=C,t[36]=T,t[37]=R,t[38]=M,t[39]=F,t[40]=K,t[41]=D,t[42]=U,t[43]=A,t[44]=E}else C=t[35],T=t[36],R=t[37],M=t[38],F=t[39],K=t[40],D=t[41],U=t[42],A=t[43],E=t[44];if(F!==Symbol.for("react.early_return_sentinel"))return F;let W;t[87]!==C||t[88]!==e?(W=C>0?s.jsx("button",{type:"button",onClick:()=>b(K4),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=C,t[88]=e,t[89]=W):W=t[89];let k;t[90]!==W||t[91]!==K||t[92]!==D?(k=s.jsxs("div",{className:K,children:[D,W]}),t[90]=W,t[91]=K,t[92]=D,t[93]=k):k=t[93];let v;t[94]!==k||t[95]!==U?(v=s.jsx("div",{className:U,children:k}),t[94]=k,t[95]=U,t[96]=v):v=t[96];let I;t[97]!==v||t[98]!==A||t[99]!==E?(I=s.jsxs("div",{className:A,children:[E,v]}),t[97]=v,t[98]=A,t[99]=E,t[100]=I):I=t[100];let H;t[101]!==T||t[102]!==R||t[103]!==I?(H=s.jsxs("div",{className:T,children:[R,I]}),t[101]=T,t[102]=R,t[103]=I,t[104]=H):H=t[104];let $;return t[105]!==M||t[106]!==H?($=s.jsx("div",{className:M,children:H}),t[105]=M,t[106]=H,t[107]=$):$=t[107],$}function K4(t){return t+Ro}function V4(t){return[t.title]}function U4(t,e){return e.sessions.length-t.sessions.length}function H4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function G4(t){return t.homeDirectory}function q4(t){return t.unarchiveSession}function Y4(t){return t.setCurrentSession}function Q4(t){return t.setArchivePageOpen}function X4(t){return t.isArchivePageOpen}function J4(){const t=nt.c(18),{t:e}=At(),n=ye(t3),r=ye(e3),i=zt(Z4);let o;t[0]!==n?(o=y=>y.projects.find(b=>b.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=zt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(B,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==a||t[10]!==u?(m=s.jsx("div",{className:"flex items-center",children:s.jsxs(mt,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(np,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let g;return t[15]!==m||t[16]!==f?(g=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[m,f]})})}),t[15]=m,t[16]=f,t[17]=g):g=t[17],g}function Z4(t){return t.setActiveProjectIdOnly}function e3(t){return t.setNewWorktreeDialogOpen}function t3(t){return t.worktreesPageProjectId}function s3(t){const e=[],n=(r,i)=>{const o=gt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const n3=new Map,r3=t=>{const e=nt.c(23),{isVSCode:n}=t,r=Xo(),i=zt(o3),o=Zt(i3),l=ot(a3);let a;e[0]!==n?(a=R=>n?n3:R.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=ot(a),u=!n;let m;e[2]!==d||e[3]!==i||e[4]!==u?(m=lm(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=m):m=e[5];const f=m,g=ps(l3),y=ps(c3),b=ps(d3),j=`session-list-sync:${c.useId()}`;let x,h;e[6]!==j||e[7]!==r||e[8]!==o||e[9]!==l?(x=()=>(r.setBootstrapDemand(j,s3({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(j)),h=[j,r,o,l],e[6]=j,e[7]=r,e[8]=o,e[9]=l,e[10]=x,e[11]=h):(x=e[10],h=e[11]),c.useEffect(x,h);const p=c.useRef(null);let w,S;e[12]!==n||e[13]!==f?(w=()=>{const R=new Set(f),M=p.current;p.current=R;const F=M?[...R].filter(K=>!M.has(K)):n?[...R]:[];F.length&&Ia(F,Fo())},S=[n,f],e[12]=n,e[13]=f,e[14]=w,e[15]=S):(w=e[14],S=e[15]),c.useEffect(w,S);let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[16]=N):N=e[16],c.useEffect(u3,N);let P;e[17]!==y||e[18]!==g?(P=[...g,...y],e[17]=y,e[18]=g,e[19]=P):P=e[19];const C=P;let T;e[20]!==C||e[21]!==b?(T={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:C},e[20]=C,e[21]=b,e[22]=T):T=e[22],rp(T)};function o3(t){return t.projects}function i3(t){return t.currentDirectory}function a3(t){return t.currentSessionDirectory}function l3(t){return t.activeSessions}function c3(t){return t.archivedSessions}function d3(t){return t.status==="ready"}function u3(){let t=null,e=!1;const n=new Set,r=Dn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Jo(Fo());return}const o=[...n];n.clear(),o.length&&Ia(o,Fo())},500)});return()=>{t&&clearTimeout(t),r()}}const f3=In(()=>en(()=>import("./SettingsWindow-0vSQTxkV.js"),__vite__mapDeps([147,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,148,85,86,87,149,133,134,135,136,121,122,107,108,92,93,94,95,96,97,98,99,100,101,102,103,104,105,150,151,152])).then(t=>({default:t.SettingsWindow}))),m3=()=>{const t=nt.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],r3(e),op();const n=ye(h3),r=ye(p3),i=ye(g3),o=ye(b3),l=ye(x3),[a,d]=c.useState(!1);let u,m;t[1]!==o?(u=()=>{o&&d(!0)},m=[o],t[1]=o,t[2]=u,t[3]=m):(u=t[2],m=t[3]),c.useEffect(u,m);const f=ye(y3),g=ye(w3),y=ye(v3),b=ye(S3),j=ye(j3),x=ye(k3),h=Ru();let p;if(t[4]!==h||t[5]!==x){let _;t[7]!==x?(_=J=>J.id===x,t[7]=x,t[8]=_):_=t[8],p=h.find(_),t[4]=h,t[5]=x,t[6]=p}else p=t[6];const w=p;let S,N;t[9]!==w||t[10]!==x?(S=()=>{x&&!w&&ye.getState().setOpenGuestPage(null)},N=[x,w],t[9]=w,t[10]=x,t[11]=S,t[12]=N):(S=t[11],N=t[12]),c.useEffect(S,N);let P;t[13]===Symbol.for("react.memo_cache_sentinel")?(P=[],t[13]=P):P=t[13],c.useEffect(N3,P);const C=g||y||b||!!j||f||!!w;let T;t[14]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[14]=T):T=t[14],c.useEffect(P3,T);const{isMobile:R}=Pn();ip();let M,F;t[15]!==R||t[16]!==i?(M=()=>{ye.getState().isMobile!==R&&i(R)},F=[R,i],t[15]=R,t[16]=i,t[17]=M,t[18]=F):(M=t[17],F=t[18]),c.useEffect(M,F);let K,D,U,A,E;t[19]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(pj,{}),D=s.jsx(u0,{}),U=s.jsx(p0,{}),A=s.jsx(ap,{}),E=s.jsx(h4,{}),t[19]=K,t[20]=D,t[21]=U,t[22]=A,t[23]=E):(K=t[19],D=t[20],U=t[21],A=t[22],E=t[23]);let W;t[24]!==r?(W=r?s.jsx(lp,{}):null,t[24]=r,t[25]=W):W=t[25];let k;t[26]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(Wy,{}),t[26]=k):k=t[26];let v;t[27]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(zy,{}),t[27]=v):v=t[27];let I;t[28]!==n?(I=s.jsx(m4,{isVisible:n}),t[28]=n,t[29]=I):I=t[29];let H;t[30]!==R||t[31]!==n||t[32]!==I?(H=s.jsx($y,{isOpen:n,isMobile:R,className:"border-border",topBar:v,children:I}),t[30]=R,t[31]=n,t[32]=I,t[33]=H):H=t[33];let $;t[34]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(Ly,{}),t[34]=$):$=t[34];const re=C&&"invisible";let te;t[35]!==re?(te=De("absolute inset-0",re),t[35]=re,t[36]=te):te=t[36];const ee=!o&&!C;let ue;t[37]!==ee?(ue=s.jsx(ms,{children:s.jsx(su,{active:ee})}),t[37]=ee,t[38]=ue):ue=t[38];let de;t[39]!==te||t[40]!==ue?(de=s.jsx("div",{className:te,children:ue}),t[39]=te,t[40]=ue,t[41]=de):de=t[41];let Te;t[42]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx(ms,{children:s.jsx(cp,{})}),t[42]=Te):Te=t[42];let we;t[43]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(ms,{children:s.jsx(z4,{})}),t[43]=we):we=t[43];let fe;t[44]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(ms,{children:s.jsx(W4,{})}),t[44]=fe):fe=t[44];let Ne;t[45]!==b?(Ne=b&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ms,{children:s.jsx(dp,{})})}),t[45]=b,t[46]=Ne):Ne=t[46];let L;t[47]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(ms,{children:s.jsx(J4,{})}),t[47]=L):L=t[47];let oe;t[48]!==w?(oe=w&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ms,{children:s.jsx(Ex,{mode:`plugin:${w.id}`,surface:"page",item:null,onDismiss:D3})})}),t[48]=w,t[49]=oe):oe=t[49];let ce;t[50]!==de||t[51]!==Ne||t[52]!==oe?(ce=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[de,Te,we,fe,Ne,L,oe]}),t[50]=de,t[51]=Ne,t[52]=oe,t[53]=ce):ce=t[53];let pe;t[54]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(FS,{}),t[54]=pe):pe=t[54];let Y;t[55]!==ce?(Y=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[ce,pe]})})}),t[55]=ce,t[56]=Y):Y=t[56];let ve;t[57]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(ms,{children:s.jsx(GS,{})})}),t[57]=ve):ve=t[57];let Ee;t[58]===Symbol.for("react.memo_cache_sentinel")?(Ee=s.jsx(ms,{children:s.jsx(ox,{})}),t[58]=Ee):Ee=t[58];let je;t[59]!==Y?(je=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[$,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Y,ve,Ee]})]}),t[59]=Y,t[60]=je):je=t[60];let ge;t[61]!==H||t[62]!==je?(ge=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[H,je]}),t[61]=H,t[62]=je,t[63]=ge):ge=t[63];let be;t[64]!==o||t[65]!==l||t[66]!==a?(be=a?s.jsx(c.Suspense,{fallback:null,children:s.jsx(f3,{open:o,onOpenChange:l})}):null,t[64]=o,t[65]=l,t[66]=a,t[67]=be):be=t[67];let Q;return t[68]!==W||t[69]!==ge||t[70]!==be?(Q=s.jsx(up,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[K,D,U,A,E,W,k,ge,be]})}),t[68]=W,t[69]=ge,t[70]=be,t[71]=Q):Q=t[71],Q};function h3(t){return t.isSidebarOpen}function p3(t){return t.isolatedSpacesEnabled}function g3(t){return t.setIsMobile}function b3(t){return t.isSettingsDialogOpen}function x3(t){return t.setSettingsDialogOpen}function y3(t){return t.runOverviewKey!==null}function w3(t){return t.isScheduledTasksDialogOpen}function v3(t){return t.isArchivePageOpen}function S3(t){return t.isUsageStatsPageOpen}function j3(t){return t.worktreesPageProjectId}function k3(t){return t.openGuestPageId}function C3(){return ye.getState().setOpenGuestPage(null)}function N3(){return vr(C3)}function A3(){return ye.getState().closeMainSurfaces()}function P3(){const t=A3,e=ot.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function D3(){return ye.getState().setOpenGuestPage(null)}const um=12,I3=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],T3=t=>{const e=nt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,m=l===void 0?I3:l,f=lt.useRef(!1);let g,y;e[0]!==n||e[1]!==a?(g=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},y=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=y):(g=e[2],y=e[3]),lt.useEffect(g,y);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:um},E3),e[4]=b):b=e[4];const j=b;if(!n)return null;let x;e[5]!==i?(x=De("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=S=>{const N={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:j.map((P,C)=>{const T=P.x*S.radius,R=P.y*S.radius,M={"--translate-x":`${T}px`,"--translate-y":`${R}px`,"--particle-delay":`${P.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:M},`${S.id}-${C}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],h=m.map(w),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let p;return e[14]!==d||e[15]!==x||e[16]!==h?(p=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=x,e[16]=h,e[17]=p):p=e[17],p};function E3(t,e){const n=Math.PI*2*e/um;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const R3=t=>{const e=nt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=lt.useState(o),d=lt.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),a(M3)},e[4]=f):f=e[4];const g=f;let y;e[5]!==i?(y=()=>{m(),a(O3),d.current=window.setTimeout(()=>{a(B3),d.current=null},i)},e[5]=i,e[6]=y):y=e[6];const b=y;let j,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=()=>()=>m(),x=[m],e[7]=j,e[8]=x):(j=e[7],x=e[8]),lt.useEffect(j,x);let h;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==b?(h={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:b,dismissFireworks:g},e[9]=l.cycle,e[10]=l.isActive,e[11]=b,e[12]=h):h=e[12],h};function M3(t){return t.isActive?{...t,isActive:!1}:t}function O3(t){return{isActive:!0,cycle:t.cycle+1}}function B3(t){return t.isActive?{...t,isActive:!1}:t}const fm=c.createContext(void 0),F3=t=>{const e=nt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=R3();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(T3,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(fm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},O5=()=>{const t=c.useContext(fm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ka="openchamber_requests_in_flight",mm=1e3,L3=300*1e3,Go=Math.ceil(L3/mm),_3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ka)==="1"}catch{return!1}},hm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let $3=1;const z3=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},W3=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},pm=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},xr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},K3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=$3++;z3(o,Date.now());try{return await e(r,i)}finally{W3(o)}};window.fetch=n},kd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Ir=t=>{t.length>Go&&t.splice(0,t.length-Go)},V3=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=pm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(xr(e,50)),t.p90Samples.push(xr(e,90)),t.p99Samples.push(xr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Ir(t.samples),Ir(t.p50Samples),Ir(t.p90Samples),Ir(t.p99Samples),Ir(t.maxSamples),t.lastSampleAt=Date.now()},U3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(V3,mm))},Cd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Nd=t=>{if(!(typeof window>"u"))try{if(t){Cd(),kd(),window.localStorage.setItem(ka,"1"),window.__openchamberRequestsInFlight__=hm(),K3(),U3();return}window.localStorage.removeItem(ka),Cd(),kd(),delete window.__openchamberRequestsInFlight__}catch{}},H3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=hm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},Ca=()=>{if(typeof window>"u")return Ad();const t=window.__openchamberRequestsInFlight__;if(!_3()||!t)return Ad();const e=pm(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:xr(e,50),ageP90:xr(e,90),ageP99:xr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Go}},Ad=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Go});function G3(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const gm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Na=t=>`${(t/1e3).toFixed(2)} s`,cs=t=>{const e=nt.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Pd=t=>{const e=nt.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=At();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Q3,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?gm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let y;e[18]!==m||e[19]!==g?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,g]}),e[18]=m,e[19]=g,e[20]=y):y=e[20];let b;e[21]!==o?(b=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=b):b=e[22];let j;e[23]!==r.entries.length||e[24]!==b?(j=s.jsx(cs,{label:b,value:r.entries.length}),e[23]=r.entries.length,e[24]=b,e[25]=j):j=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let h;e[28]!==x||e[29]!==u?(h=s.jsx(cs,{label:x,value:u}),e[28]=x,e[29]=u,e[30]=h):h=e[30];let p;e[31]!==o?(p=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=p):p=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==o?(w=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=w):w=e[35];let S;e[36]!==p||e[37]!==w?(S=s.jsx(cs,{label:p,value:w}),e[36]=p,e[37]=w,e[38]=S):S=e[38];let N;e[39]!==h||e[40]!==S||e[41]!==j?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[j,h,S]}),e[39]=h,e[40]=S,e[41]=j,e[42]=N):N=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[y,N,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(bn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(P=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:P.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:P.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:P.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:P.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:P.total})})]})]},P.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Dd=t=>{const e=nt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(X3,0),u=r>0?52/r:0;let m;e[0]!==d||e[1]!==a?(m=S=>a-d+S,e[0]=d,e[1]=a,e[2]=m):m=e[2];const f=m;let g;e[3]!==u?(g=S=>56-S*u,e[3]=u,e[4]=g):g=e[4];const y=g;let b;e[5]!==l?(b=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=b):b=e[6];const j=`0 0 ${a} 56`;let x;e[7]!==a?(x=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=x):x=e[8];let h;if(e[9]!==n||e[10]!==f||e[11]!==y){let S;e[13]!==f||e[14]!==y?(S=(N,P)=>{const C=N.samples.length;if(C===0)return null;const T=N.samples.map((M,F)=>`${f(F)},${y(M).toFixed(2)}`),R=`M ${T.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${T.join(" L ")} L ${f(C-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:R,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},P)},e[13]=f,e[14]=y,e[15]=S):S=e[15],h=n.map(S),e[9]=n,e[10]=f,e[11]=y,e[12]=h}else h=e[12];let p;e[16]!==o||e[17]!==j||e[18]!==x||e[19]!==h?(p=s.jsxs("svg",{viewBox:j,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,h]}),e[16]=o,e[17]=j,e[18]=x,e[19]=h,e[20]=p):p=e[20];let w;return e[21]!==b||e[22]!==p?(w=s.jsxs("div",{className:"relative w-full",children:[b,p]}),e[21]=b,e[22]=p,e[23]=w):w=e[23],w},q3=t=>{const e=nt.c(100),{onClose:n}=t,{t:r}=At(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=ot(J3),u=zu(Z3),m=Nu(),f=Nb(eN),g=Ps(tN),[y,b]=c.useState(sN),[j,x]=c.useState(nN),[h,p]=c.useState(rN),w=[{label:"p50",current:h.ageP50,samples:h.p50Samples,color:"var(--status-success)"},{label:"p90",current:h.ageP90,samples:h.p90Samples,color:"var(--status-info)"},{label:"p99",current:h.ageP99,samples:h.p99Samples,color:"var(--status-warning)"},{label:"max",current:h.ageMax,samples:h.maxSamples,color:"var(--status-error)"}];let S;e[0]!==h.samples?(S=h.samples.reduce(oN,0),e[0]=h.samples,e[1]=S):S=e[1];const N=S,P=w.reduce(aN,0);let C;e[2]!==y.entries?(C=new Map,y.entries.forEach($e=>{C.set($e.metric,$e.count)}),e[2]=y.entries,e[3]=C):C=e[3];let T;e[4]!==C?(T=C.get("ui.message_list.render")??0,e[4]=C,e[5]=T):T=e[5];let R;e[6]!==C?(R=C.get("ui.message_list.render.streaming")??0,e[6]=C,e[7]=R):R=e[7];let M;e[8]!==C?(M=C.get("ui.chat_message.render")??0,e[8]=C,e[9]=M):M=e[9];let F;e[10]!==C?(F=C.get("ui.chat_message.render.streaming")??0,e[10]=C,e[11]=F):F=e[11];let K;e[12]!==C?(K=C.get("ui.chat_message.render.static_during_stream")??0,e[12]=C,e[13]=K):K=e[13];let D;e[14]!==C?(D=C.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=C,e[15]=D):D=e[15];let U;e[16]!==T||e[17]!==R||e[18]!==M||e[19]!==F||e[20]!==K||e[21]!==D?(U={messageListRender:T,messageListRenderStreaming:R,chatMessageRender:M,chatMessageRenderStreaming:F,chatMessageRenderStaticDuringStream:K,chatMessageRenderStaticOutsideActiveTurnDuringStream:D},e[16]=T,e[17]=R,e[18]=M,e[19]=F,e[20]=K,e[21]=D,e[22]=U):U=e[22];const A=U;let E,W;e[23]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{const $e=()=>{b(No()),x(Ao()),p(Ca())};$e();const Ue=window.setInterval($e,500);return()=>window.clearInterval(Ue)},E=[],e[23]=E,e[24]=W):(E=e[23],W=e[24]),c.useEffect(W,E);let k,v;e[25]!==l?(k=()=>{if(l==="idle")return;const $e=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout($e)},v=[l],e[25]=l,e[26]=k,e[27]=v):(k=e[26],v=e[27]),c.useEffect(k,v);let I=0,H=0,$=0;for(const $e of Object.keys(f)){const Ue=f[$e]??[];H=H+Ue.length;for(const ct of Ue)ct.role==="user"?$=$+1:ct.role==="assistant"&&(I=I+1)}let re;e[28]!==I||e[29]!==H||e[30]!==$?(re={assistant:I,total:H,user:$},e[28]=I,e[29]=H,e[30]=$,e[31]=re):re=e[31];const te=re;let ee;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==m||e[36]!==r){let $e;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?($e=Ue=>{const ct=f[Ue.id]??[];let pt=0,it=0;for(const yt of ct)yt.role==="user"?it=it+1:yt.role==="assistant"&&(pt=pt+1);const ft=u.get(Ue.id);return{id:Ue.id,title:Ue.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:pt,messageCount:ct.length,userMessageCount:it,isStreaming:ft?.isStreaming||!1,isZombie:ft?.isZombie||!1,backgroundCount:ft?.backgroundMessageCount||0,lastAccessed:ft?.lastAccessedAt||0,isCurrent:Ue.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=$e):$e=e[42],ee=m.map($e).sort(lN),e[32]=d,e[33]=f,e[34]=u,e[35]=m,e[36]=r,e[37]=ee}else ee=e[37];const ue=ee;let de;e[43]!==f?(de=Object.keys(f),e[43]=f,e[44]=de):de=e[44];const Te=de.length;let we;e[45]===Symbol.for("react.memo_cache_sentinel")?(we=async()=>{try{const $e={generatedAt:new Date().toISOString(),ui:No(),vscode:Ao()};await navigator.clipboard.writeText(JSON.stringify($e,null,2)),a("copied")}catch{a("error")}},e[45]=we):we=e[45];const fe=we,Ne=Pb,L="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let oe;e[46]===Symbol.for("react.memo_cache_sentinel")?(oe={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=oe):oe=e[46];let ce;e[47]!==i?(ce=G3(i),e[47]=i,e[48]=ce):ce=e[48];let pe;e[49]!==ce?(pe=s.jsx(B,{name:ce,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=ce,e[50]=pe):pe=e[50];let Y;e[51]!==r?(Y=r("memoryDebugPanel.title"),e[51]=r,e[52]=Y):Y=e[52];let ve;e[53]!==Y?(ve=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Y}),e[53]=Y,e[54]=ve):ve=e[54];let Ee;e[55]!==pe||e[56]!==ve?(Ee=s.jsxs("div",{className:"flex items-center gap-2",children:[pe,ve]}),e[55]=pe,e[56]=ve,e[57]=Ee):Ee=e[57];let je;e[58]!==i?(je=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(mt,{size:"xs",variant:"ghost",onClick:fe,children:s.jsx(B,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(mt,{size:"xs",variant:"ghost",onClick:()=>{uh(),b(No()),x(Ao())},children:s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=je):je=e[59];let ge;e[60]!==i?(ge=i==="requests"?s.jsx(mt,{size:"xs",variant:"ghost",onClick:()=>{H3(),p(Ca())},children:s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=ge):ge=e[61];let be;e[62]!==n?(be=n?s.jsx(mt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(B,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=be):be=e[63];let Q;e[64]!==je||e[65]!==ge||e[66]!==be?(Q=s.jsxs("div",{className:"flex items-center gap-1",children:[je,ge,be]}),e[64]=je,e[65]=ge,e[66]=be,e[67]=Q):Q=e[67];let _;e[68]!==Ee||e[69]!==Q?(_=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Ee,Q]}),e[68]=Ee,e[69]=Q,e[70]=_):_=e[70];let J;e[71]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=J):J=e[71];const me=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let V;e[73]!==r?(V=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=V):V=e[74];let Z;e[75]!==me||e[76]!==V?(Z=s.jsx(mt,{size:"sm",variant:me,className:"flex-1",onClick:le,children:V}),e[75]=me,e[76]=V,e[77]=Z):Z=e[77];const G=i==="streaming"?"secondary":"ghost";let ie;e[78]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>o("streaming"),e[78]=ie):ie=e[78];let Se;e[79]!==r?(Se=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=Se):Se=e[80];let se;e[81]!==G||e[82]!==Se?(se=s.jsx(mt,{size:"sm",variant:G,className:"flex-1",onClick:ie,children:Se}),e[81]=G,e[82]=Se,e[83]=se):se=e[83];const Me=i==="requests"?"secondary":"ghost";let He;e[84]===Symbol.for("react.memo_cache_sentinel")?(He=()=>o("requests"),e[84]=He):He=e[84];let We;e[85]!==r?(We=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=We):We=e[86];let Le;e[87]!==Me||e[88]!==We?(Le=s.jsx(mt,{size:"sm",variant:Me,className:"flex-1",onClick:He,children:We}),e[87]=Me,e[88]=We,e[89]=Le):Le=e[89];let Ve;e[90]!==Z||e[91]!==se||e[92]!==Le?(Ve=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:J,children:[Z,se,Le]}),e[90]=Z,e[91]=se,e[92]=Le,e[93]=Ve):Ve=e[93];const O=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(cs,{label:r("memoryDebugPanel.metric.totalMessages"),value:te.total}),s.jsx(cs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Te} / ${$l.MAX_SESSIONS}`}),s.jsx(cs,{label:r("memoryDebugPanel.metric.userMessages"),value:te.user}),s.jsx(cs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:te.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:Ab()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:$l.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:g})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(bn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:ue.map($e=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:$e.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:$e.title}),$e.isStreaming?s.jsx(B,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,$e.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:$e.assistantMessageCount,user:$e.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:$e.messageCount})}),$e.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",$e.backgroundCount]}):null]})]},$e.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(mt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(cN),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:te,sessionMessageRoleCounts:ue.map(dN),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(jt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(mt,{size:"xs",variant:"outline",onClick:fe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(cs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(cs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:j.entries.length}),s.jsx(cs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:A.messageListRender}),s.jsx(cs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:A.messageListRenderStreaming}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:A.chatMessageRender}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:A.chatMessageRenderStreaming}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:A.chatMessageRenderStaticDuringStream}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:A.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Pd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),j.entries.length>0?s.jsx(Pd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:j,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(cs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${h.totalSettled} / ${h.totalStarted}`}),s.jsx(cs,{label:r("memoryDebugPanel.requests.tracking"),value:h.startedAt?gm(h.durationMs):r("memoryDebugPanel.common.idle")})]}),h.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.peak})]})]}),s.jsx(Dd,{series:[{samples:h.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:h.peak}),maxLabel:`${N}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Na(h.peakAgeMs)})]}),s.jsx(Dd,{series:w.map(uN),peak:P,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Na(P)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:w.map(fN)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:h.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let he;return e[94]!==Ne||e[95]!==oe||e[96]!==_||e[97]!==Ve||e[98]!==O?(he=s.jsxs(Ne,{className:L,style:oe,children:[_,Ve,O]}),e[94]=Ne,e[95]=oe,e[96]=_,e[97]=Ve,e[98]=O,e[99]=he):he=e[99],he},Y3=q3;function Q3(t,e){return t+e.count}function X3(t,e){return Math.max(t,e.samples.length)}function J3(t){return t.currentSessionId}function Z3(t){return t.sessionMemoryState}function eN(t){return t.message}function tN(t){return t.totalRequestCount}function sN(){return No()}function nN(){return Ao()}function rN(){return Ca()}function oN(t,e){return Math.max(t,e)}function iN(t,e){return Math.max(t,e)}function aN(t,e){return e.samples.reduce(iN,t)}function lN(t,e){return e.lastAccessed-t.lastAccessed}function cN(t){return{id:t.id,title:t.title}}function dN(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function uN(t){return{samples:t.samples,color:t.color}}function fN(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Na(t.current)})]},t.label)}const mN=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},hN=async()=>{const t=mN()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Id="openchamber:menu-action",Bi="openchamber:check-for-updates",pN=t=>{const e=ot(h=>h.openNewSessionDraft),n=ye(h=>h.toggleCommandPalette),r=ye(h=>h.setCommandPaletteOpen),i=ye(h=>h.toggleHelpDialog),o=ye(h=>h.toggleSidebar),l=ye(h=>h.setSessionSwitcherOpen),a=ye(h=>h.setSettingsDialogOpen),d=ye(h=>h.setAboutDialogOpen),u=Fr(h=>h.checkForUpdates),{setThemeMode:m}=qn(),f=c.useRef(!1),g=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:h,error:p}=Fr.getState();if(p){_e.error("Failed to check for updates",{description:p});return}h||_e.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),y=c.useCallback(()=>{Us.requestDirectoryDialog()},[]),b=c.useCallback(h=>{const p=Db();if(p.length===0)return;const w=ot.getState().currentSessionId,S=p.findIndex(C=>C.id===w);let N=h>0?0:p.length-1;S>=0&&(N=(S+h+p.length)%p.length);const P=p[N];P&&(l(!1),ot.getState().setCurrentSession(P.id))},[l]),j=c.useCallback(h=>{const{activeProjectId:p,projects:w,setActiveProject:S}=zt.getState();if(w.length===0)return;const N=w.findIndex(T=>T.id===p);let P=h>0?0:w.length-1;N>=0&&(P=(N+h+w.length)%w.length);const C=w[P];C&&S(C.id)},[]),x=c.useCallback(h=>{switch(h){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=ot.getState(),w=Zt.getState().currentDirectory;e(p.currentSessionId&&w?{directoryOverride:w}:void 0)}break;case"new-worktree-session":l(!1),Tu();break;case"change-workspace":y();break;case"toggle-right-sidebar":{const p=Zt.getState().currentDirectory;if(!p)break;const w=ye.getState(),S=Fn(p),N=w.contextPanelByDirectory[S];N?.isOpen?w.closeContextPanel(S):N?.activeTabId?w.setActiveContextPanelTab(S,N.activeTabId):w.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const p=Zt.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"git");break}case"open-right-sidebar-files":{const p=Zt.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"file");break}case"toggle-terminal":{const p=Zt.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"terminal");break}case"toggle-terminal-expanded":{const p=Zt.getState().currentDirectory;if(!p)break;const w=Fn(p),S=ye.getState(),N=S.contextPanelByDirectory[w];(N?.isOpen?N.tabs.find(C=>C.id===N.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(w,"terminal"),S.toggleContextPanelExpanded(w);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||hN();break}case"theme-light":m("light");break;case"theme-dark":m("dark");break;case"theme-system":m("system");break;case"add-selection-to-chat":Ib();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Zt.getState().goBack();break;case"go-forward":Zt.getState().goForward();break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":j(-1);break;case"next-project":j(1);break;case"help-dialog":i();break;case"download-logs":{Eu().catch(()=>{_e.error("Failed to collect OpenCode status")});break}}},[y,j,b,t,e,d,l,r,a,m,n,i,o]);c.useEffect(()=>{const h=w=>{const S=w.detail;S&&x(S)},p=()=>{g()};return window.addEventListener(Id,h),window.addEventListener(Bi,p),()=>{window.removeEventListener(Id,h),window.removeEventListener(Bi,p)}},[x,g]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let w=null,S=null;return p("openchamber:menu-action",N=>{const P=N?.payload;typeof P=="string"&&x(P)}).then(N=>{w=N}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Bi))}).then(N=>{S=N}).catch(()=>{}),()=>{(async()=>{try{const P=w?.();P instanceof Promise&&await P}catch{}try{const P=S?.();P instanceof Promise&&await P}catch{}})()}},[x])},gN="openchamber:tray-action",bN=5e3,xN=500,yN=20,Td=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ed=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,bm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},xm=t=>t.title.trim()||"Question",wN=(t,e)=>$a(t,e,Ur.getState().ids,Ba.getState().rankById),vN=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},SN=(t,e,n,r,i)=>{if(!t)return"";const o=ru(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||vN(t),d=Po(t);let u=d&&i.get(d)||"";if(!u){for(const[m,f]of Xn.getState().directories)if(Po(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(g=>Po(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},jN=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Eb){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:Mb(m),value:Rb(f.valueLabel,g)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},kN=async()=>{try{if(qo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=hn();if(e&&gl(e,t))return"Local OpenChamber";const r=(await Ld()).hosts.find(i=>e?gl(e,fh(i)):!1);return r?.label?.trim()?_d(r.label.trim()):"Instance"}catch{return""}},CN=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Xi()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(Po(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",g=t.get(d);(!g||g==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:bm(m),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"form",id:m.id,sessionId:f,sessionTitle:"",label:xm(m),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},NN=(t,e)=>{const n=Hu.getState().index.session,r=ps.getState().activeSessions,i=new Map;for(const p of r)if(p?.id&&p.parentID){const w=i.get(p.parentID)??[];w.push(p.id),i.set(p.parentID,w)}const o=p=>{const w=[],S=[...i.get(p)??[]],N=new Set;for(;S.length;){const P=S.pop();N.has(P)||(N.add(P),w.push(P),S.push(...i.get(P)??[]))}return w},l=ye.getState();let a=0;if(l.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let w=n.unseenCount[p.id]??0;w===0&&l.notifyOnSubtasks&&(w=o(p.id).reduce((S,N)=>S+(n.unseenCount[N]??0),0)),w>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=CN(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const m=Va.getState().statusById,f=p=>{const w=d.statusById.get(p);return w&&w!=="idle"?w:m.get(p)?.status.type??w??"idle"},g=p=>{const w=p.map(S=>f(S));return w.includes("busy")?"busy":w.includes("retry")?"retry":"idle"},y=zt.getState().projects,b=ot.getState().availableWorktreesByProject,j=r.filter(p=>p?.id&&!p.parentID).slice().sort(wN).slice(0,yN).map(p=>{const w=[p.id,...o(p.id)],S=Is(p)??"";return{id:p.id,title:p.title||"Untitled session",status:g(w),branch:S?d.branchByDirectory.get(S)??"":"",unseen:w.reduce((N,P)=>N+(n.unseenCount[P]??0),0),hasError:w.some(N=>n.unseenHasError[N]??!1),directory:S,subtitle:SN(S,p,y,b,d.branchByDirectory)}}),x=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),h=new Set(x.map(p=>p.id));for(const[p,w]of Gu.getState().bySession){const S=u.get(p)||"";for(const N of w.permissions)h.has(N.id)||(h.add(N.id),x.push({kind:"permission",id:N.id,sessionId:p,sessionTitle:S,label:bm(N),directory:w.directory}));for(const N of w.forms)h.has(N.id)||(h.add(N.id),x.push({kind:"form",id:N.id,sessionId:p,sessionTitle:S,label:xm(N),directory:w.directory}))}return{sessions:j,approvals:x,instanceName:t,usage:jN(),dockBadgeCount:a}},AN=()=>{c.useEffect(()=>{if(!Td()||!Kr())return;const t=Ed();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const C=NN(i,t),T=JSON.stringify(C);T!==n&&(n=T,Nn("desktop_tray_update",C))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},xN))},a=Hu.subscribe(()=>l()),d=ps.subscribe(()=>l()),u=ye.subscribe((C,T)=>{(C.dockBadgeEnabled!==T.dockBadgeEnabled||C.notifyOnSubtasks!==T.notifyOnSubtasks)&&l()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),m;kN().then(C=>{e||(i=C,o())});const f=new Map,g=()=>{if(e)return;let C;try{C=Xi()}catch{return}const T=new Set;for(const[R,M]of C.children.entries())T.add(R),f.has(R)||f.set(R,M.subscribe(()=>l()));for(const[R,M]of f)T.has(R)||(M(),f.delete(R))};let y=null;try{y=Xi().subscribeRegistry(()=>{g(),l()})}catch{}g();const b=zt.subscribe(()=>l()),j=ot.subscribe(()=>l()),x=Xn.subscribe(()=>l()),h=Va.subscribe(()=>l()),p=Gu.subscribe(()=>l()),w=Ba.subscribe(()=>l()),S=Ur.subscribe(()=>l()),N=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:C,results:T}=ur.getState();C.length>0&&C.some(M=>!T.some(F=>F.providerId===M))&&ur.getState().fetchQuotas(C)});const P=window.setInterval(()=>{g(),o()},bN);return o(),()=>{m(),window.clearInterval(P),b(),j(),x(),h(),p(),w(),S(),N(),y?.();for(const C of f.values())C();f.clear()}},[]),c.useEffect(()=>{if(!Td()||!Ed()||!Kr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Tb(i.sessionId,i.id,i.response).catch(()=>{_e.error("Failed to respond to permission request")})};let r=null;return e(gN,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},PN=30*6e4,DN=(t,e,n=PN)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Tr=null;const IN=()=>{if(Tr)return Tr;const t=qt();return Tr=(async()=>{const e=await mr.getHostSessionStatusSnapshot();if(!e||qt()!==t)return;const n=Va.getState(),r=ps.getState().entityById,i=DN(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Is(a):null}});for(const[l,a]of i)Ob(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Is(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Bb(o)})().finally(()=>{Tr=null}),Tr},TN=45e3,EN=[1e3,2e3,4e3],RN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const m=await u().catch(()=>!1);if(i)return;a||=m;const f=a?void 0:EN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??TN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},MN=t=>{const e=nt.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=ON;let o=i();const l=vr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function ON(){const t=qt();let e=!0;const n=async i=>(i?await Fb(Fo()):await Jo(),!e||qt()!==t?!1:(IN(),ps.getState().status==="ready")),r=RN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const BN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,FN=t=>{const e=nt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||mn()||!Pa()||!globalThis.window))return Dn(LN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function LN(t){if(t.type!=="notification")return;const e=ye.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&BN())return;Fd()?.notifications?.notifyAgentCompletion(t.payload)}const _N=6e4,$N=t=>{const e=nt.c(10),n=ye(zN),r=Lb(WN),o=fp(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:_N})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Dn(m=>{m.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function zN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function WN(t){return t.load}const KN=()=>{const t=nt.c(4),{t:e}=At(),n=ye(VN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Dn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),_e.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function VN(t){return t.setBrowserProvider}const Rd="pwa-install-toast-shown",Md="pwa-install-toast-dismissed",UN=()=>{const t=nt.c(6),{browserTab:e}=mp(),{t:n}=At(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!Pa()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(_e.dismiss(u),u=null)},f=async()=>{if(!d)return;const b=d;d=null,m(),await b.prompt();const{outcome:j}=await b.userChoice;j==="accepted"&&_e.success(r.current("pwa.installPrompt.started"))},g=b=>{const j=b;if(typeof j.prompt!="function")return;j.preventDefault(),d=j;const x=Oo(),h=mh();hp({dismissed:x.getItem(Md),sessionShown:h.getItem(Rd),hasActiveToast:u!==null})&&(h.setItem(Rd,"true"),u=_e.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Oo().setItem(Md,"true"),m()}}}))},y=()=>{d=null,m(),_e.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",y)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},HN=({open:t,onOpenChange:e})=>{const{t:n}=At(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[m,f]=c.useState(!1),[g,y]=c.useState(null),[b,j]=c.useState(!1);c.useCallback(async()=>{},[g,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const p=await as("/api/system/info");if(p.ok){const w=await p.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){o(w.openchamberVersion);return}}}catch{}o(await _b())})()},[t]),c.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const w=await as("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const S=await w.json().catch(()=>null),N=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!h&&N&&a(N)}catch{}})(),()=>{h=!0}},[t]),c.useEffect(()=>{{y(null),j(!1);return}},[t,r]);const x=i;return s.jsx(ks,{open:t,onOpenChange:e,children:s.jsx(Cs,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Au,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(B,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(B,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(B,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Aa="project-config-invalid",GN=()=>{const t=nt.c(9),{t:e}=At(),n=Wt(qN);let r;t[0]!==n?(r=g=>g.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const i=Wt(r),[o,l]=lt.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const g=Wt.getState(),y=g.activeDirectoryKey;l(!0),Promise.all([g.loadProviders({directory:y,source:"projectConfigError:retry"}),g.loadAgents({directory:y,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,m;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){_e.dismiss(Aa);return}_e.error(e("projectConfigError.toast.title"),{id:Aa,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&s.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:g=>{g.preventDefault(),o||d()}}})},m=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=m):(u=t[6],m=t[7]),lt.useEffect(u,m);let f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[8]=f):f=t[8],lt.useEffect(QN,f),null};function qN(t){return t.activeDirectoryKey}function YN(){_e.dismiss(Aa)}function QN(){return YN}const XN="\x1B",JN=new RegExp(`${XN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Co=Hn().transform(t=>t.replace(JN,"").trim()).nullish(),ZN=Yl({isOpenCodeReady:Ql().optional(),openCodeRunning:Ql().optional(),lastOpenCodeError:Co,opencodeBinaryResolved:Co,lastOpenCodeLaunchDiagnostics:Yl({sourceBinary:Co,binary:Co}).nullish()}),e5=async(t,e=as)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=ZN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},t5=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},Od=In(()=>en(()=>import("./OnboardingScreen-DdB_pV9d.js"),__vite__mapDeps([153,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.OnboardingScreen}))),s5=()=>{const t=nt.c(3),e=ye(l5),n=ye(c5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(HN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},n5=t=>{const e=nt.c(33),{onRetry:n,isRetrying:r}=t,{t:i}=At(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const N=new AbortController,P=qt(),C=setTimeout(()=>N.abort(),5e3);return e5(N.signal).then(T=>{!N.signal.aborted&&qt()===P&&l(T)}).catch(d5).finally(()=>clearTimeout(C)),()=>{N.abort(),clearTimeout(C)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=Wt(u5),m=o?null:u?.message??null;let f;e[2]!==i?(f=i("startup.initRecovery.title"),e[2]=i,e[3]=f):f=e[3];let g;e[4]!==f?(g=s.jsx("h1",{className:"typography-title text-foreground",children:f}),e[4]=f,e[5]=g):g=e[5];let y;e[6]!==o||e[7]!==u||e[8]!==i?(y=i(t5(o,u)),e[6]=o,e[7]=u,e[8]=i,e[9]=y):y=e[9];let b;e[10]!==y?(b=s.jsx("p",{className:"typography-body text-muted-foreground",children:y}),e[10]=y,e[11]=b):b=e[11];let j;e[12]!==g||e[13]!==b?(j=s.jsxs("div",{className:"flex flex-col gap-2",children:[g,b]}),e[12]=g,e[13]=b,e[14]=j):j=e[14];let x;e[15]!==m||e[16]!==i?(x=m&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:m})]}),e[15]=m,e[16]=i,e[17]=x):x=e[17];let h;e[18]!==o||e[19]!==i?(h=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=h):h=e[20];let p;e[21]!==r||e[22]!==i?(p=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=p):p=e[23];let w;e[24]!==r||e[25]!==n||e[26]!==p?(w=s.jsx(mt,{type:"button",onClick:n,disabled:r,children:p}),e[24]=r,e[25]=n,e[26]=p,e[27]=w):w=e[27];let S;return e[28]!==w||e[29]!==j||e[30]!==x||e[31]!==h?(S=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[j,x,h,w]})}),e[28]=w,e[29]=j,e[30]=x,e[31]=h,e[32]=S):S=e[32],S},Bd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",r5=()=>{if(typeof window>"u"||!Tx())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},o5=t=>{const e=nt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=Zt(f5),l=ot(m5),a=ot(h5),d=Ub(),u=c.useRef(null);let m;e[0]!==n.directory?(m=Bd(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let g;e[2]!==o?(g=Bd(o),e[2]=o,e[3]=g):g=e[3];const y=g;let b,j;if(e[4]!==y||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(b=()=>{if(r||f&&y!==f)return;const N=`${f}
885
+ `)?(M(it),T(!0)):T(!1);return}T(!1)},[]),me=lt.useCallback(O=>{p(he=>({...he,execution:{...he.execution,prompt:O}}))},[]),le=lt.useCallback(O=>{const he=h.execution.prompt,Ue=$.current?.selectionStart??he.length,pt=he.substring(0,Ue).lastIndexOf("@"),it=O.relativePath&&O.relativePath.trim().length>0?O.relativePath.trim():O.path||O.name,ft=pt!==-1?pt:Ue,yt=`${he.substring(0,ft)}@${it} ${he.substring(Ue)}`,ht=ft+it.length+2;me(yt),T(!1),M(""),requestAnimationFrame(()=>{const bt=$.current;bt&&(bt.selectionStart=ht,bt.selectionEnd=ht,bt.focus()),J(yt,ht)})},[h.execution.prompt,me,J]),V=lt.useCallback(O=>{const he=h.execution.prompt,Ue=$.current?.selectionStart??he.length,pt=he.substring(0,Ue).lastIndexOf("@"),it=pt!==-1?pt:Ue,ft=`${he.substring(0,it)}@${O} ${he.substring(Ue)}`,yt=it+O.length+2;me(ft),T(!1),M(""),requestAnimationFrame(()=>{const ht=$.current;ht&&(ht.selectionStart=yt,ht.selectionEnd=yt,ht.focus()),J(ft,yt)})},[h.execution.prompt,me,J]),Z=lt.useCallback(O=>{const he=`/${O.name} `;me(he),K(!1),U(""),E(!1),requestAnimationFrame(()=>{const $e=$.current;$e&&($e.focus(),$e.selectionStart=$e.value.length,$e.selectionEnd=$e.value.length),J(he,he.length)})},[me,J]),G=lt.useCallback((O,he)=>{const $e=h.execution.prompt,ct=$.current?.selectionStart??$e.length,it=$e.substring(0,ct).lastIndexOf("#"),ft=it!==-1?it:ct,yt=`${$e.substring(0,ft)}#${he} ${$e.substring(ct)}`,ht=ft+he.length+2;me(yt),E(!1),k(""),requestAnimationFrame(()=>{const bt=$.current;bt&&(bt.selectionStart=ht,bt.selectionEnd=ht,bt.focus()),J(yt,ht)})},[h.execution.prompt,me,J]),ie=lt.useCallback(O=>{if(F&&te.current&&(O.key==="Enter"||O.key==="ArrowUp"||O.key==="ArrowDown"||O.key==="Escape"||O.key==="Tab")){O.preventDefault(),te.current.handleKeyDown(O.key);return}C&&re.current&&(O.key==="Enter"||O.key==="ArrowUp"||O.key==="ArrowDown"||O.key==="Escape"||O.key==="Tab")&&(O.preventDefault(),re.current.handleKeyDown(O.key)),A&&ee.current&&(O.key==="Enter"||O.key==="ArrowUp"||O.key==="ArrowDown"||O.key==="Escape"||O.key==="Tab")&&(O.preventDefault(),ee.current.handleKeyDown(O.key))},[F,C,A]),Se=lt.useCallback(async()=>{const O=P4(h,o);if(O){_e.error(O);return}const he={...h.id?{id:h.id}:{},name:h.name.trim(),enabled:h.enabled,schedule:{kind:h.schedule.kind,timezone:h.schedule.timezone.trim(),...h.schedule.kind==="cron"?{cron:h.schedule.cronExpression.trim()}:h.schedule.kind==="once"?{date:h.schedule.onceDate,time:h.schedule.onceTime}:{times:D4(h.schedule.times),...h.schedule.kind==="weekly"?{weekdays:h.schedule.weekdays}:{}}},execution:{prompt:h.execution.prompt,providerID:h.execution.providerID,modelID:h.execution.modelID,...h.execution.variant.trim()?{variant:h.execution.variant.trim()}:{},...h.execution.agent.trim()?{agent:h.execution.agent.trim()}:{},...h.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...h.execution.goalEnabled?{goalEnabled:!0}:{},...h.execution.goalEnabled&&h.execution.goalTokenBudget?{goalTokenBudget:h.execution.goalTokenBudget}:{}},...h.state?{state:h.state}:{}};S(!0);try{await i(he),r(!1)}catch($e){_e.error($e instanceof Error?$e.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[h,r,i,o]),se=lt.useId(),Me=lt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),He=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),We=o("sessions.scheduledTasks.editor.description"),Le=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Wn,{id:"sched-name",value:h.name,onChange:O=>p(he=>({...he,name:O.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(ln,{value:h.schedule.kind,onValueChange:O=>{p(he=>({...he,schedule:{...he.schedule,kind:O,...O==="cron"&&!he.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{children:O=>o(O==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":O==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":O==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(dn,{children:[s.jsx(ds,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ds,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ds,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ds,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),h.schedule.kind==="cron"?s.jsx(I4,{draft:h,setDraft:p,locale:l,t:o}):h.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:H,children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:De(gb({size:"default"}),"w-fit max-w-full"),onClick:()=>P(O=>!O),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(B,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:x4(h.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>I(O=>gd(O,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:be,children:s.jsx(B,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(v)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>I(O=>gd(O,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(B,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:Q.map((O,he)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:O},`${O}-${he}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:y4(v,we).map(({date:O,inCurrentMonth:he})=>{const $e=pd(O),Ue=$e===h.schedule.onceDate,ct=vd(O,Ee),pt=O.getTime()<Ee.getTime(),it=Ue?"bg-interactive-selection text-interactive-selection-foreground":pt?"text-muted-foreground/40":he?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{pt||(_($e),P(!1))},disabled:pt,className:["h-8 rounded-md typography-ui-label",it,ct&&!Ue?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",pt?"cursor-not-allowed opacity-45":""].join(" "),children:O.getDate()},$e)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:ge||""}),s.jsx(mt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{_(pd(Ee)),I(new Date(Ee.getFullYear(),Ee.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(yd,{value:h.schedule.onceTime,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:O=>p(he=>({...he,schedule:{...he.schedule,onceTime:O}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ln,{value:h.schedule.timezone,onValueChange:O=>{p(he=>({...he,schedule:{...he.schedule,timezone:O}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{})}),s.jsx(dn,{children:ja.map(O=>s.jsx(ds,{value:O,children:O},O))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[h.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:fe.map(O=>{const he=h.schedule.weekdays.includes(O.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",he?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(Lr,{checked:he,onChange:$e=>ce(O.value,$e),ariaLabel:O.label}),s.jsx("button",{type:"button",onClick:()=>ce(O.value,!he),className:"group-hover:text-foreground",children:O.label})]},O.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:h.schedule.times.map((O,he)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yd,{value:O,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:$e=>pe(he,$e)}),h.schedule.times.length>1?s.jsx(mt,{type:"button",size:"icon",variant:"ghost",onClick:()=>Y(he),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(B,{name:"close",className:"h-4 w-4"})}):null]},he))}),s.jsx("div",{children:s.jsxs(mt,{type:"button",size:"sm",variant:"outline",onClick:ve,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ln,{value:h.schedule.timezone,onValueChange:O=>{p(he=>({...he,schedule:{...he.schedule,timezone:O}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{})}),s.jsx(dn,{children:ja.map(O=>s.jsx(ds,{value:O,children:O},O))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(bb,{providerId:h.execution.providerID,modelId:h.execution.modelID,onChange:(O,he)=>{p($e=>({...$e,execution:{...$e.execution,providerID:O,modelID:he,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(ln,{value:oe,disabled:!L,onValueChange:O=>{p(he=>({...he,execution:{...he.execution,variant:O==="__default"?"":O}}))},children:[s.jsx(cn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Js,{children:O=>O==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):O})}),s.jsxs(dn,{children:[s.jsx(ds,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Ne.map(O=>s.jsx(ds,{value:O,children:O},O))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(xs,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(xb,{agentName:h.execution.agent,filter:O=>yb(O.mode),onChange:O=>p(he=>({...he,execution:{...he.execution,agent:O}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(xs,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(Er,{id:"sched-prompt",ref:$,value:h.execution.prompt,onChange:O=>{const he=O.target.value;me(he);const $e=O.target.selectionStart??he.length;J(he,$e)},onKeyDown:ie,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),F?s.jsx(wb,{ref:te,searchQuery:D,onCommandSelect:Z,onClose:()=>K(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,C?s.jsx(vb,{ref:re,searchQuery:R,onFileSelect:le,onAgentSelect:V,onClose:()=>T(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,A?s.jsx(Sb,{ref:ee,searchQuery:W,onSnippetSelect:G,onClose:()=>E(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),h.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(Lr,{checked:h.execution.goalTokenBudget!==null,onChange:O=>p(he=>({...he,execution:{...he.execution,goalTokenBudget:O?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),h.execution.goalTokenBudget!==null?s.jsx(jb,{value:h.execution.goalTokenBudget,onValueChange:O=>{typeof O=="number"&&Number.isFinite(O)&&O>0&&p(he=>({...he,execution:{...he.execution,goalTokenBudget:Math.floor(O)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Ve=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(Lr,{checked:h.enabled,onChange:O=>p(he=>({...he,enabled:O})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:De(md),onClick:()=>p(O=>({...O,execution:{...O.execution,permissionAutoAccept:!O.execution.permissionAutoAccept}})),"aria-pressed":h.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:h.execution.permissionAutoAccept?s.jsx(B,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(B,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:De(md,h.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>p(O=>({...O,execution:{...O.execution,goalEnabled:!O.execution.goalEnabled}})),"aria-pressed":h.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:h.execution.goalEnabled?s.jsx(B,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(B,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(mt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:w,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(mt,{type:"button",size:"sm",onClick:Se,disabled:w,children:o(w?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return x?s.jsx(Qo,{open:e,title:He,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:O=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:He}),O]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:We})]}),footer:Ve,children:Le}):s.jsx(ks,{open:e,onOpenChange:O=>{!O&&Me()||r(O)},children:s.jsxs(Cs,{"aria-describedby":se,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(_s,{id:se,className:"sr-only",children:We}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Ls,{className:"typography-ui-label font-medium text-foreground",children:He}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:We})]})}),s.jsx(ju,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Le})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:Ve})})]})})}function E4(t){return jr(t,{min:0,max:23})}function R4(t,e){return jr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function M4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function O4(t){return s.jsx(ds,{value:t,children:t},t)}const B4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},F4=(t,e)=>{const n=B4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},L4=(t,e)=>!t||!Number.isFinite(t)?"":kb(t,e),jd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),g=Math.round(r%o/i),y=g>0?`${f}h ${g}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:y}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:y})}const d=Math.floor(r/l),u=Math.round(r%l/o),m=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:m}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:m})},_4={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},$4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function z4(){const{t}=At(),e=ye(k=>k.isScheduledTasksDialogOpen),n=ye(k=>k.setScheduledTasksDialogOpen),r=ye(k=>k.isMobile),i=ye(k=>k.timeFormatPreference),o=zt(k=>k.projects),l=zt(k=>k.getActiveProject()),a=Zt(k=>k.homeDirectory),{currentTheme:d}=qn(),[u,m]=lt.useState(""),[f,g]=lt.useState([]),[y,b]=lt.useState(!0),[j,x]=lt.useState(!1),[h,p]=lt.useState(null),[w,S]=lt.useState(null),N=lt.useMemo(()=>o.find(k=>k.id===u)||null,[o,u]),P=lt.useCallback(k=>{const v=k.label?.trim()||yr(k.path,a||void 0),I=k.icon?za[k.icon]:null,H=k.color?Wa[k.color]:void 0,$=I?s.jsx(B,{name:I,className:"h-3.5 w-3.5 shrink-0",style:H?{color:H}:void 0}):s.jsx(B,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:H?{color:H}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:k.iconBackground?{backgroundColor:k.iconBackground}:void 0,children:s.jsx(Ka,{project:{id:k.id,iconImage:k.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:$})}):$,s.jsx("span",{className:"truncate",children:v})]})},[a,d.metadata.variant,d.colors.surface.foreground]),C=lt.useCallback(async(k,v)=>{if(!k){g([]);return}v?.silent||b(!0);try{const I=await dx(k);I.sort((H,$)=>{if(H.enabled!==$.enabled)return H.enabled?-1:1;const re=H.name.localeCompare($.name);return re!==0?re:(H.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-($.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),g(I)}catch(I){_e.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),v?.silent||g([])}finally{v?.silent||b(!1)}},[t]);lt.useEffect(()=>{if(!e)return;const k=l?.id||o[0]?.id||"";m(k),k?C(k):(g([]),b(!1))},[e,l,o,C]),lt.useEffect(()=>{if(!e)return;let k=null;const v=Dn(I=>{I.type==="scheduled-task-ran"&&I.projectId===u&&(k&&clearTimeout(k),k=setTimeout(()=>{C(u,{silent:!0})},400))});return()=>{k&&clearTimeout(k),v()}},[e,u,C]);const T=lt.useCallback(async k=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await ql(u,k),await C(u),_e.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,C,t]),R=lt.useCallback(async(k,v)=>{if(u){S(k.id),g(I=>I.map(H=>H.id===k.id?{...H,enabled:v}:H));try{k.loopFile?await ux(u,k.id,v):await ql(u,{...k,enabled:v}),await C(u,{silent:!0})}catch(I){_e.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await C(u,{silent:!0})}finally{S(null)}}},[u,C,t]),M=lt.useCallback(async k=>{if(!(!u||!window.confirm(k.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:k.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:k.name})))){S(k.id);try{k.loopFile?await fx(u,k.id):await mx(u,k.id),await C(u,{silent:!0}),_e.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(I){_e.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[u,C,t]),F=lt.useCallback(k=>{if(!k.loopFile){p(k),x(!0);return}N?.path&&(n(!1),Qs.getState().setSelectedPath(N.path,k.loopFile,{allowOutsideRoot:!0}),ye.getState().openContextFile(N.path,k.loopFile))},[N?.path,n]),K=lt.useCallback(async k=>{if(u){S(k.id);try{const{sessionId:v,persistError:I}=await hx(u,k.id);if(await Promise.all([C(u,{silent:!0}),Jo()]),I?_e.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):_e.success(t("sessions.scheduledTasks.dialog.toast.started")),v){const H=o.find($=>$.id===u);ot.getState().setCurrentSession(v,H?.path??null)}}catch(v){_e.error(v instanceof Error?v.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[u,o,C,t]),D=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(ln,{value:u||"__none",onValueChange:k=>{const v=k==="__none"?"":k;m(v),v?C(v):g([])},children:[s.jsx(cn,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Js,{children:P(N)}):s.jsx(Js,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(dn,{children:[o.length===0?s.jsx(ds,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(k=>s.jsx(ds,{value:k.id,children:P(k)},k.id))]})]})]}),U=()=>{p(null),x(!0)},A=k=>{m(k),k?C(k):g([])},E=s.jsx("div",{className:"min-h-[280px]",children:y?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(B,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(k=>{const v=w===k.id,I=k.state?.lastStatus||"idle",H=_4[I],$=t(I==="success"?"sessions.scheduledTasks.dialog.status.success":I==="error"?"sessions.scheduledTasks.dialog.status.error":I==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),re=k.state?.nextRunAt,te=k.state?.lastRunAt;return s.jsxs("div",{className:De("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:De("min-w-0",!k.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:k.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:F4(k,t)}),k.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:k.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:k.loopFile})}):null]}),s.jsxs("div",{className:De("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!k.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),re?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:jd(re,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:L4(re,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),I==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(B,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):te?s.jsxs(s.Fragment,{children:[H.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${H.tone})`},children:[s.jsx(B,{name:H.Icon,className:"h-3.5 w-3.5"}),$]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:jd(te,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),k.state?.lastError?s.jsxs("div",{className:De("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!k.enabled&&"opacity-60"),style:$4("error"),children:[s.jsx(B,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:k.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:De("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",k.enabled?"text-foreground":"text-muted-foreground",v&&"cursor-not-allowed opacity-50"),children:[s.jsx(Lr,{checked:k.enabled,onChange:ee=>{R(k,ee)},ariaLabel:k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:k.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:k.name}),disabled:v}),k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(mt,{variant:"outline",size:"sm",onClick:()=>{K(k)},disabled:v,children:[s.jsx(B,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(mt,{variant:"outline",size:"sm",onClick:()=>F(k),disabled:v,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:k.name}),children:[s.jsx(B,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(mt,{variant:"destructive",size:"sm",onClick:()=>{M(k)},disabled:v,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:k.name}),children:s.jsx(B,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},k.id)})})}),W=s.jsxs("div",{className:"space-y-4",children:[D,E]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Qo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:k=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),k]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(mt,{className:"w-full",onClick:U,disabled:!u,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:W}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(k=>s.jsx("button",{type:"button",onClick:()=>A(k.id),className:De("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===k.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:P(k)},k.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(mt,{size:"sm",onClick:U,disabled:!u,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:E})})]})]})}):null,s.jsx(T4,{open:j,task:h,onOpenChange:x,onSave:T})]})}const Ro=100;function W4(){const t=nt.c(108),{t:e}=At(),n=ye(X4),r=ye(Q4),i=ot(Y4),o=ot(q4),l=Zt(G4);let a;t[0]!==n?(a=re=>n?re.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=ps(Un(a)),[u,m]=c.useState(""),[f,g]=c.useState(null),[y,b]=c.useState(Ro);let j;t[2]!==u?(j=u.trim().toLowerCase(),t[2]=u,t[3]=j):j=t[3];const x=j;let h;e:{if(!n){let te;t[4]===Symbol.for("react.memo_cache_sentinel")?(te=[],t[4]=te):te=t[4],h=te;break e}let re;t[5]!==d?(re=[...d].sort(H4),t[5]=d,t[6]=re):re=t[6],h=re}const p=h;let w;if(t[7]!==l||t[8]!==p||t[9]!==e){const re=new Map;for(const te of p){const ee=gt(Is(te))??"",ue=re.get(ee);if(ue){ue.sessions.push(te);continue}re.set(ee,{directory:ee,label:ee?yr(ee,l)||ee:e("sessions.archivePage.otherProjects"),sessions:[te]})}w=[...re.values()].sort(U4),t[7]=l,t[8]=p,t[9]=e,t[10]=w}else w=t[10];const S=w;let N;e:{if(x){if(x.startsWith("ses_")){let ee;if(t[11]!==x||t[12]!==p){let ue;t[14]!==x?(ue=de=>de.id.toLowerCase()===x,t[14]=x,t[15]=ue):ue=t[15],ee=p.filter(ue),t[11]=x,t[12]=p,t[13]=ee}else ee=t[13];N=ee;break e}let te;t[16]!==x||t[17]!==p?(te=Cb(p,x,V4),t[16]=x,t[17]=p,t[18]=te):te=t[18],N=te;break e}if(f===null){N=p;break e}let re;t[19]!==S||t[20]!==f?(re=S.find(te=>te.directory===f)?.sessions??[],t[19]=S,t[20]=f,t[21]=re):re=t[21],N=re}const P=N;let C,T,R,M,F,K,D,U,A,E;if(t[22]!==d.length||t[23]!==S||t[24]!==P||t[25]!==l||t[26]!==x||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==y){F=Symbol.for("react.early_return_sentinel");e:{const re=P.slice(0,y);C=P.length-re.length;const te=d.length;let ee;t[45]===Symbol.for("react.memo_cache_sentinel")?(ee=be=>{g(be),b(Ro)},t[45]=ee):ee=t[45];const ue=ee;let de;t[46]!==i||t[47]!==r?(de=be=>{const Q=gt(Is(be));i(be.id,Q??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=de):de=t[48];const Te=de;let we;t[49]!==e||t[50]!==o?(we=be=>{o(be.id).then(Q=>{Q?_e.success(e("sessions.sidebar.session.restore.success")):_e.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=we):we=t[51];const fe=we;if(!n){F=null;break e}let Ne;t[52]!==e?(Ne=(be,Q,_,J,me,le,V)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:me,title:le,className:De("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",V?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",J?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:_})]}),V?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>Us.requestDelete({sessions:V,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:Q}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},be),t[52]=e,t[53]=Ne):Ne=t[53];const L=Ne;M="absolute inset-0 z-10 flex flex-col bg-background",T="flex min-h-0 flex-1";let oe;if(t[54]!==L||t[55]!==f||t[56]!==e||t[57]!==te){let be;t[59]===Symbol.for("react.memo_cache_sentinel")?(be=()=>ue(null),t[59]=be):be=t[59],oe=L("__all__",e("sessions.archivePage.allDirectories"),te,f===null,be),t[54]=L,t[55]=f,t[56]=e,t[57]=te,t[58]=oe}else oe=t[58];let ce;if(t[60]!==S||t[61]!==L||t[62]!==f){let be;t[64]!==L||t[65]!==f?(be=Q=>L(Q.directory||"__none__",Q.label,Q.sessions.length,f===Q.directory,()=>ue(Q.directory),Q.directory||void 0,Q.sessions),t[64]=L,t[65]=f,t[66]=be):be=t[66],ce=S.map(be),t[60]=S,t[61]=L,t[62]=f,t[63]=ce}else ce=t[63];t[67]!==oe||t[68]!==ce?(R=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[oe,ce]})}),t[67]=oe,t[68]=ce,t[69]=R):R=t[69],A="flex min-w-0 flex-1 flex-col";let pe;t[70]===Symbol.for("react.memo_cache_sentinel")?(pe=be=>{m(be),b(Ro)},t[70]=pe):pe=t[70];let Y;t[71]!==e?(Y=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=Y):Y=t[72];let ve;t[73]!==e?(ve=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=ve):ve=t[74];let Ee;t[75]!==u||t[76]!==Y||t[77]!==ve?(Ee=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Jd,{value:u,onSearch:pe,placeholder:Y,clearLabel:ve})}),t[75]=u,t[76]=Y,t[77]=ve,t[78]=Ee):Ee=t[78];let je;t[79]!==P.length||t[80]!==e?(je=P.length===1?e("sessions.archivePage.countSingle",{count:P.length}):e("sessions.archivePage.countPlural",{count:P.length}),t[79]=P.length,t[80]=e,t[81]=je):je=t[81];let ge;t[82]!==je?(ge=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:je}),t[82]=je,t[83]=ge):ge=t[83],t[84]!==Ee||t[85]!==ge?(E=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Ee,ge]}),t[84]=Ee,t[85]=ge,t[86]=E):E=t[86],U="min-h-0 flex-1 overflow-y-auto px-6 py-3",K="mx-auto w-full max-w-3xl space-y-0.5",D=re.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(x?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):re.map(be=>{const Q=gt(Is(be))??"",_=Q?yr(Q,l)||Q:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Te(be),role:"button",tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),Te(be))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:be.title||e("sessions.sidebar.session.untitled")}),x&&_?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:Q,children:_}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Ku(be.time?.archived??be.time?.updated??be.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),fe(be)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(B,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),Us.requestDelete({sessions:[be],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},be.id)})}t[22]=d.length,t[23]=S,t[24]=P,t[25]=l,t[26]=x,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=y,t[35]=C,t[36]=T,t[37]=R,t[38]=M,t[39]=F,t[40]=K,t[41]=D,t[42]=U,t[43]=A,t[44]=E}else C=t[35],T=t[36],R=t[37],M=t[38],F=t[39],K=t[40],D=t[41],U=t[42],A=t[43],E=t[44];if(F!==Symbol.for("react.early_return_sentinel"))return F;let W;t[87]!==C||t[88]!==e?(W=C>0?s.jsx("button",{type:"button",onClick:()=>b(K4),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=C,t[88]=e,t[89]=W):W=t[89];let k;t[90]!==W||t[91]!==K||t[92]!==D?(k=s.jsxs("div",{className:K,children:[D,W]}),t[90]=W,t[91]=K,t[92]=D,t[93]=k):k=t[93];let v;t[94]!==k||t[95]!==U?(v=s.jsx("div",{className:U,children:k}),t[94]=k,t[95]=U,t[96]=v):v=t[96];let I;t[97]!==v||t[98]!==A||t[99]!==E?(I=s.jsxs("div",{className:A,children:[E,v]}),t[97]=v,t[98]=A,t[99]=E,t[100]=I):I=t[100];let H;t[101]!==T||t[102]!==R||t[103]!==I?(H=s.jsxs("div",{className:T,children:[R,I]}),t[101]=T,t[102]=R,t[103]=I,t[104]=H):H=t[104];let $;return t[105]!==M||t[106]!==H?($=s.jsx("div",{className:M,children:H}),t[105]=M,t[106]=H,t[107]=$):$=t[107],$}function K4(t){return t+Ro}function V4(t){return[t.title]}function U4(t,e){return e.sessions.length-t.sessions.length}function H4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function G4(t){return t.homeDirectory}function q4(t){return t.unarchiveSession}function Y4(t){return t.setCurrentSession}function Q4(t){return t.setArchivePageOpen}function X4(t){return t.isArchivePageOpen}function J4(){const t=nt.c(18),{t:e}=At(),n=ye(t3),r=ye(e3),i=zt(Z4);let o;t[0]!==n?(o=y=>y.projects.find(b=>b.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=zt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(B,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==a||t[10]!==u?(m=s.jsx("div",{className:"flex items-center",children:s.jsxs(mt,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(np,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let g;return t[15]!==m||t[16]!==f?(g=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[m,f]})})}),t[15]=m,t[16]=f,t[17]=g):g=t[17],g}function Z4(t){return t.setActiveProjectIdOnly}function e3(t){return t.setNewWorktreeDialogOpen}function t3(t){return t.worktreesPageProjectId}function s3(t){const e=[],n=(r,i)=>{const o=gt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const n3=new Map,r3=t=>{const e=nt.c(23),{isVSCode:n}=t,r=Xo(),i=zt(o3),o=Zt(i3),l=ot(a3);let a;e[0]!==n?(a=R=>n?n3:R.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=ot(a),u=!n;let m;e[2]!==d||e[3]!==i||e[4]!==u?(m=lm(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=m):m=e[5];const f=m,g=ps(l3),y=ps(c3),b=ps(d3),j=`session-list-sync:${c.useId()}`;let x,h;e[6]!==j||e[7]!==r||e[8]!==o||e[9]!==l?(x=()=>(r.setBootstrapDemand(j,s3({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(j)),h=[j,r,o,l],e[6]=j,e[7]=r,e[8]=o,e[9]=l,e[10]=x,e[11]=h):(x=e[10],h=e[11]),c.useEffect(x,h);const p=c.useRef(null);let w,S;e[12]!==n||e[13]!==f?(w=()=>{const R=new Set(f),M=p.current;p.current=R;const F=M?[...R].filter(K=>!M.has(K)):n?[...R]:[];F.length&&Ia(F,Fo())},S=[n,f],e[12]=n,e[13]=f,e[14]=w,e[15]=S):(w=e[14],S=e[15]),c.useEffect(w,S);let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[16]=N):N=e[16],c.useEffect(u3,N);let P;e[17]!==y||e[18]!==g?(P=[...g,...y],e[17]=y,e[18]=g,e[19]=P):P=e[19];const C=P;let T;e[20]!==C||e[21]!==b?(T={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:C},e[20]=C,e[21]=b,e[22]=T):T=e[22],rp(T)};function o3(t){return t.projects}function i3(t){return t.currentDirectory}function a3(t){return t.currentSessionDirectory}function l3(t){return t.activeSessions}function c3(t){return t.archivedSessions}function d3(t){return t.status==="ready"}function u3(){let t=null,e=!1;const n=new Set,r=Dn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Jo(Fo());return}const o=[...n];n.clear(),o.length&&Ia(o,Fo())},500)});return()=>{t&&clearTimeout(t),r()}}const f3=In(()=>en(()=>import("./SettingsWindow-B8RpyNyO.js"),__vite__mapDeps([147,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,148,85,86,87,149,133,134,135,136,121,122,107,108,92,93,94,95,96,97,98,99,100,101,102,103,104,105,150,151,152])).then(t=>({default:t.SettingsWindow}))),m3=()=>{const t=nt.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],r3(e),op();const n=ye(h3),r=ye(p3),i=ye(g3),o=ye(b3),l=ye(x3),[a,d]=c.useState(!1);let u,m;t[1]!==o?(u=()=>{o&&d(!0)},m=[o],t[1]=o,t[2]=u,t[3]=m):(u=t[2],m=t[3]),c.useEffect(u,m);const f=ye(y3),g=ye(w3),y=ye(v3),b=ye(S3),j=ye(j3),x=ye(k3),h=Ru();let p;if(t[4]!==h||t[5]!==x){let _;t[7]!==x?(_=J=>J.id===x,t[7]=x,t[8]=_):_=t[8],p=h.find(_),t[4]=h,t[5]=x,t[6]=p}else p=t[6];const w=p;let S,N;t[9]!==w||t[10]!==x?(S=()=>{x&&!w&&ye.getState().setOpenGuestPage(null)},N=[x,w],t[9]=w,t[10]=x,t[11]=S,t[12]=N):(S=t[11],N=t[12]),c.useEffect(S,N);let P;t[13]===Symbol.for("react.memo_cache_sentinel")?(P=[],t[13]=P):P=t[13],c.useEffect(N3,P);const C=g||y||b||!!j||f||!!w;let T;t[14]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[14]=T):T=t[14],c.useEffect(P3,T);const{isMobile:R}=Pn();ip();let M,F;t[15]!==R||t[16]!==i?(M=()=>{ye.getState().isMobile!==R&&i(R)},F=[R,i],t[15]=R,t[16]=i,t[17]=M,t[18]=F):(M=t[17],F=t[18]),c.useEffect(M,F);let K,D,U,A,E;t[19]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(pj,{}),D=s.jsx(u0,{}),U=s.jsx(p0,{}),A=s.jsx(ap,{}),E=s.jsx(h4,{}),t[19]=K,t[20]=D,t[21]=U,t[22]=A,t[23]=E):(K=t[19],D=t[20],U=t[21],A=t[22],E=t[23]);let W;t[24]!==r?(W=r?s.jsx(lp,{}):null,t[24]=r,t[25]=W):W=t[25];let k;t[26]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(Wy,{}),t[26]=k):k=t[26];let v;t[27]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(zy,{}),t[27]=v):v=t[27];let I;t[28]!==n?(I=s.jsx(m4,{isVisible:n}),t[28]=n,t[29]=I):I=t[29];let H;t[30]!==R||t[31]!==n||t[32]!==I?(H=s.jsx($y,{isOpen:n,isMobile:R,className:"border-border",topBar:v,children:I}),t[30]=R,t[31]=n,t[32]=I,t[33]=H):H=t[33];let $;t[34]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(Ly,{}),t[34]=$):$=t[34];const re=C&&"invisible";let te;t[35]!==re?(te=De("absolute inset-0",re),t[35]=re,t[36]=te):te=t[36];const ee=!o&&!C;let ue;t[37]!==ee?(ue=s.jsx(ms,{children:s.jsx(su,{active:ee})}),t[37]=ee,t[38]=ue):ue=t[38];let de;t[39]!==te||t[40]!==ue?(de=s.jsx("div",{className:te,children:ue}),t[39]=te,t[40]=ue,t[41]=de):de=t[41];let Te;t[42]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx(ms,{children:s.jsx(cp,{})}),t[42]=Te):Te=t[42];let we;t[43]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(ms,{children:s.jsx(z4,{})}),t[43]=we):we=t[43];let fe;t[44]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(ms,{children:s.jsx(W4,{})}),t[44]=fe):fe=t[44];let Ne;t[45]!==b?(Ne=b&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ms,{children:s.jsx(dp,{})})}),t[45]=b,t[46]=Ne):Ne=t[46];let L;t[47]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(ms,{children:s.jsx(J4,{})}),t[47]=L):L=t[47];let oe;t[48]!==w?(oe=w&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ms,{children:s.jsx(Ex,{mode:`plugin:${w.id}`,surface:"page",item:null,onDismiss:D3})})}),t[48]=w,t[49]=oe):oe=t[49];let ce;t[50]!==de||t[51]!==Ne||t[52]!==oe?(ce=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[de,Te,we,fe,Ne,L,oe]}),t[50]=de,t[51]=Ne,t[52]=oe,t[53]=ce):ce=t[53];let pe;t[54]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(FS,{}),t[54]=pe):pe=t[54];let Y;t[55]!==ce?(Y=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[ce,pe]})})}),t[55]=ce,t[56]=Y):Y=t[56];let ve;t[57]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(ms,{children:s.jsx(GS,{})})}),t[57]=ve):ve=t[57];let Ee;t[58]===Symbol.for("react.memo_cache_sentinel")?(Ee=s.jsx(ms,{children:s.jsx(ox,{})}),t[58]=Ee):Ee=t[58];let je;t[59]!==Y?(je=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[$,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Y,ve,Ee]})]}),t[59]=Y,t[60]=je):je=t[60];let ge;t[61]!==H||t[62]!==je?(ge=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[H,je]}),t[61]=H,t[62]=je,t[63]=ge):ge=t[63];let be;t[64]!==o||t[65]!==l||t[66]!==a?(be=a?s.jsx(c.Suspense,{fallback:null,children:s.jsx(f3,{open:o,onOpenChange:l})}):null,t[64]=o,t[65]=l,t[66]=a,t[67]=be):be=t[67];let Q;return t[68]!==W||t[69]!==ge||t[70]!==be?(Q=s.jsx(up,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[K,D,U,A,E,W,k,ge,be]})}),t[68]=W,t[69]=ge,t[70]=be,t[71]=Q):Q=t[71],Q};function h3(t){return t.isSidebarOpen}function p3(t){return t.isolatedSpacesEnabled}function g3(t){return t.setIsMobile}function b3(t){return t.isSettingsDialogOpen}function x3(t){return t.setSettingsDialogOpen}function y3(t){return t.runOverviewKey!==null}function w3(t){return t.isScheduledTasksDialogOpen}function v3(t){return t.isArchivePageOpen}function S3(t){return t.isUsageStatsPageOpen}function j3(t){return t.worktreesPageProjectId}function k3(t){return t.openGuestPageId}function C3(){return ye.getState().setOpenGuestPage(null)}function N3(){return vr(C3)}function A3(){return ye.getState().closeMainSurfaces()}function P3(){const t=A3,e=ot.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function D3(){return ye.getState().setOpenGuestPage(null)}const um=12,I3=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],T3=t=>{const e=nt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,m=l===void 0?I3:l,f=lt.useRef(!1);let g,y;e[0]!==n||e[1]!==a?(g=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},y=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=y):(g=e[2],y=e[3]),lt.useEffect(g,y);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:um},E3),e[4]=b):b=e[4];const j=b;if(!n)return null;let x;e[5]!==i?(x=De("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=x):x=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=S=>{const N={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:j.map((P,C)=>{const T=P.x*S.radius,R=P.y*S.radius,M={"--translate-x":`${T}px`,"--translate-y":`${R}px`,"--particle-delay":`${P.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:M},`${S.id}-${C}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],h=m.map(w),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let p;return e[14]!==d||e[15]!==x||e[16]!==h?(p=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=x,e[16]=h,e[17]=p):p=e[17],p};function E3(t,e){const n=Math.PI*2*e/um;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const R3=t=>{const e=nt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=lt.useState(o),d=lt.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),a(M3)},e[4]=f):f=e[4];const g=f;let y;e[5]!==i?(y=()=>{m(),a(O3),d.current=window.setTimeout(()=>{a(B3),d.current=null},i)},e[5]=i,e[6]=y):y=e[6];const b=y;let j,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=()=>()=>m(),x=[m],e[7]=j,e[8]=x):(j=e[7],x=e[8]),lt.useEffect(j,x);let h;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==b?(h={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:b,dismissFireworks:g},e[9]=l.cycle,e[10]=l.isActive,e[11]=b,e[12]=h):h=e[12],h};function M3(t){return t.isActive?{...t,isActive:!1}:t}function O3(t){return{isActive:!0,cycle:t.cycle+1}}function B3(t){return t.isActive?{...t,isActive:!1}:t}const fm=c.createContext(void 0),F3=t=>{const e=nt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=R3();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(T3,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(fm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},O5=()=>{const t=c.useContext(fm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ka="openchamber_requests_in_flight",mm=1e3,L3=300*1e3,Go=Math.ceil(L3/mm),_3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ka)==="1"}catch{return!1}},hm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let $3=1;const z3=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},W3=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},pm=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},xr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},K3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=$3++;z3(o,Date.now());try{return await e(r,i)}finally{W3(o)}};window.fetch=n},kd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Ir=t=>{t.length>Go&&t.splice(0,t.length-Go)},V3=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=pm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(xr(e,50)),t.p90Samples.push(xr(e,90)),t.p99Samples.push(xr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Ir(t.samples),Ir(t.p50Samples),Ir(t.p90Samples),Ir(t.p99Samples),Ir(t.maxSamples),t.lastSampleAt=Date.now()},U3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(V3,mm))},Cd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Nd=t=>{if(!(typeof window>"u"))try{if(t){Cd(),kd(),window.localStorage.setItem(ka,"1"),window.__openchamberRequestsInFlight__=hm(),K3(),U3();return}window.localStorage.removeItem(ka),Cd(),kd(),delete window.__openchamberRequestsInFlight__}catch{}},H3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=hm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},Ca=()=>{if(typeof window>"u")return Ad();const t=window.__openchamberRequestsInFlight__;if(!_3()||!t)return Ad();const e=pm(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:xr(e,50),ageP90:xr(e,90),ageP99:xr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Go}},Ad=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Go});function G3(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const gm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Na=t=>`${(t/1e3).toFixed(2)} s`,cs=t=>{const e=nt.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Pd=t=>{const e=nt.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=At();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Q3,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?gm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let y;e[18]!==m||e[19]!==g?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,g]}),e[18]=m,e[19]=g,e[20]=y):y=e[20];let b;e[21]!==o?(b=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=b):b=e[22];let j;e[23]!==r.entries.length||e[24]!==b?(j=s.jsx(cs,{label:b,value:r.entries.length}),e[23]=r.entries.length,e[24]=b,e[25]=j):j=e[25];let x;e[26]!==o?(x=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=x):x=e[27];let h;e[28]!==x||e[29]!==u?(h=s.jsx(cs,{label:x,value:u}),e[28]=x,e[29]=u,e[30]=h):h=e[30];let p;e[31]!==o?(p=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=p):p=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==o?(w=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=w):w=e[35];let S;e[36]!==p||e[37]!==w?(S=s.jsx(cs,{label:p,value:w}),e[36]=p,e[37]=w,e[38]=S):S=e[38];let N;e[39]!==h||e[40]!==S||e[41]!==j?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[j,h,S]}),e[39]=h,e[40]=S,e[41]=j,e[42]=N):N=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[y,N,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(bn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(P=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:P.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:P.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:P.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:P.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:P.total})})]})]},P.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Dd=t=>{const e=nt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(X3,0),u=r>0?52/r:0;let m;e[0]!==d||e[1]!==a?(m=S=>a-d+S,e[0]=d,e[1]=a,e[2]=m):m=e[2];const f=m;let g;e[3]!==u?(g=S=>56-S*u,e[3]=u,e[4]=g):g=e[4];const y=g;let b;e[5]!==l?(b=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=b):b=e[6];const j=`0 0 ${a} 56`;let x;e[7]!==a?(x=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=x):x=e[8];let h;if(e[9]!==n||e[10]!==f||e[11]!==y){let S;e[13]!==f||e[14]!==y?(S=(N,P)=>{const C=N.samples.length;if(C===0)return null;const T=N.samples.map((M,F)=>`${f(F)},${y(M).toFixed(2)}`),R=`M ${T.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${T.join(" L ")} L ${f(C-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:R,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},P)},e[13]=f,e[14]=y,e[15]=S):S=e[15],h=n.map(S),e[9]=n,e[10]=f,e[11]=y,e[12]=h}else h=e[12];let p;e[16]!==o||e[17]!==j||e[18]!==x||e[19]!==h?(p=s.jsxs("svg",{viewBox:j,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[x,h]}),e[16]=o,e[17]=j,e[18]=x,e[19]=h,e[20]=p):p=e[20];let w;return e[21]!==b||e[22]!==p?(w=s.jsxs("div",{className:"relative w-full",children:[b,p]}),e[21]=b,e[22]=p,e[23]=w):w=e[23],w},q3=t=>{const e=nt.c(100),{onClose:n}=t,{t:r}=At(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=ot(J3),u=zu(Z3),m=Nu(),f=Nb(eN),g=Ps(tN),[y,b]=c.useState(sN),[j,x]=c.useState(nN),[h,p]=c.useState(rN),w=[{label:"p50",current:h.ageP50,samples:h.p50Samples,color:"var(--status-success)"},{label:"p90",current:h.ageP90,samples:h.p90Samples,color:"var(--status-info)"},{label:"p99",current:h.ageP99,samples:h.p99Samples,color:"var(--status-warning)"},{label:"max",current:h.ageMax,samples:h.maxSamples,color:"var(--status-error)"}];let S;e[0]!==h.samples?(S=h.samples.reduce(oN,0),e[0]=h.samples,e[1]=S):S=e[1];const N=S,P=w.reduce(aN,0);let C;e[2]!==y.entries?(C=new Map,y.entries.forEach($e=>{C.set($e.metric,$e.count)}),e[2]=y.entries,e[3]=C):C=e[3];let T;e[4]!==C?(T=C.get("ui.message_list.render")??0,e[4]=C,e[5]=T):T=e[5];let R;e[6]!==C?(R=C.get("ui.message_list.render.streaming")??0,e[6]=C,e[7]=R):R=e[7];let M;e[8]!==C?(M=C.get("ui.chat_message.render")??0,e[8]=C,e[9]=M):M=e[9];let F;e[10]!==C?(F=C.get("ui.chat_message.render.streaming")??0,e[10]=C,e[11]=F):F=e[11];let K;e[12]!==C?(K=C.get("ui.chat_message.render.static_during_stream")??0,e[12]=C,e[13]=K):K=e[13];let D;e[14]!==C?(D=C.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=C,e[15]=D):D=e[15];let U;e[16]!==T||e[17]!==R||e[18]!==M||e[19]!==F||e[20]!==K||e[21]!==D?(U={messageListRender:T,messageListRenderStreaming:R,chatMessageRender:M,chatMessageRenderStreaming:F,chatMessageRenderStaticDuringStream:K,chatMessageRenderStaticOutsideActiveTurnDuringStream:D},e[16]=T,e[17]=R,e[18]=M,e[19]=F,e[20]=K,e[21]=D,e[22]=U):U=e[22];const A=U;let E,W;e[23]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{const $e=()=>{b(No()),x(Ao()),p(Ca())};$e();const Ue=window.setInterval($e,500);return()=>window.clearInterval(Ue)},E=[],e[23]=E,e[24]=W):(E=e[23],W=e[24]),c.useEffect(W,E);let k,v;e[25]!==l?(k=()=>{if(l==="idle")return;const $e=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout($e)},v=[l],e[25]=l,e[26]=k,e[27]=v):(k=e[26],v=e[27]),c.useEffect(k,v);let I=0,H=0,$=0;for(const $e of Object.keys(f)){const Ue=f[$e]??[];H=H+Ue.length;for(const ct of Ue)ct.role==="user"?$=$+1:ct.role==="assistant"&&(I=I+1)}let re;e[28]!==I||e[29]!==H||e[30]!==$?(re={assistant:I,total:H,user:$},e[28]=I,e[29]=H,e[30]=$,e[31]=re):re=e[31];const te=re;let ee;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==m||e[36]!==r){let $e;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?($e=Ue=>{const ct=f[Ue.id]??[];let pt=0,it=0;for(const yt of ct)yt.role==="user"?it=it+1:yt.role==="assistant"&&(pt=pt+1);const ft=u.get(Ue.id);return{id:Ue.id,title:Ue.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:pt,messageCount:ct.length,userMessageCount:it,isStreaming:ft?.isStreaming||!1,isZombie:ft?.isZombie||!1,backgroundCount:ft?.backgroundMessageCount||0,lastAccessed:ft?.lastAccessedAt||0,isCurrent:Ue.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=$e):$e=e[42],ee=m.map($e).sort(lN),e[32]=d,e[33]=f,e[34]=u,e[35]=m,e[36]=r,e[37]=ee}else ee=e[37];const ue=ee;let de;e[43]!==f?(de=Object.keys(f),e[43]=f,e[44]=de):de=e[44];const Te=de.length;let we;e[45]===Symbol.for("react.memo_cache_sentinel")?(we=async()=>{try{const $e={generatedAt:new Date().toISOString(),ui:No(),vscode:Ao()};await navigator.clipboard.writeText(JSON.stringify($e,null,2)),a("copied")}catch{a("error")}},e[45]=we):we=e[45];const fe=we,Ne=Pb,L="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let oe;e[46]===Symbol.for("react.memo_cache_sentinel")?(oe={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=oe):oe=e[46];let ce;e[47]!==i?(ce=G3(i),e[47]=i,e[48]=ce):ce=e[48];let pe;e[49]!==ce?(pe=s.jsx(B,{name:ce,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=ce,e[50]=pe):pe=e[50];let Y;e[51]!==r?(Y=r("memoryDebugPanel.title"),e[51]=r,e[52]=Y):Y=e[52];let ve;e[53]!==Y?(ve=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Y}),e[53]=Y,e[54]=ve):ve=e[54];let Ee;e[55]!==pe||e[56]!==ve?(Ee=s.jsxs("div",{className:"flex items-center gap-2",children:[pe,ve]}),e[55]=pe,e[56]=ve,e[57]=Ee):Ee=e[57];let je;e[58]!==i?(je=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(mt,{size:"xs",variant:"ghost",onClick:fe,children:s.jsx(B,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(mt,{size:"xs",variant:"ghost",onClick:()=>{uh(),b(No()),x(Ao())},children:s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=je):je=e[59];let ge;e[60]!==i?(ge=i==="requests"?s.jsx(mt,{size:"xs",variant:"ghost",onClick:()=>{H3(),p(Ca())},children:s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=ge):ge=e[61];let be;e[62]!==n?(be=n?s.jsx(mt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(B,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=be):be=e[63];let Q;e[64]!==je||e[65]!==ge||e[66]!==be?(Q=s.jsxs("div",{className:"flex items-center gap-1",children:[je,ge,be]}),e[64]=je,e[65]=ge,e[66]=be,e[67]=Q):Q=e[67];let _;e[68]!==Ee||e[69]!==Q?(_=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Ee,Q]}),e[68]=Ee,e[69]=Q,e[70]=_):_=e[70];let J;e[71]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=J):J=e[71];const me=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let V;e[73]!==r?(V=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=V):V=e[74];let Z;e[75]!==me||e[76]!==V?(Z=s.jsx(mt,{size:"sm",variant:me,className:"flex-1",onClick:le,children:V}),e[75]=me,e[76]=V,e[77]=Z):Z=e[77];const G=i==="streaming"?"secondary":"ghost";let ie;e[78]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>o("streaming"),e[78]=ie):ie=e[78];let Se;e[79]!==r?(Se=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=Se):Se=e[80];let se;e[81]!==G||e[82]!==Se?(se=s.jsx(mt,{size:"sm",variant:G,className:"flex-1",onClick:ie,children:Se}),e[81]=G,e[82]=Se,e[83]=se):se=e[83];const Me=i==="requests"?"secondary":"ghost";let He;e[84]===Symbol.for("react.memo_cache_sentinel")?(He=()=>o("requests"),e[84]=He):He=e[84];let We;e[85]!==r?(We=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=We):We=e[86];let Le;e[87]!==Me||e[88]!==We?(Le=s.jsx(mt,{size:"sm",variant:Me,className:"flex-1",onClick:He,children:We}),e[87]=Me,e[88]=We,e[89]=Le):Le=e[89];let Ve;e[90]!==Z||e[91]!==se||e[92]!==Le?(Ve=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:J,children:[Z,se,Le]}),e[90]=Z,e[91]=se,e[92]=Le,e[93]=Ve):Ve=e[93];const O=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(cs,{label:r("memoryDebugPanel.metric.totalMessages"),value:te.total}),s.jsx(cs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Te} / ${$l.MAX_SESSIONS}`}),s.jsx(cs,{label:r("memoryDebugPanel.metric.userMessages"),value:te.user}),s.jsx(cs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:te.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:Ab()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:$l.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:g})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(bn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:ue.map($e=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:$e.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:$e.title}),$e.isStreaming?s.jsx(B,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,$e.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:$e.assistantMessageCount,user:$e.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:$e.messageCount})}),$e.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",$e.backgroundCount]}):null]})]},$e.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(mt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(cN),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:te,sessionMessageRoleCounts:ue.map(dN),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(jt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(mt,{size:"xs",variant:"outline",onClick:fe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(cs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(cs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:j.entries.length}),s.jsx(cs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:A.messageListRender}),s.jsx(cs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:A.messageListRenderStreaming}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:A.chatMessageRender}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:A.chatMessageRenderStreaming}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:A.chatMessageRenderStaticDuringStream}),s.jsx(cs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:A.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Pd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),j.entries.length>0?s.jsx(Pd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:j,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(cs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${h.totalSettled} / ${h.totalStarted}`}),s.jsx(cs,{label:r("memoryDebugPanel.requests.tracking"),value:h.startedAt?gm(h.durationMs):r("memoryDebugPanel.common.idle")})]}),h.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.peak})]})]}),s.jsx(Dd,{series:[{samples:h.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:h.peak}),maxLabel:`${N}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Na(h.peakAgeMs)})]}),s.jsx(Dd,{series:w.map(uN),peak:P,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Na(P)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:w.map(fN)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:h.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let he;return e[94]!==Ne||e[95]!==oe||e[96]!==_||e[97]!==Ve||e[98]!==O?(he=s.jsxs(Ne,{className:L,style:oe,children:[_,Ve,O]}),e[94]=Ne,e[95]=oe,e[96]=_,e[97]=Ve,e[98]=O,e[99]=he):he=e[99],he},Y3=q3;function Q3(t,e){return t+e.count}function X3(t,e){return Math.max(t,e.samples.length)}function J3(t){return t.currentSessionId}function Z3(t){return t.sessionMemoryState}function eN(t){return t.message}function tN(t){return t.totalRequestCount}function sN(){return No()}function nN(){return Ao()}function rN(){return Ca()}function oN(t,e){return Math.max(t,e)}function iN(t,e){return Math.max(t,e)}function aN(t,e){return e.samples.reduce(iN,t)}function lN(t,e){return e.lastAccessed-t.lastAccessed}function cN(t){return{id:t.id,title:t.title}}function dN(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function uN(t){return{samples:t.samples,color:t.color}}function fN(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Na(t.current)})]},t.label)}const mN=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},hN=async()=>{const t=mN()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Id="openchamber:menu-action",Bi="openchamber:check-for-updates",pN=t=>{const e=ot(h=>h.openNewSessionDraft),n=ye(h=>h.toggleCommandPalette),r=ye(h=>h.setCommandPaletteOpen),i=ye(h=>h.toggleHelpDialog),o=ye(h=>h.toggleSidebar),l=ye(h=>h.setSessionSwitcherOpen),a=ye(h=>h.setSettingsDialogOpen),d=ye(h=>h.setAboutDialogOpen),u=Fr(h=>h.checkForUpdates),{setThemeMode:m}=qn(),f=c.useRef(!1),g=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:h,error:p}=Fr.getState();if(p){_e.error("Failed to check for updates",{description:p});return}h||_e.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),y=c.useCallback(()=>{Us.requestDirectoryDialog()},[]),b=c.useCallback(h=>{const p=Db();if(p.length===0)return;const w=ot.getState().currentSessionId,S=p.findIndex(C=>C.id===w);let N=h>0?0:p.length-1;S>=0&&(N=(S+h+p.length)%p.length);const P=p[N];P&&(l(!1),ot.getState().setCurrentSession(P.id))},[l]),j=c.useCallback(h=>{const{activeProjectId:p,projects:w,setActiveProject:S}=zt.getState();if(w.length===0)return;const N=w.findIndex(T=>T.id===p);let P=h>0?0:w.length-1;N>=0&&(P=(N+h+w.length)%w.length);const C=w[P];C&&S(C.id)},[]),x=c.useCallback(h=>{switch(h){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=ot.getState(),w=Zt.getState().currentDirectory;e(p.currentSessionId&&w?{directoryOverride:w}:void 0)}break;case"new-worktree-session":l(!1),Tu();break;case"change-workspace":y();break;case"toggle-right-sidebar":{const p=Zt.getState().currentDirectory;if(!p)break;const w=ye.getState(),S=Fn(p),N=w.contextPanelByDirectory[S];N?.isOpen?w.closeContextPanel(S):N?.activeTabId?w.setActiveContextPanelTab(S,N.activeTabId):w.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const p=Zt.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"git");break}case"open-right-sidebar-files":{const p=Zt.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"file");break}case"toggle-terminal":{const p=Zt.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"terminal");break}case"toggle-terminal-expanded":{const p=Zt.getState().currentDirectory;if(!p)break;const w=Fn(p),S=ye.getState(),N=S.contextPanelByDirectory[w];(N?.isOpen?N.tabs.find(C=>C.id===N.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(w,"terminal"),S.toggleContextPanelExpanded(w);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||hN();break}case"theme-light":m("light");break;case"theme-dark":m("dark");break;case"theme-system":m("system");break;case"add-selection-to-chat":Ib();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Zt.getState().goBack();break;case"go-forward":Zt.getState().goForward();break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":j(-1);break;case"next-project":j(1);break;case"help-dialog":i();break;case"download-logs":{Eu().catch(()=>{_e.error("Failed to collect OpenCode status")});break}}},[y,j,b,t,e,d,l,r,a,m,n,i,o]);c.useEffect(()=>{const h=w=>{const S=w.detail;S&&x(S)},p=()=>{g()};return window.addEventListener(Id,h),window.addEventListener(Bi,p),()=>{window.removeEventListener(Id,h),window.removeEventListener(Bi,p)}},[x,g]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let w=null,S=null;return p("openchamber:menu-action",N=>{const P=N?.payload;typeof P=="string"&&x(P)}).then(N=>{w=N}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Bi))}).then(N=>{S=N}).catch(()=>{}),()=>{(async()=>{try{const P=w?.();P instanceof Promise&&await P}catch{}try{const P=S?.();P instanceof Promise&&await P}catch{}})()}},[x])},gN="openchamber:tray-action",bN=5e3,xN=500,yN=20,Td=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ed=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,bm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},xm=t=>t.title.trim()||"Question",wN=(t,e)=>$a(t,e,Ur.getState().ids,Ba.getState().rankById),vN=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},SN=(t,e,n,r,i)=>{if(!t)return"";const o=ru(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||vN(t),d=Po(t);let u=d&&i.get(d)||"";if(!u){for(const[m,f]of Xn.getState().directories)if(Po(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(g=>Po(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},jN=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Eb){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:Mb(m),value:Rb(f.valueLabel,g)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},kN=async()=>{try{if(qo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=hn();if(e&&gl(e,t))return"Local OpenChamber";const r=(await Ld()).hosts.find(i=>e?gl(e,fh(i)):!1);return r?.label?.trim()?_d(r.label.trim()):"Instance"}catch{return""}},CN=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Xi()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(Po(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",g=t.get(d);(!g||g==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:bm(m),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"form",id:m.id,sessionId:f,sessionTitle:"",label:xm(m),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},NN=(t,e)=>{const n=Hu.getState().index.session,r=ps.getState().activeSessions,i=new Map;for(const p of r)if(p?.id&&p.parentID){const w=i.get(p.parentID)??[];w.push(p.id),i.set(p.parentID,w)}const o=p=>{const w=[],S=[...i.get(p)??[]],N=new Set;for(;S.length;){const P=S.pop();N.has(P)||(N.add(P),w.push(P),S.push(...i.get(P)??[]))}return w},l=ye.getState();let a=0;if(l.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let w=n.unseenCount[p.id]??0;w===0&&l.notifyOnSubtasks&&(w=o(p.id).reduce((S,N)=>S+(n.unseenCount[N]??0),0)),w>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=CN(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const m=Va.getState().statusById,f=p=>{const w=d.statusById.get(p);return w&&w!=="idle"?w:m.get(p)?.status.type??w??"idle"},g=p=>{const w=p.map(S=>f(S));return w.includes("busy")?"busy":w.includes("retry")?"retry":"idle"},y=zt.getState().projects,b=ot.getState().availableWorktreesByProject,j=r.filter(p=>p?.id&&!p.parentID).slice().sort(wN).slice(0,yN).map(p=>{const w=[p.id,...o(p.id)],S=Is(p)??"";return{id:p.id,title:p.title||"Untitled session",status:g(w),branch:S?d.branchByDirectory.get(S)??"":"",unseen:w.reduce((N,P)=>N+(n.unseenCount[P]??0),0),hasError:w.some(N=>n.unseenHasError[N]??!1),directory:S,subtitle:SN(S,p,y,b,d.branchByDirectory)}}),x=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),h=new Set(x.map(p=>p.id));for(const[p,w]of Gu.getState().bySession){const S=u.get(p)||"";for(const N of w.permissions)h.has(N.id)||(h.add(N.id),x.push({kind:"permission",id:N.id,sessionId:p,sessionTitle:S,label:bm(N),directory:w.directory}));for(const N of w.forms)h.has(N.id)||(h.add(N.id),x.push({kind:"form",id:N.id,sessionId:p,sessionTitle:S,label:xm(N),directory:w.directory}))}return{sessions:j,approvals:x,instanceName:t,usage:jN(),dockBadgeCount:a}},AN=()=>{c.useEffect(()=>{if(!Td()||!Kr())return;const t=Ed();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const C=NN(i,t),T=JSON.stringify(C);T!==n&&(n=T,Nn("desktop_tray_update",C))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},xN))},a=Hu.subscribe(()=>l()),d=ps.subscribe(()=>l()),u=ye.subscribe((C,T)=>{(C.dockBadgeEnabled!==T.dockBadgeEnabled||C.notifyOnSubtasks!==T.notifyOnSubtasks)&&l()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),m;kN().then(C=>{e||(i=C,o())});const f=new Map,g=()=>{if(e)return;let C;try{C=Xi()}catch{return}const T=new Set;for(const[R,M]of C.children.entries())T.add(R),f.has(R)||f.set(R,M.subscribe(()=>l()));for(const[R,M]of f)T.has(R)||(M(),f.delete(R))};let y=null;try{y=Xi().subscribeRegistry(()=>{g(),l()})}catch{}g();const b=zt.subscribe(()=>l()),j=ot.subscribe(()=>l()),x=Xn.subscribe(()=>l()),h=Va.subscribe(()=>l()),p=Gu.subscribe(()=>l()),w=Ba.subscribe(()=>l()),S=Ur.subscribe(()=>l()),N=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:C,results:T}=ur.getState();C.length>0&&C.some(M=>!T.some(F=>F.providerId===M))&&ur.getState().fetchQuotas(C)});const P=window.setInterval(()=>{g(),o()},bN);return o(),()=>{m(),window.clearInterval(P),b(),j(),x(),h(),p(),w(),S(),N(),y?.();for(const C of f.values())C();f.clear()}},[]),c.useEffect(()=>{if(!Td()||!Ed()||!Kr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Tb(i.sessionId,i.id,i.response).catch(()=>{_e.error("Failed to respond to permission request")})};let r=null;return e(gN,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},PN=30*6e4,DN=(t,e,n=PN)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Tr=null;const IN=()=>{if(Tr)return Tr;const t=qt();return Tr=(async()=>{const e=await mr.getHostSessionStatusSnapshot();if(!e||qt()!==t)return;const n=Va.getState(),r=ps.getState().entityById,i=DN(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Is(a):null}});for(const[l,a]of i)Ob(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Is(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Bb(o)})().finally(()=>{Tr=null}),Tr},TN=45e3,EN=[1e3,2e3,4e3],RN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const m=await u().catch(()=>!1);if(i)return;a||=m;const f=a?void 0:EN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??TN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},MN=t=>{const e=nt.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=ON;let o=i();const l=vr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function ON(){const t=qt();let e=!0;const n=async i=>(i?await Fb(Fo()):await Jo(),!e||qt()!==t?!1:(IN(),ps.getState().status==="ready")),r=RN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const BN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,FN=t=>{const e=nt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||mn()||!Pa()||!globalThis.window))return Dn(LN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function LN(t){if(t.type!=="notification")return;const e=ye.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&BN())return;Fd()?.notifications?.notifyAgentCompletion(t.payload)}const _N=6e4,$N=t=>{const e=nt.c(10),n=ye(zN),r=Lb(WN),o=fp(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:_N})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Dn(m=>{m.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function zN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function WN(t){return t.load}const KN=()=>{const t=nt.c(4),{t:e}=At(),n=ye(VN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Dn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),_e.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function VN(t){return t.setBrowserProvider}const Rd="pwa-install-toast-shown",Md="pwa-install-toast-dismissed",UN=()=>{const t=nt.c(6),{browserTab:e}=mp(),{t:n}=At(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!Pa()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(_e.dismiss(u),u=null)},f=async()=>{if(!d)return;const b=d;d=null,m(),await b.prompt();const{outcome:j}=await b.userChoice;j==="accepted"&&_e.success(r.current("pwa.installPrompt.started"))},g=b=>{const j=b;if(typeof j.prompt!="function")return;j.preventDefault(),d=j;const x=Oo(),h=mh();hp({dismissed:x.getItem(Md),sessionShown:h.getItem(Rd),hasActiveToast:u!==null})&&(h.setItem(Rd,"true"),u=_e.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Oo().setItem(Md,"true"),m()}}}))},y=()=>{d=null,m(),_e.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",y)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},HN=({open:t,onOpenChange:e})=>{const{t:n}=At(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[m,f]=c.useState(!1),[g,y]=c.useState(null),[b,j]=c.useState(!1);c.useCallback(async()=>{},[g,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const p=await as("/api/system/info");if(p.ok){const w=await p.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){o(w.openchamberVersion);return}}}catch{}o(await _b())})()},[t]),c.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const w=await as("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const S=await w.json().catch(()=>null),N=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!h&&N&&a(N)}catch{}})(),()=>{h=!0}},[t]),c.useEffect(()=>{{y(null),j(!1);return}},[t,r]);const x=i;return s.jsx(ks,{open:t,onOpenChange:e,children:s.jsx(Cs,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Au,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(B,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(B,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(B,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Aa="project-config-invalid",GN=()=>{const t=nt.c(9),{t:e}=At(),n=Wt(qN);let r;t[0]!==n?(r=g=>g.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const i=Wt(r),[o,l]=lt.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const g=Wt.getState(),y=g.activeDirectoryKey;l(!0),Promise.all([g.loadProviders({directory:y,source:"projectConfigError:retry"}),g.loadAgents({directory:y,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,m;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){_e.dismiss(Aa);return}_e.error(e("projectConfigError.toast.title"),{id:Aa,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&s.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:g=>{g.preventDefault(),o||d()}}})},m=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=m):(u=t[6],m=t[7]),lt.useEffect(u,m);let f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[8]=f):f=t[8],lt.useEffect(QN,f),null};function qN(t){return t.activeDirectoryKey}function YN(){_e.dismiss(Aa)}function QN(){return YN}const XN="\x1B",JN=new RegExp(`${XN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Co=Hn().transform(t=>t.replace(JN,"").trim()).nullish(),ZN=Yl({isOpenCodeReady:Ql().optional(),openCodeRunning:Ql().optional(),lastOpenCodeError:Co,opencodeBinaryResolved:Co,lastOpenCodeLaunchDiagnostics:Yl({sourceBinary:Co,binary:Co}).nullish()}),e5=async(t,e=as)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=ZN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},t5=(t,e)=>{if(t)return"startup.initRecovery.openCodeUnavailable";switch(e?.step){case"serverUnreachable":return"startup.initRecovery.serverUnreachable";case"openCodeUnavailable":return"startup.initRecovery.openCodeUnavailable";case"loadAgents":return"startup.initRecovery.loadAgentsFailed";default:return"startup.initRecovery.unexpected"}},Od=In(()=>en(()=>import("./OnboardingScreen-DiMFS3A7.js"),__vite__mapDeps([153,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.OnboardingScreen}))),s5=()=>{const t=nt.c(3),e=ye(l5),n=ye(c5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(HN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},n5=t=>{const e=nt.c(33),{onRetry:n,isRetrying:r}=t,{t:i}=At(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const N=new AbortController,P=qt(),C=setTimeout(()=>N.abort(),5e3);return e5(N.signal).then(T=>{!N.signal.aborted&&qt()===P&&l(T)}).catch(d5).finally(()=>clearTimeout(C)),()=>{N.abort(),clearTimeout(C)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=Wt(u5),m=o?null:u?.message??null;let f;e[2]!==i?(f=i("startup.initRecovery.title"),e[2]=i,e[3]=f):f=e[3];let g;e[4]!==f?(g=s.jsx("h1",{className:"typography-title text-foreground",children:f}),e[4]=f,e[5]=g):g=e[5];let y;e[6]!==o||e[7]!==u||e[8]!==i?(y=i(t5(o,u)),e[6]=o,e[7]=u,e[8]=i,e[9]=y):y=e[9];let b;e[10]!==y?(b=s.jsx("p",{className:"typography-body text-muted-foreground",children:y}),e[10]=y,e[11]=b):b=e[11];let j;e[12]!==g||e[13]!==b?(j=s.jsxs("div",{className:"flex flex-col gap-2",children:[g,b]}),e[12]=g,e[13]=b,e[14]=j):j=e[14];let x;e[15]!==m||e[16]!==i?(x=m&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:m})]}),e[15]=m,e[16]=i,e[17]=x):x=e[17];let h;e[18]!==o||e[19]!==i?(h=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=h):h=e[20];let p;e[21]!==r||e[22]!==i?(p=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=p):p=e[23];let w;e[24]!==r||e[25]!==n||e[26]!==p?(w=s.jsx(mt,{type:"button",onClick:n,disabled:r,children:p}),e[24]=r,e[25]=n,e[26]=p,e[27]=w):w=e[27];let S;return e[28]!==w||e[29]!==j||e[30]!==x||e[31]!==h?(S=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[j,x,h,w]})}),e[28]=w,e[29]=j,e[30]=x,e[31]=h,e[32]=S):S=e[32],S},Bd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",r5=()=>{if(typeof window>"u"||!Tx())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},o5=t=>{const e=nt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=Zt(f5),l=ot(m5),a=ot(h5),d=Ub(),u=c.useRef(null);let m;e[0]!==n.directory?(m=Bd(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let g;e[2]!==o?(g=Bd(o),e[2]=o,e[3]=g):g=e[3];const y=g;let b,j;if(e[4]!==y||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(b=()=>{if(r||f&&y!==f)return;const N=`${f}
886
886
  ${n.sessionId}`;u.current===N&&l||(u.current=N,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},j=[y,l,n.directory,n.sessionId,f,r,a,d],e[4]=y,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=b,e[13]=j):(b=e[12],j=e[13]),c.useEffect(b,j),f&&y!==f)return null;let x;e[14]!==i?(x=s.jsx(qu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=x):x=e[15];let h;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(nu,{}),e[16]=h):h=e[16];let p;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(p=s.jsx(su,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=p):p=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Yu,{}),e[21]=w):w=e[21];let S;return e[22]!==x||e[23]!==p?(S=s.jsxs(s.Fragment,{children:[x,h,p,w]}),e[22]=x,e[23]=p,e[24]=S):S=e[24],S};function i5({apis:t}){c.useEffect(()=>{hh("App:mounted"),ph()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Wt(L=>L.initializeApp),n=Wt(L=>L.isInitialized),r=Wt(L=>L.isConnected),i=Wt(L=>L.providers.length),o=Wt(L=>L.agents.length),l=Wt(L=>L.loadProviders),a=Wt(L=>L.loadAgents),d=ot(L=>L.error),u=ot(L=>L.clearError),m=Zt(L=>L.currentDirectory),f=Zt(L=>L.setDirectory),g=Zt(L=>L.isSwitchingDirectory),[y,b]=c.useState(!1),j=pn(L=>L.refreshStatus),x=Ui(L=>L.refreshStatus),[h,p]=c.useState(()=>t.runtime.isVSCode),[w,S]=c.useState(!1),[N,P]=c.useState(!1),[C,T]=c.useState(0),[R,M]=c.useState(0),[F,K]=c.useState(!1),D=ye(L=>L.wideChatLayoutEnabled),U=ye(L=>L.mobileKeyboardMode),A=c.useMemo(()=>mn(),[]),E=Ea(L=>L.setPlanModeEnabled),[W,k]=c.useState(()=>bl()),[v,I]=c.useState(()=>{const L=xl();return L!==null?yl({isDesktopShell:!0,bootOutcome:L}):null}),H=c.useRef(!1),$=c.useMemo(()=>r5(),[]),re=!$||w;c.useEffect(()=>(wl(y),Nd(y),()=>{wl(!1),Nd(!1)}),[y]),c.useEffect(()=>{gh(U)},[U]),c.useEffect(()=>{p(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>vr(L=>{gp(L),M(oe=>oe+1),P(!1),T(oe=>oe+1)}),[]);const te=zl(L=>{const oe=qt();return Object.values(L.runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===oe).map(ce=>`${ce.originalSessionID}:${ce.phase}:${ce.lastForwardedMessageID??""}:${ce.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if($)return;const L=qt(),oe=Object.values(zl.getState().runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===L);for(const ce of oe)$b(ce.originalSessionID)},[te,$,R]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",D),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[D]),c.useEffect(()=>(vl(t),()=>vl(null)),[t]),c.useEffect(()=>{$||(j(t.github,{force:!0}),x(t.linear,{force:!0}))},[t.github,t.linear,$,r,j,x,R]),zb();const ee=W==="valid",ue=v?.screen==="main";c.useEffect(()=>{if(!bh({isDesktopShell:A,isInitialized:n,bootOutcomeKnown:ee,bootViewIsMain:ue}))return;const L=setTimeout(()=>{const oe=document.getElementById("initial-loading");oe&&(oe.classList.add("fade-out"),setTimeout(()=>{oe.remove()},300))},150);return()=>clearTimeout(L)},[A,n,ee,ue]),c.useEffect(()=>{if(!A||W!=="malformed")return;const L=document.getElementById("initial-loading");L&&(L.textContent="Desktop startup failed — please restart the app.")},[A,W]),c.useEffect(()=>{if(A)return;const L=setTimeout(()=>{const oe=document.getElementById("initial-loading");oe&&!n&&(oe.classList.add("fade-out"),setTimeout(()=>{oe.remove()},300))},5e3);return()=>clearTimeout(L)},[A,n]),c.useEffect(()=>{let L=!1;return(async()=>{const ce=await as("/health",{method:"GET"}).catch(()=>null);if(!ce||!ce.ok||L)return;const pe=await ce.json().catch(()=>null);if(!pe||L)return;const Y=pe.planModeExperimentalEnabled;E(Y===!0||Y===1||Y==="1"||Y==="true")})(),()=>{L=!0}},[E]),c.useEffect(()=>{h||e()},[e,h]),c.useEffect(()=>{if(h||n)return;let L=!0,oe,ce=0;const pe=10,Y=1e3,ve=async()=>{if(!L)return;if(ce>=pe){P(!0);return}const Ee=Wt.getState();if(Ee.isInitialized){P(!1);return}ce+=1,await Ee.initializeApp();const je=Wt.getState();if(!L)return;if(je.isInitialized){P(!1);return}if(ce>=pe){P(!0);return}const ge=Math.min(Y*Math.pow(2,ce-1),16e3);oe=setTimeout(ve,ge)};return oe=setTimeout(ve,Y),()=>{L=!1,oe&&clearTimeout(oe)}},[C,n,h]),c.useEffect(()=>{n&&P(!1)},[n]),c.useEffect(()=>{if(!N)return;const L=document.getElementById("initial-loading");L&&(L.classList.add("fade-out"),setTimeout(()=>{L.remove()},300))},[N]),c.useEffect(()=>{if(h||!r||i>0&&o>0)return;let L=!0,oe=0;const ce=15,pe=async()=>{const ve=Wt.getState();if(!(ve.providers.length>0&&ve.agents.length>0))try{ve.providers.length===0&&await l({source:"startupRecovery"}),Wt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};pe();const Y=setInterval(()=>{if(L){if(++oe>=ce){clearInterval(Y);return}pe()}},2e3);return()=>{L=!1,clearInterval(Y)}},[r,h,a,l,i,o]),c.useEffect(()=>{g||h||r&&mr.setDirectory(m)},[m,g,r,h]),c.useEffect(()=>{if(!$||typeof window>"u")return;const L=pe=>{S(pe?.visible===!0)},oe=pe=>{if(pe.origin!==window.location.origin||pe.source!==window.parent)return;const Y=pe.data;Y?.type===rf&&L(Y.payload)},ce=window;return ce.__openchamberSetEmbeddedVisibility=L,window.addEventListener("message",oe),Ix(),()=>{window.removeEventListener("message",oe),ce.__openchamberSetEmbeddedVisibility===L&&delete ce.__openchamberSetEmbeddedVisibility}},[$]),c.useEffect(()=>{!$?.directory||h||m!==$.directory&&f($.directory,{showOverlay:!1})},[m,$,h,f]),c.useEffect(()=>{if(!$||typeof window>"u")return;const L=oe=>{oe.storageArea===window.localStorage&&oe.key==="ui-store"&&ye.persist.rehydrate()};return window.addEventListener("storage",L),()=>{window.removeEventListener("storage",L)}},[$]),c.useEffect(()=>{if(typeof window>"u")return;const L=oe=>{const ce=oe.detail,pe=typeof ce?.sessionId=="string"?ce.sessionId.trim():"";if(!pe)return;const Y=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null;ot.getState().setCurrentSession(pe,Y)};return window.addEventListener("openchamber:open-session",L),()=>window.removeEventListener("openchamber:open-session",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{Nn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",L),()=>window.removeEventListener("openchamber:open-mini-chat",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{const oe=ot.getState().currentSessionId;oe&&Pu(oe)};return window.addEventListener("focus",L),()=>window.removeEventListener("focus",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=oe=>{const ce=oe.detail,pe=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null,Y=typeof ce?.projectId=="string"&&ce.projectId.trim().length>0?ce.projectId.trim():null,ve=!!(pe||Y);ye.getState().setSessionSwitcherOpen(!1),ot.getState().openNewSessionDraft({target:ve?"project":"chat",selectedProjectId:ve?Y:null,directoryOverride:ve?pe:null,preserveDirectoryOverride:!!pe})};return window.addEventListener("openchamber:open-draft-session",L),()=>window.removeEventListener("openchamber:open-draft-session",L)},[]),c.useEffect(()=>{typeof window>"u"||!n||g||H.current||(H.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,g]),Wb({enabled:re}),FN({enabled:re}),$N(m||null),KN(),Kb(),UN(),Vb(),ix(),bp();const de=c.useCallback(()=>{b(L=>!L)},[]);pN(de),AN(),MN(!$),c.useEffect(()=>{if($)return;const L=()=>b(oe=>!oe);return window.addEventListener("openchamber:memory-debug-toggle",L),()=>window.removeEventListener("openchamber:memory-debug-toggle",L)},[$]),c.useEffect(()=>{$||d&&setTimeout(()=>u(),5e3)},[u,$,d]),c.useEffect(()=>{if(!A||W!=="not-injected")return;let L=!1,oe=0;const ce=200,pe=2e3,Y=50,ve=()=>{if(L)return;oe++;const Ee=bl();if(Ee!=="not-injected"){if(L=!0,k(Ee),Ee==="valid"){const ge=xl();ge&&I(yl({isDesktopShell:!0,bootOutcome:ge}))}return}const je=Math.min(ce*Math.pow(1.1,oe),pe);if(oe>=Y){const ge=document.getElementById("initial-loading");ge&&!ge.textContent?.includes("taking longer")&&(ge.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(ve,je)};return window.setTimeout(ve,ce),()=>{L=!0}},[A,W]);const Te=c.useCallback(async()=>{if(xh({isDesktopShell:mn(),isDesktopLocalOriginActive:qo()})){await yh();return}window.location.reload()},[]),we=c.useCallback(async()=>{if(!F){P(!1),K(!0);try{await Wt.getState().initializeApp()}finally{K(!1)}Wt.getState().isInitialized||T(L=>L+1)}},[F]),fe=L=>{if(L.screen==="recovery")return L.variant};if(A&&v&&v.screen!=="main"){if(v.screen==="chooser")return s.jsx(ms,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Od,{mode:"first-launch",localAvailable:v.localAvailable!==!1,onCliAvailable:Te,onChooseRemote:()=>{}})})})});const L=fe(v),oe=v.screen==="recovery"&&"url"in v?v.url:void 0;return s.jsx(ms,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Od,{mode:"recovery",recoveryVariant:L,recoveryHostUrl:oe,recoveryHostLabel:void 0,localAvailable:v.localAvailable!==!1,onCliAvailable:Te})})})})}if($)return s.jsx(ms,{children:s.jsx(Wl,{sdk:mr.getSdkClient(),directory:m||"",children:s.jsx(Kl,{apis:t,children:s.jsx(Qi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(o5,{embeddedSessionChat:$,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:re}),s.jsx(Vl,{}),s.jsx(Ul,{})]})})})},R)});if(N&&!n&&!h&&!$)return s.jsx(ms,{children:s.jsx(n5,{onRetry:()=>{we()},isRetrying:F},R)});const Ne=!n&&!A;return s.jsx(ms,{children:s.jsx(Wl,{sdk:mr.getSdkClient(),directory:m||"",children:s.jsx(Kl,{apis:t,children:s.jsx(F3,{children:s.jsx(Qi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:A?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(qu,{embeddedBackgroundWorkEnabled:re}),s.jsx(nu,{}),s.jsx(GN,{}),s.jsx(m3,{}),s.jsx(xp,{ready:n&&(!A||ee&&ue)}),s.jsx(Yu,{}),s.jsx(Vl,{}),s.jsx(Ul,{}),!Ne&&s.jsxs(s.Fragment,{children:[s.jsx(yp,{}),s.jsx(s5,{}),y&&s.jsx(Y3,{onClose:()=>b(!1)})]})]})})})})},R)})}function a5(t){const e=nt.c(2);let n;return e[0]!==t?(n=s.jsx(pp,{children:s.jsx(i5,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function l5(t){return t.isAboutDialogOpen}function c5(t){return t.setAboutDialogOpen}function d5(){}function u5(t){return t.lastInitFailure}function f5(t){return t.currentDirectory}function m5(t){return t.currentSessionId}function h5(t){return t.setCurrentSession}const p5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Hb();wh().then(()=>{Promise.all([vh(),Gb()]).catch(t=>{console.error("[main] settings init failed:",t)}),qb(),Yb(),Qb()}).catch(t=>{console.error("[main] appearance init failed:",t)});const ym=document.getElementById("root");if(!ym)throw new Error("Root element not found");Xb();Um.createRoot(ym).render(s.jsx(lt.StrictMode,{children:s.jsx(Jb,{children:s.jsx(Zb,{children:s.jsx(ex,{children:s.jsx(tx,{children:s.jsx(a5,{apis:p5})})})})})}));const B5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{i1 as W,Yy as a,O5 as b,wf as g,B5 as m,o1 as u,yf as v};