@openchamber/web 2.6.0 → 2.6.1-canary.20261102.3

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 (107) hide show
  1. package/dist/assets/{AboutDialog-DBDN-gwQ.js → AboutDialog-BTYnMXM0.js} +1 -1
  2. package/dist/assets/{AboutLogo-BP87552a.js → AboutLogo-BwyB9sbV.js} +1 -1
  3. package/dist/assets/{ArchiveView-GN7gU2qK.js → ArchiveView-BsWIv-C4.js} +1 -1
  4. package/dist/assets/{ChangeRequestDiffUnavailable-B28oeUds.js → ChangeRequestDiffUnavailable-ED92kmXz.js} +1 -1
  5. package/dist/assets/{ChangedPathLabel-DV4XTf6K.js → ChangedPathLabel-7Zbbq-FE.js} +1 -1
  6. package/dist/assets/{CommandPalette-Dvsy8IHV.js → CommandPalette-CLlDfj5e.js} +1 -1
  7. package/dist/assets/{DiffView-BXm5iGeW.js → DiffView-CQOHl1hv.js} +1 -1
  8. package/dist/assets/{FilesView-CAXuJLle.js → FilesView-D00Dnc8i.js} +1 -1
  9. package/dist/assets/{GitView-D29soKpK.js → GitView-Z4zWCBn1.js} +1 -1
  10. package/dist/assets/{GuestSurfacePane-Dw0Um8RG.js → GuestSurfacePane-OM2GGOiX.js} +1 -1
  11. package/dist/assets/{HelpDialog-DuO4UnZT.js → HelpDialog-DNqqtAW-.js} +1 -1
  12. package/dist/assets/{IntegrationsCatalogView-BrLbP8hQ.js → IntegrationsCatalogView-C4-oLIEz.js} +1 -1
  13. package/dist/assets/{JsonTreeView-ZZKmvRSL.js → JsonTreeView-Bw8E9Koo.js} +1 -1
  14. package/dist/assets/{MarkdownDiffPreview-DuH8ODuS.js → MarkdownDiffPreview-CaG-F6-b.js} +1 -1
  15. package/dist/assets/{MarkdownRendererImpl-DNGYmQPH.js → MarkdownRendererImpl-Cd3zotqp.js} +3 -3
  16. package/dist/assets/{MemoryDebugPanel-C7shSvtT.js → MemoryDebugPanel-DzMnnl_P.js} +1 -1
  17. package/dist/assets/{NoteEditor-Ba3KW2rV.js → NoteEditor-DWNlP4dC.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-CIyOLCq2.js → OnboardingScreen-DZVhaQUC.js} +1 -1
  19. package/dist/assets/{OpenCodeStatusDialog-ByN8gJ51.js → OpenCodeStatusDialog-BgseXyBy.js} +1 -1
  20. package/dist/assets/{OverviewView-B6SMyBTp.js → OverviewView-CohMMobq.js} +1 -1
  21. package/dist/assets/{PatchDiff-C8jKkgEf.js → PatchDiff-DGB_PTLK.js} +1 -1
  22. package/dist/assets/{PlanView-NMKJpsCH.js → PlanView-pwTIoUJK.js} +1 -1
  23. package/dist/assets/{ProjectActionsDialog-Ctr7-_lb.js → ProjectActionsDialog-C3rXp1WV.js} +1 -1
  24. package/dist/assets/{ReplyUiBlock-C-C95eJ_.js → ReplyUiBlock-B1NgzCEP.js} +1 -1
  25. package/dist/assets/{RunOverview-DNSvGB7-.js → RunOverview-BqmEhK3a.js} +1 -1
  26. package/dist/assets/{ScheduledTasksDialog-BNXOjpPY.js → ScheduledTasksDialog-CXyiyIDe.js} +1 -1
  27. package/dist/assets/{SettingsView-ug8Oinyr.js → SettingsView-D7mytSZv.js} +1 -1
  28. package/dist/assets/{SettingsWindow-CKUU5T8p.js → SettingsWindow-CnjurTti.js} +1 -1
  29. package/dist/assets/{SidebarSectionsManager-DWJwQwVi.js → SidebarSectionsManager-D1hsBI-4.js} +1 -1
  30. package/dist/assets/{SourceBoardView-BQittQF3.js → SourceBoardView-BoMdMgmW.js} +1 -1
  31. package/dist/assets/{SpaceAccessDialog-CeZrOBod.js → SpaceAccessDialog-q5blJXG5.js} +1 -1
  32. package/dist/assets/{SpaceApplyDialog-DurN0_0Z.js → SpaceApplyDialog-Csq1Z7zY.js} +1 -1
  33. package/dist/assets/{SpaceRow-BkgNrW0R.js → SpaceRow-BvJCw88e.js} +1 -1
  34. package/dist/assets/{SpaceSetupOutput-BDkJcYrl.js → SpaceSetupOutput-Bzeasxqg.js} +1 -1
  35. package/dist/assets/{SpacesView-D6UCwVZp.js → SpacesView-DNI1yLAG.js} +1 -1
  36. package/dist/assets/{SubmoduleDiffSummary-BK5RTTC4.js → SubmoduleDiffSummary-B3CnCMwZ.js} +1 -1
  37. package/dist/assets/{ToolOutputDialog-CAenoFSA.js → ToolOutputDialog-inRAtLLn.js} +1 -1
  38. package/dist/assets/{ToolPartDiffPreview-CdjYwDyA.js → ToolPartDiffPreview-CJneViW_.js} +1 -1
  39. package/dist/assets/{UiBlock-t2ea_iLd.js → UiBlock-ChJiwt5R.js} +1 -1
  40. package/dist/assets/{UsageStatsView-D2AXngeb.js → UsageStatsView-CWV-BYPI.js} +1 -1
  41. package/dist/assets/{Virtualizer-V759EvEY.js → Virtualizer-BOHERqLh.js} +1 -1
  42. package/dist/assets/{WalkthroughView-CiQk4Tg_.js → WalkthroughView-BnT4-pMh.js} +1 -1
  43. package/dist/assets/{WorktreesView-Bmnk7eXM.js → WorktreesView-D_VUAXdo.js} +1 -1
  44. package/dist/assets/{appThemeRegistry-D4EuLaGF.js → appThemeRegistry-BBiQjAje.js} +1 -1
  45. package/dist/assets/{ar-9I6l4EAU.js → ar-BXROvDU9.js} +1 -1
  46. package/dist/assets/{codeHighlight-DD239VMc.js → codeHighlight-CJBps6zM.js} +1 -1
  47. package/dist/assets/{computeVirtualFileMetrics-BhVDZ-oP.js → computeVirtualFileMetrics-CXGHe7T5.js} +2 -2
  48. package/dist/assets/{contextFileOpenGuard-D9Z0ay-I.js → contextFileOpenGuard-Cp662aS-.js} +1 -1
  49. package/dist/assets/{date-time-DlgUVVwY.js → date-time-C4F_nWqa.js} +1 -1
  50. package/dist/assets/{de-CPlTX8kA.js → de-nCDq_bQg.js} +1 -1
  51. package/dist/assets/{es-BMaNboo9.js → es-CvZecQ0j.js} +1 -1
  52. package/dist/assets/{fileContentPoller-paKtimZt.js → fileContentPoller-D0GhYhQ3.js} +1 -1
  53. package/dist/assets/{flexokiTheme-Bv37aHkq.js → flexokiTheme-Df4MxCkn.js} +1 -1
  54. package/dist/assets/{fr-onOdSl19.js → fr-DzrngSh8.js} +1 -1
  55. package/dist/assets/{he-CgCCGzpX.js → he-uZ2JD0ys.js} +1 -1
  56. package/dist/assets/{highlights-ByNnuo4t.js → highlights-gD3Zrhb_.js} +1 -1
  57. package/dist/assets/{index-BKnb59RH.js → index-BNAoU1SB.js} +1 -1
  58. package/dist/assets/{initializeSharedPreferences-CFrNmgg0.js → initializeSharedPreferences-Cb-QZ9nO.js} +1 -1
  59. package/dist/assets/{install-EEjacdUD.js → install-BjzS6Z-p.js} +1 -1
  60. package/dist/assets/{isDiffPlainText-DUd8YJX0.js → isDiffPlainText-SBv5bM8c.js} +1 -1
  61. package/dist/assets/{isFilePlainText-BqR4iT-Y.js → isFilePlainText-QNmxHtqN.js} +1 -1
  62. package/dist/assets/{ja-CYYy1_I8.js → ja-CADF0HeI.js} +1 -1
  63. package/dist/assets/{katex.min-BBVkbKQY.js → katex.min-BCtkGOiC.js} +4 -4
  64. package/dist/assets/{ko-CupS3Elm.js → ko-BLGJMTce.js} +1 -1
  65. package/dist/assets/{main-B3MbWk_e.js → main-BAWvOAbS.js} +2 -2
  66. package/dist/assets/{main-Kwo8IqqZ.js → main-my1cVcab.js} +4 -4
  67. package/dist/assets/{miniChat-DelNi_yP.js → miniChat-C80tea9b.js} +2 -2
  68. package/dist/assets/{mobile-BIso4MdY.js → mobile-Bw86MtWV.js} +2 -2
  69. package/dist/assets/{nl-Di3GhSHB.js → nl-ClP-S61w.js} +1 -1
  70. package/dist/assets/{pageTitle-BL2yQcTV.js → pageTitle-Cph9nb1O.js} +1 -1
  71. package/dist/assets/{parseDiffFromFile-31PZ3lnE.js → parseDiffFromFile-Yp9eHLcj.js} +1 -1
  72. package/dist/assets/{pierreDiffTint-igvBfgMB.js → pierreDiffTint-CFyG2F44.js} +1 -1
  73. package/dist/assets/{pl-DEy-fwio.js → pl-LChBHlUo.js} +1 -1
  74. package/dist/assets/{pt-BR-Cqzgn2Hs.js → pt-BR-CV84EAxr.js} +1 -1
  75. package/dist/assets/{relocateRestoredSession-CGvQdGRX.js → relocateRestoredSession-gkROUapx.js} +2 -2
  76. package/dist/assets/{renderElectronMiniChatApp-hBJHkIHQ.js → renderElectronMiniChatApp-CJN6HCUs.js} +2 -2
  77. package/dist/assets/{renderMarkdownForExport-DWj11Yob.js → renderMarkdownForExport-BPMLtJlQ.js} +1 -1
  78. package/dist/assets/{renderMobileApp-Bzps4LvM.js → renderMobileApp-Cuc-A8vm.js} +3 -3
  79. package/dist/assets/{resolveLanguages-DHAaVkki.js → resolveLanguages-UhQ_Qm0O.js} +1 -1
  80. package/dist/assets/{runtimeEndpointReset-BPYbd6uu.js → runtimeEndpointReset-CMO7G_Ff.js} +5 -5
  81. package/dist/assets/{scheduledTasksApi-D6FhT0TU.js → scheduledTasksApi-Mn2aZ7Rl.js} +1 -1
  82. package/dist/assets/{shiki-y7boL955.js → shiki-B7QfMAec.js} +1 -1
  83. package/dist/assets/{space-apply-9idN6j4k.js → space-apply-CNISDYMA.js} +1 -1
  84. package/dist/assets/{space-close-CjDS5mSo.js → space-close-C4pr8Kt0.js} +1 -1
  85. package/dist/assets/{spaceNetwork-DeZE7V6c.js → spaceNetwork-DUg5u0h8.js} +1 -1
  86. package/dist/assets/{stream-tokenizer-UaU7yP0V.js → stream-tokenizer-CSMIYyXj.js} +1 -1
  87. package/dist/assets/{textMateThemeFromAppTheme-fsNcE7v2.js → textMateThemeFromAppTheme-CbTfkuJp.js} +1 -1
  88. package/dist/assets/{tr-DL0uHNVd.js → tr-BXliZ8MC.js} +1 -1
  89. package/dist/assets/{uk-qdUsCGYW.js → uk-CxABjNd2.js} +1 -1
  90. package/dist/assets/{useAppFontEffects-DpDiWkkc.js → useAppFontEffects-C_TEX3sk.js} +16 -16
  91. package/dist/assets/{useBranchPullRequestRequest-Cbky4ZeH.js → useBranchPullRequestRequest-CLTracub.js} +1 -1
  92. package/dist/assets/{useCallableModelProviders-Y8rZzgJF.js → useCallableModelProviders-CcETbnHf.js} +1 -1
  93. package/dist/assets/{useDiffFindSurface-B7KQR8iQ.js → useDiffFindSurface-BY6KBx38.js} +1 -1
  94. package/dist/assets/{useGitCleanLine-D6E5eJm2.js → useGitCleanLine-KstI02a0.js} +1 -1
  95. package/dist/assets/{useInlineCommentController-CF8aQO6-.js → useInlineCommentController-ByiCLJwx.js} +1 -1
  96. package/dist/assets/{useMarkdownLocalAssets-BXBlTj-y.js → useMarkdownLocalAssets-DG5IJM9Y.js} +1 -1
  97. package/dist/assets/{useRootScrollLock-3qp1KaTm.js → useRootScrollLock-ClFa_ezf.js} +2 -2
  98. package/dist/assets/{useWalkthroughReview-BNHJ06yD.js → useWalkthroughReview-BjhHwuOR.js} +1 -1
  99. package/dist/assets/{useWholeFileComment-CisbVgb0.js → useWholeFileComment-Dbr3Y7Ga.js} +1 -1
  100. package/dist/assets/{useWorktreeArchiveActions-03WxbHUV.js → useWorktreeArchiveActions-jkcvj4mj.js} +1 -1
  101. package/dist/assets/{vendor-codemirror-language-data-C6MZftZF.js → vendor-codemirror-language-data-Cy549AYN.js} +2 -2
  102. package/dist/assets/{zh-CN-B3B6hhd4.js → zh-CN-Cj8b8iKH.js} +1 -1
  103. package/dist/assets/{zh-TW-CBU98qnu.js → zh-TW-CyjD8MXO.js} +1 -1
  104. package/dist/index.html +2 -2
  105. package/dist/mini-chat.html +2 -2
  106. package/dist/mobile.html +2 -2
  107. package/package.json +3 -3
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-D29soKpK.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DpDiWkkc.js","assets/katex.min-BBVkbKQY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-Csf1sqWl.js","assets/vendor-opencode-client-CqFY51gT.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/vendor-streamdown-BbSYZ3NF.js","assets/vendor-markdown-BTUqNk6W.js","assets/vendor-mdast-util-from-markdown-CZHjOE75.js","assets/vendor-micromark-util-decode-numeric-character-reference-CNs1qBpV.js","assets/vendor-micromark-util-decode-string-fHsnqYdj.js","assets/vendor-decode-named-character-reference-C3-224fz.js","assets/vendor-micromark-util-normalize-identifier-C9ANKk3v.js","assets/vendor-micromark-AWM-NZXP.js","assets/vendor-micromark-util-combine-extensions-d8XJZrgA.js","assets/vendor-micromark-util-chunked-DrRIdSP-.js","assets/vendor-micromark-factory-space-PzSHLgmq.js","assets/vendor-micromark-util-character-CW3Cu1MS.js","assets/vendor-micromark-core-commonmark-kzTLNXAm.js","assets/vendor-micromark-util-classify-character-tcLuZZwM.js","assets/vendor-micromark-util-resolve-all-PQCKh0dx.js","assets/vendor-micromark-util-subtokenize-BF1Jf29a.js","assets/vendor-micromark-factory-destination-Sj0xfi0V.js","assets/vendor-micromark-factory-label-amyP0HdC.js","assets/vendor-micromark-factory-title-khnLkZK6.js","assets/vendor-micromark-factory-whitespace-eIB00uTl.js","assets/vendor-micromark-util-html-tag-name-DbKNfynz.js","assets/vendor-unist-util-stringify-position-Ch_qCilz.js","assets/vendor-mdast-util-to-string-C_aolqmU.js","assets/vendor-unist-util-visit-DhPeCsfG.js","assets/vendor-unist-util-visit-parents-DlviEg7Z.js","assets/vendor-unist-util-is-BPZGFiMU.js","assets/vendor-hast-util-raw-DvvLJg15.js","assets/vendor-ungap-structured-clone--gfxRhYI.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-parse5-DwmzEj2o.js","assets/vendor-entities-wUUgTZDW.js","assets/vendor-web-namespaces-bsVAaBS1.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-unist-util-position-60F3QETU.js","assets/vendor-hast-util-from-parse5-Ba3T6RJI.js","assets/vendor-devlop-0Dp3JUBc.js","assets/vendor-property-information-Boo8Xpef.js","assets/vendor-hastscript-BrPNioaz.js","assets/vendor-comma-separated-tokens-CRUGqg4f.js","assets/vendor-space-separated-tokens-D7QSIrTI.js","assets/vendor-hast-util-parse-selector-TXfch5wI.js","assets/vendor-vfile-location-LfEFwJ2h.js","assets/vendor-hast-util-to-parse5-BoysVIPW.js","assets/vendor-hast-util-sanitize-2aGO5ay8.js","assets/vendor-micromark-extension-gfm-CsfPlnlB.js","assets/vendor-micromark-extension-gfm-autolink-literal-BYug7onl.js","assets/vendor-micromark-extension-gfm-footnote-OFl1FCH2.js","assets/vendor-micromark-extension-gfm-strikethrough-CyFiuwBf.js","assets/vendor-micromark-extension-gfm-table-dgw4LfUw.js","assets/vendor-micromark-extension-gfm-task-list-item-Dnadzr9U.js","assets/vendor-mdast-util-gfm-CroMDYLM.js","assets/vendor-mdast-util-gfm-autolink-literal-CTruMtvI.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-mdast-util-find-and-replace-DB9iC-bx.js","assets/vendor-escape-string-regexp-BaJN9MlJ.js","assets/vendor-mdast-util-gfm-footnote-C-csI7OF.js","assets/vendor-mdast-util-gfm-strikethrough-BcskTdio.js","assets/vendor-mdast-util-gfm-table-DhPwQIyj.js","assets/vendor-markdown-table-DvhhVmnL.js","assets/vendor-mdast-util-to-markdown-Cl3qaiyc.js","assets/vendor-longest-streak-CtXnX3Xp.js","assets/vendor-mdast-util-phrasing-4oVbNLC3.js","assets/vendor-mdast-util-gfm-task-list-item-DMU5mK_M.js","assets/vendor-mdast-util-to-hast-CWnLaQSO.js","assets/vendor-micromark-util-sanitize-uri-BbwQ7CLk.js","assets/vendor-trim-lines-D8znQY54.js","assets/vendor-micromark-extension-cjk-friendly-BzZDGrF5.js","assets/vendor-micromark-extension-cjk-friendly-util-D5lVNoxW.js","assets/vendor-get-east-asian-width-CPhS2cOv.js","assets/vendor-micromark-util-symbol-JJPacVTp.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-BZ3pe_qd.js","assets/vendor-micromark-extension-cjk-friendly-gfm-strikethrough-CqW-Ep4M.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-BdPDQFO7.js","assets/vendor-hast-util-from-html-isomorphic-B0Kn01s9.js","assets/vendor-hast-util-from-dom-DeNf9aYW.js","assets/vendor-katex-DBqql0K7.js","assets/vendor-hast-util-to-text-0GXLnBvt.js","assets/vendor-hast-util-is-element-CuOmiqQi.js","assets/vendor-unist-util-find-after-CMaZmLxc.js","assets/vendor-micromark-extension-math-BRFoDziv.js","assets/vendor-mdast-util-math-wB-IJCL0.js","assets/vendor-remend-r8cP_t-e.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-marked-DN3zOnEe.js","assets/vendor-hast-util-to-jsx-runtime-Bq6JeJCx.js","assets/vendor-style-to-js-CI2G4dgu.js","assets/vendor-style-to-object-BAv4SQXc.js","assets/vendor-inline-style-parser-BlqBsVO4.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-estree-util-is-identifier-name-BgBfM8ME.js","assets/vendor-vfile-message-DqhD22jI.js","assets/vendor-unified-1CQKw2_w.js","assets/vendor-bail-FqpXQuLt.js","assets/vendor-extend-B94qxKr5.js","assets/vendor-is-plain-obj-C1gvLhAf.js","assets/vendor-trough-B_b8ryxu.js","assets/vendor-vfile-BCWrK60u.js","assets/vendor-html-url-attributes-D46m5wfe.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/katex-arxpHWv8.css","assets/vendor-base-ui-zhBy6TEG.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-Cy8dRGoy.js","assets/vendor-use-sync-external-store-CfLJGVyr.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-dnd-kit-core-Br1Cs7RV.js","assets/vendor-dnd-kit-utilities-DZ9KbT5S.js","assets/vendor-dnd-kit-accessibility-CYclfhtC.js","assets/vendor-dnd-kit-sortable-DpfLEOLv.js","assets/vendor-tanstack-react-virtual-C_IilPt1.js","assets/vendor-tanstack-virtual-core-DsQgKrou.js","assets/vendor-framer-motion-C_wK4GIM.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-CjjsURR-.js","assets/vendor-codemirror-state-Cd8udR5z.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-Ciie9ey-.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-8HZTPOnt.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CZEcqU6G.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-DmqaSK_j.js","assets/vendor-lezer-javascript-CWSwshuO.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BGedy2gC.js","assets/vendor-codemirror-lang-json-DVAYKmoO.js","assets/vendor-lezer-json-Cn1mncjr.js","assets/vendor-codemirror-lang-css-BLpgXfL2.js","assets/vendor-lezer-css-B2Hx_Nps.js","assets/vendor-codemirror-lang-html-S3jxr3Mo.js","assets/vendor-lezer-html-Cr8K5DGw.js","assets/vendor-codemirror-lang-markdown-D1jveRI5.js","assets/vendor-lezer-markdown-TQKzBB8i.js","assets/vendor-codemirror-language-data-C6MZftZF.js","assets/vendor-codemirror-lang-python-B-5UC9Ui.js","assets/vendor-lezer-python-BUoImtUb.js","assets/vendor-sonner-Dw26OnzC.js","assets/vendor-cmdk-BtSpU-Io.js","assets/vendor-radix-ui-react-dialog-OIW6VLWw.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D4RvEbuR.js","assets/vendor-radix-ui-react-context-BbFoxCHu.js","assets/vendor-radix-ui-react-id-aGag8i_5.js","assets/vendor-radix-ui-react-use-layout-effect-B1oLzD-j.js","assets/vendor-radix-ui-react-use-controllable-state-BjnNPGHq.js","assets/vendor-radix-ui-react-dismissable-layer-DpT6mMbO.js","assets/vendor-radix-ui-react-primitive-CrN9dRDb.js","assets/vendor-radix-ui-react-slot-BjbalUfz.js","assets/vendor-radix-ui-react-use-callback-ref-CcC_buIU.js","assets/vendor-radix-ui-react-use-escape-keydown-Cp1WWKTC.js","assets/vendor-radix-ui-react-focus-scope-D1noLHmd.js","assets/vendor-radix-ui-react-portal-BlUEzfrF.js","assets/vendor-radix-ui-react-presence-BGqFfiW4.js","assets/vendor-radix-ui-react-focus-guards-CSS2IbZC.js","assets/vendor-react-remove-scroll-Der_cv-1.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-Clwl9llp.js","assets/vendor-react-style-singleton-D_xJlTqU.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-BdLl6ZIw.js","assets/vendor-use-callback-ref-CXJF1lEr.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-DAdshx9l.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-BPYbd6uu.js","assets/space-apply-9idN6j4k.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-D6E5eJm2.js","assets/useBranchPullRequestRequest-Cbky4ZeH.js","assets/parseDiffFromFile-31PZ3lnE.js","assets/computeVirtualFileMetrics-BhVDZ-oP.js","assets/themeResolver-4dbEkEN5.js","assets/vendor-pierre-theming-D_TRfu0q.js","assets/hastToHtml-BHV14OWE.js","assets/vendor-hast-util-to-html-Jw3IXh58.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-diff-C3JhlQdm.js","assets/isDiffPlainText-DUd8YJX0.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-igvBfgMB.js","assets/Virtualizer-V759EvEY.js","assets/useInlineCommentController-CF8aQO6-.js","assets/appThemeRegistry-D4EuLaGF.js","assets/textMateThemeFromAppTheme-fsNcE7v2.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/ChangedPathLabel-DV4XTf6K.js","assets/useRootScrollLock-3qp1KaTm.js","assets/contextFileOpenGuard-D9Z0ay-I.js","assets/WalkthroughView-CiQk4Tg_.js","assets/ChangeRequestDiffUnavailable-B28oeUds.js","assets/useDiffFindSurface-B7KQR8iQ.js","assets/useWalkthroughReview-BNHJ06yD.js","assets/useCallableModelProviders-Y8rZzgJF.js","assets/useWholeFileComment-CisbVgb0.js","assets/DiffView-BXm5iGeW.js","assets/SubmoduleDiffSummary-BK5RTTC4.js","assets/FilesView-CAXuJLle.js","assets/flexokiTheme-Bv37aHkq.js","assets/vendor-codemirror-search-Bk6iB2TM.js","assets/vendor-replit-codemirror-vim-BpSlt2iY.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-BXBlTj-y.js","assets/fileContentPoller-paKtimZt.js","assets/JsonTreeView-ZZKmvRSL.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-BqR4iT-Y.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-DD239VMc.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-D6FhT0TU.js","assets/GuestSurfacePane-Dw0Um8RG.js","assets/SettingsWindow-CKUU5T8p.js","assets/SettingsView-ug8Oinyr.js","assets/install-EEjacdUD.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/pageTitle-BL2yQcTV.js","assets/SpaceRow-BkgNrW0R.js","assets/AboutLogo-BP87552a.js","assets/CommandPalette-Dvsy8IHV.js","assets/HelpDialog-DuO4UnZT.js","assets/ProjectActionsDialog-Ctr7-_lb.js","assets/OpenCodeStatusDialog-ByN8gJ51.js","assets/RunOverview-DNSvGB7-.js","assets/ScheduledTasksDialog-BNXOjpPY.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-DlgUVVwY.js","assets/ArchiveView-GN7gU2qK.js","assets/useWorktreeArchiveActions-03WxbHUV.js","assets/IntegrationsCatalogView-BrLbP8hQ.js","assets/UsageStatsView-D2AXngeb.js","assets/SourceBoardView-BQittQF3.js","assets/OverviewView-B6SMyBTp.js","assets/WorktreesView-Bmnk7eXM.js","assets/SpacesView-D6UCwVZp.js","assets/SpaceAccessDialog-CeZrOBod.js","assets/spaceNetwork-DeZE7V6c.js","assets/SpaceApplyDialog-DurN0_0Z.js","assets/SpaceSetupOutput-BDkJcYrl.js","assets/OnboardingScreen-CIyOLCq2.js","assets/AboutDialog-DBDN-gwQ.js","assets/MemoryDebugPanel-C7shSvtT.js"])))=>i.map(i=>d[i]);
2
- import{f as Be,j as s,R as l,r as Wt,a as Ul,h as ku}from"./vendor-react--VO_rL_p.js";import{bi as Jr,n as Yt,k as is,cr as ju,cs as Vl,u as X,bg as Us,aG as as,aR as Qr,c1 as us,ct as bi,aM as eo,cu as Cu,bT as Hl,cv as wt,cw as Tu,bd as Vo,l as wi,be as un,bf as Nr,bH as Nu,bj as ql,bb as yi,cx as Eu,cm as Gl,bO as ta,aP as Kl,cy as Pu,cz as mr,cA as Fr,cB as lr,cC as Iu,cD as tr,cE as Ru,cF as Ho,cG as yr,cH as vi,cI as to,cJ as Mn,aY as Lr,j as Vs,cK as Rn,cL as Du,cM as js,b as pn,cN as so,cO as Zl,cP as _u,cQ as Xs,cR as Au,cS as Xl,cT as Ou,cU as Mu,cV as Yl,cW as Fu,c3 as Lu,bS as $u,bY as Bu,bV as zu,bc as Wu,bn as xs,t as qo,bW as Uu,cX as Vu,cY as Hu,bu as Go,cZ as Si,c_ as qu,b9 as Gu,a_ as sa,cl as Jl,c$ as na,aI as Ql,d0 as Ku,v as ec,bX as Zu,d1 as ra,bA as ki,d2 as tc,bJ as Xu,aH as Yu,q as Ju,m as Qu,bh as sc,c9 as oa,ca as nc,cp as ef,c8 as tf,c5 as ia,d3 as sf,d4 as nf,bF as rf,bD as of,d5 as af,bK as lf,c7 as cf,d6 as df,d7 as uf,d8 as ff,d9 as aa,da as jo,db as la,dc as ca,dd as pf,bl as da,de as mf,df as hf,bm as ua,dg as gf,bE as xf,i as bf,a as wf}from"./katex.min-BBVkbKQY.js";import{_ as At}from"./vendor-vite-runtime-DD1OZmLC.js";import{bL as yf,bM as rc,aO as oc,bN as ds,r as fa,bO as vf,bP as Sf,bQ as pa,bR as ma,bS as ha,aV as kf,bT as jf,aQ as Cf,bU as ga,aR as xa,a0 as ic,a2 as ac,a4 as lc,a1 as cc,$ as ji,a6 as dc,a5 as uc,a3 as fc,aB as Tf,aC as Nf,aw as Ef,aI as Pf,aJ as If,ak as Rf,aE as Df,aD as _f,N as Af,z as Of,V as Mf,a8 as Ff,_ as Lf,a7 as $f,w as Bf,C as pc,m as zf,bV as fn,bp as Wf,bW as mc,bX as Er,bY as hc,bZ as Uf,b_ as gc,b$ as kn,c0 as ba,c1 as wa,c2 as Co,c3 as ya,aG as Pr,bm as Vf,bn as Hf,aM as qf,bH as Gf,bI as xc,c4 as Kf,bo as Zf,c5 as Xf,c6 as Yf,bg as Jf,c7 as va,c8 as To,c9 as rn,ca as jn,cb as Qf,cc as Sa,cd as ep,ce as tp,cf as sp,cg as np,ch as rp,ci as op,cj as ip,ck as ka,cl as ap,cm as lp,bq as cp,bf as dp,bG as up,br as fp,bJ as pp,cn as mp,bC as hp,bD as gp,aP as bc,co as xp,cp as bp,cq as wp,cr as yp,cs as vp,bF as Sp,ct as kp,by as jp,cu as Cp,cv as Tp,bv as Np,bt as Ep,bu as Pp,bs as Ip,bw as Rp,bK as Dp,bB as _p,bA as Ap,bE as Op,cw as Mp,cx as Fp}from"./runtimeEndpointReset-BPYbd6uu.js";import{fE as ja,aL as no,Y as Gt,$ as tt,c9 as hr,Q as $e,fg as Lp,ca as $p,I as se,fh as Bp,u as at,jF as on,X as ts,jG as zp,av as ws,ay as Es,aw as Ci,jH as wc,b5 as gn,fD as yc,fC as Wp,bn as Up,jI as vc,jJ as Vp,jK as Hp,bb as gr,ab as Ft,aa as Lt,ac as $t,ir as Hs,cd as Sc,jL as qp,jM as Gp,a1 as Kp,l as Fn,F as Ln,D as $n,af as Zp,bl as kc,n as fs,q as Bn,t as zn,b2 as Xp,A as _e,ci as jc,iZ as Yp,jN as Cc,bt as Jp,jO as Qp,jP as em,iH as Tc,jQ as tm,aJ as Gs,ed as sm,au as nm,be as Ns,b0 as ro,bc as oo,it as Dn,bd as io,jR as rm,jS as ao,jT as om,iE as Pn,aK as yn,jU as im,iF as am,eh as Nc,jV as lm,gT as xr,gU as lo,c5 as $r,ei as cm,jW as dm,jX as um,jY as fm,jZ as pm,j_ as mm,j$ as hm,k0 as gm,k1 as Ti,bJ as Ni,em as xm,o as Br,B as ft,k2 as Wn,a2 as xn,a3 as bn,a4 as wn,a5 as qt,ad as mn,k3 as Ec,k4 as Ei,aY as Qt,k5 as Pc,k6 as bm,cn as Ic,k7 as wm,k8 as ym,bB as Is,k9 as vm,bO as hn,ka as Ca,bG as Ir,kb as Sm,dI as km,bW as Pi,kc as jm,kd as Rc,ke as Ii,dw as Cm,db as zr,dC as Dc,dq as Ri,dr as Di,kf as _c,y as Un,C as Ko,gR as Tm,gw as Nm,h6 as Em,kg as Pm,ga as Ac,bD as Ws,K as _i,by as Im,aq as vs,bC as Oc,bQ as Ta,bP as Jn,gb as Rm,bR as Dm,c1 as Ai,bY as _m,gd as No,kh as Am,z as Om,bo as Mm,bp as Fm,bq as Lm,br as $m,bs as Bm,cM as Na,bH as Mc,bF as Wr,ki as zm,kj as Wm,kk as Um,dl as qn,bx as Vm,bz as co,bA as Hm,bE as qm,aI as Vn,g_ as Gm,gg as Km,bX as Oi,kl as Fc,km as Lc,kn as Zm,dh as Xm,df as Ea,ko as Ym,hf as Jm,dn as Qm,kp as eh,ds as th,kq as sh,kr as nh,dg as Pa,dB as rh,dj as oh,aZ as ih,ks as ah,kt as lh,ku as ch,kv as Mi,kw as Fi,kx as dh,ky as uh,kz as fh,kA as ph,kB as mh,jo as Li,kC as hh,kD as gh,kE as xh,kF as bh,kG as $i,kH as wh,kI as yh,kJ as vh,kK as $c,bm as Sh,kL as kh,x as Bc,kM as jh,kN as En,ao as Ch,kO as Th,V as zt,kP as Nh,cZ as Eh,cA as Ph,kQ as zc,kR as Ih,kS as Rr,kT as Cn,ie as Rh,cP as Dh,kU as _h,kV as Wc,j5 as Uc,e8 as uo,dv as Ah,d2 as Oh,kW as Bi,kX as Mh,eF as Js,kY as Vc,bf as Fh,kZ as Lh,k_ as $h,k$ as Bh,l0 as Eo,l1 as zh,l2 as Wh,dS as Uh,e9 as Vh,fz as zi,fw as Hh,is as qh,iu as Gh,l3 as cr,fv as Hc,fu as qc,iv as Kh,iw as Zh,fx as Xh,dW as Yh,aX as Jh,aM as Qh,l4 as Po,l5 as eg,l6 as tg,l7 as Gc,l8 as Kc,l9 as sg,la as ng,lb as Zo,lc as Zs,dc as rg,ld as og,le as Ia,lf as ig,lg as ag,ba as Ur,lh as Ra,li as lg,lj as cg,lk as dg,iL as ug,ll as fg,iM as Da,iN as pg,cU as mg,cf as _a,iO as hg,iP as gg,lm as xg,iQ as bg,ln as wg,k as yg,lo as Io,lp as Aa,f5 as vg,fJ as Xo,lq as Zc,hO as fo,lr as Sg,i7 as kg,ls as jg,lt as Xc,lu as Cg,lv as Yc,dV as Tg,dU as Wi,dT as Ui,dZ as Ng,lw as Oa,lx as Eg,ly as Pg,dX as Ig,lz as Yo,G as Jc,bU as Qc,lA as Rg,a0 as Dg,e$ as Ma,lB as _g,lC as ed,b6 as Fa,d_ as Ag,iB as Og,lD as Mg,iC as Fg,lE as Lg,lF as $g,jE as Bg,c_ as La,lG as zg,iG as Wg,lH as Ug,jp as Vg,er as Hg,lI as qg,e6 as Gg,es as Kg,eu as Zg,et as Xg,eC as Yg,eB as Jg,ev as Qg,jq as e1,eA as t1,ew as s1,ex as n1,ey as r1,ez as o1,eH as i1,a as a1,s as l1,b as c1,c as d1,jx as u1,ah as f1,eK as p1,eL as m1,eM as h1}from"./useAppFontEffects-DpDiWkkc.js";import{f as td,u as sd,S as g1,W as nd,a as x1,G as b1,b as w1,c as y1}from"./useRootScrollLock-3qp1KaTm.js";import{h as rd,i as Vr,T as od,M as id,D as ad,f as Jo}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as v1,h as S1,u as ld,S as cd,v as k1,a as j1}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as dd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{S as C1,M as T1,C as N1,i as E1,j as P1,k as I1}from"./vendor-base-ui-zhBy6TEG.js";import{a as an,O as R1,d as D1,D as _1,b as A1,v as $a,t as Ba,u as O1,m as za}from"./contextFileOpenGuard-D9Z0ay-I.js";import{u as Qo,c as po,p as M1}from"./vendor-zustand-C9tWdk0j.js";import{o as Qs,s as Ps,n as mo,d as ud,f as F1,e as dr,a as ei}from"./vendor-zod-Csf1sqWl.js";import{u as L1}from"./vendor-tanstack-react-virtual-C_IilPt1.js";import{d as $1,m as B1}from"./vendor-tanstack-virtual-core-DsQgKrou.js";const fd=t=>`${t}|chats`,z1=(t,e)=>{if(Jr(e))return fd(t);const n=Yt(e);return n?`${t}|${n}`:null},W1=(t,e,n)=>{const r=Yt(t);return!r||Jr(r)?[]:n.some(o=>Yt(o)===r)?[]:e.filter(o=>!o.parentID&&!o.time?.archived&&Yt(o.directory??null)===r).sort((o,i)=>ja(i)-ja(o)).map(o=>o.id)};function U1(t){const e=Be.c(37),{directory:n,className:r}=t,{currentTheme:o}=no(),i=Gt(q1),a=tt(H1),u=is(V1),c=ju(n);let d;e[0]!==n||e[1]!==u?(d=Vl(n,u),e[0]=n,e[1]=u,e[2]=d):d=e[2];const f=d;let p;e[3]!==n||e[4]!==f||e[5]!==i||e[6]!==c||e[7]!==a?(p=f||!n?null:hr(i,a,n,c),e[3]=n,e[4]=f,e[5]=i,e[6]=c,e[7]=a,e[8]=p):p=e[8];const m=p;if(f){let P;e[9]!==r?(P=$e("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=P):P=e[10];let k;return e[11]!==P?(k=s.jsx(se,{name:"chat-4",className:P}),e[11]=P,e[12]=k):k=e[12],k}if(!m)return null;const h=m.icon?Lp[m.icon]:null;let x;e[13]!==m.color?(x=$p(m.color)??void 0,e[13]=m.color,e[14]=x):x=e[14];const g=x;let b;e[15]!==r||e[16]!==g||e[17]!==h?(b=h?s.jsx(se,{name:h,className:$e("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):s.jsx(se,{name:"folder",className:$e("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),style:g?{color:g}:void 0}),e[15]=r,e[16]=g,e[17]=h,e[18]=b):b=e[18];const w=b;if(!m.iconImage)return w;let S;e[19]!==r?(S=$e("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=S):S=e[20];let y;e[21]!==m.iconBackground?(y=m.iconBackground?{backgroundColor:m.iconBackground}:void 0,e[21]=m.iconBackground,e[22]=y):y=e[22];let I;e[23]!==m.iconImage||e[24]!==m.id?(I={id:m.id,iconImage:m.iconImage},e[23]=m.iconImage,e[24]=m.id,e[25]=I):I=e[25];let j;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(j={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=j):j=e[28];let R;e[29]!==w||e[30]!==I||e[31]!==j?(R=s.jsx(Bp,{project:I,options:j,className:"h-full w-full object-contain",fallback:w}),e[29]=w,e[30]=I,e[31]=j,e[32]=R):R=e[32];let _;return e[33]!==S||e[34]!==y||e[35]!==R?(_=s.jsx("span",{className:S,style:y,children:R}),e[33]=S,e[34]=y,e[35]=R,e[36]=_):_=e[36],_}function V1(t){return t.homeDirectory}function H1(t){return t.availableWorktreesByProject}function q1(t){return t.projects}const Qn=24,G1=(t,e,n=Qn)=>{const r=e.right-(t.right-n);if(r>0)return r;const o=e.left-(t.left+n);return o<0?o:0},K1=({transform:t})=>({...t,y:0}),Z1=16,X1=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*Z1:t.deltaY;t.currentTarget.scrollLeft+=Qr(t.currentTarget)?-e:e},Y1={Item:({className:t,...e})=>s.jsx(T1,{className:$e(Hp,t),...e}),Separator:({className:t,...e})=>s.jsx(C1,{className:$e(Vp,t),...e})},J1=t=>{const e=Be.c(127),{tab:n,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:u,onPin:c,onClose:d,renderMenu:f,closeOtherTabs:p,onMenuOpenChangeComplete:m,children:h}=t,{t:x}=at(),g=X(ex);let b;e[0]!==g?(b=Ci("switch_session_tab",g),e[0]=g,e[1]=b):b=e[1];const w=b;let S;e[2]!==r||e[3]!==w?(S=w&&w!==wc&&r<=9?ws(`${w}+${r}`):void 0,e[2]=r,e[3]=w,e[4]=S):S=e[4];const y=S,[I,j]=l.useState(!1);let R;e[5]!==n.id?(R={id:n.id},e[5]=n.id,e[6]=R):R=e[6];const{attributes:_,listeners:P,setNodeRef:k,transform:N,transition:T,isDragging:A}=ld(R);let $;e[7]!==x||e[8]!==n.session.title?($=n.session.title?.trim()||x("sessions.sidebar.session.untitled"),e[7]=x,e[8]=n.session.title,e[9]=$):$=e[9];const K=$,q=n.id;let M;e[10]!==n.session?(M=gn(n.session),e[10]=n.session,e[11]=M):M=e[11];const z=rc(q,M),ne=yc(n.id),H=ne!==null,F=Wp(n.id)&&!o&&!H,C=H||F;let te;e[12]!==u||e[13]!==n?(te=()=>u(n),e[12]=u,e[13]=n,e[14]=te):te=e[14];let re;e[15]!==p||e[16]!==n.id?(re=()=>p(n.id),e[15]=p,e[16]=n.id,e[17]=re):re=e[17];let Q,ee,le,O,Y,Z,we,L,pe,je,Ee,Se,Le,Pe,Ve,Oe,be,ye,Ue,Te;if(e[18]!==_||e[19]!==h||e[20]!==I||e[21]!==o||e[22]!==z||e[23]!==A||e[24]!==i||e[25]!==P||e[26]!==d||e[27]!==m||e[28]!==c||e[29]!==u||e[30]!==f||e[31]!==k||e[32]!==g||e[33]!==C||e[34]!==a||e[35]!==x||e[36]!==te||e[37]!==re||e[38]!==n||e[39]!==y||e[40]!==K||e[41]!==N||e[42]!==T||e[43]!==ne){const G={session:n.session,open:I,isActive:o,select:te,closeOtherTabs:re,components:Y1};Le=k;let Ce;e[64]!==N?(Ce=dd.Translate.toString(N),e[64]=N,e[65]=Ce):Ce=e[65],e[66]!==Ce||e[67]!==T?(Pe={transform:Ce,transition:T},e[66]=Ce,e[67]=T,e[68]=Pe):Pe=e[68];const J=A&&"z-10 opacity-60";e[69]!==J?(Ve=$e("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",J),e[69]=J,e[70]=Ve):Ve=e[70],Oe=o?"true":"false",e[71]!==o?(be=o?{"data-active-session-tab":!0}:{},e[71]=o,e[72]=be):be=e[72],ye=_,Ue=P,O=gr,pe=I,je=j,e[73]!==m?(Ee=Ie=>m?.(Ie),e[73]=m,e[74]=Ee):Ee=e[74];let Ne;e[75]!==h||e[76]!==o||e[77]!==z||e[78]!==i||e[79]!==d||e[80]!==c||e[81]!==u||e[82]!==g||e[83]!==C||e[84]!==a||e[85]!==x||e[86]!==n||e[87]!==K||e[88]!==ne?(Ne=s.jsx(Ft,{asChild:!0,children:s.jsx(N1,{render:Ie=>s.jsx("div",{...Ie,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:o?void 0:()=>u(n),onDoubleClick:i?()=>c(n.id):void 0,onKeyDown:o?void 0:De=>{(De.key==="Enter"||De.key===" ")&&(De.preventDefault(),u(n))},onAuxClick:De=>{De.button===1&&(De.preventDefault(),d(n.id))},className:$e("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",o?"bg-interactive-selection text-interactive-selection-foreground":"cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx(U1,{directory:gn(n.session),className:$e(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":x("header.sessionTabs.closeTab"),onClick:De=>{De.stopPropagation(),d(n.id)},onPointerDown:tx,className:"absolute inset-0 flex items-center justify-center rounded text-muted-foreground opacity-0 hover:text-foreground focus-visible:opacity-100 group-hover/session-tab:opacity-100",children:s.jsx(se,{name:"close",className:"size-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:x("header.sessionTabs.closeTab"),shortcut:o?ws(Us()?"mod+w":Es("close_session_tab",g),""):void 0})})]})]}),s.jsx("div",{className:$e("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:K})})}),z?s.jsx(se,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":x("sessions.aiRename.generating")}):C?s.jsx(Sc,{state:ne??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[75]=h,e[76]=o,e[77]=z,e[78]=i,e[79]=d,e[80]=c,e[81]=u,e[82]=g,e[83]=C,e[84]=a,e[85]=x,e[86]=n,e[87]=K,e[88]=ne,e[89]=Ne):Ne=e[89];let Ae;e[90]!==y||e[91]!==K?(Ae=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:K,shortcut:y})}),e[90]=y,e[91]=K,e[92]=Ae):Ae=e[92],e[93]!==Ne||e[94]!==Ae?(Se=s.jsxs(Lt,{children:[Ne,Ae]}),e[93]=Ne,e[94]=Ae,e[95]=Se):Se=e[95],le=E1,ee=P1,L="app-region-no-drag z-50",Q=I1,Te="dropdown-menu-content",e[96]===Symbol.for("react.memo_cache_sentinel")?(Y={color:"var(--surface-elevated-foreground)"},Z=$e(Up,"min-w-[190px]"),e[96]=Y,e[97]=Z):(Y=e[96],Z=e[97]),we=f(G),e[18]=_,e[19]=h,e[20]=I,e[21]=o,e[22]=z,e[23]=A,e[24]=i,e[25]=P,e[26]=d,e[27]=m,e[28]=c,e[29]=u,e[30]=f,e[31]=k,e[32]=g,e[33]=C,e[34]=a,e[35]=x,e[36]=te,e[37]=re,e[38]=n,e[39]=y,e[40]=K,e[41]=N,e[42]=T,e[43]=ne,e[44]=Q,e[45]=ee,e[46]=le,e[47]=O,e[48]=Y,e[49]=Z,e[50]=we,e[51]=L,e[52]=pe,e[53]=je,e[54]=Ee,e[55]=Se,e[56]=Le,e[57]=Pe,e[58]=Ve,e[59]=Oe,e[60]=be,e[61]=ye,e[62]=Ue,e[63]=Te}else Q=e[44],ee=e[45],le=e[46],O=e[47],Y=e[48],Z=e[49],we=e[50],L=e[51],pe=e[52],je=e[53],Ee=e[54],Se=e[55],Le=e[56],Pe=e[57],Ve=e[58],Oe=e[59],be=e[60],ye=e[61],Ue=e[62],Te=e[63];let Me;e[98]!==Q||e[99]!==Y||e[100]!==Z||e[101]!==we||e[102]!==Te?(Me=s.jsx(Q,{"data-slot":Te,style:Y,className:Z,children:we}),e[98]=Q,e[99]=Y,e[100]=Z,e[101]=we,e[102]=Te,e[103]=Me):Me=e[103];let Re;e[104]!==ee||e[105]!==L||e[106]!==Me?(Re=s.jsx(ee,{className:L,children:Me}),e[104]=ee,e[105]=L,e[106]=Me,e[107]=Re):Re=e[107];let ze;e[108]!==le||e[109]!==Re?(ze=s.jsx(le,{children:Re}),e[108]=le,e[109]=Re,e[110]=ze):ze=e[110];let B;e[111]!==O||e[112]!==pe||e[113]!==je||e[114]!==Ee||e[115]!==Se||e[116]!==ze?(B=s.jsxs(O,{open:pe,onOpenChange:je,onOpenChangeComplete:Ee,children:[Se,ze]}),e[111]=O,e[112]=pe,e[113]=je,e[114]=Ee,e[115]=Se,e[116]=ze,e[117]=B):B=e[117];let ce;return e[118]!==Le||e[119]!==Pe||e[120]!==Ve||e[121]!==Oe||e[122]!==be||e[123]!==ye||e[124]!==Ue||e[125]!==B?(ce=s.jsx("div",{ref:Le,style:Pe,className:Ve,"data-active":Oe,...be,...ye,...Ue,children:B}),e[118]=Le,e[119]=Pe,e[120]=Ve,e[121]=Oe,e[122]=be,e[123]=ye,e[124]=Ue,e[125]=B,e[126]=ce):ce=e[126],ce},Q1=t=>{const e=Be.c(109),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:u,direction:c}=at(),d=c==="rtl",f=on(sx),p=on(nx),m=on(rx),h=on(ox),x=on(ix),g=on(ax),b=tt(lx),w=tt(cx),S=ts(dx),y=X(ux),I=on(fx),j=ts(px),R=tt(mx),_=tt(hx),P=tt(gx),k=tt(xx),N=tt(bx),T=tt(wx);let A;e[0]!==T?(A=W=>{const me=T??W.activeProjectId;return W.projects.find(he=>he.id===me)?.path??null},e[0]=T,e[1]=A):A=e[1];const $=Gt(A),K=yf(b);let q,M;e[2]!==K||e[3]!==R||e[4]!==b||e[5]!==N||e[6]!==k||e[7]!==_||e[8]!==$||e[9]!==m||e[10]!==I||e[11]!==y||e[12]!==j?(q=()=>{if(!y)I(qp,yx);else{if(!j)return;const W=as(),me=!b&&_&&k,he=b?R:_&&!k?N??$:null,Je=me?fd(W):z1(W,he);if(!Je)return;I(Je,()=>W1(he,ts.getState().activeSessions,Gt.getState().projects.map(vx)))}b&&m(b,K)},M=[K,R,b,N,k,_,$,m,I,y,j],e[2]=K,e[3]=R,e[4]=b,e[5]=N,e[6]=k,e[7]=_,e[8]=$,e[9]=m,e[10]=I,e[11]=y,e[12]=j,e[13]=q,e[14]=M):(q=e[13],M=e[14]),l.useEffect(q,M);let z;if(e[15]!==S){z=new Map;for(const W of S)z.set(W.id,W);e[15]=S,e[16]=z}else z=e[16];const ne=z;let H;if(e[17]!==ne||e[18]!==f){H=[];for(const W of f){const me=ne.get(W);me&&H.push({id:W,session:me})}e[17]=ne,e[18]=f,e[19]=H}else H=e[19];const V=H;let F;e[20]!==w?(F=W=>{w(W.id,gn(W.session))},e[20]=w,e[21]=F):F=e[21];const C=F,te=Sx,re=!b&&_;let Q;e[22]!==re||e[23]!==P?(Q=W=>!re||!P?"":(W.drafts.find(he=>he.id===P)?.text??"").split(/\r?\n/).find(kx)?.trim()??"",e[22]=re,e[23]=P,e[24]=Q):Q=e[24];const ee=zp(Q),le=X(jx),O=Cx;let Y;e[25]!==b||e[26]!==re||e[27]!==V?(Y=V.some(W=>W.id===b)||re&&V.length>0,e[25]=b,e[26]=re,e[27]=V,e[28]=Y):Y=e[28];const Z=Y;let we,L;e[29]!==Z?(we=()=>{if(Z)return oc(Tx,{current:document.body})},L=[Z],e[29]=Z,e[30]=we,e[31]=L):(we=e[30],L=e[31]),l.useEffect(we,L);let pe;e[32]!==x||e[33]!==b||e[34]!==C||e[35]!==V?(pe=W=>{if(x(W),b&&b!==W){const me=V.find(he=>he.id===W);me&&C(me)}},e[32]=x,e[33]=b,e[34]=C,e[35]=V,e[36]=pe):pe=e[36];const je=pe;let Ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(Ee={activationConstraint:{distance:8}},e[37]=Ee):Ee=e[37];let Se;e[38]===Symbol.for("react.memo_cache_sentinel")?(Se={activationConstraint:{delay:200,tolerance:6}},e[38]=Se):Se=e[38];const Le=rd(Vr(id,Ee),Vr(od,Se));let Pe;e[39]!==g?(Pe=W=>{const{active:me,over:he}=W;he&&me.id!==he.id&&g(String(me.id),String(he.id))},e[39]=g,e[40]=Pe):Pe=e[40];const Ve=Pe,Oe=l.useRef(null);let be;e[41]===Symbol.for("react.memo_cache_sentinel")?(be={left:!1,right:!1},e[41]=be):be=e[41];const[ye,Ue]=l.useState(be);let Te;e[42]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>{const W=Oe.current;if(!W)return;const me=W.scrollWidth-W.clientWidth,he=Qr(W)?me+W.scrollLeft:W.scrollLeft,Je=he>2,Fe=he<me-2;Ue(fe=>fe.left===Je&&fe.right===Fe?fe:{left:Je,right:Fe})},e[42]=Te):Te=e[42];const Me=Te;let Re;e[43]===Symbol.for("react.memo_cache_sentinel")?(Re=()=>{Me();const W=Oe.current;if(!W||!globalThis.ResizeObserver)return;const me=new ResizeObserver(Me);return me.observe(W),()=>me.disconnect()},e[43]=Re):Re=e[43];let ze;e[44]!==V.length?(ze=[Me,V.length],e[44]=V.length,e[45]=ze):ze=e[45],l.useEffect(Re,ze);let B;e[46]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{const W=Oe.current,me=W?.querySelector("[data-active-session-tab]");if(!W||!me)return;const he=G1(W.getBoundingClientRect(),me.getBoundingClientRect());he!==0&&(W.scrollLeft=W.scrollLeft+he,Me())},e[46]=B):B=e[46];let ce;e[47]!==b?(ce=[b,Me],e[47]=b,e[48]=ce):ce=e[48],l.useEffect(B,ce);const G=ye.left&&ye.right?`linear-gradient(to right, transparent, black ${Qn}px, black calc(100% - ${Qn}px), transparent)`:ye.left?`linear-gradient(to right, transparent, black ${Qn}px)`:ye.right?`linear-gradient(to right, black calc(100% - ${Qn}px), transparent)`:void 0;let Ce;e[49]!==V?(Ce=V.map(Nx),e[49]=V,e[50]=Ce):Ce=e[50];const J=Ce;let Ne;e[51]!==b||e[52]!==V?(Ne=!!b&&!V.some(W=>W.id===b),e[51]=b,e[52]=V,e[53]=Ne):Ne=e[53];const Ae=Ne;let Ie;e[54]!==u?(Ie=u("header.sessionTabs.stripAria"),e[54]=u,e[55]=Ie):Ie=e[55];let De;e[56]!==G?(De=G?{maskImage:G,WebkitMaskImage:G}:void 0,e[56]=G,e[57]=De):De=e[57];let We;e[58]===Symbol.for("react.memo_cache_sentinel")?(We=[K1],e[58]=We):We=e[58];const Ke=d?v1:S1;let Ze;e[59]!==i||e[60]!==b||e[61]!==je||e[62]!==C||e[63]!==r||e[64]!==h||e[65]!==p||e[66]!==n||e[67]!==a||e[68]!==V?(Ze=V.map((W,me)=>s.jsx(J1,{tabNumber:me+1,tab:W,isActive:W.id===b,isPreview:W.id===p,suppressControls:W.id===b&&a,onSelect:C,onPin:h,onClose:te,renderMenu:n,closeOtherTabs:je,onMenuOpenChangeComplete:r,children:W.id===b?i:null},W.id)),e[59]=i,e[60]=b,e[61]=je,e[62]=C,e[63]=r,e[64]=h,e[65]=p,e[66]=n,e[67]=a,e[68]=V,e[69]=Ze):Ze=e[69];let Qe;e[70]!==Ke||e[71]!==Ze||e[72]!==J?(Qe=s.jsx(cd,{items:J,strategy:Ke,children:Ze}),e[70]=Ke,e[71]=Ze,e[72]=J,e[73]=Qe):Qe=e[73];let qe;e[74]!==Ve||e[75]!==Le||e[76]!==Qe?(qe=s.jsx(ad,{sensors:Le,collisionDetection:Jo,modifiers:We,onDragEnd:Ve,children:Qe}),e[74]=Ve,e[75]=Le,e[76]=Qe,e[77]=qe):qe=e[77];let et;e[78]!==ee||e[79]!==re||e[80]!==u?(et=re?s.jsxs("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2 text-interactive-selection-foreground","data-active":"true","data-active-session-tab":!0,children:[s.jsx(se,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),s.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:ee||u("sessions.switcher.draftTitle")})})]}):null,e[78]=ee,e[79]=re,e[80]=u,e[81]=et):et=e[81];let He;e[82]!==i||e[83]!==Ae?(He=Ae?s.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag 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:i})}):null,e[82]=i,e[83]=Ae,e[84]=He):He=e[84];let Ye;e[85]!==De||e[86]!==qe||e[87]!==et||e[88]!==He?(Ye=s.jsxs("div",{ref:Oe,onScroll:Me,onWheel:X1,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:De,children:[qe,et,He]}),e[85]=De,e[86]=qe,e[87]=et,e[88]=He,e[89]=Ye):Ye=e[89];let dt;e[90]!==u?(dt=u("sessions.sidebar.header.actions.newSession"),e[90]=u,e[91]=dt):dt=e[91];let nt;e[92]===Symbol.for("react.memo_cache_sentinel")?(nt=s.jsx(se,{name:"add",className:"size-4"}),e[92]=nt):nt=e[92];let ut;e[93]!==dt?(ut=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:O,"aria-label":dt,className:"app-region-no-drag ms-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:nt})}),e[93]=dt,e[94]=ut):ut=e[94];let oe;e[95]!==u?(oe=u("sessions.sidebar.header.actions.newSession"),e[95]=u,e[96]=oe):oe=e[96];let de;e[97]!==le?(de=ws(Es("new_chat",le),""),e[97]=le,e[98]=de):de=e[98];let ve;e[99]!==oe||e[100]!==de?(ve=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:oe,shortcut:de})}),e[99]=oe,e[100]=de,e[101]=ve):ve=e[101];let v;e[102]!==ut||e[103]!==ve?(v=s.jsxs(Lt,{children:[ut,ve]}),e[102]=ut,e[103]=ve,e[104]=v):v=e[104];let ae;return e[105]!==Ie||e[106]!==Ye||e[107]!==v?(ae=s.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ie,children:[Ye,v]}),e[105]=Ie,e[106]=Ye,e[107]=v,e[108]=ae):ae=e[108],ae};function ex(t){return t.shortcutOverrides}function tx(t){return t.stopPropagation()}function sx(t){return t.tabIds}function nx(t){return t.previewTabId}function rx(t){return t.ensureTab}function ox(t){return t.pinTab}function ix(t){return t.closeOtherTabs}function ax(t){return t.reorderTabs}function lx(t){return t.currentSessionId}function cx(t){return t.setCurrentSession}function dx(t){return t.activeSessions}function ux(t){return t.sessionTabsPerWorkspace}function fx(t){return t.enterScope}function px(t){return t.hasLoaded}function mx(t){return t.currentSessionDirectory}function hx(t){return t.newSessionDraft.open}function gx(t){return t.newSessionDraft.workDraftId??null}function xx(t){return t.newSessionDraft.target==="chat"}function bx(t){return t.newSessionDraft.directoryOverride}function wx(t){return t.newSessionDraft.selectedProjectId??null}function yx(){return[]}function vx(t){return t.path}function Sx(t){vc(t)}function kx(t){return t.trim()}function jx(t){return t.shortcutOverrides}function Cx(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:n}=tt.getState(),r=t?is.getState().currentDirectory:e.directoryOverride;n(r?{directoryOverride:r}:void 0)}function Tx(){const t=tt.getState().currentSessionId;t?vc(t):Gp(-1)}function Nx(t){return t.id}const Ex=t=>{const e=Be.c(29),{open:n,onOpenChange:r,onPick:o}=t,{t:i}=at(),a=Kp(Gt(Px),n),u=is(Ix);let c;e[0]!==i?(c=i("sessions.moveChatToProject.title"),e[0]=i,e[1]=c):c=e[1];let d;e[2]!==c?(d=s.jsx(Fn,{children:c}),e[2]=c,e[3]=d):d=e[3];let f;e[4]!==i?(f=i("sessions.moveChatToProject.description"),e[4]=i,e[5]=f):f=e[5];let p;e[6]!==f?(p=s.jsx(Ln,{children:f}),e[6]=f,e[7]=p):p=e[7];let m;e[8]!==d||e[9]!==p?(m=s.jsxs($n,{children:[d,p]}),e[8]=d,e[9]=p,e[10]=m):m=e[10];let h;if(e[11]!==u||e[12]!==r||e[13]!==o||e[14]!==a){let w;e[16]!==u||e[17]!==r||e[18]!==o?(w=S=>s.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] focus-visible:outline-none",onClick:()=>{r(!1),o(S.path)},children:[s.jsx(se,{name:"folder",className:"size-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:S.label?.trim()||Zp(S.path)}),s.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:kc(S.path,u)})]},S.id),e[16]=u,e[17]=r,e[18]=o,e[19]=w):w=e[19],h=a.map(w),e[11]=u,e[12]=r,e[13]=o,e[14]=a,e[15]=h}else h=e[15];let x;e[20]!==h?(x=s.jsx(fs,{outerClassName:"max-h-[50vh]",className:"flex flex-col gap-0.5",disableHorizontal:!0,children:h}),e[20]=h,e[21]=x):x=e[21];let g;e[22]!==m||e[23]!==x?(g=s.jsxs(Bn,{className:"max-w-md",children:[m,x]}),e[22]=m,e[23]=x,e[24]=g):g=e[24];let b;return e[25]!==r||e[26]!==n||e[27]!==g?(b=s.jsx(zn,{open:n,onOpenChange:r,children:g}),e[25]=r,e[26]=n,e[27]=g,e[28]=b):b=e[28],b};function Px(t){return t.projects}function Ix(t){return t.homeDirectory}function Wa(t){const e=Be.c(37),{sessionId:n,onArchive:r,Item:o}=t,{t:i}=at(),a=X(Dx);let u;e[0]!==n?(u=A=>A.currentSessionId===n,e[0]=n,e[1]=u):u=e[1];const c=tt(u);let d;e[2]!==a?(d=ws(Es("archive_current_session",a),""),e[2]=a,e[3]=d):d=e[3];const f=d;let p;e[4]!==n?(p=A=>!!A.entityById.get(n)?.time.archived,e[4]=n,e[5]=p):p=e[5];const m=ts(p);let h;e[6]!==n?(h=A=>{const $=A.entityById.get(n);return!$||Xp($,A.entityById)},e[6]=n,e[7]=h):h=e[7];const x=ts(h),g=tt(Rx);let b;e[8]!==n||e[9]!==i||e[10]!==g?(b=async()=>{await g(n)?_e.success(i("sessions.sidebar.session.restore.success")):_e.error(i("sessions.sidebar.session.restore.error"))},e[8]=n,e[9]=i,e[10]=g,e[11]=b):b=e[11];const w=b;if(m&&!x)return null;const S=m?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let y;e[12]!==i||e[13]!==S?(y=i(S),e[12]=i,e[13]=S,e[14]=y):y=e[14];let I;e[15]!==m||e[16]!==r||e[17]!==w?(I=m?()=>{w()}:r,e[15]=m,e[16]=r,e[17]=w,e[18]=I):I=e[18];const j=m?"inbox-unarchive":"inbox-archive";let R;e[19]!==j?(R=s.jsx(se,{name:j,className:"me-1 size-4"}),e[19]=j,e[20]=R):R=e[20];const _=m?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let P;e[21]!==i||e[22]!==_?(P=i(_),e[21]=i,e[22]=_,e[23]=P):P=e[23];let k;e[24]!==f||e[25]!==m||e[26]!==c?(k=!m&&c&&f?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:f}):null,e[24]=f,e[25]=m,e[26]=c,e[27]=k):k=e[27];let N;e[28]!==o||e[29]!==R||e[30]!==P||e[31]!==k||e[32]!==I?(N=s.jsxs(o,{onClick:I,children:[R,P,k]}),e[28]=o,e[29]=R,e[30]=P,e[31]=k,e[32]=I,e[33]=N):N=e[33];let T;return e[34]!==N||e[35]!==y?(T=s.jsx(ds,{hint:y,children:N}),e[34]=N,e[35]=y,e[36]=T):T=e[36],T}function Rx(t){return t.unarchiveSession}function Dx(t){return t.shortcutOverrides}function _x(t){const e=Be.c(17),{session:n,Item:r}=t,{t:o}=at();if(!X(Ax)||n.parentID||!jc(n))return null;let a;e[0]!==n||e[1]!==o?(a=async()=>{try{await Yp(n.id,gn(n),"done"),Cc([n.id])}catch{_e.error(o("sessions.sidebar.session.work.updateFailed"))}},e[0]=n,e[1]=o,e[2]=a):a=e[2];const u=a;let c;e[3]!==o?(c=o("sessions.sidebar.session.menuHint.markDone"),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==u?(d=()=>{u()},e[5]=u,e[6]=d):d=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(se,{name:"check",className:"me-1 size-4"}),e[7]=f):f=e[7];let p;e[8]!==o?(p=o("sessions.sidebar.session.work.markDone"),e[8]=o,e[9]=p):p=e[9];let m;e[10]!==r||e[11]!==d||e[12]!==p?(m=s.jsxs(r,{onClick:d,children:[f,p]}),e[10]=r,e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;return e[14]!==c||e[15]!==m?(h=s.jsx(ds,{hint:c,children:m}),e[14]=c,e[15]=m,e[16]=h):h=e[16],h}function Ax(t){return t.sessionWorkEnabled}const Ox=t=>{const e=Tc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},Mx=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,pd=()=>{const t=Be.c(4),e=tt(Fx),n=tt(Lx)??void 0,r=Jp(e??"",n,Ox,Mx),{context:o}=Qp(e,n),i=o>0?o:em;let a;return t[0]!==r||t[1]!==i||t[2]!==e?(a={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=a):a=t[3],a};function Fx(t){return t.currentSessionId}function Lx(t){return t.currentSessionDirectory}const Ua=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Ls=18,ti=2,si=(Ls-ti)/2,Va=2*Math.PI*si,$x=t=>{const e=Be.c(9),{percent:n,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,n));let u;e[0]!==o?(u=$e("shrink-0",o),e[0]=o,e[1]=u):u=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx("circle",{cx:Ls/2,cy:Ls/2,r:si,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ti}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==a?(d=a>0?s.jsx("circle",{cx:Ls/2,cy:Ls/2,r:si,fill:"none",stroke:i,strokeWidth:ti,strokeLinecap:"round",strokeDasharray:Va,strokeDashoffset:Va*(1-a/100),transform:`rotate(-90 ${Ls/2} ${Ls/2})`}):null,e[3]=i,e[4]=a,e[5]=d):d=e[5];let f;return e[6]!==u||e[7]!==d?(f=s.jsxs("svg",{viewBox:`0 0 ${Ls} ${Ls}`,className:u,"aria-hidden":"true",children:[c,d]}),e[6]=u,e[7]=d,e[8]=f):f=e[8],f},md=()=>{const t=Be.c(16),{t:e}=at(),{sessionId:n,fill:r,limit:o}=pd(),{totalCost:i}=tm(n);if(!n||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Ua(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let u;t[4]!==o||t[5]!==e?(u=e("contextUsage.tooltip.contextLimit",{tokens:Ua(o)}),t[4]=o,t[5]=e,t[6]=u):u=t[6];let c;t[7]!==e||t[8]!==i?(c=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:td(i)})]:[],t[7]=e,t[8]=i,t[9]=c):c=t[9];let d;t[10]!==a||t[11]!==u||t[12]!==c?(d=[a,u,...c],t[10]=a,t[11]=u,t[12]=c,t[13]=d):d=t[13];const f=d;let p;return t[14]!==f?(p=s.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(Bx)}),t[14]=f,t[15]=p):p=t[15],p};function Bx(t){return s.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const zx="—",Wx={safe:"var(--status-success)",warn:"var(--status-warning)",critical:"var(--status-error)"},Ux=t=>{const e=Be.c(35),{buttonClassName:n}=t,{t:r}=at(),{sessionId:o,fill:i,limit:a}=pd(),u=Gs();let c;e[0]!==u?(c=u?us(u):"",e[0]=u,e[1]=c):c=e[1];const d=c,f=X(Hx);let p;e[2]!==d?(p=A=>d!==""&&bi(A.contextPanelByDirectory[d],A.contextSurfaceZones).has("context"),e[2]=d,e[3]=p):p=e[3];const m=X(p);if(!o||!i)return null;const h=i.state==="measured"?i.totalTokens/a*100:null,x=h===null?void 0:Wx[sm(Math.round(h))];let g;e[4]!==d||e[5]!==f?(g=d?()=>f(d,"context"):void 0,e[4]=d,e[5]=f,e[6]=g):g=e[6];let b;e[7]!==r?(b=r("contextUsage.aria.label"),e[7]=r,e[8]=b):b=e[8];const w=m&&"text-foreground";let S;e[9]!==n||e[10]!==w?(S=$e(n,"w-auto gap-1.5 px-1 tabular-nums",w),e[9]=n,e[10]=w,e[11]=S):S=e[11];const y=h??0;let I;e[12]!==x||e[13]!==y?(I=s.jsx($x,{percent:y,arcColor:x,className:"size-4"}),e[12]=x,e[13]=y,e[14]=I):I=e[14];let j;e[15]!==h?(j=h===null?zx:`${Math.min(h,999).toFixed(1)}%`,e[15]=h,e[16]=j):j=e[16];let R;e[17]!==j?(R=s.jsx("span",{dir:"ltr",className:"typography-meta",children:j}),e[17]=j,e[18]=R):R=e[18];let _;e[19]!==m||e[20]!==R||e[21]!==g||e[22]!==b||e[23]!==S||e[24]!==I?(_=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:g,"aria-label":b,"aria-pressed":m,className:S,children:[I,R]})}),e[19]=m,e[20]=R,e[21]=g,e[22]=b,e[23]=S,e[24]=I,e[25]=_):_=e[25];let P;e[26]!==m||e[27]!==r?(P=m?null:s.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=m,e[27]=r,e[28]=P):P=e[28];let k;e[29]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(md,{}),e[29]=k):k=e[29];let N;e[30]!==P?(N=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[P,k]})}),e[30]=P,e[31]=N):N=e[31];let T;return e[32]!==_||e[33]!==N?(T=s.jsxs(Lt,{children:[_,N]}),e[32]=_,e[33]=N,e[34]=T):T=e[34],T},Vx=l.memo(Ux);function Hx(t){return t.openContextSurface}const hd=l.createContext(null),gd=()=>l.useContext(hd),qx=t=>{const e=Be.c(4),n=gd()?.observe;let r,o;e[0]!==t||e[1]!==n?(r=()=>t&&n?n():void 0,o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),l.useEffect(r,o)},Ha=t=>{const e=Be.c(12),{run:n,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,u=o===void 0?!1:o;if(n?.status==="stopping"||n?.status==="waiting-for-preview"){let d;e[0]!==i?(d=$e("size-4 shrink-0 animate-spin text-[var(--status-warning)]",i),e[0]=i,e[1]=d):d=e[1];let f;return e[2]!==d?(f=s.jsx(se,{name:"loader-4",className:d}),e[2]=d,e[3]=f):f=e[3],f}if(n){const d=u?"stop-large":"stop";let f;e[4]!==i?(f=$e("size-4 shrink-0 text-[var(--status-warning)]",i),e[4]=i,e[5]=f):f=e[5];let p;return e[6]!==d||e[7]!==f?(p=s.jsx(se,{name:d,className:f}),e[6]=d,e[7]=f,e[8]=p):p=e[8],p}let c;return e[9]!==i||e[10]!==a?(c=a?s.jsx(se,{name:"play",className:$e("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=c):c=e[11],c},Gx=t=>{const e=Be.c(68),{directory:n,buttonClassName:r}=t,{t:o}=at(),i=an(Zx),a=an(Xx),u=an(Yx),c=an(Jx),d=nm(c),f=an(Qx),p=an(eb),m=an(tb);let h,x;e[0]!==f?(h=()=>{f()},x=[f],e[0]=f,e[1]=h,e[2]=x):(h=e[1],x=e[2]),l.useEffect(h,x);const g=Us()&&eo();let b;e[3]!==a||e[4]!==i?(b=a.find(le=>le.id===i)??a.find(sb)??a[0]??R1[0],e[3]=a,e[4]=i,e[5]=b):b=e[5];const w=b;if(!g||!n||a.length===0)return null;let S;e[6]!==n?(S=async le=>{await Cu(n,le.id,le.appName)||await Hl(n,le.appName)},e[6]=n,e[7]=S):S=e[7];const y=S;let I;e[8]!==y||e[9]!==m?(I=async le=>{await m(le.id),await y(le)},e[8]=y,e[9]=m,e[10]=I):I=e[10];const j=I;let R;e[11]!==n||e[12]!==o?(R=async()=>{(await ro(n)).ok&&_e.success(o("openInApp.toast.pathCopied"))},e[11]=n,e[12]=o,e[13]=R):R=e[13];const _=R;let P;e[14]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx("div",{className:"inline-flex"}),e[14]=P):P=e[14];let k;e[15]!==y||e[16]!==w?(k=()=>{y(w)},e[15]=y,e[16]=w,e[17]=k):k=e[17];let N;e[18]!==d||e[19]!==r?(N=$e(r,d),e[18]=d,e[19]=r,e[20]=N):N=e[20];let T;e[21]!==w.label||e[22]!==o?(T=o("openInApp.actions.openInAria",{app:w.label}),e[21]=w.label,e[22]=o,e[23]=T):T=e[23];let A;e[24]!==w.icon?(A=s.jsx(se,{name:w.icon,className:"size-4"}),e[24]=w.icon,e[25]=A):A=e[25];let $;e[26]!==T||e[27]!==A||e[28]!==k||e[29]!==N?($=s.jsx(oo,{render:P,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:N,"aria-label":T,children:A})})}),e[26]=T,e[27]=A,e[28]=k,e[29]=N,e[30]=$):$=e[30];let K;e[31]!==w.label||e[32]!==o?(K=o("openInApp.actions.openInAria",{app:w.label}),e[31]=w.label,e[32]=o,e[33]=K):K=e[33];let q;e[34]!==K?(q=s.jsx($t,{side:"bottom",children:K}),e[34]=K,e[35]=q):q=e[35];let M;e[36]!==$||e[37]!==q?(M=s.jsxs(Lt,{children:[$,q]}),e[36]=$,e[37]=q,e[38]=M):M=e[38];let z;e[39]!==_?(z=()=>{_()},e[39]=_,e[40]=z):z=e[40];let ne;e[41]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(se,{name:"file-copy",className:"h-4 w-4"}),e[41]=ne):ne=e[41];let H;e[42]!==o?(H=o("openInApp.actions.copyPath"),e[42]=o,e[43]=H):H=e[43];let V;e[44]!==H?(V=s.jsx("span",{className:"typography-ui-label text-foreground",children:H}),e[44]=H,e[45]=V):V=e[45];let F;e[46]!==z||e[47]!==V?(F=s.jsxs(Ns,{className:"flex items-center gap-2",onClick:z,children:[ne,V]}),e[46]=z,e[47]=V,e[48]=F):F=e[48];let C;e[49]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(Dn,{}),e[49]=C):C=e[49];let te;if(e[50]!==a||e[51]!==j||e[52]!==w.id){let le;e[54]!==j||e[55]!==w.id?(le=O=>s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{j(O)},children:[s.jsx(se,{name:O.icon,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:O.label}),w.id===O.id?s.jsx(se,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},O.id),e[54]=j,e[55]=w.id,e[56]=le):le=e[56],te=a.map(le),e[50]=a,e[51]=j,e[52]=w.id,e[53]=te}else te=e[53];let re;e[57]!==u||e[58]!==p||e[59]!==o?(re=u?s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{p(!0)},children:[s.jsx(se,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=u,e[58]=p,e[59]=o,e[60]=re):re=e[60];let Q;e[61]!==F||e[62]!==te||e[63]!==re?(Q=s.jsxs(io,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[F,C,te,re]}),e[61]=F,e[62]=te,e[63]=re,e[64]=Q):Q=e[64];let ee;return e[65]!==M||e[66]!==Q?(ee=s.jsxs(gr,{children:[M,Q]}),e[65]=M,e[66]=Q,e[67]=ee):ee=e[67],ee},Kx=l.memo(Gx);function Zx(t){return t.selectedAppId}function Xx(t){return t.availableApps}function Yx(t){return t.isCacheStale}function Jx(t){return t.isScanning}function Qx(t){return t.initialize}function eb(t){return t.loadInstalledApps}function tb(t){return t.selectApp}function sb(t){return t.id===D1}const er=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},nb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const o=er(n??"");if(o){const i=hr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function xd(){const t=Gt(b=>b.projects),e=Gt(b=>b.activeProjectId),n=tt(b=>b.availableWorktreesByProject),r=tt(b=>b.currentSessionId),o=rm(r??null),i=tt(b=>r?b.worktreeMetadata.get(r)?.path??"":""),a=tt(b=>b.newSessionDraft?.open?er(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),u=tt(b=>b.newSessionDraft?.open?b.newSessionDraft.target==="chat":null),c=l.useMemo(()=>er(i||""),[i]),d=l.useMemo(()=>er(o||""),[o]),f=c||d||a,p=l.useMemo(()=>nb({projects:t,worktreesByProject:n,directory:f,activeProjectId:e}),[e,f,t,n]),m=l.useMemo(()=>er(f||p?.path||""),[f,p?.path]),h=l.useMemo(()=>p?{id:p.id,path:p.path}:null,[p]),x=u??Jr(d),g=l.useRef(null);return l.useEffect(()=>{h&&m&&!x&&(g.current={projectRef:h,directory:m})},[m,h,x]),l.useMemo(()=>x?null:h&&m?{projectRef:h,directory:m}:g.current,[h,m,x])}const rb=t=>{const e=Be.c(67),{buttonClassName:n}=t,{t:r}=at(),o=gd(),i=X(lb),[a,u]=l.useState(!1),c=X(cb);let d;e[0]!==c?(d=ws(Es("open_project_actions",c),""),e[0]=c,e[1]=d):d=e[1];const f=d,p=o?.available?o.shown:null;let m;e[2]!==o||e[3]!==p?(m=p&&o?o.runOf(p):null,e[2]=o,e[3]=p,e[4]=m):m=e[4];const h=m;qx(!0);let x;e[5]!==h?(x=Q=>h?Q.getDirectoryState(h.directory)?.tabs.find(ee=>ee.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=x):x=e[6];const g=wt(x);if(!o||!p)return null;let b;e[7]!==p.name||e[8]!==h||e[9]!==r?(b=h?r("projectActions.actions.stopNamedAria",{name:p.name}):r("projectActions.actions.runNamedAria",{name:p.name}),e[7]=p.name,e[8]=h,e[9]=r,e[10]=b):b=e[10];const w=b;let S;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(S=h&&g?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:n,"aria-label":r("projectActions.actions.openPreview"),children:s.jsx(se,{name:"global",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=n,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=S):S=e[16];let y;e[17]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("div",{className:"inline-flex"}),e[17]=y):y=e[17];let I;e[18]!==o||e[19]!==p?(I=()=>o.toggle(p),e[18]=o,e[19]=p,e[20]=I):I=e[20];const j=o.isLoading||h?.status==="stopping",R=a&&"text-foreground";let _;e[21]!==n||e[22]!==R?(_=$e(n,R),e[21]=n,e[22]=R,e[23]=_):_=e[23];let P;e[24]!==p||e[25]!==h?(P=h?s.jsx(Ha,{run:h,large:!0}):s.jsx(se,{name:fa(p),className:"size-4"}),e[24]=p,e[25]=h,e[26]=P):P=e[26];let k;e[27]!==w||e[28]!==_||e[29]!==P||e[30]!==I||e[31]!==j?(k=s.jsx(oo,{render:y,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:I,disabled:j,className:_,"aria-label":w,children:P})})}),e[27]=w,e[28]=_,e[29]=P,e[30]=I,e[31]=j,e[32]=k):k=e[32];let N;e[33]!==w?(N=s.jsx("span",{children:w}),e[33]=w,e[34]=N):N=e[34];let T;e[35]!==r?(T=r("projectActions.header.allActions"),e[35]=r,e[36]=T):T=e[36];let A;e[37]!==f||e[38]!==T?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:s.jsx(Hs,{label:T,shortcut:f})}),e[37]=f,e[38]=T,e[39]=A):A=e[39];let $;e[40]!==N||e[41]!==A?($=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[N,A]})}),e[40]=N,e[41]=A,e[42]=$):$=e[42];let K;e[43]!==k||e[44]!==$?(K=s.jsxs(Lt,{children:[k,$]}),e[43]=k,e[44]=$,e[45]=K):K=e[45];const q=o.openSettings;let M;e[46]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(se,{name:"add",className:"h-4 w-4"}),e[46]=M):M=e[46];let z;e[47]!==r?(z=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=z):z=e[48];let ne;e[49]!==z?(ne=s.jsx("span",{className:"typography-ui-label text-foreground",children:z}),e[49]=z,e[50]=ne):ne=e[50];let H;e[51]!==o.openSettings||e[52]!==ne?(H=s.jsxs(Ns,{className:"flex items-center gap-2",onClick:q,children:[M,ne]}),e[51]=o.openSettings,e[52]=ne,e[53]=H):H=e[53];let V;e[54]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Dn,{}),e[54]=V):V=e[54];let F;e[55]!==o||e[56]!==r?(F=o.actions.map(Q=>s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{o.select(Q),o.toggle(Q)},children:[s.jsx(se,{name:fa(Q),className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q.name}),Q.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:r("projectActions.menu.sharedBadge")}):null,s.jsx(Ha,{run:o.runOf(Q),className:"ms-auto"})]},Q.id)),e[55]=o,e[56]=r,e[57]=F):F=e[57];let C;e[58]!==H||e[59]!==F?(C=s.jsxs(io,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[H,V,F]}),e[58]=H,e[59]=F,e[60]=C):C=e[60];let te;e[61]!==K||e[62]!==C?(te=s.jsxs(gr,{onOpenChange:u,children:[K,C]}),e[61]=K,e[62]=C,e[63]=te):te=e[63];let re;return e[64]!==te||e[65]!==S?(re=s.jsxs(s.Fragment,{children:[S,te]}),e[64]=te,e[65]=S,e[66]=re):re=e[66],re},ob=l.memo(rb),ib=t=>{const e=Be.c(8),{buttonClassName:n}=t,r=xd();if(!r)return null;let o;e[0]!==n||e[1]!==r.directory?(o=s.jsx(Kx,{directory:r.directory,buttonClassName:n}),e[0]=n,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==n?(i=s.jsx(ob,{buttonClassName:n}),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=s.jsxs(s.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},ab=l.memo(ib);function lb(t){return t.openContextPreview}function cb(t){return t.shortcutOverrides}const Ro="--oc-titlebar-controls-width",ni=new Set;let sr=null;const bd=t=>{sr===null?t.style.removeProperty(Ro):t.style.getPropertyValue(Ro)!==sr&&t.style.setProperty(Ro,sr)},db=t=>{const e=`${Math.round(t)}px`;e!==sr&&(sr=e,ni.forEach(bd))},wd=t=>{if(t)return ni.add(t),bd(t),()=>{ni.delete(t)}},Zn="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",Tn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ub=()=>{Tu("ui.header.render");const{t,direction:e}=at(),n=X(U=>U.isSidebarOpen),r=ao(),o=X(U=>U.sessionTabsEnabled),i=tt(U=>!!U.newSessionDraft?.open),a=tt(U=>U.currentSessionId),u=om(a??""),c=vf(a??""),d=ts(Qo(l.useCallback(U=>{if(!a)return null;const Xe=[...U.activeSessions,...U.archivedSessions].find(Tt=>Tt.id===a);if(!Xe)return null;const ot=Xe;return{title:Xe.title??null,directory:ot.directory??null,created:Xe.time?.created??null,slug:ot.slug??null,parentId:Xe.parentID??null}},[a]))),f=Gt(Qo(U=>{if(!U.activeProjectId)return null;const Xe=U.projects.find(ot=>ot.id===U.activeProjectId);return Xe?{id:Xe.id,path:Xe.path,label:Xe.label}:null})),p=l.useMemo(()=>{if(!f)return null;const U=f.label?.trim();if(U)return U;const Xe=f.path.split(/[\\/]/).filter(Boolean);return Xe[Xe.length-1]??null},[f]),m=Pn(U=>U.loadSettings),{isMobile:h}=yn(),x=l.useRef(null),[g,b]=l.useState(()=>typeof window>"u"?!1:Us()),w=l.useMemo(()=>Vo(),[]),S=im(),[y,I]=l.useState(!1),j=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:_}=sd(),P=l.useMemo(()=>{if(typeof window>"u")return null;const U=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof U=="number"&&Number.isFinite(U)&&U>0)return U;if(typeof navigator>"u")return null;const Xe=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Xe)return null;const ot=Number.parseInt(Xe[1],10),Tt=Number.parseInt(Xe[2],10);return Number.isNaN(ot)?null:ot===10?Tt:ot},[]);Wt.useEffect(()=>{typeof window>"u"||b(Us())},[]);const k=l.useMemo(()=>wi(),[]),N=X(U=>U.shortcutOverrides),T=ws(Es("rename_current_session",N),""),A=X(U=>U.workStatusPanelVisible),$=X(U=>U.workStatusPanelEnabled),K=X(U=>U.setWorkStatusPanelEnabled),q=X(U=>U.workStatusPanelFits),M=X(U=>U.workStatusOverlayOpen),z=X(U=>U.setWorkStatusOverlayOpen),H=$&&q||M,V=l.useCallback(()=>{if($&&!q){z(!M);return}K(!$)},[z,K,M,$,q]);am(),l.useEffect(()=>{m()},[m]);const F=a?d??null:null,C=l.useRef(null),[te,re]=l.useState(0);l.useEffect(()=>{if(!a){C.current&&(C.current=null,re(Tt=>Tt+1));return}if(F){C.current={sessionId:a,session:F,expiresAt:Date.now()+2e3};return}const U=C.current;if(!U||U.sessionId!==a)return;const Xe=U.expiresAt-Date.now();if(Xe<=0){C.current=null,re(Tt=>Tt+1);return}const ot=window.setTimeout(()=>{C.current?.sessionId===a&&(C.current=null),re(Tt=>Tt+1)},Xe);return()=>{window.clearTimeout(ot)}},[a,F]);const Q=(()=>{if(F)return F;if(!a)return null;const U=C.current;return U&&U.sessionId===a&&U.expiresAt>Date.now()?U.session:null})(),ee=tt(U=>a?U.worktreeMetadata.get(a)?.path??"":""),le=tt(U=>a?U.worktreeMetadata.get(a)?.branch?.trim()??null:null),O=Nc(U=>a?U.getAttachment(a):void 0),Y=l.useMemo(()=>O?lm(O,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,O]),Z=l.useMemo(()=>O?O.legacy?"legacy":O.degraded?"degraded":O.worktreeStatus==="pending"?"pending":O.worktreeStatus==="missing"?"missing":O.worktreeStatus==="invalid"?"invalid":O.attentionReason?"attention":null:null,[O]),we=l.useMemo(()=>Tn(ee||""),[ee]),L=l.useMemo(()=>{const U=typeof Q?.directory=="string"?Q.directory:"";return Tn(U||"")},[Q?.directory]),pe=rc(a??"",L),je=tt(U=>U.newSessionDraft?.open?Tn(U.newSessionDraft.bootstrapPendingDirectory??U.newSessionDraft.directoryOverride??""):""),Ee=tt(U=>U.newSessionDraft.target),Se=tt(U=>U.newSessionDraft.selectedProjectId),Le=tt(U=>U.currentSessionDirectory),Pe=is(U=>U.homeDirectory),Ve=xr(),Oe=l.useMemo(()=>we||L||(lo(Ve,je)??""),[je,Ve,L,we]),be=tt(U=>{const Xe=Tn(we||L||"");if(!Xe)return null;for(const ot of U.availableWorktreesByProject.values()){const Zt=$r(ot,Xe)?.branch?.trim();if(Zt)return Zt}return null}),Ue=cm(Oe||null)||le||be,Te=i?Ee==="chat":Vl(L||Le,Pe),Me=!Te&&!A&&!!(p||Ue||!i&&Z),Re=l.useMemo(()=>{if(!a)return p??"OpenChamber";const U=Q?.title?.trim();return U&&U.length>0?U:"Untitled Session"},[p,Q?.title,a]),ze=dm(),B=tt(U=>U.updateSessionTitle),ce=tt(U=>U.archiveSessions),G=tt(U=>U.deleteSessions),[Ce,J]=l.useState(!1),[Ne,Ae]=l.useState(!1),Ie=l.useRef(null),[De,We]=l.useState(""),[Ke,Ze]=l.useState(!1),Qe=Gt(U=>U.projects.length>0),[qe,et]=l.useState(null),He=ts(U=>qe&&U.entityById.get(qe)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ye=l.useRef(null),dt=l.useCallback(()=>{a&&(We(Q?.title?.trim()||Re),J(!0))},[Q?.title,a,Re]),nt=l.useRef(dt);nt.current=dt;const ut=l.useCallback(U=>{U&&(U.focus(),U.select())},[]);l.useEffect(()=>{if(Ae(!1),et(null),a&&Ie.current===a){Ie.current=null,nt.current();return}J(!1),We("")},[a]);const oe=l.useCallback(async()=>{if(!a)return;const U=De.trim();U&&U!==Q?.title?.trim()&&await B(a,U),J(!1)},[Q?.title,a,De,B]);l.useEffect(()=>{if(!Ce)return;const U=Xe=>{const ot=Xe.target;(!ot||!Ye.current?.contains(ot))&&oe()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Ce,oe]);const de=l.useCallback(U=>{U&&ro(U).then(Xe=>{_e[Xe.ok?"success":"error"](t(Xe.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(t("sessions.sidebar.session.copyId.error")))},[t]),ve=l.useCallback(async()=>{if(!a||!Oe){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const U=await ze({sessionID:a,directory:Oe}).catch(()=>null);if(!U){_e.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(U.length===0){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Xe=um(U,Q?.title??null),ot=fm(Q?.title??null);await pm(Xe,ot)||mm(Xe,ot),_e.success(t("sessions.sidebar.session.export.success"))},[Q?.title,a,ze,Oe,t]),v=hm(),ae=l.useMemo(()=>gm(v),[v]),W=l.useCallback(U=>{a&&Sf({entry:U,t,session:{id:a,title:Q?.title,directory:L??Oe},loadRecords:async()=>{if(!Oe)return null;try{return await ze({sessionID:a,directory:Oe})}catch{return null}},onLoadFailed:()=>_e.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[Q?.title,a,ze,Oe,L,t]),me=l.useCallback(U=>ae.map(Xe=>s.jsxs(U,{onClick:()=>W(Xe),children:[s.jsx(Ti,{icon:Xe.icon,iconSrc:Xe.iconSrc,className:"me-1 size-4"}),Xe.action.label]},`${Xe.guest.id}:${Xe.action.id}`)),[ae,W]),he=u?.type==="busy"||u?.type==="retry",Je=l.useCallback(()=>{if(!a||!L||he||c)return;const Xe=ts.getState().activeSessions.find(ot=>ot.id===a);Xe&&pa({kind:"quick",root:Xe,descendants:ha(Xe,[]),sourceDirectory:L,messages:ma(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,he,c,L,t]),Fe=l.useCallback(U=>{if(!a||!L||he||c)return;const ot=ts.getState().activeSessions.find(Tt=>Tt.id===a);ot&&pa({kind:"project",root:ot,descendants:ha(ot,[]),sourceDirectory:L,projectDirectory:U,messages:ma(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[a,he,c,L,t]),fe=l.useCallback(async(U,Xe)=>{const ot=[Xe,...kf(Xe,[],U==="delete")],Tt=tt.getState().currentSessionId===Xe?Xe:null;if(U==="delete"){const{failedIds:Xt}=await G(ot);Xt.length>0?_e.error(t("sessions.sidebar.session.delete.error")):_e.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:Zt,failedIds:Ds}=await ce(ot);if(Ds.length>0){_e.error(t("sessions.sidebar.session.archive.error"));return}_e.success(t("sessions.sidebar.session.archive.success"),jf(Zt,Tt,t))},[ce,G,t]),ke=l.useCallback(async()=>{qe&&(et(null),await fe("delete",qe))},[qe,fe]),rt=X(U=>U.openGuestPageId),ge=Ni(U=>U.guests.find(Xe=>Xe.id===rt)),lt=X(U=>U.isScheduledTasksDialogOpen),Ct=X(U=>U.isArchivePageOpen),bt=X(U=>U.isIntegrationsCatalogOpen),kt=X(U=>U.isUsageStatsPageOpen),ht=X(U=>U.isSourceBoardOpen),St=X(U=>U.isOverviewOpen),yt=X(U=>U.worktreesPageProjectId),xt=X(U=>U.isolatedSpacesEnabled?U.spacesPageProjectId:null),vt=X(U=>U.runOverviewKey),ct=Cf(vt),Pt=yt??xt,Dt=Gt(U=>{if(!Pt)return null;const Xe=U.projects.find(ot=>ot.id===Pt);return Xe?.label?.trim()||Xe?.path?.split("/").pop()||null}),pt=l.useMemo(()=>ge?{title:ge.pageTitle??ge.name,subtitle:null}:lt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Ct?{title:t("sessions.archivePage.title"),subtitle:null}:bt?{title:t("integrationsCatalog.page.title"),subtitle:null}:kt?{title:t("usageStats.title"),subtitle:null}:ht?{title:t("sourceBoard.title"),subtitle:null}:St?{title:t("overview.title"),subtitle:null}:yt?{title:t("sessions.worktreesPage.title",{project:Dt??""}),subtitle:null}:xt?{title:t("spaces.page.title",{project:Dt??""}),subtitle:null}:vt?{title:ct??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[ge,Ct,bt,ct,vt,lt,ht,St,kt,xt,Dt,t,yt]),mt=L||Tn(Le||"")||we,Ot=l.useCallback(()=>{un("desktop_open_draft_mini_chat_window",{directory:Te?"":je,projectId:Te?null:Se,...Nr()}).catch(U=>{console.warn("[header] failed to open draft mini chat window",U)})},[je,Se,Te]),Ut=l.useCallback(()=>{if(i){Ot();return}a&&un("desktop_open_session_mini_chat_window",{sessionId:a,directory:L||Tn(Le||"")||we,...Nr()}).catch(U=>{console.warn("[header] failed to open session mini chat window",U)})},[a,Ot,i,Le,L,we]),ss=w&&(i||!!a),ps=l.useCallback((U,Xe)=>{un("desktop_open_session_mini_chat_window",{sessionId:U,directory:Xe,...Nr()}).catch(ot=>{console.warn("[header] failed to open session mini chat window",ot)})},[]),ns=Zn,ms=l.useMemo(()=>g&&j&&!y?"88px":S?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||R)&&!k?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,y,j,S,k,R]),ls=(!g||R)&&!k?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",rs=e==="rtl",Rs=rs?ls:ms,Vt=rs?ms:ls,cs=R&&_!==ql(e);Wt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",Rs)},[Rs]);const Ht=n?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",ie=n?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Wt.useEffect(()=>{if(!g||!j){I(!1);return}let U=!1;const Xe=async()=>{try{const Tt=await un("desktop_is_window_fullscreen");U||I(Tt===!0)}catch{U||I(!1)}},ot=()=>{Xe()};return Xe(),window.addEventListener("openchamber:window-resized",ot),()=>{U=!0,window.removeEventListener("openchamber:window-resized",ot)}},[g,j]);const Ge=l.useMemo(()=>!g||!j||P===null?"":P>=26?"h-11":P<=15?"h-14":"",[g,j,P]),gt=l.useMemo(()=>g&&j&&!y?P!==null&&P<=15?"56px":"44px":"0px",[g,y,j,P]),jt=l.useMemo(()=>{const Xe=`max(${g&&j?"2.75rem":"3rem"}, ${gt}, var(--oc-wco-titlebar-height, 0px))`,ot=g&&!R||k;if(ot&&gt==="0px")return{};const Tt={minHeight:Xe,height:Xe};return!cs&&(!ot||rs)&&(Tt.paddingInlineEnd=Vt),Tt},[cs,g,j,rs,k,Vt,gt,R]),It=l.useRef(null),Mt=l.useCallback(U=>{!U||U===It.current||(It.current=U,document.documentElement.style.setProperty("--oc-header-height",`${U}px`))},[]),Kt=l.useCallback(()=>{typeof document>"u"||Mt(x.current?.getBoundingClientRect().height)},[Mt]);Wt.useEffect(()=>{if(typeof window>"u")return;Kt();const U=x.current;if(!U||typeof ResizeObserver>"u")return()=>{};let Xe=0;const ot=()=>{Xe||(Xe=requestAnimationFrame(()=>{Xe=0,Kt()}))},Tt=new ResizeObserver(Zt=>{const Ds=Zt[Zt.length-1];Mt(Ds?.borderBoxSize?.[0]?.blockSize??Ds?.target.getBoundingClientRect().height)});return Tt.observe(U),window.addEventListener("resize",ot),window.addEventListener("orientationchange",ot),()=>{Xe&&cancelAnimationFrame(Xe),Tt.disconnect(),window.removeEventListener("resize",ot),window.removeEventListener("orientationchange",ot)}},[Mt,Kt]),Wt.useEffect(()=>{Kt()},[Kt,h,Ge]);const Jt=l.useCallback(async U=>{const Xe=U.target;Xe.closest(".app-region-no-drag")||Xe.closest("button, a, input, select, textarea")||U.button===0&&g&&await Nu()},[g]);xm({rename_current_session:()=>{if(!a||h)return!1;dt()},archive_current_session:()=>{if(!a||h||ts.getState().entityById.get(a)?.time.archived)return!1;fe("archive",a)}});const gs=l.useCallback(({session:U,open:Xe,isActive:ot,select:Tt,closeOtherTabs:Zt,components:Ds})=>{const{Item:Xt,Separator:en}=Ds,Sn=ot&&!k&&!Te&&Q&&!Q.parentId,tn=ot&&!k&&Te&&Q&&!Q.parentId&&Qe;return s.jsxs(s.Fragment,{children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Xt,{onClick:()=>{ot||Tt(),Ie.current=U.id},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),ot&&T?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:T}):null]})}),s.jsx(ga,{sessionID:U.id,directory:U.directory,open:Xe,Item:Xt}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Xt,{onClick:()=>de(U.id),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(en,{}),ot?s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Xt,{onClick:()=>{ve()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,w?s.jsxs(Xt,{onClick:()=>ps(U.id,ot?mt:U.directory??""),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ot?me(Xt):null,Sn?s.jsx(ds,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Xt,{disabled:!L||he||c,onClick:Je,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,tn?s.jsx(ds,{hint:t(he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Xt,{disabled:!L||he||c,onClick:()=>Ze(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,s.jsx(en,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:s.jsxs(Xt,{onClick:Zt,children:[s.jsx(se,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),s.jsx(en,{}),s.jsx(_x,{session:U,Item:Xt}),s.jsx(Wa,{sessionId:U.id,Item:Xt,onArchive:()=>{fe("archive",U.id)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Xt,{className:"text-destructive focus:text-destructive",onClick:()=>et(U.id),children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[de,Q,mt,ve,w,Qe,Te,he,c,k,Je,ps,me,T,fe,L,t]),Cs=()=>s.jsxs("div",{onMouseDown:Jt,className:$e("app-region-drag relative flex h-12 select-none items-center",cs?"pe-0":"pe-2.5",Ge),style:jt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Ht,transitionDuration:`${r}ms`,transitionTimingFunction:Wn}}),s.jsx("div",{ref:wd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:ie,transitionDuration:`${r}ms`,transitionTimingFunction:Wn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[pt?s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>X.getState().closeMainSurfaces(),children:s.jsx(se,{name:"arrow-left",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[s.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:pt.title}),pt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:pt.subtitle}):null]})]}):k||!o?s.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[pe?s.jsx(se,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,n?null:s.jsxs(Lt,{children:[s.jsx(g1,{align:"start",children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",className:ns,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(se,{name:"history",className:"h-4 w-4"})})})}),s.jsx($t,{side:"bottom",children:s.jsx(Hs,{label:t("sessions.switcher.openAria"),shortcut:ws(Es("open_session_list",N),"")})})]}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ce?s.jsxs("form",{ref:Ye,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),oe()},children:[s.jsx("input",{ref:ut,value:De,onChange:U=>We(U.target.value),onKeyDown:U=>xa(U,()=>J(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[0.875rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>J(!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(se,{name:"close",className:"size-4"})})]}):i?null:s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:Re}),Me?s.jsxs("span",{className:$e("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[0.875rem] text-foreground":"typography-micro text-[0.65625rem] text-muted-foreground"),children:[p?s.jsx("span",{className:"truncate",children:p}):null,Ue?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(se,{name:"git-branch",className:$e("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),s.jsx("span",{className:$e("truncate",i&&"text-muted-foreground"),children:Ue})]}):null,!i&&Z?s.jsxs("span",{className:$e("inline-flex min-w-0 items-center gap-0.5",Z==="attention"||Z==="invalid"||Z==="missing"?"text-status-warning":"text-muted-foreground"),children:[s.jsx(se,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Y})]}):null]}):null]}),s.jsx("div",{className:$e("flex h-[1.125rem] shrink-0 items-center justify-center",Me?"self-start":"self-center"),children:a&&!i&&!Ce?s.jsxs(xn,{open:Ne,onOpenChange:Ae,onOpenChangeComplete:U=>{!U&&Ie.current&&Ie.current===a&&(Ie.current=null,dt())},children:[s.jsx(bn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"h-[1.125rem] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(se,{name:"more",className:"size-4"})})}),s.jsxs(wn,{align:"end",className:"min-w-[190px]",children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(qt,{onClick:()=>{Ie.current=a},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),T?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:T}):null]})}),s.jsx(ga,{sessionID:a,directory:L,open:Ne,Item:qt}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(qt,{onClick:()=>a&&de(a),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(mn,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(qt,{onClick:()=>{ve()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),w?s.jsxs(qt,{onClick:()=>ps(a,mt),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,me(qt),!k&&!Te&&Q&&!Q.parentId?s.jsx(ds,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(qt,{disabled:!L||he||c,onClick:Je,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,!k&&Te&&Q&&!Q.parentId&&Qe?s.jsx(ds,{hint:t(he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(qt,{disabled:!L||he||c,onClick:()=>Ze(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,s.jsx(mn,{}),s.jsx(Wa,{sessionId:a,Item:qt,onArchive:()=>{fe("archive",a)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(qt,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&et(a)},children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):s.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:s.jsx(Q1,{renderMenu:gs,suppressActiveTabControls:Ce,onMenuOpenChangeComplete:U=>{!U&&Ie.current&&Ie.current===a&&(Ie.current=null,dt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ce?s.jsxs("form",{ref:Ye,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),oe()},children:[s.jsx("input",{ref:ut,value:De,onChange:U=>We(U.target.value),onKeyDown:U=>xa(U,()=>J(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[0.8125rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>J(!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(se,{name:"close",className:"size-4"})})]}):s.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):Re})})})}),pt||k||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!k&&!pt?s.jsxs(s.Fragment,{children:[s.jsx(Vx,{buttonClassName:Zn}),s.jsx(ab,{buttonClassName:Zn})]}):null,ss?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Ut,className:Zn,children:s.jsx(se,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:s.jsx(Hs,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?ws(Es("new_mini_chat",N),""):void 0})})]}):null,k?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":H,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:V,className:$e(Zn,H&&"text-foreground"),children:s.jsx(se,{name:"list-indefinite",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:t($&&!q?M?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":$?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),s.jsx(nd,{visible:cs,position:_})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:x,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Cs()}),s.jsx(Ex,{open:Ke,onOpenChange:Ze,onPick:Fe}),s.jsx(zn,{open:qe!==null,onOpenChange:U=>{U||et(null)},children:s.jsxs(Bn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs($n,{children:[s.jsx(Fn,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),s.jsx(Ln,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:He})})]}),s.jsxs(Br,{children:[s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>et(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",size:"sm",onClick:()=>{ke()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},qa=280,Ga=264,Ka=500,fb=({isOpen:t,isMobile:e,children:n,className:r,topBar:o,peek:i})=>{const{t:a,direction:u}=at(),c=X(F=>F.sidebarWidth),d=X(F=>F.setSidebarWidth),[f,p]=l.useState(!1),m=l.useRef(0),h=l.useRef(c||qa),x=l.useRef(null),g=l.useRef(null),b=l.useRef(null),w=l.useRef(null),S=l.useRef(null),y=l.useCallback(F=>Math.min(Ka,Math.max(Ga,F)),[]),I=l.useCallback(()=>{const F=S.current;if(F?.isConnected)return F;const C=document.querySelector("[data-titlebar-left-controls]");return S.current=C,C},[]),j=l.useCallback(F=>{const C=w.current;if(!C)return;C.style.width=`${F}px`,C.style.minWidth=`${F}px`,C.style.maxWidth=`${F}px`,C.style.setProperty("--oc-left-sidebar-width",`${F}px`);const te=I();te&&te.style.setProperty("--oc-left-sidebar-width",`${F}px`)},[I]);l.useEffect(()=>{e&&f&&p(!1)},[e,f]),l.useEffect(()=>{f||(x.current=null,g.current=null,b.current?.(),b.current=null)},[f]),l.useEffect(()=>{!t&&f&&p(!1)},[t,f]),l.useEffect(()=>()=>{b.current?.(),b.current=null},[]);const R=Math.min(Ka,Math.max(Ga,c||qa)),_=t?R:0,P=f?x.current??_:_,k=f?P:R;l.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${k}px`);const F=S.current;!f&&F&&F.style.removeProperty("--oc-left-sidebar-width")},[k,f]);const[N,T]=l.useState(!t);t&&N&&T(!1);const A=ao(),$=l.useRef(t),K=l.useRef(t);if(l.useLayoutEffect(()=>{$.current=t,K.current!==t&&(K.current=t,Ec(A),t||Ei(()=>{$.current||T(!0)}))},[t,A]),e)return null;const q=F=>{if(t){try{F.currentTarget.setPointerCapture(F.pointerId)}catch{}g.current=F.pointerId,p(!0),m.current=F.clientX,h.current=_,x.current=_,j(_),b.current?.(),b.current=Pc(),F.preventDefault()}},M=F=>{if(e||!f||g.current!==F.pointerId)return;const C=(F.clientX-m.current)*(u==="rtl"?-1:1),te=y(h.current+C);x.current!==te&&(x.current=te,j(te))},z=F=>{if(g.current!==F.pointerId||e)return;try{F.currentTarget.releasePointerCapture(F.pointerId)}catch{}const C=y(x.current??_);g.current=null,x.current=null,p(!1),d(C),b.current?.(),b.current=null},ne=!t&&i?i.state:!1,H=ne!==!1,V=H&&i&&i.animationMs>0?`${ne==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${Wn} forwards`:void 0;return s.jsxs("div",{ref:w,"data-left-sidebar":"",className:$e("relative flex h-full",!H&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${P}px`,minWidth:`${P}px`,maxWidth:`${P}px`,"--oc-left-sidebar-width":`${k}px`,overflowX:H?void 0:"clip",transitionDuration:`${A}ms`,transitionTimingFunction:Wn},children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-0.5px_0_0_0_var(--oc-edge-strong)] rtl:shadow-[inset_0.5px_0_0_0_var(--oc-edge-strong)]","aria-hidden":"true"}),t&&s.jsx("div",{className:$e("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:q,onPointerMove:M,onPointerUp:z,onPointerCancel:z,onLostPointerCapture:z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":H?ne:void 0,className:$e("flex h-full shrink-0 flex-col",H?"absolute inset-s-0 top-0 z-[25] bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!H&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${A}ms`,overflowX:"hidden",contentVisibility:N&&!H?"hidden":void 0,animation:V,"--oc-peek-offset":u==="rtl"?"100%":"-100%"},inert:!t&&!H||void 0,onPointerEnter:H?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:H?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:H?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,s.jsx(fs,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Qt,{children:n})})]})]})},pb=()=>{const t=Be.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-start-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",{ref:wd,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},mb=50,hb=18,gb=300,xb='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',yd=t=>!document.getElementById("root")?.contains(t),bb=t=>{if((Qr(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>hb)return!1;const n=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=n},Za=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(xb)).some(n=>yd(n)&&n.getClientRects().length>0)},wb=({enabled:t,layoutAnimationMs:e})=>{const[n,r]=l.useState(!1),o=bm()?0:e,i=o>0,a=l.useRef(null),u=l.useRef(null),c=l.useRef(null),d=l.useCallback(()=>{u.current!==null&&clearTimeout(u.current),c.current!==null&&clearTimeout(c.current),u.current=null,c.current=null},[]),f=l.useCallback(()=>{d(),r(x=>x==="in"&&i?"out":!1)},[i,d]),p=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{if(c.current=null,Za(a.current)){p();return}f()},gb)},[f]),m=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null},[]);l.useEffect(()=>{t||(d(),r(!1))},[d,t]),l.useEffect(()=>d,[d]),l.useEffect(()=>{if(n!=="in")return;const x=w=>{const S=w.target;S instanceof Element&&(a.current?.contains(S)||yd(S)||f())},g=w=>{Ic(w)||w.key!=="Escape"||w.defaultPrevented||Za(a.current)||f()},b=w=>{w.relatedTarget===null&&p()};return document.addEventListener("pointerdown",x,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",b)}},[f,p,n]),l.useEffect(()=>{if(!t||n!==!1)return;const x=()=>{u.current!==null&&clearTimeout(u.current),u.current=null},g=w=>{if(w.pointerType!=="mouse"||w.buttons!==0||!bb(w)){x();return}u.current===null&&(u.current=setTimeout(()=>{u.current=null,r("in")},mb))},b=w=>{w.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",b),x()}},[t,n]);const h=l.useMemo(()=>({onPointerEnter:()=>{m(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{n==="in"&&p()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?!1:g)}}),[m,p,n]);return{state:t?n:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},vr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",yb=()=>{const t=Be.c(47),{t:e,locale:n,direction:r}=at(),o=X(vb),i=X(Sb),a=X(kb),u=l.useRef(null),c=ws(Es("toggle_sidebar",a)),d=jb,f=X(Cb),{usesFramelessChrome:p,side:m}=sd();let h;t[0]!==n?(h=C=>{const te=C.currentTarget.getBoundingClientRect();un("desktop_show_app_menu",{x:te.left,y:te.bottom,locale:n}).catch(Tb)},t[0]=n,t[1]=h):h=t[1];const x=h;let g,b;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const C=u.current;if(!C)return;const te=()=>{const Q=Math.max(C.getBoundingClientRect().width,C.scrollWidth);db(Q)};if(te(),typeof ResizeObserver>"u")return;const re=new ResizeObserver(te);return re.observe(C),()=>{re.disconnect()}},b=[],t[2]=g,t[3]=b):(g=t[2],b=t[3]),l.useEffect(g,b);const w="",S="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",y=i?"var(--oc-left-sidebar-width, 100%)":void 0;let I;t[4]!==y?(I={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:y},t[4]=y,t[5]=I):I=t[5];const j="flex min-w-0 items-center gap-2";let R;t[6]!==r||t[7]!==p||t[8]!==m?(R=p&&m===ql(r)?s.jsx(nd,{visible:!0,position:m}):null,t[6]=r,t[7]=p,t[8]=m,t[9]=R):R=t[9];let _;t[10]!==x||t[11]!==e||t[12]!==p?(_=p?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:$e(vr,"shrink-0"),children:s.jsx(se,{name:"menu-2",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=p,t[13]=_):_=t[13];const P=Lt;let k;t[14]!==e?(k=e("header.actions.openSessionsAria"),t[14]=e,t[15]=k):k=t[15];const N=i&&"text-foreground";let T;t[16]!==N?(T=$e(vr,"shrink-0",N),t[16]=N,t[17]=T):T=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(se,{name:"layout-left",className:"h-4 w-4"}),t[18]=A):A=t[18];let $;t[19]!==i||t[20]!==k||t[21]!==T||t[22]!==o?($=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":k,"aria-pressed":i,className:T,children:A})}),t[19]=i,t[20]=k,t[21]=T,t[22]=o,t[23]=$):$=t[23];const K=$t,q=e("header.actions.openSessionsWithShortcut",{shortcut:c});let M;t[24]!==q?(M=s.jsx("p",{children:q}),t[24]=q,t[25]=M):M=t[25];let z;t[26]!==K||t[27]!==M?(z=s.jsx(K,{children:M}),t[26]=K,t[27]=M,t[28]=z):z=t[28];let ne;t[29]!==P||t[30]!==$||t[31]!==z?(ne=s.jsxs(P,{children:[$,z]}),t[29]=P,t[30]=$,t[31]=z,t[32]=ne):ne=t[32];let H;t[33]!==d||t[34]!==i||t[35]!==a||t[36]!==e||t[37]!==f?(H=f?null:i?s.jsxs("button",{type:"button",onClick:d,className:$e(vr,"-ms-1 w-auto min-w-0 ps-1 pe-1.5 font-normal"),children:[s.jsx(se,{name:"chat-new",className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:$e(vr,"-ms-1 shrink-0"),children:s.jsx(se,{name:"chat-new",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx(Hs,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:ws(Es("new_chat",a),"")})})]}),t[33]=d,t[34]=i,t[35]=a,t[36]=e,t[37]=f,t[38]=H):H=t[38];let V;t[39]!==ne||t[40]!==H||t[41]!==R||t[42]!==_?(V=s.jsxs("div",{ref:u,className:j,children:[R,_,ne,H]}),t[39]=ne,t[40]=H,t[41]=R,t[42]=_,t[43]=V):V=t[43];let F;return t[44]!==V||t[45]!==I?(F=s.jsx("div",{"data-titlebar-left-controls":w,className:S,style:I,children:V}),t[44]=V,t[45]=I,t[46]=F):F=t[46],F};function vb(t){return t.toggleSidebar}function Sb(t){return t.isSidebarOpen}function kb(t){return t.shortcutOverrides}function jb(){X.getState().closeMainSurfaces(),tt.getState().openNewSessionDraft()}function Cb(t){return t.sessionTabsEnabled&&!(t.isScheduledTasksDialogOpen||t.isArchivePageOpen||t.isIntegrationsCatalogOpen||t.isUsageStatsPageOpen||t.isSourceBoardOpen||t.isOverviewOpen||t.worktreesPageProjectId!==null||t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null||t.runOverviewKey!==null||t.openGuestPageId!==null)}function Tb(t){console.warn("[titlebar] failed to open app menu",t)}function Nb(t,e,n){const r=Be.c(5),[o,i]=l.useState();let a,u;return r[0]!==n||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let c=!1;return(async()=>{const[d,f]=await Promise.all([wm(t),ym(t)]).catch(Eb);if(c)return;const p=Yt(d),m=Yt(f);if(!p||!m||m===p)return;const h=n||"",x=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:p,branch:h,label:h||x,name:x,worktreeRoot:m,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{c=!0}},u=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=a,r[4]=u):(a=r[3],u=r[4]),l.useEffect(a,u),e??o}function Eb(){return["",""]}const Pb=()=>{const t=Be.c(3),e=X(Ib),n=X(Rb);let r;return t[0]!==e||t[1]!==n?(r=()=>{n("integrations"),e(!0)},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function Ib(t){return t.setSettingsDialogOpen}function Rb(t){return t.setSettingsPage}const Xa="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",Db=({className:t,identity:e})=>{const{t:n}=at(),{sourceControl:r}=Is(),o=vm(e),i=yi(e.provider),a=i.label,u=o?.status??null,c=hn(w=>w.setStatus),[d,f]=l.useState(!1),p=l.useCallback(async w=>{if(!(!w||d)){f(!0);try{c(e,await r.authActivate(e,w))}catch(S){console.error("Failed to switch source control account:",S)}finally{f(!1)}}},[e,d,c,r]);if(u?.status!=="connected")return null;const m=u.user.username||null,h=u.user.avatarUrl??null,x=u.accounts,g=m?n("header.sourceControl.connectedWithLogin",{login:m,provider:a}):n("header.sourceControl.connected",{provider:a}),b=h?s.jsx("img",{src:h,alt:m?n("header.sourceControl.avatarWithLogin",{login:m}):n("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(Ca,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?s.jsx("div",{className:$e(Xa,t),title:g,children:b}):s.jsxs(xn,{children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:$e(Xa,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:d,children:b})}),s.jsxs(wn,{align:"end",className:"w-64",children:[s.jsx(Ir,{className:"typography-ui-header font-semibold text-foreground",children:n("header.sourceControl.accountsTitle",{provider:a})}),s.jsx(mn,{}),x.map(w=>{const S=w.user,y=!!w.current,I=n(Sm(w.source??"oauth"));return s.jsxs(qt,{className:"gap-2",disabled:d,onSelect:()=>{y||p(w.id)},children:[S?.avatarUrl?s.jsx("img",{src:S.avatarUrl,alt:S.username?n("header.sourceControl.avatarWithLogin",{login:S.username}):n("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge 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-edge bg-muted",children:s.jsx(Ca,{descriptor:i,variant:"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:S?.name?.trim()||S.username||i.label}),S.username?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:S.username}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:I})]}):null]}),y?s.jsx(se,{name:"check",className:"h-4 w-4 text-primary"}):null]},w.id)})]})]})},_b=t=>JSON.stringify(km(t)),Ab=async(t,e)=>{const n=await t.projectUpstream(e);if(!n?.isFork||!n.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,n.upstream.owner,n.upstream.name);return{upstream:n.upstream,branches:r}},vd=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function Ob(t){if(!vd(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function Mb(t,e,n){const r=Be.c(18),{sourceControl:o}=Is(),i=yi(t.provider).features.referenceSearch,[a,u]=Wt.useState(null);let c;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(c=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=c):c=r[4];const d=c;let f;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==i||r[9]!==o?(f=()=>{if(!i)return;let m=!1;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(m||!h.connected)return;const x=h.items.find(g=>g.kind==="pull"&&g.number===e);x&&u({key:d,pull:x})}).catch(Fb),()=>{m=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=i,r[9]=o,r[10]=f):f=r[10];let p;return r[11]!==t||r[12]!==d||r[13]!==e||r[14]!==n||r[15]!==i||r[16]!==o?(p=[t,d,e,n,i,o],r[11]=t,r[12]=d,r[13]=e,r[14]=n,r[15]=i,r[16]=o,r[17]=p):p=r[17],Wt.useEffect(f,p),a?.key===d?a.pull:null}function Fb(){}const Lb=t=>{const e=Be.c(93),{directory:n,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:u}=Is(),c=Gs(),d=Gt($b),[f,p]=Wt.useState(0),[m,h]=Wt.useState(!1),x=Pi(),g=Mb(r,o.number,f);let b;e[0]!==o?(b=jm(o),e[0]=o,e[1]=b):b=e[1];const w=b;let S;e[2]!==g||e[3]!==w?(S=g?{...w,labels:g.labels,commentCount:g.commentCount}:w,e[2]=g,e[3]=w,e[4]=S):S=e[4];const y=S,[I,j]=Wt.useState(null),R=I?.number===o.number?I.sha:null,{detail:_,latest:P,refresh:k}=Rc(n,y,!0,R),N=P.status==="ready"?P.value.pull:null,T=ic(y);let A;e[5]!==i||e[6]!==k?(A=()=>{k(),p(Bb),i()},e[5]=i,e[6]=k,e[7]=A):A=e[7];const $=A,K=ac(y,r,$);let q;e[8]!==r||e[9]!==i||e[10]!==y.number||e[11]!==y.sourceRepo.owner||e[12]!==y.sourceRepo.repo||e[13]!==k||e[14]!==u?(q=async()=>{const J={owner:y.sourceRepo.owner,repo:y.sourceRepo.repo,number:y.number};await u.refreshProviderReads(r,{item:J}).catch(zb),Dc(J),p(Wb),await Promise.all([k(),i()])},e[8]=r,e[9]=i,e[10]=y.number,e[11]=y.sourceRepo.owner,e[12]=y.sourceRepo.repo,e[13]=k,e[14]=u,e[15]=q):q=e[15];const M=q;let z;e[16]!==y?(z={source:"repository",reference:y},e[16]=y,e[17]=z):z=e[17];const ne=z,H=c??n;let V;e[18]!==_||e[19]!==a?(V=_.status==="ready"&&_.value.pull&&_.value.pull.stack===void 0&&a!==void 0?{status:"ready",value:{..._.value,pull:{..._.value.pull,stack:a}}}:_,e[18]=_,e[19]=a,e[20]=V):V=e[20];const F=V,C=F.status==="ready"?F.value.pull?.stack??null:a??null,te=Ii(),re=Gt(Ub),Q=tt(Vb),ee=hr(re,Q,n),[le,O]=Wt.useState(!1);let Y;e[21]===Symbol.for("react.memo_cache_sentinel")?(Y={status:"idle"},e[21]=Y):Y=e[21];const Z=ee?()=>O(!0):void 0,we=N?.submitRequirements,L=P.status==="error",pe=o.mergeable??null;let je;e[22]!==r||e[23]!==ne||e[24]!==$||e[25]!==C||e[26]!==L||e[27]!==pe||e[28]!==Z||e[29]!==we?(je=s.jsx(ji,{item:ne,project:null,context:r,onStartWorktree:qb,onChanged:$,worktreeAvailable:!1,stack:C,onStartOnTop:Z,submitRequirements:we,submitRequirementsUnreadable:L,mergeable:pe}),e[22]=r,e[23]=ne,e[24]=$,e[25]=C,e[26]=L,e[27]=pe,e[28]=Z,e[29]=we,e[30]=je):je=e[30];let Ee;e[31]!==o.number||e[32]!==N||e[33]!==R?(Ee=N?.revisions?{revisions:N.revisions,selected:R,onSelect:J=>j(J?{number:o.number,sha:J}:null)}:void 0,e[31]=o.number,e[32]=N,e[33]=R,e[34]=Ee):Ee=e[34];let Se;e[35]!==n||e[36]!==te?(Se=J=>{te(J.url,n)},e[35]=n,e[36]=te,e[37]=Se):Se=e[37];let Le;e[38]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>h(!0),e[38]=Le):Le=e[38];let Pe;e[39]!==T.attachComment||e[40]!==T.attachComments?(Pe={onAttach:T.attachComment,onAttachAll:T.attachComments},e[39]=T.attachComment,e[40]=T.attachComments,e[41]=Pe):Pe=e[41];let Ve;e[42]!==r||e[43]!==y||e[44]!==$?(Ve=s.jsx(dc,{reference:y,context:r,onChanged:$}),e[42]=r,e[43]=y,e[44]=$,e[45]=Ve):Ve=e[45];let Oe;e[46]!==r||e[47]!==_||e[48]!==y||e[49]!==$?(Oe=s.jsx(uc,{pull:y,detail:_,context:r,onChanged:$}),e[46]=r,e[47]=_,e[48]=y,e[49]=$,e[50]=Oe):Oe=e[50];const be=N?.voteLabels;let ye;e[51]!==N?.revisions?(ye=N?.revisions?.at(-1)?.sha,e[51]=N?.revisions,e[52]=ye):ye=e[52];const Ue=R===null;let Te;e[53]!==r||e[54]!==y||e[55]!==$||e[56]!==be||e[57]!==ye||e[58]!==Ue?(Te=s.jsx(lc,{reference:y,context:r,onRefresh:$,voteLabels:be,latestRevision:ye,onLatestRevision:Ue},y.number),e[53]=r,e[54]=y,e[55]=$,e[56]=be,e[57]=ye,e[58]=Ue,e[59]=Te):Te=e[59];const Me=d??"";let Re;e[60]!==H||e[61]!==Me?(Re={id:Me,path:H},e[60]=H,e[61]=Me,e[62]=Re):Re=e[62];let ze;e[63]!==r||e[64]!==H||e[65]!==y||e[66]!==R||e[67]!==Re?(ze=s.jsx(fc,{pull:y,project:Re,repository:null,context:r,projectOwnsDirectory:Gb,currentDirectory:H,revision:R}),e[63]=r,e[64]=H,e[65]=y,e[66]=R,e[67]=Re,e[68]=ze):ze=e[68];let B;e[69]!==n||e[70]!==ne||e[71]!==x||e[72]!==M||e[73]!==F||e[74]!==je||e[75]!==Ee||e[76]!==Se||e[77]!==Pe||e[78]!==Ve||e[79]!==Oe||e[80]!==Te||e[81]!==ze||e[82]!==K?(B=s.jsx(Ri,{item:ne,directory:n,pullStatus:Di,trackerDetail:Y,repositoryDetail:F,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Hb,now:x,footer:je,revisionChoice:Ee,onOpenStackLayer:Se,onOpenChecks:Le,onRefresh:M,commentAttachments:Pe,threadActions:K,labelsControl:Ve,reviewersControl:Oe,reply:Te,pullLinks:ze}),e[69]=n,e[70]=ne,e[71]=x,e[72]=M,e[73]=F,e[74]=je,e[75]=Ee,e[76]=Se,e[77]=Pe,e[78]=Ve,e[79]=Oe,e[80]=Te,e[81]=ze,e[82]=K,e[83]=B):B=e[83];let ce;e[84]!==T.attachFailedChecks||e[85]!==m||e[86]!==r||e[87]!==y?(ce=s.jsx(cc,{pull:y,context:r,open:m,onOpenChange:h,onAttachFailed:T.attachFailedChecks}),e[84]=T.attachFailedChecks,e[85]=m,e[86]=r,e[87]=y,e[88]=ce):ce=e[88];const G=ee?s.jsx(Cm,{open:le,onOpenChange:O,project:{id:ee.id,path:zr(ee.path)??ee.path},initialSourceBranch:y.head,onWorktreeCreated:Kb}):null;let Ce;return e[89]!==B||e[90]!==ce||e[91]!==G?(Ce=s.jsxs(s.Fragment,{children:[B,ce,G]}),e[89]=B,e[90]=ce,e[91]=G,e[92]=Ce):Ce=e[92],Ce};function $b(t){return t.activeProjectId}function Bb(t){return t+1}function zb(){}function Wb(t){return t+1}function Ub(t){return t.projects}function Vb(t){return t.availableWorktreesByProject}function Hb(){}function qb(){}function Gb(){return!0}function Kb(t){tt.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const Zb=/^Change-Id:\s*I[0-9a-f]{40}$/,Xb=50,Yb=t=>(t.replace(/\r\n/g,`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-Z4zWCBn1.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-C_TEX3sk.js","assets/katex.min-BCtkGOiC.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-Csf1sqWl.js","assets/vendor-opencode-client-CqFY51gT.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/vendor-streamdown-BbSYZ3NF.js","assets/vendor-markdown-BTUqNk6W.js","assets/vendor-mdast-util-from-markdown-CZHjOE75.js","assets/vendor-micromark-util-decode-numeric-character-reference-CNs1qBpV.js","assets/vendor-micromark-util-decode-string-fHsnqYdj.js","assets/vendor-decode-named-character-reference-C3-224fz.js","assets/vendor-micromark-util-normalize-identifier-C9ANKk3v.js","assets/vendor-micromark-AWM-NZXP.js","assets/vendor-micromark-util-combine-extensions-d8XJZrgA.js","assets/vendor-micromark-util-chunked-DrRIdSP-.js","assets/vendor-micromark-factory-space-PzSHLgmq.js","assets/vendor-micromark-util-character-CW3Cu1MS.js","assets/vendor-micromark-core-commonmark-kzTLNXAm.js","assets/vendor-micromark-util-classify-character-tcLuZZwM.js","assets/vendor-micromark-util-resolve-all-PQCKh0dx.js","assets/vendor-micromark-util-subtokenize-BF1Jf29a.js","assets/vendor-micromark-factory-destination-Sj0xfi0V.js","assets/vendor-micromark-factory-label-amyP0HdC.js","assets/vendor-micromark-factory-title-khnLkZK6.js","assets/vendor-micromark-factory-whitespace-eIB00uTl.js","assets/vendor-micromark-util-html-tag-name-DbKNfynz.js","assets/vendor-unist-util-stringify-position-Ch_qCilz.js","assets/vendor-mdast-util-to-string-C_aolqmU.js","assets/vendor-unist-util-visit-DhPeCsfG.js","assets/vendor-unist-util-visit-parents-DlviEg7Z.js","assets/vendor-unist-util-is-BPZGFiMU.js","assets/vendor-hast-util-raw-DvvLJg15.js","assets/vendor-ungap-structured-clone--gfxRhYI.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-parse5-DwmzEj2o.js","assets/vendor-entities-wUUgTZDW.js","assets/vendor-web-namespaces-bsVAaBS1.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-unist-util-position-60F3QETU.js","assets/vendor-hast-util-from-parse5-Ba3T6RJI.js","assets/vendor-devlop-0Dp3JUBc.js","assets/vendor-property-information-Boo8Xpef.js","assets/vendor-hastscript-BrPNioaz.js","assets/vendor-comma-separated-tokens-CRUGqg4f.js","assets/vendor-space-separated-tokens-D7QSIrTI.js","assets/vendor-hast-util-parse-selector-TXfch5wI.js","assets/vendor-vfile-location-LfEFwJ2h.js","assets/vendor-hast-util-to-parse5-BoysVIPW.js","assets/vendor-hast-util-sanitize-2aGO5ay8.js","assets/vendor-micromark-extension-gfm-CsfPlnlB.js","assets/vendor-micromark-extension-gfm-autolink-literal-BYug7onl.js","assets/vendor-micromark-extension-gfm-footnote-OFl1FCH2.js","assets/vendor-micromark-extension-gfm-strikethrough-CyFiuwBf.js","assets/vendor-micromark-extension-gfm-table-dgw4LfUw.js","assets/vendor-micromark-extension-gfm-task-list-item-Dnadzr9U.js","assets/vendor-mdast-util-gfm-CroMDYLM.js","assets/vendor-mdast-util-gfm-autolink-literal-CTruMtvI.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-mdast-util-find-and-replace-DB9iC-bx.js","assets/vendor-escape-string-regexp-BaJN9MlJ.js","assets/vendor-mdast-util-gfm-footnote-C-csI7OF.js","assets/vendor-mdast-util-gfm-strikethrough-BcskTdio.js","assets/vendor-mdast-util-gfm-table-DhPwQIyj.js","assets/vendor-markdown-table-DvhhVmnL.js","assets/vendor-mdast-util-to-markdown-Cl3qaiyc.js","assets/vendor-longest-streak-CtXnX3Xp.js","assets/vendor-mdast-util-phrasing-4oVbNLC3.js","assets/vendor-mdast-util-gfm-task-list-item-DMU5mK_M.js","assets/vendor-mdast-util-to-hast-CWnLaQSO.js","assets/vendor-micromark-util-sanitize-uri-BbwQ7CLk.js","assets/vendor-trim-lines-D8znQY54.js","assets/vendor-micromark-extension-cjk-friendly-BzZDGrF5.js","assets/vendor-micromark-extension-cjk-friendly-util-D5lVNoxW.js","assets/vendor-get-east-asian-width-CPhS2cOv.js","assets/vendor-micromark-util-symbol-JJPacVTp.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-BZ3pe_qd.js","assets/vendor-micromark-extension-cjk-friendly-gfm-strikethrough-CqW-Ep4M.js","assets/vendor-mdast-util-to-markdown-cjk-friendly-gfm-strikethrough-BdPDQFO7.js","assets/vendor-hast-util-from-html-isomorphic-B0Kn01s9.js","assets/vendor-hast-util-from-dom-DeNf9aYW.js","assets/vendor-katex-DBqql0K7.js","assets/vendor-hast-util-to-text-0GXLnBvt.js","assets/vendor-hast-util-is-element-CuOmiqQi.js","assets/vendor-unist-util-find-after-CMaZmLxc.js","assets/vendor-micromark-extension-math-BRFoDziv.js","assets/vendor-mdast-util-math-wB-IJCL0.js","assets/vendor-remend-r8cP_t-e.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-marked-DN3zOnEe.js","assets/vendor-hast-util-to-jsx-runtime-Bq6JeJCx.js","assets/vendor-style-to-js-CI2G4dgu.js","assets/vendor-style-to-object-BAv4SQXc.js","assets/vendor-inline-style-parser-BlqBsVO4.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-estree-util-is-identifier-name-BgBfM8ME.js","assets/vendor-vfile-message-DqhD22jI.js","assets/vendor-unified-1CQKw2_w.js","assets/vendor-bail-FqpXQuLt.js","assets/vendor-extend-B94qxKr5.js","assets/vendor-is-plain-obj-C1gvLhAf.js","assets/vendor-trough-B_b8ryxu.js","assets/vendor-vfile-BCWrK60u.js","assets/vendor-html-url-attributes-D46m5wfe.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/katex-arxpHWv8.css","assets/vendor-base-ui-zhBy6TEG.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-Cy8dRGoy.js","assets/vendor-use-sync-external-store-CfLJGVyr.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-dnd-kit-core-Br1Cs7RV.js","assets/vendor-dnd-kit-utilities-DZ9KbT5S.js","assets/vendor-dnd-kit-accessibility-CYclfhtC.js","assets/vendor-dnd-kit-sortable-DpfLEOLv.js","assets/vendor-tanstack-react-virtual-C_IilPt1.js","assets/vendor-tanstack-virtual-core-DsQgKrou.js","assets/vendor-framer-motion-C_wK4GIM.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-CjjsURR-.js","assets/vendor-codemirror-state-Cd8udR5z.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-Ciie9ey-.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-8HZTPOnt.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CZEcqU6G.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-DmqaSK_j.js","assets/vendor-lezer-javascript-CWSwshuO.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BGedy2gC.js","assets/vendor-codemirror-lang-json-DVAYKmoO.js","assets/vendor-lezer-json-Cn1mncjr.js","assets/vendor-codemirror-lang-css-BLpgXfL2.js","assets/vendor-lezer-css-B2Hx_Nps.js","assets/vendor-codemirror-lang-html-S3jxr3Mo.js","assets/vendor-lezer-html-Cr8K5DGw.js","assets/vendor-codemirror-lang-markdown-D1jveRI5.js","assets/vendor-lezer-markdown-TQKzBB8i.js","assets/vendor-codemirror-language-data-Cy549AYN.js","assets/vendor-codemirror-lang-python-B-5UC9Ui.js","assets/vendor-lezer-python-BUoImtUb.js","assets/vendor-sonner-Dw26OnzC.js","assets/vendor-cmdk-BtSpU-Io.js","assets/vendor-radix-ui-react-dialog-OIW6VLWw.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D4RvEbuR.js","assets/vendor-radix-ui-react-context-BbFoxCHu.js","assets/vendor-radix-ui-react-id-aGag8i_5.js","assets/vendor-radix-ui-react-use-layout-effect-B1oLzD-j.js","assets/vendor-radix-ui-react-use-controllable-state-BjnNPGHq.js","assets/vendor-radix-ui-react-dismissable-layer-DpT6mMbO.js","assets/vendor-radix-ui-react-primitive-CrN9dRDb.js","assets/vendor-radix-ui-react-slot-BjbalUfz.js","assets/vendor-radix-ui-react-use-callback-ref-CcC_buIU.js","assets/vendor-radix-ui-react-use-escape-keydown-Cp1WWKTC.js","assets/vendor-radix-ui-react-focus-scope-D1noLHmd.js","assets/vendor-radix-ui-react-portal-BlUEzfrF.js","assets/vendor-radix-ui-react-presence-BGqFfiW4.js","assets/vendor-radix-ui-react-focus-guards-CSS2IbZC.js","assets/vendor-react-remove-scroll-Der_cv-1.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-Clwl9llp.js","assets/vendor-react-style-singleton-D_xJlTqU.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-BdLl6ZIw.js","assets/vendor-use-callback-ref-CXJF1lEr.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-DAdshx9l.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-CMO7G_Ff.js","assets/space-apply-CNISDYMA.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-KstI02a0.js","assets/useBranchPullRequestRequest-CLTracub.js","assets/parseDiffFromFile-Yp9eHLcj.js","assets/computeVirtualFileMetrics-CXGHe7T5.js","assets/themeResolver-4dbEkEN5.js","assets/vendor-pierre-theming-D_TRfu0q.js","assets/hastToHtml-BHV14OWE.js","assets/vendor-hast-util-to-html-Jw3IXh58.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-diff-C3JhlQdm.js","assets/isDiffPlainText-SBv5bM8c.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-CFyG2F44.js","assets/Virtualizer-BOHERqLh.js","assets/useInlineCommentController-ByiCLJwx.js","assets/appThemeRegistry-BBiQjAje.js","assets/textMateThemeFromAppTheme-CbTfkuJp.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/ChangedPathLabel-7Zbbq-FE.js","assets/useRootScrollLock-ClFa_ezf.js","assets/contextFileOpenGuard-Cp662aS-.js","assets/WalkthroughView-BnT4-pMh.js","assets/ChangeRequestDiffUnavailable-ED92kmXz.js","assets/useDiffFindSurface-BY6KBx38.js","assets/useWalkthroughReview-BjhHwuOR.js","assets/useCallableModelProviders-CcETbnHf.js","assets/useWholeFileComment-Dbr3Y7Ga.js","assets/DiffView-CQOHl1hv.js","assets/SubmoduleDiffSummary-B3CnCMwZ.js","assets/FilesView-D00Dnc8i.js","assets/flexokiTheme-Df4MxCkn.js","assets/vendor-codemirror-search-Bk6iB2TM.js","assets/vendor-replit-codemirror-vim-BpSlt2iY.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-DG5IJM9Y.js","assets/fileContentPoller-D0GhYhQ3.js","assets/JsonTreeView-Bw8E9Koo.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-QNmxHtqN.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-CJBps6zM.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-Mn2aZ7Rl.js","assets/GuestSurfacePane-OM2GGOiX.js","assets/SettingsWindow-CnjurTti.js","assets/SettingsView-D7mytSZv.js","assets/install-BjzS6Z-p.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/pageTitle-Cph9nb1O.js","assets/SpaceRow-BvJCw88e.js","assets/AboutLogo-BwyB9sbV.js","assets/CommandPalette-CLlDfj5e.js","assets/HelpDialog-DNqqtAW-.js","assets/ProjectActionsDialog-C3rXp1WV.js","assets/OpenCodeStatusDialog-BgseXyBy.js","assets/RunOverview-BqmEhK3a.js","assets/ScheduledTasksDialog-CXyiyIDe.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-C4F_nWqa.js","assets/ArchiveView-BsWIv-C4.js","assets/useWorktreeArchiveActions-jkcvj4mj.js","assets/IntegrationsCatalogView-C4-oLIEz.js","assets/UsageStatsView-CWV-BYPI.js","assets/SourceBoardView-BoMdMgmW.js","assets/OverviewView-CohMMobq.js","assets/WorktreesView-D_VUAXdo.js","assets/SpacesView-DNI1yLAG.js","assets/SpaceAccessDialog-q5blJXG5.js","assets/spaceNetwork-DUg5u0h8.js","assets/SpaceApplyDialog-Csq1Z7zY.js","assets/SpaceSetupOutput-Bzeasxqg.js","assets/OnboardingScreen-DZVhaQUC.js","assets/AboutDialog-BTYnMXM0.js","assets/MemoryDebugPanel-DzMnnl_P.js"])))=>i.map(i=>d[i]);
2
+ import{f as Be,j as s,R as l,r as Wt,a as Ul,h as ku}from"./vendor-react--VO_rL_p.js";import{bi as Jr,n as Yt,k as is,cr as ju,cs as Vl,u as X,bg as Us,aG as as,aR as Qr,c1 as us,ct as bi,aM as eo,cu as Cu,bT as Hl,cv as wt,cw as Tu,bd as Vo,l as wi,be as un,bf as Nr,bH as Nu,bj as ql,bb as yi,cx as Eu,cm as Gl,bO as ta,aP as Kl,cy as Pu,cz as mr,cA as Fr,cB as lr,cC as Iu,cD as tr,cE as Ru,cF as Ho,cG as yr,cH as vi,cI as to,cJ as Mn,aY as Lr,j as Vs,cK as Rn,cL as Du,cM as js,b as pn,cN as so,cO as Zl,cP as _u,cQ as Xs,cR as Au,cS as Xl,cT as Ou,cU as Mu,cV as Yl,cW as Fu,c3 as Lu,bS as $u,bY as Bu,bV as zu,bc as Wu,bn as xs,t as qo,bW as Uu,cX as Vu,cY as Hu,bu as Go,cZ as Si,c_ as qu,b9 as Gu,a_ as sa,cl as Jl,c$ as na,aI as Ql,d0 as Ku,v as ec,bX as Zu,d1 as ra,bA as ki,d2 as tc,bJ as Xu,aH as Yu,q as Ju,m as Qu,bh as sc,c9 as oa,ca as nc,cp as ef,c8 as tf,c5 as ia,d3 as sf,d4 as nf,bF as rf,bD as of,d5 as af,bK as lf,c7 as cf,d6 as df,d7 as uf,d8 as ff,d9 as aa,da as jo,db as la,dc as ca,dd as pf,bl as da,de as mf,df as hf,bm as ua,dg as gf,bE as xf,i as bf,a as wf}from"./katex.min-BCtkGOiC.js";import{_ as At}from"./vendor-vite-runtime-DD1OZmLC.js";import{bL as yf,bM as rc,aO as oc,bN as ds,r as fa,bO as vf,bP as Sf,bQ as pa,bR as ma,bS as ha,aV as kf,bT as jf,aQ as Cf,bU as ga,aR as xa,a0 as ic,a2 as ac,a4 as lc,a1 as cc,$ as ji,a6 as dc,a5 as uc,a3 as fc,aB as Tf,aC as Nf,aw as Ef,aI as Pf,aJ as If,ak as Rf,aE as Df,aD as _f,N as Af,z as Of,V as Mf,a8 as Ff,_ as Lf,a7 as $f,w as Bf,C as pc,m as zf,bV as fn,bp as Wf,bW as mc,bX as Er,bY as hc,bZ as Uf,b_ as gc,b$ as kn,c0 as ba,c1 as wa,c2 as Co,c3 as ya,aG as Pr,bm as Vf,bn as Hf,aM as qf,bH as Gf,bI as xc,c4 as Kf,bo as Zf,c5 as Xf,c6 as Yf,bg as Jf,c7 as va,c8 as To,c9 as rn,ca as jn,cb as Qf,cc as Sa,cd as ep,ce as tp,cf as sp,cg as np,ch as rp,ci as op,cj as ip,ck as ka,cl as ap,cm as lp,bq as cp,bf as dp,bG as up,br as fp,bJ as pp,cn as mp,bC as hp,bD as gp,aP as bc,co as xp,cp as bp,cq as wp,cr as yp,cs as vp,bF as Sp,ct as kp,by as jp,cu as Cp,cv as Tp,bv as Np,bt as Ep,bu as Pp,bs as Ip,bw as Rp,bK as Dp,bB as _p,bA as Ap,bE as Op,cw as Mp,cx as Fp}from"./runtimeEndpointReset-CMO7G_Ff.js";import{fE as ja,aL as no,Y as Gt,$ as tt,c9 as hr,Q as $e,fg as Lp,ca as $p,I as se,fh as Bp,u as at,jF as on,X as ts,jG as zp,av as ws,ay as Es,aw as Ci,jH as wc,b5 as gn,fD as yc,fC as Wp,bn as Up,jI as vc,jJ as Vp,jK as Hp,bb as gr,ab as Ft,aa as Lt,ac as $t,ir as Hs,cd as Sc,jL as qp,jM as Gp,a1 as Kp,l as Fn,F as Ln,D as $n,af as Zp,bl as kc,n as fs,q as Bn,t as zn,b2 as Xp,A as _e,ci as jc,iZ as Yp,jN as Cc,bt as Jp,jO as Qp,jP as em,iH as Tc,jQ as tm,aJ as Gs,ed as sm,au as nm,be as Ns,b0 as ro,bc as oo,it as Dn,bd as io,jR as rm,jS as ao,jT as om,iE as Pn,aK as yn,jU as im,iF as am,eh as Nc,jV as lm,gT as xr,gU as lo,c5 as $r,ei as cm,jW as dm,jX as um,jY as fm,jZ as pm,j_ as mm,j$ as hm,k0 as gm,k1 as Ti,bJ as Ni,em as xm,o as Br,B as ft,k2 as Wn,a2 as xn,a3 as bn,a4 as wn,a5 as qt,ad as mn,k3 as Ec,k4 as Ei,aY as Qt,k5 as Pc,k6 as bm,cn as Ic,k7 as wm,k8 as ym,bB as Is,k9 as vm,bO as hn,ka as Ca,bG as Ir,kb as Sm,dI as km,bW as Pi,kc as jm,kd as Rc,ke as Ii,dw as Cm,db as zr,dC as Dc,dq as Ri,dr as Di,kf as _c,y as Un,C as Ko,gR as Tm,gw as Nm,h6 as Em,kg as Pm,ga as Ac,bD as Ws,K as _i,by as Im,aq as vs,bC as Oc,bQ as Ta,bP as Jn,gb as Rm,bR as Dm,c1 as Ai,bY as _m,gd as No,kh as Am,z as Om,bo as Mm,bp as Fm,bq as Lm,br as $m,bs as Bm,cM as Na,bH as Mc,bF as Wr,ki as zm,kj as Wm,kk as Um,dl as qn,bx as Vm,bz as co,bA as Hm,bE as qm,aI as Vn,g_ as Gm,gg as Km,bX as Oi,kl as Fc,km as Lc,kn as Zm,dh as Xm,df as Ea,ko as Ym,hf as Jm,dn as Qm,kp as eh,ds as th,kq as sh,kr as nh,dg as Pa,dB as rh,dj as oh,aZ as ih,ks as ah,kt as lh,ku as ch,kv as Mi,kw as Fi,kx as dh,ky as uh,kz as fh,kA as ph,kB as mh,jo as Li,kC as hh,kD as gh,kE as xh,kF as bh,kG as $i,kH as wh,kI as yh,kJ as vh,kK as $c,bm as Sh,kL as kh,x as Bc,kM as jh,kN as En,ao as Ch,kO as Th,V as zt,kP as Nh,cZ as Eh,cA as Ph,kQ as zc,kR as Ih,kS as Rr,kT as Cn,ie as Rh,cP as Dh,kU as _h,kV as Wc,j5 as Uc,e8 as uo,dv as Ah,d2 as Oh,kW as Bi,kX as Mh,eF as Js,kY as Vc,bf as Fh,kZ as Lh,k_ as $h,k$ as Bh,l0 as Eo,l1 as zh,l2 as Wh,dS as Uh,e9 as Vh,fz as zi,fw as Hh,is as qh,iu as Gh,l3 as cr,fv as Hc,fu as qc,iv as Kh,iw as Zh,fx as Xh,dW as Yh,aX as Jh,aM as Qh,l4 as Po,l5 as eg,l6 as tg,l7 as Gc,l8 as Kc,l9 as sg,la as ng,lb as Zo,lc as Zs,dc as rg,ld as og,le as Ia,lf as ig,lg as ag,ba as Ur,lh as Ra,li as lg,lj as cg,lk as dg,iL as ug,ll as fg,iM as Da,iN as pg,cU as mg,cf as _a,iO as hg,iP as gg,lm as xg,iQ as bg,ln as wg,k as yg,lo as Io,lp as Aa,f5 as vg,fJ as Xo,lq as Zc,hO as fo,lr as Sg,i7 as kg,ls as jg,lt as Xc,lu as Cg,lv as Yc,dV as Tg,dU as Wi,dT as Ui,dZ as Ng,lw as Oa,lx as Eg,ly as Pg,dX as Ig,lz as Yo,G as Jc,bU as Qc,lA as Rg,a0 as Dg,e$ as Ma,lB as _g,lC as ed,b6 as Fa,d_ as Ag,iB as Og,lD as Mg,iC as Fg,lE as Lg,lF as $g,jE as Bg,c_ as La,lG as zg,iG as Wg,lH as Ug,jp as Vg,er as Hg,lI as qg,e6 as Gg,es as Kg,eu as Zg,et as Xg,eC as Yg,eB as Jg,ev as Qg,jq as e1,eA as t1,ew as s1,ex as n1,ey as r1,ez as o1,eH as i1,a as a1,s as l1,b as c1,c as d1,jx as u1,ah as f1,eK as p1,eL as m1,eM as h1}from"./useAppFontEffects-C_TEX3sk.js";import{f as td,u as sd,S as g1,W as nd,a as x1,G as b1,b as w1,c as y1}from"./useRootScrollLock-ClFa_ezf.js";import{h as rd,i as Vr,T as od,M as id,D as ad,f as Jo}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as v1,h as S1,u as ld,S as cd,v as k1,a as j1}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as dd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{S as C1,M as T1,C as N1,i as E1,j as P1,k as I1}from"./vendor-base-ui-zhBy6TEG.js";import{a as an,O as R1,d as D1,D as _1,b as A1,v as $a,t as Ba,u as O1,m as za}from"./contextFileOpenGuard-Cp662aS-.js";import{u as Qo,c as po,p as M1}from"./vendor-zustand-C9tWdk0j.js";import{o as Qs,s as Ps,n as mo,d as ud,f as F1,e as dr,a as ei}from"./vendor-zod-Csf1sqWl.js";import{u as L1}from"./vendor-tanstack-react-virtual-C_IilPt1.js";import{d as $1,m as B1}from"./vendor-tanstack-virtual-core-DsQgKrou.js";const fd=t=>`${t}|chats`,z1=(t,e)=>{if(Jr(e))return fd(t);const n=Yt(e);return n?`${t}|${n}`:null},W1=(t,e,n)=>{const r=Yt(t);return!r||Jr(r)?[]:n.some(o=>Yt(o)===r)?[]:e.filter(o=>!o.parentID&&!o.time?.archived&&Yt(o.directory??null)===r).sort((o,i)=>ja(i)-ja(o)).map(o=>o.id)};function U1(t){const e=Be.c(37),{directory:n,className:r}=t,{currentTheme:o}=no(),i=Gt(q1),a=tt(H1),u=is(V1),c=ju(n);let d;e[0]!==n||e[1]!==u?(d=Vl(n,u),e[0]=n,e[1]=u,e[2]=d):d=e[2];const f=d;let p;e[3]!==n||e[4]!==f||e[5]!==i||e[6]!==c||e[7]!==a?(p=f||!n?null:hr(i,a,n,c),e[3]=n,e[4]=f,e[5]=i,e[6]=c,e[7]=a,e[8]=p):p=e[8];const m=p;if(f){let P;e[9]!==r?(P=$e("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=P):P=e[10];let k;return e[11]!==P?(k=s.jsx(se,{name:"chat-4",className:P}),e[11]=P,e[12]=k):k=e[12],k}if(!m)return null;const h=m.icon?Lp[m.icon]:null;let x;e[13]!==m.color?(x=$p(m.color)??void 0,e[13]=m.color,e[14]=x):x=e[14];const g=x;let b;e[15]!==r||e[16]!==g||e[17]!==h?(b=h?s.jsx(se,{name:h,className:$e("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):s.jsx(se,{name:"folder",className:$e("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),style:g?{color:g}:void 0}),e[15]=r,e[16]=g,e[17]=h,e[18]=b):b=e[18];const w=b;if(!m.iconImage)return w;let S;e[19]!==r?(S=$e("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=S):S=e[20];let y;e[21]!==m.iconBackground?(y=m.iconBackground?{backgroundColor:m.iconBackground}:void 0,e[21]=m.iconBackground,e[22]=y):y=e[22];let I;e[23]!==m.iconImage||e[24]!==m.id?(I={id:m.id,iconImage:m.iconImage},e[23]=m.iconImage,e[24]=m.id,e[25]=I):I=e[25];let j;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(j={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=j):j=e[28];let R;e[29]!==w||e[30]!==I||e[31]!==j?(R=s.jsx(Bp,{project:I,options:j,className:"h-full w-full object-contain",fallback:w}),e[29]=w,e[30]=I,e[31]=j,e[32]=R):R=e[32];let _;return e[33]!==S||e[34]!==y||e[35]!==R?(_=s.jsx("span",{className:S,style:y,children:R}),e[33]=S,e[34]=y,e[35]=R,e[36]=_):_=e[36],_}function V1(t){return t.homeDirectory}function H1(t){return t.availableWorktreesByProject}function q1(t){return t.projects}const Qn=24,G1=(t,e,n=Qn)=>{const r=e.right-(t.right-n);if(r>0)return r;const o=e.left-(t.left+n);return o<0?o:0},K1=({transform:t})=>({...t,y:0}),Z1=16,X1=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*Z1:t.deltaY;t.currentTarget.scrollLeft+=Qr(t.currentTarget)?-e:e},Y1={Item:({className:t,...e})=>s.jsx(T1,{className:$e(Hp,t),...e}),Separator:({className:t,...e})=>s.jsx(C1,{className:$e(Vp,t),...e})},J1=t=>{const e=Be.c(127),{tab:n,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:u,onPin:c,onClose:d,renderMenu:f,closeOtherTabs:p,onMenuOpenChangeComplete:m,children:h}=t,{t:x}=at(),g=X(ex);let b;e[0]!==g?(b=Ci("switch_session_tab",g),e[0]=g,e[1]=b):b=e[1];const w=b;let S;e[2]!==r||e[3]!==w?(S=w&&w!==wc&&r<=9?ws(`${w}+${r}`):void 0,e[2]=r,e[3]=w,e[4]=S):S=e[4];const y=S,[I,j]=l.useState(!1);let R;e[5]!==n.id?(R={id:n.id},e[5]=n.id,e[6]=R):R=e[6];const{attributes:_,listeners:P,setNodeRef:k,transform:N,transition:T,isDragging:A}=ld(R);let $;e[7]!==x||e[8]!==n.session.title?($=n.session.title?.trim()||x("sessions.sidebar.session.untitled"),e[7]=x,e[8]=n.session.title,e[9]=$):$=e[9];const K=$,q=n.id;let M;e[10]!==n.session?(M=gn(n.session),e[10]=n.session,e[11]=M):M=e[11];const z=rc(q,M),ne=yc(n.id),H=ne!==null,F=Wp(n.id)&&!o&&!H,C=H||F;let te;e[12]!==u||e[13]!==n?(te=()=>u(n),e[12]=u,e[13]=n,e[14]=te):te=e[14];let re;e[15]!==p||e[16]!==n.id?(re=()=>p(n.id),e[15]=p,e[16]=n.id,e[17]=re):re=e[17];let Q,ee,le,O,Y,Z,we,L,pe,je,Ee,Se,Le,Pe,Ve,Oe,be,ye,Ue,Te;if(e[18]!==_||e[19]!==h||e[20]!==I||e[21]!==o||e[22]!==z||e[23]!==A||e[24]!==i||e[25]!==P||e[26]!==d||e[27]!==m||e[28]!==c||e[29]!==u||e[30]!==f||e[31]!==k||e[32]!==g||e[33]!==C||e[34]!==a||e[35]!==x||e[36]!==te||e[37]!==re||e[38]!==n||e[39]!==y||e[40]!==K||e[41]!==N||e[42]!==T||e[43]!==ne){const G={session:n.session,open:I,isActive:o,select:te,closeOtherTabs:re,components:Y1};Le=k;let Ce;e[64]!==N?(Ce=dd.Translate.toString(N),e[64]=N,e[65]=Ce):Ce=e[65],e[66]!==Ce||e[67]!==T?(Pe={transform:Ce,transition:T},e[66]=Ce,e[67]=T,e[68]=Pe):Pe=e[68];const J=A&&"z-10 opacity-60";e[69]!==J?(Ve=$e("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",J),e[69]=J,e[70]=Ve):Ve=e[70],Oe=o?"true":"false",e[71]!==o?(be=o?{"data-active-session-tab":!0}:{},e[71]=o,e[72]=be):be=e[72],ye=_,Ue=P,O=gr,pe=I,je=j,e[73]!==m?(Ee=Ie=>m?.(Ie),e[73]=m,e[74]=Ee):Ee=e[74];let Ne;e[75]!==h||e[76]!==o||e[77]!==z||e[78]!==i||e[79]!==d||e[80]!==c||e[81]!==u||e[82]!==g||e[83]!==C||e[84]!==a||e[85]!==x||e[86]!==n||e[87]!==K||e[88]!==ne?(Ne=s.jsx(Ft,{asChild:!0,children:s.jsx(N1,{render:Ie=>s.jsx("div",{...Ie,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:o?void 0:()=>u(n),onDoubleClick:i?()=>c(n.id):void 0,onKeyDown:o?void 0:De=>{(De.key==="Enter"||De.key===" ")&&(De.preventDefault(),u(n))},onAuxClick:De=>{De.button===1&&(De.preventDefault(),d(n.id))},className:$e("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",o?"bg-interactive-selection text-interactive-selection-foreground":"cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx(U1,{directory:gn(n.session),className:$e(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":x("header.sessionTabs.closeTab"),onClick:De=>{De.stopPropagation(),d(n.id)},onPointerDown:tx,className:"absolute inset-0 flex items-center justify-center rounded text-muted-foreground opacity-0 hover:text-foreground focus-visible:opacity-100 group-hover/session-tab:opacity-100",children:s.jsx(se,{name:"close",className:"size-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:x("header.sessionTabs.closeTab"),shortcut:o?ws(Us()?"mod+w":Es("close_session_tab",g),""):void 0})})]})]}),s.jsx("div",{className:$e("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:K})})}),z?s.jsx(se,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":x("sessions.aiRename.generating")}):C?s.jsx(Sc,{state:ne??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[75]=h,e[76]=o,e[77]=z,e[78]=i,e[79]=d,e[80]=c,e[81]=u,e[82]=g,e[83]=C,e[84]=a,e[85]=x,e[86]=n,e[87]=K,e[88]=ne,e[89]=Ne):Ne=e[89];let Ae;e[90]!==y||e[91]!==K?(Ae=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:K,shortcut:y})}),e[90]=y,e[91]=K,e[92]=Ae):Ae=e[92],e[93]!==Ne||e[94]!==Ae?(Se=s.jsxs(Lt,{children:[Ne,Ae]}),e[93]=Ne,e[94]=Ae,e[95]=Se):Se=e[95],le=E1,ee=P1,L="app-region-no-drag z-50",Q=I1,Te="dropdown-menu-content",e[96]===Symbol.for("react.memo_cache_sentinel")?(Y={color:"var(--surface-elevated-foreground)"},Z=$e(Up,"min-w-[190px]"),e[96]=Y,e[97]=Z):(Y=e[96],Z=e[97]),we=f(G),e[18]=_,e[19]=h,e[20]=I,e[21]=o,e[22]=z,e[23]=A,e[24]=i,e[25]=P,e[26]=d,e[27]=m,e[28]=c,e[29]=u,e[30]=f,e[31]=k,e[32]=g,e[33]=C,e[34]=a,e[35]=x,e[36]=te,e[37]=re,e[38]=n,e[39]=y,e[40]=K,e[41]=N,e[42]=T,e[43]=ne,e[44]=Q,e[45]=ee,e[46]=le,e[47]=O,e[48]=Y,e[49]=Z,e[50]=we,e[51]=L,e[52]=pe,e[53]=je,e[54]=Ee,e[55]=Se,e[56]=Le,e[57]=Pe,e[58]=Ve,e[59]=Oe,e[60]=be,e[61]=ye,e[62]=Ue,e[63]=Te}else Q=e[44],ee=e[45],le=e[46],O=e[47],Y=e[48],Z=e[49],we=e[50],L=e[51],pe=e[52],je=e[53],Ee=e[54],Se=e[55],Le=e[56],Pe=e[57],Ve=e[58],Oe=e[59],be=e[60],ye=e[61],Ue=e[62],Te=e[63];let Me;e[98]!==Q||e[99]!==Y||e[100]!==Z||e[101]!==we||e[102]!==Te?(Me=s.jsx(Q,{"data-slot":Te,style:Y,className:Z,children:we}),e[98]=Q,e[99]=Y,e[100]=Z,e[101]=we,e[102]=Te,e[103]=Me):Me=e[103];let Re;e[104]!==ee||e[105]!==L||e[106]!==Me?(Re=s.jsx(ee,{className:L,children:Me}),e[104]=ee,e[105]=L,e[106]=Me,e[107]=Re):Re=e[107];let ze;e[108]!==le||e[109]!==Re?(ze=s.jsx(le,{children:Re}),e[108]=le,e[109]=Re,e[110]=ze):ze=e[110];let B;e[111]!==O||e[112]!==pe||e[113]!==je||e[114]!==Ee||e[115]!==Se||e[116]!==ze?(B=s.jsxs(O,{open:pe,onOpenChange:je,onOpenChangeComplete:Ee,children:[Se,ze]}),e[111]=O,e[112]=pe,e[113]=je,e[114]=Ee,e[115]=Se,e[116]=ze,e[117]=B):B=e[117];let ce;return e[118]!==Le||e[119]!==Pe||e[120]!==Ve||e[121]!==Oe||e[122]!==be||e[123]!==ye||e[124]!==Ue||e[125]!==B?(ce=s.jsx("div",{ref:Le,style:Pe,className:Ve,"data-active":Oe,...be,...ye,...Ue,children:B}),e[118]=Le,e[119]=Pe,e[120]=Ve,e[121]=Oe,e[122]=be,e[123]=ye,e[124]=Ue,e[125]=B,e[126]=ce):ce=e[126],ce},Q1=t=>{const e=Be.c(109),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:u,direction:c}=at(),d=c==="rtl",f=on(sx),p=on(nx),m=on(rx),h=on(ox),x=on(ix),g=on(ax),b=tt(lx),w=tt(cx),S=ts(dx),y=X(ux),I=on(fx),j=ts(px),R=tt(mx),_=tt(hx),P=tt(gx),k=tt(xx),N=tt(bx),T=tt(wx);let A;e[0]!==T?(A=W=>{const me=T??W.activeProjectId;return W.projects.find(he=>he.id===me)?.path??null},e[0]=T,e[1]=A):A=e[1];const $=Gt(A),K=yf(b);let q,M;e[2]!==K||e[3]!==R||e[4]!==b||e[5]!==N||e[6]!==k||e[7]!==_||e[8]!==$||e[9]!==m||e[10]!==I||e[11]!==y||e[12]!==j?(q=()=>{if(!y)I(qp,yx);else{if(!j)return;const W=as(),me=!b&&_&&k,he=b?R:_&&!k?N??$:null,Je=me?fd(W):z1(W,he);if(!Je)return;I(Je,()=>W1(he,ts.getState().activeSessions,Gt.getState().projects.map(vx)))}b&&m(b,K)},M=[K,R,b,N,k,_,$,m,I,y,j],e[2]=K,e[3]=R,e[4]=b,e[5]=N,e[6]=k,e[7]=_,e[8]=$,e[9]=m,e[10]=I,e[11]=y,e[12]=j,e[13]=q,e[14]=M):(q=e[13],M=e[14]),l.useEffect(q,M);let z;if(e[15]!==S){z=new Map;for(const W of S)z.set(W.id,W);e[15]=S,e[16]=z}else z=e[16];const ne=z;let H;if(e[17]!==ne||e[18]!==f){H=[];for(const W of f){const me=ne.get(W);me&&H.push({id:W,session:me})}e[17]=ne,e[18]=f,e[19]=H}else H=e[19];const V=H;let F;e[20]!==w?(F=W=>{w(W.id,gn(W.session))},e[20]=w,e[21]=F):F=e[21];const C=F,te=Sx,re=!b&&_;let Q;e[22]!==re||e[23]!==P?(Q=W=>!re||!P?"":(W.drafts.find(he=>he.id===P)?.text??"").split(/\r?\n/).find(kx)?.trim()??"",e[22]=re,e[23]=P,e[24]=Q):Q=e[24];const ee=zp(Q),le=X(jx),O=Cx;let Y;e[25]!==b||e[26]!==re||e[27]!==V?(Y=V.some(W=>W.id===b)||re&&V.length>0,e[25]=b,e[26]=re,e[27]=V,e[28]=Y):Y=e[28];const Z=Y;let we,L;e[29]!==Z?(we=()=>{if(Z)return oc(Tx,{current:document.body})},L=[Z],e[29]=Z,e[30]=we,e[31]=L):(we=e[30],L=e[31]),l.useEffect(we,L);let pe;e[32]!==x||e[33]!==b||e[34]!==C||e[35]!==V?(pe=W=>{if(x(W),b&&b!==W){const me=V.find(he=>he.id===W);me&&C(me)}},e[32]=x,e[33]=b,e[34]=C,e[35]=V,e[36]=pe):pe=e[36];const je=pe;let Ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(Ee={activationConstraint:{distance:8}},e[37]=Ee):Ee=e[37];let Se;e[38]===Symbol.for("react.memo_cache_sentinel")?(Se={activationConstraint:{delay:200,tolerance:6}},e[38]=Se):Se=e[38];const Le=rd(Vr(id,Ee),Vr(od,Se));let Pe;e[39]!==g?(Pe=W=>{const{active:me,over:he}=W;he&&me.id!==he.id&&g(String(me.id),String(he.id))},e[39]=g,e[40]=Pe):Pe=e[40];const Ve=Pe,Oe=l.useRef(null);let be;e[41]===Symbol.for("react.memo_cache_sentinel")?(be={left:!1,right:!1},e[41]=be):be=e[41];const[ye,Ue]=l.useState(be);let Te;e[42]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>{const W=Oe.current;if(!W)return;const me=W.scrollWidth-W.clientWidth,he=Qr(W)?me+W.scrollLeft:W.scrollLeft,Je=he>2,Fe=he<me-2;Ue(fe=>fe.left===Je&&fe.right===Fe?fe:{left:Je,right:Fe})},e[42]=Te):Te=e[42];const Me=Te;let Re;e[43]===Symbol.for("react.memo_cache_sentinel")?(Re=()=>{Me();const W=Oe.current;if(!W||!globalThis.ResizeObserver)return;const me=new ResizeObserver(Me);return me.observe(W),()=>me.disconnect()},e[43]=Re):Re=e[43];let ze;e[44]!==V.length?(ze=[Me,V.length],e[44]=V.length,e[45]=ze):ze=e[45],l.useEffect(Re,ze);let B;e[46]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{const W=Oe.current,me=W?.querySelector("[data-active-session-tab]");if(!W||!me)return;const he=G1(W.getBoundingClientRect(),me.getBoundingClientRect());he!==0&&(W.scrollLeft=W.scrollLeft+he,Me())},e[46]=B):B=e[46];let ce;e[47]!==b?(ce=[b,Me],e[47]=b,e[48]=ce):ce=e[48],l.useEffect(B,ce);const G=ye.left&&ye.right?`linear-gradient(to right, transparent, black ${Qn}px, black calc(100% - ${Qn}px), transparent)`:ye.left?`linear-gradient(to right, transparent, black ${Qn}px)`:ye.right?`linear-gradient(to right, black calc(100% - ${Qn}px), transparent)`:void 0;let Ce;e[49]!==V?(Ce=V.map(Nx),e[49]=V,e[50]=Ce):Ce=e[50];const J=Ce;let Ne;e[51]!==b||e[52]!==V?(Ne=!!b&&!V.some(W=>W.id===b),e[51]=b,e[52]=V,e[53]=Ne):Ne=e[53];const Ae=Ne;let Ie;e[54]!==u?(Ie=u("header.sessionTabs.stripAria"),e[54]=u,e[55]=Ie):Ie=e[55];let De;e[56]!==G?(De=G?{maskImage:G,WebkitMaskImage:G}:void 0,e[56]=G,e[57]=De):De=e[57];let We;e[58]===Symbol.for("react.memo_cache_sentinel")?(We=[K1],e[58]=We):We=e[58];const Ke=d?v1:S1;let Ze;e[59]!==i||e[60]!==b||e[61]!==je||e[62]!==C||e[63]!==r||e[64]!==h||e[65]!==p||e[66]!==n||e[67]!==a||e[68]!==V?(Ze=V.map((W,me)=>s.jsx(J1,{tabNumber:me+1,tab:W,isActive:W.id===b,isPreview:W.id===p,suppressControls:W.id===b&&a,onSelect:C,onPin:h,onClose:te,renderMenu:n,closeOtherTabs:je,onMenuOpenChangeComplete:r,children:W.id===b?i:null},W.id)),e[59]=i,e[60]=b,e[61]=je,e[62]=C,e[63]=r,e[64]=h,e[65]=p,e[66]=n,e[67]=a,e[68]=V,e[69]=Ze):Ze=e[69];let Qe;e[70]!==Ke||e[71]!==Ze||e[72]!==J?(Qe=s.jsx(cd,{items:J,strategy:Ke,children:Ze}),e[70]=Ke,e[71]=Ze,e[72]=J,e[73]=Qe):Qe=e[73];let qe;e[74]!==Ve||e[75]!==Le||e[76]!==Qe?(qe=s.jsx(ad,{sensors:Le,collisionDetection:Jo,modifiers:We,onDragEnd:Ve,children:Qe}),e[74]=Ve,e[75]=Le,e[76]=Qe,e[77]=qe):qe=e[77];let et;e[78]!==ee||e[79]!==re||e[80]!==u?(et=re?s.jsxs("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2 text-interactive-selection-foreground","data-active":"true","data-active-session-tab":!0,children:[s.jsx(se,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),s.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:ee||u("sessions.switcher.draftTitle")})})]}):null,e[78]=ee,e[79]=re,e[80]=u,e[81]=et):et=e[81];let He;e[82]!==i||e[83]!==Ae?(He=Ae?s.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag 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:i})}):null,e[82]=i,e[83]=Ae,e[84]=He):He=e[84];let Ye;e[85]!==De||e[86]!==qe||e[87]!==et||e[88]!==He?(Ye=s.jsxs("div",{ref:Oe,onScroll:Me,onWheel:X1,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:De,children:[qe,et,He]}),e[85]=De,e[86]=qe,e[87]=et,e[88]=He,e[89]=Ye):Ye=e[89];let dt;e[90]!==u?(dt=u("sessions.sidebar.header.actions.newSession"),e[90]=u,e[91]=dt):dt=e[91];let nt;e[92]===Symbol.for("react.memo_cache_sentinel")?(nt=s.jsx(se,{name:"add",className:"size-4"}),e[92]=nt):nt=e[92];let ut;e[93]!==dt?(ut=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:O,"aria-label":dt,className:"app-region-no-drag ms-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:nt})}),e[93]=dt,e[94]=ut):ut=e[94];let oe;e[95]!==u?(oe=u("sessions.sidebar.header.actions.newSession"),e[95]=u,e[96]=oe):oe=e[96];let de;e[97]!==le?(de=ws(Es("new_chat",le),""),e[97]=le,e[98]=de):de=e[98];let ve;e[99]!==oe||e[100]!==de?(ve=s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:oe,shortcut:de})}),e[99]=oe,e[100]=de,e[101]=ve):ve=e[101];let v;e[102]!==ut||e[103]!==ve?(v=s.jsxs(Lt,{children:[ut,ve]}),e[102]=ut,e[103]=ve,e[104]=v):v=e[104];let ae;return e[105]!==Ie||e[106]!==Ye||e[107]!==v?(ae=s.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ie,children:[Ye,v]}),e[105]=Ie,e[106]=Ye,e[107]=v,e[108]=ae):ae=e[108],ae};function ex(t){return t.shortcutOverrides}function tx(t){return t.stopPropagation()}function sx(t){return t.tabIds}function nx(t){return t.previewTabId}function rx(t){return t.ensureTab}function ox(t){return t.pinTab}function ix(t){return t.closeOtherTabs}function ax(t){return t.reorderTabs}function lx(t){return t.currentSessionId}function cx(t){return t.setCurrentSession}function dx(t){return t.activeSessions}function ux(t){return t.sessionTabsPerWorkspace}function fx(t){return t.enterScope}function px(t){return t.hasLoaded}function mx(t){return t.currentSessionDirectory}function hx(t){return t.newSessionDraft.open}function gx(t){return t.newSessionDraft.workDraftId??null}function xx(t){return t.newSessionDraft.target==="chat"}function bx(t){return t.newSessionDraft.directoryOverride}function wx(t){return t.newSessionDraft.selectedProjectId??null}function yx(){return[]}function vx(t){return t.path}function Sx(t){vc(t)}function kx(t){return t.trim()}function jx(t){return t.shortcutOverrides}function Cx(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:n}=tt.getState(),r=t?is.getState().currentDirectory:e.directoryOverride;n(r?{directoryOverride:r}:void 0)}function Tx(){const t=tt.getState().currentSessionId;t?vc(t):Gp(-1)}function Nx(t){return t.id}const Ex=t=>{const e=Be.c(29),{open:n,onOpenChange:r,onPick:o}=t,{t:i}=at(),a=Kp(Gt(Px),n),u=is(Ix);let c;e[0]!==i?(c=i("sessions.moveChatToProject.title"),e[0]=i,e[1]=c):c=e[1];let d;e[2]!==c?(d=s.jsx(Fn,{children:c}),e[2]=c,e[3]=d):d=e[3];let f;e[4]!==i?(f=i("sessions.moveChatToProject.description"),e[4]=i,e[5]=f):f=e[5];let p;e[6]!==f?(p=s.jsx(Ln,{children:f}),e[6]=f,e[7]=p):p=e[7];let m;e[8]!==d||e[9]!==p?(m=s.jsxs($n,{children:[d,p]}),e[8]=d,e[9]=p,e[10]=m):m=e[10];let h;if(e[11]!==u||e[12]!==r||e[13]!==o||e[14]!==a){let w;e[16]!==u||e[17]!==r||e[18]!==o?(w=S=>s.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] focus-visible:outline-none",onClick:()=>{r(!1),o(S.path)},children:[s.jsx(se,{name:"folder",className:"size-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:S.label?.trim()||Zp(S.path)}),s.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:kc(S.path,u)})]},S.id),e[16]=u,e[17]=r,e[18]=o,e[19]=w):w=e[19],h=a.map(w),e[11]=u,e[12]=r,e[13]=o,e[14]=a,e[15]=h}else h=e[15];let x;e[20]!==h?(x=s.jsx(fs,{outerClassName:"max-h-[50vh]",className:"flex flex-col gap-0.5",disableHorizontal:!0,children:h}),e[20]=h,e[21]=x):x=e[21];let g;e[22]!==m||e[23]!==x?(g=s.jsxs(Bn,{className:"max-w-md",children:[m,x]}),e[22]=m,e[23]=x,e[24]=g):g=e[24];let b;return e[25]!==r||e[26]!==n||e[27]!==g?(b=s.jsx(zn,{open:n,onOpenChange:r,children:g}),e[25]=r,e[26]=n,e[27]=g,e[28]=b):b=e[28],b};function Px(t){return t.projects}function Ix(t){return t.homeDirectory}function Wa(t){const e=Be.c(37),{sessionId:n,onArchive:r,Item:o}=t,{t:i}=at(),a=X(Dx);let u;e[0]!==n?(u=A=>A.currentSessionId===n,e[0]=n,e[1]=u):u=e[1];const c=tt(u);let d;e[2]!==a?(d=ws(Es("archive_current_session",a),""),e[2]=a,e[3]=d):d=e[3];const f=d;let p;e[4]!==n?(p=A=>!!A.entityById.get(n)?.time.archived,e[4]=n,e[5]=p):p=e[5];const m=ts(p);let h;e[6]!==n?(h=A=>{const $=A.entityById.get(n);return!$||Xp($,A.entityById)},e[6]=n,e[7]=h):h=e[7];const x=ts(h),g=tt(Rx);let b;e[8]!==n||e[9]!==i||e[10]!==g?(b=async()=>{await g(n)?_e.success(i("sessions.sidebar.session.restore.success")):_e.error(i("sessions.sidebar.session.restore.error"))},e[8]=n,e[9]=i,e[10]=g,e[11]=b):b=e[11];const w=b;if(m&&!x)return null;const S=m?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let y;e[12]!==i||e[13]!==S?(y=i(S),e[12]=i,e[13]=S,e[14]=y):y=e[14];let I;e[15]!==m||e[16]!==r||e[17]!==w?(I=m?()=>{w()}:r,e[15]=m,e[16]=r,e[17]=w,e[18]=I):I=e[18];const j=m?"inbox-unarchive":"inbox-archive";let R;e[19]!==j?(R=s.jsx(se,{name:j,className:"me-1 size-4"}),e[19]=j,e[20]=R):R=e[20];const _=m?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let P;e[21]!==i||e[22]!==_?(P=i(_),e[21]=i,e[22]=_,e[23]=P):P=e[23];let k;e[24]!==f||e[25]!==m||e[26]!==c?(k=!m&&c&&f?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:f}):null,e[24]=f,e[25]=m,e[26]=c,e[27]=k):k=e[27];let N;e[28]!==o||e[29]!==R||e[30]!==P||e[31]!==k||e[32]!==I?(N=s.jsxs(o,{onClick:I,children:[R,P,k]}),e[28]=o,e[29]=R,e[30]=P,e[31]=k,e[32]=I,e[33]=N):N=e[33];let T;return e[34]!==N||e[35]!==y?(T=s.jsx(ds,{hint:y,children:N}),e[34]=N,e[35]=y,e[36]=T):T=e[36],T}function Rx(t){return t.unarchiveSession}function Dx(t){return t.shortcutOverrides}function _x(t){const e=Be.c(17),{session:n,Item:r}=t,{t:o}=at();if(!X(Ax)||n.parentID||!jc(n))return null;let a;e[0]!==n||e[1]!==o?(a=async()=>{try{await Yp(n.id,gn(n),"done"),Cc([n.id])}catch{_e.error(o("sessions.sidebar.session.work.updateFailed"))}},e[0]=n,e[1]=o,e[2]=a):a=e[2];const u=a;let c;e[3]!==o?(c=o("sessions.sidebar.session.menuHint.markDone"),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==u?(d=()=>{u()},e[5]=u,e[6]=d):d=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(se,{name:"check",className:"me-1 size-4"}),e[7]=f):f=e[7];let p;e[8]!==o?(p=o("sessions.sidebar.session.work.markDone"),e[8]=o,e[9]=p):p=e[9];let m;e[10]!==r||e[11]!==d||e[12]!==p?(m=s.jsxs(r,{onClick:d,children:[f,p]}),e[10]=r,e[11]=d,e[12]=p,e[13]=m):m=e[13];let h;return e[14]!==c||e[15]!==m?(h=s.jsx(ds,{hint:c,children:m}),e[14]=c,e[15]=m,e[16]=h):h=e[16],h}function Ax(t){return t.sessionWorkEnabled}const Ox=t=>{const e=Tc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},Mx=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,pd=()=>{const t=Be.c(4),e=tt(Fx),n=tt(Lx)??void 0,r=Jp(e??"",n,Ox,Mx),{context:o}=Qp(e,n),i=o>0?o:em;let a;return t[0]!==r||t[1]!==i||t[2]!==e?(a={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=a):a=t[3],a};function Fx(t){return t.currentSessionId}function Lx(t){return t.currentSessionDirectory}const Ua=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Ls=18,ti=2,si=(Ls-ti)/2,Va=2*Math.PI*si,$x=t=>{const e=Be.c(9),{percent:n,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,n));let u;e[0]!==o?(u=$e("shrink-0",o),e[0]=o,e[1]=u):u=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx("circle",{cx:Ls/2,cy:Ls/2,r:si,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ti}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==a?(d=a>0?s.jsx("circle",{cx:Ls/2,cy:Ls/2,r:si,fill:"none",stroke:i,strokeWidth:ti,strokeLinecap:"round",strokeDasharray:Va,strokeDashoffset:Va*(1-a/100),transform:`rotate(-90 ${Ls/2} ${Ls/2})`}):null,e[3]=i,e[4]=a,e[5]=d):d=e[5];let f;return e[6]!==u||e[7]!==d?(f=s.jsxs("svg",{viewBox:`0 0 ${Ls} ${Ls}`,className:u,"aria-hidden":"true",children:[c,d]}),e[6]=u,e[7]=d,e[8]=f):f=e[8],f},md=()=>{const t=Be.c(16),{t:e}=at(),{sessionId:n,fill:r,limit:o}=pd(),{totalCost:i}=tm(n);if(!n||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Ua(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let u;t[4]!==o||t[5]!==e?(u=e("contextUsage.tooltip.contextLimit",{tokens:Ua(o)}),t[4]=o,t[5]=e,t[6]=u):u=t[6];let c;t[7]!==e||t[8]!==i?(c=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:td(i)})]:[],t[7]=e,t[8]=i,t[9]=c):c=t[9];let d;t[10]!==a||t[11]!==u||t[12]!==c?(d=[a,u,...c],t[10]=a,t[11]=u,t[12]=c,t[13]=d):d=t[13];const f=d;let p;return t[14]!==f?(p=s.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(Bx)}),t[14]=f,t[15]=p):p=t[15],p};function Bx(t){return s.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const zx="—",Wx={safe:"var(--status-success)",warn:"var(--status-warning)",critical:"var(--status-error)"},Ux=t=>{const e=Be.c(35),{buttonClassName:n}=t,{t:r}=at(),{sessionId:o,fill:i,limit:a}=pd(),u=Gs();let c;e[0]!==u?(c=u?us(u):"",e[0]=u,e[1]=c):c=e[1];const d=c,f=X(Hx);let p;e[2]!==d?(p=A=>d!==""&&bi(A.contextPanelByDirectory[d],A.contextSurfaceZones).has("context"),e[2]=d,e[3]=p):p=e[3];const m=X(p);if(!o||!i)return null;const h=i.state==="measured"?i.totalTokens/a*100:null,x=h===null?void 0:Wx[sm(Math.round(h))];let g;e[4]!==d||e[5]!==f?(g=d?()=>f(d,"context"):void 0,e[4]=d,e[5]=f,e[6]=g):g=e[6];let b;e[7]!==r?(b=r("contextUsage.aria.label"),e[7]=r,e[8]=b):b=e[8];const w=m&&"text-foreground";let S;e[9]!==n||e[10]!==w?(S=$e(n,"w-auto gap-1.5 px-1 tabular-nums",w),e[9]=n,e[10]=w,e[11]=S):S=e[11];const y=h??0;let I;e[12]!==x||e[13]!==y?(I=s.jsx($x,{percent:y,arcColor:x,className:"size-4"}),e[12]=x,e[13]=y,e[14]=I):I=e[14];let j;e[15]!==h?(j=h===null?zx:`${Math.min(h,999).toFixed(1)}%`,e[15]=h,e[16]=j):j=e[16];let R;e[17]!==j?(R=s.jsx("span",{dir:"ltr",className:"typography-meta",children:j}),e[17]=j,e[18]=R):R=e[18];let _;e[19]!==m||e[20]!==R||e[21]!==g||e[22]!==b||e[23]!==S||e[24]!==I?(_=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:g,"aria-label":b,"aria-pressed":m,className:S,children:[I,R]})}),e[19]=m,e[20]=R,e[21]=g,e[22]=b,e[23]=S,e[24]=I,e[25]=_):_=e[25];let P;e[26]!==m||e[27]!==r?(P=m?null:s.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=m,e[27]=r,e[28]=P):P=e[28];let k;e[29]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(md,{}),e[29]=k):k=e[29];let N;e[30]!==P?(N=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[P,k]})}),e[30]=P,e[31]=N):N=e[31];let T;return e[32]!==_||e[33]!==N?(T=s.jsxs(Lt,{children:[_,N]}),e[32]=_,e[33]=N,e[34]=T):T=e[34],T},Vx=l.memo(Ux);function Hx(t){return t.openContextSurface}const hd=l.createContext(null),gd=()=>l.useContext(hd),qx=t=>{const e=Be.c(4),n=gd()?.observe;let r,o;e[0]!==t||e[1]!==n?(r=()=>t&&n?n():void 0,o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),l.useEffect(r,o)},Ha=t=>{const e=Be.c(12),{run:n,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,u=o===void 0?!1:o;if(n?.status==="stopping"||n?.status==="waiting-for-preview"){let d;e[0]!==i?(d=$e("size-4 shrink-0 animate-spin text-[var(--status-warning)]",i),e[0]=i,e[1]=d):d=e[1];let f;return e[2]!==d?(f=s.jsx(se,{name:"loader-4",className:d}),e[2]=d,e[3]=f):f=e[3],f}if(n){const d=u?"stop-large":"stop";let f;e[4]!==i?(f=$e("size-4 shrink-0 text-[var(--status-warning)]",i),e[4]=i,e[5]=f):f=e[5];let p;return e[6]!==d||e[7]!==f?(p=s.jsx(se,{name:d,className:f}),e[6]=d,e[7]=f,e[8]=p):p=e[8],p}let c;return e[9]!==i||e[10]!==a?(c=a?s.jsx(se,{name:"play",className:$e("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=c):c=e[11],c},Gx=t=>{const e=Be.c(68),{directory:n,buttonClassName:r}=t,{t:o}=at(),i=an(Zx),a=an(Xx),u=an(Yx),c=an(Jx),d=nm(c),f=an(Qx),p=an(eb),m=an(tb);let h,x;e[0]!==f?(h=()=>{f()},x=[f],e[0]=f,e[1]=h,e[2]=x):(h=e[1],x=e[2]),l.useEffect(h,x);const g=Us()&&eo();let b;e[3]!==a||e[4]!==i?(b=a.find(le=>le.id===i)??a.find(sb)??a[0]??R1[0],e[3]=a,e[4]=i,e[5]=b):b=e[5];const w=b;if(!g||!n||a.length===0)return null;let S;e[6]!==n?(S=async le=>{await Cu(n,le.id,le.appName)||await Hl(n,le.appName)},e[6]=n,e[7]=S):S=e[7];const y=S;let I;e[8]!==y||e[9]!==m?(I=async le=>{await m(le.id),await y(le)},e[8]=y,e[9]=m,e[10]=I):I=e[10];const j=I;let R;e[11]!==n||e[12]!==o?(R=async()=>{(await ro(n)).ok&&_e.success(o("openInApp.toast.pathCopied"))},e[11]=n,e[12]=o,e[13]=R):R=e[13];const _=R;let P;e[14]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx("div",{className:"inline-flex"}),e[14]=P):P=e[14];let k;e[15]!==y||e[16]!==w?(k=()=>{y(w)},e[15]=y,e[16]=w,e[17]=k):k=e[17];let N;e[18]!==d||e[19]!==r?(N=$e(r,d),e[18]=d,e[19]=r,e[20]=N):N=e[20];let T;e[21]!==w.label||e[22]!==o?(T=o("openInApp.actions.openInAria",{app:w.label}),e[21]=w.label,e[22]=o,e[23]=T):T=e[23];let A;e[24]!==w.icon?(A=s.jsx(se,{name:w.icon,className:"size-4"}),e[24]=w.icon,e[25]=A):A=e[25];let $;e[26]!==T||e[27]!==A||e[28]!==k||e[29]!==N?($=s.jsx(oo,{render:P,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:k,className:N,"aria-label":T,children:A})})}),e[26]=T,e[27]=A,e[28]=k,e[29]=N,e[30]=$):$=e[30];let K;e[31]!==w.label||e[32]!==o?(K=o("openInApp.actions.openInAria",{app:w.label}),e[31]=w.label,e[32]=o,e[33]=K):K=e[33];let q;e[34]!==K?(q=s.jsx($t,{side:"bottom",children:K}),e[34]=K,e[35]=q):q=e[35];let M;e[36]!==$||e[37]!==q?(M=s.jsxs(Lt,{children:[$,q]}),e[36]=$,e[37]=q,e[38]=M):M=e[38];let z;e[39]!==_?(z=()=>{_()},e[39]=_,e[40]=z):z=e[40];let ne;e[41]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(se,{name:"file-copy",className:"h-4 w-4"}),e[41]=ne):ne=e[41];let H;e[42]!==o?(H=o("openInApp.actions.copyPath"),e[42]=o,e[43]=H):H=e[43];let V;e[44]!==H?(V=s.jsx("span",{className:"typography-ui-label text-foreground",children:H}),e[44]=H,e[45]=V):V=e[45];let F;e[46]!==z||e[47]!==V?(F=s.jsxs(Ns,{className:"flex items-center gap-2",onClick:z,children:[ne,V]}),e[46]=z,e[47]=V,e[48]=F):F=e[48];let C;e[49]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(Dn,{}),e[49]=C):C=e[49];let te;if(e[50]!==a||e[51]!==j||e[52]!==w.id){let le;e[54]!==j||e[55]!==w.id?(le=O=>s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{j(O)},children:[s.jsx(se,{name:O.icon,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:O.label}),w.id===O.id?s.jsx(se,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},O.id),e[54]=j,e[55]=w.id,e[56]=le):le=e[56],te=a.map(le),e[50]=a,e[51]=j,e[52]=w.id,e[53]=te}else te=e[53];let re;e[57]!==u||e[58]!==p||e[59]!==o?(re=u?s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{p(!0)},children:[s.jsx(se,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=u,e[58]=p,e[59]=o,e[60]=re):re=e[60];let Q;e[61]!==F||e[62]!==te||e[63]!==re?(Q=s.jsxs(io,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[F,C,te,re]}),e[61]=F,e[62]=te,e[63]=re,e[64]=Q):Q=e[64];let ee;return e[65]!==M||e[66]!==Q?(ee=s.jsxs(gr,{children:[M,Q]}),e[65]=M,e[66]=Q,e[67]=ee):ee=e[67],ee},Kx=l.memo(Gx);function Zx(t){return t.selectedAppId}function Xx(t){return t.availableApps}function Yx(t){return t.isCacheStale}function Jx(t){return t.isScanning}function Qx(t){return t.initialize}function eb(t){return t.loadInstalledApps}function tb(t){return t.selectApp}function sb(t){return t.id===D1}const er=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},nb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const o=er(n??"");if(o){const i=hr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function xd(){const t=Gt(b=>b.projects),e=Gt(b=>b.activeProjectId),n=tt(b=>b.availableWorktreesByProject),r=tt(b=>b.currentSessionId),o=rm(r??null),i=tt(b=>r?b.worktreeMetadata.get(r)?.path??"":""),a=tt(b=>b.newSessionDraft?.open?er(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),u=tt(b=>b.newSessionDraft?.open?b.newSessionDraft.target==="chat":null),c=l.useMemo(()=>er(i||""),[i]),d=l.useMemo(()=>er(o||""),[o]),f=c||d||a,p=l.useMemo(()=>nb({projects:t,worktreesByProject:n,directory:f,activeProjectId:e}),[e,f,t,n]),m=l.useMemo(()=>er(f||p?.path||""),[f,p?.path]),h=l.useMemo(()=>p?{id:p.id,path:p.path}:null,[p]),x=u??Jr(d),g=l.useRef(null);return l.useEffect(()=>{h&&m&&!x&&(g.current={projectRef:h,directory:m})},[m,h,x]),l.useMemo(()=>x?null:h&&m?{projectRef:h,directory:m}:g.current,[h,m,x])}const rb=t=>{const e=Be.c(67),{buttonClassName:n}=t,{t:r}=at(),o=gd(),i=X(lb),[a,u]=l.useState(!1),c=X(cb);let d;e[0]!==c?(d=ws(Es("open_project_actions",c),""),e[0]=c,e[1]=d):d=e[1];const f=d,p=o?.available?o.shown:null;let m;e[2]!==o||e[3]!==p?(m=p&&o?o.runOf(p):null,e[2]=o,e[3]=p,e[4]=m):m=e[4];const h=m;qx(!0);let x;e[5]!==h?(x=Q=>h?Q.getDirectoryState(h.directory)?.tabs.find(ee=>ee.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=x):x=e[6];const g=wt(x);if(!o||!p)return null;let b;e[7]!==p.name||e[8]!==h||e[9]!==r?(b=h?r("projectActions.actions.stopNamedAria",{name:p.name}):r("projectActions.actions.runNamedAria",{name:p.name}),e[7]=p.name,e[8]=h,e[9]=r,e[10]=b):b=e[10];const w=b;let S;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(S=h&&g?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:n,"aria-label":r("projectActions.actions.openPreview"),children:s.jsx(se,{name:"global",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=n,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=S):S=e[16];let y;e[17]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("div",{className:"inline-flex"}),e[17]=y):y=e[17];let I;e[18]!==o||e[19]!==p?(I=()=>o.toggle(p),e[18]=o,e[19]=p,e[20]=I):I=e[20];const j=o.isLoading||h?.status==="stopping",R=a&&"text-foreground";let _;e[21]!==n||e[22]!==R?(_=$e(n,R),e[21]=n,e[22]=R,e[23]=_):_=e[23];let P;e[24]!==p||e[25]!==h?(P=h?s.jsx(Ha,{run:h,large:!0}):s.jsx(se,{name:fa(p),className:"size-4"}),e[24]=p,e[25]=h,e[26]=P):P=e[26];let k;e[27]!==w||e[28]!==_||e[29]!==P||e[30]!==I||e[31]!==j?(k=s.jsx(oo,{render:y,children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:I,disabled:j,className:_,"aria-label":w,children:P})})}),e[27]=w,e[28]=_,e[29]=P,e[30]=I,e[31]=j,e[32]=k):k=e[32];let N;e[33]!==w?(N=s.jsx("span",{children:w}),e[33]=w,e[34]=N):N=e[34];let T;e[35]!==r?(T=r("projectActions.header.allActions"),e[35]=r,e[36]=T):T=e[36];let A;e[37]!==f||e[38]!==T?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:s.jsx(Hs,{label:T,shortcut:f})}),e[37]=f,e[38]=T,e[39]=A):A=e[39];let $;e[40]!==N||e[41]!==A?($=s.jsx($t,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[N,A]})}),e[40]=N,e[41]=A,e[42]=$):$=e[42];let K;e[43]!==k||e[44]!==$?(K=s.jsxs(Lt,{children:[k,$]}),e[43]=k,e[44]=$,e[45]=K):K=e[45];const q=o.openSettings;let M;e[46]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(se,{name:"add",className:"h-4 w-4"}),e[46]=M):M=e[46];let z;e[47]!==r?(z=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=z):z=e[48];let ne;e[49]!==z?(ne=s.jsx("span",{className:"typography-ui-label text-foreground",children:z}),e[49]=z,e[50]=ne):ne=e[50];let H;e[51]!==o.openSettings||e[52]!==ne?(H=s.jsxs(Ns,{className:"flex items-center gap-2",onClick:q,children:[M,ne]}),e[51]=o.openSettings,e[52]=ne,e[53]=H):H=e[53];let V;e[54]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Dn,{}),e[54]=V):V=e[54];let F;e[55]!==o||e[56]!==r?(F=o.actions.map(Q=>s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{o.select(Q),o.toggle(Q)},children:[s.jsx(se,{name:fa(Q),className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Q.name}),Q.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:r("projectActions.menu.sharedBadge")}):null,s.jsx(Ha,{run:o.runOf(Q),className:"ms-auto"})]},Q.id)),e[55]=o,e[56]=r,e[57]=F):F=e[57];let C;e[58]!==H||e[59]!==F?(C=s.jsxs(io,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[H,V,F]}),e[58]=H,e[59]=F,e[60]=C):C=e[60];let te;e[61]!==K||e[62]!==C?(te=s.jsxs(gr,{onOpenChange:u,children:[K,C]}),e[61]=K,e[62]=C,e[63]=te):te=e[63];let re;return e[64]!==te||e[65]!==S?(re=s.jsxs(s.Fragment,{children:[S,te]}),e[64]=te,e[65]=S,e[66]=re):re=e[66],re},ob=l.memo(rb),ib=t=>{const e=Be.c(8),{buttonClassName:n}=t,r=xd();if(!r)return null;let o;e[0]!==n||e[1]!==r.directory?(o=s.jsx(Kx,{directory:r.directory,buttonClassName:n}),e[0]=n,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==n?(i=s.jsx(ob,{buttonClassName:n}),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=s.jsxs(s.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},ab=l.memo(ib);function lb(t){return t.openContextPreview}function cb(t){return t.shortcutOverrides}const Ro="--oc-titlebar-controls-width",ni=new Set;let sr=null;const bd=t=>{sr===null?t.style.removeProperty(Ro):t.style.getPropertyValue(Ro)!==sr&&t.style.setProperty(Ro,sr)},db=t=>{const e=`${Math.round(t)}px`;e!==sr&&(sr=e,ni.forEach(bd))},wd=t=>{if(t)return ni.add(t),bd(t),()=>{ni.delete(t)}},Zn="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",Tn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ub=()=>{Tu("ui.header.render");const{t,direction:e}=at(),n=X(U=>U.isSidebarOpen),r=ao(),o=X(U=>U.sessionTabsEnabled),i=tt(U=>!!U.newSessionDraft?.open),a=tt(U=>U.currentSessionId),u=om(a??""),c=vf(a??""),d=ts(Qo(l.useCallback(U=>{if(!a)return null;const Xe=[...U.activeSessions,...U.archivedSessions].find(Tt=>Tt.id===a);if(!Xe)return null;const ot=Xe;return{title:Xe.title??null,directory:ot.directory??null,created:Xe.time?.created??null,slug:ot.slug??null,parentId:Xe.parentID??null}},[a]))),f=Gt(Qo(U=>{if(!U.activeProjectId)return null;const Xe=U.projects.find(ot=>ot.id===U.activeProjectId);return Xe?{id:Xe.id,path:Xe.path,label:Xe.label}:null})),p=l.useMemo(()=>{if(!f)return null;const U=f.label?.trim();if(U)return U;const Xe=f.path.split(/[\\/]/).filter(Boolean);return Xe[Xe.length-1]??null},[f]),m=Pn(U=>U.loadSettings),{isMobile:h}=yn(),x=l.useRef(null),[g,b]=l.useState(()=>typeof window>"u"?!1:Us()),w=l.useMemo(()=>Vo(),[]),S=im(),[y,I]=l.useState(!1),j=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:R,side:_}=sd(),P=l.useMemo(()=>{if(typeof window>"u")return null;const U=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof U=="number"&&Number.isFinite(U)&&U>0)return U;if(typeof navigator>"u")return null;const Xe=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Xe)return null;const ot=Number.parseInt(Xe[1],10),Tt=Number.parseInt(Xe[2],10);return Number.isNaN(ot)?null:ot===10?Tt:ot},[]);Wt.useEffect(()=>{typeof window>"u"||b(Us())},[]);const k=l.useMemo(()=>wi(),[]),N=X(U=>U.shortcutOverrides),T=ws(Es("rename_current_session",N),""),A=X(U=>U.workStatusPanelVisible),$=X(U=>U.workStatusPanelEnabled),K=X(U=>U.setWorkStatusPanelEnabled),q=X(U=>U.workStatusPanelFits),M=X(U=>U.workStatusOverlayOpen),z=X(U=>U.setWorkStatusOverlayOpen),H=$&&q||M,V=l.useCallback(()=>{if($&&!q){z(!M);return}K(!$)},[z,K,M,$,q]);am(),l.useEffect(()=>{m()},[m]);const F=a?d??null:null,C=l.useRef(null),[te,re]=l.useState(0);l.useEffect(()=>{if(!a){C.current&&(C.current=null,re(Tt=>Tt+1));return}if(F){C.current={sessionId:a,session:F,expiresAt:Date.now()+2e3};return}const U=C.current;if(!U||U.sessionId!==a)return;const Xe=U.expiresAt-Date.now();if(Xe<=0){C.current=null,re(Tt=>Tt+1);return}const ot=window.setTimeout(()=>{C.current?.sessionId===a&&(C.current=null),re(Tt=>Tt+1)},Xe);return()=>{window.clearTimeout(ot)}},[a,F]);const Q=(()=>{if(F)return F;if(!a)return null;const U=C.current;return U&&U.sessionId===a&&U.expiresAt>Date.now()?U.session:null})(),ee=tt(U=>a?U.worktreeMetadata.get(a)?.path??"":""),le=tt(U=>a?U.worktreeMetadata.get(a)?.branch?.trim()??null:null),O=Nc(U=>a?U.getAttachment(a):void 0),Y=l.useMemo(()=>O?lm(O,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,O]),Z=l.useMemo(()=>O?O.legacy?"legacy":O.degraded?"degraded":O.worktreeStatus==="pending"?"pending":O.worktreeStatus==="missing"?"missing":O.worktreeStatus==="invalid"?"invalid":O.attentionReason?"attention":null:null,[O]),we=l.useMemo(()=>Tn(ee||""),[ee]),L=l.useMemo(()=>{const U=typeof Q?.directory=="string"?Q.directory:"";return Tn(U||"")},[Q?.directory]),pe=rc(a??"",L),je=tt(U=>U.newSessionDraft?.open?Tn(U.newSessionDraft.bootstrapPendingDirectory??U.newSessionDraft.directoryOverride??""):""),Ee=tt(U=>U.newSessionDraft.target),Se=tt(U=>U.newSessionDraft.selectedProjectId),Le=tt(U=>U.currentSessionDirectory),Pe=is(U=>U.homeDirectory),Ve=xr(),Oe=l.useMemo(()=>we||L||(lo(Ve,je)??""),[je,Ve,L,we]),be=tt(U=>{const Xe=Tn(we||L||"");if(!Xe)return null;for(const ot of U.availableWorktreesByProject.values()){const Zt=$r(ot,Xe)?.branch?.trim();if(Zt)return Zt}return null}),Ue=cm(Oe||null)||le||be,Te=i?Ee==="chat":Vl(L||Le,Pe),Me=!Te&&!A&&!!(p||Ue||!i&&Z),Re=l.useMemo(()=>{if(!a)return p??"OpenChamber";const U=Q?.title?.trim();return U&&U.length>0?U:"Untitled Session"},[p,Q?.title,a]),ze=dm(),B=tt(U=>U.updateSessionTitle),ce=tt(U=>U.archiveSessions),G=tt(U=>U.deleteSessions),[Ce,J]=l.useState(!1),[Ne,Ae]=l.useState(!1),Ie=l.useRef(null),[De,We]=l.useState(""),[Ke,Ze]=l.useState(!1),Qe=Gt(U=>U.projects.length>0),[qe,et]=l.useState(null),He=ts(U=>qe&&U.entityById.get(qe)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ye=l.useRef(null),dt=l.useCallback(()=>{a&&(We(Q?.title?.trim()||Re),J(!0))},[Q?.title,a,Re]),nt=l.useRef(dt);nt.current=dt;const ut=l.useCallback(U=>{U&&(U.focus(),U.select())},[]);l.useEffect(()=>{if(Ae(!1),et(null),a&&Ie.current===a){Ie.current=null,nt.current();return}J(!1),We("")},[a]);const oe=l.useCallback(async()=>{if(!a)return;const U=De.trim();U&&U!==Q?.title?.trim()&&await B(a,U),J(!1)},[Q?.title,a,De,B]);l.useEffect(()=>{if(!Ce)return;const U=Xe=>{const ot=Xe.target;(!ot||!Ye.current?.contains(ot))&&oe()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Ce,oe]);const de=l.useCallback(U=>{U&&ro(U).then(Xe=>{_e[Xe.ok?"success":"error"](t(Xe.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>_e.error(t("sessions.sidebar.session.copyId.error")))},[t]),ve=l.useCallback(async()=>{if(!a||!Oe){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const U=await ze({sessionID:a,directory:Oe}).catch(()=>null);if(!U){_e.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(U.length===0){_e.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Xe=um(U,Q?.title??null),ot=fm(Q?.title??null);await pm(Xe,ot)||mm(Xe,ot),_e.success(t("sessions.sidebar.session.export.success"))},[Q?.title,a,ze,Oe,t]),v=hm(),ae=l.useMemo(()=>gm(v),[v]),W=l.useCallback(U=>{a&&Sf({entry:U,t,session:{id:a,title:Q?.title,directory:L??Oe},loadRecords:async()=>{if(!Oe)return null;try{return await ze({sessionID:a,directory:Oe})}catch{return null}},onLoadFailed:()=>_e.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[Q?.title,a,ze,Oe,L,t]),me=l.useCallback(U=>ae.map(Xe=>s.jsxs(U,{onClick:()=>W(Xe),children:[s.jsx(Ti,{icon:Xe.icon,iconSrc:Xe.iconSrc,className:"me-1 size-4"}),Xe.action.label]},`${Xe.guest.id}:${Xe.action.id}`)),[ae,W]),he=u?.type==="busy"||u?.type==="retry",Je=l.useCallback(()=>{if(!a||!L||he||c)return;const Xe=ts.getState().activeSessions.find(ot=>ot.id===a);Xe&&pa({kind:"quick",root:Xe,descendants:ha(Xe,[]),sourceDirectory:L,messages:ma(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,he,c,L,t]),Fe=l.useCallback(U=>{if(!a||!L||he||c)return;const ot=ts.getState().activeSessions.find(Tt=>Tt.id===a);ot&&pa({kind:"project",root:ot,descendants:ha(ot,[]),sourceDirectory:L,projectDirectory:U,messages:ma(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[a,he,c,L,t]),fe=l.useCallback(async(U,Xe)=>{const ot=[Xe,...kf(Xe,[],U==="delete")],Tt=tt.getState().currentSessionId===Xe?Xe:null;if(U==="delete"){const{failedIds:Xt}=await G(ot);Xt.length>0?_e.error(t("sessions.sidebar.session.delete.error")):_e.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:Zt,failedIds:Ds}=await ce(ot);if(Ds.length>0){_e.error(t("sessions.sidebar.session.archive.error"));return}_e.success(t("sessions.sidebar.session.archive.success"),jf(Zt,Tt,t))},[ce,G,t]),ke=l.useCallback(async()=>{qe&&(et(null),await fe("delete",qe))},[qe,fe]),rt=X(U=>U.openGuestPageId),ge=Ni(U=>U.guests.find(Xe=>Xe.id===rt)),lt=X(U=>U.isScheduledTasksDialogOpen),Ct=X(U=>U.isArchivePageOpen),bt=X(U=>U.isIntegrationsCatalogOpen),kt=X(U=>U.isUsageStatsPageOpen),ht=X(U=>U.isSourceBoardOpen),St=X(U=>U.isOverviewOpen),yt=X(U=>U.worktreesPageProjectId),xt=X(U=>U.isolatedSpacesEnabled?U.spacesPageProjectId:null),vt=X(U=>U.runOverviewKey),ct=Cf(vt),Pt=yt??xt,Dt=Gt(U=>{if(!Pt)return null;const Xe=U.projects.find(ot=>ot.id===Pt);return Xe?.label?.trim()||Xe?.path?.split("/").pop()||null}),pt=l.useMemo(()=>ge?{title:ge.pageTitle??ge.name,subtitle:null}:lt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Ct?{title:t("sessions.archivePage.title"),subtitle:null}:bt?{title:t("integrationsCatalog.page.title"),subtitle:null}:kt?{title:t("usageStats.title"),subtitle:null}:ht?{title:t("sourceBoard.title"),subtitle:null}:St?{title:t("overview.title"),subtitle:null}:yt?{title:t("sessions.worktreesPage.title",{project:Dt??""}),subtitle:null}:xt?{title:t("spaces.page.title",{project:Dt??""}),subtitle:null}:vt?{title:ct??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[ge,Ct,bt,ct,vt,lt,ht,St,kt,xt,Dt,t,yt]),mt=L||Tn(Le||"")||we,Ot=l.useCallback(()=>{un("desktop_open_draft_mini_chat_window",{directory:Te?"":je,projectId:Te?null:Se,...Nr()}).catch(U=>{console.warn("[header] failed to open draft mini chat window",U)})},[je,Se,Te]),Ut=l.useCallback(()=>{if(i){Ot();return}a&&un("desktop_open_session_mini_chat_window",{sessionId:a,directory:L||Tn(Le||"")||we,...Nr()}).catch(U=>{console.warn("[header] failed to open session mini chat window",U)})},[a,Ot,i,Le,L,we]),ss=w&&(i||!!a),ps=l.useCallback((U,Xe)=>{un("desktop_open_session_mini_chat_window",{sessionId:U,directory:Xe,...Nr()}).catch(ot=>{console.warn("[header] failed to open session mini chat window",ot)})},[]),ns=Zn,ms=l.useMemo(()=>g&&j&&!y?"88px":S?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||R)&&!k?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,y,j,S,k,R]),ls=(!g||R)&&!k?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",rs=e==="rtl",Rs=rs?ls:ms,Vt=rs?ms:ls,cs=R&&_!==ql(e);Wt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",Rs)},[Rs]);const Ht=n?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",ie=n?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Wt.useEffect(()=>{if(!g||!j){I(!1);return}let U=!1;const Xe=async()=>{try{const Tt=await un("desktop_is_window_fullscreen");U||I(Tt===!0)}catch{U||I(!1)}},ot=()=>{Xe()};return Xe(),window.addEventListener("openchamber:window-resized",ot),()=>{U=!0,window.removeEventListener("openchamber:window-resized",ot)}},[g,j]);const Ge=l.useMemo(()=>!g||!j||P===null?"":P>=26?"h-11":P<=15?"h-14":"",[g,j,P]),gt=l.useMemo(()=>g&&j&&!y?P!==null&&P<=15?"56px":"44px":"0px",[g,y,j,P]),jt=l.useMemo(()=>{const Xe=`max(${g&&j?"2.75rem":"3rem"}, ${gt}, var(--oc-wco-titlebar-height, 0px))`,ot=g&&!R||k;if(ot&&gt==="0px")return{};const Tt={minHeight:Xe,height:Xe};return!cs&&(!ot||rs)&&(Tt.paddingInlineEnd=Vt),Tt},[cs,g,j,rs,k,Vt,gt,R]),It=l.useRef(null),Mt=l.useCallback(U=>{!U||U===It.current||(It.current=U,document.documentElement.style.setProperty("--oc-header-height",`${U}px`))},[]),Kt=l.useCallback(()=>{typeof document>"u"||Mt(x.current?.getBoundingClientRect().height)},[Mt]);Wt.useEffect(()=>{if(typeof window>"u")return;Kt();const U=x.current;if(!U||typeof ResizeObserver>"u")return()=>{};let Xe=0;const ot=()=>{Xe||(Xe=requestAnimationFrame(()=>{Xe=0,Kt()}))},Tt=new ResizeObserver(Zt=>{const Ds=Zt[Zt.length-1];Mt(Ds?.borderBoxSize?.[0]?.blockSize??Ds?.target.getBoundingClientRect().height)});return Tt.observe(U),window.addEventListener("resize",ot),window.addEventListener("orientationchange",ot),()=>{Xe&&cancelAnimationFrame(Xe),Tt.disconnect(),window.removeEventListener("resize",ot),window.removeEventListener("orientationchange",ot)}},[Mt,Kt]),Wt.useEffect(()=>{Kt()},[Kt,h,Ge]);const Jt=l.useCallback(async U=>{const Xe=U.target;Xe.closest(".app-region-no-drag")||Xe.closest("button, a, input, select, textarea")||U.button===0&&g&&await Nu()},[g]);xm({rename_current_session:()=>{if(!a||h)return!1;dt()},archive_current_session:()=>{if(!a||h||ts.getState().entityById.get(a)?.time.archived)return!1;fe("archive",a)}});const gs=l.useCallback(({session:U,open:Xe,isActive:ot,select:Tt,closeOtherTabs:Zt,components:Ds})=>{const{Item:Xt,Separator:en}=Ds,Sn=ot&&!k&&!Te&&Q&&!Q.parentId,tn=ot&&!k&&Te&&Q&&!Q.parentId&&Qe;return s.jsxs(s.Fragment,{children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Xt,{onClick:()=>{ot||Tt(),Ie.current=U.id},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),ot&&T?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:T}):null]})}),s.jsx(ga,{sessionID:U.id,directory:U.directory,open:Xe,Item:Xt}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Xt,{onClick:()=>de(U.id),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(en,{}),ot?s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Xt,{onClick:()=>{ve()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,w?s.jsxs(Xt,{onClick:()=>ps(U.id,ot?mt:U.directory??""),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ot?me(Xt):null,Sn?s.jsx(ds,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Xt,{disabled:!L||he||c,onClick:Je,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,tn?s.jsx(ds,{hint:t(he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Xt,{disabled:!L||he||c,onClick:()=>Ze(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,s.jsx(en,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:s.jsxs(Xt,{onClick:Zt,children:[s.jsx(se,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),s.jsx(en,{}),s.jsx(_x,{session:U,Item:Xt}),s.jsx(Wa,{sessionId:U.id,Item:Xt,onArchive:()=>{fe("archive",U.id)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Xt,{className:"text-destructive focus:text-destructive",onClick:()=>et(U.id),children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[de,Q,mt,ve,w,Qe,Te,he,c,k,Je,ps,me,T,fe,L,t]),Cs=()=>s.jsxs("div",{onMouseDown:Jt,className:$e("app-region-drag relative flex h-12 select-none items-center",cs?"pe-0":"pe-2.5",Ge),style:jt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Ht,transitionDuration:`${r}ms`,transitionTimingFunction:Wn}}),s.jsx("div",{ref:wd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:ie,transitionDuration:`${r}ms`,transitionTimingFunction:Wn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[pt?s.jsxs(s.Fragment,{children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>X.getState().closeMainSurfaces(),children:s.jsx(se,{name:"arrow-left",className:"size-4"})})}),s.jsx($t,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[s.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:pt.title}),pt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:pt.subtitle}):null]})]}):k||!o?s.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[pe?s.jsx(se,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,n?null:s.jsxs(Lt,{children:[s.jsx(g1,{align:"start",children:s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",className:ns,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(se,{name:"history",className:"h-4 w-4"})})})}),s.jsx($t,{side:"bottom",children:s.jsx(Hs,{label:t("sessions.switcher.openAria"),shortcut:ws(Es("open_session_list",N),"")})})]}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ce?s.jsxs("form",{ref:Ye,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),oe()},children:[s.jsx("input",{ref:ut,value:De,onChange:U=>We(U.target.value),onKeyDown:U=>xa(U,()=>J(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[0.875rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>J(!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(se,{name:"close",className:"size-4"})})]}):i?null:s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:Re}),Me?s.jsxs("span",{className:$e("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[0.875rem] text-foreground":"typography-micro text-[0.65625rem] text-muted-foreground"),children:[p?s.jsx("span",{className:"truncate",children:p}):null,Ue?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(se,{name:"git-branch",className:$e("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),s.jsx("span",{className:$e("truncate",i&&"text-muted-foreground"),children:Ue})]}):null,!i&&Z?s.jsxs("span",{className:$e("inline-flex min-w-0 items-center gap-0.5",Z==="attention"||Z==="invalid"||Z==="missing"?"text-status-warning":"text-muted-foreground"),children:[s.jsx(se,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Y})]}):null]}):null]}),s.jsx("div",{className:$e("flex h-[1.125rem] shrink-0 items-center justify-center",Me?"self-start":"self-center"),children:a&&!i&&!Ce?s.jsxs(xn,{open:Ne,onOpenChange:Ae,onOpenChangeComplete:U=>{!U&&Ie.current&&Ie.current===a&&(Ie.current=null,dt())},children:[s.jsx(bn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"h-[1.125rem] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(se,{name:"more",className:"size-4"})})}),s.jsxs(wn,{align:"end",className:"min-w-[190px]",children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(qt,{onClick:()=>{Ie.current=a},children:[s.jsx(se,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),T?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:T}):null]})}),s.jsx(ga,{sessionID:a,directory:L,open:Ne,Item:qt}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(qt,{onClick:()=>a&&de(a),children:[s.jsx(se,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(mn,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(qt,{onClick:()=>{ve()},children:[s.jsx(se,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),w?s.jsxs(qt,{onClick:()=>ps(a,mt),children:[s.jsx(se,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,me(qt),!k&&!Te&&Q&&!Q.parentId?s.jsx(ds,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(qt,{disabled:!L||he||c,onClick:Je,className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,!k&&Te&&Q&&!Q.parentId&&Qe?s.jsx(ds,{hint:t(he?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(qt,{disabled:!L||he||c,onClick:()=>Ze(!0),className:"w-full",children:[s.jsx(se,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,s.jsx(mn,{}),s.jsx(Wa,{sessionId:a,Item:qt,onArchive:()=>{fe("archive",a)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(qt,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&et(a)},children:[s.jsx(se,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):s.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:s.jsx(Q1,{renderMenu:gs,suppressActiveTabControls:Ce,onMenuOpenChangeComplete:U=>{!U&&Ie.current&&Ie.current===a&&(Ie.current=null,dt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ce?s.jsxs("form",{ref:Ye,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),oe()},children:[s.jsx("input",{ref:ut,value:De,onChange:U=>We(U.target.value),onKeyDown:U=>xa(U,()=>J(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[0.8125rem] 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(se,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>J(!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(se,{name:"close",className:"size-4"})})]}):s.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):Re})})})}),pt||k||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!k&&!pt?s.jsxs(s.Fragment,{children:[s.jsx(Vx,{buttonClassName:Zn}),s.jsx(ab,{buttonClassName:Zn})]}):null,ss?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Ut,className:Zn,children:s.jsx(se,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:s.jsx(Hs,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?ws(Es("new_mini_chat",N),""):void 0})})]}):null,k?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":H,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:V,className:$e(Zn,H&&"text-foreground"),children:s.jsx(se,{name:"list-indefinite",className:"h-4 w-4"})})}),s.jsx($t,{side:"bottom",children:t($&&!q?M?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":$?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),s.jsx(nd,{visible:cs,position:_})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:x,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:Cs()}),s.jsx(Ex,{open:Ke,onOpenChange:Ze,onPick:Fe}),s.jsx(zn,{open:qe!==null,onOpenChange:U=>{U||et(null)},children:s.jsxs(Bn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs($n,{children:[s.jsx(Fn,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),s.jsx(Ln,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:He})})]}),s.jsxs(Br,{children:[s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>et(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",size:"sm",onClick:()=>{ke()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},qa=280,Ga=264,Ka=500,fb=({isOpen:t,isMobile:e,children:n,className:r,topBar:o,peek:i})=>{const{t:a,direction:u}=at(),c=X(F=>F.sidebarWidth),d=X(F=>F.setSidebarWidth),[f,p]=l.useState(!1),m=l.useRef(0),h=l.useRef(c||qa),x=l.useRef(null),g=l.useRef(null),b=l.useRef(null),w=l.useRef(null),S=l.useRef(null),y=l.useCallback(F=>Math.min(Ka,Math.max(Ga,F)),[]),I=l.useCallback(()=>{const F=S.current;if(F?.isConnected)return F;const C=document.querySelector("[data-titlebar-left-controls]");return S.current=C,C},[]),j=l.useCallback(F=>{const C=w.current;if(!C)return;C.style.width=`${F}px`,C.style.minWidth=`${F}px`,C.style.maxWidth=`${F}px`,C.style.setProperty("--oc-left-sidebar-width",`${F}px`);const te=I();te&&te.style.setProperty("--oc-left-sidebar-width",`${F}px`)},[I]);l.useEffect(()=>{e&&f&&p(!1)},[e,f]),l.useEffect(()=>{f||(x.current=null,g.current=null,b.current?.(),b.current=null)},[f]),l.useEffect(()=>{!t&&f&&p(!1)},[t,f]),l.useEffect(()=>()=>{b.current?.(),b.current=null},[]);const R=Math.min(Ka,Math.max(Ga,c||qa)),_=t?R:0,P=f?x.current??_:_,k=f?P:R;l.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${k}px`);const F=S.current;!f&&F&&F.style.removeProperty("--oc-left-sidebar-width")},[k,f]);const[N,T]=l.useState(!t);t&&N&&T(!1);const A=ao(),$=l.useRef(t),K=l.useRef(t);if(l.useLayoutEffect(()=>{$.current=t,K.current!==t&&(K.current=t,Ec(A),t||Ei(()=>{$.current||T(!0)}))},[t,A]),e)return null;const q=F=>{if(t){try{F.currentTarget.setPointerCapture(F.pointerId)}catch{}g.current=F.pointerId,p(!0),m.current=F.clientX,h.current=_,x.current=_,j(_),b.current?.(),b.current=Pc(),F.preventDefault()}},M=F=>{if(e||!f||g.current!==F.pointerId)return;const C=(F.clientX-m.current)*(u==="rtl"?-1:1),te=y(h.current+C);x.current!==te&&(x.current=te,j(te))},z=F=>{if(g.current!==F.pointerId||e)return;try{F.currentTarget.releasePointerCapture(F.pointerId)}catch{}const C=y(x.current??_);g.current=null,x.current=null,p(!1),d(C),b.current?.(),b.current=null},ne=!t&&i?i.state:!1,H=ne!==!1,V=H&&i&&i.animationMs>0?`${ne==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${Wn} forwards`:void 0;return s.jsxs("div",{ref:w,"data-left-sidebar":"",className:$e("relative flex h-full",!H&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${P}px`,minWidth:`${P}px`,maxWidth:`${P}px`,"--oc-left-sidebar-width":`${k}px`,overflowX:H?void 0:"clip",transitionDuration:`${A}ms`,transitionTimingFunction:Wn},children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-0.5px_0_0_0_var(--oc-edge-strong)] rtl:shadow-[inset_0.5px_0_0_0_var(--oc-edge-strong)]","aria-hidden":"true"}),t&&s.jsx("div",{className:$e("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:q,onPointerMove:M,onPointerUp:z,onPointerCancel:z,onLostPointerCapture:z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":H?ne:void 0,className:$e("flex h-full shrink-0 flex-col",H?"absolute inset-s-0 top-0 z-[25] bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!H&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${A}ms`,overflowX:"hidden",contentVisibility:N&&!H?"hidden":void 0,animation:V,"--oc-peek-offset":u==="rtl"?"100%":"-100%"},inert:!t&&!H||void 0,onPointerEnter:H?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:H?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:H?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,s.jsx(fs,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Qt,{children:n})})]})]})},pb=()=>{const t=Be.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-start-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",{ref:wd,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},mb=50,hb=18,gb=300,xb='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',yd=t=>!document.getElementById("root")?.contains(t),bb=t=>{if((Qr(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>hb)return!1;const n=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=n},Za=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(xb)).some(n=>yd(n)&&n.getClientRects().length>0)},wb=({enabled:t,layoutAnimationMs:e})=>{const[n,r]=l.useState(!1),o=bm()?0:e,i=o>0,a=l.useRef(null),u=l.useRef(null),c=l.useRef(null),d=l.useCallback(()=>{u.current!==null&&clearTimeout(u.current),c.current!==null&&clearTimeout(c.current),u.current=null,c.current=null},[]),f=l.useCallback(()=>{d(),r(x=>x==="in"&&i?"out":!1)},[i,d]),p=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{if(c.current=null,Za(a.current)){p();return}f()},gb)},[f]),m=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null},[]);l.useEffect(()=>{t||(d(),r(!1))},[d,t]),l.useEffect(()=>d,[d]),l.useEffect(()=>{if(n!=="in")return;const x=w=>{const S=w.target;S instanceof Element&&(a.current?.contains(S)||yd(S)||f())},g=w=>{Ic(w)||w.key!=="Escape"||w.defaultPrevented||Za(a.current)||f()},b=w=>{w.relatedTarget===null&&p()};return document.addEventListener("pointerdown",x,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",b)}},[f,p,n]),l.useEffect(()=>{if(!t||n!==!1)return;const x=()=>{u.current!==null&&clearTimeout(u.current),u.current=null},g=w=>{if(w.pointerType!=="mouse"||w.buttons!==0||!bb(w)){x();return}u.current===null&&(u.current=setTimeout(()=>{u.current=null,r("in")},mb))},b=w=>{w.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",b),x()}},[t,n]);const h=l.useMemo(()=>({onPointerEnter:()=>{m(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{n==="in"&&p()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?!1:g)}}),[m,p,n]);return{state:t?n:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},vr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",yb=()=>{const t=Be.c(47),{t:e,locale:n,direction:r}=at(),o=X(vb),i=X(Sb),a=X(kb),u=l.useRef(null),c=ws(Es("toggle_sidebar",a)),d=jb,f=X(Cb),{usesFramelessChrome:p,side:m}=sd();let h;t[0]!==n?(h=C=>{const te=C.currentTarget.getBoundingClientRect();un("desktop_show_app_menu",{x:te.left,y:te.bottom,locale:n}).catch(Tb)},t[0]=n,t[1]=h):h=t[1];const x=h;let g,b;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const C=u.current;if(!C)return;const te=()=>{const Q=Math.max(C.getBoundingClientRect().width,C.scrollWidth);db(Q)};if(te(),typeof ResizeObserver>"u")return;const re=new ResizeObserver(te);return re.observe(C),()=>{re.disconnect()}},b=[],t[2]=g,t[3]=b):(g=t[2],b=t[3]),l.useEffect(g,b);const w="",S="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",y=i?"var(--oc-left-sidebar-width, 100%)":void 0;let I;t[4]!==y?(I={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:y},t[4]=y,t[5]=I):I=t[5];const j="flex min-w-0 items-center gap-2";let R;t[6]!==r||t[7]!==p||t[8]!==m?(R=p&&m===ql(r)?s.jsx(nd,{visible:!0,position:m}):null,t[6]=r,t[7]=p,t[8]=m,t[9]=R):R=t[9];let _;t[10]!==x||t[11]!==e||t[12]!==p?(_=p?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:$e(vr,"shrink-0"),children:s.jsx(se,{name:"menu-2",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=p,t[13]=_):_=t[13];const P=Lt;let k;t[14]!==e?(k=e("header.actions.openSessionsAria"),t[14]=e,t[15]=k):k=t[15];const N=i&&"text-foreground";let T;t[16]!==N?(T=$e(vr,"shrink-0",N),t[16]=N,t[17]=T):T=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(se,{name:"layout-left",className:"h-4 w-4"}),t[18]=A):A=t[18];let $;t[19]!==i||t[20]!==k||t[21]!==T||t[22]!==o?($=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":k,"aria-pressed":i,className:T,children:A})}),t[19]=i,t[20]=k,t[21]=T,t[22]=o,t[23]=$):$=t[23];const K=$t,q=e("header.actions.openSessionsWithShortcut",{shortcut:c});let M;t[24]!==q?(M=s.jsx("p",{children:q}),t[24]=q,t[25]=M):M=t[25];let z;t[26]!==K||t[27]!==M?(z=s.jsx(K,{children:M}),t[26]=K,t[27]=M,t[28]=z):z=t[28];let ne;t[29]!==P||t[30]!==$||t[31]!==z?(ne=s.jsxs(P,{children:[$,z]}),t[29]=P,t[30]=$,t[31]=z,t[32]=ne):ne=t[32];let H;t[33]!==d||t[34]!==i||t[35]!==a||t[36]!==e||t[37]!==f?(H=f?null:i?s.jsxs("button",{type:"button",onClick:d,className:$e(vr,"-ms-1 w-auto min-w-0 ps-1 pe-1.5 font-normal"),children:[s.jsx(se,{name:"chat-new",className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:$e(vr,"-ms-1 shrink-0"),children:s.jsx(se,{name:"chat-new",className:"h-4 w-4"})})}),s.jsx($t,{children:s.jsx(Hs,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:ws(Es("new_chat",a),"")})})]}),t[33]=d,t[34]=i,t[35]=a,t[36]=e,t[37]=f,t[38]=H):H=t[38];let V;t[39]!==ne||t[40]!==H||t[41]!==R||t[42]!==_?(V=s.jsxs("div",{ref:u,className:j,children:[R,_,ne,H]}),t[39]=ne,t[40]=H,t[41]=R,t[42]=_,t[43]=V):V=t[43];let F;return t[44]!==V||t[45]!==I?(F=s.jsx("div",{"data-titlebar-left-controls":w,className:S,style:I,children:V}),t[44]=V,t[45]=I,t[46]=F):F=t[46],F};function vb(t){return t.toggleSidebar}function Sb(t){return t.isSidebarOpen}function kb(t){return t.shortcutOverrides}function jb(){X.getState().closeMainSurfaces(),tt.getState().openNewSessionDraft()}function Cb(t){return t.sessionTabsEnabled&&!(t.isScheduledTasksDialogOpen||t.isArchivePageOpen||t.isIntegrationsCatalogOpen||t.isUsageStatsPageOpen||t.isSourceBoardOpen||t.isOverviewOpen||t.worktreesPageProjectId!==null||t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null||t.runOverviewKey!==null||t.openGuestPageId!==null)}function Tb(t){console.warn("[titlebar] failed to open app menu",t)}function Nb(t,e,n){const r=Be.c(5),[o,i]=l.useState();let a,u;return r[0]!==n||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let c=!1;return(async()=>{const[d,f]=await Promise.all([wm(t),ym(t)]).catch(Eb);if(c)return;const p=Yt(d),m=Yt(f);if(!p||!m||m===p)return;const h=n||"",x=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:p,branch:h,label:h||x,name:x,worktreeRoot:m,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{c=!0}},u=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=a,r[4]=u):(a=r[3],u=r[4]),l.useEffect(a,u),e??o}function Eb(){return["",""]}const Pb=()=>{const t=Be.c(3),e=X(Ib),n=X(Rb);let r;return t[0]!==e||t[1]!==n?(r=()=>{n("integrations"),e(!0)},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function Ib(t){return t.setSettingsDialogOpen}function Rb(t){return t.setSettingsPage}const Xa="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",Db=({className:t,identity:e})=>{const{t:n}=at(),{sourceControl:r}=Is(),o=vm(e),i=yi(e.provider),a=i.label,u=o?.status??null,c=hn(w=>w.setStatus),[d,f]=l.useState(!1),p=l.useCallback(async w=>{if(!(!w||d)){f(!0);try{c(e,await r.authActivate(e,w))}catch(S){console.error("Failed to switch source control account:",S)}finally{f(!1)}}},[e,d,c,r]);if(u?.status!=="connected")return null;const m=u.user.username||null,h=u.user.avatarUrl??null,x=u.accounts,g=m?n("header.sourceControl.connectedWithLogin",{login:m,provider:a}):n("header.sourceControl.connected",{provider:a}),b=h?s.jsx("img",{src:h,alt:m?n("header.sourceControl.avatarWithLogin",{login:m}):n("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(Ca,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?s.jsx("div",{className:$e(Xa,t),title:g,children:b}):s.jsxs(xn,{children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:$e(Xa,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:d,children:b})}),s.jsxs(wn,{align:"end",className:"w-64",children:[s.jsx(Ir,{className:"typography-ui-header font-semibold text-foreground",children:n("header.sourceControl.accountsTitle",{provider:a})}),s.jsx(mn,{}),x.map(w=>{const S=w.user,y=!!w.current,I=n(Sm(w.source??"oauth"));return s.jsxs(qt,{className:"gap-2",disabled:d,onSelect:()=>{y||p(w.id)},children:[S?.avatarUrl?s.jsx("img",{src:S.avatarUrl,alt:S.username?n("header.sourceControl.avatarWithLogin",{login:S.username}):n("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge 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-edge bg-muted",children:s.jsx(Ca,{descriptor:i,variant:"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:S?.name?.trim()||S.username||i.label}),S.username?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:S.username}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:I})]}):null]}),y?s.jsx(se,{name:"check",className:"h-4 w-4 text-primary"}):null]},w.id)})]})]})},_b=t=>JSON.stringify(km(t)),Ab=async(t,e)=>{const n=await t.projectUpstream(e);if(!n?.isFork||!n.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,n.upstream.owner,n.upstream.name);return{upstream:n.upstream,branches:r}},vd=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function Ob(t){if(!vd(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function Mb(t,e,n){const r=Be.c(18),{sourceControl:o}=Is(),i=yi(t.provider).features.referenceSearch,[a,u]=Wt.useState(null);let c;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(c=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=c):c=r[4];const d=c;let f;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==i||r[9]!==o?(f=()=>{if(!i)return;let m=!1;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(m||!h.connected)return;const x=h.items.find(g=>g.kind==="pull"&&g.number===e);x&&u({key:d,pull:x})}).catch(Fb),()=>{m=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=i,r[9]=o,r[10]=f):f=r[10];let p;return r[11]!==t||r[12]!==d||r[13]!==e||r[14]!==n||r[15]!==i||r[16]!==o?(p=[t,d,e,n,i,o],r[11]=t,r[12]=d,r[13]=e,r[14]=n,r[15]=i,r[16]=o,r[17]=p):p=r[17],Wt.useEffect(f,p),a?.key===d?a.pull:null}function Fb(){}const Lb=t=>{const e=Be.c(93),{directory:n,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:u}=Is(),c=Gs(),d=Gt($b),[f,p]=Wt.useState(0),[m,h]=Wt.useState(!1),x=Pi(),g=Mb(r,o.number,f);let b;e[0]!==o?(b=jm(o),e[0]=o,e[1]=b):b=e[1];const w=b;let S;e[2]!==g||e[3]!==w?(S=g?{...w,labels:g.labels,commentCount:g.commentCount}:w,e[2]=g,e[3]=w,e[4]=S):S=e[4];const y=S,[I,j]=Wt.useState(null),R=I?.number===o.number?I.sha:null,{detail:_,latest:P,refresh:k}=Rc(n,y,!0,R),N=P.status==="ready"?P.value.pull:null,T=ic(y);let A;e[5]!==i||e[6]!==k?(A=()=>{k(),p(Bb),i()},e[5]=i,e[6]=k,e[7]=A):A=e[7];const $=A,K=ac(y,r,$);let q;e[8]!==r||e[9]!==i||e[10]!==y.number||e[11]!==y.sourceRepo.owner||e[12]!==y.sourceRepo.repo||e[13]!==k||e[14]!==u?(q=async()=>{const J={owner:y.sourceRepo.owner,repo:y.sourceRepo.repo,number:y.number};await u.refreshProviderReads(r,{item:J}).catch(zb),Dc(J),p(Wb),await Promise.all([k(),i()])},e[8]=r,e[9]=i,e[10]=y.number,e[11]=y.sourceRepo.owner,e[12]=y.sourceRepo.repo,e[13]=k,e[14]=u,e[15]=q):q=e[15];const M=q;let z;e[16]!==y?(z={source:"repository",reference:y},e[16]=y,e[17]=z):z=e[17];const ne=z,H=c??n;let V;e[18]!==_||e[19]!==a?(V=_.status==="ready"&&_.value.pull&&_.value.pull.stack===void 0&&a!==void 0?{status:"ready",value:{..._.value,pull:{..._.value.pull,stack:a}}}:_,e[18]=_,e[19]=a,e[20]=V):V=e[20];const F=V,C=F.status==="ready"?F.value.pull?.stack??null:a??null,te=Ii(),re=Gt(Ub),Q=tt(Vb),ee=hr(re,Q,n),[le,O]=Wt.useState(!1);let Y;e[21]===Symbol.for("react.memo_cache_sentinel")?(Y={status:"idle"},e[21]=Y):Y=e[21];const Z=ee?()=>O(!0):void 0,we=N?.submitRequirements,L=P.status==="error",pe=o.mergeable??null;let je;e[22]!==r||e[23]!==ne||e[24]!==$||e[25]!==C||e[26]!==L||e[27]!==pe||e[28]!==Z||e[29]!==we?(je=s.jsx(ji,{item:ne,project:null,context:r,onStartWorktree:qb,onChanged:$,worktreeAvailable:!1,stack:C,onStartOnTop:Z,submitRequirements:we,submitRequirementsUnreadable:L,mergeable:pe}),e[22]=r,e[23]=ne,e[24]=$,e[25]=C,e[26]=L,e[27]=pe,e[28]=Z,e[29]=we,e[30]=je):je=e[30];let Ee;e[31]!==o.number||e[32]!==N||e[33]!==R?(Ee=N?.revisions?{revisions:N.revisions,selected:R,onSelect:J=>j(J?{number:o.number,sha:J}:null)}:void 0,e[31]=o.number,e[32]=N,e[33]=R,e[34]=Ee):Ee=e[34];let Se;e[35]!==n||e[36]!==te?(Se=J=>{te(J.url,n)},e[35]=n,e[36]=te,e[37]=Se):Se=e[37];let Le;e[38]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>h(!0),e[38]=Le):Le=e[38];let Pe;e[39]!==T.attachComment||e[40]!==T.attachComments?(Pe={onAttach:T.attachComment,onAttachAll:T.attachComments},e[39]=T.attachComment,e[40]=T.attachComments,e[41]=Pe):Pe=e[41];let Ve;e[42]!==r||e[43]!==y||e[44]!==$?(Ve=s.jsx(dc,{reference:y,context:r,onChanged:$}),e[42]=r,e[43]=y,e[44]=$,e[45]=Ve):Ve=e[45];let Oe;e[46]!==r||e[47]!==_||e[48]!==y||e[49]!==$?(Oe=s.jsx(uc,{pull:y,detail:_,context:r,onChanged:$}),e[46]=r,e[47]=_,e[48]=y,e[49]=$,e[50]=Oe):Oe=e[50];const be=N?.voteLabels;let ye;e[51]!==N?.revisions?(ye=N?.revisions?.at(-1)?.sha,e[51]=N?.revisions,e[52]=ye):ye=e[52];const Ue=R===null;let Te;e[53]!==r||e[54]!==y||e[55]!==$||e[56]!==be||e[57]!==ye||e[58]!==Ue?(Te=s.jsx(lc,{reference:y,context:r,onRefresh:$,voteLabels:be,latestRevision:ye,onLatestRevision:Ue},y.number),e[53]=r,e[54]=y,e[55]=$,e[56]=be,e[57]=ye,e[58]=Ue,e[59]=Te):Te=e[59];const Me=d??"";let Re;e[60]!==H||e[61]!==Me?(Re={id:Me,path:H},e[60]=H,e[61]=Me,e[62]=Re):Re=e[62];let ze;e[63]!==r||e[64]!==H||e[65]!==y||e[66]!==R||e[67]!==Re?(ze=s.jsx(fc,{pull:y,project:Re,repository:null,context:r,projectOwnsDirectory:Gb,currentDirectory:H,revision:R}),e[63]=r,e[64]=H,e[65]=y,e[66]=R,e[67]=Re,e[68]=ze):ze=e[68];let B;e[69]!==n||e[70]!==ne||e[71]!==x||e[72]!==M||e[73]!==F||e[74]!==je||e[75]!==Ee||e[76]!==Se||e[77]!==Pe||e[78]!==Ve||e[79]!==Oe||e[80]!==Te||e[81]!==ze||e[82]!==K?(B=s.jsx(Ri,{item:ne,directory:n,pullStatus:Di,trackerDetail:Y,repositoryDetail:F,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Hb,now:x,footer:je,revisionChoice:Ee,onOpenStackLayer:Se,onOpenChecks:Le,onRefresh:M,commentAttachments:Pe,threadActions:K,labelsControl:Ve,reviewersControl:Oe,reply:Te,pullLinks:ze}),e[69]=n,e[70]=ne,e[71]=x,e[72]=M,e[73]=F,e[74]=je,e[75]=Ee,e[76]=Se,e[77]=Pe,e[78]=Ve,e[79]=Oe,e[80]=Te,e[81]=ze,e[82]=K,e[83]=B):B=e[83];let ce;e[84]!==T.attachFailedChecks||e[85]!==m||e[86]!==r||e[87]!==y?(ce=s.jsx(cc,{pull:y,context:r,open:m,onOpenChange:h,onAttachFailed:T.attachFailedChecks}),e[84]=T.attachFailedChecks,e[85]=m,e[86]=r,e[87]=y,e[88]=ce):ce=e[88];const G=ee?s.jsx(Cm,{open:le,onOpenChange:O,project:{id:ee.id,path:zr(ee.path)??ee.path},initialSourceBranch:y.head,onWorktreeCreated:Kb}):null;let Ce;return e[89]!==B||e[90]!==ce||e[91]!==G?(Ce=s.jsxs(s.Fragment,{children:[B,ce,G]}),e[89]=B,e[90]=ce,e[91]=G,e[92]=Ce):Ce=e[92],Ce};function $b(t){return t.activeProjectId}function Bb(t){return t+1}function zb(){}function Wb(t){return t+1}function Ub(t){return t.projects}function Vb(t){return t.availableWorktreesByProject}function Hb(){}function qb(){}function Gb(){return!0}function Kb(t){tt.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const Zb=/^Change-Id:\s*I[0-9a-f]{40}$/,Xb=50,Yb=t=>(t.replace(/\r\n/g,`
3
3
  `).trim().split(/\n[ \t]*\n/).at(-1)??"").split(`
4
4
  `).some(r=>Zb.test(r.trim())),Jb=t=>{const e=t[0]??null,n=t.filter(r=>!Yb(r.body));return{status:"ready",commits:t.length,subject:e?.message.trim()||null,tip:e?.hash??null,missing:n.length===0?"none":n.length===1&&n[0]===e?"tip":"many",missingCount:n.length}};function Qb(t,e,n,r,o){const i=Be.c(15),[a,u]=l.useState(null);let c;i[0]!==e||i[1]!==n||i[2]!==t||i[3]!==o?(c=JSON.stringify([t,e,n,o]),i[0]=e,i[1]=n,i[2]=t,i[3]=o,i[4]=c):c=i[4];const d=c;let f,p;if(i[5]!==e||i[6]!==n||i[7]!==t||i[8]!==r||i[9]!==d?(f=()=>{if(!r||!t||!e||!n)return;let h=!1;return u({key:d,value:{status:"loading"}}),_c(t,{from:e,to:n,maxCount:Xb}).then(x=>{h||u({key:d,value:Jb(x.all)})}).catch(()=>{h||u({key:d,value:{status:"error"}})}),()=>{h=!0}},p=[e,n,t,r,d],i[5]=e,i[6]=n,i[7]=t,i[8]=r,i[9]=d,i[10]=f,i[11]=p):(f=i[10],p=i[11]),l.useEffect(f,p),!r)return null;let m;return i[12]!==d||i[13]!==a?(m=a?.key===d?a.value:{status:"loading"},i[12]=d,i[13]=a,i[14]=m):m=i[14],m}const ew=t=>{const e=Be.c(111),{preflight:n,topic:r,onTopicChange:o,hashtags:i,onHashtagsChange:a,wip:u,onWipChange:c,privateChange:d,onPrivateChange:f,onAddChangeId:p,disabled:m}=t,{t:h}=at(),x=n?.status==="ready"?n:null;let g=null;if(x?.commits===0){let L;e[0]!==h?(L=h("gitView.change.push.nothingToPush"),e[0]=h,e[1]=L):L=e[1];let pe;e[2]!==L?(pe=s.jsx("span",{className:"text-muted-foreground",children:L}),e[2]=L,e[3]=pe):pe=e[3],g=pe}else if(x?.missing==="tip"){let L;e[4]!==h?(L=h("gitView.change.changeId.missingTip"),e[4]=h,e[5]=L):L=e[5];let pe;e[6]!==L?(pe=s.jsx("span",{className:"min-w-0 flex-1 text-[var(--status-warning)]",children:L}),e[6]=L,e[7]=pe):pe=e[7];let je;e[8]!==m||e[9]!==p||e[10]!==h?(je=p?s.jsx(ft,{size:"xs",variant:"outline",className:"shrink-0",onClick:p,disabled:m,children:h("gitView.change.changeId.add")}):null,e[8]=m,e[9]=p,e[10]=h,e[11]=je):je=e[11];let Ee;e[12]!==pe||e[13]!==je?(Ee=s.jsxs(s.Fragment,{children:[pe,je]}),e[12]=pe,e[13]=je,e[14]=Ee):Ee=e[14],g=Ee}else if(x?.missing==="many"){let L;e[15]!==x.missingCount||e[16]!==h?(L=h("gitView.change.changeId.missingMany",{count:x.missingCount}),e[15]=x.missingCount,e[16]=h,e[17]=L):L=e[17];let pe;e[18]!==L?(pe=s.jsx("span",{className:"text-[var(--status-warning)]",children:L}),e[18]=L,e[19]=pe):pe=e[19],g=pe}else if(n?.status==="error"){let L;e[20]!==h?(L=h("gitView.change.push.readFailed"),e[20]=h,e[21]=L):L=e[21];let pe;e[22]!==L?(pe=s.jsx("span",{className:"text-[var(--status-error-text)]",children:L}),e[22]=L,e[23]=pe):pe=e[23],g=pe}let b;e[24]!==h?(b=h("gitView.change.push.subject"),e[24]=h,e[25]=b):b=e[25];let w;e[26]!==b?(w=s.jsx("div",{className:"typography-micro text-muted-foreground",children:b}),e[26]=b,e[27]=w):w=e[27];const S=x?.subject??void 0;let y;e[28]!==n?.status||e[29]!==x?.subject?(y=x?.subject??(n?.status==="loading"?s.jsx(se,{name:"loader-4",className:"size-3.5 animate-spin text-muted-foreground"}):null),e[28]=n?.status,e[29]=x?.subject,e[30]=y):y=e[30];let I;e[31]!==S||e[32]!==y?(I=s.jsx("div",{className:"min-h-5 truncate typography-ui-label text-foreground",title:S,children:y}),e[31]=S,e[32]=y,e[33]=I):I=e[33];let j;e[34]!==h?(j=h("gitView.change.push.subjectHint"),e[34]=h,e[35]=j):j=e[35];let R;e[36]!==j?(R=s.jsx("div",{className:"typography-micro text-muted-foreground",children:j}),e[36]=j,e[37]=R):R=e[37];let _;e[38]!==w||e[39]!==I||e[40]!==R?(_=s.jsxs("div",{className:"space-y-1",children:[w,I,R]}),e[38]=w,e[39]=I,e[40]=R,e[41]=_):_=e[41];let P;e[42]!==h?(P=h("gitView.change.push.topic"),e[42]=h,e[43]=P):P=e[43];let k;e[44]!==P?(k=s.jsx("div",{className:"typography-micro text-muted-foreground",children:P}),e[44]=P,e[45]=k):k=e[45];let N;e[46]!==o?(N=L=>o(L.target.value),e[46]=o,e[47]=N):N=e[47];let T;e[48]!==h?(T=h("gitView.change.push.optional"),e[48]=h,e[49]=T):T=e[49];let A;e[50]!==m||e[51]!==N||e[52]!==T||e[53]!==r?(A=s.jsx(Un,{value:r,onChange:N,placeholder:T,disabled:m}),e[50]=m,e[51]=N,e[52]=T,e[53]=r,e[54]=A):A=e[54];let $;e[55]!==k||e[56]!==A?($=s.jsxs("label",{className:"space-y-1",children:[k,A]}),e[55]=k,e[56]=A,e[57]=$):$=e[57];let K;e[58]!==h?(K=h("gitView.change.push.hashtags"),e[58]=h,e[59]=K):K=e[59];let q;e[60]!==K?(q=s.jsx("div",{className:"typography-micro text-muted-foreground",children:K}),e[60]=K,e[61]=q):q=e[61];let M;e[62]!==a?(M=L=>a(L.target.value),e[62]=a,e[63]=M):M=e[63];let z;e[64]!==h?(z=h("gitView.change.push.hashtagsPlaceholder"),e[64]=h,e[65]=z):z=e[65];let ne;e[66]!==m||e[67]!==i||e[68]!==M||e[69]!==z?(ne=s.jsx(Un,{value:i,onChange:M,placeholder:z,disabled:m}),e[66]=m,e[67]=i,e[68]=M,e[69]=z,e[70]=ne):ne=e[70];let H;e[71]!==q||e[72]!==ne?(H=s.jsxs("label",{className:"space-y-1",children:[q,ne]}),e[71]=q,e[72]=ne,e[73]=H):H=e[73];let V;e[74]!==$||e[75]!==H?(V=s.jsxs("div",{className:"flex flex-col gap-3",children:[$,H]}),e[74]=$,e[75]=H,e[76]=V):V=e[76];let F;e[77]!==h?(F=h("gitView.change.push.wip"),e[77]=h,e[78]=F):F=e[78];let C;e[79]!==m||e[80]!==c||e[81]!==F||e[82]!==u?(C=s.jsx(Ko,{checked:u,onChange:c,disabled:m,ariaLabel:F}),e[79]=m,e[80]=c,e[81]=F,e[82]=u,e[83]=C):C=e[83];let te;e[84]!==h?(te=h("gitView.change.push.wip"),e[84]=h,e[85]=te):te=e[85];let re;e[86]!==C||e[87]!==te?(re=s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[C,te]}),e[86]=C,e[87]=te,e[88]=re):re=e[88];let Q;e[89]!==h?(Q=h("gitView.change.push.private"),e[89]=h,e[90]=Q):Q=e[90];let ee;e[91]!==m||e[92]!==f||e[93]!==d||e[94]!==Q?(ee=s.jsx(Ko,{checked:d,onChange:f,disabled:m,ariaLabel:Q}),e[91]=m,e[92]=f,e[93]=d,e[94]=Q,e[95]=ee):ee=e[95];let le;e[96]!==h?(le=h("gitView.change.push.private"),e[96]=h,e[97]=le):le=e[97];let O;e[98]!==ee||e[99]!==le?(O=s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[ee,le]}),e[98]=ee,e[99]=le,e[100]=O):O=e[100];let Y;e[101]!==re||e[102]!==O?(Y=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[re,O]}),e[101]=re,e[102]=O,e[103]=Y):Y=e[103];let Z;e[104]!==g?(Z=s.jsx("div",{className:"flex min-h-7 items-center gap-2 typography-micro",children:g}),e[104]=g,e[105]=Z):Z=e[105];let we;return e[106]!==V||e[107]!==Y||e[108]!==Z||e[109]!==_?(we=s.jsxs("div",{className:"flex flex-col gap-3",children:[_,V,Y,Z]}),e[106]=V,e[107]=Y,e[108]=Z,e[109]=_,e[110]=we):we=e[110],we};function tw(t,e){const{git:n,sourceControl:r}=Is(),{t:o}=at(),i=Tf(),a=Nf({directory:t,branch:e,chooseContributor:i.choose}),u=Ef(t,n,r),c=async(m,h)=>{const x=u.start();if(!x)return _e.info(o("gitView.pr.toast.gitBusy")),!1;try{return await h(x),x.isCurrent()}catch(g){if(g instanceof Tm){if(g.code==="stale-runtime")return!1;const b=g.code==="review-option-invalid"?o("gitView.change.push.invalidOption"):a.errorMessage(g);return b?_e.info(b):_e.error(m),!1}return g instanceof Nm||g instanceof Em?(_e.error(m,{description:g.message||void 0}),!1):(_e.error(m,{description:g instanceof Error?g.message:String(g)}),!1)}finally{x.finish()}},d=()=>c(o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")}),async m=>{await(await a.prepare("push",{onOperation:m.onOperation}))()}),f=m=>t?c(o("gitView.change.push.toast.failed"),async h=>{await Pm({directory:t,git:n,sourceControl:r,review:m,onOperation:h.onOperation})}):Promise.resolve(!1),p=s.jsxs(s.Fragment,{children:[a.context?s.jsx(Pf,{context:a.context,onSelect:a.settle}):null,a.confirmDialog,s.jsx(If,{candidates:i.candidates,onSelect:i.settle})]});return{push:d,pushForReview:f,dialogs:p}}const sw=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"}},nw=(t,e)=>{const{currentSessionId:n,getDirectoryForSession:r}=tt.getState(),o=n?r(n):null;!n||!o||Yt(o)!==Yt(t)||zm(n,o,Wm({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},rw=t=>{const e=t?.changeRequest??t?.pr;return e?Um({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},ow=[2e3,5e3];let Ya=0;const iw=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(Ya+=1,`source-control-${Date.now().toString(36)}-${Ya.toString(36)}`)},aw=(t,e,n)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...n]),Sd="openchamber:pr-create-as-draft:v1",Ja=()=>{try{return localStorage.getItem(Sd)==="true"}catch{return!1}},lw=t=>{try{localStorage.setItem(Sd,String(t))}catch{}},Do=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Ks=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):""},cw=(t,e)=>{const n=Ks(t);if(!n||n.includes("->"))return"";if(e){const o=`${e}/`;return n.startsWith(o)?n.slice(o.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},dw=(t,e)=>`${t}::${e}`,_o=new Map,Qa=qn;function uw(t,e,n){const r=Be.c(14);let o;r[0]!==n?(o=n?_b(n):null,r[0]=n,r[1]=o):o=r[1];const i=o;let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=a):a=r[2];const[u,c]=l.useState(a);let d,f;r[3]!==i||r[4]!==t||r[5]!==n||r[6]!==e?(d=()=>{if(!t||!n||!i)return;let m=!1;return(async()=>{try{const h=await Ab(e,n);m||c({contextKey:i,detectedUpstream:h.upstream,upstreamBranches:h.branches})}catch{}})(),()=>{m=!0}},f=[i,t,n,e],r[3]=i,r[4]=t,r[5]=n,r[6]=e,r[7]=d,r[8]=f):(d=r[7],f=r[8]),l.useEffect(d,f);let p;return r[9]!==i||r[10]!==u.contextKey||r[11]!==u.detectedUpstream||r[12]!==u.upstreamBranches?(p=u.contextKey===i?{detectedUpstream:u.detectedUpstream,upstreamBranches:u.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=u.contextKey,r[11]=u.detectedUpstream,r[12]=u.upstreamBranches,r[13]=p):p=r[13],p}const fw=({directory:t,branch:e,baseBranch:n,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:a})=>{const{t:u}=at(),c=Ac(t),d=Eu(),f=Gl(E=>E.byId),p=E=>f.has(E),m=d(c?.provider),h=m.terminology.changeRequest,x=m.features.createByPush,g=l.useCallback((E,xe)=>u(Ws(E,h),xe),[h,u]),b=Pb(),{sourceControl:w,git:S}=Is(),y=_i(),I=hn(E=>E.entries),{isMobile:j,hasTouchInput:R,screenWidth:_}=yn(),P=X(E=>E.openContextSurface),k=Im(E=>E.requestTarget),N=!j&&_>=768&&!wi(),T=l.useMemo(()=>dw(t,e),[t,e]),A=l.useMemo(()=>_o.get(T)??null,[T]),$=vs(E=>E.ensureEntry),K=vs(E=>E.setParams),q=vs(E=>E.beginActiveContextsLoad),M=vs(E=>E.commitActiveContexts),z=vs(E=>E.releaseActiveContexts),ne=l.useId(),H=vs(E=>E.startWatching),V=vs(E=>E.stopWatching),F=vs(E=>E.refresh),[C,te]=l.useState(()=>A?.title??Do(e)),[re,Q]=l.useState(()=>A?.body??""),[ee,le]=l.useState(()=>A?.draft??Ja()),[O,Y]=l.useState(()=>A?.additionalContext??""),[Z,we]=l.useState(()=>A?.targetBaseBranchChosen===!0),[L,pe]=l.useState(()=>{const E=typeof A?.targetBaseBranch=="string"?Ks(A.targetBaseBranch):"";return E||Ks(n)}),je=l.useCallback(E=>{we(!0),pe(E)},[]),[Ee,Se]=l.useState(!1),[Le,Pe]=l.useState(!1),[Ve,Oe]=l.useState(""),[be,ye]=l.useState(""),[Ue,Te]=l.useState(!1),[Me,Re]=l.useState(0),[ze,B]=l.useState(!1),ce=Oc(t,w),G=ce.scope.runtimeKey;l.useEffect(()=>{if(!t)return;const E=ce.scope.runtimeKey,xe=q(E,t,ne),ue=ce.contexts.filter(it=>Ta(I[Jn(it)],it).connected);return M(E,t,ne,xe,ue),()=>{z(E,t,ne)}},[q,ce.contexts,ce.scope.runtimeKey,M,t,z,I,ne]);const J=ce.contexts[0]??null,Ne=vs(E=>{if(!J||!L)return null;const xe=Rm(E.entries,J,L);if(!xe||xe.defaultBranch===L)return null;const ue=xe.changeRequest??xe.pr??null;return ue?.state==="open"?ue:null}),Ae=hn(E=>c?E.entries[Jn(c)]?.hasChecked===!0:!1),Ie=J?.primaryRemote??null,De=l.useMemo(()=>J?Jn(J):"",[J]),We=hn(E=>E.entries[De]),Ke=J?Ta(We,J):{authChecked:We?.hasChecked??!1,connected:!1},Ze=Ke.authChecked,[Qe,qe]=l.useState(0),[et,He]=l.useState({key:"",status:"loading",capabilities:null}),[Ye,dt]=l.useState(!1),{detectedUpstream:nt,upstreamBranches:ut}=uw(t,w,J);l.useEffect(()=>{if(!J)return;let E=!1;const xe=Jn(J);return He({key:xe,status:"loading",capabilities:null}),w.capabilities(J).then(ue=>{E||He({key:xe,status:"ready",capabilities:ue})}).catch(()=>{E||He({key:xe,status:"error",capabilities:null})}),()=>{E=!0}},[Qe,J,w]);const oe=et.key===De?et:null,de=oe?.status==="ready"?oe.capabilities:null;l.useEffect(()=>{dt(!1)},[t]);const v=!!(t&&e&&n&&(e!==n||nt!==null||x)),ae=l.useMemo(()=>J?Dm(J,e):"",[e,J]),W=l.useRef(ae);W.current=ae;const me=l.useCallback((E,xe)=>E===as()&&xe===W.current,[]),he=vs(E=>E.entries[ae]),Je=l.useMemo(()=>ae?[ae]:[],[ae]);Ai(_m(Je));const Fe=he?.isLoading??!1,fe=Ke.connected?he?.status??null:null,ke=ce.error?g("settings.sourceControl.instance.status.operationFailed"):he?.error??null,rt=he?.isInitialStatusResolved??!1,ge=l.useMemo(()=>{const E=Ye?null:Ie,xe=new Set;for(const st of i){const Nt=cw(st,E);!Nt||Nt==="HEAD"||xe.add(Nt)}if(Ye)for(const st of ut)st&&st!=="HEAD"&&xe.add(st);const ue=Ks(n);ue&&ue!=="HEAD"&&xe.add(ue);const it=Ks(L);return it&&it!=="HEAD"&&xe.add(it),Array.from(xe).sort((st,Nt)=>st.localeCompare(Nt))},[n,i,Ie,L,ut,Ye]);l.useEffect(()=>{const E=Ks(n);if(!L&&E){pe(E);return}if(ge.length!==0&&!ge.includes(L)){const xe=ge.includes(E)?E:ge[0];xe&&pe(xe)}},[ge,n,L]);const lt=l.useRef([]),Ct=l.useRef(new Map),bt=l.useCallback(E=>{const xe=Ct.current.get(E);if(xe?.inFlight)return null;if(xe)return xe.inFlight=!0,xe.key;const ue=iw();return Ct.current.set(E,{key:ue,inFlight:!0}),ue},[]),kt=l.useCallback((E,xe,ue)=>{const it=Ct.current.get(E);!it||it.key!==xe||(ue?it.inFlight=!1:Ct.current.delete(E))},[]);l.useEffect(()=>{nt&&dt(!0)},[nt]),l.useEffect(()=>{Ye&&nt?.defaultBranch&&pe(nt.defaultBranch)},[Ye,nt?.defaultBranch]);const ht=fe?.changeRequest??fe?.pr??null,St=fe?.identity??J,yt=l.useMemo(()=>fe?.project??(fe?.repo&&St?{...fe.repo,...St,id:No(fe.repo.owner,fe.repo.repo),name:fe.repo.repo}:null),[fe?.project,fe?.repo,St]),xt=ht?.state==="merged"||ht?.state==="closed",vt=xt?null:ht,ct=fe?.ci?.summary??fe?.checks??null,[Pt,Dt]=l.useState(!1),pt=l.useRef(!0);l.useEffect(()=>(pt.current=!0,()=>{pt.current=!1}),[]);const mt=l.useCallback(async E=>{await F(ae,E)},[ae,F]),Ot=l.useCallback((E,xe)=>{lt.current.forEach(ue=>{window.clearTimeout(ue)}),lt.current=ow.map(ue=>window.setTimeout(()=>{me(E,xe)&&F(xe,{force:!0,silent:!0,markInitialResolved:!0})},ue))},[me,F]),Ut=l.useCallback(async(E,xe,ue)=>{await Ob({error:E,isCurrent:()=>me(xe,ue),refresh:()=>F(ue,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>Ot(xe,ue)})},[me,F,Ot]);l.useEffect(()=>{!J||!ae||($(ae),K(ae,{directory:t,branch:e,remoteName:J.primaryRemote,canShow:v,identity:J,readContext:J,sourceControl:w,authChecked:Ke.authChecked,connected:Ke.connected}))},[e,v,t,$,ae,J,w,Ke.authChecked,Ke.connected,K]);const ss=600,ps=l.useCallback(async()=>{if(Pt)return;Dt(!0);const E=Date.now();try{if(await mt({force:!0}),ht&&fe?.repo&&St){const xe={owner:fe.repo.owner,repo:fe.repo.repo,number:ht.number};await w.refreshProviderReads(St,{item:xe}).catch(()=>{})}}finally{const xe=ss-(Date.now()-E);xe>0&&await new Promise(ue=>window.setTimeout(ue,xe)),pt.current&&Dt(!1)}},[Pt,ht,mt,w,fe?.repo,St]);l.useEffect(()=>{if(!(!J||!ae))return H(ae),()=>{V(ae)}},[ae,J,H,V]),l.useEffect(()=>{const E=_o.get(T)??null;te(E?.title??Do(e)),Q(E?.body??""),le(E?.draft??Ja());const xe=E?.targetBaseBranchChosen===!0&&!!E.targetBaseBranch;we(xe),pe(xe&&E?.targetBaseBranch?Ks(E.targetBaseBranch):Ks(n))},[n,e,T]),l.useEffect(()=>{!J||!ae||!Ke.connected||mt({markInitialResolved:!0})},[ae,J,mt,Ke.connected]),l.useEffect(()=>{!v||!J||!Ke.connected||mt({force:!0,silent:!0,markInitialResolved:!0})},[v,J,mt,Ke.connected]),l.useEffect(()=>{const E=()=>{const ue=vs.getState().entries[ae]?.lastRefreshAt??0;Date.now()-ue>6e4&&mt({force:!0,silent:!0})},xe=()=>{document.visibilityState==="visible"&&E()};return window.addEventListener("focus",E),document.addEventListener("visibilitychange",xe),()=>{window.removeEventListener("focus",E),document.removeEventListener("visibilitychange",xe)}},[ae,mt]),l.useEffect(()=>{Ze&&!Ke.connected&&mt({force:!0,silent:!0,markInitialResolved:!0})},[mt,Ke.connected,Ze]),l.useEffect(()=>{!t||!e||_o.set(T,{title:C,body:re,draft:ee,additionalContext:O,targetBaseBranch:L,targetBaseBranchChosen:Z})},[T,C,re,ee,O,L,Z,t,e]),l.useEffect(()=>()=>{lt.current.forEach(E=>{window.clearTimeout(E)}),lt.current=[]},[ae,G]),l.useEffect(()=>()=>{Ct.current.clear()},[]);const ns=Ye&&nt?.defaultBranchSha?nt.defaultBranchSha:J?`${J.primaryRemote}/${L}`:L;l.useEffect(()=>{if(!t||!e||!ns)return;let E=!1;return _c(t,{from:ns,to:e,maxCount:2}).then(xe=>{const ue=xe.all.length===1?xe.all[0]?.message.trim():"";E||!ue||te(it=>it===Do(e)?ue:it)}).catch(()=>{}),()=>{E=!0}},[e,ns,t]);const ms=x?fe?.localRevision?.uploadedAs===null:!r||o>0,ls=tw(t,e),rs=Qb(t,ns,e,x&&v,Me),Rs=l.useId(),Vt=E=>{le(E),lw(E)},cs=l.useCallback(async()=>{if(!Ee&&t){Se(!0);try{const xe={base:ns,head:e,...J?.provider?{changeRequestProvider:d(J.provider)}:{}};O&&(xe.context=O);const ue=await Am(t,xe);ue.title?.trim()&&te(ue.title.trim()),ue.body?.trim()&&Q(ue.body.trim()),a?.()}catch(E){const xe=E instanceof Error?E.message:String(E);_e.error(g("gitView.pr.toast.generateDescriptionFailed"),{description:xe})}finally{Se(!1)}}},[O,e,ns,d,t,Ee,a,J,g]),Ht=l.useCallback(async()=>{if(de?.changeRequests!==!0){_e.error(g("gitView.pr.toast.createPrFailed"),{description:g("gitView.pr.capabilitiesUnavailable")});return}const E=C.trim();if(!E){_e.error(g("gitView.pr.toast.titleRequired"));return}const xe=L.trim();if(!xe){_e.error(g("gitView.pr.toast.baseBranchRequired"));return}if(!Ye&&xe===e){_e.error(g("gitView.pr.toast.baseMustDifferFromHead"));return}const ue=Ye?nt:yt;if(!J||!ue){_e.error(g("gitView.pr.toast.createPrFailed"),{description:ke??g("gitView.pr.statusUnavailable")});return}if(ms&&(Pe(!0),!await ls.push())){Pe(!1);return}const it=as(),st=ae,Nt={owner:ue.owner,name:ue.name},Rt=re.trim()?re:void 0,Et=Ye?void 0:J.primaryRemote,_t=Ye?J.primaryRemote:void 0,ys=aw(it,J,[Nt.owner,Nt.name,e,xe,E,Rt,ee,Et,_t]),sn=bt(ys);if(!sn){Pe(!1);return}Pe(!0);let So=!1,ea=!1;try{const Os={...J,idempotencyKey:sn,target:{project:Nt,head:e,base:xe},title:E,draft:ee};Rt!==void 0&&(Os.body=Rt),Et&&(Os.remote=Et),_t&&(Os.headRemote=_t);const nn=await w.changeRequestCreate(Os);if(ea=!0,kt(ys,sn,!1),!me(it,st)||(nn.result.stacked===!1?_e.warning(g("stacks.toast.createdNotStacked"),{description:g("stacks.toast.createdNotStackedDescription",{base:xe})}):_e.success(g(nn.result.stacked?"stacks.toast.createdStacked":"gitView.pr.toast.prCreated")),await mt({force:!0}),!me(it,st)))return;const wr=vs.getState().entries[st]?.status,ko=wr?.changeRequest??wr?.pr;ko&&ko.number===nn.target.number&&nw(t,ko),Ot(it,st)}catch(Os){const nn=Os instanceof Error?Os:new Error(String(Os));So=vd(nn);const wr=nn.message;_e.error(g("gitView.pr.toast.createPrFailed"),{description:wr}),So&&await Ut(nn,it,st)}finally{ea||kt(ys,sn,So),Pe(!1)}},[bt,re,e,ls,nt,t,ee,ke,kt,me,ms,ae,J,Ut,mt,Ot,w,de?.changeRequests,yt,L,C,Ye,g]),ie=async()=>{const E=L.trim();if(!E){_e.error(g("gitView.pr.toast.baseBranchRequired"));return}const xe={target:E,wip:ee,private:Ue};Ve.trim()&&(xe.topic=Ve.trim());const ue=be.split(/[\s,]+/).filter(Boolean);ue.length>0&&(xe.hashtags=ue),Pe(!0);try{if(!await ls.pushForReview(xe))return;_e.success(g("gitView.change.push.toast.pushed")),await mt({force:!0})}finally{Pe(!1)}},Ge=async E=>{Pe(!0);try{if(!await ls.pushForReview({target:E.base}))return;_e.success(g("gitView.change.push.toast.uploaded")),await mt({force:!0})}finally{Pe(!1)}},gt=S.addChangeIdToHead,jt=async()=>{const E=rs?.status==="ready"?rs.tip:null;if(!(!gt||!E||!await y.confirm({title:g("gitView.change.changeId.confirmTitle"),message:g("gitView.change.changeId.confirmMessage"),action:g("gitView.change.changeId.add")})))try{await gt(t,E),_e.success(g("gitView.change.changeId.toast.added"))}catch(ue){_e.error(g("gitView.change.changeId.toast.failed"),{description:ue instanceof Error?ue.message:String(ue)})}finally{Re(ue=>ue+1)}},It="border-0 bg-transparent rounded-none px-4 py-3";if(!v)return s.jsx("section",{className:It,children:s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:g("gitView.pullRequest.availableOnFeatureBranches")}),c?s.jsx(Db,{identity:c}):null]})});const Mt=fe?.changeRequest&&fe.changeRequest.state==="open"?fe.changeRequest:vt&&yt&&St?{...St,id:`${No(yt.owner,yt.name)}#${vt.number}`,number:vt.number,project:{...St,id:yt.id,owner:yt.owner,name:yt.name,url:yt.url??""},title:vt.title,body:vt.body,url:vt.url,state:vt.state,draft:vt.draft,base:vt.base,head:vt.head,headSha:vt.headSha,mergeable:vt.mergeable,mergeableState:vt.mergeableState}:null;if(Mt&&J){const E=s.jsx(Lb,{directory:t,context:J,changeRequest:Mt,onChanged:()=>mt({force:!0,silent:!0,markInitialResolved:!0}),statusStack:fe?.stack});if(!(x&&ms))return s.jsx("div",{className:"h-full min-h-0",children:E});const xe=Mt.revisionNumber!==void 0?Mt.revisionNumber+1:null;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-edge-muted px-4 py-2",children:[s.jsx(se,{name:"arrow-up",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:g("gitView.change.push.notUploaded")}),s.jsxs(ft,{size:"sm",className:"shrink-0",onClick:()=>{Ge(Mt)},disabled:Le,children:[Le?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(se,{name:"upload-2",className:"size-4"}),xe!==null?g("gitView.change.push.uploadPatchset",{number:xe}):g("gitView.change.push.uploadNew")]}),ls.dialogs]}),s.jsx("div",{className:"min-h-0 flex-1",children:E})]})}const Kt=yt?.url||null,Jt=Ye&&nt?.url?nt.url:Kt,gs=oe?.status==="error",Cs=!!fe?.connected,Ts=!!(!J&&c&&ce.status==="ready"&&Ae),U=!!(St&&Ze&&fe?.connected===!1)||Ts,Xe=St??c,ot=Xe?d(Xe.provider).label:null,Tt=rw(fe),Zt=Tt?`var(--pr-${Tt})`:"var(--status-info)",Ds=Tt==="draft"?"git-pr-draft":Tt==="merged"?"git-merge":Tt==="closed"?"git-close-pull-request":"git-pull-request",Xt=ht?[`${ht.state}${ht.draft?" (draft)":""}`,ht.state==="open"&&ht.mergeable===!1?g("gitView.pr.notMergeable"):null,ht.state==="open"&&typeof ht.mergeableState=="string"&&ht.mergeableState&&ht.mergeableState!=="unknown"?ht.mergeableState:null].filter(Boolean).join(" · "):"",en=ct?ct.total>0?`${ct.success}/${ct.total} ${g("gitView.pr.checks.label")}`:`${ct.state} ${g("gitView.pr.checks.label")}`:"",Sn="px-0 py-3 border-b border-edge-muted flex flex-col gap-1",tn="flex flex-col gap-3 py-3",Gn=s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Fe||Pt,onClick:()=>{ps()},"aria-label":g("gitView.pr.actions.refreshAria"),children:s.jsx(se,{name:Fe||Pt?"loader-4":"refresh",className:$e("size-4 text-muted-foreground",(Fe||Pt)&&"animate-spin")})})}),s.jsx($t,{children:s.jsx("p",{children:g("gitView.pr.actions.refresh")})})]}),yo=ze||O.trim().length>0,Kn=ms?r?o===1?g("gitView.pr.unpushed.one"):g("gitView.pr.unpushed.many",{count:o}):g("gitView.pr.unpushed.unpublished"):null,br=g(ms?ee?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":ee?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),vo=Le||!Cs||de?.changeRequests!==!0||!L.trim()||!Ye&&L.trim()===e,D=Le||!Cs||!L.trim()||rs?.status!=="ready"||rs.commits===0||rs.missing!=="none";return s.jsxs("section",{className:It,children:[ht?s.jsxs("div",{className:Sn,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs(ft,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Qa(ht.url)},"aria-label":ot?g("gitView.pr.actions.openOnProviderAria",{provider:ot}):g("gitView.header.openPullRequest"),children:[s.jsx(se,{name:Ds,className:"size-4 shrink-0",style:{color:Zt}}),ot?g("gitView.pr.actions.openOnProvider",{provider:ot}):g("gitView.header.openPullRequest")]}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.pullRequest.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ta(d(St?.provider),ht.number)})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Gn})]}),s.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Zt},children:Xt}),ct?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${sw(ct.state)}`}),en]}):null,r&&Ie&&r.split("/")[0]!==Ie?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",Ie]}):null]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:N&&J&&p(J.provider)?s.jsxs(ft,{variant:"outline",size:"sm",className:$e("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Rf),onClick:()=>{k(t,{source:{kind:"pr",number:ht.number,...yt?{sourceRepo:{owner:yt.owner,repo:yt.name}}:{}},context:J}),P(t,"walkthrough")},"aria-label":g("walkthrough.action.open"),children:[s.jsx(se,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:g("walkthrough.action.open")})]}):null})]})]}):null,s.jsxs("div",{className:tn,children:[gs?s.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[s.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:g("gitView.pr.capabilitiesUnavailable")}),s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>qe(E=>E+1),children:g("settings.sourceControl.transport.retry")})]}):null,U&&ot?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.pr.providerNotConnected",{provider:ot})}),s.jsx(ft,{variant:"outline",size:"sm",onClick:b,className:"w-fit",children:g("gitView.pr.actions.openSettings")})]}):null,ke?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:ke}),ce.error?s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>{ce.retry()},disabled:ce.status==="loading",children:g("settings.sourceControl.transport.retry")}):null,Jt?s.jsx(ft,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:Jt,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(se,{name:"external-link",className:"size-4"}),g("gitView.pr.actions.repo")]})}):null]}):null,(vt||!ht&&!rt)&&!ke&&!U&&(ce.status==="loading"||J)?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(Om,{className:"size-4"}),g("gitView.pr.checkingStatus")]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[ht&&xt?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md oc-tile-inset px-2.5 py-2",children:[s.jsx(se,{name:ht.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Zt}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:ht.state==="merged"?g("gitView.pr.history.merged",{number:ht.number,base:ht.base||L}):g("gitView.pr.history.closed",{number:ht.number})}),s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Qa(ht.url)},"aria-label":g("gitView.pr.actions.openOnProviderAria",{provider:ot}),children:s.jsx(se,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(se,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),s.jsx(se,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),Ye&&nt?s.jsx("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:No(nt.owner,nt.name)}):null,ge.length>0?s.jsxs(Mm,{value:L,onValueChange:je,children:[s.jsx(Fm,{className:"w-auto min-w-0","aria-label":g("gitView.pr.field.baseBranch"),children:s.jsx(Lm,{placeholder:g("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx($m,{children:ge.map(E=>s.jsx(Bm,{value:E,children:E},E))})]}):s.jsx(Un,{value:L,onChange:E=>je(E.target.value),placeholder:g("gitView.pr.placeholder.main"),"aria-label":g("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),s.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[Jt?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:s.jsx("a",{href:Jt,target:"_blank",rel:"noopener noreferrer","aria-label":g("gitView.pr.actions.repo"),children:s.jsx(se,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),s.jsx($t,{children:s.jsx("p",{children:g("gitView.pr.actions.repo")})})]}):null,Gn]})]}),Ne?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[s.jsx(se,{name:"stack",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:g("stacks.create.stacksOn",{reference:ta(d(J?.provider),Ne.number)})})]}):null,x?s.jsx(ew,{preflight:rs,topic:Ve,onTopicChange:Oe,hashtags:be,onHashtagsChange:ye,wip:ee,onWipChange:Vt,privateChange:Ue,onPrivateChange:Te,onAddChangeId:gt?()=>{jt()}:void 0,disabled:Le}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.title")}),s.jsx(Un,{value:C,onChange:E=>te(E.target.value),placeholder:g("gitView.pr.placeholder.title"),autoCorrect:R?"on":"off",autoCapitalize:R?"sentences":"off",spellCheck:R})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("label",{htmlFor:Rs,className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.description")}),s.jsxs("div",{className:"flex items-center",children:[s.jsxs(ft,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:cs,disabled:Ee||Le,children:[Ee?s.jsx(se,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(se,{name:"ai-generate-2",className:"size-3.5 text-primary"}),g("gitView.commit.generate")]}),s.jsxs(xn,{children:[s.jsx(bn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:Ee||Le,"aria-label":g("gitView.pr.generate.optionsAria"),children:s.jsx(se,{name:"arrow-down-s",className:"size-3.5"})})}),s.jsx(wn,{align:"end",className:"w-60",children:s.jsxs(qt,{onSelect:()=>B(!0),children:[s.jsx(se,{name:"sticky-note",className:"size-4 shrink-0"}),g("gitView.pr.generate.withNotes")]})})]})]})]}),yo?s.jsxs("div",{className:"relative",children:[s.jsx(Na,{value:O,onChange:E=>Y(E.target.value),className:"min-h-[72px] pe-9",placeholder:g("gitView.pr.placeholder.additionalContext"),"aria-label":g("gitView.pr.generate.notesAria"),autoFocus:ze&&!O}),s.jsx(ft,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{Y(""),B(!1)},"aria-label":g("gitView.pr.generate.removeNotesAria"),children:s.jsx(se,{name:"close",className:"size-3.5"})})]}):null,s.jsx(Na,{id:Rs,value:re,onChange:E=>Q(E.target.value),className:"min-h-[140px]",placeholder:g("gitView.pr.placeholder.whatChanged"),autoCorrect:R?"on":"off",autoCapitalize:R?"sentences":"off",spellCheck:R})]})]}),Kn&&!x?s.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[s.jsx(se,{name:"arrow-up",className:"size-3.5 shrink-0"}),Kn]}):null,s.jsx("div",{className:"flex justify-end",children:x?s.jsxs(ft,{size:"sm",className:"justify-center gap-2",onClick:()=>{ie()},disabled:D,children:[Le?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(se,{name:"upload-2",className:"size-4"}),s.jsx("span",{children:g("gitView.change.push.forReview")})]}):s.jsxs("div",{className:"flex items-center",children:[s.jsxs(ft,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:Ht,disabled:vo,children:[Le?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(se,{name:ee?"git-pr-draft":"git-pull-request",className:"size-4"}),s.jsx("span",{children:br})]}),s.jsxs(xn,{children:[s.jsx(bn,{asChild:!0,children:s.jsx(ft,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:Le,"aria-label":g("gitView.pr.createKindAria"),children:s.jsx(se,{name:"arrow-down-s",className:"size-4"})})}),s.jsx(wn,{align:"end",className:"w-56",children:s.jsxs(Mc,{value:ee?"draft":"ready",onValueChange:E=>Vt(E==="draft"),children:[s.jsx(Wr,{value:"ready",children:g("gitView.pr.actions.createPr")}),s.jsx(Wr,{value:"draft",children:g("gitView.pr.actions.createDraftPr")})]})})]})]})}),ls.dialogs,y.dialog]})]})]})},pw=()=>{const t=Be.c(95),{t:e}=at(),{git:n,sourceControl:r}=Is(),o=Gs();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={recheckOnOpen:!0},t[0]=i):i=t[0];const{rootIsGitRepo:a,gitDirectory:u,nestedRepos:c,repositoryOptions:d}=Vm(o??null,i),f=co(u??null),p=Hm(u??null),m=qm(u??null),h=Oc(u,r),{ensureAll:x,ensureNestedRepos:g,selectNestedRepo:b}=Vn(Qo(mw)),w=tt(hw),S=tt(gw),y=tt(xw),I=tt(bw);let j;t[1]!==o?(j=Yt(o),t[1]=o,t[2]=j):j=t[2];const R=j;let _;e:{if(!R){_=void 0;break e}let be;t[3]!==I||t[4]!==R||t[5]!==y?(be=$r(I,R)??$r(y.values(),R),t[3]=I,t[4]=R,t[5]=y,t[6]=be):be=t[6],_=be}const P=_;let k;t[7]!==w||t[8]!==P||t[9]!==S?.open||t[10]!==y?(k=()=>{if(w)return y.get(w)??P;if(S?.open)return P},t[7]=w,t[8]=P,t[9]=S?.open,t[10]=y,t[11]=k):k=t[11],S?.open;let N;t[12]!==k?(N=k(),t[12]=k,t[13]=N):N=t[13];const T=N;let A;t[14]!==w?(A=be=>w?be.getAttachment(w):void 0,t[14]=w,t[15]=A):A=t[15];const $=Nc(A),K=$&&!$.degraded&&!$.legacy?$.worktreeRoot??void 0:void 0,q=Nb(o,T,f?.current??void 0);let M,z;t[16]!==x||t[17]!==n||t[18]!==u?(M=()=>{!u||!n||x(u,n)},z=[u,x,n],t[16]=x,t[17]=n,t[18]=u,t[19]=M,t[20]=z):(M=t[19],z=t[20]),l.useEffect(M,z);const[ne,H]=l.useState(null);let V;t[21]!==K||t[22]!==q?.projectDirectory?(V=()=>{const be=K||q?.projectDirectory;if(!be){H(null);return}let ye=!1;return Gm(be).then(Ue=>{if(ye)return;const Te=Ue.trim();H(Te&&Te!=="HEAD"?Te:null)}).catch(()=>{ye||H(null)}),()=>{ye=!0}},t[21]=K,t[22]=q?.projectDirectory,t[23]=V):V=t[23];const F=q?.projectDirectory;let C;t[24]!==K||t[25]!==F?(C=[K,F],t[24]=K,t[25]=F,t[26]=C):C=t[26],l.useEffect(V,C);let te;e:{if(!p?.all){let ye;t[27]===Symbol.for("react.memo_cache_sentinel")?(ye=[],t[27]=ye):ye=t[27],te=ye;break e}let be;t[28]!==p.all?(be=p.all.filter(ww).sort(),t[28]=p.all,t[29]=be):be=t[29],te=be}const re=te;let Q;e:{if(!p?.all){let ye;t[30]===Symbol.for("react.memo_cache_sentinel")?(ye=[],t[30]=ye):ye=t[30],Q=ye;break e}let be;t[31]!==p.all?(be=p.all.filter(yw).map(vw).sort(),t[31]=p.all,t[32]=be):be=t[32],Q=be}const ee=Q,le=f?.current??null,O=h.contexts[0]?.primaryRemote,Y=O?p?.defaultBranches?.[O]:void 0;let Z;t[33]!==h.contexts[0]||t[34]!==h.read?.repository.remotes||t[35]!==le||t[36]!==Y||t[37]!==re||t[38]!==ne||t[39]!==q?.createdFromBranch?(Z=()=>_f({remoteNames:new Set(h.contexts[0]?.primaryRemote?[h.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(h.read?.repository.remotes.map(Sw)??[]),localBranches:re,worktreeCreatedFromBranch:q?.createdFromBranch,rootBranchHint:ne,defaultBranch:Y,headBranch:le,fallbackToConventional:!1}),t[33]=h.contexts[0],t[34]=h.read?.repository.remotes,t[35]=le,t[36]=Y,t[37]=re,t[38]=ne,t[39]=q?.createdFromBranch,t[40]=Z):Z=t[40],q?.createdFromBranch;let we;t[41]!==Z?(we=Z(),t[41]=Z,t[42]=we):we=t[42];const pe=Df(u??null,le,!0,h,p,we),je=Kl(Ac(o??null)?.provider);if(!o){let be;t[43]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(se,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[43]=be):be=t[43];let ye;t[44]!==je||t[45]!==e?(ye=e(Ws("gitView.pullRequest.title",je)),t[44]=je,t[45]=e,t[46]=ye):ye=t[46];let Ue;t[47]!==ye?(Ue=s.jsx("div",{className:"typography-ui-header text-foreground",children:ye}),t[47]=ye,t[48]=Ue):Ue=t[48];let Te;t[49]!==je||t[50]!==e?(Te=e(Ws("gitView.pullRequest.createHint",je)),t[49]=je,t[50]=e,t[51]=Te):Te=t[51];let Me;t[52]!==Te?(Me=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Te}),t[52]=Te,t[53]=Me):Me=t[53];let Re;return t[54]!==Ue||t[55]!==Me?(Re=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,Ue,Me]}),t[54]=Ue,t[55]=Me,t[56]=Re):Re=t[56],Re}if(a===!1&&m!==!0){let be;t[57]!==o||t[58]!==g?(be=()=>{g(o,{force:!0})},t[57]=o,t[58]=g,t[59]=be):be=t[59];let ye;return t[60]!==o||t[61]!==m||t[62]!==c||t[63]!==a||t[64]!==be?(ye=s.jsx(Af,{root:o,rootIsGitRepo:a,resolvedIsGitRepo:m,nestedRepos:c,onRetryDiscovery:be}),t[60]=o,t[61]=m,t[62]=c,t[63]=a,t[64]=be,t[65]=ye):ye=t[65],ye}if(!le){let be;t[66]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(se,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[66]=be):be=t[66];let ye;t[67]!==je||t[68]!==e?(ye=e(Ws("gitView.pullRequest.title",je)),t[67]=je,t[68]=e,t[69]=ye):ye=t[69];let Ue;t[70]!==ye?(Ue=s.jsx("div",{className:"typography-ui-header text-foreground",children:ye}),t[70]=ye,t[71]=Ue):Ue=t[71];let Te;t[72]!==je||t[73]!==e?(Te=e(Ws("gitView.pullRequest.createHint",je)),t[72]=je,t[73]=e,t[74]=Te):Te=t[74];let Me;t[75]!==Te?(Me=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Te}),t[75]=Te,t[76]=Me):Me=t[76];let Re;return t[77]!==Ue||t[78]!==Me?(Re=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,Ue,Me]}),t[77]=Ue,t[78]=Me,t[79]=Re):Re=t[79],Re}let Ee;t[80]!==o||t[81]!==u||t[82]!==d||t[83]!==b?(Ee=d?s.jsx("div",{className:"flex shrink-0 items-center border-b border-edge px-4 py-2",children:s.jsx(Of,{repositories:d,selectedRepository:u??null,onSelectRepository:be=>{o&&b(o,be)},repositoryRoot:o??void 0})}):null,t[80]=o,t[81]=u,t[82]=d,t[83]=b,t[84]=Ee):Ee=t[84];const Se=u??o,Le=f?.tracking??void 0,Pe=f?.ahead??0;let Ve;t[85]!==pe||t[86]!==le||t[87]!==ee||t[88]!==Se||t[89]!==Le||t[90]!==Pe?(Ve=s.jsx(fs,{as:Km,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(fw,{directory:Se,branch:le,baseBranch:pe,trackingBranch:Le,ahead:Pe,remoteBranches:ee})}),t[85]=pe,t[86]=le,t[87]=ee,t[88]=Se,t[89]=Le,t[90]=Pe,t[91]=Ve):Ve=t[91];let Oe;return t[92]!==Ee||t[93]!==Ve?(Oe=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Ee,Ve]}),t[92]=Ee,t[93]=Ve,t[94]=Oe):Oe=t[94],Oe};function mw(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function hw(t){return t.currentSessionId}function gw(t){return t.newSessionDraft}function xw(t){return t.worktreeMetadata}function bw(t){return t.availableWorktrees}function ww(t){return!t.startsWith("remotes/")}function yw(t){return t.startsWith("remotes/")}function vw(t){return t.replace(/^remotes\//,"")}function Sw(t){return t.name}const kd=[],kw=t=>{const e=Be.c(17),n=Oi(),r=Fc();let o;e[0]!==t.url||e[1]!==r||e[2]!==n?(o=Lc(t.url,n,r),e[0]=t.url,e[1]=r,e[2]=n,e[3]=o):o=e[3];const i=o;Mf(t.visible);const{panelDirectory:a,tabId:u,url:c}=t;let d;e[4]!==a||e[5]!==u||e[6]!==c?(d=()=>{sh(a,u)&&(qn(c),X.getState().closeContextPanelTab(a,u))},e[4]=a,e[5]=u,e[6]=c,e[7]=d):d=e[7];const f=d;let p;e[8]!==a||e[9]!==u?(p=()=>nh(a,u),e[8]=a,e[9]=u,e[10]=p):p=e[10];const m=p;let h;if(e[11]!==f||e[12]!==t||e[13]!==m||e[14]!==i||e[15]!==c){const x=i?i.source==="tracker"?s.jsx(Cw,{url:c,provider:i.provider,identifier:i.identifier,visible:t.visible,onUnavailable:f,onShown:m}):s.jsx(jw,{...t,kind:i.kind,onUnavailable:f,onShown:m}):s.jsx(Vi,{url:c});h=s.jsx("div",{className:"h-full min-h-0",children:x}),e[11]=f,e[12]=t,e[13]=m,e[14]=i,e[15]=c,e[16]=h}else h=e[16];return h},nr=t=>{const e=Be.c(8),{message:n,onRetry:r}=t,{t:o}=at();let i;e[0]!==n?(i=s.jsx("span",{children:n}),e[0]=n,e[1]=i):i=e[1];let a;e[2]!==r||e[3]!==o?(a=r?s.jsx(ft,{size:"sm",variant:"outline",onClick:r,children:o("references.picker.actions.retry")}):null,e[2]=r,e[3]=o,e[4]=a):a=e[4];let u;return e[5]!==i||e[6]!==a?(u=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,a]}),e[5]=i,e[6]=a,e[7]=u):u=e[7],u},Vi=t=>{const e=Be.c(14),{url:n}=t,{t:r}=at();let o;e[0]!==r?(o=r("contextPanel.tracker.unavailable"),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=s.jsx("span",{children:o}),e[2]=o,e[3]=i):i=e[3];let a;e[4]!==n?(a=()=>{qn(n)},e[4]=n,e[5]=a):a=e[5];let u;e[6]!==r?(u=r("contextPanel.preview.actions.openExternal"),e[6]=r,e[7]=u):u=e[7];let c;e[8]!==a||e[9]!==u?(c=s.jsx(ft,{size:"sm",variant:"outline",onClick:a,children:u}),e[8]=a,e[9]=u,e[10]=c):c=e[10];let d;return e[11]!==i||e[12]!==c?(d=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,c]}),e[11]=i,e[12]=c,e[13]=d):d=e[13],d},jw=t=>{const e=Be.c(131),{url:n,directory:r,panelDirectory:o,foreign:i,visible:a,kind:u,onUnavailable:c,onShown:d}=t,{t:f}=at(),{sourceControl:p}=Is(),m=Gt(Tw),h=Lf(r,n),x=h.directory,g=h.status==="ready";let b;e[0]!==u||e[1]!==x||e[2]!==g||e[3]!==n?(b={enabled:g,directory:x,kind:u,filter:Pa,query:n},e[0]=u,e[1]=x,e[2]=g,e[3]=n,e[4]=b):b=e[4];const w=Ea(b),S=Oi();let y;e[5]!==n||e[6]!==S?(y=He=>He.find(Ye=>rh(Ye.url,n,S))??null,e[5]=n,e[6]=S,e[7]=y):y=e[7];const I=y;let j;if(e[8]!==u||e[9]!==n||e[10]!==S){const He=u==="issue"?Ym(n,S):null,Ye=S.match(n);j=He?.descriptor.terminology.sharedNumberSpace&&Ye?Jm(He,"pull",Ye.number):null,e[8]=u,e[9]=n,e[10]=S,e[11]=j}else j=e[11];const R=j,_=(w.status==="ready"||w.status==="unavailable")&&!w.refreshing,[P,k]=Wt.useState(null),N=P===n;R&&!N&&_&&!I(w.items)&&k(n);const T=N&&R!==null&&h.status==="ready",A=R??"";let $;e[12]!==x||e[13]!==T||e[14]!==A?($={enabled:T,directory:x,kind:"pull",filter:Pa,query:A},e[12]=x,e[13]=T,e[14]=A,e[15]=$):$=e[15];const K=Ea($),q=N?K:w;let M;e[16]!==q.items||e[17]!==I?(M=I(q.items),e[16]=q.items,e[17]=I,e[18]=M):M=e[18];const z=M;let ne;if(e[19]!==q.followed||e[20]!==z?.number){let He;e[22]!==z?.number?(He=Ye=>!oh(Ye)&&Ye.number===z?.number,e[22]=z?.number,e[23]=He):He=e[23],ne=q.followed.filter(He),e[19]=q.followed,e[20]=z?.number,e[21]=ne}else ne=e[21];Ai(a?ne:kd);const V=Qm(x),F=V&&V!=="missing"?V:null,C=(q.status==="ready"||q.status==="unavailable")&&!q.refreshing&&!z;let te,re;e[24]!==c||e[25]!==C?(te=()=>{C&&c()},re=[c,C],e[24]=c,e[25]=C,e[26]=te,e[27]=re):(te=e[26],re=e[27]),Wt.useEffect(te,re);const Q=z!==null;let ee,le;e[28]!==Q||e[29]!==d?(ee=()=>{Q&&d()},le=[Q,d],e[28]=Q,e[29]=d,e[30]=ee,e[31]=le):(ee=e[30],le=e[31]),Wt.useEffect(ee,le);const{detail:O,refresh:Y}=Rc(x,z,!0);let Z;e[32]!==z?(Z=z?[z]:[],e[32]=z,e[33]=Z):Z=e[33];const we=eh(x,Z),L=ic(z),[pe,je]=Wt.useState(!1),Ee=Pi(),{retry:Se}=q;let Le;e[34]!==Y||e[35]!==Se?(Le=()=>Promise.all([Y(),Se()]).then(Nw),e[34]=Y,e[35]=Se,e[36]=Le):Le=e[36];const Pe=Le,Ve=ac(z,F,Pe),Oe=Ii(),be=O.status==="ready"?O.value.pull?.stack??null:null;let ye;e[37]!==F||e[38]!==z||e[39]!==Pe||e[40]!==p?(ye=async()=>{if(F&&z){const He={owner:z.sourceRepo.owner,repo:z.sourceRepo.repo,number:z.number};await p.refreshProviderReads(F,{item:He}).catch(Ew),Dc(He)}await Pe()},e[37]=F,e[38]=z,e[39]=Pe,e[40]=p,e[41]=ye):ye=e[41];const Ue=ye;if(!z){if(C){let Ye;return e[42]!==n?(Ye=s.jsx(Vi,{url:n}),e[42]=n,e[43]=Ye):Ye=e[43],Ye}if(h.status==="failed"){let Ye;e[44]!==f?(Ye=f("gitView.empty.discoverFailed"),e[44]=f,e[45]=Ye):Ye=e[45];let dt;return e[46]!==h.retry||e[47]!==Ye?(dt=s.jsx(nr,{message:Ye,onRetry:h.retry}),e[46]=h.retry,e[47]=Ye,e[48]=dt):dt=e[48],dt}let He;return e[49]!==q.error||e[50]!==q.status||e[51]!==Se||e[52]!==f?(He=q.status==="error"?s.jsx(nr,{message:q.error??f("contextPanel.tracker.loadFailed"),onRetry:()=>{Se()}}):s.jsx(nr,{message:f("common.loading")}),e[49]=q.error,e[50]=q.status,e[51]=Se,e[52]=f,e[53]=He):He=e[53],He}let Te;e[54]!==z?(Te={source:"repository",reference:z},e[54]=z,e[55]=Te):Te=e[55];const Me=Te,Re=z.kind==="pull"?z:null;let ze;e[56]!==Re||e[57]!==we?(ze=Re?we(Re):Di,e[56]=Re,e[57]=we,e[58]=ze):ze=e[58];let B;e[59]===Symbol.for("react.memo_cache_sentinel")?(B={status:"idle"},e[59]=B):B=e[59];let ce;e[60]!==Pe?(ce=()=>{Pe()},e[60]=Pe,e[61]=ce):ce=e[61];let G;e[62]!==F||e[63]!==Me||e[64]!==be||e[65]!==ce?(G=s.jsx(ji,{item:Me,project:null,context:F,onStartWorktree:Iw,onChanged:ce,worktreeAvailable:!1,stack:be}),e[62]=F,e[63]=Me,e[64]=be,e[65]=ce,e[66]=G):G=e[66];let Ce;e[67]!==r||e[68]!==Oe?(Ce=He=>{Oe(He.url,r)},e[67]=r,e[68]=Oe,e[69]=Ce):Ce=e[69];let J;e[70]!==F||e[71]!==Re?(J=Re&&F?()=>je(!0):void 0,e[70]=F,e[71]=Re,e[72]=J):J=e[72];const Ne=F?Ue:void 0;let Ae;e[73]!==F||e[74]!==O.status||e[75]!==O.value||e[76]!==Me||e[77]!==z||e[78]!==Pe?(Ae=z.state!=="merged"&&F&&(z.kind!=="discussion"||th(z,O.status==="ready"?O.value.discussion:void 0))?s.jsx($f,{item:Me,context:F,onChanged:()=>{Pe()}}):void 0,e[73]=F,e[74]=O.status,e[75]=O.value,e[76]=Me,e[77]=z,e[78]=Pe,e[79]=Ae):Ae=e[79];let Ie;e[80]!==L.attachComment||e[81]!==L.attachComments?(Ie={onAttach:L.attachComment,onAttachAll:L.attachComments},e[80]=L.attachComment,e[81]=L.attachComments,e[82]=Ie):Ie=e[82];let De;e[83]!==F||e[84]!==z||e[85]!==Pe?(De=F?s.jsx(dc,{reference:z,context:F,onChanged:Pe}):void 0,e[83]=F,e[84]=z,e[85]=Pe,e[86]=De):De=e[86];let We;e[87]!==F||e[88]!==O||e[89]!==Re||e[90]!==Pe?(We=Re&&F?s.jsx(uc,{pull:Re,detail:O,context:F,onChanged:Pe}):void 0,e[87]=F,e[88]=O,e[89]=Re,e[90]=Pe,e[91]=We):We=e[91];let Ke;e[92]!==F||e[93]!==O.status||e[94]!==O.value||e[95]!==z||e[96]!==Pe?(Ke=F&&(O.status!=="ready"||O.value.discussion?.canComment!==!1)?s.jsx(lc,{reference:z,context:F,onRefresh:Pe}):void 0,e[92]=F,e[93]=O.status,e[94]=O.value,e[95]=z,e[96]=Pe,e[97]=Ke):Ke=e[97];let Ze;e[98]!==m||e[99]!==F||e[100]!==r||e[101]!==i||e[102]!==o||e[103]!==Re||e[104]!==x?(Ze=Re&&F?s.jsx(fc,{pull:Re,project:{id:m??"",path:r},repository:x,context:F,projectOwnsDirectory:()=>!i,currentDirectory:o}):null,e[98]=m,e[99]=F,e[100]=r,e[101]=i,e[102]=o,e[103]=Re,e[104]=x,e[105]=Ze):Ze=e[105];let Qe;e[106]!==O||e[107]!==Me||e[108]!==Ee||e[109]!==x||e[110]!==ze||e[111]!==G||e[112]!==Ce||e[113]!==J||e[114]!==Ne||e[115]!==Ae||e[116]!==Ie||e[117]!==De||e[118]!==We||e[119]!==Ke||e[120]!==Ze||e[121]!==Ve?(Qe=s.jsx(Ri,{item:Me,directory:x,pullStatus:ze,trackerDetail:B,repositoryDetail:O,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Pw,now:Ee,footer:G,onOpenStackLayer:Ce,onOpenChecks:J,onRefresh:Ne,threadActions:Ve,stateMenu:Ae,commentAttachments:Ie,labelsControl:De,reviewersControl:We,reply:Ke,pullLinks:Ze}),e[106]=O,e[107]=Me,e[108]=Ee,e[109]=x,e[110]=ze,e[111]=G,e[112]=Ce,e[113]=J,e[114]=Ne,e[115]=Ae,e[116]=Ie,e[117]=De,e[118]=We,e[119]=Ke,e[120]=Ze,e[121]=Ve,e[122]=Qe):Qe=e[122];let qe;e[123]!==L.attachFailedChecks||e[124]!==pe||e[125]!==F||e[126]!==Re?(qe=Re&&F?s.jsx(cc,{pull:Re,context:F,open:pe,onOpenChange:je,onAttachFailed:L.attachFailedChecks}):null,e[123]=L.attachFailedChecks,e[124]=pe,e[125]=F,e[126]=Re,e[127]=qe):qe=e[127];let et;return e[128]!==Qe||e[129]!==qe?(et=s.jsxs(s.Fragment,{children:[Qe,qe]}),e[128]=Qe,e[129]=qe,e[130]=et):et=e[130],et},Cw=t=>{const e=Be.c(50),{url:n,provider:r,identifier:o,visible:i,onUnavailable:a,onShown:u}=t,{t:c}=at(),d=Zm(r);let f;e[0]!==o||e[1]!==r||e[2]!==d?(f=d==="ready"?{provider:r,id:o}:null,e[0]=o,e[1]=r,e[2]=d,e[3]=f):f=e[3];const{detail:p,refresh:m,followed:h}=Xm(f,!0);Ai(i?h:kd);const x=Ii(),g=Pi(),b=d!=="ready",w=p.status==="error",S=p.status==="ready";let y,I;e[4]!==b||e[5]!==w||e[6]!==a?(y=()=>{(b||w)&&a()},I=[b,w,a],e[4]=b,e[5]=w,e[6]=a,e[7]=y,e[8]=I):(y=e[7],I=e[8]),Wt.useEffect(y,I);let j,R;if(e[9]!==u||e[10]!==S?(j=()=>{S&&u()},R=[u,S],e[9]=u,e[10]=S,e[11]=j,e[12]=R):(j=e[11],R=e[12]),Wt.useEffect(j,R),b){let M;return e[13]!==n?(M=s.jsx(Vi,{url:n}),e[13]=n,e[14]=M):M=e[14],M}if(p.status==="error"){let M;e[15]!==p.error||e[16]!==c?(M=p.error||c("contextPanel.tracker.loadFailed"),e[15]=p.error,e[16]=c,e[17]=M):M=e[17];let z;e[18]!==m?(z=()=>{m()},e[18]=m,e[19]=z):z=e[19];let ne;return e[20]!==M||e[21]!==z?(ne=s.jsx(nr,{message:M,onRetry:z}),e[20]=M,e[21]=z,e[22]=ne):ne=e[22],ne}if(p.status!=="ready"){let M;e[23]!==c?(M=c("common.loading"),e[23]=c,e[24]=M):M=e[24];let z;return e[25]!==M?(z=s.jsx(nr,{message:M}),e[25]=M,e[26]=z):z=e[26],z}let _;e[27]!==p.value||e[28]!==r?(_={source:"tracker",provider:r,item:p.value},e[27]=p.value,e[28]=r,e[29]=_):_=e[29];const P=_;let k;e[30]===Symbol.for("react.memo_cache_sentinel")?(k={status:"idle"},e[30]=k):k=e[30];let N;e[31]!==m?(N=()=>{m()},e[31]=m,e[32]=N):N=e[32];let T;e[33]!==P||e[34]!==N?(T=s.jsx(ji,{item:P,project:null,context:null,onStartWorktree:Dw,onChanged:N,worktreeAvailable:!1}),e[33]=P,e[34]=N,e[35]=T):T=e[35];let A;e[36]!==m?(A=()=>{m()},e[36]=m,e[37]=A):A=e[37];let $;e[38]!==p.value||e[39]!==A?($=s.jsx(Ff,{item:p.value,onChanged:A}),e[38]=p.value,e[39]=A,e[40]=$):$=e[40];let K;e[41]!==x?(K=M=>{x(M.url,null)},e[41]=x,e[42]=K):K=e[42];let q;return e[43]!==p||e[44]!==P||e[45]!==g||e[46]!==$||e[47]!==K||e[48]!==T?(q=s.jsx(Ri,{item:P,directory:null,pullStatus:Di,trackerDetail:p,repositoryDetail:k,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:Rw,now:g,footer:T,trackerStateControl:$,onOpenTrackerItem:K}),e[43]=p,e[44]=P,e[45]=g,e[46]=$,e[47]=K,e[48]=T,e[49]=q):q=e[49],q};function Tw(t){return t.activeProjectId}function Nw(){}function Ew(){}function Pw(){}function Iw(){}function Rw(){}function Dw(){}const Hr=new Map,_w=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Aw=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},Ow=(t,e)=>{if(e.length===0)return Hr;const n=new Set(e),r=new Map,o=new Map;for(const i of t)for(const a of i.session){if(!n.has(a.id))continue;const u=a.title?.trim();if(!u)continue;const c=Aw(a),d=r.get(a.id);d!==void 0&&d>c||(r.set(a.id,c),o.set(a.id,u))}return o.size===0?Hr:o},ho=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Mw=t=>t.kind==="record",Fw=t=>{const e=Be.c(5),{node:n}=t,r=n.tone==="string"?"text-foreground":"font-mono text-muted-foreground";let o;e[0]!==r?(o=$e("whitespace-pre-wrap break-words",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==n.text||e[3]!==o?(i=s.jsx("span",{dir:"auto",className:o,children:n.text}),e[2]=n.text,e[3]=o,e[4]=i):i=e[4],i},Lw=t=>{const e=Be.c(4),{node:n}=t;let r;e[0]!==n.entries?(r=n.entries.map($w),e[0]=n.entries,e[1]=r):r=e[1];let o;return e[2]!==r?(o=s.jsx("dl",{className:"flex flex-col gap-1.5",children:r}),e[2]=r,e[3]=o):o=e[3],o},go=t=>{const e=Be.c(13),{node:n}=t;if(n.kind==="scalar"){let i;return e[0]!==n?(i=s.jsx(Fw,{node:n}),e[0]=n,e[1]=i):i=e[1],i}if(n.kind==="record"){let i;return e[2]!==n?(i=s.jsx(Lw,{node:n}),e[2]=n,e[3]=i):i=e[3],i}if(n.items.length===0){let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"font-mono text-muted-foreground",children:"[]"}),e[4]=i):i=e[4],i}if(n.items.every(Mw)){let i;e[5]!==n.items?(i=n.items.map(Bw),e[5]=n.items,e[6]=i):i=e[6];let a;return e[7]!==i?(a=s.jsx("div",{className:"flex flex-col gap-1.5",children:i}),e[7]=i,e[8]=a):a=e[8],a}let r;e[9]!==n.items?(r=n.items.map(zw),e[9]=n.items,e[10]=r):r=e[10];let o;return e[11]!==r?(o=s.jsx("ul",{className:"flex list-disc flex-col gap-0.5 ps-4",children:r}),e[11]=r,e[12]=o):o=e[12],o},jd=t=>{const e=Be.c(16),{answer:n}=t,{t:r}=at(),[o,i]=l.useState(!1);if(n.kind==="text"){let p;return e[0]!==n.text?(p=s.jsx(ih,{content:n.text,singleTilde:!1,className:"typography-markdown-body",enableFileReferences:!1}),e[0]=n.text,e[1]=p):p=e[1],p}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>i(Ww),e[2]=a):a=e[2];let u;e[3]!==o||e[4]!==r?(u=r(o?"workflows.panel.answer.formatted":"workflows.panel.answer.raw"),e[3]=o,e[4]=r,e[5]=u):u=e[5];let c;e[6]!==o||e[7]!==u?(c=s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"button",onClick:a,"aria-pressed":o,className:"typography-micro text-muted-foreground hover:text-foreground",children:u})}),e[6]=o,e[7]=u,e[8]=c):c=e[8];let d;e[9]!==n.tree||e[10]!==n.value||e[11]!==o?(d=o?s.jsx("pre",{dir:"ltr",className:"overflow-x-auto whitespace-pre-wrap break-words font-mono typography-meta text-foreground",children:JSON.stringify(n.value,null,2)}):s.jsx(go,{node:n.tree}),e[9]=n.tree,e[10]=n.value,e[11]=o,e[12]=d):d=e[12];let f;return e[13]!==c||e[14]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[13]=c,e[14]=d,e[15]=f):f=e[15],f};function $w(t){const[e,n]=t,r=n.kind==="scalar"&&n.text.length<=60&&!n.text.includes(`
5
- `);return s.jsxs("div",{className:$e("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[s.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),s.jsx("dd",{className:"min-w-0 typography-meta",children:s.jsx(go,{node:n})})]},e)}function Bw(t,e){return s.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:s.jsx(go,{node:t})},e)}function zw(t,e){return s.jsx("li",{className:"typography-meta",children:s.jsx(go,{node:t})},e)}function Ww(t){return!t}const Cd=t=>t.slice(t.indexOf("/")+1),Hi=t=>{const e=Be.c(7),{start:n,end:r,className:o}=t,i=ph(n!==void 0&&r===void 0);if(n===void 0)return null;let a;e[0]!==o?(a=$e("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const u=(r??i)-n;let c;e[2]!==u?(c=mh(u),e[2]=u,e[3]=c):c=e[3];let d;return e[4]!==a||e[5]!==c?(d=s.jsx("span",{className:a,dir:"auto",children:c}),e[4]=a,e[5]=c,e[6]=d):d=e[6],d},Uw=t=>{const e=t.flatMap(o=>o.startedAt===void 0||o.replayed?[]:[o.startedAt]);if(e.length===0)return{start:void 0,end:void 0};const n=t.some(o=>o.state==="running"||o.state==="queued"),r=t.flatMap(o=>o.endedAt===void 0?[]:[o.endedAt]);return{start:Math.min(...e),end:n?void 0:Math.max(...r,...e)}},Vw=t=>{const e=Be.c(18),{run:n,groups:r}=t,{t:o}=at();let i,a,u,c,d,f;if(e[0]!==r||e[1]!==n||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const m=r.filter(Xw);if(m.length===0){f=null;break e}i=fs,a="overlay-scrollbar-wrapper--no-gutter",u=!1,c="flex gap-1.5 pb-1";let h;e[9]!==n||e[10]!==o?(h=x=>{const g=x.agents.length,b=Uw(x.agents),w=n.state==="running"&&n.currentPhase===x.title;return s.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[s.jsx("div",{className:$e("truncate typography-meta",w?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?s.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):s.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?s.jsx(Hi,{start:b.start,end:b.end,className:"ms-auto"}):null]}),s.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?s.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(x.done/g*100)}%`,background:x.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},x.title)},e[9]=n,e[10]=o,e[11]=h):h=e[11],d=m.map(h)}e[0]=r,e[1]=n,e[2]=o,e[3]=i,e[4]=a,e[5]=u,e[6]=c,e[7]=d,e[8]=f}else i=e[3],a=e[4],u=e[5],c=e[6],d=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[12]!==i||e[13]!==a||e[14]!==u||e[15]!==c||e[16]!==d?(p=s.jsx(i,{outerClassName:a,fillContainer:u,className:c,children:d}),e[12]=i,e[13]=a,e[14]=u,e[15]=c,e[16]=d,e[17]=p):p=e[17],p},Hw=t=>{const e=Be.c(30),{run:n,agent:r,onOpenSession:o}=t,{t:i}=at(),[a,u]=l.useState(null),[c,d]=l.useState(!1),[f,p]=l.useState(!1);let m;e[0]!==r.key||e[1]!==n.id?(m=()=>{let I=!0;return d(!1),hh(n.id,r.key).then(j=>{I&&u(j)}).catch(()=>{I&&d(!0)}),()=>{I=!1}},e[0]=r.key,e[1]=n.id,e[2]=m):m=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==n.id?(h=[r.key,r.state,n.id],e[3]=r.key,e[4]=r.state,e[5]=n.id,e[6]=h):h=e[6],l.useEffect(m,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?s.jsx("p",{className:"typography-meta",style:{color:r.state==="failed"?"var(--status-error)":void 0},children:r.error}):null,e[7]=r.error,e[8]=r.state,e[9]=x):x=e[9];let g;e[10]!==c||e[11]!==i?(g=c?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.loadFailed")}):null,e[10]=c,e[11]=i,e[12]=g):g=e[12];let b;e[13]!==a||e[14]!==c||e[15]!==i?(b=!a&&!c?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),s.jsx(Li,{})]}):null,e[13]=a,e[14]=c,e[15]=i,e[16]=b):b=e[16];let w;e[17]!==a||e[18]!==f||e[19]!==i?(w=a?s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),s.jsx("div",{className:"mt-1",children:a.result===void 0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):s.jsx(jd,{answer:a.result})})]}),s.jsxs("section",{children:[s.jsxs("button",{type:"button",onClick:()=>p(Yw),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:$e("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]}),f?s.jsx(fs,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:!0,children:a.prompt}):null]})]}):null,e[17]=a,e[18]=f,e[19]=i,e[20]=w):w=e[20];let S;e[21]!==o||e[22]!==i?(S=o?s.jsx("div",{children:s.jsxs(ft,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}):null,e[21]=o,e[22]=i,e[23]=S):S=e[23];let y;return e[24]!==x||e[25]!==g||e[26]!==b||e[27]!==w||e[28]!==S?(y=s.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[x,g,b,w,S]}),e[24]=x,e[25]=g,e[26]=b,e[27]=w,e[28]=S,e[29]=y):y=e[29],y},qw=t=>{const e=Be.c(57),{run:n,agent:r,showModel:o,columns:i,open:a,onToggle:u,onOpenSession:c}=t,{t:d}=at();let f,p,m,h,x,g,b,w,S,y,I;if(e[0]!==r||e[1]!==i.tokens||e[2]!==u||e[3]!==a||e[4]!==o||e[5]!==d){const k=uh(r.state),N=fh(r);f="button",h=u,x=a,g=r.label,b="flex h-7 w-full min-w-0 items-center gap-2 rounded-md text-start typography-meta text-foreground/80 hover:text-foreground";const T=k.icon,A=k.color?{color:k.color}:void 0,$=d(k.labelKey);e[17]!==k||e[18]!==A||e[19]!==$?(w=s.jsx(se,{name:T,className:"size-3.5 shrink-0",style:A,"aria-label":$}),e[17]=k,e[18]=A,e[19]=$,e[20]=w):w=e[20],e[21]!==r.label?(S=s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=S):S=e[22],e[23]!==r.replayed||e[24]!==d?(y=r.replayed?s.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:d("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=d,e[25]=y):y=e[25],e[26]!==r.model||e[27]!==o?(I=o&&r.model?s.jsx("span",{className:"oc-tile-inset max-w-[9rem] shrink-0 truncate rounded-full px-1.5 typography-micro text-muted-foreground",title:r.model,dir:"ltr",children:Cd(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=I):I=e[28];const K=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==K?(p=s.jsx(Hi,{start:K,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=K,e[31]=p):p=e[31],m=i.tokens?s.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:N===null||r.replayed?"":Mi(N)}):null,e[0]=r,e[1]=i.tokens,e[2]=u,e[3]=a,e[4]=o,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=x,e[11]=g,e[12]=b,e[13]=w,e[14]=S,e[15]=y,e[16]=I}else f=e[6],p=e[7],m=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13],S=e[14],y=e[15],I=e[16];let j;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(j=i.cost?s.jsx("span",{className:"min-w-14 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"ltr",children:r.usage&&!r.replayed&&r.usage.cost>0?Fi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=j):j=e[35];let R;e[36]!==f||e[37]!==p||e[38]!==m||e[39]!==j||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==b||e[44]!==w||e[45]!==S||e[46]!==y||e[47]!==I?(R=s.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:b,children:[w,S,y,I,p,m,j]}),e[36]=f,e[37]=p,e[38]=m,e[39]=j,e[40]=h,e[41]=x,e[42]=g,e[43]=b,e[44]=w,e[45]=S,e[46]=y,e[47]=I,e[48]=R):R=e[48];let _;e[49]!==r||e[50]!==c||e[51]!==a||e[52]!==n?(_=a?s.jsx(Hw,{run:n,agent:r,onOpenSession:c}):null,e[49]=r,e[50]=c,e[51]=a,e[52]=n,e[53]=_):_=e[53];let P;return e[54]!==R||e[55]!==_?(P=s.jsxs(s.Fragment,{children:[R,_]}),e[54]=R,e[55]=_,e[56]=P):P=e[56],P},Gw=(t,e)=>{const n=dh(t);if(n.measured===0)return null;const r=[];return e.tokens&&r.push(Mi(n.tokens)),e.cost&&n.cost>0&&r.push(Fi(n.cost)),r.length>0?r.join(" · "):null},Kw=t=>{const e=new Set(t.map(r=>r.model??null)),[n]=e;return e.size===1&&n?Cd(n):null},Zw=t=>{const e=Be.c(51),{run:n,directory:r}=t,{t:o}=at();let i;e[0]!==n?(i=ah(n),e[0]=n,e[1]=i):i=e[1];const a=i,u=lh(r),[c,d]=l.useState(Jw),[f,p]=l.useState(Qw);let m,h,x,g,b,w;if(e[2]!==a||e[3]!==c||e[4]!==u||e[5]!==n||e[6]!==o||e[7]!==f){const I=ch(n),j=I.measured>0,R=I.cost>0;let _,P,k;if(e[14]!==a||e[15]!==c||e[16]!==u||e[17]!==n||e[18]!==o||e[19]!==j||e[20]!==R||e[21]!==f){const N={tokens:j,cost:R},T=n.agents.filter(ey).length,A=ty;b="flex h-full min-h-0 flex-col";let $;e[28]!==a||e[29]!==n?($=s.jsx(Vw,{run:n,groups:a}),e[28]=a,e[29]=n,e[30]=$):$=e[30];const K=a.map(q=>{if(q.agents.length===0)return null;const M=q.title??"",z=q.done+q.failed===q.agents.length,H=(n.state==="running"&&z)===f.has(M),V=Kw(q.agents),F=Gw(q.agents,N);return s.jsxs("section",{className:"mt-3",children:[s.jsxs("button",{type:"button",onClick:()=>A(p,M),"aria-expanded":H,className:"flex h-7 w-full min-w-0 items-center gap-1.5 text-start typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:$e("size-3.5 shrink-0 transition-transform",H&&"rotate-90 rtl:-rotate-90")}),s.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:q.title??o("chat.workflow.phase.unphased")}),V?s.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${V}`}):null,F?s.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:F}):null,s.jsx("span",{className:$e("shrink-0 tabular-nums font-normal",!F&&"ms-auto"),dir:"auto",children:F?`· ${q.done}/${q.agents.length}`:`${q.done}/${q.agents.length}`})]}),H?q.agents.map(C=>{const te=C.sessionId;return s.jsx(qw,{run:n,agent:C,showModel:V===null,columns:N,open:c.has(C.key),onToggle:()=>A(d,C.key),onOpenSession:te?()=>u(te,C.label):null},C.key)}):null]},M)});e[31]!==$||e[32]!==K?(w=s.jsxs(fs,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[$,K]}),e[31]=$,e[32]=K,e[33]=w):w=e[33],m="flex shrink-0 flex-wrap items-center gap-x-1.5 border-t border-edge px-3 py-2 typography-micro text-muted-foreground",_="tabular-nums",P="auto",k=o("workflows.panel.summary.agents",{done:T,total:n.agents.length}),e[14]=a,e[15]=c,e[16]=u,e[17]=n,e[18]=o,e[19]=j,e[20]=R,e[21]=f,e[22]=_,e[23]=P,e[24]=k,e[25]=m,e[26]=b,e[27]=w}else _=e[22],P=e[23],k=e[24],m=e[25],b=e[26],w=e[27];e[34]!==_||e[35]!==P||e[36]!==k?(h=s.jsx("span",{className:_,dir:P,children:k}),e[34]=_,e[35]=P,e[36]=k,e[37]=h):h=e[37],e[38]!==n.endedAt||e[39]!==n.startedAt||e[40]!==n.state?(x=n.startedAt!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx(Hi,{start:n.startedAt,end:n.state==="running"?void 0:n.endedAt??n.startedAt})]}):null,e[38]=n.endedAt,e[39]=n.startedAt,e[40]=n.state,e[41]=x):x=e[41],g=I.measured>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:Mi(I.tokens)})}),I.cost>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"ltr",children:Fi(I.cost)})]}):null]}):null,e[2]=a,e[3]=c,e[4]=u,e[5]=n,e[6]=o,e[7]=f,e[8]=m,e[9]=h,e[10]=x,e[11]=g,e[12]=b,e[13]=w}else m=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13];let S;e[42]!==m||e[43]!==h||e[44]!==x||e[45]!==g?(S=s.jsxs("div",{className:m,children:[h,x,g]}),e[42]=m,e[43]=h,e[44]=x,e[45]=g,e[46]=S):S=e[46];let y;return e[47]!==b||e[48]!==w||e[49]!==S?(y=s.jsxs("div",{className:b,children:[w,S]}),e[47]=b,e[48]=w,e[49]=S,e[50]=y):y=e[50],y};function Xw(t){return t.title!==null}function Yw(t){return!t}function Jw(){return new Set}function Qw(){return new Set}function ey(t){return t.state==="completed"}function ty(t,e){return t(n=>{const r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})}const sy={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},ny=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script"}],ry=1500,oy=(t,e)=>{const n=Be.c(11),[r,o]=l.useState(null),[i,a]=l.useState(null),u=l.useRef(null),c=e!=="agents",d=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;n[0]!==t.id||n[1]!==c?(f=()=>{if(!c)return;let g=!0;const b=u.current?.runId===t.id?u.current.at:0,w=Math.max(0,b+ry-Date.now()),S=setTimeout(()=>{u.current={runId:t.id,at:Date.now()},jh(t.id).then(y=>{g&&(o(y),a(null))}).catch(()=>{g&&a(t.id)})},w);return()=>{g=!1,clearTimeout(S)}},n[0]=t.id,n[1]=c,n[2]=f):f=n[2];let p;n[3]!==d||n[4]!==t.id||n[5]!==t.state||n[6]!==c?(p=[d,t.id,t.state,c],n[3]=d,n[4]=t.id,n[5]=t.state,n[6]=c,n[7]=p):p=n[7],l.useEffect(f,p);const m=r?.runId===t.id?r:null,h=i===t.id;let x;return n[8]!==m||n[9]!==h?(x={detail:m,failed:h},n[8]=m,n[9]=h,n[10]=x):x=n[10],x},iy=t=>new Intl.DateTimeFormat(Bc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),ay=t=>{const e=Be.c(8),{run:n,detail:r}=t,{t:o}=at(),i=r?.logs??n.logs;if(i.length===0){let c;e[0]!==o?(c=o("workflows.panel.log.empty"),e[0]=o,e[1]=c):c=e[1];let d;return e[2]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[2]=c,e[3]=d):d=e[3],d}let a;e[4]!==i?(a=i.map(xy),e[4]=i,e[5]=a):a=e[5];let u;return e[6]!==a?(u=s.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=u):u=e[7],u},ly=t=>{const e=Be.c(24),{run:n,detail:r,failed:o}=t,{t:i}=at();if(n.error&&(n.state==="failed"||n.state==="stopped")){const c=n.state==="failed"?"var(--status-error)":void 0;let d;e[0]!==c?(d={color:c},e[0]=c,e[1]=d):d=e[1];let f;return e[2]!==n.error||e[3]!==d?(f=s.jsx("p",{className:"px-4 py-6 typography-meta",style:d,children:n.error}),e[2]=n.error,e[3]=d,e[4]=f):f=e[4],f}if(n.state==="awaiting-approval"||n.state==="running"||n.state==="declined"){let c;e[5]!==i?(c=i("workflows.panel.result.pending"),e[5]=i,e[6]=c):c=e[6];let d;return e[7]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[7]=c,e[8]=d):d=e[8],d}if(o&&!r){let c;e[9]!==i?(c=i("workflows.panel.detail.loadFailed"),e[9]=i,e[10]=c):c=e[10];let d;return e[11]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[11]=c,e[12]=d):d=e[12],d}if(!r){let c;e[13]!==i?(c=i("workflows.panel.agent.loading"),e[13]=i,e[14]=c):c=e[14];let d;e[15]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Li,{}),e[15]=d):d=e[15];let f;return e[16]!==c?(f=s.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[c,d]}),e[16]=c,e[17]=f):f=e[17],f}const{result:a}=r;if(!a||a.kind==="json"&&a.value===null){let c;e[18]!==i?(c=i("workflows.panel.result.none"),e[18]=i,e[19]=c):c=e[19];let d;return e[20]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[20]=c,e[21]=d):d=e[21],d}let u;return e[22]!==a?(u=s.jsx("div",{className:"px-4 py-3",children:s.jsx(jd,{answer:a})}),e[22]=a,e[23]=u):u=e[23],u},cy=t=>{const e=Be.c(16),{detail:n,failed:r}=t,{t:o}=at();if(!n){let p;e[0]!==r||e[1]!==o?(p=r?o("workflows.panel.detail.loadFailed"):s.jsxs(s.Fragment,{children:[o("workflows.panel.agent.loading"),s.jsx(Li,{})]}),e[0]=r,e[1]=o,e[2]=p):p=e[2];let m;return e[3]!==p?(m=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:p}),e[3]=p,e[4]=m):m=e[4],m}const i=n.args;let a;e[5]!==i?(a=i!=null&&JSON.stringify(i)!=="{}",e[5]=i,e[6]=a):a=e[6];const u=a;let c;e[7]!==i||e[8]!==u||e[9]!==o?(c=u?s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),s.jsx(fs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile mt-1 rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro text-foreground",children:JSON.stringify(i,null,2)})]}):null,e[7]=i,e[8]=u,e[9]=o,e[10]=c):c=e[10];let d;e[11]!==n.script?(d=s.jsx(fs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:n.script}),e[11]=n.script,e[12]=d):d=e[12];let f;return e[13]!==c||e[14]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[c,d]}),e[13]=c,e[14]=d,e[15]=f):f=e[15],f},dy=t=>{const e=Be.c(63),{run:n}=t,{t:r}=at(),{pending:o,act:i}=kh(),a=o===n.id;if(n.state==="awaiting-approval"){let u;e[0]!==i||e[1]!==n.id?(u=()=>i(n.id,"approve"),e[0]=i,e[1]=n.id,e[2]=u):u=e[2];let c;e[3]!==r?(c=r("chat.workflow.action.run"),e[3]=r,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"play",className:"size-3.5"}),e[5]=d):d=e[5];let f;e[6]!==r?(f=r("chat.workflow.action.run"),e[6]=r,e[7]=f):f=e[7];let p;e[8]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[8]=f,e[9]=p):p=e[9];let m;e[10]!==a||e[11]!==u||e[12]!==c||e[13]!==p?(m=s.jsxs(ft,{type:"button",size:"sm",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[10]=a,e[11]=u,e[12]=c,e[13]=p,e[14]=m):m=e[14];let h;e[15]!==i||e[16]!==n.id?(h=()=>i(n.id,"decline"),e[15]=i,e[16]=n.id,e[17]=h):h=e[17];let x;e[18]!==r?(x=r("chat.workflow.action.decline"),e[18]=r,e[19]=x):x=e[19];let g;e[20]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(se,{name:"close",className:"size-3.5"}),e[20]=g):g=e[20];let b;e[21]!==r?(b=r("chat.workflow.action.decline"),e[21]=r,e[22]=b):b=e[22];let w;e[23]!==b?(w=s.jsx("span",{className:"workflows-header__action-label",children:b}),e[23]=b,e[24]=w):w=e[24];let S;e[25]!==a||e[26]!==w||e[27]!==h||e[28]!==x?(S=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:h,"aria-label":x,children:[g,w]}),e[25]=a,e[26]=w,e[27]=h,e[28]=x,e[29]=S):S=e[29];let y;return e[30]!==S||e[31]!==m?(y=s.jsxs(s.Fragment,{children:[m,S]}),e[30]=S,e[31]=m,e[32]=y):y=e[32],y}if(n.state==="running"){let u;e[33]!==i||e[34]!==n.id?(u=()=>i(n.id,"stop"),e[33]=i,e[34]=n.id,e[35]=u):u=e[35];let c;e[36]!==r?(c=r("chat.workflow.action.stop"),e[36]=r,e[37]=c):c=e[37];let d;e[38]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"stop",className:"size-3.5"}),e[38]=d):d=e[38];let f;e[39]!==r?(f=r("chat.workflow.action.stop"),e[39]=r,e[40]=f):f=e[40];let p;e[41]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[41]=f,e[42]=p):p=e[42];let m;return e[43]!==a||e[44]!==u||e[45]!==c||e[46]!==p?(m=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[43]=a,e[44]=u,e[45]=c,e[46]=p,e[47]=m):m=e[47],m}if(n.state==="failed"||n.state==="stopped"){let u;e[48]!==i||e[49]!==n.id?(u=()=>i(n.id,"resume"),e[48]=i,e[49]=n.id,e[50]=u):u=e[50];let c;e[51]!==r?(c=r("chat.workflow.action.resume"),e[51]=r,e[52]=c):c=e[52];let d;e[53]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"restart",className:"size-3.5"}),e[53]=d):d=e[53];let f;e[54]!==r?(f=r("chat.workflow.action.resume"),e[54]=r,e[55]=f):f=e[55];let p;e[56]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[56]=f,e[57]=p):p=e[57];let m;return e[58]!==a||e[59]!==u||e[60]!==c||e[61]!==p?(m=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[58]=a,e[59]=u,e[60]=c,e[61]=p,e[62]=m):m=e[62],m}return null},uy=()=>{const t=Be.c(2),e=ts(by);let n;return t[0]!==e?(n={get:r=>e.get(r)?.title},t[0]=e,t[1]=n):n=t[1],n},el=t=>{const e=Be.c(31),{run:n,selected:r,caption:o,onSelect:i}=t,{t:a}=at();let u,c,d,f,p,m,h;if(e[0]!==i||e[1]!==n.state||e[2]!==a){const I=$c(n.state);c=qt,h=i,u=se,d=I.icon,f="size-3.5 shrink-0",p=I.color?{color:I.color}:void 0,m=a(I.labelKey),e[0]=i,e[1]=n.state,e[2]=a,e[3]=u,e[4]=c,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h}else u=e[3],c=e[4],d=e[5],f=e[6],p=e[7],m=e[8],h=e[9];let x;e[10]!==u||e[11]!==d||e[12]!==f||e[13]!==p||e[14]!==m?(x=s.jsx(u,{name:d,className:f,style:p,"aria-label":m}),e[10]=u,e[11]=d,e[12]=f,e[13]=p,e[14]=m,e[15]=x):x=e[15];let g;e[16]!==n.name?(g=s.jsx("span",{className:"truncate",dir:"auto",children:n.name}),e[16]=n.name,e[17]=g):g=e[17];let b;e[18]!==o?(b=o?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=b):b=e[19];let w;e[20]!==g||e[21]!==b?(w=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,b]}),e[20]=g,e[21]=b,e[22]=w):w=e[22];let S;e[23]!==r?(S=r?s.jsx(se,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=S):S=e[24];let y;return e[25]!==c||e[26]!==S||e[27]!==h||e[28]!==x||e[29]!==w?(y=s.jsxs(c,{onSelect:h,children:[x,w,S]}),e[25]=c,e[26]=S,e[27]=h,e[28]=x,e[29]=w,e[30]=y):y=e[30],y},fy=t=>{const e=Be.c(56),{runs:n,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:u,onRunSaved:c,onDelete:d}=t,{t:f}=at();let p;e[0]!==r.state?(p=$c(r.state),e[0]=r.state,e[1]=p):p=e[1];const m=p;let h,x,g,b,w,S,y;if(e[2]!==m.color||e[3]!==m.icon||e[4]!==u||e[5]!==n||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const P=n.slice().reverse();let k;e[18]!==o?(k=H=>H.parentSessionId===o,e[18]=o,e[19]=k):k=e[19];const N=P.filter(k);let T;e[20]!==o?(T=H=>H.parentSessionId!==o,e[20]=o,e[21]=T):T=e[21];const A=P.filter(T);x=xn;let $;e[22]!==f?($=f("workflows.panel.runPicker"),e[22]=f,e[23]=$):$=e[23];let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=$e(Sh(),"max-w-[14rem] shrink-0"),e[24]=K):K=e[24];let q;e[25]!==m.color?(q=m.color?{color:m.color}:void 0,e[25]=m.color,e[26]=q):q=e[26];let M;e[27]!==m.icon||e[28]!==q?(M=s.jsx(se,{name:m.icon,className:"size-3.5",style:q}),e[27]=m.icon,e[28]=q,e[29]=M):M=e[29];let z;e[30]!==r.name?(z=s.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=z):z=e[31];let ne;e[32]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(se,{name:"arrow-down-s",className:"size-4"}),e[32]=ne):ne=e[32],e[33]!==M||e[34]!==z||e[35]!==$?(y=s.jsx(bn,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":$,className:K,children:[M,z,ne]})}),e[33]=M,e[34]=z,e[35]=$,e[36]=y):y=e[36],h=wn,g="start",b="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",w=N.length>0?s.jsxs(s.Fragment,{children:[s.jsx(Ir,{children:f("workflows.panel.picker.thisSession")}),N.map(H=>s.jsx(el,{run:H,selected:H.id===r.id,onSelect:()=>u(H.id)},H.id))]}):null,S=A.length>0?s.jsxs(s.Fragment,{children:[N.length>0?s.jsx(mn,{}):null,s.jsx(Ir,{children:f("workflows.panel.picker.otherSessions")}),A.map(H=>s.jsx(el,{run:H,selected:H.id===r.id,caption:i.get(H.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>u(H.id)},H.id))]}):null,e[2]=m.color,e[3]=m.icon,e[4]=u,e[5]=n,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=i,e[10]=f,e[11]=h,e[12]=x,e[13]=g,e[14]=b,e[15]=w,e[16]=S,e[17]=y}else h=e[11],x=e[12],g=e[13],b=e[14],w=e[15],S=e[16],y=e[17];let I;e[37]!==c||e[38]!==a||e[39]!==f?(I=a.length>0?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsx(Ir,{children:f("workflows.panel.picker.saved")}),a.map(P=>s.jsxs(qt,{disabled:!!P.error,onSelect:()=>c(P.name),title:P.error??P.description,children:[s.jsx(se,{name:"play",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:P.name})]},P.name))]}):null,e[37]=c,e[38]=a,e[39]=f,e[40]=I):I=e[40];let j;e[41]!==d||e[42]!==f?(j=d?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsxs(qt,{variant:"destructive",onSelect:d,children:[s.jsx(se,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[41]=d,e[42]=f,e[43]=j):j=e[43];let R;e[44]!==h||e[45]!==g||e[46]!==b||e[47]!==w||e[48]!==S||e[49]!==I||e[50]!==j?(R=s.jsxs(h,{align:g,className:b,children:[w,S,I,j]}),e[44]=h,e[45]=g,e[46]=b,e[47]=w,e[48]=S,e[49]=I,e[50]=j,e[51]=R):R=e[51];let _;return e[52]!==x||e[53]!==y||e[54]!==R?(_=s.jsxs(x,{children:[y,R]}),e[52]=x,e[53]=y,e[54]=R,e[55]=_):_=e[55],_},py=(t,e,n,r)=>{const o=Be.c(11),{t:i}=at(),{confirm:a,dialog:u}=_i(),c=$i(wy);let d;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==c||o[4]!==r||o[5]!==n||o[6]!==i?(d=async m=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:m}),message:i(n?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const x=await wh({directory:t,scriptDirectory:e,sessionId:n,name:m});n?c(r,x.runId):(c(x.sessionId,x.runId),tt.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;_e.error(i("workflows.panel.saved.failed"),{description:g instanceof Error?g.message:void 0})}},o[0]=a,o[1]=t,o[2]=e,o[3]=c,o[4]=r,o[5]=n,o[6]=i,o[7]=d):d=o[7];const f=d;let p;return o[8]!==u||o[9]!==f?(p={run:f,dialog:u},o[8]=u,o[9]=f,o[10]=p):p=o[10],p},my=t=>{const e=Be.c(23),{saved:n,onRunSaved:r}=t,{t:o}=at();if(n.length===0){let p;e[0]!==o?(p=o("workflows.panel.emptyProject"),e[0]=o,e[1]=p):p=e[1];let m;return e[2]!==p?(m=s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3],m}let i;e[4]!==o?(i=o("workflows.panel.emptyProject"),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==i?(a=s.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[6]=i,e[7]=a):a=e[7];let u;e[8]!==o?(u=o("workflows.panel.picker.saved"),e[8]=o,e[9]=u):u=e[9];let c;e[10]!==u?(c=s.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:u}),e[10]=u,e[11]=c):c=e[11];let d;if(e[12]!==r||e[13]!==n||e[14]!==o){let p;e[16]!==r||e[17]!==o?(p=m=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:m.name}),m.description||m.error?s.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:m.error??m.description,children:m.error??m.description}):null]}),s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:!!m.error,onClick:()=>r(m.name),"aria-label":o("workflows.panel.saved.runAria",{name:m.name}),children:[s.jsx(se,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})]},m.name),e[16]=r,e[17]=o,e[18]=p):p=e[18],d=n.map(p),e[12]=r,e[13]=n,e[14]=o,e[15]=d}else d=e[15];let f;return e[19]!==a||e[20]!==c||e[21]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[a,c,d]}),e[19]=a,e[20]=c,e[21]=d,e[22]=f):f=e[22],f},hy=t=>{const e=Be.c(17),{directory:n}=t,r=tt(yy),o=gh(n),i=xh(o),a=bh(o?.savedDirectory??null),u=r??`directory:${n??""}`;let c;e[0]!==u?(c=b=>b.selectedBySession[u],e[0]=u,e[1]=c):c=e[1];const d=$i(c),{run:f,dialog:p}=py(n,o?.savedDirectory??null,r,u);let m;e[2]!==i||e[3]!==d||e[4]!==r?(m=i.find(b=>b.id===d)??i.filter(b=>b.parentSessionId===r).at(-1)??i.at(-1)??null,e[2]=i,e[3]=d,e[4]=r,e[5]=m):m=e[5];const h=m;let x;e[6]!==n||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==u||e[12]!==r?(x=h?s.jsx(gy,{sessionId:r,selectionKey:u,runs:i,saved:a,run:h,directory:n,onRunSaved:b=>{f(b)}}):s.jsx(my,{saved:a,onRunSaved:b=>{f(b)}}),e[6]=n,e[7]=h,e[8]=f,e[9]=i,e[10]=a,e[11]=u,e[12]=r,e[13]=x):x=e[13];let g;return e[14]!==p||e[15]!==x?(g=s.jsxs(s.Fragment,{children:[p,x]}),e[14]=p,e[15]=x,e[16]=g):g=e[16],g},gy=t=>{const e=Be.c(58),{sessionId:n,selectionKey:r,runs:o,saved:i,run:a,directory:u,onRunSaved:c}=t,{t:d}=at(),f=$i(vy),p=uy(),[m,h]=l.useState("agents"),{detail:x,failed:g}=oy(a,m),b=l.useRef(null);Bf(b,sy);const{confirm:w,dialog:S}=_i(),y=a.state==="running"||a.state==="awaiting-approval",I=a.parentSessionId!==n;let j;e[0]!==w||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==d?(j=async()=>{if(await w({title:d("workflows.panel.delete.title",{name:a.name}),message:d("workflows.panel.delete.message"),action:d("workflows.panel.delete.confirm"),destructive:!0}))try{await yh(a.id),vh.getState().remove(a.parentSessionId,a.id)}catch(C){const te=C;_e.error(d("workflows.panel.delete.failed"),{description:te instanceof Error?te.message:void 0})}},e[0]=w,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=d,e[5]=j):j=e[5];const R=j;let _;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(_=()=>{f(a.parentSessionId,a.id),tt.getState().setCurrentSession(a.parentSessionId,a.directory)},e[6]=a.directory,e[7]=a.id,e[8]=a.parentSessionId,e[9]=f,e[10]=_):_=e[10];const P=_;let k;e[11]!==f||e[12]!==r?(k=F=>f(r,F),e[11]=f,e[12]=r,e[13]=k):k=e[13];let N;e[14]!==R||e[15]!==y?(N=y?null:()=>{R()},e[14]=R,e[15]=y,e[16]=N):N=e[16];let T;e[17]!==c||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==n||e[22]!==p||e[23]!==k||e[24]!==N?(T=s.jsx(fy,{runs:o,selected:a,sessionId:n,sessionTitles:p,saved:i,onSelect:k,onRunSaved:c,onDelete:N}),e[17]=c,e[18]=a,e[19]=o,e[20]=i,e[21]=n,e[22]=p,e[23]=k,e[24]=N,e[25]=T):T=e[25];let A;e[26]!==d?(A=d("workflows.panel.view.label"),e[26]=d,e[27]=A):A=e[27];let $;e[28]!==d||e[29]!==m?($=ny.map(F=>{const C=F.id===m;return s.jsxs("button",{type:"button",onClick:()=>h(F.id),"aria-current":C?"page":void 0,title:d(F.labelKey),"aria-label":d(F.labelKey),className:$e("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",C?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(se,{name:F.icon,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:d(F.labelKey)})]},F.id)}),e[28]=d,e[29]=m,e[30]=$):$=e[30];let K;e[31]!==A||e[32]!==$?(K=s.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":A,children:$}),e[31]=A,e[32]=$,e[33]=K):K=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=q):q=e[34];let M;e[35]!==I||e[36]!==P||e[37]!==a.parentSessionId||e[38]!==p||e[39]!==d?(M=I?s.jsxs(ft,{type:"button",size:"sm",variant:"ghost",onClick:P,"aria-label":d("workflows.panel.agent.openSession"),title:p.get(a.parentSessionId)||d("workflows.panel.picker.untitledSession"),children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),s.jsx("span",{className:"workflows-header__action-label",children:d("workflows.panel.agent.openSession")})]}):null,e[35]=I,e[36]=P,e[37]=a.parentSessionId,e[38]=p,e[39]=d,e[40]=M):M=e[40];let z;e[41]!==a?(z=s.jsx(dy,{run:a}),e[41]=a,e[42]=z):z=e[42];let ne;e[43]!==M||e[44]!==z||e[45]!==T||e[46]!==K?(ne=s.jsx(pc,{children:s.jsxs("div",{ref:b,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[T,K,q,M,z]})}),e[43]=M,e[44]=z,e[45]=T,e[46]=K,e[47]=ne):ne=e[47];let H;e[48]!==x||e[49]!==u||e[50]!==g||e[51]!==a||e[52]!==m?(H=m==="agents"?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(Zw,{run:a,directory:u},a.id)}):s.jsxs(fs,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[m==="log"?s.jsx(ay,{run:a,detail:x}):null,m==="result"?s.jsx(ly,{run:a,detail:x,failed:g}):null,m==="script"?s.jsx(cy,{detail:x,failed:g}):null]}),e[48]=x,e[49]=u,e[50]=g,e[51]=a,e[52]=m,e[53]=H):H=e[53];let V;return e[54]!==S||e[55]!==ne||e[56]!==H?(V=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[S,ne,H]}),e[54]=S,e[55]=ne,e[56]=H,e[57]=V):V=e[57],V};function xy(t,e){return s.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:iy(t.at)}),s.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function by(t){return t.entityById}function wy(t){return t.select}function yy(t){return t.currentSessionId}function vy(t){return t.select}const tl=60,Sy=t=>{try{return new URL(t).origin}catch{return""}},Ao=new Set,Td=po()((t,e)=>({byOrigin:{},resolve:(n,r,o)=>{const i=Sy(n);!i||!r||e().byOrigin[i]||Ao.has(i)||(Ao.add(i),En("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const u=typeof a?.dataUrl=="string"?a.dataUrl:"";u&&t(c=>{const d={...c.byOrigin,[i]:u},f=Object.keys(d);if(f.length<=tl)return{byOrigin:d};for(const p of f.slice(0,f.length-tl))delete d[p];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Ao.delete(i)}))}})),qi=t=>t,ri=t=>{const e=qi(t).type;return typeof e=="string"?e:""},ky=t=>{const e=qi(t).tool;return typeof e=="string"?e:""},jy=t=>{const e=qi(t).text;return typeof e=="string"?e:""},Cy=t=>{const e=ri(t);return e==="tool"?ky(t).trim().toLowerCase()||"tool":e||"unknown"},Ty=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=Cy(n);e.includes(r)||e.push(r)}return e.join(" + ")},Ny=t=>t.replace(/\s+/g," ").trim(),Ey=t=>{for(const n of t)if(ri(n)==="text"){const r=Ny(jy(n));if(r.length===0)continue;return r}const e=t.filter(n=>ri(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Py=(t,e,n)=>`${n(t)} / ${n(e)}`,Iy=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Ry=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=Iy(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},Dy=(t,{windowTokens:e,compacted:n=!1})=>{const r=n?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},oi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Dr={user:0,assistant:0,tool:0,other:0},$s=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,sl=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...oi,total:$s(n)};if(!n||typeof n!="object")return oi;const r=n,o=$s(r.input),i=$s(r.output),a=$s(r.reasoning),u=$s(r.cache?.read),c=$s(r.cache?.write),d=$s(r.total);return{input:o,output:i,reasoning:a,cacheRead:u,cacheWrite:c,total:d>0?d:o+i+a+u+c}},_y=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},bs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+bs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+bs(n),0):0,Ay=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Dr,assistant:bs(n.text)+bs(n.content)};const o=_y(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:bs(n.input)+bs(n.output)+bs(n.error)+bs(n.call?.input)+bs(n.call?.output)+bs(n.call?.error)+bs(n.raw)+Math.round(bs(n.metadata)*.25)+Math.round(bs(n.state)*.1)+Math.round((Pu(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},nl=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Oy=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",My=(t,e)=>{if(t.length===0)return{...Dr};const n=t.reduce((r,o)=>{const i=Oy(o);let a={...Dr};for(const u of o.parts)a=nl(a,Ay(u,i));return nl(r,a)},{...Dr});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},dn=t=>t.toLocaleString(Bc()),Fy=(t,e)=>!t||!Number.isFinite(t)?"-":Eh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Ly=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},$y=()=>{const t=Be.c(215),{t:e}=at(),n=zf(),r=X(By);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=l.useState(o),[u,c]=l.useState(null),d=l.useRef(null),f=tt(zy),p=tt(Wy),m=Ch(p??void 0),h=Th(f??"",p??void 0),x=zt(Uy);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),a(Vy),c(null)},t[1]=g):g=t[1];let b;t[2]!==p||t[3]!==f?(b=[p,f],t[2]=p,t[3]=f,t[4]=b):b=t[4],l.useEffect(g,b);let w,S;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},S=[],t[5]=w,t[6]=S):(w=t[5],S=t[6]),l.useEffect(w,S);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=async(ge,lt)=>{(await ro(lt)).ok?(c(ge),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{c(bt=>bt===ge?null:bt),d.current=null},2e3)):c(null)},t[7]=y):y=t[7];const I=y;let j,R,_,P,k,N,T,A,$,K;if(t[8]!==f||t[9]!==x||t[10]!==h||t[11]!==m){P=f?m.find(pt=>pt.id===f)??null:null,j=h.filter(Hy);let ge;t[22]!==h?(ge=h.filter(qy),t[22]=h,t[23]=ge):ge=t[23],K=ge;let lt;t[24]!==h?(lt=Tc(h.map(Gy)),t[24]=h,t[25]=lt):lt=t[25];const Ct=lt,bt=Ct?h[Ct.index]??null:null,kt=Ct?.state==="compacted";T=bt?sl(bt):oi,R=Nh({input:T.input,cache:{read:T.cacheRead,write:T.cacheWrite}}),A=Number.isFinite(P?.cost)?$s(P?.cost):j.reduce(Ky,0);const ht=bt?.info??null,St=x,yt=ht?.providerID||"",xt=ht?.modelID||"";let vt;t[26]!==yt||t[27]!==xt||t[28]!==St?(vt=Ly(St,yt,xt),t[26]=yt,t[27]=xt,t[28]=St,t[29]=vt):vt=t[29],k=vt,_=k.contextLimit,$=kt?null:_&&_>0?Math.min(999,T.total/_*100):0;const ct=[...h].reverse().find(Zy),Pt=ct?.info.role==="system"?ct.info.text:"",Dt=My(h,Pt);N=Dy(Dt,{windowTokens:T.total,compacted:kt}),t[8]=f,t[9]=x,t[10]=h,t[11]=m,t[12]=j,t[13]=R,t[14]=_,t[15]=P,t[16]=k,t[17]=N,t[18]=T,t[19]=A,t[20]=$,t[21]=K}else j=t[12],R=t[13],_=t[14],P=t[15],k=t[16],N=t[17],T=t[18],A=t[19],$=t[20],K=t[21];const q=N,M=h[0]?.info?.time?.created,z=h.length>0?h[h.length-1]?.info?.time?.created:null;let ne;t[30]!==P?.title||t[31]!==e?(ne=P?.title||e("contextSidebar.session.untitled"),t[30]=P?.title,t[31]=e,t[32]=ne):ne=t[32];const H=P?.time?.created??M??null,V=z??P?.time?.created??null;let F;t[33]!==j.length||t[34]!==q||t[35]!==R||t[36]!==_||t[37]!==k||t[38]!==h.length||t[39]!==ne||t[40]!==H||t[41]!==V||t[42]!==T||t[43]!==A||t[44]!==$||t[45]!==K.length?(F={sessionTitle:ne,messagesCount:h.length,userMessagesCount:K.length,assistantMessagesCount:j.length,createdAt:H,lastActivityAt:V,providerModel:k,tokenBreakdown:T,usagePercent:$,cacheHitRate:R,totalAssistantCost:A,contextLimit:_,breakdown:q,breakdownTotal:q.total},t[33]=j.length,t[34]=q,t[35]=R,t[36]=_,t[37]=k,t[38]=h.length,t[39]=ne,t[40]=H,t[41]=V,t[42]=T,t[43]=A,t[44]=$,t[45]=K.length,t[46]=F):F=t[46];const C=F;if(!f){let ge;t[47]!==e?(ge=e("contextSidebar.empty.openSession"),t[47]=e,t[48]=ge):ge=t[48];let lt;return t[49]!==ge?(lt=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:ge}),t[49]=ge,t[50]=lt):lt=t[50],lt}let te;t[51]!==e?(te=e("contextSidebar.breakdown.user"),t[51]=e,t[52]=te):te=t[52];let re;t[53]!==te||t[54]!==C.breakdown.user?(re={key:"user",label:te,value:C.breakdown.user,color:"var(--status-success)"},t[53]=te,t[54]=C.breakdown.user,t[55]=re):re=t[55];let Q;t[56]!==e?(Q=e("contextSidebar.breakdown.assistant"),t[56]=e,t[57]=Q):Q=t[57];let ee;t[58]!==Q||t[59]!==C.breakdown.assistant?(ee={key:"assistant",label:Q,value:C.breakdown.assistant,color:"var(--primary-base)"},t[58]=Q,t[59]=C.breakdown.assistant,t[60]=ee):ee=t[60];let le;t[61]!==e?(le=e("contextSidebar.breakdown.toolCalls"),t[61]=e,t[62]=le):le=t[62];let O;t[63]!==le||t[64]!==C.breakdown.tool?(O={key:"tool",label:le,value:C.breakdown.tool,color:"var(--status-warning)"},t[63]=le,t[64]=C.breakdown.tool,t[65]=O):O=t[65];let Y;t[66]!==e?(Y=e("contextSidebar.breakdown.other"),t[66]=e,t[67]=Y):Y=t[67];let Z;t[68]!==Y||t[69]!==C.breakdown.other?(Z={key:"other",label:Y,value:C.breakdown.other,color:"var(--surface-muted-foreground)"},t[68]=Y,t[69]=C.breakdown.other,t[70]=Z):Z=t[70];let we;t[71]!==re||t[72]!==ee||t[73]!==O||t[74]!==Z?(we=[re,ee,O,Z],t[71]=re,t[72]=ee,t[73]=O,t[74]=Z,t[75]=we):we=t[75];const L=we;let pe;t[76]!==n||t[77]!==C.sessionTitle?(pe=n?s.jsx(pc,{children:s.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:s.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:C.sessionTitle,children:C.sessionTitle})})}):null,t[76]=n,t[77]=C.sessionTitle,t[78]=pe):pe=t[78];let je;t[79]!==n||t[80]!==C.sessionTitle?(je=n?null:s.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:C.sessionTitle}),t[79]=n,t[80]=C.sessionTitle,t[81]=je):je=t[81];const Ee=!n&&"mt-1";let Se;t[82]!==Ee?(Se=$e(Ee,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[82]=Ee,t[83]=Se):Se=t[83];let Le;t[84]!==C.providerModel.modelName||t[85]!==C.providerModel.providerName?(Le=s.jsxs("span",{children:[C.providerModel.providerName," / ",C.providerModel.modelName]}),t[84]=C.providerModel.modelName,t[85]=C.providerModel.providerName,t[86]=Le):Le=t[86];let Pe;t[87]!==r||t[88]!==C.createdAt?(Pe=C.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Fy(C.createdAt,r)})]}),t[87]=r,t[88]=C.createdAt,t[89]=Pe):Pe=t[89];let Ve;t[90]!==Se||t[91]!==Le||t[92]!==Pe?(Ve=s.jsxs("div",{className:Se,children:[Le,Pe]}),t[90]=Se,t[91]=Le,t[92]=Pe,t[93]=Ve):Ve=t[93];let Oe;t[94]!==je||t[95]!==Ve?(Oe=s.jsxs("div",{className:"mb-6",children:[je,Ve]}),t[94]=je,t[95]=Ve,t[96]=Oe):Oe=t[96];let be;t[97]!==e?(be=e("contextSidebar.section.context"),t[97]=e,t[98]=be):be=t[98];let ye;t[99]!==be?(ye=s.jsx("span",{className:"typography-micro text-muted-foreground",children:be}),t[99]=be,t[100]=ye):ye=t[100];let Ue;t[101]!==C.tokenBreakdown.total||t[102]!==C.usagePercent?(Ue=C.usagePercent===null?"—":dn(C.tokenBreakdown.total),t[101]=C.tokenBreakdown.total,t[102]=C.usagePercent,t[103]=Ue):Ue=t[103];let Te;t[104]!==C.contextLimit?(Te=C.contextLimit?` / ${dn(C.contextLimit)}`:"",t[104]=C.contextLimit,t[105]=Te):Te=t[105];let Me;t[106]!==Ue||t[107]!==Te?(Me=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Ue,Te]}),t[106]=Ue,t[107]=Te,t[108]=Me):Me=t[108];let Re;t[109]!==ye||t[110]!==Me?(Re=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ye,Me]}),t[109]=ye,t[110]=Me,t[111]=Re):Re=t[111];let ze;t[112]!==C.usagePercent?(ze=C.usagePercent!==null&&C.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,C.usagePercent)}%`,backgroundColor:C.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[112]=C.usagePercent,t[113]=ze):ze=t[113];let B;t[114]!==ze?(B=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ze}),t[114]=ze,t[115]=B):B=t[115];let ce;t[116]!==e||t[117]!==C.usagePercent?(ce=C.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:C.usagePercent.toFixed(1)}),t[116]=e,t[117]=C.usagePercent,t[118]=ce):ce=t[118];let G;t[119]!==ce?(G=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ce}),t[119]=ce,t[120]=G):G=t[120];let Ce;t[121]!==Re||t[122]!==B||t[123]!==G?(Ce=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Re,B,G]}),t[121]=Re,t[122]=B,t[123]=G,t[124]=Ce):Ce=t[124];let J;t[125]!==e?(J=e("contextSidebar.stats.messages"),t[125]=e,t[126]=J):J=t[126];let Ne;t[127]!==C.messagesCount?(Ne=dn(C.messagesCount),t[127]=C.messagesCount,t[128]=Ne):Ne=t[128];let Ae;t[129]!==J||t[130]!==Ne?(Ae={label:J,value:Ne},t[129]=J,t[130]=Ne,t[131]=Ae):Ae=t[131];let Ie;t[132]!==e?(Ie=e("contextSidebar.stats.user"),t[132]=e,t[133]=Ie):Ie=t[133];let De;t[134]!==C.userMessagesCount?(De=dn(C.userMessagesCount),t[134]=C.userMessagesCount,t[135]=De):De=t[135];let We;t[136]!==Ie||t[137]!==De?(We={label:Ie,value:De},t[136]=Ie,t[137]=De,t[138]=We):We=t[138];let Ke;t[139]!==e?(Ke=e("contextSidebar.stats.assistant"),t[139]=e,t[140]=Ke):Ke=t[140];let Ze;t[141]!==C.assistantMessagesCount?(Ze=dn(C.assistantMessagesCount),t[141]=C.assistantMessagesCount,t[142]=Ze):Ze=t[142];let Qe;t[143]!==Ke||t[144]!==Ze?(Qe={label:Ke,value:Ze},t[143]=Ke,t[144]=Ze,t[145]=Qe):Qe=t[145];let qe;t[146]!==e?(qe=e("contextSidebar.stats.cost"),t[146]=e,t[147]=qe):qe=t[147];let et;t[148]!==C.totalAssistantCost?(et=td(C.totalAssistantCost),t[148]=C.totalAssistantCost,t[149]=et):et=t[149];let He;t[150]!==qe||t[151]!==et?(He={label:qe,value:et},t[150]=qe,t[151]=et,t[152]=He):He=t[152];let Ye;t[153]!==Ae||t[154]!==We||t[155]!==Qe||t[156]!==He?(Ye=[Ae,We,Qe,He],t[153]=Ae,t[154]=We,t[155]=Qe,t[156]=He,t[157]=Ye):Ye=t[157];const dt=Ye;let nt;t[158]!==dt?(nt=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:dt.map(Xy)}),t[158]=dt,t[159]=nt):nt=t[159];let ut;t[160]!==e?(ut=e("contextSidebar.section.lastAssistantMessage"),t[160]=e,t[161]=ut):ut=t[161];let oe;t[162]!==ut?(oe=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:ut}),t[162]=ut,t[163]=oe):oe=t[163];let de;t[164]!==e||t[165]!==C.cacheHitRate.hasInput||t[166]!==C.cacheHitRate.percent||t[167]!==C.tokenBreakdown.cacheRead||t[168]!==C.tokenBreakdown.cacheWrite||t[169]!==C.tokenBreakdown.input||t[170]!==C.tokenBreakdown.output||t[171]!==C.tokenBreakdown.reasoning?(de=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:C.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:C.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:C.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:C.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:C.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:C.cacheHitRate.hasInput?C.cacheHitRate.percent:null,format:"percent"}].map(Yy)}),t[164]=e,t[165]=C.cacheHitRate.hasInput,t[166]=C.cacheHitRate.percent,t[167]=C.tokenBreakdown.cacheRead,t[168]=C.tokenBreakdown.cacheWrite,t[169]=C.tokenBreakdown.input,t[170]=C.tokenBreakdown.output,t[171]=C.tokenBreakdown.reasoning,t[172]=de):de=t[172];let ve;t[173]!==oe||t[174]!==de?(ve=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[oe,de]}),t[173]=oe,t[174]=de,t[175]=ve):ve=t[175];let v;t[176]!==L||t[177]!==C.breakdownTotal?(v=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:L.map(ge=>ge.value<=0||C.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${ge.value/C.breakdownTotal*100}%`,backgroundColor:ge.color}},ge.key))}),t[176]=L,t[177]=C.breakdownTotal,t[178]=v):v=t[178];let ae;t[179]!==L||t[180]!==C.breakdownTotal?(ae=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:L.map(ge=>{const lt=C.breakdownTotal>0?ge.value/C.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:ge.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[ge.label," ",s.jsxs("span",{className:"tabular-nums",children:[lt.toFixed(0),"%"]})]})]},ge.key)})}),t[179]=L,t[180]=C.breakdownTotal,t[181]=ae):ae=t[181];let W;t[182]!==v||t[183]!==ae?(W=s.jsxs("div",{className:"mb-6",children:[v,ae]}),t[182]=v,t[183]=ae,t[184]=W):W=t[184];let me;t[185]!==e?(me=e("contextSidebar.section.rawMessages"),t[185]=e,t[186]=me):me=t[186];let he;t[187]!==me?(he=s.jsx("div",{className:"typography-micro text-muted-foreground",children:me}),t[187]=me,t[188]=he):he=t[188];let Je;if(t[189]!==u||t[190]!==i||t[191]!==h||t[192]!==e||t[193]!==r){let ge;t[195]!==u||t[196]!==i||t[197]!==e||t[198]!==r?(ge=lt=>{const Ct=lt.info.role,bt=Ct==="assistant",kt=Ct==="user",ht=i[lt.info.id]===!0,St=u===lt.info.id,yt=lt.info.time?.created??null,xt=Ty(lt.parts),vt=bt?sl({info:lt.info,parts:lt.parts}):null,ct=kt?Ey(lt.parts):"",Pt=Ry(yt,r),Dt=xt||"—",pt=vt?Py(vt.input,vt.output,dn):"",mt=Ct||"unknown",Ot=xt?`${mt}: ${xt}`:mt,Ut=ht?JSON.stringify({info:lt.info,parts:lt.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":ht,onClick:()=>{a(ss=>({...ss,[lt.info.id]:ss[lt.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:bt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[kt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",ct]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:bt?Dt:Ot}),bt&&s.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:pt})]}),s.jsx("span",{className:"text-end text-muted-foreground",children:Pt})]})}),ht&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs(fs,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[s.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:ss=>{ss.stopPropagation(),I(lt.info.id,Ut)},"aria-label":e(St?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(St?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:St?s.jsx(se,{name:"check",className:"size-3.5"}):s.jsx(se,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Ph,{language:"json",code:Ut,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},lt.info.id)},t[195]=u,t[196]=i,t[197]=e,t[198]=r,t[199]=ge):ge=t[199],Je=[...h].reverse().map(ge),t[189]=u,t[190]=i,t[191]=h,t[192]=e,t[193]=r,t[194]=Je}else Je=t[194];let Fe;t[200]!==Je?(Fe=s.jsx("div",{className:"mt-2.5 space-y-1",children:Je}),t[200]=Je,t[201]=Fe):Fe=t[201];let fe;t[202]!==he||t[203]!==Fe?(fe=s.jsxs("div",{children:[he,Fe]}),t[202]=he,t[203]=Fe,t[204]=fe):fe=t[204];let ke;t[205]!==Oe||t[206]!==Ce||t[207]!==nt||t[208]!==ve||t[209]!==W||t[210]!==fe?(ke=s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[Oe,Ce,nt,ve,W,fe]}),t[205]=Oe,t[206]=Ce,t[207]=nt,t[208]=ve,t[209]=W,t[210]=fe,t[211]=ke):ke=t[211];let rt;return t[212]!==pe||t[213]!==ke?(rt=s.jsxs(fs,{outerClassName:"h-full",className:"bg-background",children:[pe,ke]}),t[212]=pe,t[213]=ke,t[214]=rt):rt=t[214],rt};function By(t){return t.timeFormatPreference}function zy(t){return t.currentSessionId}function Wy(t){return t.currentSessionDirectory}function Uy(t){return t.providers}function Vy(t){return Object.keys(t).length>0?{}:t}function Hy(t){return t.info.role==="assistant"}function qy(t){return t.info.role==="user"}function Gy(t){return t.info}function Ky(t,e){const n=$s(e.info.cost);return t+n}function Zy(t){return t.info.role==="system"}function Xy(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function Yy(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:dn(t.value):"—"})]},t.label)}const Jy=280,Qy=.28,ev=240,tv=.35,sv=(t,e,n=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=n?n.top:i-Math.min(ev,e.height*tv),u=Math.min(Jy,t.width*Qy,e.width/4),c=e.left-t.left>=1,d=r-o>=1,f=Math.max(0,a-t.top),p=c?e.left:t.left+u,m=d?o:r-u;return{left:{left:t.left,top:t.top,width:p-t.left,height:c?t.height:f},right:{left:m,top:t.top,width:r-m,height:d?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},Oo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,nv=(t,e)=>Oo(t.bottom,e)?"bottom":Oo(t.left,e)?"left":Oo(t.right,e)?"right":null,qs=po(()=>({drag:null,hovered:null})),_r=t=>{if(!t)return null;const{left:e,top:n,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:n,width:r,height:o}:null},Mo=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),Fo=t=>_r(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Nd=t=>{const e=_r(document.querySelector("[data-workspace-row]")),n=_r(document.querySelector("[data-workspace-chat]"));if(!e||!n)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=sv(e,n,_r(r)),i={left:Fo("left")??Mo(o.left),right:Fo("right")??Mo(o.right),bottom:Fo("bottom")??Mo(o.bottom)};return qs.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Ed=t=>{const{drag:e,hovered:n}=qs.getState();if(!e)return;const r=nv(e.targets,t);r!==n&&qs.setState({hovered:r})},ii=()=>{qs.getState().drag&&qs.setState({drag:null,hovered:null})},Pd=t=>{const{drag:e,hovered:n}=qs.getState();if(qs.setState({drag:null,hovered:null}),!e||!n)return!1;const r=X.getState();n!==e.from&&r.moveContextSurfaceToZone(e.mode,n);const o=t?us(t):"";if(o){const i=X.getState();bi(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Gi=(t,e)=>{let n=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(n||(n=Nd(t)),n&&Ed(a)):n&&(ii(),n=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),n?(Pd(i),!0):!1),cancel:()=>{o(),n&&ii()}}},rl={left:null,right:null,bottom:null},ur=po(()=>({body:rl,headerSlot:rl})),Id=(t,e,n)=>{const r=ur.getState()[t];r[e]!==n&&ur.setState({[t]:{...r,[e]:n}})},rv=(t,e)=>Id("body",t,e),ov=(t,e)=>Id("headerSlot",t,e),rr=t=>{const e=l.useRef(t);e.current=t;const[n,r]=l.useState(t),o=l.useCallback(()=>r(e.current),[]);return l.useLayoutEffect(()=>{Ei(o)},[t,o]),l.useEffect(()=>()=>zc(o),[o]),n},Lo=t=>{const e=rr(t);return t||e},iv=mr(()=>At(()=>import("./GitView-D29soKpK.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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206])).then(t=>({default:t.GitView}))),Ki=320,Rd=320,av=24,lv=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},ol=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Ki,Math.round(t))):vi,cv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Ki,t-Rd),il=(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},Ar=(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==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):t==="workflows"?e("contextPanel.mode.workflows"):Mn(t)?Ni.getState().guests.find(r=>r.id===Lr(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),dv=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},uv=(t,e,n)=>{if(t.mode==="chat"){const r=ho(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?to(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?dv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ar(t.mode,n)},fv=t=>{const e=Be.c(8),{mode:n}=t,r=Bi();let o;if(e[0]!==n||e[1]!==r){let d;e[3]!==n?(d=f=>f.mode===n,e[3]=n,e[4]=d):d=e[4],o=r.find(d),e[0]=n,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??Mh,u=i?.iconSrc;let c;return e[5]!==a||e[6]!==u?(c=s.jsx(Ti,{icon:a,iconSrc:u,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=u,e[7]=c):c=e[7],c},pv=t=>{const e=Be.c(2),{sessionId:n}=t,r=yc(n);let o;return e[0]!==r?(o=r?s.jsx(Sc,{state:r,className:"h-3.5 w-3.5"}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},mv=t=>{const e=Be.c(6),{url:n}=t,r=Oi(),o=Fc();let i;if(e[0]!==o||e[1]!==n||e[2]!==r){const c=n?Lc(n,r,o):null;i=c?c.source==="tracker"?Oh(c.provider).icon:Ah[c.kind]:"git-branch",e[0]=o,e[1]=n,e[2]=r,e[3]=i}else i=e[3];const a=i;let u;return e[4]!==a?(u=s.jsx(se,{name:a,className:"h-3.5 w-3.5"}),e[4]=a,e[5]=u):u=e[5],u},al=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(uo,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(hc,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(se,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(se,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(mv,{url:t.targetPath});if(t.mode==="notes")return s.jsx(se,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(se,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(se,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return s.jsx(se,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const n=ho(t.dedupeKey);return n?s.jsx(pv,{sessionId:n}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"})}if(Mn(t.mode))return s.jsx(fv,{mode:t.mode});if(t.mode==="browser"){const n=hv(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(se,{name:"global",className:"h-3.5 w-3.5"})}},hv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},gv=t=>{const e=Uc(),n=l.useRef(Hr),r=l.useRef(t);r.current=t;const o=t.length>0;return l.useSyncExternalStore(l.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),l.useCallback(()=>{const i=Array.from(e.children.values(),u=>u.getState()),a=Ow(i,r.current);return _w(n.current,a)?n.current:(n.current=a,a)},[e]),()=>Hr)},xv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,bv=8,wv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',yv=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Dd=320,Zi=160,ai=200,vv={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},ll=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Zi,Math.round(t))):Dd,Sv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Zi,t-ai),$o=({zone:t="right"})=>{const e=vv[t],n=ao(),r=e.axis==="y",{t:o,direction:i}=at(),a=i==="rtl",u=Gs()??"",c=Kl(Ih(u||null)),d=l.useCallback((ie,Ge)=>o(Ws(ie,c),Ge),[c,o]),f=l.useMemo(()=>lv(u),[u]),p=X(ie=>f?ie.contextPanelByDirectory[f]:void 0),m=X(ie=>ie.contextSurfaceZones),h=X(ie=>ie.shortcutOverrides),x=X(ie=>ie.closeContextZone),g=X(ie=>ie.closeContextPanelTab),b=X(ie=>ie.pinContextPanelTab),w=X(ie=>ie.toggleContextPanelExpanded),S=X(ie=>ie.setContextZoneSize),y=X(ie=>ie.setContextZoneExpandedChatSize),I=X(ie=>ie.setActiveContextPanelTab),j=X(ie=>ie.reorderContextPanelTabs),R=X(ie=>ie.contextEditorTreeVisible),_=X(ie=>ie.contextEditorTreeWidth),P=X(ie=>ie.setContextEditorTreeWidth),k=X(ie=>ie.toggleContextEditorTree),N=X(ie=>ie.contextEditorVisible),T=X(ie=>ie.toggleContextEditor),A=X(ie=>ie.fileTreeSide),$=X(ie=>ie.openNewContextBrowserTab),K=Td(ie=>ie.byOrigin),[q,M]=l.useState(null),z=l.useCallback(ie=>{M(ie),ov(t,ie)},[t]),ne=l.useCallback(ie=>{rv(t,ie)},[t]),H=l.useMemo(()=>p?.tabs??[],[p?.tabs]),V=p?Fr(p,m,t):null,F=p?lr(p,t):Iu,C=Rr(ie=>ie.workStatusReserved),te=Rr(ie=>ie.workStatusBesidePanel),re=Rr(ie=>ie.chatCovered),Q=t==="bottom"&&re,ee=!!(F.isOpen&&V)&&!Q,le=l.useMemo(()=>H.some(ie=>ie.mode==="file"&&ie.targetPath),[H]),O=le&&(N||!R),Y=!r&&V?.mode==="file"&&!O,Z=!!(ee&&F.expanded&&!Y),we=X(ie=>ie.contextZoneSizes[t]),L=Y?_:r?ll(we??Dd,Number.POSITIVE_INFINITY):ol(we??vi,Number.POSITIVE_INFINITY),pe=l.useCallback((ie,Ge)=>r?ll(ie,Sv(Ge)):ol(ie,cv(Ge)),[r]),je=r?ai:Rd,Ee=X(ie=>r?0:ie.sidebarWidth),Se=X(ie=>ie.contextZoneExpandedChatSizes[t]),Le=Math.max(je,Se??(r?ai:Ee)),Pe=t==="right"?"left":t==="left"?"right":null,Ve=X(ie=>{if(!Pe||!f)return 0;const Ge=ie.contextPanelByDirectory[f],gt=Ge&&tr(Ge,ie.contextSurfaceZones,Pe)?Fr(Ge,ie.contextSurfaceZones,Pe):null;return Ge&&gt?Ru(Ge,gt,Pe,ie):0}),Oe=Pe==="right"&&C&&!re&&Ve===0?Cn:Ve,be=t==="right"&&C&&!re,ye=be&&te&&!Z,[Ue,Te]=l.useState(null),Me=l.useRef(null),Re=l.useRef(Oe);Re.current=Oe;const ze=l.useRef(ee);ze.current=ee;const B=l.useRef(()=>!1);B.current=ie=>Z||!Y&&ie-Re.current-je<L;const ce=l.useCallback(()=>{let ie=Me.current;if(ie!==null&&!r&&ze.current){const Ge=document.querySelector("[data-left-sidebar]");Ge&&(ie+=Math.round(Ge.getBoundingClientRect().width-(Number.parseFloat(Ge.style.width)||0)))}Te(ie!==null&&B.current(ie)?ie:null)},[r]),G=Ue!==null?Ue-Oe:null,Ce=Y?L:Z&&G!==null?Math.max(r?Zi:Ki,G-Le):pe(L,G),J=ee&&V?.mode==="chat",Ne=l.useMemo(()=>{const ie=[];if(!J)return ie;for(const Ge of H){if(Ge.mode!=="chat")continue;const gt=ho(Ge.dedupeKey);gt&&!ie.includes(gt)&&ie.push(gt)}return ie},[J,H]),Ae=gv(Ne),[Ie,De]=l.useState(!1),We=l.useRef(0),Ke=l.useRef(Ce),Ze=l.useRef(null),Qe=l.useRef(null),qe=l.useRef(null),et=l.useRef(null),He=l.useRef(!1);l.useLayoutEffect(()=>{const ie=r?qe.current?.parentElement:qe.current?.closest("[data-workspace-row]");if(!ie||typeof ResizeObserver>"u")return;const Ge=new ResizeObserver(gt=>{const jt=gt[gt.length-1]?.contentRect,It=r?jt?.height:jt?.width;Me.current=It?Math.round(It):null,Ei(ce)});return Ge.observe(ie),Me.current=(r?ie.clientHeight:ie.clientWidth)||null,ce(),()=>{Ge.disconnect(),zc(ce)}},[ce,r]);const Ye=!r&&ee&&(Z||Ue!==null),dt=X(ie=>Ye&&ie.isSidebarOpen);l.useLayoutEffect(()=>{ce()},[ce,L,Z,ee,Oe,dt]),l.useEffect(()=>{if(!ee||He.current){He.current=ee;return}const ie=window.requestAnimationFrame(()=>{et.current?.focus({preventScroll:!0})});return He.current=!0,()=>window.cancelAnimationFrame(ie)},[ee]);const nt=l.useRef(null),ut=l.useRef(null),oe=l.useRef(null),de=l.useRef(null),ve=l.useRef(!1),v=l.useRef(null),ae=l.useRef(!1),W=l.useCallback(ie=>{const Ge=qe.current,gt=v.current;if(!Ge||!gt)return;const jt=r?"height":"width";Ge.style[jt]=ae.current?`${ie+Cn}px`:`min(${ie}px, 100%)`,gt.style[jt]=`calc(${ie}px - ${e.gutterSize})`},[e.gutterSize,r]),me=l.useCallback(()=>{ut.current=null;const ie=Ze.current;ie!==null&&W(ie)},[W]);l.useEffect(()=>()=>{ut.current!==null&&cancelAnimationFrame(ut.current),oe.current?.(),oe.current=null,de.current?.remove(),de.current=null},[]);const he=l.useCallback(ie=>{const Ge=nt.current,gt=Y?Ho(ie):pe(ie,Ge);return Ge===null?gt:Math.min(gt,Math.max(1,Ge))},[pe,Y]),Je=l.useCallback(ie=>{if(!ee||!f)return;Qe.current=ie.pointerId,De(!0),We.current=r?ie.clientY:ie.clientX,Ke.current=Ce,Ze.current=Ce;const Ge=r?qe.current?.parentElement?.clientHeight:(qe.current?.closest("[data-workspace-row]")?.clientWidth??0)-Re.current-(ye?Cn:0);nt.current=Ge&&Ge>0?Ge:null,de.current?.remove();const gt=document.createElement("div");gt.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${r?"row-resize":"col-resize"}`,document.body.appendChild(gt),de.current=gt,oe.current?.(),oe.current=Pc(r?"height":"width"),ie.preventDefault()},[ye,f,ee,r,Ce]),Fe=l.useCallback(()=>{const ie=he(Ze.current??Ce),Ge=nt.current;ut.current!==null&&(cancelAnimationFrame(ut.current),ut.current=null);const gt=qe.current,jt=v.current;if(gt&&jt){const It=r?"height":"width";gt.style.setProperty(e.sizeVariable,`${ie}px`),gt.style[It]=cs.current,jt.style[It]=Ht.current}Ze.current=null,nt.current=null,ve.current=!0,de.current?.remove(),de.current=null,Y?P(ie):Z?Ge!==null&&y(t,Ge-ie):S(t,ie),De(!1),Qe.current=null,oe.current?.(),oe.current=null},[he,e.sizeVariable,Z,Y,r,P,y,S,Ce,t]);l.useEffect(()=>{if(!Ie)return;const ie=jt=>{if(Qe.current!==jt.pointerId)return;const It=r?jt.clientY:jt.clientX,Mt=t==="left"?It-We.current:We.current-It,Kt=!r&&a?-Mt:Mt,Jt=he(Ke.current+Kt);Ze.current!==Jt&&(Ze.current=Jt,ut.current===null&&(ut.current=requestAnimationFrame(me)))},Ge=jt=>{Qe.current===jt.pointerId&&Fe()},gt=()=>{Fe()};return window.addEventListener("pointermove",ie),window.addEventListener("pointerup",Ge),window.addEventListener("pointercancel",Ge),window.addEventListener("blur",gt),()=>{window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",Ge),window.removeEventListener("pointercancel",Ge),window.removeEventListener("blur",gt)}},[me,he,Fe,Ie,a,r,t]),l.useEffect(()=>{Ie||(Ze.current=null,de.current?.remove(),de.current=null)},[Ie]);const fe=l.useCallback(()=>{f&&x(f,t)},[x,f,t]),ke=l.useCallback(()=>{f&&w(f,t)},[f,w,t]),rt=V?.mode==="file"||V?.mode==="chat"||V?.mode==="browser"||V?.mode==="pr",ge=l.useMemo(()=>{if(!V)return[];const ie=H.filter(Ge=>Ge.mode===V.mode);return V.mode==="pr"?[...ie.filter(yr),...ie.filter(Ge=>!yr(Ge))]:ie},[V,H]),lt=co(V?.mode==="pr"&&f?f:null)?.current??null,Ct=l.useMemo(()=>{const ie=Rh(ge.filter(Ge=>Ge.mode==="file").map(Ge=>il(Ge.targetPath,u)));return ge.map(Ge=>{const gt=yr(Ge),jt=gt?lt||o("contextPanel.tracker.branchTab"):uv(Ge,Ae,d),It=xv(jt,av),Mt=il(Ge.targetPath,u);return{id:Ge.id,label:It,labelFolder:Ge.mode==="file"?ie.get(Mt):void 0,icon:al(Ge,K),title:Mt?`${jt}: ${Mt}`:jt,closeLabel:o("contextPanel.tab.closeTabAria",{label:It}),closable:!gt,preview:Ge.preview}})},[ge,u,K,Ae,o,d,lt]),bt=V?.mode==="context"?s.jsx(fn,{value:q,children:s.jsx($y,{})}):V?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(fn,{value:q,children:s.jsx(iv,{isActive:ee})})}):V?.mode==="pr"?V.targetPath?s.jsx(kw,{url:V.targetPath,directory:V.targetDirectory??u,panelDirectory:u,tabId:V.id,foreign:!!V.targetDirectory,visible:ee},V.id):s.jsx(pw,{}):V?.mode==="notes"?s.jsx(fn,{value:q,children:s.jsx(Wf,{visible:ee})}):V?.mode==="workflows"?s.jsx(fn,{value:q,children:s.jsx(hy,{directory:u||null})}):null,kt=V?.mode==="file",ht=kt&&!!V?.targetPath&&O,St=ee&&V&&rt&&!ht&&!yr(V)?V.id:null;l.useEffect(()=>{if(!(!f||!St))return oc(()=>g(f,St),qe)},[g,f,St]);const yt=X(ie=>ie.closeContextPanelTabs),xt=l.useCallback(ie=>{if(!f)return null;const{id:Ge,index:gt,allIds:jt,close:It}=ie,Mt=()=>yt(f,jt.filter(Tt=>Tt!==Ge)),Kt=jt.slice(0,gt),Jt=jt.slice(gt+1),gs=()=>yt(f,a?Jt:Kt),Cs=()=>yt(f,a?Kt:Jt),Ts=()=>yt(f,jt),U=jt.length>1,Xe=a?gt===jt.length-1:gt===0,ot=a?gt===0:gt===jt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Ns,{onClick:It,children:[s.jsx(se,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),s.jsx(Dn,{}),s.jsxs(Ns,{onClick:Mt,disabled:!U,children:[s.jsx(se,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Ns,{onClick:gs,disabled:Xe,children:[s.jsx(se,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Ns,{onClick:Cs,disabled:ot,children:[s.jsx(se,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),s.jsx(Dn,{}),s.jsxs(Ns,{onClick:Ts,disabled:!U,children:[s.jsx(se,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),V?s.jsxs(s.Fragment,{children:[s.jsx(Dn,{}),s.jsx(mc,{mode:V.mode})]}):null]})},[V,yt,f,a,o]),vt=l.useCallback((ie,Ge)=>{const gt=H.find(It=>It.id===ie);if(!gt)return null;const jt=Gi({mode:gt.mode,label:Ar(gt.mode,d),from:t},Ge);return{finish:()=>jt.finish(f),cancel:jt.cancel}},[f,d,H,t]),[ct,Pt]=l.useState(null),Dt=l.useCallback(ie=>{if(!V||ie.button!==0||ie.pointerType==="touch"||ie.target instanceof Element&&ie.target.closest(wv))return;const Ge=V.mode,gt=Ar(Ge,d),jt={x:ie.clientX,y:ie.clientY};let It=!1;const Mt=Cs=>{const Ts={x:Cs.clientX,y:Cs.clientY};!It&&(Math.hypot(Ts.x-jt.x,Ts.y-jt.y)<bv||(It=Nd({mode:Ge,label:gt,from:t}),!It))||Ed(Ts)},Kt=()=>{window.removeEventListener("pointermove",Mt),window.removeEventListener("pointerup",Jt),window.removeEventListener("pointercancel",gs),window.removeEventListener("blur",gs)},Jt=()=>{Kt(),It&&Pd(f)},gs=()=>{Kt(),It&&ii()};window.addEventListener("pointermove",Mt),window.addEventListener("pointerup",Jt),window.addEventListener("pointercancel",gs),window.addEventListener("blur",gs)},[V,f,d,t]);l.useEffect(()=>{if(ct)return ct.addEventListener("pointerdown",Dt),()=>ct.removeEventListener("pointerdown",Dt)},[Dt,ct]);const pt=s.jsxs("header",{ref:Pt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[rt?s.jsx(Dh,{items:Ct,activeId:V?.id??null,onSelect:ie=>{f&&I(f,ie)},onClose:ie=>{f&&g(f,ie)},onReorder:(ie,Ge)=>{f&&j(f,ie,Ge)},onDoubleClickTab:ie=>{f&&b(f,ie)},layoutMode:"scrollable",variant:"default",tabContextMenu:xt,onTabDragOut:vt}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[V?al(V,K):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:V?Ar(V.mode,d):null})]}),s.jsx("div",{ref:z,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),s.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[V?.mode==="browser"?s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&$(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:s.jsx(se,{name:"add",className:"h-3.5 w-3.5"})}):null,kt?["left","right"].map(ie=>{const Ge=ie===A;if(!Ge&&!le)return null;const gt=o(Ge?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:Ge?k:T,className:"h-7 w-7 p-0",title:gt,"aria-label":gt,"aria-pressed":Ge?R:O,children:s.jsx(se,{name:ie==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},ie)}):null,Y?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:ke,className:"h-7 w-7 p-0","aria-label":o(Z?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:Z?s.jsx(se,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(se,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:o(Z?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:ws(Es("toggle_context_panel_expanded",h),"")})})]}),s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:fe,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:s.jsx(se,{name:"close",className:"h-3.5 w-3.5"})})]})]}),mt=ee?ye?`calc(var(${e.sizeVariable}) + ${Cn}px)`:`min(var(${e.sizeVariable}), 100%)`:be?`${Cn}px`:"0px",Ot=ye?`${Cn}px`:"0px";ae.current=ye;const Ut=t==="bottom"&&tr(p,m,"left"),ss=t==="bottom"&&(C&&!re||tr(p,m,"right")),ps=`${ee}|${Z}|${be}|${ee&&ye}|${ee?L:""}`,ns=l.useRef(ps),ms=l.useRef(re),ls=ms.current!==re;l.useLayoutEffect(()=>{ms.current=re},[re]),l.useLayoutEffect(()=>{if(ns.current===ps)return;ns.current=ps;const ie=ve.current;!ls&&!ie&&Ec(n)},[ps,ls,n]),l.useLayoutEffect(()=>{ve.current=!1});const rs=!Er(ee,rr(ee),V?.mode),Rs={[e.sizeVariable]:`${Ce}px`,...r?{height:mt,maxHeight:"100%"}:{width:mt,maxWidth:"100%"},transitionDuration:ls||Ie?"0ms":`${n}ms`,transitionTimingFunction:Wn},Vt=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,cs=l.useRef(mt);cs.current=mt;const Ht=l.useRef(Vt);return Ht.current=Vt,s.jsxs("aside",{ref:qe,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":ee?"true":"false",tabIndex:-1,className:$e("flex min-h-0 flex-col overflow-clip bg-background","isolate",r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),style:Rs,children:[s.jsx("div",{ref:et,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?s.jsx("div",{ref:_h,className:$e("absolute inset-y-0 z-0 flex",ye?"inset-s-0":"inset-e-0",re&&"invisible")}):null,ee&&s.jsx("div",{className:e.handle,style:{marginInlineStart:Ot},onPointerDown:Je,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{ref:v,"data-zone-card":"",className:$e("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Ut?"ms-0":"ms-2"),t==="bottom"&&(ss?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity,margin-inline-start]",!ee&&"opacity-0",rs&&"pointer-events-none select-none"),style:{...r?{height:Vt,width:`calc(100% - ${(Ut?0:.5)+(ss?0:.375)}rem)`}:{width:Vt},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Ot})`}:null,transitionDuration:Ie?"0ms":`${n}ms`,transitionTimingFunction:Wn},inert:rs||void 0,children:s.jsxs(Wc.Provider,{value:!0,children:[pt,s.jsx("div",{ref:ne,className:"relative min-h-0 flex-1 overflow-hidden",children:V&&yv(V.mode)?bt:null})]})})]})},kv=Qs({port:mo().int().positive(),url:Ps().min(1),command:Ps(),directory:Ps().min(1).optional()}),jv=t=>{const e=Qs({servers:ud(F1())}).safeParse(t);return e.success?e.data.servers.flatMap(n=>{const r=kv.safeParse(n);return r.success?[r.data]:[]}):null},Cv=async(t,e)=>{try{const n=await Vs("/api/dev-servers",{signal:t,directory:e});if(!n.ok)return{kind:"unavailable"};const r=jv(await n.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Tv=async t=>{try{const e=await Vs("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},Nv=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},Ev=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=Nv(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0,directory:r.directory}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Pv=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),cl=(t,e)=>{if(!e)return null;let n=null;for(const r of t)Pv(r.path,e)&&(!n||r.path.length>n.path.length)&&(n=r);return n},Iv=t=>t.slice(t.lastIndexOf("/")+1)||t,Rv=({candidates:t,folders:e,directory:n})=>{const r=e.flatMap(c=>{const d=Yt(c.path),f=Yt(c.projectPath);return d&&f?[{path:d,projectPath:f}]:[]}),o=Yt(n),i=o?{path:o,projectPath:cl(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(c=>{const d=Yt(c.directory),f=cl(a,d),p=c.announced?0:f&&i&&f.path===i.path?1:f&&i&&f.projectPath===i.projectPath?2:3;return{server:{...c,folderName:f?Iv(f.path):null,outsideWork:d!==null&&f===null&&!c.announced},rank:p}}).sort((c,d)=>c.rank-d.rank||c.server.port-d.server.port).map(c=>c.server)},Dv=t=>({sessionId:t.sessionId,directory:t.directory?us(t.directory):null}),_v=2e3,Av=Qs({title:Ps(),settled:dr()}),Ov=4e4,Mv=50,or=400,hs=new Map,As=new Map;let li=null,ci=null;const fr=new Map;let Bs=null,Ys=null,ir=null;const zs=async t=>{try{const e=await Vs("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},Fv=async(t,e)=>{try{const n=await Vs("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},_d=async(t,e=_v)=>{const n=Date.now()+e;for(;!hs.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,Mv));return hs.get(t)??null},qr=t=>hs.has(t)||As.has(t),Hn=t=>hs.get(t)??As.get(t)??null,di=()=>[...hs.values(),...[...As.values()].filter(t=>!hs.has(t.tabId))],Xi=t=>{const e=ci?Hn(ci):null,n=e?.directory===li?e:null;if(!t.sessionId){if(n)return n.tabId;const i=di().filter(c=>c.directory===li),a=i.filter(c=>hs.has(c.tabId)),u=a.length>0?a:i;return u.length>0?u[u.length-1].tabId:null}if(n?.ownerSessionId===t.sessionId)return n.tabId;const r=fr.get(t.sessionId);if(r&&Hn(r)?.ownerSessionId===t.sessionId)return r;const o=di().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:n&&n.ownerSessionId===null&&(!t.directory||n.directory===t.directory)?n.tabId:null},Lv=t=>{const e=Xi(t);return e&&Hn(e)?.ownerSessionId===t.sessionId?e:null},$v=(t,e)=>{t.sessionId&&Hn(e)?.ownerSessionId===t.sessionId&&fr.set(t.sessionId,e)},Ad=async t=>{const e=hs.get(t);if(e)return e;const n=As.get(t);return n?(n.wake(),_d(t)):null},Od=t=>{const e=Xi(t);return di().filter(n=>!t.sessionId||!t.directory||n.ownerSessionId===t.sessionId||n.directory===t.directory).map(n=>{let r={title:"",url:""};try{r=n.describe()}catch{}const o=n.ownerSessionId===null?"user":n.ownerSessionId===t.sessionId?"you":"another session";return{id:n.tabId,title:r.title,url:r.url,owner:o,active:n.tabId===e}})},Md=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Fd=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,Bv=t=>{const e=Od(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
5
+ `);return s.jsxs("div",{className:$e("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[s.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),s.jsx("dd",{className:"min-w-0 typography-meta",children:s.jsx(go,{node:n})})]},e)}function Bw(t,e){return s.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:s.jsx(go,{node:t})},e)}function zw(t,e){return s.jsx("li",{className:"typography-meta",children:s.jsx(go,{node:t})},e)}function Ww(t){return!t}const Cd=t=>t.slice(t.indexOf("/")+1),Hi=t=>{const e=Be.c(7),{start:n,end:r,className:o}=t,i=ph(n!==void 0&&r===void 0);if(n===void 0)return null;let a;e[0]!==o?(a=$e("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const u=(r??i)-n;let c;e[2]!==u?(c=mh(u),e[2]=u,e[3]=c):c=e[3];let d;return e[4]!==a||e[5]!==c?(d=s.jsx("span",{className:a,dir:"auto",children:c}),e[4]=a,e[5]=c,e[6]=d):d=e[6],d},Uw=t=>{const e=t.flatMap(o=>o.startedAt===void 0||o.replayed?[]:[o.startedAt]);if(e.length===0)return{start:void 0,end:void 0};const n=t.some(o=>o.state==="running"||o.state==="queued"),r=t.flatMap(o=>o.endedAt===void 0?[]:[o.endedAt]);return{start:Math.min(...e),end:n?void 0:Math.max(...r,...e)}},Vw=t=>{const e=Be.c(18),{run:n,groups:r}=t,{t:o}=at();let i,a,u,c,d,f;if(e[0]!==r||e[1]!==n||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const m=r.filter(Xw);if(m.length===0){f=null;break e}i=fs,a="overlay-scrollbar-wrapper--no-gutter",u=!1,c="flex gap-1.5 pb-1";let h;e[9]!==n||e[10]!==o?(h=x=>{const g=x.agents.length,b=Uw(x.agents),w=n.state==="running"&&n.currentPhase===x.title;return s.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[s.jsx("div",{className:$e("truncate typography-meta",w?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?s.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):s.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?s.jsx(Hi,{start:b.start,end:b.end,className:"ms-auto"}):null]}),s.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?s.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(x.done/g*100)}%`,background:x.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},x.title)},e[9]=n,e[10]=o,e[11]=h):h=e[11],d=m.map(h)}e[0]=r,e[1]=n,e[2]=o,e[3]=i,e[4]=a,e[5]=u,e[6]=c,e[7]=d,e[8]=f}else i=e[3],a=e[4],u=e[5],c=e[6],d=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[12]!==i||e[13]!==a||e[14]!==u||e[15]!==c||e[16]!==d?(p=s.jsx(i,{outerClassName:a,fillContainer:u,className:c,children:d}),e[12]=i,e[13]=a,e[14]=u,e[15]=c,e[16]=d,e[17]=p):p=e[17],p},Hw=t=>{const e=Be.c(30),{run:n,agent:r,onOpenSession:o}=t,{t:i}=at(),[a,u]=l.useState(null),[c,d]=l.useState(!1),[f,p]=l.useState(!1);let m;e[0]!==r.key||e[1]!==n.id?(m=()=>{let I=!0;return d(!1),hh(n.id,r.key).then(j=>{I&&u(j)}).catch(()=>{I&&d(!0)}),()=>{I=!1}},e[0]=r.key,e[1]=n.id,e[2]=m):m=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==n.id?(h=[r.key,r.state,n.id],e[3]=r.key,e[4]=r.state,e[5]=n.id,e[6]=h):h=e[6],l.useEffect(m,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?s.jsx("p",{className:"typography-meta",style:{color:r.state==="failed"?"var(--status-error)":void 0},children:r.error}):null,e[7]=r.error,e[8]=r.state,e[9]=x):x=e[9];let g;e[10]!==c||e[11]!==i?(g=c?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.loadFailed")}):null,e[10]=c,e[11]=i,e[12]=g):g=e[12];let b;e[13]!==a||e[14]!==c||e[15]!==i?(b=!a&&!c?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),s.jsx(Li,{})]}):null,e[13]=a,e[14]=c,e[15]=i,e[16]=b):b=e[16];let w;e[17]!==a||e[18]!==f||e[19]!==i?(w=a?s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),s.jsx("div",{className:"mt-1",children:a.result===void 0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):s.jsx(jd,{answer:a.result})})]}),s.jsxs("section",{children:[s.jsxs("button",{type:"button",onClick:()=>p(Yw),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:$e("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]}),f?s.jsx(fs,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:!0,children:a.prompt}):null]})]}):null,e[17]=a,e[18]=f,e[19]=i,e[20]=w):w=e[20];let S;e[21]!==o||e[22]!==i?(S=o?s.jsx("div",{children:s.jsxs(ft,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}):null,e[21]=o,e[22]=i,e[23]=S):S=e[23];let y;return e[24]!==x||e[25]!==g||e[26]!==b||e[27]!==w||e[28]!==S?(y=s.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[x,g,b,w,S]}),e[24]=x,e[25]=g,e[26]=b,e[27]=w,e[28]=S,e[29]=y):y=e[29],y},qw=t=>{const e=Be.c(57),{run:n,agent:r,showModel:o,columns:i,open:a,onToggle:u,onOpenSession:c}=t,{t:d}=at();let f,p,m,h,x,g,b,w,S,y,I;if(e[0]!==r||e[1]!==i.tokens||e[2]!==u||e[3]!==a||e[4]!==o||e[5]!==d){const k=uh(r.state),N=fh(r);f="button",h=u,x=a,g=r.label,b="flex h-7 w-full min-w-0 items-center gap-2 rounded-md text-start typography-meta text-foreground/80 hover:text-foreground";const T=k.icon,A=k.color?{color:k.color}:void 0,$=d(k.labelKey);e[17]!==k||e[18]!==A||e[19]!==$?(w=s.jsx(se,{name:T,className:"size-3.5 shrink-0",style:A,"aria-label":$}),e[17]=k,e[18]=A,e[19]=$,e[20]=w):w=e[20],e[21]!==r.label?(S=s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=S):S=e[22],e[23]!==r.replayed||e[24]!==d?(y=r.replayed?s.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:d("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=d,e[25]=y):y=e[25],e[26]!==r.model||e[27]!==o?(I=o&&r.model?s.jsx("span",{className:"oc-tile-inset max-w-[9rem] shrink-0 truncate rounded-full px-1.5 typography-micro text-muted-foreground",title:r.model,dir:"ltr",children:Cd(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=I):I=e[28];const K=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==K?(p=s.jsx(Hi,{start:K,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=K,e[31]=p):p=e[31],m=i.tokens?s.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:N===null||r.replayed?"":Mi(N)}):null,e[0]=r,e[1]=i.tokens,e[2]=u,e[3]=a,e[4]=o,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h,e[10]=x,e[11]=g,e[12]=b,e[13]=w,e[14]=S,e[15]=y,e[16]=I}else f=e[6],p=e[7],m=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13],S=e[14],y=e[15],I=e[16];let j;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(j=i.cost?s.jsx("span",{className:"min-w-14 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"ltr",children:r.usage&&!r.replayed&&r.usage.cost>0?Fi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=j):j=e[35];let R;e[36]!==f||e[37]!==p||e[38]!==m||e[39]!==j||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==b||e[44]!==w||e[45]!==S||e[46]!==y||e[47]!==I?(R=s.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:b,children:[w,S,y,I,p,m,j]}),e[36]=f,e[37]=p,e[38]=m,e[39]=j,e[40]=h,e[41]=x,e[42]=g,e[43]=b,e[44]=w,e[45]=S,e[46]=y,e[47]=I,e[48]=R):R=e[48];let _;e[49]!==r||e[50]!==c||e[51]!==a||e[52]!==n?(_=a?s.jsx(Hw,{run:n,agent:r,onOpenSession:c}):null,e[49]=r,e[50]=c,e[51]=a,e[52]=n,e[53]=_):_=e[53];let P;return e[54]!==R||e[55]!==_?(P=s.jsxs(s.Fragment,{children:[R,_]}),e[54]=R,e[55]=_,e[56]=P):P=e[56],P},Gw=(t,e)=>{const n=dh(t);if(n.measured===0)return null;const r=[];return e.tokens&&r.push(Mi(n.tokens)),e.cost&&n.cost>0&&r.push(Fi(n.cost)),r.length>0?r.join(" · "):null},Kw=t=>{const e=new Set(t.map(r=>r.model??null)),[n]=e;return e.size===1&&n?Cd(n):null},Zw=t=>{const e=Be.c(51),{run:n,directory:r}=t,{t:o}=at();let i;e[0]!==n?(i=ah(n),e[0]=n,e[1]=i):i=e[1];const a=i,u=lh(r),[c,d]=l.useState(Jw),[f,p]=l.useState(Qw);let m,h,x,g,b,w;if(e[2]!==a||e[3]!==c||e[4]!==u||e[5]!==n||e[6]!==o||e[7]!==f){const I=ch(n),j=I.measured>0,R=I.cost>0;let _,P,k;if(e[14]!==a||e[15]!==c||e[16]!==u||e[17]!==n||e[18]!==o||e[19]!==j||e[20]!==R||e[21]!==f){const N={tokens:j,cost:R},T=n.agents.filter(ey).length,A=ty;b="flex h-full min-h-0 flex-col";let $;e[28]!==a||e[29]!==n?($=s.jsx(Vw,{run:n,groups:a}),e[28]=a,e[29]=n,e[30]=$):$=e[30];const K=a.map(q=>{if(q.agents.length===0)return null;const M=q.title??"",z=q.done+q.failed===q.agents.length,H=(n.state==="running"&&z)===f.has(M),V=Kw(q.agents),F=Gw(q.agents,N);return s.jsxs("section",{className:"mt-3",children:[s.jsxs("button",{type:"button",onClick:()=>A(p,M),"aria-expanded":H,className:"flex h-7 w-full min-w-0 items-center gap-1.5 text-start typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(se,{name:"arrow-right-s",className:$e("size-3.5 shrink-0 transition-transform",H&&"rotate-90 rtl:-rotate-90")}),s.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:q.title??o("chat.workflow.phase.unphased")}),V?s.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${V}`}):null,F?s.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:F}):null,s.jsx("span",{className:$e("shrink-0 tabular-nums font-normal",!F&&"ms-auto"),dir:"auto",children:F?`· ${q.done}/${q.agents.length}`:`${q.done}/${q.agents.length}`})]}),H?q.agents.map(C=>{const te=C.sessionId;return s.jsx(qw,{run:n,agent:C,showModel:V===null,columns:N,open:c.has(C.key),onToggle:()=>A(d,C.key),onOpenSession:te?()=>u(te,C.label):null},C.key)}):null]},M)});e[31]!==$||e[32]!==K?(w=s.jsxs(fs,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[$,K]}),e[31]=$,e[32]=K,e[33]=w):w=e[33],m="flex shrink-0 flex-wrap items-center gap-x-1.5 border-t border-edge px-3 py-2 typography-micro text-muted-foreground",_="tabular-nums",P="auto",k=o("workflows.panel.summary.agents",{done:T,total:n.agents.length}),e[14]=a,e[15]=c,e[16]=u,e[17]=n,e[18]=o,e[19]=j,e[20]=R,e[21]=f,e[22]=_,e[23]=P,e[24]=k,e[25]=m,e[26]=b,e[27]=w}else _=e[22],P=e[23],k=e[24],m=e[25],b=e[26],w=e[27];e[34]!==_||e[35]!==P||e[36]!==k?(h=s.jsx("span",{className:_,dir:P,children:k}),e[34]=_,e[35]=P,e[36]=k,e[37]=h):h=e[37],e[38]!==n.endedAt||e[39]!==n.startedAt||e[40]!==n.state?(x=n.startedAt!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx(Hi,{start:n.startedAt,end:n.state==="running"?void 0:n.endedAt??n.startedAt})]}):null,e[38]=n.endedAt,e[39]=n.startedAt,e[40]=n.state,e[41]=x):x=e[41],g=I.measured>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:Mi(I.tokens)})}),I.cost>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"ltr",children:Fi(I.cost)})]}):null]}):null,e[2]=a,e[3]=c,e[4]=u,e[5]=n,e[6]=o,e[7]=f,e[8]=m,e[9]=h,e[10]=x,e[11]=g,e[12]=b,e[13]=w}else m=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13];let S;e[42]!==m||e[43]!==h||e[44]!==x||e[45]!==g?(S=s.jsxs("div",{className:m,children:[h,x,g]}),e[42]=m,e[43]=h,e[44]=x,e[45]=g,e[46]=S):S=e[46];let y;return e[47]!==b||e[48]!==w||e[49]!==S?(y=s.jsxs("div",{className:b,children:[w,S]}),e[47]=b,e[48]=w,e[49]=S,e[50]=y):y=e[50],y};function Xw(t){return t.title!==null}function Yw(t){return!t}function Jw(){return new Set}function Qw(){return new Set}function ey(t){return t.state==="completed"}function ty(t,e){return t(n=>{const r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})}const sy={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},ny=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script"}],ry=1500,oy=(t,e)=>{const n=Be.c(11),[r,o]=l.useState(null),[i,a]=l.useState(null),u=l.useRef(null),c=e!=="agents",d=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;n[0]!==t.id||n[1]!==c?(f=()=>{if(!c)return;let g=!0;const b=u.current?.runId===t.id?u.current.at:0,w=Math.max(0,b+ry-Date.now()),S=setTimeout(()=>{u.current={runId:t.id,at:Date.now()},jh(t.id).then(y=>{g&&(o(y),a(null))}).catch(()=>{g&&a(t.id)})},w);return()=>{g=!1,clearTimeout(S)}},n[0]=t.id,n[1]=c,n[2]=f):f=n[2];let p;n[3]!==d||n[4]!==t.id||n[5]!==t.state||n[6]!==c?(p=[d,t.id,t.state,c],n[3]=d,n[4]=t.id,n[5]=t.state,n[6]=c,n[7]=p):p=n[7],l.useEffect(f,p);const m=r?.runId===t.id?r:null,h=i===t.id;let x;return n[8]!==m||n[9]!==h?(x={detail:m,failed:h},n[8]=m,n[9]=h,n[10]=x):x=n[10],x},iy=t=>new Intl.DateTimeFormat(Bc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),ay=t=>{const e=Be.c(8),{run:n,detail:r}=t,{t:o}=at(),i=r?.logs??n.logs;if(i.length===0){let c;e[0]!==o?(c=o("workflows.panel.log.empty"),e[0]=o,e[1]=c):c=e[1];let d;return e[2]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[2]=c,e[3]=d):d=e[3],d}let a;e[4]!==i?(a=i.map(xy),e[4]=i,e[5]=a):a=e[5];let u;return e[6]!==a?(u=s.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=u):u=e[7],u},ly=t=>{const e=Be.c(24),{run:n,detail:r,failed:o}=t,{t:i}=at();if(n.error&&(n.state==="failed"||n.state==="stopped")){const c=n.state==="failed"?"var(--status-error)":void 0;let d;e[0]!==c?(d={color:c},e[0]=c,e[1]=d):d=e[1];let f;return e[2]!==n.error||e[3]!==d?(f=s.jsx("p",{className:"px-4 py-6 typography-meta",style:d,children:n.error}),e[2]=n.error,e[3]=d,e[4]=f):f=e[4],f}if(n.state==="awaiting-approval"||n.state==="running"||n.state==="declined"){let c;e[5]!==i?(c=i("workflows.panel.result.pending"),e[5]=i,e[6]=c):c=e[6];let d;return e[7]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[7]=c,e[8]=d):d=e[8],d}if(o&&!r){let c;e[9]!==i?(c=i("workflows.panel.detail.loadFailed"),e[9]=i,e[10]=c):c=e[10];let d;return e[11]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[11]=c,e[12]=d):d=e[12],d}if(!r){let c;e[13]!==i?(c=i("workflows.panel.agent.loading"),e[13]=i,e[14]=c):c=e[14];let d;e[15]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Li,{}),e[15]=d):d=e[15];let f;return e[16]!==c?(f=s.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[c,d]}),e[16]=c,e[17]=f):f=e[17],f}const{result:a}=r;if(!a||a.kind==="json"&&a.value===null){let c;e[18]!==i?(c=i("workflows.panel.result.none"),e[18]=i,e[19]=c):c=e[19];let d;return e[20]!==c?(d=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:c}),e[20]=c,e[21]=d):d=e[21],d}let u;return e[22]!==a?(u=s.jsx("div",{className:"px-4 py-3",children:s.jsx(jd,{answer:a})}),e[22]=a,e[23]=u):u=e[23],u},cy=t=>{const e=Be.c(16),{detail:n,failed:r}=t,{t:o}=at();if(!n){let p;e[0]!==r||e[1]!==o?(p=r?o("workflows.panel.detail.loadFailed"):s.jsxs(s.Fragment,{children:[o("workflows.panel.agent.loading"),s.jsx(Li,{})]}),e[0]=r,e[1]=o,e[2]=p):p=e[2];let m;return e[3]!==p?(m=s.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:p}),e[3]=p,e[4]=m):m=e[4],m}const i=n.args;let a;e[5]!==i?(a=i!=null&&JSON.stringify(i)!=="{}",e[5]=i,e[6]=a):a=e[6];const u=a;let c;e[7]!==i||e[8]!==u||e[9]!==o?(c=u?s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),s.jsx(fs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile mt-1 rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro text-foreground",children:JSON.stringify(i,null,2)})]}):null,e[7]=i,e[8]=u,e[9]=o,e[10]=c):c=e[10];let d;e[11]!==n.script?(d=s.jsx(fs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:n.script}),e[11]=n.script,e[12]=d):d=e[12];let f;return e[13]!==c||e[14]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[c,d]}),e[13]=c,e[14]=d,e[15]=f):f=e[15],f},dy=t=>{const e=Be.c(63),{run:n}=t,{t:r}=at(),{pending:o,act:i}=kh(),a=o===n.id;if(n.state==="awaiting-approval"){let u;e[0]!==i||e[1]!==n.id?(u=()=>i(n.id,"approve"),e[0]=i,e[1]=n.id,e[2]=u):u=e[2];let c;e[3]!==r?(c=r("chat.workflow.action.run"),e[3]=r,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"play",className:"size-3.5"}),e[5]=d):d=e[5];let f;e[6]!==r?(f=r("chat.workflow.action.run"),e[6]=r,e[7]=f):f=e[7];let p;e[8]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[8]=f,e[9]=p):p=e[9];let m;e[10]!==a||e[11]!==u||e[12]!==c||e[13]!==p?(m=s.jsxs(ft,{type:"button",size:"sm",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[10]=a,e[11]=u,e[12]=c,e[13]=p,e[14]=m):m=e[14];let h;e[15]!==i||e[16]!==n.id?(h=()=>i(n.id,"decline"),e[15]=i,e[16]=n.id,e[17]=h):h=e[17];let x;e[18]!==r?(x=r("chat.workflow.action.decline"),e[18]=r,e[19]=x):x=e[19];let g;e[20]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(se,{name:"close",className:"size-3.5"}),e[20]=g):g=e[20];let b;e[21]!==r?(b=r("chat.workflow.action.decline"),e[21]=r,e[22]=b):b=e[22];let w;e[23]!==b?(w=s.jsx("span",{className:"workflows-header__action-label",children:b}),e[23]=b,e[24]=w):w=e[24];let S;e[25]!==a||e[26]!==w||e[27]!==h||e[28]!==x?(S=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:h,"aria-label":x,children:[g,w]}),e[25]=a,e[26]=w,e[27]=h,e[28]=x,e[29]=S):S=e[29];let y;return e[30]!==S||e[31]!==m?(y=s.jsxs(s.Fragment,{children:[m,S]}),e[30]=S,e[31]=m,e[32]=y):y=e[32],y}if(n.state==="running"){let u;e[33]!==i||e[34]!==n.id?(u=()=>i(n.id,"stop"),e[33]=i,e[34]=n.id,e[35]=u):u=e[35];let c;e[36]!==r?(c=r("chat.workflow.action.stop"),e[36]=r,e[37]=c):c=e[37];let d;e[38]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"stop",className:"size-3.5"}),e[38]=d):d=e[38];let f;e[39]!==r?(f=r("chat.workflow.action.stop"),e[39]=r,e[40]=f):f=e[40];let p;e[41]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[41]=f,e[42]=p):p=e[42];let m;return e[43]!==a||e[44]!==u||e[45]!==c||e[46]!==p?(m=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[43]=a,e[44]=u,e[45]=c,e[46]=p,e[47]=m):m=e[47],m}if(n.state==="failed"||n.state==="stopped"){let u;e[48]!==i||e[49]!==n.id?(u=()=>i(n.id,"resume"),e[48]=i,e[49]=n.id,e[50]=u):u=e[50];let c;e[51]!==r?(c=r("chat.workflow.action.resume"),e[51]=r,e[52]=c):c=e[52];let d;e[53]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(se,{name:"restart",className:"size-3.5"}),e[53]=d):d=e[53];let f;e[54]!==r?(f=r("chat.workflow.action.resume"),e[54]=r,e[55]=f):f=e[55];let p;e[56]!==f?(p=s.jsx("span",{className:"workflows-header__action-label",children:f}),e[56]=f,e[57]=p):p=e[57];let m;return e[58]!==a||e[59]!==u||e[60]!==c||e[61]!==p?(m=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":c,children:[d,p]}),e[58]=a,e[59]=u,e[60]=c,e[61]=p,e[62]=m):m=e[62],m}return null},uy=()=>{const t=Be.c(2),e=ts(by);let n;return t[0]!==e?(n={get:r=>e.get(r)?.title},t[0]=e,t[1]=n):n=t[1],n},el=t=>{const e=Be.c(31),{run:n,selected:r,caption:o,onSelect:i}=t,{t:a}=at();let u,c,d,f,p,m,h;if(e[0]!==i||e[1]!==n.state||e[2]!==a){const I=$c(n.state);c=qt,h=i,u=se,d=I.icon,f="size-3.5 shrink-0",p=I.color?{color:I.color}:void 0,m=a(I.labelKey),e[0]=i,e[1]=n.state,e[2]=a,e[3]=u,e[4]=c,e[5]=d,e[6]=f,e[7]=p,e[8]=m,e[9]=h}else u=e[3],c=e[4],d=e[5],f=e[6],p=e[7],m=e[8],h=e[9];let x;e[10]!==u||e[11]!==d||e[12]!==f||e[13]!==p||e[14]!==m?(x=s.jsx(u,{name:d,className:f,style:p,"aria-label":m}),e[10]=u,e[11]=d,e[12]=f,e[13]=p,e[14]=m,e[15]=x):x=e[15];let g;e[16]!==n.name?(g=s.jsx("span",{className:"truncate",dir:"auto",children:n.name}),e[16]=n.name,e[17]=g):g=e[17];let b;e[18]!==o?(b=o?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=b):b=e[19];let w;e[20]!==g||e[21]!==b?(w=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,b]}),e[20]=g,e[21]=b,e[22]=w):w=e[22];let S;e[23]!==r?(S=r?s.jsx(se,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=S):S=e[24];let y;return e[25]!==c||e[26]!==S||e[27]!==h||e[28]!==x||e[29]!==w?(y=s.jsxs(c,{onSelect:h,children:[x,w,S]}),e[25]=c,e[26]=S,e[27]=h,e[28]=x,e[29]=w,e[30]=y):y=e[30],y},fy=t=>{const e=Be.c(56),{runs:n,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:u,onRunSaved:c,onDelete:d}=t,{t:f}=at();let p;e[0]!==r.state?(p=$c(r.state),e[0]=r.state,e[1]=p):p=e[1];const m=p;let h,x,g,b,w,S,y;if(e[2]!==m.color||e[3]!==m.icon||e[4]!==u||e[5]!==n||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const P=n.slice().reverse();let k;e[18]!==o?(k=H=>H.parentSessionId===o,e[18]=o,e[19]=k):k=e[19];const N=P.filter(k);let T;e[20]!==o?(T=H=>H.parentSessionId!==o,e[20]=o,e[21]=T):T=e[21];const A=P.filter(T);x=xn;let $;e[22]!==f?($=f("workflows.panel.runPicker"),e[22]=f,e[23]=$):$=e[23];let K;e[24]===Symbol.for("react.memo_cache_sentinel")?(K=$e(Sh(),"max-w-[14rem] shrink-0"),e[24]=K):K=e[24];let q;e[25]!==m.color?(q=m.color?{color:m.color}:void 0,e[25]=m.color,e[26]=q):q=e[26];let M;e[27]!==m.icon||e[28]!==q?(M=s.jsx(se,{name:m.icon,className:"size-3.5",style:q}),e[27]=m.icon,e[28]=q,e[29]=M):M=e[29];let z;e[30]!==r.name?(z=s.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=z):z=e[31];let ne;e[32]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(se,{name:"arrow-down-s",className:"size-4"}),e[32]=ne):ne=e[32],e[33]!==M||e[34]!==z||e[35]!==$?(y=s.jsx(bn,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":$,className:K,children:[M,z,ne]})}),e[33]=M,e[34]=z,e[35]=$,e[36]=y):y=e[36],h=wn,g="start",b="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",w=N.length>0?s.jsxs(s.Fragment,{children:[s.jsx(Ir,{children:f("workflows.panel.picker.thisSession")}),N.map(H=>s.jsx(el,{run:H,selected:H.id===r.id,onSelect:()=>u(H.id)},H.id))]}):null,S=A.length>0?s.jsxs(s.Fragment,{children:[N.length>0?s.jsx(mn,{}):null,s.jsx(Ir,{children:f("workflows.panel.picker.otherSessions")}),A.map(H=>s.jsx(el,{run:H,selected:H.id===r.id,caption:i.get(H.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>u(H.id)},H.id))]}):null,e[2]=m.color,e[3]=m.icon,e[4]=u,e[5]=n,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=i,e[10]=f,e[11]=h,e[12]=x,e[13]=g,e[14]=b,e[15]=w,e[16]=S,e[17]=y}else h=e[11],x=e[12],g=e[13],b=e[14],w=e[15],S=e[16],y=e[17];let I;e[37]!==c||e[38]!==a||e[39]!==f?(I=a.length>0?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsx(Ir,{children:f("workflows.panel.picker.saved")}),a.map(P=>s.jsxs(qt,{disabled:!!P.error,onSelect:()=>c(P.name),title:P.error??P.description,children:[s.jsx(se,{name:"play",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:P.name})]},P.name))]}):null,e[37]=c,e[38]=a,e[39]=f,e[40]=I):I=e[40];let j;e[41]!==d||e[42]!==f?(j=d?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsxs(qt,{variant:"destructive",onSelect:d,children:[s.jsx(se,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[41]=d,e[42]=f,e[43]=j):j=e[43];let R;e[44]!==h||e[45]!==g||e[46]!==b||e[47]!==w||e[48]!==S||e[49]!==I||e[50]!==j?(R=s.jsxs(h,{align:g,className:b,children:[w,S,I,j]}),e[44]=h,e[45]=g,e[46]=b,e[47]=w,e[48]=S,e[49]=I,e[50]=j,e[51]=R):R=e[51];let _;return e[52]!==x||e[53]!==y||e[54]!==R?(_=s.jsxs(x,{children:[y,R]}),e[52]=x,e[53]=y,e[54]=R,e[55]=_):_=e[55],_},py=(t,e,n,r)=>{const o=Be.c(11),{t:i}=at(),{confirm:a,dialog:u}=_i(),c=$i(wy);let d;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==c||o[4]!==r||o[5]!==n||o[6]!==i?(d=async m=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:m}),message:i(n?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const x=await wh({directory:t,scriptDirectory:e,sessionId:n,name:m});n?c(r,x.runId):(c(x.sessionId,x.runId),tt.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;_e.error(i("workflows.panel.saved.failed"),{description:g instanceof Error?g.message:void 0})}},o[0]=a,o[1]=t,o[2]=e,o[3]=c,o[4]=r,o[5]=n,o[6]=i,o[7]=d):d=o[7];const f=d;let p;return o[8]!==u||o[9]!==f?(p={run:f,dialog:u},o[8]=u,o[9]=f,o[10]=p):p=o[10],p},my=t=>{const e=Be.c(23),{saved:n,onRunSaved:r}=t,{t:o}=at();if(n.length===0){let p;e[0]!==o?(p=o("workflows.panel.emptyProject"),e[0]=o,e[1]=p):p=e[1];let m;return e[2]!==p?(m=s.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3],m}let i;e[4]!==o?(i=o("workflows.panel.emptyProject"),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==i?(a=s.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[6]=i,e[7]=a):a=e[7];let u;e[8]!==o?(u=o("workflows.panel.picker.saved"),e[8]=o,e[9]=u):u=e[9];let c;e[10]!==u?(c=s.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:u}),e[10]=u,e[11]=c):c=e[11];let d;if(e[12]!==r||e[13]!==n||e[14]!==o){let p;e[16]!==r||e[17]!==o?(p=m=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:m.name}),m.description||m.error?s.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:m.error??m.description,children:m.error??m.description}):null]}),s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:!!m.error,onClick:()=>r(m.name),"aria-label":o("workflows.panel.saved.runAria",{name:m.name}),children:[s.jsx(se,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})]},m.name),e[16]=r,e[17]=o,e[18]=p):p=e[18],d=n.map(p),e[12]=r,e[13]=n,e[14]=o,e[15]=d}else d=e[15];let f;return e[19]!==a||e[20]!==c||e[21]!==d?(f=s.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[a,c,d]}),e[19]=a,e[20]=c,e[21]=d,e[22]=f):f=e[22],f},hy=t=>{const e=Be.c(17),{directory:n}=t,r=tt(yy),o=gh(n),i=xh(o),a=bh(o?.savedDirectory??null),u=r??`directory:${n??""}`;let c;e[0]!==u?(c=b=>b.selectedBySession[u],e[0]=u,e[1]=c):c=e[1];const d=$i(c),{run:f,dialog:p}=py(n,o?.savedDirectory??null,r,u);let m;e[2]!==i||e[3]!==d||e[4]!==r?(m=i.find(b=>b.id===d)??i.filter(b=>b.parentSessionId===r).at(-1)??i.at(-1)??null,e[2]=i,e[3]=d,e[4]=r,e[5]=m):m=e[5];const h=m;let x;e[6]!==n||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==u||e[12]!==r?(x=h?s.jsx(gy,{sessionId:r,selectionKey:u,runs:i,saved:a,run:h,directory:n,onRunSaved:b=>{f(b)}}):s.jsx(my,{saved:a,onRunSaved:b=>{f(b)}}),e[6]=n,e[7]=h,e[8]=f,e[9]=i,e[10]=a,e[11]=u,e[12]=r,e[13]=x):x=e[13];let g;return e[14]!==p||e[15]!==x?(g=s.jsxs(s.Fragment,{children:[p,x]}),e[14]=p,e[15]=x,e[16]=g):g=e[16],g},gy=t=>{const e=Be.c(58),{sessionId:n,selectionKey:r,runs:o,saved:i,run:a,directory:u,onRunSaved:c}=t,{t:d}=at(),f=$i(vy),p=uy(),[m,h]=l.useState("agents"),{detail:x,failed:g}=oy(a,m),b=l.useRef(null);Bf(b,sy);const{confirm:w,dialog:S}=_i(),y=a.state==="running"||a.state==="awaiting-approval",I=a.parentSessionId!==n;let j;e[0]!==w||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==d?(j=async()=>{if(await w({title:d("workflows.panel.delete.title",{name:a.name}),message:d("workflows.panel.delete.message"),action:d("workflows.panel.delete.confirm"),destructive:!0}))try{await yh(a.id),vh.getState().remove(a.parentSessionId,a.id)}catch(C){const te=C;_e.error(d("workflows.panel.delete.failed"),{description:te instanceof Error?te.message:void 0})}},e[0]=w,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=d,e[5]=j):j=e[5];const R=j;let _;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(_=()=>{f(a.parentSessionId,a.id),tt.getState().setCurrentSession(a.parentSessionId,a.directory)},e[6]=a.directory,e[7]=a.id,e[8]=a.parentSessionId,e[9]=f,e[10]=_):_=e[10];const P=_;let k;e[11]!==f||e[12]!==r?(k=F=>f(r,F),e[11]=f,e[12]=r,e[13]=k):k=e[13];let N;e[14]!==R||e[15]!==y?(N=y?null:()=>{R()},e[14]=R,e[15]=y,e[16]=N):N=e[16];let T;e[17]!==c||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==n||e[22]!==p||e[23]!==k||e[24]!==N?(T=s.jsx(fy,{runs:o,selected:a,sessionId:n,sessionTitles:p,saved:i,onSelect:k,onRunSaved:c,onDelete:N}),e[17]=c,e[18]=a,e[19]=o,e[20]=i,e[21]=n,e[22]=p,e[23]=k,e[24]=N,e[25]=T):T=e[25];let A;e[26]!==d?(A=d("workflows.panel.view.label"),e[26]=d,e[27]=A):A=e[27];let $;e[28]!==d||e[29]!==m?($=ny.map(F=>{const C=F.id===m;return s.jsxs("button",{type:"button",onClick:()=>h(F.id),"aria-current":C?"page":void 0,title:d(F.labelKey),"aria-label":d(F.labelKey),className:$e("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",C?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(se,{name:F.icon,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:d(F.labelKey)})]},F.id)}),e[28]=d,e[29]=m,e[30]=$):$=e[30];let K;e[31]!==A||e[32]!==$?(K=s.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":A,children:$}),e[31]=A,e[32]=$,e[33]=K):K=e[33];let q;e[34]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=q):q=e[34];let M;e[35]!==I||e[36]!==P||e[37]!==a.parentSessionId||e[38]!==p||e[39]!==d?(M=I?s.jsxs(ft,{type:"button",size:"sm",variant:"ghost",onClick:P,"aria-label":d("workflows.panel.agent.openSession"),title:p.get(a.parentSessionId)||d("workflows.panel.picker.untitledSession"),children:[s.jsx(se,{name:"chat-4",className:"size-3.5"}),s.jsx("span",{className:"workflows-header__action-label",children:d("workflows.panel.agent.openSession")})]}):null,e[35]=I,e[36]=P,e[37]=a.parentSessionId,e[38]=p,e[39]=d,e[40]=M):M=e[40];let z;e[41]!==a?(z=s.jsx(dy,{run:a}),e[41]=a,e[42]=z):z=e[42];let ne;e[43]!==M||e[44]!==z||e[45]!==T||e[46]!==K?(ne=s.jsx(pc,{children:s.jsxs("div",{ref:b,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[T,K,q,M,z]})}),e[43]=M,e[44]=z,e[45]=T,e[46]=K,e[47]=ne):ne=e[47];let H;e[48]!==x||e[49]!==u||e[50]!==g||e[51]!==a||e[52]!==m?(H=m==="agents"?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(Zw,{run:a,directory:u},a.id)}):s.jsxs(fs,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[m==="log"?s.jsx(ay,{run:a,detail:x}):null,m==="result"?s.jsx(ly,{run:a,detail:x,failed:g}):null,m==="script"?s.jsx(cy,{detail:x,failed:g}):null]}),e[48]=x,e[49]=u,e[50]=g,e[51]=a,e[52]=m,e[53]=H):H=e[53];let V;return e[54]!==S||e[55]!==ne||e[56]!==H?(V=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[S,ne,H]}),e[54]=S,e[55]=ne,e[56]=H,e[57]=V):V=e[57],V};function xy(t,e){return s.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:iy(t.at)}),s.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function by(t){return t.entityById}function wy(t){return t.select}function yy(t){return t.currentSessionId}function vy(t){return t.select}const tl=60,Sy=t=>{try{return new URL(t).origin}catch{return""}},Ao=new Set,Td=po()((t,e)=>({byOrigin:{},resolve:(n,r,o)=>{const i=Sy(n);!i||!r||e().byOrigin[i]||Ao.has(i)||(Ao.add(i),En("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const u=typeof a?.dataUrl=="string"?a.dataUrl:"";u&&t(c=>{const d={...c.byOrigin,[i]:u},f=Object.keys(d);if(f.length<=tl)return{byOrigin:d};for(const p of f.slice(0,f.length-tl))delete d[p];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Ao.delete(i)}))}})),qi=t=>t,ri=t=>{const e=qi(t).type;return typeof e=="string"?e:""},ky=t=>{const e=qi(t).tool;return typeof e=="string"?e:""},jy=t=>{const e=qi(t).text;return typeof e=="string"?e:""},Cy=t=>{const e=ri(t);return e==="tool"?ky(t).trim().toLowerCase()||"tool":e||"unknown"},Ty=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=Cy(n);e.includes(r)||e.push(r)}return e.join(" + ")},Ny=t=>t.replace(/\s+/g," ").trim(),Ey=t=>{for(const n of t)if(ri(n)==="text"){const r=Ny(jy(n));if(r.length===0)continue;return r}const e=t.filter(n=>ri(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Py=(t,e,n)=>`${n(t)} / ${n(e)}`,Iy=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Ry=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=Iy(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},Dy=(t,{windowTokens:e,compacted:n=!1})=>{const r=n?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},oi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Dr={user:0,assistant:0,tool:0,other:0},$s=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,sl=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...oi,total:$s(n)};if(!n||typeof n!="object")return oi;const r=n,o=$s(r.input),i=$s(r.output),a=$s(r.reasoning),u=$s(r.cache?.read),c=$s(r.cache?.write),d=$s(r.total);return{input:o,output:i,reasoning:a,cacheRead:u,cacheWrite:c,total:d>0?d:o+i+a+u+c}},_y=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},bs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+bs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+bs(n),0):0,Ay=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Dr,assistant:bs(n.text)+bs(n.content)};const o=_y(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:bs(n.input)+bs(n.output)+bs(n.error)+bs(n.call?.input)+bs(n.call?.output)+bs(n.call?.error)+bs(n.raw)+Math.round(bs(n.metadata)*.25)+Math.round(bs(n.state)*.1)+Math.round((Pu(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},nl=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Oy=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",My=(t,e)=>{if(t.length===0)return{...Dr};const n=t.reduce((r,o)=>{const i=Oy(o);let a={...Dr};for(const u of o.parts)a=nl(a,Ay(u,i));return nl(r,a)},{...Dr});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},dn=t=>t.toLocaleString(Bc()),Fy=(t,e)=>!t||!Number.isFinite(t)?"-":Eh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Ly=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},$y=()=>{const t=Be.c(215),{t:e}=at(),n=zf(),r=X(By);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=l.useState(o),[u,c]=l.useState(null),d=l.useRef(null),f=tt(zy),p=tt(Wy),m=Ch(p??void 0),h=Th(f??"",p??void 0),x=zt(Uy);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),a(Vy),c(null)},t[1]=g):g=t[1];let b;t[2]!==p||t[3]!==f?(b=[p,f],t[2]=p,t[3]=f,t[4]=b):b=t[4],l.useEffect(g,b);let w,S;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},S=[],t[5]=w,t[6]=S):(w=t[5],S=t[6]),l.useEffect(w,S);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=async(ge,lt)=>{(await ro(lt)).ok?(c(ge),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{c(bt=>bt===ge?null:bt),d.current=null},2e3)):c(null)},t[7]=y):y=t[7];const I=y;let j,R,_,P,k,N,T,A,$,K;if(t[8]!==f||t[9]!==x||t[10]!==h||t[11]!==m){P=f?m.find(pt=>pt.id===f)??null:null,j=h.filter(Hy);let ge;t[22]!==h?(ge=h.filter(qy),t[22]=h,t[23]=ge):ge=t[23],K=ge;let lt;t[24]!==h?(lt=Tc(h.map(Gy)),t[24]=h,t[25]=lt):lt=t[25];const Ct=lt,bt=Ct?h[Ct.index]??null:null,kt=Ct?.state==="compacted";T=bt?sl(bt):oi,R=Nh({input:T.input,cache:{read:T.cacheRead,write:T.cacheWrite}}),A=Number.isFinite(P?.cost)?$s(P?.cost):j.reduce(Ky,0);const ht=bt?.info??null,St=x,yt=ht?.providerID||"",xt=ht?.modelID||"";let vt;t[26]!==yt||t[27]!==xt||t[28]!==St?(vt=Ly(St,yt,xt),t[26]=yt,t[27]=xt,t[28]=St,t[29]=vt):vt=t[29],k=vt,_=k.contextLimit,$=kt?null:_&&_>0?Math.min(999,T.total/_*100):0;const ct=[...h].reverse().find(Zy),Pt=ct?.info.role==="system"?ct.info.text:"",Dt=My(h,Pt);N=Dy(Dt,{windowTokens:T.total,compacted:kt}),t[8]=f,t[9]=x,t[10]=h,t[11]=m,t[12]=j,t[13]=R,t[14]=_,t[15]=P,t[16]=k,t[17]=N,t[18]=T,t[19]=A,t[20]=$,t[21]=K}else j=t[12],R=t[13],_=t[14],P=t[15],k=t[16],N=t[17],T=t[18],A=t[19],$=t[20],K=t[21];const q=N,M=h[0]?.info?.time?.created,z=h.length>0?h[h.length-1]?.info?.time?.created:null;let ne;t[30]!==P?.title||t[31]!==e?(ne=P?.title||e("contextSidebar.session.untitled"),t[30]=P?.title,t[31]=e,t[32]=ne):ne=t[32];const H=P?.time?.created??M??null,V=z??P?.time?.created??null;let F;t[33]!==j.length||t[34]!==q||t[35]!==R||t[36]!==_||t[37]!==k||t[38]!==h.length||t[39]!==ne||t[40]!==H||t[41]!==V||t[42]!==T||t[43]!==A||t[44]!==$||t[45]!==K.length?(F={sessionTitle:ne,messagesCount:h.length,userMessagesCount:K.length,assistantMessagesCount:j.length,createdAt:H,lastActivityAt:V,providerModel:k,tokenBreakdown:T,usagePercent:$,cacheHitRate:R,totalAssistantCost:A,contextLimit:_,breakdown:q,breakdownTotal:q.total},t[33]=j.length,t[34]=q,t[35]=R,t[36]=_,t[37]=k,t[38]=h.length,t[39]=ne,t[40]=H,t[41]=V,t[42]=T,t[43]=A,t[44]=$,t[45]=K.length,t[46]=F):F=t[46];const C=F;if(!f){let ge;t[47]!==e?(ge=e("contextSidebar.empty.openSession"),t[47]=e,t[48]=ge):ge=t[48];let lt;return t[49]!==ge?(lt=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:ge}),t[49]=ge,t[50]=lt):lt=t[50],lt}let te;t[51]!==e?(te=e("contextSidebar.breakdown.user"),t[51]=e,t[52]=te):te=t[52];let re;t[53]!==te||t[54]!==C.breakdown.user?(re={key:"user",label:te,value:C.breakdown.user,color:"var(--status-success)"},t[53]=te,t[54]=C.breakdown.user,t[55]=re):re=t[55];let Q;t[56]!==e?(Q=e("contextSidebar.breakdown.assistant"),t[56]=e,t[57]=Q):Q=t[57];let ee;t[58]!==Q||t[59]!==C.breakdown.assistant?(ee={key:"assistant",label:Q,value:C.breakdown.assistant,color:"var(--primary-base)"},t[58]=Q,t[59]=C.breakdown.assistant,t[60]=ee):ee=t[60];let le;t[61]!==e?(le=e("contextSidebar.breakdown.toolCalls"),t[61]=e,t[62]=le):le=t[62];let O;t[63]!==le||t[64]!==C.breakdown.tool?(O={key:"tool",label:le,value:C.breakdown.tool,color:"var(--status-warning)"},t[63]=le,t[64]=C.breakdown.tool,t[65]=O):O=t[65];let Y;t[66]!==e?(Y=e("contextSidebar.breakdown.other"),t[66]=e,t[67]=Y):Y=t[67];let Z;t[68]!==Y||t[69]!==C.breakdown.other?(Z={key:"other",label:Y,value:C.breakdown.other,color:"var(--surface-muted-foreground)"},t[68]=Y,t[69]=C.breakdown.other,t[70]=Z):Z=t[70];let we;t[71]!==re||t[72]!==ee||t[73]!==O||t[74]!==Z?(we=[re,ee,O,Z],t[71]=re,t[72]=ee,t[73]=O,t[74]=Z,t[75]=we):we=t[75];const L=we;let pe;t[76]!==n||t[77]!==C.sessionTitle?(pe=n?s.jsx(pc,{children:s.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:s.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:C.sessionTitle,children:C.sessionTitle})})}):null,t[76]=n,t[77]=C.sessionTitle,t[78]=pe):pe=t[78];let je;t[79]!==n||t[80]!==C.sessionTitle?(je=n?null:s.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:C.sessionTitle}),t[79]=n,t[80]=C.sessionTitle,t[81]=je):je=t[81];const Ee=!n&&"mt-1";let Se;t[82]!==Ee?(Se=$e(Ee,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[82]=Ee,t[83]=Se):Se=t[83];let Le;t[84]!==C.providerModel.modelName||t[85]!==C.providerModel.providerName?(Le=s.jsxs("span",{children:[C.providerModel.providerName," / ",C.providerModel.modelName]}),t[84]=C.providerModel.modelName,t[85]=C.providerModel.providerName,t[86]=Le):Le=t[86];let Pe;t[87]!==r||t[88]!==C.createdAt?(Pe=C.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:Fy(C.createdAt,r)})]}),t[87]=r,t[88]=C.createdAt,t[89]=Pe):Pe=t[89];let Ve;t[90]!==Se||t[91]!==Le||t[92]!==Pe?(Ve=s.jsxs("div",{className:Se,children:[Le,Pe]}),t[90]=Se,t[91]=Le,t[92]=Pe,t[93]=Ve):Ve=t[93];let Oe;t[94]!==je||t[95]!==Ve?(Oe=s.jsxs("div",{className:"mb-6",children:[je,Ve]}),t[94]=je,t[95]=Ve,t[96]=Oe):Oe=t[96];let be;t[97]!==e?(be=e("contextSidebar.section.context"),t[97]=e,t[98]=be):be=t[98];let ye;t[99]!==be?(ye=s.jsx("span",{className:"typography-micro text-muted-foreground",children:be}),t[99]=be,t[100]=ye):ye=t[100];let Ue;t[101]!==C.tokenBreakdown.total||t[102]!==C.usagePercent?(Ue=C.usagePercent===null?"—":dn(C.tokenBreakdown.total),t[101]=C.tokenBreakdown.total,t[102]=C.usagePercent,t[103]=Ue):Ue=t[103];let Te;t[104]!==C.contextLimit?(Te=C.contextLimit?` / ${dn(C.contextLimit)}`:"",t[104]=C.contextLimit,t[105]=Te):Te=t[105];let Me;t[106]!==Ue||t[107]!==Te?(Me=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Ue,Te]}),t[106]=Ue,t[107]=Te,t[108]=Me):Me=t[108];let Re;t[109]!==ye||t[110]!==Me?(Re=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ye,Me]}),t[109]=ye,t[110]=Me,t[111]=Re):Re=t[111];let ze;t[112]!==C.usagePercent?(ze=C.usagePercent!==null&&C.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,C.usagePercent)}%`,backgroundColor:C.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[112]=C.usagePercent,t[113]=ze):ze=t[113];let B;t[114]!==ze?(B=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ze}),t[114]=ze,t[115]=B):B=t[115];let ce;t[116]!==e||t[117]!==C.usagePercent?(ce=C.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:C.usagePercent.toFixed(1)}),t[116]=e,t[117]=C.usagePercent,t[118]=ce):ce=t[118];let G;t[119]!==ce?(G=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ce}),t[119]=ce,t[120]=G):G=t[120];let Ce;t[121]!==Re||t[122]!==B||t[123]!==G?(Ce=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Re,B,G]}),t[121]=Re,t[122]=B,t[123]=G,t[124]=Ce):Ce=t[124];let J;t[125]!==e?(J=e("contextSidebar.stats.messages"),t[125]=e,t[126]=J):J=t[126];let Ne;t[127]!==C.messagesCount?(Ne=dn(C.messagesCount),t[127]=C.messagesCount,t[128]=Ne):Ne=t[128];let Ae;t[129]!==J||t[130]!==Ne?(Ae={label:J,value:Ne},t[129]=J,t[130]=Ne,t[131]=Ae):Ae=t[131];let Ie;t[132]!==e?(Ie=e("contextSidebar.stats.user"),t[132]=e,t[133]=Ie):Ie=t[133];let De;t[134]!==C.userMessagesCount?(De=dn(C.userMessagesCount),t[134]=C.userMessagesCount,t[135]=De):De=t[135];let We;t[136]!==Ie||t[137]!==De?(We={label:Ie,value:De},t[136]=Ie,t[137]=De,t[138]=We):We=t[138];let Ke;t[139]!==e?(Ke=e("contextSidebar.stats.assistant"),t[139]=e,t[140]=Ke):Ke=t[140];let Ze;t[141]!==C.assistantMessagesCount?(Ze=dn(C.assistantMessagesCount),t[141]=C.assistantMessagesCount,t[142]=Ze):Ze=t[142];let Qe;t[143]!==Ke||t[144]!==Ze?(Qe={label:Ke,value:Ze},t[143]=Ke,t[144]=Ze,t[145]=Qe):Qe=t[145];let qe;t[146]!==e?(qe=e("contextSidebar.stats.cost"),t[146]=e,t[147]=qe):qe=t[147];let et;t[148]!==C.totalAssistantCost?(et=td(C.totalAssistantCost),t[148]=C.totalAssistantCost,t[149]=et):et=t[149];let He;t[150]!==qe||t[151]!==et?(He={label:qe,value:et},t[150]=qe,t[151]=et,t[152]=He):He=t[152];let Ye;t[153]!==Ae||t[154]!==We||t[155]!==Qe||t[156]!==He?(Ye=[Ae,We,Qe,He],t[153]=Ae,t[154]=We,t[155]=Qe,t[156]=He,t[157]=Ye):Ye=t[157];const dt=Ye;let nt;t[158]!==dt?(nt=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:dt.map(Xy)}),t[158]=dt,t[159]=nt):nt=t[159];let ut;t[160]!==e?(ut=e("contextSidebar.section.lastAssistantMessage"),t[160]=e,t[161]=ut):ut=t[161];let oe;t[162]!==ut?(oe=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:ut}),t[162]=ut,t[163]=oe):oe=t[163];let de;t[164]!==e||t[165]!==C.cacheHitRate.hasInput||t[166]!==C.cacheHitRate.percent||t[167]!==C.tokenBreakdown.cacheRead||t[168]!==C.tokenBreakdown.cacheWrite||t[169]!==C.tokenBreakdown.input||t[170]!==C.tokenBreakdown.output||t[171]!==C.tokenBreakdown.reasoning?(de=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:C.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:C.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:C.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:C.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:C.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:C.cacheHitRate.hasInput?C.cacheHitRate.percent:null,format:"percent"}].map(Yy)}),t[164]=e,t[165]=C.cacheHitRate.hasInput,t[166]=C.cacheHitRate.percent,t[167]=C.tokenBreakdown.cacheRead,t[168]=C.tokenBreakdown.cacheWrite,t[169]=C.tokenBreakdown.input,t[170]=C.tokenBreakdown.output,t[171]=C.tokenBreakdown.reasoning,t[172]=de):de=t[172];let ve;t[173]!==oe||t[174]!==de?(ve=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[oe,de]}),t[173]=oe,t[174]=de,t[175]=ve):ve=t[175];let v;t[176]!==L||t[177]!==C.breakdownTotal?(v=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:L.map(ge=>ge.value<=0||C.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${ge.value/C.breakdownTotal*100}%`,backgroundColor:ge.color}},ge.key))}),t[176]=L,t[177]=C.breakdownTotal,t[178]=v):v=t[178];let ae;t[179]!==L||t[180]!==C.breakdownTotal?(ae=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:L.map(ge=>{const lt=C.breakdownTotal>0?ge.value/C.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:ge.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[ge.label," ",s.jsxs("span",{className:"tabular-nums",children:[lt.toFixed(0),"%"]})]})]},ge.key)})}),t[179]=L,t[180]=C.breakdownTotal,t[181]=ae):ae=t[181];let W;t[182]!==v||t[183]!==ae?(W=s.jsxs("div",{className:"mb-6",children:[v,ae]}),t[182]=v,t[183]=ae,t[184]=W):W=t[184];let me;t[185]!==e?(me=e("contextSidebar.section.rawMessages"),t[185]=e,t[186]=me):me=t[186];let he;t[187]!==me?(he=s.jsx("div",{className:"typography-micro text-muted-foreground",children:me}),t[187]=me,t[188]=he):he=t[188];let Je;if(t[189]!==u||t[190]!==i||t[191]!==h||t[192]!==e||t[193]!==r){let ge;t[195]!==u||t[196]!==i||t[197]!==e||t[198]!==r?(ge=lt=>{const Ct=lt.info.role,bt=Ct==="assistant",kt=Ct==="user",ht=i[lt.info.id]===!0,St=u===lt.info.id,yt=lt.info.time?.created??null,xt=Ty(lt.parts),vt=bt?sl({info:lt.info,parts:lt.parts}):null,ct=kt?Ey(lt.parts):"",Pt=Ry(yt,r),Dt=xt||"—",pt=vt?Py(vt.input,vt.output,dn):"",mt=Ct||"unknown",Ot=xt?`${mt}: ${xt}`:mt,Ut=ht?JSON.stringify({info:lt.info,parts:lt.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":ht,onClick:()=>{a(ss=>({...ss,[lt.info.id]:ss[lt.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:bt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[kt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",ct]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:bt?Dt:Ot}),bt&&s.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:pt})]}),s.jsx("span",{className:"text-end text-muted-foreground",children:Pt})]})}),ht&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs(fs,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[s.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:ss=>{ss.stopPropagation(),I(lt.info.id,Ut)},"aria-label":e(St?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(St?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:St?s.jsx(se,{name:"check",className:"size-3.5"}):s.jsx(se,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Ph,{language:"json",code:Ut,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},lt.info.id)},t[195]=u,t[196]=i,t[197]=e,t[198]=r,t[199]=ge):ge=t[199],Je=[...h].reverse().map(ge),t[189]=u,t[190]=i,t[191]=h,t[192]=e,t[193]=r,t[194]=Je}else Je=t[194];let Fe;t[200]!==Je?(Fe=s.jsx("div",{className:"mt-2.5 space-y-1",children:Je}),t[200]=Je,t[201]=Fe):Fe=t[201];let fe;t[202]!==he||t[203]!==Fe?(fe=s.jsxs("div",{children:[he,Fe]}),t[202]=he,t[203]=Fe,t[204]=fe):fe=t[204];let ke;t[205]!==Oe||t[206]!==Ce||t[207]!==nt||t[208]!==ve||t[209]!==W||t[210]!==fe?(ke=s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[Oe,Ce,nt,ve,W,fe]}),t[205]=Oe,t[206]=Ce,t[207]=nt,t[208]=ve,t[209]=W,t[210]=fe,t[211]=ke):ke=t[211];let rt;return t[212]!==pe||t[213]!==ke?(rt=s.jsxs(fs,{outerClassName:"h-full",className:"bg-background",children:[pe,ke]}),t[212]=pe,t[213]=ke,t[214]=rt):rt=t[214],rt};function By(t){return t.timeFormatPreference}function zy(t){return t.currentSessionId}function Wy(t){return t.currentSessionDirectory}function Uy(t){return t.providers}function Vy(t){return Object.keys(t).length>0?{}:t}function Hy(t){return t.info.role==="assistant"}function qy(t){return t.info.role==="user"}function Gy(t){return t.info}function Ky(t,e){const n=$s(e.info.cost);return t+n}function Zy(t){return t.info.role==="system"}function Xy(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function Yy(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:dn(t.value):"—"})]},t.label)}const Jy=280,Qy=.28,ev=240,tv=.35,sv=(t,e,n=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=n?n.top:i-Math.min(ev,e.height*tv),u=Math.min(Jy,t.width*Qy,e.width/4),c=e.left-t.left>=1,d=r-o>=1,f=Math.max(0,a-t.top),p=c?e.left:t.left+u,m=d?o:r-u;return{left:{left:t.left,top:t.top,width:p-t.left,height:c?t.height:f},right:{left:m,top:t.top,width:r-m,height:d?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},Oo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,nv=(t,e)=>Oo(t.bottom,e)?"bottom":Oo(t.left,e)?"left":Oo(t.right,e)?"right":null,qs=po(()=>({drag:null,hovered:null})),_r=t=>{if(!t)return null;const{left:e,top:n,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:n,width:r,height:o}:null},Mo=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),Fo=t=>_r(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Nd=t=>{const e=_r(document.querySelector("[data-workspace-row]")),n=_r(document.querySelector("[data-workspace-chat]"));if(!e||!n)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=sv(e,n,_r(r)),i={left:Fo("left")??Mo(o.left),right:Fo("right")??Mo(o.right),bottom:Fo("bottom")??Mo(o.bottom)};return qs.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Ed=t=>{const{drag:e,hovered:n}=qs.getState();if(!e)return;const r=nv(e.targets,t);r!==n&&qs.setState({hovered:r})},ii=()=>{qs.getState().drag&&qs.setState({drag:null,hovered:null})},Pd=t=>{const{drag:e,hovered:n}=qs.getState();if(qs.setState({drag:null,hovered:null}),!e||!n)return!1;const r=X.getState();n!==e.from&&r.moveContextSurfaceToZone(e.mode,n);const o=t?us(t):"";if(o){const i=X.getState();bi(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Gi=(t,e)=>{let n=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(n||(n=Nd(t)),n&&Ed(a)):n&&(ii(),n=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),n?(Pd(i),!0):!1),cancel:()=>{o(),n&&ii()}}},rl={left:null,right:null,bottom:null},ur=po(()=>({body:rl,headerSlot:rl})),Id=(t,e,n)=>{const r=ur.getState()[t];r[e]!==n&&ur.setState({[t]:{...r,[e]:n}})},rv=(t,e)=>Id("body",t,e),ov=(t,e)=>Id("headerSlot",t,e),rr=t=>{const e=l.useRef(t);e.current=t;const[n,r]=l.useState(t),o=l.useCallback(()=>r(e.current),[]);return l.useLayoutEffect(()=>{Ei(o)},[t,o]),l.useEffect(()=>()=>zc(o),[o]),n},Lo=t=>{const e=rr(t);return t||e},iv=mr(()=>At(()=>import("./GitView-Z4zWCBn1.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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206])).then(t=>({default:t.GitView}))),Ki=320,Rd=320,av=24,lv=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},ol=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Ki,Math.round(t))):vi,cv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Ki,t-Rd),il=(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},Ar=(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==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):t==="workflows"?e("contextPanel.mode.workflows"):Mn(t)?Ni.getState().guests.find(r=>r.id===Lr(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),dv=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},uv=(t,e,n)=>{if(t.mode==="chat"){const r=ho(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?to(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?dv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ar(t.mode,n)},fv=t=>{const e=Be.c(8),{mode:n}=t,r=Bi();let o;if(e[0]!==n||e[1]!==r){let d;e[3]!==n?(d=f=>f.mode===n,e[3]=n,e[4]=d):d=e[4],o=r.find(d),e[0]=n,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??Mh,u=i?.iconSrc;let c;return e[5]!==a||e[6]!==u?(c=s.jsx(Ti,{icon:a,iconSrc:u,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=u,e[7]=c):c=e[7],c},pv=t=>{const e=Be.c(2),{sessionId:n}=t,r=yc(n);let o;return e[0]!==r?(o=r?s.jsx(Sc,{state:r,className:"h-3.5 w-3.5"}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},mv=t=>{const e=Be.c(6),{url:n}=t,r=Oi(),o=Fc();let i;if(e[0]!==o||e[1]!==n||e[2]!==r){const c=n?Lc(n,r,o):null;i=c?c.source==="tracker"?Oh(c.provider).icon:Ah[c.kind]:"git-branch",e[0]=o,e[1]=n,e[2]=r,e[3]=i}else i=e[3];const a=i;let u;return e[4]!==a?(u=s.jsx(se,{name:a,className:"h-3.5 w-3.5"}),e[4]=a,e[5]=u):u=e[5],u},al=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(uo,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(hc,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(se,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(se,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(mv,{url:t.targetPath});if(t.mode==="notes")return s.jsx(se,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(se,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(se,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return s.jsx(se,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const n=ho(t.dedupeKey);return n?s.jsx(pv,{sessionId:n}):s.jsx(se,{name:"chat-4",className:"h-3.5 w-3.5"})}if(Mn(t.mode))return s.jsx(fv,{mode:t.mode});if(t.mode==="browser"){const n=hv(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(se,{name:"global",className:"h-3.5 w-3.5"})}},hv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},gv=t=>{const e=Uc(),n=l.useRef(Hr),r=l.useRef(t);r.current=t;const o=t.length>0;return l.useSyncExternalStore(l.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),l.useCallback(()=>{const i=Array.from(e.children.values(),u=>u.getState()),a=Ow(i,r.current);return _w(n.current,a)?n.current:(n.current=a,a)},[e]),()=>Hr)},xv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,bv=8,wv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',yv=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Dd=320,Zi=160,ai=200,vv={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},ll=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Zi,Math.round(t))):Dd,Sv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Zi,t-ai),$o=({zone:t="right"})=>{const e=vv[t],n=ao(),r=e.axis==="y",{t:o,direction:i}=at(),a=i==="rtl",u=Gs()??"",c=Kl(Ih(u||null)),d=l.useCallback((ie,Ge)=>o(Ws(ie,c),Ge),[c,o]),f=l.useMemo(()=>lv(u),[u]),p=X(ie=>f?ie.contextPanelByDirectory[f]:void 0),m=X(ie=>ie.contextSurfaceZones),h=X(ie=>ie.shortcutOverrides),x=X(ie=>ie.closeContextZone),g=X(ie=>ie.closeContextPanelTab),b=X(ie=>ie.pinContextPanelTab),w=X(ie=>ie.toggleContextPanelExpanded),S=X(ie=>ie.setContextZoneSize),y=X(ie=>ie.setContextZoneExpandedChatSize),I=X(ie=>ie.setActiveContextPanelTab),j=X(ie=>ie.reorderContextPanelTabs),R=X(ie=>ie.contextEditorTreeVisible),_=X(ie=>ie.contextEditorTreeWidth),P=X(ie=>ie.setContextEditorTreeWidth),k=X(ie=>ie.toggleContextEditorTree),N=X(ie=>ie.contextEditorVisible),T=X(ie=>ie.toggleContextEditor),A=X(ie=>ie.fileTreeSide),$=X(ie=>ie.openNewContextBrowserTab),K=Td(ie=>ie.byOrigin),[q,M]=l.useState(null),z=l.useCallback(ie=>{M(ie),ov(t,ie)},[t]),ne=l.useCallback(ie=>{rv(t,ie)},[t]),H=l.useMemo(()=>p?.tabs??[],[p?.tabs]),V=p?Fr(p,m,t):null,F=p?lr(p,t):Iu,C=Rr(ie=>ie.workStatusReserved),te=Rr(ie=>ie.workStatusBesidePanel),re=Rr(ie=>ie.chatCovered),Q=t==="bottom"&&re,ee=!!(F.isOpen&&V)&&!Q,le=l.useMemo(()=>H.some(ie=>ie.mode==="file"&&ie.targetPath),[H]),O=le&&(N||!R),Y=!r&&V?.mode==="file"&&!O,Z=!!(ee&&F.expanded&&!Y),we=X(ie=>ie.contextZoneSizes[t]),L=Y?_:r?ll(we??Dd,Number.POSITIVE_INFINITY):ol(we??vi,Number.POSITIVE_INFINITY),pe=l.useCallback((ie,Ge)=>r?ll(ie,Sv(Ge)):ol(ie,cv(Ge)),[r]),je=r?ai:Rd,Ee=X(ie=>r?0:ie.sidebarWidth),Se=X(ie=>ie.contextZoneExpandedChatSizes[t]),Le=Math.max(je,Se??(r?ai:Ee)),Pe=t==="right"?"left":t==="left"?"right":null,Ve=X(ie=>{if(!Pe||!f)return 0;const Ge=ie.contextPanelByDirectory[f],gt=Ge&&tr(Ge,ie.contextSurfaceZones,Pe)?Fr(Ge,ie.contextSurfaceZones,Pe):null;return Ge&&gt?Ru(Ge,gt,Pe,ie):0}),Oe=Pe==="right"&&C&&!re&&Ve===0?Cn:Ve,be=t==="right"&&C&&!re,ye=be&&te&&!Z,[Ue,Te]=l.useState(null),Me=l.useRef(null),Re=l.useRef(Oe);Re.current=Oe;const ze=l.useRef(ee);ze.current=ee;const B=l.useRef(()=>!1);B.current=ie=>Z||!Y&&ie-Re.current-je<L;const ce=l.useCallback(()=>{let ie=Me.current;if(ie!==null&&!r&&ze.current){const Ge=document.querySelector("[data-left-sidebar]");Ge&&(ie+=Math.round(Ge.getBoundingClientRect().width-(Number.parseFloat(Ge.style.width)||0)))}Te(ie!==null&&B.current(ie)?ie:null)},[r]),G=Ue!==null?Ue-Oe:null,Ce=Y?L:Z&&G!==null?Math.max(r?Zi:Ki,G-Le):pe(L,G),J=ee&&V?.mode==="chat",Ne=l.useMemo(()=>{const ie=[];if(!J)return ie;for(const Ge of H){if(Ge.mode!=="chat")continue;const gt=ho(Ge.dedupeKey);gt&&!ie.includes(gt)&&ie.push(gt)}return ie},[J,H]),Ae=gv(Ne),[Ie,De]=l.useState(!1),We=l.useRef(0),Ke=l.useRef(Ce),Ze=l.useRef(null),Qe=l.useRef(null),qe=l.useRef(null),et=l.useRef(null),He=l.useRef(!1);l.useLayoutEffect(()=>{const ie=r?qe.current?.parentElement:qe.current?.closest("[data-workspace-row]");if(!ie||typeof ResizeObserver>"u")return;const Ge=new ResizeObserver(gt=>{const jt=gt[gt.length-1]?.contentRect,It=r?jt?.height:jt?.width;Me.current=It?Math.round(It):null,Ei(ce)});return Ge.observe(ie),Me.current=(r?ie.clientHeight:ie.clientWidth)||null,ce(),()=>{Ge.disconnect(),zc(ce)}},[ce,r]);const Ye=!r&&ee&&(Z||Ue!==null),dt=X(ie=>Ye&&ie.isSidebarOpen);l.useLayoutEffect(()=>{ce()},[ce,L,Z,ee,Oe,dt]),l.useEffect(()=>{if(!ee||He.current){He.current=ee;return}const ie=window.requestAnimationFrame(()=>{et.current?.focus({preventScroll:!0})});return He.current=!0,()=>window.cancelAnimationFrame(ie)},[ee]);const nt=l.useRef(null),ut=l.useRef(null),oe=l.useRef(null),de=l.useRef(null),ve=l.useRef(!1),v=l.useRef(null),ae=l.useRef(!1),W=l.useCallback(ie=>{const Ge=qe.current,gt=v.current;if(!Ge||!gt)return;const jt=r?"height":"width";Ge.style[jt]=ae.current?`${ie+Cn}px`:`min(${ie}px, 100%)`,gt.style[jt]=`calc(${ie}px - ${e.gutterSize})`},[e.gutterSize,r]),me=l.useCallback(()=>{ut.current=null;const ie=Ze.current;ie!==null&&W(ie)},[W]);l.useEffect(()=>()=>{ut.current!==null&&cancelAnimationFrame(ut.current),oe.current?.(),oe.current=null,de.current?.remove(),de.current=null},[]);const he=l.useCallback(ie=>{const Ge=nt.current,gt=Y?Ho(ie):pe(ie,Ge);return Ge===null?gt:Math.min(gt,Math.max(1,Ge))},[pe,Y]),Je=l.useCallback(ie=>{if(!ee||!f)return;Qe.current=ie.pointerId,De(!0),We.current=r?ie.clientY:ie.clientX,Ke.current=Ce,Ze.current=Ce;const Ge=r?qe.current?.parentElement?.clientHeight:(qe.current?.closest("[data-workspace-row]")?.clientWidth??0)-Re.current-(ye?Cn:0);nt.current=Ge&&Ge>0?Ge:null,de.current?.remove();const gt=document.createElement("div");gt.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${r?"row-resize":"col-resize"}`,document.body.appendChild(gt),de.current=gt,oe.current?.(),oe.current=Pc(r?"height":"width"),ie.preventDefault()},[ye,f,ee,r,Ce]),Fe=l.useCallback(()=>{const ie=he(Ze.current??Ce),Ge=nt.current;ut.current!==null&&(cancelAnimationFrame(ut.current),ut.current=null);const gt=qe.current,jt=v.current;if(gt&&jt){const It=r?"height":"width";gt.style.setProperty(e.sizeVariable,`${ie}px`),gt.style[It]=cs.current,jt.style[It]=Ht.current}Ze.current=null,nt.current=null,ve.current=!0,de.current?.remove(),de.current=null,Y?P(ie):Z?Ge!==null&&y(t,Ge-ie):S(t,ie),De(!1),Qe.current=null,oe.current?.(),oe.current=null},[he,e.sizeVariable,Z,Y,r,P,y,S,Ce,t]);l.useEffect(()=>{if(!Ie)return;const ie=jt=>{if(Qe.current!==jt.pointerId)return;const It=r?jt.clientY:jt.clientX,Mt=t==="left"?It-We.current:We.current-It,Kt=!r&&a?-Mt:Mt,Jt=he(Ke.current+Kt);Ze.current!==Jt&&(Ze.current=Jt,ut.current===null&&(ut.current=requestAnimationFrame(me)))},Ge=jt=>{Qe.current===jt.pointerId&&Fe()},gt=()=>{Fe()};return window.addEventListener("pointermove",ie),window.addEventListener("pointerup",Ge),window.addEventListener("pointercancel",Ge),window.addEventListener("blur",gt),()=>{window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",Ge),window.removeEventListener("pointercancel",Ge),window.removeEventListener("blur",gt)}},[me,he,Fe,Ie,a,r,t]),l.useEffect(()=>{Ie||(Ze.current=null,de.current?.remove(),de.current=null)},[Ie]);const fe=l.useCallback(()=>{f&&x(f,t)},[x,f,t]),ke=l.useCallback(()=>{f&&w(f,t)},[f,w,t]),rt=V?.mode==="file"||V?.mode==="chat"||V?.mode==="browser"||V?.mode==="pr",ge=l.useMemo(()=>{if(!V)return[];const ie=H.filter(Ge=>Ge.mode===V.mode);return V.mode==="pr"?[...ie.filter(yr),...ie.filter(Ge=>!yr(Ge))]:ie},[V,H]),lt=co(V?.mode==="pr"&&f?f:null)?.current??null,Ct=l.useMemo(()=>{const ie=Rh(ge.filter(Ge=>Ge.mode==="file").map(Ge=>il(Ge.targetPath,u)));return ge.map(Ge=>{const gt=yr(Ge),jt=gt?lt||o("contextPanel.tracker.branchTab"):uv(Ge,Ae,d),It=xv(jt,av),Mt=il(Ge.targetPath,u);return{id:Ge.id,label:It,labelFolder:Ge.mode==="file"?ie.get(Mt):void 0,icon:al(Ge,K),title:Mt?`${jt}: ${Mt}`:jt,closeLabel:o("contextPanel.tab.closeTabAria",{label:It}),closable:!gt,preview:Ge.preview}})},[ge,u,K,Ae,o,d,lt]),bt=V?.mode==="context"?s.jsx(fn,{value:q,children:s.jsx($y,{})}):V?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(fn,{value:q,children:s.jsx(iv,{isActive:ee})})}):V?.mode==="pr"?V.targetPath?s.jsx(kw,{url:V.targetPath,directory:V.targetDirectory??u,panelDirectory:u,tabId:V.id,foreign:!!V.targetDirectory,visible:ee},V.id):s.jsx(pw,{}):V?.mode==="notes"?s.jsx(fn,{value:q,children:s.jsx(Wf,{visible:ee})}):V?.mode==="workflows"?s.jsx(fn,{value:q,children:s.jsx(hy,{directory:u||null})}):null,kt=V?.mode==="file",ht=kt&&!!V?.targetPath&&O,St=ee&&V&&rt&&!ht&&!yr(V)?V.id:null;l.useEffect(()=>{if(!(!f||!St))return oc(()=>g(f,St),qe)},[g,f,St]);const yt=X(ie=>ie.closeContextPanelTabs),xt=l.useCallback(ie=>{if(!f)return null;const{id:Ge,index:gt,allIds:jt,close:It}=ie,Mt=()=>yt(f,jt.filter(Tt=>Tt!==Ge)),Kt=jt.slice(0,gt),Jt=jt.slice(gt+1),gs=()=>yt(f,a?Jt:Kt),Cs=()=>yt(f,a?Kt:Jt),Ts=()=>yt(f,jt),U=jt.length>1,Xe=a?gt===jt.length-1:gt===0,ot=a?gt===0:gt===jt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Ns,{onClick:It,children:[s.jsx(se,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),s.jsx(Dn,{}),s.jsxs(Ns,{onClick:Mt,disabled:!U,children:[s.jsx(se,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Ns,{onClick:gs,disabled:Xe,children:[s.jsx(se,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Ns,{onClick:Cs,disabled:ot,children:[s.jsx(se,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),s.jsx(Dn,{}),s.jsxs(Ns,{onClick:Ts,disabled:!U,children:[s.jsx(se,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),V?s.jsxs(s.Fragment,{children:[s.jsx(Dn,{}),s.jsx(mc,{mode:V.mode})]}):null]})},[V,yt,f,a,o]),vt=l.useCallback((ie,Ge)=>{const gt=H.find(It=>It.id===ie);if(!gt)return null;const jt=Gi({mode:gt.mode,label:Ar(gt.mode,d),from:t},Ge);return{finish:()=>jt.finish(f),cancel:jt.cancel}},[f,d,H,t]),[ct,Pt]=l.useState(null),Dt=l.useCallback(ie=>{if(!V||ie.button!==0||ie.pointerType==="touch"||ie.target instanceof Element&&ie.target.closest(wv))return;const Ge=V.mode,gt=Ar(Ge,d),jt={x:ie.clientX,y:ie.clientY};let It=!1;const Mt=Cs=>{const Ts={x:Cs.clientX,y:Cs.clientY};!It&&(Math.hypot(Ts.x-jt.x,Ts.y-jt.y)<bv||(It=Nd({mode:Ge,label:gt,from:t}),!It))||Ed(Ts)},Kt=()=>{window.removeEventListener("pointermove",Mt),window.removeEventListener("pointerup",Jt),window.removeEventListener("pointercancel",gs),window.removeEventListener("blur",gs)},Jt=()=>{Kt(),It&&Pd(f)},gs=()=>{Kt(),It&&ii()};window.addEventListener("pointermove",Mt),window.addEventListener("pointerup",Jt),window.addEventListener("pointercancel",gs),window.addEventListener("blur",gs)},[V,f,d,t]);l.useEffect(()=>{if(ct)return ct.addEventListener("pointerdown",Dt),()=>ct.removeEventListener("pointerdown",Dt)},[Dt,ct]);const pt=s.jsxs("header",{ref:Pt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[rt?s.jsx(Dh,{items:Ct,activeId:V?.id??null,onSelect:ie=>{f&&I(f,ie)},onClose:ie=>{f&&g(f,ie)},onReorder:(ie,Ge)=>{f&&j(f,ie,Ge)},onDoubleClickTab:ie=>{f&&b(f,ie)},layoutMode:"scrollable",variant:"default",tabContextMenu:xt,onTabDragOut:vt}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[V?al(V,K):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:V?Ar(V.mode,d):null})]}),s.jsx("div",{ref:z,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),s.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[V?.mode==="browser"?s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&$(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:s.jsx(se,{name:"add",className:"h-3.5 w-3.5"})}):null,kt?["left","right"].map(ie=>{const Ge=ie===A;if(!Ge&&!le)return null;const gt=o(Ge?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:Ge?k:T,className:"h-7 w-7 p-0",title:gt,"aria-label":gt,"aria-pressed":Ge?R:O,children:s.jsx(se,{name:ie==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},ie)}):null,Y?null:s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:ke,className:"h-7 w-7 p-0","aria-label":o(Z?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:Z?s.jsx(se,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(se,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:s.jsx(Hs,{label:o(Z?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:ws(Es("toggle_context_panel_expanded",h),"")})})]}),s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:fe,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:s.jsx(se,{name:"close",className:"h-3.5 w-3.5"})})]})]}),mt=ee?ye?`calc(var(${e.sizeVariable}) + ${Cn}px)`:`min(var(${e.sizeVariable}), 100%)`:be?`${Cn}px`:"0px",Ot=ye?`${Cn}px`:"0px";ae.current=ye;const Ut=t==="bottom"&&tr(p,m,"left"),ss=t==="bottom"&&(C&&!re||tr(p,m,"right")),ps=`${ee}|${Z}|${be}|${ee&&ye}|${ee?L:""}`,ns=l.useRef(ps),ms=l.useRef(re),ls=ms.current!==re;l.useLayoutEffect(()=>{ms.current=re},[re]),l.useLayoutEffect(()=>{if(ns.current===ps)return;ns.current=ps;const ie=ve.current;!ls&&!ie&&Ec(n)},[ps,ls,n]),l.useLayoutEffect(()=>{ve.current=!1});const rs=!Er(ee,rr(ee),V?.mode),Rs={[e.sizeVariable]:`${Ce}px`,...r?{height:mt,maxHeight:"100%"}:{width:mt,maxWidth:"100%"},transitionDuration:ls||Ie?"0ms":`${n}ms`,transitionTimingFunction:Wn},Vt=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,cs=l.useRef(mt);cs.current=mt;const Ht=l.useRef(Vt);return Ht.current=Vt,s.jsxs("aside",{ref:qe,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":ee?"true":"false",tabIndex:-1,className:$e("flex min-h-0 flex-col overflow-clip bg-background","isolate",r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),style:Rs,children:[s.jsx("div",{ref:et,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?s.jsx("div",{ref:_h,className:$e("absolute inset-y-0 z-0 flex",ye?"inset-s-0":"inset-e-0",re&&"invisible")}):null,ee&&s.jsx("div",{className:e.handle,style:{marginInlineStart:Ot},onPointerDown:Je,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{ref:v,"data-zone-card":"",className:$e("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Ut?"ms-0":"ms-2"),t==="bottom"&&(ss?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity,margin-inline-start]",!ee&&"opacity-0",rs&&"pointer-events-none select-none"),style:{...r?{height:Vt,width:`calc(100% - ${(Ut?0:.5)+(ss?0:.375)}rem)`}:{width:Vt},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Ot})`}:null,transitionDuration:Ie?"0ms":`${n}ms`,transitionTimingFunction:Wn},inert:rs||void 0,children:s.jsxs(Wc.Provider,{value:!0,children:[pt,s.jsx("div",{ref:ne,className:"relative min-h-0 flex-1 overflow-hidden",children:V&&yv(V.mode)?bt:null})]})})]})},kv=Qs({port:mo().int().positive(),url:Ps().min(1),command:Ps(),directory:Ps().min(1).optional()}),jv=t=>{const e=Qs({servers:ud(F1())}).safeParse(t);return e.success?e.data.servers.flatMap(n=>{const r=kv.safeParse(n);return r.success?[r.data]:[]}):null},Cv=async(t,e)=>{try{const n=await Vs("/api/dev-servers",{signal:t,directory:e});if(!n.ok)return{kind:"unavailable"};const r=jv(await n.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Tv=async t=>{try{const e=await Vs("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},Nv=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},Ev=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=Nv(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0,directory:r.directory}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Pv=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),cl=(t,e)=>{if(!e)return null;let n=null;for(const r of t)Pv(r.path,e)&&(!n||r.path.length>n.path.length)&&(n=r);return n},Iv=t=>t.slice(t.lastIndexOf("/")+1)||t,Rv=({candidates:t,folders:e,directory:n})=>{const r=e.flatMap(c=>{const d=Yt(c.path),f=Yt(c.projectPath);return d&&f?[{path:d,projectPath:f}]:[]}),o=Yt(n),i=o?{path:o,projectPath:cl(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(c=>{const d=Yt(c.directory),f=cl(a,d),p=c.announced?0:f&&i&&f.path===i.path?1:f&&i&&f.projectPath===i.projectPath?2:3;return{server:{...c,folderName:f?Iv(f.path):null,outsideWork:d!==null&&f===null&&!c.announced},rank:p}}).sort((c,d)=>c.rank-d.rank||c.server.port-d.server.port).map(c=>c.server)},Dv=t=>({sessionId:t.sessionId,directory:t.directory?us(t.directory):null}),_v=2e3,Av=Qs({title:Ps(),settled:dr()}),Ov=4e4,Mv=50,or=400,hs=new Map,As=new Map;let li=null,ci=null;const fr=new Map;let Bs=null,Ys=null,ir=null;const zs=async t=>{try{const e=await Vs("/api/browser-control/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t})});return e.ok?(await e.json())?.granted===!0:!1}catch{return!1}},Fv=async(t,e)=>{try{const n=await Vs("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},_d=async(t,e=_v)=>{const n=Date.now()+e;for(;!hs.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,Mv));return hs.get(t)??null},qr=t=>hs.has(t)||As.has(t),Hn=t=>hs.get(t)??As.get(t)??null,di=()=>[...hs.values(),...[...As.values()].filter(t=>!hs.has(t.tabId))],Xi=t=>{const e=ci?Hn(ci):null,n=e?.directory===li?e:null;if(!t.sessionId){if(n)return n.tabId;const i=di().filter(c=>c.directory===li),a=i.filter(c=>hs.has(c.tabId)),u=a.length>0?a:i;return u.length>0?u[u.length-1].tabId:null}if(n?.ownerSessionId===t.sessionId)return n.tabId;const r=fr.get(t.sessionId);if(r&&Hn(r)?.ownerSessionId===t.sessionId)return r;const o=di().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:n&&n.ownerSessionId===null&&(!t.directory||n.directory===t.directory)?n.tabId:null},Lv=t=>{const e=Xi(t);return e&&Hn(e)?.ownerSessionId===t.sessionId?e:null},$v=(t,e)=>{t.sessionId&&Hn(e)?.ownerSessionId===t.sessionId&&fr.set(t.sessionId,e)},Ad=async t=>{const e=hs.get(t);if(e)return e;const n=As.get(t);return n?(n.wake(),_d(t)):null},Od=t=>{const e=Xi(t);return di().filter(n=>!t.sessionId||!t.directory||n.ownerSessionId===t.sessionId||n.directory===t.directory).map(n=>{let r={title:"",url:""};try{r=n.describe()}catch{}const o=n.ownerSessionId===null?"user":n.ownerSessionId===t.sessionId?"you":"another session";return{id:n.tabId,title:r.title,url:r.url,owner:o,active:n.tabId===e}})},Md=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Fd=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,Bv=t=>{const e=Od(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
6
6
  ${e.map(r=>`- ${r.id}: ${r.title||r.url||"blank"} (opened by ${r.owner})`).join(`
7
7
  `)}`:"")},zv=()=>"This session has no browser tab of its own to close. Agent actions never close a tab the user opened. Open a page with browser.open first, or name a tab this session opened with tabId.",Wv=t=>`The browser tab ${t} was not opened by this session, so it was not closed. Agent actions never close a tab the user or another session opened. Name a tab from browser.snapshot whose owner is you.`,Uv=()=>"This browser.close did not come from a session, so there is no tab it opened to close. Nothing was closed.",es=(t,e)=>Fv(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:Vc()})}:e),Vv=async(t,e,n)=>{if(!e.sessionId){if(!await zs(t.requestId))return;await es(t,{ok:!1,error:Uv()});return}const r=n??Lv(e);if(r===null){if(await new Promise(a=>setTimeout(a,or)),!await zs(t.requestId))return;await es(t,{ok:!1,error:zv()});return}if(!qr(r)){if(hs.size===0&&As.size===0&&!Ys)return;if(await new Promise(a=>setTimeout(a,or)),!qr(r)){if(!await zs(t.requestId))return;await es(t,{ok:!1,error:Fd(r)});return}}const o=Hn(r);if(!o||o.ownerSessionId!==e.sessionId){if(!await zs(t.requestId))return;await es(t,{ok:!1,error:Wv(r)});return}if(!await zs(t.requestId))return;if(!(Ys?Ys(o.directory,r):!1)){await es(t,{ok:!1,error:Ys?`The browser tab ${r} could not be closed.`:"There is no browser here to close a tab in."});return}e.sessionId&&fr.get(e.sessionId)===r&&fr.delete(e.sessionId),await es(t,{ok:!0,data:{closed:!0,tabId:r}})},Hv=async t=>{const e=t.action==="browser.open",n=t.action==="browser.close",r=Dv(t.context),{tabId:o,...i}=t.parameters,a=o===void 0?null:String(o);if(n){await Vv(t,r,a);return}if(a!==null){if(!qr(a)){if(hs.size===0&&As.size===0&&!Bs)return;if(await new Promise(d=>setTimeout(d,or)),qr(a)){await dl(t,r,a,i);return}if(!await zs(t.requestId))return;await es(t,{ok:!1,error:Fd(a)});return}await dl(t,r,a,i);return}const u=Xi(r);if(!u&&!(e&&Bs)){if(!r.sessionId||(await new Promise(d=>setTimeout(d,or)),!await zs(t.requestId)))return;await es(t,{ok:!1,error:Bv(r)});return}if(!(e&&Bs!==null)&&r.sessionId&&Hn(u)?.ownerSessionId!==r.sessionId&&await new Promise(d=>setTimeout(d,or)),!!await zs(t.requestId))try{const d=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!d){await es(t,{ok:!1,error:"url is required"});return}const f=Date.now(),p=e&&Bs?Bs(d,t.context):null;if(e&&!p&&!u){await es(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(p){r.sessionId&&fr.set(r.sessionId,p);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"",x=!!h&&h!=="fill",g=Vc();if(!x&&!g){await es(t,{ok:!0,data:{url:d,opened:!0,tabId:p}});return}const b=await _d(p);if(!b&&!x){await es(t,{ok:!0,data:{url:d,opened:!0,tabId:p,settled:!1}});return}if(!b){await es(t,{ok:!0,data:{url:d,opened:!0,tabId:p,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const w=x?await b.run("browser.resize",{viewport:h}):null,S=w&&typeof w=="object"?w.viewport??null:null,y=g?Av.safeParse(await b.run("browser.settle",{budgetMs:Math.max(0,Ov-(Date.now()-f))}).catch(()=>null)):null;await es(t,{ok:!0,data:Object.assign({url:d,opened:!0,tabId:p},x?{viewportApplied:!0,viewport:S}:{},y?y.success?y.data:{settled:!1}:{})});return}const m=await Ad(u);await es(t,m?await Ld(m,r,t.action,i):{ok:!1,error:Md(u)})}catch(d){await es(t,{ok:!1,error:d instanceof Error?d.message:String(d)})}},dl=async(t,e,n,r)=>{if(!await zs(t.requestId))return;$v(e,n);const o=await Ad(n);await es(t,o?await Ld(o,e,t.action,r):{ok:!1,error:Md(n)})},Ld=async(t,e,n,r)=>{try{const o=await t.run(n,r);return n==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:Od(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},xo=()=>{ir||(ir=Js(t=>{t.type==="browser-control-request"&&Hv({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},bo=()=>{hs.size>0||As.size>0||Bs||Ys||!ir||(ir(),ir=null)},qv=t=>(hs.set(t.tabId,t),xo(),()=>{hs.get(t.tabId)===t&&hs.delete(t.tabId),bo()}),Gv=t=>(As.set(t.tabId,t),xo(),()=>{As.get(t.tabId)===t&&As.delete(t.tabId),bo()}),Kv=(t,e)=>{li=t,e&&(ci=e)},Zv=t=>(Bs=t,xo(),()=>{Bs===t&&(Bs=null),bo()}),Xv=t=>(Ys=t,xo(),()=>{Ys===t&&(Ys=null),bo()}),Yv=50,Jv=6,Qv=2048,e0=200,$d=t=>{const e=Rn(String(t??"").trim());if(!e||e.length>Qv)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},t0=(t,e)=>{const n=$d(e.url);if(!n)return t;const r=t.find(a=>a.url===n),o=String(e.title??"").trim().slice(0,e0)||r?.title||"";return[{url:n,title:o,lastVisitedAt:e.at},...t.filter(a=>a.url!==n)].slice(0,Yv)},s0=(t,e)=>{const n=$d(e);return t.filter(r=>r.url!==n)},n0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Bd=(t,e,n=Jv)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((a,u)=>u.lastVisitedAt-a.lastVisitedAt);if(!r)return o.slice(0,n);const i=r.replace(/^https?:\/\//,"");return o.filter(a=>{const u=n0(a);return a.url===r||u===i?!1:u.includes(i)}).slice(0,n)},ul=20,Or=t=>{const e=Yt((t||"").trim());return e?JSON.stringify([as(),e]):""},r0=t=>{const e=Object.keys(t);if(e.length<=ul)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,ul);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},_n=po()(M1(t=>({byProject:{},recordVisit:(e,n)=>{const r=Or(e);r&&t(o=>{const i=o.byProject[r]??[],a=t0(i,{...n,at:Date.now()});return a===i?o:{byProject:r0({...o.byProject,[r]:a})}})},forget:(e,n)=>{const r=Or(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:s0(i,n)}}:o})},clear:e=>{const n=Or(e);n&&t(r=>{if(!(n in r.byProject))return r;const o={...r.byProject};return delete o[n],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Du(),partialize:t=>({byProject:t.byProject})})),o0=[],zd=t=>e=>{const n=Or(t);return(n?e.byProject[n]:void 0)??o0},Yi=t=>{const e=Be.c(10),{t:n}=at();let r;e[0]!==t?(r=js(t),e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=d=>o?d.journey?.get(o):void 0,e[2]=o,e[3]=i):i=e[3];const a=pn(i);if(o===null)return null;if(!a){let d;return e[4]!==n?(d=n("contextPanel.browser.spaceAddress"),e[4]=n,e[5]=d):d=e[5],d}let u;e[6]!==a.machine||e[7]!==a.placeId||e[8]!==n?(u=a.machine??(a.placeId==="docker"?n("spaces.create.place.localDocker"):a.placeId),e[6]=a.machine,e[7]=a.placeId,e[8]=n,e[9]=u):u=e[9];const c=u;return`${a.name} · ${c}`},fl=6e3,i0=120,a0=80,l0=32,c0=100,d0=`
8
8
  var MAX_ELEMENTS = ${i0};
@@ -495,4 +495,4 @@ ${t}
495
495
  inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
496
496
  styles: styles
497
497
  };
498
- `),w0=t=>{const e=Be.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:u}=at();if(n.length===0)return null;let c;e[0]!==u?(c=u("contextPanel.browser.history.label"),e[0]=u,e[1]=c):c=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==u){let p;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==u?(p=(m,h)=>s.jsxs("div",{role:"option","aria-selected":h===r,className:$e("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",h===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),o(m.url)},onPointerEnter:()=>a(h),children:[s.jsx(se,{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:m.title||to(m.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),s.jsx("button",{type:"button",className:$e("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":u("contextPanel.browser.history.forget"),title:u("contextPanel.browser.history.forget"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),i(m.url)},children:s.jsx(se,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=u,e[14]=p):p=e[14],d=n.map(p),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=o,e[7]=u,e[8]=d}else d=e[8];let f;return e[15]!==c||e[16]!==d?(f=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":c,children:d}),e[15]=c,e[16]=d,e[17]=f):f=e[17],f},Ss=t=>{const e=Be.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:a}=t,u=a?"secondary":"ghost",c=a&&"text-foreground";let d;e[0]!==c?(d=$e("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",c),e[0]=c,e[1]=d):d=e[1];let f;e[2]!==n?(f=s.jsx(se,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==u||e[9]!==d||e[10]!==f?(p=s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{type:"button",variant:u,size:"xs",className:d,onClick:o,disabled:i,"aria-label":r,"aria-pressed":a,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=a,e[8]=u,e[9]=d,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=s.jsx($t,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let h;return e[14]!==p||e[15]!==m?(h=s.jsxs(Lt,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=h):h=e[16],h},Wd=t=>{const e=Be.c(110),{address:n,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:u,onBack:c,onForward:d,onReload:f,onOpenExternal:p,canOpenExternal:m,canGoBack:h,canGoForward:x,isLoading:g,onAnnotate:b,onOpenDevTools:w,isAnnotating:S,onHardReload:y,onZoomIn:I,onZoomOut:j,onZoomReset:R,zoomPercent:_,onClearCookies:P,onClearCache:k,onToggleDeviceBar:N,isDeviceBarOpen:T}=t;let A;e[0]!==o?(A=o===void 0?[]:o,e[0]=o,e[1]=A):A=e[1];const $=A,K=m===void 0?!0:m,q=_===void 0?100:_,{t:M}=at(),[z,ne]=l.useState(!1),[H,V]=l.useState(-1);let F;e[2]!==z||e[3]!==$?(F=z?$:[],e[2]=z,e[3]=$,e[4]=F):F=e[4];const C=F;let te;e[5]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{V(-1)},e[5]=te):te=e[5];let re;e[6]!==n||e[7]!==z?(re=[n,z],e[6]=n,e[7]=z,e[8]=re):re=e[8],l.useEffect(te,re);let Q;e[9]!==u?(Q=qe=>{ne(!1),V(-1),u(qe)},e[9]=u,e[10]=Q):Q=e[10];const ee=Q;let le;e[11]!==H||e[12]!==ee||e[13]!==C?(le=qe=>{if(C.length!==0){if(qe.key==="ArrowDown"||qe.key==="ArrowUp"){qe.preventDefault();const et=qe.key==="ArrowDown"?1:-1,He=C.length;V(Ye=>{const dt=Ye+et;return dt<-1?He-1:dt>=He?-1:dt});return}if(qe.key==="Escape"&&H>=0){qe.preventDefault(),V(-1);return}if(qe.key==="Enter"&&H>=0){qe.preventDefault();const et=C[H];et&&ee(et.url)}}},e[11]=H,e[12]=ee,e[13]=C,e[14]=le):le=e[14];const O=le;let Y;e[15]!==M?(Y=M("contextPanel.browser.back"),e[15]=M,e[16]=Y):Y=e[16];const Z=!h;let we;e[17]!==c||e[18]!==Y||e[19]!==Z?(we=s.jsx(Ss,{icon:"arrow-left",label:Y,onClick:c,disabled:Z}),e[17]=c,e[18]=Y,e[19]=Z,e[20]=we):we=e[20];let L;e[21]!==M?(L=M("contextPanel.browser.forward"),e[21]=M,e[22]=L):L=e[22];const pe=!x;let je;e[23]!==d||e[24]!==L||e[25]!==pe?(je=s.jsx(Ss,{icon:"arrow-right",label:L,onClick:d,disabled:pe}),e[23]=d,e[24]=L,e[25]=pe,e[26]=je):je=e[26];let Ee;e[27]!==g||e[28]!==M?(Ee=M(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=M,e[29]=Ee):Ee=e[29];let Se;e[30]!==f||e[31]!==Ee?(Se=s.jsx(Ss,{icon:"refresh",label:Ee,onClick:f}),e[30]=f,e[31]=Ee,e[32]=Se):Se=e[32];let Le;e[33]!==y||e[34]!==M?(Le=y?s.jsx(Ss,{icon:"restart",label:M("contextPanel.browser.hardReload"),onClick:y}):null,e[33]=y,e[34]=M,e[35]=Le):Le=e[35];let Pe;e[36]!==n||e[37]!==ee?(Pe=qe=>{qe.preventDefault(),ee(n)},e[36]=n,e[37]=ee,e[38]=Pe):Pe=e[38];let Ve;e[39]!==r?(Ve=r?s.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:s.jsx(se,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=Ve):Ve=e[40];let Oe;e[41]!==a?(Oe=qe=>a(qe.target.value),e[41]=a,e[42]=Oe):Oe=e[42];let be,ye;e[43]===Symbol.for("react.memo_cache_sentinel")?(be=()=>ne(!0),ye=()=>ne(!1),e[43]=be,e[44]=ye):(be=e[43],ye=e[44]);const Ue=C.length>0,Te=r&&"ps-8";let Me;e[45]!==Te?(Me=$e("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",Te,"typography-micro text-foreground outline-none"),e[45]=Te,e[46]=Me):Me=e[46];let Re;e[47]!==M?(Re=M("contextPanel.browser.addressAria"),e[47]=M,e[48]=Re):Re=e[48];let ze;e[49]!==n||e[50]!==O||e[51]!==Oe||e[52]!==Ue||e[53]!==Me||e[54]!==Re?(ze=s.jsx("input",{value:n,onChange:Oe,onFocus:be,onBlur:ye,onKeyDown:O,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Ue,"aria-controls":"openchamber-browser-address-suggestions",className:Me,"aria-label":Re}),e[49]=n,e[50]=O,e[51]=Oe,e[52]=Ue,e[53]=Me,e[54]=Re,e[55]=ze):ze=e[55];let B;e[56]!==i?(B=qe=>i?.(qe),e[56]=i,e[57]=B):B=e[57];let ce;e[58]!==H||e[59]!==ee||e[60]!==B||e[61]!==C?(ce=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(w0,{entries:C,activeIndex:H,onSelect:ee,onForget:B,onHighlight:V})}),e[58]=H,e[59]=ee,e[60]=B,e[61]=C,e[62]=ce):ce=e[62];let G;e[63]!==Pe||e[64]!==Ve||e[65]!==ze||e[66]!==ce?(G=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Pe,children:[Ve,ze,ce]}),e[63]=Pe,e[64]=Ve,e[65]=ze,e[66]=ce,e[67]=G):G=e[67];let Ce;e[68]!==I||e[69]!==j||e[70]!==R||e[71]!==M||e[72]!==q?(Ce=j&&I?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(Ss,{icon:"subtract",label:M("contextPanel.browser.zoomOut"),onClick:j}),q!==100&&R?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsxs(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:R,"aria-label":M("contextPanel.browser.zoomReset"),children:[q,"%"]})}),s.jsx($t,{sideOffset:6,children:M("contextPanel.browser.zoomReset")})]}):null,s.jsx(Ss,{icon:"add",label:M("contextPanel.browser.zoomIn"),onClick:I})]}):null,e[68]=I,e[69]=j,e[70]=R,e[71]=M,e[72]=q,e[73]=Ce):Ce=e[73];let J;e[74]!==P||e[75]!==M?(J=P?s.jsx(Ss,{icon:"delete-bin",label:M("contextPanel.browser.clearCookies"),onClick:P}):null,e[74]=P,e[75]=M,e[76]=J):J=e[76];let Ne;e[77]!==k||e[78]!==M?(Ne=k?s.jsx(Ss,{icon:"database-2",label:M("contextPanel.browser.clearCache"),onClick:k}):null,e[77]=k,e[78]=M,e[79]=Ne):Ne=e[79];let Ae;e[80]!==T||e[81]!==N||e[82]!==M?(Ae=N?s.jsx(Ss,{icon:"smartphone",label:M("contextPanel.browser.deviceToolbar"),onClick:N,pressed:T}):null,e[80]=T,e[81]=N,e[82]=M,e[83]=Ae):Ae=e[83];let Ie;e[84]!==S||e[85]!==b||e[86]!==M?(Ie=b?s.jsx(Ss,{icon:"markup",label:M("contextPanel.browser.annotate.toggle"),onClick:b,pressed:S}):null,e[84]=S,e[85]=b,e[86]=M,e[87]=Ie):Ie=e[87];let De;e[88]!==w||e[89]!==M?(De=w?s.jsx(Ss,{icon:"terminal-box",label:M("contextPanel.browser.devTools"),onClick:w}):null,e[88]=w,e[89]=M,e[90]=De):De=e[90];let We;e[91]!==M?(We=M("contextPanel.browser.openExternal"),e[91]=M,e[92]=We):We=e[92];const Ke=!K;let Ze;e[93]!==p||e[94]!==We||e[95]!==Ke?(Ze=s.jsx(Ss,{icon:"external-link",label:We,onClick:p,disabled:Ke}),e[93]=p,e[94]=We,e[95]=Ke,e[96]=Ze):Ze=e[96];let Qe;return e[97]!==we||e[98]!==je||e[99]!==Se||e[100]!==Le||e[101]!==G||e[102]!==Ce||e[103]!==J||e[104]!==Ne||e[105]!==Ae||e[106]!==Ie||e[107]!==De||e[108]!==Ze?(Qe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[we,je,Se,Le,G,Ce,J,Ne,Ae,Ie,De,Ze]}),e[97]=we,e[98]=je,e[99]=Se,e[100]=Le,e[101]=G,e[102]=Ce,e[103]=J,e[104]=Ne,e[105]=Ae,e[106]=Ie,e[107]=De,e[108]=Ze,e[109]=Qe):Qe=e[109],Qe},Gr={kind:"fill"},pl=240,y0=3840,Ud=[{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}],ml=t=>Number.isFinite(t)?Math.round(Math.min(y0,Math.max(pl,t))):pl,Kr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Vd=t=>{const e=Ud.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},v0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},S0=(t,e)=>{const n=Kr(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},k0=["mobile","tablet","desktop","fill"],j0={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},hl=t=>typeof t=="string"&&k0.includes(t),ui=t=>t==="fill"?Gr:Vd(j0[t])??Gr,Sr=t=>{const e=Kr(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=ui(n),o=Kr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},C0=t=>{const e=Be.c(70),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:u}=at();let c;e[0]!==n?(c=Kr(n),e[0]=n,e[1]=c):c=e[1];const d=c,f=n.kind==="preset"?n.id:"";let p;e[2]!==r||e[3]!==d?(p=(le,O)=>{const Y=Number.parseInt(O,10);if(!Number.isFinite(Y))return;const Z=d??{width:1280,height:800};r({kind:"custom",width:ml(le==="width"?Y:Z.width),height:ml(le==="height"?Y:Z.height)})},e[2]=r,e[3]=d,e[4]=p):p=e[4];const m=p;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=$e("oc-raised oc-field h-6 w-14 rounded-full bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none"),e[5]=h):h=e[5];const x=h;let g;e[6]!==r?(g=le=>{const O=Vd(le.target.value);r(O??Gr)},e[6]=r,e[7]=g):g=e[7];let b;e[8]!==u?(b=u("contextPanel.browser.device.preset"),e[8]=u,e[9]=b):b=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=$e("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=w):w=e[10];let S;e[11]!==u?(S=u("contextPanel.browser.device.responsive"),e[11]=u,e[12]=S):S=e[12];let y;e[13]!==S?(y=s.jsx("option",{value:"",children:S}),e[13]=S,e[14]=y):y=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=Ud.map(T0),e[15]=I):I=e[15];let j;e[16]!==f||e[17]!==g||e[18]!==b||e[19]!==y?(j=s.jsxs("select",{value:f,onChange:g,"aria-label":b,className:w,children:[y,I]}),e[16]=f,e[17]=g,e[18]=b,e[19]=y,e[20]=j):j=e[20];const R=d?String(d.width):"";let _;e[21]!==m?(_=le=>m("width",le.target.value),e[21]=m,e[22]=_):_=e[22];let P;e[23]!==u?(P=u("contextPanel.browser.device.width"),e[23]=u,e[24]=P):P=e[24];let k;e[25]!==R||e[26]!==_||e[27]!==P?(k=s.jsx("input",{value:R,onChange:_,placeholder:"—",inputMode:"numeric","aria-label":P,className:x}),e[25]=R,e[26]=_,e[27]=P,e[28]=k):k=e[28];let N;e[29]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=N):N=e[29];const T=d?String(d.height):"";let A;e[30]!==m?(A=le=>m("height",le.target.value),e[30]=m,e[31]=A):A=e[31];let $;e[32]!==u?($=u("contextPanel.browser.device.height"),e[32]=u,e[33]=$):$=e[33];let K;e[34]!==T||e[35]!==A||e[36]!==$?(K=s.jsx("input",{value:T,onChange:A,placeholder:"—",inputMode:"numeric","aria-label":$,className:x}),e[34]=T,e[35]=A,e[36]=$,e[37]=K):K=e[37];let q;e[38]!==r||e[39]!==n?(q=()=>r(v0(n)),e[38]=r,e[39]=n,e[40]=q):q=e[40];const M=!d;let z;e[41]!==u?(z=u("contextPanel.browser.device.rotate"),e[41]=u,e[42]=z):z=e[42];let ne;e[43]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(se,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=ne):ne=e[43];let H;e[44]!==q||e[45]!==M||e[46]!==z?(H=s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:q,disabled:M,"aria-label":z,children:ne})}),e[44]=q,e[45]=M,e[46]=z,e[47]=H):H=e[47];let V;e[48]!==u?(V=u("contextPanel.browser.device.rotate"),e[48]=u,e[49]=V):V=e[49];let F;e[50]!==V?(F=s.jsx($t,{sideOffset:6,children:V}),e[50]=V,e[51]=F):F=e[51];let C;e[52]!==H||e[53]!==F?(C=s.jsxs(Lt,{children:[H,F]}),e[52]=H,e[53]=F,e[54]=C):C=e[54];let te;e[55]!==a||e[56]!==d?(te=d&&a<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[55]=a,e[56]=d,e[57]=te):te=e[57];let re;e[58]===Symbol.for("react.memo_cache_sentinel")?(re=["system","light","dark"],e[58]=re):re=e[58];let Q;e[59]!==o||e[60]!==i||e[61]!==u?(Q=s.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:re.map(le=>s.jsx(ft,{type:"button",variant:o===le?"secondary":"ghost",size:"xs",className:$e("shrink-0 rounded-full px-2.5 typography-micro",o===le?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(le),"aria-pressed":o===le,children:u(le==="system"?"contextPanel.browser.device.schemeSystem":le==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},le))}),e[59]=o,e[60]=i,e[61]=u,e[62]=Q):Q=e[62];let ee;return e[63]!==j||e[64]!==k||e[65]!==K||e[66]!==C||e[67]!==te||e[68]!==Q?(ee=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,k,N,K,C,te,Q]}),e[63]=j,e[64]=k,e[65]=K,e[66]=C,e[67]=te,e[68]=Q,e[69]=ee):ee=e[69],ee};function T0(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Zr=new Map,fi=new Set,Hd=()=>{for(const t of fi)t()},Bo=(t,e)=>{const n=t.trim();n&&(e.length===0?Zr.delete(n):Zr.set(n,[...e]),Hd())},N0=t=>{Zr.delete(t.trim())&&Hd()},qd=[],E0=t=>Zr.get(t.trim())??qd,P0=t=>(fi.add(t),()=>{fi.delete(t)}),I0=t=>{const e=Be.c(2);let n;return e[0]!==t?(n=()=>E0(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(P0,n,R0)};function R0(){return qd}const Gd="oc.browser.hiddenDevServerPorts.v1",D0=ei(Ps(),ud(mo().int().positive())),pi=new Set,Kd=[];let kr=null;const Ji=()=>{const t=so().getItem(Gd);if(kr&&kr.raw===t)return kr.value;let e={};if(t!==null)try{const n=D0.safeParse(JSON.parse(t));n.success&&(e=n.data)}catch{e={}}return kr={raw:t,value:e},e},Zd=t=>{so().setItem(Gd,JSON.stringify(t));for(const e of pi)e()},_0=(t=as())=>Ji()[t]??Kd,A0=t=>{const e=as(),n=Ji(),r=n[e]??[];r.includes(t)||Zd({...n,[e]:[...r,t].sort((o,i)=>o-i)})},O0=()=>{const t=as(),e=Ji();if(!e[t])return;const n={...e};delete n[t],Zd(n)},M0=t=>(pi.add(t),()=>{pi.delete(t)}),F0=()=>l.useSyncExternalStore(M0,L0,$0);function L0(){return _0()}function $0(){return Kd}const B0=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},z0=2e3,W0=t=>gc("http://localhost",t),Xd=t=>{const e=Be.c(62),{onOpen:n,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=at();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={kind:"loading"},e[0]=u):u=e[0];const[c,d]=l.useState(u),f=I0(i);let p;e[1]!==i?(p=()=>W0(i),e[1]=i,e[2]=p):p=e[2];const[m]=l.useState(p);let h;e[3]!==i?(h=()=>Uf(i),e[3]=i,e[4]=h):h=e[4];const[x]=l.useState(h);let g;e[5]!==i?(g=Zl(i),e[5]=i,e[6]=g):g=e[6];const b=g,w=Yi(i),S=_u(i);let y,I;e[7]!==i||e[8]!==S||e[9]!==o?(y=()=>{if(S){d({kind:"ready",servers:[]});return}if(!o)return;let ee=!0,le=null;const O=new AbortController,Y=()=>{Cv(O.signal,i).then(Z=>{ee&&(d(Z),le=setTimeout(Y,z0))})};return Y(),()=>{ee=!1,le&&clearTimeout(le),O.abort()}},I=[i,S,o],e[7]=i,e[8]=S,e[9]=o,e[10]=y,e[11]=I):(y=e[10],I=e[11]),l.useEffect(y,I);const j=Gt(U0),R=tt(V0);let _;if(e[12]!==j||e[13]!==R){const ee=j.map(H0);let le;e[15]!==R?(le=[...R].flatMap(q0),e[15]=R,e[16]=le):le=e[16],_=[...ee,...le],e[12]=j,e[13]=R,e[14]=_}else _=e[14];const P=_;let k;e[17]!==f||e[18]!==i||e[19]!==c.kind||e[20]!==c.servers||e[21]!==P?(k=Rv({candidates:Ev({announced:f,discovered:c.kind==="ready"?c.servers:null}),folders:P,directory:i}),e[17]=f,e[18]=i,e[19]=c.kind,e[20]=c.servers,e[21]=P,e[22]=k):k=e[22];const N=k,T=F0(),[A,$]=l.useState(!1);let K;if(e[23]!==N||e[24]!==T||e[25]!==A){let ee;e[27]!==T||e[28]!==A?(ee=le=>le.announced||!T.includes(le.port)&&(A||!le.outsideWork),e[27]=T,e[28]=A,e[29]=ee):ee=e[29],K=N.filter(ee),e[23]=N,e[24]=T,e[25]=A,e[26]=K}else K=e[26];const q=K,M=N.length-q.length;let z;e[30]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(Fh,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=z):z=e[30];let ne;e[31]!==a?(ne=a("contextPanel.browser.empty"),e[31]=a,e[32]=ne):ne=e[32];let H;e[33]!==ne?(H=s.jsx("span",{className:"typography-ui-header text-foreground",children:ne}),e[33]=ne,e[34]=H):H=e[34];let V;e[35]!==a?(V=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=V):V=e[36];let F;e[37]!==V?(F=s.jsx("span",{className:"typography-micro text-muted-foreground",children:V}),e[37]=V,e[38]=F):F=e[38];let C;e[39]!==H||e[40]!==F?(C=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[H,F]}),e[39]=H,e[40]=F,e[41]=C):C=e[41];let te;e[42]!==f||e[43]!==N.length||e[44]!==i||e[45]!==M||e[46]!==b||e[47]!==n||e[48]!==m||e[49]!==w||e[50]!==x||e[51]!==a||e[52]!==q?(te=N.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-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),m&&!x?s.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx(fs,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:q.map(ee=>s.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[s.jsxs(ft,{type:"button",variant:"outline",size:"sm",className:$e("min-w-0 flex-1 justify-start gap-2",m&&"cursor-default opacity-60"),"aria-disabled":m||void 0,onClick:()=>{m||(N0(i),n(ee.url))},children:[b?s.jsx("span",{className:"shrink-0",role:"img","aria-label":w??a("contextPanel.browser.spaceAddress"),title:w??a("contextPanel.browser.spaceAddress"),children:s.jsx(se,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):s.jsx(se,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsxs("span",{className:"truncate",children:[to(ee.url)||ee.url,s.jsx("span",{className:"typography-micro text-muted-foreground",children:B0(ee.url)})]}),x?s.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:s.jsx(se,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):ee.folderName?s.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:ee.directory,children:[s.jsx(se,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",dir:"auto",children:ee.folderName})]}):null]}),ee.announced?null:s.jsx(ft,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>A0(ee.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:ee.port}),title:a("contextPanel.browser.devServers.hide",{port:ee.port}),children:s.jsx(se,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},ee.port))}),M>0?s.jsx(ft,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{O0(),$(!0)},children:M===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:M}):a("contextPanel.browser.devServers.showHiddenPlural",{count:M})}):null]}):null,e[42]=f,e[43]=N.length,e[44]=i,e[45]=M,e[46]=b,e[47]=n,e[48]=m,e[49]=w,e[50]=x,e[51]=a,e[52]=q,e[53]=te):te=e[53];let re;e[54]!==N.length||e[55]!==c.kind||e[56]!==a?(re=N.length===0&&c.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=N.length,e[55]=c.kind,e[56]=a,e[57]=re):re=e[57];let Q;return e[58]!==C||e[59]!==te||e[60]!==re?(Q=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:[z,C,te,re]}),e[58]=C,e[59]=te,e[60]=re,e[61]=Q):Q=e[61],Q};function U0(t){return t.projects}function V0(t){return t.availableWorktreesByProject}function H0(t){return{path:t.path,projectPath:t.path}}function q0(t){const[e,n]=t;return n.map(r=>({path:r.path,projectPath:e}))}const G0=3e4,K0=3,Z0=250,X0={attempts:0,windowStartedAt:null},Y0=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=G0,r=n?0:t.attempts;return r>=K0?null:{delayMs:Z0*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},J0=-3,jr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",In=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Q0=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:Lh),[i,a]=l.useState(e),[u,c]=l.useState(""),[d,f]=l.useState(!1),[p,m]=l.useState(!1),h=l.useRef(n);h.current=n;const x=l.useRef(X0);return l.useEffect(()=>{if(!t)return;const g=()=>{try{const N=t.getURL();return jr(N)?N:""}catch{return""}},b=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},w=N=>{jr(N)&&(a(N),h.current(N))},S=()=>{const N=g();o({kind:"loading",url:N})},y=()=>{const N=g();let T="";try{T=t.getTitle()||""}catch{T=""}c(T),w(N),b(),o(A=>A.kind==="failed"?A:{kind:"ready",url:N,title:T})},I=N=>{const T=In(N);jr(T.url)&&(w(T.url),b())},j=N=>{const T=In(N),A=Array.isArray(T.favicons)?T.favicons.find(Boolean):"",$=g();if(!A||!$)return;let K=-1;try{K=t.getWebContentsId()}catch{return}!Number.isFinite(K)||K<0||Td.getState().resolve($,A,K)},R=N=>{const T=In(N);typeof T.title=="string"&&c(T.title)},_=N=>{const T=In(N);if(T.isMainFrame===!1)return;const A=typeof T.errorCode=="number"?T.errorCode:0;A!==J0&&o({kind:"failed",url:jr(T.validatedURL)?T.validatedURL:g(),code:A,description:typeof T.errorDescription=="string"?T.errorDescription:""})};let P=null;const k=()=>{const N=g(),T=Y0(x.current,Date.now());if(!T){o({kind:"failed",url:N,code:0,description:"",crashed:!0});return}x.current=T.state,o({kind:"loading",url:N}),P=setTimeout(()=>{P=null;try{t.reload()}catch{o({kind:"failed",url:N,code:0,description:"",crashed:!0})}},T.delayMs)};t.addEventListener("did-start-loading",S),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",I),t.addEventListener("did-navigate-in-page",I),t.addEventListener("page-title-updated",R),t.addEventListener("page-favicon-updated",j),t.addEventListener("did-fail-load",_),t.addEventListener("render-process-gone",k),t.addEventListener("crashed",k);try{!t.isLoading()&&g()&&y()}catch{}return()=>{P!==null&&clearTimeout(P),t.removeEventListener("render-process-gone",k),t.removeEventListener("crashed",k),t.removeEventListener("did-start-loading",S),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",I),t.removeEventListener("did-navigate-in-page",I),t.removeEventListener("page-title-updated",R),t.removeEventListener("page-favicon-updated",j),t.removeEventListener("did-fail-load",_)}},[t]),{status:r,url:i,title:u,canGoBack:d,canGoForward:p}},gl=1e3,Yd=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},eS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},tS=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},sS=(t,e)=>{const n=l.useRef(0),r=l.useRef(0),o=l.useRef(0),i=l.useRef(null),a=l.useCallback(()=>{if(!t||document.activeElement!==t)return;const u=i.current;u&&u.isConnected&&u!==document.body?u.focus({preventScroll:!0}):t.blur()},[t]);return l.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=tS());const u=c=>{if(document.activeElement!==t){i.current=eS(c);return}const d=e.current,f=n.current>r.current||Date.now()<o.current;d&&Yd(d)&&!f||r.current>0||a()};return document.addEventListener("focusin",u,!0),()=>document.removeEventListener("focusin",u,!0)},[a,e,t]),l.useCallback(async u=>{const c=t!==null&&document.activeElement===t;let d=!1;const f=()=>{d&&(d=!1,r.current-=1,o.current=Date.now()+gl,!c&&r.current===0&&a())},p=()=>(d||(d=!0,r.current+=1),f);n.current+=1;try{return await u(p)}finally{n.current-=1,o.current=Date.now()+gl,f()}},[a,t])},nS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),rS=()=>document.visibilityState==="visible",oS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Cr=.5,iS=-3,aS=4,lS="persist:openchamber-browser",Jd=(t,e,n)=>js(t)!==null&&Yl(e)?{icon:"instance",label:n}:void 0,xl=t=>{const e=js(t);return e?`openchamber-space-preview:${e}`:lS},bl="openchamber:browser-panel-open-tab",cS=Qs({webContentsId:mo(),url:Ps().min(1),background:dr()}),wl=20,dS=600,uS=2e4,fS=15e3,yl=500,vl=5e3,pS=3e4,mS=3e3,Sl=1e3,hS=250,gS=Qs({quiet:dr()}),xS=()=>new Promise(t=>{let e=0,n=0,r=0,o;const i=d=>{clearTimeout(o),t(d)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},u=()=>{n=e,r=performance.now()+Sl,o=setTimeout(c,Sl)},c=()=>{e>n||performance.now()-r>hS?u():i(!1)};requestAnimationFrame(a),u()}),bS=t=>{if(!t||Yd(t))return()=>{};const e=t.getBoundingClientRect(),n=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=n}},wS=({initialUrl:t,directory:e,siteDirectory:n,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=at(),{currentTheme:u}=no(),c=l.useRef(null),[d,f]=l.useState(null),p=l.useCallback(oe=>{c.current=oe,f(oe)},[]),m=X(oe=>oe.setContextPanelTabTargetPath),h=l.useRef(Rn(t)),x=h.current!==Xs?h.current:"",[g,b]=l.useState(x?null:Xs),w=Yi(n),[S,y]=l.useState(x),[I,j]=l.useState(!1),[R,_]=l.useState(!1),[P,k]=l.useState(0),N=l.useRef(0),[T,A]=l.useState(!1),[$,K]=l.useState(Gr),q=l.useRef($);q.current=$;const M=l.useRef([]),[z,ne]=l.useState("system"),[H,V]=l.useState({width:0,height:0}),F=l.useRef(null),C=l.useRef(null),te=us(e),re=l.useRef(!!x&&!Au(te,r)),Q=l.useRef(null);l.useEffect(()=>{Xl(te,r)},[te,r]);const ee=l.useRef(!1),le=l.useRef(Date.now()),O=l.useCallback(oe=>{!oe||oe===Xs||!e||!r||m(e,r,oe)},[e,r,m]),Y=Q0(d,{initialUrl:x,onUrlChange:l.useCallback(oe=>{const de=kn(oe);y(de),O(de)},[O])}),[Z,we]=l.useState(null),[L,pe]=l.useState(js(n)===null);l.useEffect(()=>{const oe=js(n);if(oe===null){pe(!0);return}let de=!0;return pe(!1),En("desktop_space_preview_prepare",{spaceId:oe}).then(()=>{de&&pe(!0)}).catch(()=>{de&&we(x||"http://localhost/")}),()=>{de=!1}},[n,x]);const je=$h(e),Ee=Bh(),Se=Y.status.kind==="loading",Le=_n(zd(n)),Pe=_n(oe=>oe.recordVisit),Ve=_n(oe=>oe.forget);l.useEffect(()=>{Y.status.kind==="ready"&&Pe(n,{url:kn(Y.status.url),title:Y.status.title})},[n,Y.status,Pe]);const Oe=l.useMemo(()=>Bd(Le,S),[Le,S]),be=l.useCallback(oe=>{const de=Rn(oe);de!==Xs&&(re.current=!1,y(de),we(null),ba(de,n).then(ve=>{const v=c.current;if(!v){b(ve);return}try{v.loadURL(ve)}catch{b(ve)}}).catch(ve=>{ve instanceof wa&&we(de)}))},[n]);l.useEffect(()=>{if(!x)return;let oe=!0;return ba(x,n).then(de=>{oe&&b(de)}).catch(de=>{if(oe){if(de instanceof wa){we(x),re.current=!1,b(Xs);return}b(x)}}),()=>{oe=!1}},[]);const ye=l.useMemo(()=>({executeJavaScript:async(oe,de)=>{const ve=c.current;if(!ve)throw new Error("Browser view is not available");return ve.executeJavaScript(oe,de)},capturePage:async()=>{const oe=c.current;if(!oe)return null;const de=oe.getWebContentsId();return Number.isFinite(de)?await En("desktop_browser_capture_page",{webContentsId:de}):null}}),[]),Ue=l.useCallback(()=>{if(I){j(!1),Eo(ye);return}if(!Y.url){_e.error(a("contextPanel.browser.annotate.noPage"));return}const oe=zh(u.metadata.variant==="light"?"light":"dark");j(!0),Wh({host:ye,theme:oe,labels:Ee}).then(async de=>{j(!1),de&&await je(de)}).catch(()=>{j(!1),_e.error(a("contextPanel.browser.annotate.failed"))})},[ye,je,u,I,Y.url,Ee,a]);l.useEffect(()=>{if(!I)return;const oe=de=>{Ic(de)||de.key!=="Escape"||(de.preventDefault(),de.stopImmediatePropagation(),j(!1),Eo(ye))};return window.addEventListener("keydown",oe,!0),()=>window.removeEventListener("keydown",oe,!0)},[ye,I]);const Te=l.useRef(!1);l.useEffect(()=>{if(!d)return;const oe=()=>{Te.current=!0};return d.addEventListener("dom-ready",oe),d.addEventListener("did-fail-load",oe),()=>{d.removeEventListener("dom-ready",oe),d.removeEventListener("did-fail-load",oe)}},[d]);const Me=l.useCallback(async()=>{const oe=Date.now()+fS;for(;!(c.current&&Te.current)&&Date.now()<oe;)await new Promise(de=>setTimeout(de,100));return c.current},[]),Re=l.useCallback(async(oe=8e3)=>{const de=Date.now();for(;;){const ve=c.current;if(!ve)return!1;let v=!1;try{v=ve.isLoading()}catch{return!1}if(!v)return!0;if(Date.now()-de>oe)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),ze=l.useCallback(async(oe,de)=>{const ve=g0({quietMs:yl,maxMs:de});let v;const ae=new Promise(W=>{v=setTimeout(()=>W(null),de+1e3)});try{const W=gS.safeParse(await Promise.race([oe.executeJavaScript(ve,!1),ae]));return W.success&&W.data.quiet}catch{return!1}finally{clearTimeout(v)}},[]),B=l.useCallback(async(oe,de=pS)=>{const ve=Date.now(),v=await Re(Math.min(25e3,Math.max(0,de-vl))),ae=de-(Date.now()-ve),W=v&&ae>yl&&await ze(oe,Math.min(vl,ae));let me="";try{me=oe.getTitle()||""}catch{me=""}return{title:me,settled:W}},[Re,ze]),ce=l.useCallback(async(oe,de,ve)=>{const v=await Me();if(!v)throw new Error("The browser panel is not ready");const ae=()=>{hl(de.viewport)&&(K(ui(de.viewport)),A(!0))};if(oe==="browser.back"||oe==="browser.forward"){const ke=oe==="browser.back";if(!(ke?v.canGoBack():v.canGoForward()))throw new Error(ke?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");ke?v.goBack():v.goForward(),await new Promise(lt=>setTimeout(lt,150)),await Re();let ge="";try{ge=v.getTitle()||""}catch{ge=""}return{url:kn(v.getURL()),title:ge}}if(oe==="browser.capture"){const ke=bS(F.current);try{if(!await xS())throw new Error("The OpenChamber window is not being drawn (minimized, on a workspace or tab that is not shown, or the screen is locked or off), so nothing can be captured. browser.snapshot still reads the page.");await Re()&&await ze(v,mS);const rt=await ye.capturePage();if(!rt)throw new Error("The page could not be captured");let ge="";try{ge=v.getTitle()||""}catch{ge=""}return{...rt,url:kn(v.getURL()),title:ge,viewport:Sr(q.current)}}finally{ke()}}if(oe==="browser.resize"){if(!hl(de.viewport))throw new Error("viewport is required");return ae(),await new Promise(ke=>setTimeout(ke,200)),await Re(),{viewport:Sr(ui(de.viewport))}}if(oe==="browser.open"){const ke=typeof de.url=="string"?de.url:"";if(!ke)throw new Error("url is required");return ae(),be(ke),await new Promise(rt=>setTimeout(rt,150)),{url:Rn(ke),...await B(v),opened:!0,viewport:Sr(q.current)}}if(oe==="browser.settle"){const ke=mo().safeParse(de.budgetMs);return B(v,ke.success?ke.data:void 0)}await Re();const W=ke=>typeof ke=="string"&&ke?ke:void 0,he=(()=>{switch(oe){case"browser.snapshot":return u0({selector:W(de.selector)});case"browser.click":return f0({selector:W(de.selector),text:W(de.text)});case"browser.type":return p0({selector:String(de.selector??""),value:String(de.value??""),submit:de.submit===!0});case"browser.select":return m0({selector:String(de.selector??""),label:typeof de.label=="string"?de.label:void 0,value:typeof de.value=="string"?de.value:void 0});case"browser.inspect":return b0({selector:String(de.selector??"")});case"browser.scroll":return h0({selector:W(de.selector),direction:W(de.direction)});default:return null}})();if(!he)throw new Error(`Unsupported browser action: ${oe}`);let Je=()=>{};(oe==="browser.click"||oe==="browser.type")&&(await En("desktop_browser_keep_page_focused",{webContentsId:v.getWebContentsId()}).then(rt=>rt.focused===!0).catch(()=>!1)||(Je=ve(),v.focus({preventScroll:!0})));let Fe;try{Fe=await v.executeJavaScript(he,!0)}finally{Je()}if(!Fe||typeof Fe!="object")throw new Error("The page returned no result");const fe=Fe;if(fe.ok!==!0)throw new Error(typeof fe.error=="string"&&fe.error?fe.error:"Browser action failed");if(oe==="browser.snapshot"){const ke=M.current;return{...fe,viewport:Sr(q.current),...ke.length>0?{consoleProblems:[...ke]}:{}}}return(oe==="browser.click"||oe==="browser.select"||oe==="browser.type"&&de.submit===!0)&&(await new Promise(ke=>setTimeout(ke,150)),await Re()),Fe},[ye,be,B,Re,ze,Me]),G=sS(d,F),[Ce,J]=l.useState(!1),Ne=l.useCallback((oe,de)=>(J(!0),G(ve=>ce(oe,de,ve))),[G,ce]),Ae=l.useCallback(()=>{const oe=c.current;if(!oe)return{title:"",url:""};let de="",ve="";try{de=oe.getTitle()||""}catch{de=""}try{ve=kn(oe.getURL())}catch{ve=""}return{title:de,url:ve}},[]);l.useEffect(()=>qv({tabId:r,directory:te,ownerSessionId:o,describe:Ae,run:Ne}),[Ae,o,Ne,te,r]),l.useEffect(()=>{const oe=ye;return()=>{Eo(oe)}},[ye]),l.useEffect(()=>{if(!d)return;const oe=ve=>{const v=ve;if(typeof v.level!="number"||v.level<2)return;const ae=v.sourceId?`${v.sourceId}${v.line?`:${v.line}`:""}`:"";M.current.push({level:v.level>=3?"error":"warning",message:String(v.message??"").slice(0,400),source:ae}),M.current.length>wl&&M.current.splice(0,M.current.length-wl)},de=()=>{M.current=[]};return d.addEventListener("console-message",oe),d.addEventListener("did-start-loading",de),()=>{d.removeEventListener("console-message",oe),d.removeEventListener("did-start-loading",de)}},[d]);const Ie=l.useRef(new Set),De=l.useCallback(oe=>{Ie.current.clear(),be(oe)},[be]),We=l.useRef(Y.status);We.current=Y.status;const Ke=l.useRef(!1);Y.status.kind==="ready"&&Y.status.url&&(Ke.current=!0),l.useEffect(()=>Ou(te,r,oe=>{Fu(We.current,Ke.current)&&De(oe)}),[De,te,r]),l.useEffect(()=>{if(!d)return;const oe=ve=>{const v=In(ve),ae=typeof v.url=="string"?v.url:"";!ae||!ya(ae,n)||(ve.preventDefault(),be(ae))},de=ve=>{const v=In(ve);if(v.isMainFrame===!1||v.errorCode===-3)return;const ae=typeof v.validatedURL=="string"?v.validatedURL:"";!ae||!ya(ae,n)||Ie.current.has(ae)||(Ie.current.add(ae),be(ae))};return d.addEventListener("will-navigate",oe),d.addEventListener("did-fail-load",de),()=>{d.removeEventListener("will-navigate",oe),d.removeEventListener("did-fail-load",de)}},[n,be,d]),l.useEffect(()=>{if(!d)return;const oe=de=>{if(!(de instanceof CustomEvent))return;const ve=cS.safeParse(de.detail);if(!ve.success)return;let v=-1;try{v=d.getWebContentsId()}catch{return}ve.data.webContentsId===v&&X.getState().openContextBrowser(te,ve.data.url,{reveal:!ve.data.background})};return window.addEventListener(bl,oe),()=>window.removeEventListener(bl,oe)},[te,d]);const Ze=l.useCallback(oe=>{const de=Math.min(aS,Math.max(iS,oe));N.current=de,k(de);try{c.current?.setZoomLevel(de)}catch{}},[]);l.useEffect(()=>{const oe=de=>{if(!(de instanceof CustomEvent))return;const ve=de.detail,v=c.current;!v||document.activeElement!==v||(ve==="zoom-in"?Ze(N.current+Cr):ve==="zoom-out"?Ze(N.current-Cr):ve==="zoom-reset"&&Ze(0))};return window.addEventListener("openchamber:zoom",oe),()=>window.removeEventListener("openchamber:zoom",oe)},[Ze]);const Qe=l.useCallback(oe=>{En("desktop_browser_clear_data",{partition:xl(n),cookies:oe==="cookies",cache:oe==="cache"}).then(()=>{_e.success(a(oe==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{c.current?.reloadIgnoringCache()}catch{}}).catch(()=>_e.error(a("contextPanel.browser.clearFailed")))},[n,a]);l.useEffect(()=>{const oe=F.current;if(!oe||typeof ResizeObserver>"u")return;const de=new ResizeObserver(ve=>{const v=ve[0]?.contentRect;v&&V({width:v.width,height:v.height})});return de.observe(oe),()=>de.disconnect()},[]);const qe=l.useCallback(oe=>{ne(oe);const de=c.current;if(!de)return;let ve=-1;try{ve=de.getWebContentsId()}catch{return}En("desktop_browser_set_color_scheme",{webContentsId:ve,scheme:oe}).catch(v=>{ne("system"),_e.error(v instanceof Error?v.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),et=l.useCallback(()=>{try{Se?c.current?.stop():c.current?.reload()}catch{}},[Se]),He=Y.status,Ye=l.useSyncExternalStore(nS,rS),dt=i&&Ye||o!==null||Ce;l.useEffect(()=>{const oe=W=>{_(!0);const me=setTimeout(()=>{try{c.current?.reload()}catch{}},W);return()=>clearTimeout(me)};if(He.kind==="loading")return;const de=re.current||Q.current===He;if(re.current&&(He.kind==="failed"||He.kind==="ready"&&He.url)&&(re.current=!1,Q.current=He),He.kind==="failed"){const W=Mu(He,{run:C.current,restored:de,watched:dt,now:Date.now()});if(C.current=W.run,W.next==="retry")return oe(W.delayMs);_(W.next==="pause");return}if(C.current=null,He.kind!=="ready"||!He.url||!Yl(He.url)){ee.current=!0,_(!1);return}if(de||ee.current||Date.now()-le.current>uS){ee.current=!0,_(!1);return}let ve=!1,v=null;return(js(n)?Promise.resolve(null):Tv(kn(He.url))).then(W=>{if(!ve){if(W===null||W<500){ee.current=!0,_(!1);return}v=oe(dS)}}),()=>{ve=!0,v?.()}},[n,He,dt]);const nt=Y.status.kind==="failed"&&!R?Y.status:null,ut=S0($,H);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Wd,{address:S,onAddressChange:y,onSubmit:De,suggestions:Oe,onForgetSuggestion:oe=>Ve(n,oe),onBack:()=>{try{c.current?.goBack()}catch{}},onForward:()=>{try{c.current?.goForward()}catch{}},onReload:et,onOpenExternal:()=>{qn(Y.url||S)},addressMark:Jd(n,S,w??a("contextPanel.browser.spaceAddress")),canOpenExternal:js(n)===null,canGoBack:Y.canGoBack,canGoForward:Y.canGoForward,isLoading:Se,onAnnotate:Ue,isAnnotating:I,onOpenDevTools:()=>{try{c.current?.openDevTools()}catch{}},onHardReload:()=>{try{c.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ze(P+Cr),onZoomOut:()=>Ze(P-Cr),onZoomReset:()=>Ze(0),zoomPercent:Math.round(Math.pow(1.2,P)*100),onClearCookies:()=>Qe("cookies"),onClearCache:()=>Qe("cache"),onToggleDeviceBar:()=>A(oe=>!oe),isDeviceBarOpen:T}),T?s.jsx(C0,{viewport:$,onViewportChange:K,colorScheme:z,onColorSchemeChange:qe,scale:ut?.scale??1}):null,s.jsxs("div",{ref:F,className:$e("relative min-h-0 flex-1 bg-background",ut&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&L?s.jsx("webview",{ref:p,src:g,partition:xl(n),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:ut?{width:`${ut.width}px`,height:`${ut.height}px`,transform:`scale(${ut.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!x&&!Y.url&&!Se?s.jsx(Xd,{onOpen:De,directory:n,visible:i}):null,R?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:a("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,Z?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[js(n)!==null?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a(js(n)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:Z})})]}):null,nt&&!Z?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:nt.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:nt.crashed?a("contextPanel.browser.crashedHint"):nt.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,Se?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 bg-[var(--primary)]"})}):null]})]})},yS=t=>{const e=Be.c(75),{initialUrl:n,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:u}=at(),c=X(SS);let d;e[0]!==n?(d=Rn(n),e[0]=n,e[1]=d):d=e[1];const f=d,p=f!==Xs?f:"",[m,h]=l.useState(p);let x;e[2]!==o||e[3]!==p?(x=Co(p,o),e[2]=o,e[3]=p,e[4]=x):x=e[4];const[g,b]=l.useState(x);let w;e[5]!==o||e[6]!==p?(w=gc(p,o)?p:"",e[5]=o,e[6]=p,e[7]=w):w=e[7];const[S,y]=l.useState(w);let I;e[8]!==o?(I=js(o),e[8]=o,e[9]=I):I=e[9];const j=I!==null,R=Yi(o);let _;e[10]!==p?(_=p?[p]:[],e[10]=p,e[11]=_):_=e[11];const[P,k]=l.useState(_),[N,T]=l.useState(p?0:-1),[A,$]=l.useReducer(kS,0);let K,q;e[12]!==i||e[13]!==r?(K=()=>{Xl(us(r),i)},q=[r,i],e[12]=i,e[13]=r,e[14]=K,e[15]=q):(K=e[14],q=e[15]),l.useEffect(K,q);let M;e[16]!==c||e[17]!==i||e[18]!==r?(M=Oe=>{!Oe||Oe===Xs||!r||!i||c(r,i,Oe)},e[16]=c,e[17]=i,e[18]=r,e[19]=M):M=e[19];const z=M;let ne;e[20]!==o?(ne=zd(o),e[20]=o,e[21]=ne):ne=e[21];const H=_n(ne),V=_n(jS),F=_n(CS);let C;e[22]!==m||e[23]!==H?(C=Bd(H,m),e[22]=m,e[23]=H,e[24]=C):C=e[24];const te=C;let re;e[25]!==o||e[26]!==N||e[27]!==z||e[28]!==V?(re=Oe=>{const be=Rn(Oe);if(be===Xs)return;h(be);const ye=Co(be,o);b(ye),y(ye?"":be),z(be),V(o,{url:be}),k(Ue=>{const Te=N>=0?Ue.slice(0,N+1):[];return Te[Te.length-1]===be?(T(Te.length-1),Te):(T(Te.length),[...Te,be])})},e[25]=o,e[26]=N,e[27]=z,e[28]=V,e[29]=re):re=e[29];const Q=re;let ee;e[30]!==o||e[31]!==P||e[32]!==z?(ee=Oe=>{const be=P[Oe];if(!be)return;T(Oe),h(be);const ye=Co(be,o);b(ye),y(ye?"":be),z(be)},e[30]=o,e[31]=P,e[32]=z,e[33]=ee):ee=e[33];const le=ee;let O;e[34]!==o||e[35]!==F?(O=Oe=>F(o,Oe),e[34]=o,e[35]=F,e[36]=O):O=e[36];let Y,Z;e[37]!==le||e[38]!==N?(Y=()=>le(N-1),Z=()=>le(N+1),e[37]=le,e[38]=N,e[39]=Y,e[40]=Z):(Y=e[39],Z=e[40]);let we;e[41]!==m||e[42]!==g?(we=()=>{qn(g||m)},e[41]=m,e[42]=g,e[43]=we):we=e[43];let L;e[44]!==R||e[45]!==u?(L=R??u("contextPanel.browser.spaceAddress"),e[44]=R,e[45]=u,e[46]=L):L=e[46];let pe;e[47]!==m||e[48]!==o||e[49]!==L?(pe=Jd(o,m,L),e[47]=m,e[48]=o,e[49]=L,e[50]=pe):pe=e[50];const je=!S,Ee=N>0,Se=N>=0&&N<P.length-1;let Le;e[51]!==m||e[52]!==Q||e[53]!==te||e[54]!==O||e[55]!==Y||e[56]!==Z||e[57]!==we||e[58]!==pe||e[59]!==je||e[60]!==Ee||e[61]!==Se?(Le=s.jsx(Wd,{address:m,onAddressChange:h,onSubmit:Q,suggestions:te,onForgetSuggestion:O,onBack:Y,onForward:Z,onReload:$,onOpenExternal:we,addressMark:pe,canOpenExternal:je,canGoBack:Ee,canGoForward:Se,isLoading:!1}),e[51]=m,e[52]=Q,e[53]=te,e[54]=O,e[55]=Y,e[56]=Z,e[57]=we,e[58]=pe,e[59]=je,e[60]=Ee,e[61]=Se,e[62]=Le):Le=e[62];let Pe;e[63]!==o||e[64]!==j||e[65]!==g||e[66]!==Q||e[67]!==A||e[68]!==u||e[69]!==S||e[70]!==a?(Pe=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:S?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[j?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:u(j?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:to(S)})}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:u("contextPanel.browser.remoteLoopback.hint")})]}):g?s.jsx("iframe",{src:g,title:u("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${A}`):s.jsx(Xd,{onOpen:Q,directory:o,visible:a})}),e[63]=o,e[64]=j,e[65]=g,e[66]=Q,e[67]=A,e[68]=u,e[69]=S,e[70]=a,e[71]=Pe):Pe=e[71];let Ve;return e[72]!==Le||e[73]!==Pe?(Ve=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Le,Pe]}),e[72]=Le,e[73]=Pe,e[74]=Ve):Ve=e[74],Ve},vS=t=>{const e=Be.c(3),[n]=l.useState(oS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(wS,{...t}):s.jsx(yS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function SS(t){return t.setContextPanelTabTargetPath}function kS(t){return t+1}function jS(t){return t.recordVisit}function CS(t){return t.forget}const TS=t=>{const e=Be.c(13),{zone:n,children:r}=t,[o]=l.useState(NS);let i;e[0]!==n?(i=m=>m.body[n],e[0]=n,e[1]=i):i=e[1];const a=ur(i);let u,c;e[2]!==a||e[3]!==o||e[4]!==n?(u=()=>{const m=a??ur.getState().body[n];if(!m){o.remove();return}if(o.parentElement===m)return;const h=document.activeElement;m.moveBefore&&o.isConnected?m.moveBefore(o,null):m.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:!0})},c=[a,o,n],e[2]=a,e[3]=o,e[4]=n,e[5]=u,e[6]=c):(u=e[5],c=e[6]),l.useLayoutEffect(u,c);let d,f;e[7]!==o?(d=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=d,e[9]=f):(d=e[8],f=e[9]),l.useLayoutEffect(d,f);let p;return e[10]!==r||e[11]!==o?(p=Ul.createPortal(r,o),e[10]=r,e[11]=o,e[12]=p):p=e[12],p};function NS(){const t=document.createElement("div");return t.style.display="contents",t}const ES=200,Qd=t=>`${t.path}:${t.line}:${t.column}`,kl={status:"idle"},PS=t=>{const e=Be.c(9),{searchContents:n,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:u,active:c}=t,[d,f]=l.useState(kl);let p,m;return e[0]!==c||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==u||e[6]!==n?(p=()=>{if(!c||!n||!r||!o.trim()){f(kl);return}const h=new AbortController;let x=!1;return f({status:"searching"}),n({directory:r,query:o,regex:i,limit:ES,includeHidden:a,respectGitignore:u,signal:h.signal}).then(g=>{x||f(g.status==="ok"?{status:"results",matches:g.matches,stopped:g.stopped}:g)}).catch(g=>{x||f({status:"failed",message:g instanceof Error?g.message:String(g)})}),()=>{x=!0,h.abort()}},m=[c,r,a,o,i,u,n],e[0]=c,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=u,e[6]=n,e[7]=p,e[8]=m):(p=e[7],m=e[8]),l.useEffect(p,m),d},ln=t=>{const e=Be.c(5),{className:n,children:r}=t;let o;e[0]!==n?(o=$e("px-2 py-1 typography-meta text-muted-foreground",n),e[0]=n,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=s.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},IS=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},RS=t=>{const e=Be.c(44),{state:n,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:u}=at();switch(n.status){case"idle":return null;case"searching":{let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=p):p=e[0];let m;e[1]!==u?(m=u("sidebarFilesTree.state.searching"),e[1]=u,e[2]=m):m=e[2];let h;return e[3]!==m?(h=s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[p,m]}),e[3]=m,e[4]=h):h=e[4],h}case"unavailable":{let p;e[5]!==u?(p=u("sidebarFilesTree.contentSearch.unavailable"),e[5]=u,e[6]=p):p=e[6];let m;return e[7]!==p?(m=s.jsx(ln,{children:p}),e[7]=p,e[8]=m):m=e[8],m}case"invalid-pattern":{let p;e[9]!==u?(p=u("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=u,e[10]=p):p=e[10];let m;e[11]!==p?(m=s.jsx("span",{className:"text-[var(--status-error)]",children:p}),e[11]=p,e[12]=m):m=e[12];let h;e[13]!==n.message?(h=s.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:n.message}),e[13]=n.message,e[14]=h):h=e[14];let x;return e[15]!==m||e[16]!==h?(x=s.jsxs(ln,{className:"flex flex-col gap-0.5",children:[m,h]}),e[15]=m,e[16]=h,e[17]=x):x=e[17],x}case"failed":{let p;e[18]!==n.message||e[19]!==u?(p=u("sidebarFilesTree.contentSearch.failed",{message:n.message}),e[18]=n.message,e[19]=u,e[20]=p):p=e[20];let m;return e[21]!==p?(m=s.jsx(ln,{className:"text-[var(--status-error)]",children:p}),e[21]=p,e[22]=m):m=e[22],m}}if(n.matches.length===0){let p;return e[23]!==n.stopped||e[24]!==u?(p=n.stopped==="deadline"?s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.deadline")}):s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.empty")}),e[23]=n.stopped,e[24]=u,e[25]=p):p=e[25],p}let c;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==n.matches){let p;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(p=m=>{const{name:h,directory:x}=IS(m.relativePath),g=Qd(m),b=r===g;return s.jsx("li",{"data-file-tree-path":m.path,children:s.jsxs("button",{type:"button",onClick:()=>o(m),onDoubleClick:()=>o(m,{pin:!0}),draggable:!!i,onDragStart:i?w=>i(w,m):void 0,onDragEnd:a?w=>a(w,m):void 0,className:$e("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",zi(b)),title:`${m.relativePath}:${m.line}`,children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsx(uo,{filePath:m.path,className:"size-3.5 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`‎${x}‎`}):s.jsx("span",{className:"flex-1"}),s.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:m.line})]}),s.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[m.cutStart?"…":null,s.jsx(Uh,{segments:Vh(m.text,m.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=p):p=e[36],c=n.matches.map(p),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=n.matches,e[31]=c}else c=e[31];let d;e[37]!==n.matches.length||e[38]!==n.stopped||e[39]!==u?(d=n.stopped==="limit"?s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.limit",{count:n.matches.length})}):n.stopped==="deadline"?s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=n.matches.length,e[38]=n.stopped,e[39]=u,e[40]=d):d=e[40];let f;return e[41]!==c||e[42]!==d?(f=s.jsxs(s.Fragment,{children:[c,d]}),e[41]=c,e[42]=d,e[43]=f):f=e[43],f},jl=8;let pr=null;const eu=(t,e)=>Math.abs(e.clientX-t.x)<=jl&&Math.abs(e.clientY-t.y)<=jl,mi=t=>{pr={x:t.clientX,y:t.clientY}},hi=t=>{const e=pr;return pr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:eu(e,t)},tu=t=>pr!==null&&eu(pr,t);let su=null;const zo=t=>{su=t},nu=()=>su,Cl=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},ru=(t,e,n)=>{const r=e===null?n:e.type==="directory"?e.path:Cl(e.path);return!r||Cl(t.path)===r||t.type==="directory"&&Lu(r,t.path,t.path)!==null?null:r},DS=(t,e)=>{const n=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${n}`:`${e}/${n}`},_S=({root:t,childrenByDir:e,expandedPaths:n,loadErrorsByDir:r})=>{const o=[],i=(a,u)=>{for(const c of e[a]??[]){const d=c.type==="directory"&&n.has(c.path);if(o.push({kind:"node",key:c.path,node:c,depth:u,isExpanded:d}),!d)continue;const f=r[c.path];f&&o.push({kind:"error",key:`error:${c.path}`,directory:c.path,depth:u+1,message:f}),i(c.path,u+1)}};return i(t,0),o},AS=(t,e,n)=>{const r=e.filter(o=>o>=0&&o<n&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},OS=28,An=t=>Array.from(t.types).includes("Files"),ar=t=>Array.from(t.types).includes(cr)?nu():null,ou=(t,e,n)=>t.getData(cr)===wo(e,n.path),MS=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},FS=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),Bt=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},wo=(t,e)=>{const n=Bt(e),r=Bt(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Xn=(t,e)=>{const n=wo(t,e);if(n!==".")return n;const r=Bt(t);return r.split("/").filter(Boolean).pop()??r},Mr=t=>{const e=Bt(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},LS=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),$S=new Set(["node_modules"]),BS=t=>$S.has(t),zS=t=>{const e=Bt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},WS=8,_s=new Map,Qi=t=>JSON.stringify([as(),t]),US=t=>{const e=Qi(t),n=_s.get(e);return n?(n.touchedAt=Date.now(),_s.delete(e),_s.set(e,n),n):null},Wo=t=>{const e=Qi(t),n=_s.get(e);if(n)return n.touchedAt=Date.now(),n;if(_s.size>=WS){const o=_s.keys().next().value;o!==void 0&&_s.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return _s.set(e,r),r},VS=t=>{const e=Be.c(131),{node:n,root:r,isExpanded:o,isActive:i,isBrowserClient:a,depth:u,isOpen:c,status:d,badge:f,isDropTarget:p,isDragSource:m,canUpload:h,canMove:x,permissions:g,downloadFile:b,onSelect:w,onToggle:S,onRevealPath:y,onOpenDialog:I,onSetDropTarget:j,onDropFiles:R,onPickFiles:_,onMoveDragChange:P,onSetMoveDropTarget:k,onMoveDrop:N}=t,{t:T}=at(),A=n.type==="directory";let $;e[0]!==A||e[1]!==n.path?($=A?n.path:Mr(n.path),e[0]=A,e[1]=n.path,e[2]=$):$=e[2];const K=$,{canRename:q,canCreateFile:M,canCreateFolder:z,canDelete:ne,canReveal:H}=g,V=!A&&!!b,F=H&&!a,C=A&&h,te=q||M||z||C||ne||V||F,[re,Q]=l.useState(!1),[ee,le]=l.useState(!1);let O;e[3]!==te?(O=ve=>{te&&(ve?.preventDefault(),le(!0))},e[3]=te,e[4]=O):O=e[4];const Y=O;let Z;e[5]!==A||e[6]!==n||e[7]!==w||e[8]!==S?(Z=()=>{A?S(n.path):w(n)},e[5]=A,e[6]=n,e[7]=w,e[8]=S,e[9]=Z):Z=e[9];const we=Z;let L;e[10]!==A||e[11]!==n||e[12]!==w?(L=()=>{A||w(n,{pin:!0})},e[10]=A,e[11]=n,e[12]=w,e[13]=L):L=e[13];const pe=L;let je;e[14]===Symbol.for("react.memo_cache_sentinel")?(je=ve=>{ve.stopPropagation(),le(!1),Q(!0)},e[14]=je):je=e[14];const Ee=je;let Se;e[15]!==M||e[16]!==z||e[17]!==ne||e[18]!==q||e[19]!==F||e[20]!==C||e[21]!==b||e[22]!==a||e[23]!==A||e[24]!==n||e[25]!==I||e[26]!==_||e[27]!==y||e[28]!==T?(Se=ve=>{const{Item:v,Separator:ae}=ve;return s.jsxs(s.Fragment,{children:[q&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("rename",n)},children:[s.jsx(se,{name:"edit",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.rename")]}),s.jsxs(v,{onClick:W=>{W.stopPropagation(),ro(n.path).then(me=>{if(me.ok){_e.success(T("sidebarFilesTree.toast.pathCopied"));return}_e.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(se,{name:"link",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.copyPath")]}),!A&&b&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),b(n.path).catch(me=>{console.error("Download failed:",me),_e.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"download",className:"me-2 h-4 w-4"})," ",T(a?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),F&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),y(n.path)},children:[s.jsx(se,{name:"folder-received",className:"me-2 h-4 w-4"})," ",T(Gh())]}),!A&&F&&eo()&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),Hl(n.path).then(me=>{me||_e.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"external-link",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.openInDefaultApp")]}),A&&(M||z||C)&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{}),M&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("createFile",n)},children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.newFile")]}),z&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("createFolder",n)},children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.newFolder")]}),C&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),_(n.path)},children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.uploadFiles")]})]}),ne&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{}),s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(se,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.delete")]})]})]})},e[15]=M,e[16]=z,e[17]=ne,e[18]=q,e[19]=F,e[20]=C,e[21]=b,e[22]=a,e[23]=A,e[24]=n,e[25]=I,e[26]=_,e[27]=y,e[28]=T,e[29]=Se):Se=e[29];const Le=Se;let Pe;e[30]!==x||e[31]!==n.path||e[32]!==n.type||e[33]!==P||e[34]!==r?(Pe=ve=>{mi(ve);const v=wo(r,n.path);!v||v==="."||(ve.dataTransfer.setData(cr,v),ve.dataTransfer.effectAllowed=x?"copyMove":"copy",x&&P({path:n.path,type:n.type}))},e[30]=x,e[31]=n.path,e[32]=n.type,e[33]=P,e[34]=r,e[35]=Pe):Pe=e[35];const Ve=Pe;let Oe;e[36]!==x||e[37]!==we||e[38]!==P?(Oe=ve=>{x&&P(null),hi(ve)&&we()},e[36]=x,e[37]=we,e[38]=P,e[39]=Oe):Oe=e[39];const be=Oe;let ye;e[40]!==h||e[41]!==j||e[42]!==K?(ye=ve=>{!h||!K||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),ve.dataTransfer.dropEffect="copy",j(K))},e[40]=h,e[41]=j,e[42]=K,e[43]=ye):ye=e[43];const Ue=ye;let Te;e[44]!==h||e[45]!==j||e[46]!==K?(Te=ve=>{!h||!K||!An(ve.dataTransfer)||ve.relatedTarget instanceof Node&&ve.currentTarget.contains(ve.relatedTarget)||(ve.stopPropagation(),j(null))},e[44]=h,e[45]=j,e[46]=K,e[47]=Te):Te=e[47];const Me=Te;let Re;e[48]!==h||e[49]!==R||e[50]!==K?(Re=ve=>{!h||!K||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),R(K,ve.dataTransfer))},e[48]=h,e[49]=R,e[50]=K,e[51]=Re):Re=e[51];const ze=Re;let B;e[52]!==n.path||e[53]!==n.type||e[54]!==r?(B=(ve,v)=>tu(ve)?null:ru(v,{path:n.path,type:n.type},r),e[52]=n.path,e[53]=n.type,e[54]=r,e[55]=B):B=e[55];const ce=B;let G;e[56]!==x||e[57]!==ce||e[58]!==Ue||e[59]!==k?(G=ve=>{const v=x?ar(ve.dataTransfer):null;if(!v){Ue(ve);return}ve.stopPropagation();const ae=ce(ve,v);k(ae),ae&&(ve.preventDefault(),ve.dataTransfer.dropEffect="move")},e[56]=x,e[57]=ce,e[58]=Ue,e[59]=k,e[60]=G):G=e[60];const Ce=G;let J;e[61]!==x||e[62]!==ce||e[63]!==ze||e[64]!==N||e[65]!==k||e[66]!==r?(J=ve=>{const v=x?ar(ve.dataTransfer):null;if(!v){ze(ve);return}ve.stopPropagation(),ve.preventDefault(),k(null);const ae=ce(ve,v);ae&&ou(ve.dataTransfer,r,v)&&N(v,ae)},e[61]=x,e[62]=ce,e[63]=ze,e[64]=N,e[65]=k,e[66]=r,e[67]=J):J=e[67];const Ne=J;let Ae;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ae={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ae):Ae=e[68];let Ie;e[69]!==Y||e[70]!==Me||e[71]!==Ce||e[72]!==Ne?(Ie=s.jsx("div",{className:"group relative flex items-center typography-meta",style:Ae,onContextMenu:Y,onDragEnter:Ce,onDragOver:Ce,onDragLeave:Me,onDrop:Ne}),e[69]=Y,e[70]=Me,e[71]=Ce,e[72]=Ne,e[73]=Ie):Ie=e[73];let De;e[74]!==u?(De=s.jsx(Hc,{depth:u}),e[74]=u,e[75]=De):De=e[75];let We;e[76]!==i||e[77]!==m||e[78]!==p?(We=$e("oc-file-tree-row flex w-full items-center gap-1.5 rounded-md py-1 text-start select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary [--oc-file-tree-row-fill:var(--interactive-selection)] [--oc-file-tree-row-ring:var(--primary)]":zi(i),m&&"opacity-50"),e[76]=i,e[77]=m,e[78]=p,e[79]=We):We=e[79];let Ke;e[80]!==u?(Ke=qc(u),e[80]=u,e[81]=Ke):Ke=e[81];let Ze;e[82]!==Ke?(Ze={paddingInlineStart:Ke},e[82]=Ke,e[83]=Ze):Ze=e[83];let Qe;e[84]!==A||e[85]!==o||e[86]!==n.extension||e[87]!==n.path?(Qe=A?s.jsx(Hh,{expanded:o}):s.jsx(uo,{filePath:n.path,extension:n.extension,className:"ms-0.5 size-3.5"}),e[84]=A,e[85]=o,e[86]=n.extension,e[87]=n.path,e[88]=Qe):Qe=e[88];let qe;e[89]!==n.name||e[90]!==n.path?(qe=s.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:n.path,children:n.name}),e[89]=n.name,e[90]=n.path,e[91]=qe):qe=e[91];let et;e[92]!==A||e[93]!==c||e[94]!==d?(et=!A&&s.jsx(Kh,{isOpen:c,status:d}),e[92]=A,e[93]=c,e[94]=d,e[95]=et):et=e[95];let He;e[96]!==f||e[97]!==A?(He=A&&f&&s.jsx(Zh,{badge:f}),e[96]=f,e[97]=A,e[98]=He):He=e[98];let Ye;e[99]!==et||e[100]!==He?(Ye=s.jsxs(Xh,{className:"pe-2",children:[et,He]}),e[99]=et,e[100]=He,e[101]=Ye):Ye=e[101];let dt;e[102]!==Y||e[103]!==pe||e[104]!==be||e[105]!==Ve||e[106]!==we||e[107]!==We||e[108]!==Ze||e[109]!==Qe||e[110]!==qe||e[111]!==Ye?(dt=s.jsxs("button",{type:"button",onClick:we,onDoubleClick:pe,onContextMenu:Y,draggable:!0,onDragStart:Ve,onDragEnd:be,className:We,style:Ze,children:[Qe,qe,Ye]}),e[102]=Y,e[103]=pe,e[104]=be,e[105]=Ve,e[106]=we,e[107]=We,e[108]=Ze,e[109]=Qe,e[110]=qe,e[111]=Ye,e[112]=dt):dt=e[112];let nt;e[113]!==re||e[114]!==te||e[115]!==i||e[116]!==p||e[117]!==Le||e[118]!==T?(nt=te&&s.jsx("div",{className:$e("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100",qh(i||p)),children:s.jsxs(xn,{open:re,onOpenChange:Q,children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(bn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Ee,title:T("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":T("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(se,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:T("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(wn,{align:"end",side:"bottom",onCloseAutoFocus:()=>Q(!1),children:Le({Item:qt,Separator:mn})})]})}),e[113]=re,e[114]=te,e[115]=i,e[116]=p,e[117]=Le,e[118]=T,e[119]=nt):nt=e[119];let ut;e[120]!==Ie||e[121]!==De||e[122]!==dt||e[123]!==nt?(ut=s.jsxs(oo,{render:Ie,children:[De,dt,nt]}),e[120]=Ie,e[121]=De,e[122]=dt,e[123]=nt,e[124]=ut):ut=e[124];let oe;e[125]!==Le?(oe=s.jsx(io,{className:"min-w-[180px]",children:Le({Item:Ns,Separator:Dn})}),e[125]=Le,e[126]=oe):oe=e[126];let de;return e[127]!==ee||e[128]!==ut||e[129]!==oe?(de=s.jsxs(gr,{open:ee,onOpenChange:le,children:[ut,oe]}),e[127]=ee,e[128]=ut,e[129]=oe,e[130]=de):de=e[130],de},HS=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles&&t.onPickFiles===e.onPickFiles&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,qS=l.memo(VS,HS),GS=t=>{const e=Be.c(14),{visible:n}=t,r=n===void 0?!0:n,o=Vn(ZS),i=Gs()??"",a=xr();let u,c,d,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(c=lo(a,i)??"",a?.kind==="preparing"){let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Pr,{}),e[7]=m):m=e[7],f=m;break e}u=KS,d=JSON.stringify([o,c])}e[0]=a,e[1]=i,e[2]=o,e[3]=u,e[4]=c,e[5]=d,e[6]=f}else u=e[3],c=e[4],d=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[8]!==u||e[9]!==c||e[10]!==i||e[11]!==d||e[12]!==r?(p=s.jsx(u,{visible:r,currentDirectory:c,panelDirectory:i},d),e[8]=u,e[9]=c,e[10]=i,e[11]=d,e[12]=r,e[13]=p):p=e[13],p},KS=({visible:t,currentDirectory:e,panelDirectory:n})=>{const r=l.useRef(t);r.current=t;const{t:o}=at(),{files:i,runtime:a}=Is(),u=$u(a.platform),c=Bt(e.trim()),d=Bt(n.trim()),f=Qi(c),p=Bu(),m=zu(),h=Wu(D=>D.searchFiles),x=X(D=>D.openContextFile),g=co(t?e:null),[b,w]=l.useState(""),S=Yh(b,200),y=l.useRef(null),[I,j]=l.useState([]),[R,_]=l.useState(!1),P=!!i.searchContents,[k,N]=l.useState("names"),[T,A]=l.useState(!1),$=P&&k==="contents",K=PS({searchContents:i.searchContents,directory:e,query:S,regex:T,includeHidden:p,respectGitignore:!m,active:t&&$}),q=X(D=>D.openContextFileAtLine),[M,z]=l.useState(null),[ne,H]=l.useState(null),[V,F]=l.useState(null),[C,te]=l.useState(null),[re,Q]=l.useState(null),{hasTouchOnlyPointer:ee}=yn(),le=!!(i.rename&&c)&&!ee,O=X(D=>D.confirmFileTreeMove),Y=X(D=>D.setConfirmFileTreeMove),[Z,we]=l.useState({}),[L,pe]=l.useState({}),je=l.useRef(new Set),Ee=l.useRef(new Map),Se=l.useMemo(()=>new _1,[]);l.useEffect(()=>()=>Se.clear(),[Se]);const Le=l.useRef(null);l.useEffect(()=>{if(H(null),te(null),Q(null),!c){we({}),pe({}),je.current=new Set;return}const D=US(c);D?(we({...D.childrenByDir}),pe({...D.loadErrorsByDir}),je.current=new Set(D.loadedDirs)):(we({}),pe({}),je.current=new Set)},[c]),l.useEffect(()=>{if(!c)return;const D=Wo(c);D.childrenByDir=Z},[c,Z]),l.useEffect(()=>{if(!c)return;const D=Wo(c);D.loadErrorsByDir=L},[c,L]),l.useEffect(()=>{if(!c)return;const D=Wo(c);D.loadedDirs=new Set(je.current)},[c,Z,L]),l.useEffect(()=>()=>{if(!c)return;const D=_s.get(f);D&&D.loadedDirs.size===0&&Object.keys(D.childrenByDir).length===0&&_s.delete(f)},[f,c]);const Pe=l.useMemo(()=>[],[]),Ve=l.useMemo(()=>[],[]),Oe=xs(D=>c?D.byRoot[c]?.expandedPaths??Pe:Pe),be=l.useMemo(()=>new Set(Oe),[Oe]),ye=xs(D=>c?D.byRoot[c]?.selectedPath??null:null),Ue=xs(D=>D.setSelectedPath),Te=l.useRef(null);l.useEffect(()=>{Te.current=ye},[ye]);const Me=xs(D=>D.addOpenPath),Re=xs(D=>D.removeOpenPathsByPrefix),ze=xs(D=>D.toggleExpandedPath),B=xs(D=>D.expandPath),ce=xs(D=>D.collapseAllExpandedPaths),G=X(D=>d?D.contextPanelByDirectory[d]?.tabs??Ve:Ve),Ce=l.useMemo(()=>new Set(G.map(D=>D.mode==="file"?D.targetPath:null).filter(D=>typeof D=="string"&&D.length>0).map(D=>Bt(D))),[G]),[J,Ne]=l.useState(null),[Ae,Ie]=l.useState(null),[De,We]=l.useState(""),[Ke,Ze]=l.useState(!1),Qe=!!i.writeFile,qe=!!i.createDirectory,et=!!i.rename,He=!!i.delete,Ye=!!i.revealPath,dt=l.useMemo(()=>({canRename:et,canCreateFile:Qe,canCreateFolder:qe,canDelete:He,canReveal:Ye}),[et,Qe,qe,He,Ye]),nt=l.useCallback(D=>{i.revealPath&&i.revealPath(D).catch(()=>{_e.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),ut=l.useCallback((D,E)=>{Ne(D),Ie(E),We(D==="rename"&&E.name||""),Ze(!1)},[]),oe=l.useCallback((D,E)=>{const xe=E.filter(ue=>ue&&typeof ue.name=="string"&&ue.name.length>0).filter(ue=>p||!ue.name.startsWith(".")).filter(ue=>m||!BS(ue.name)).map(ue=>{const it=ue.name,st=Bt(ue.path||""),Nt=st?LS(st)?st:Bt(`${D}/${st}`):Bt(`${D}/${it}`),Rt=ue.isDirectory?"directory":"file",Et=Rt==="file"&&it.includes(".")?it.split(".").pop()?.toLowerCase():void 0;return{name:it,path:Nt,type:Rt,extension:Et}});return FS(xe)},[m,p]),de=l.useCallback(async(D,E,xe=!1)=>{if(!r.current||E?.())return;const ue=Bt(D.trim());if(!ue||!xe&&je.current.has(ue))return;const it=as();return Se.run(ue,async st=>{const Nt=()=>!st()||as()!==it;try{const Rt=!m,Et=i.listDirectory?(await i.listDirectory(ue,{respectGitignore:Rt})).entries:await qo.listLocalDirectory(ue,{respectGitignore:Rt});if(Nt())return;Ee.current.set(ue,Et.length);const _t=oe(ue,Et);je.current=new Set(je.current),je.current.add(ue),pe(ys=>{if(!ys[ue])return ys;const sn={...ys};return delete sn[ue],sn}),we(ys=>ys[ue]&&A1(ys[ue],_t)?ys:{...ys,[ue]:_t})}catch(Rt){if(Nt())return;const Et=Rt instanceof Error?Rt.message:String(Rt??"");console.error("Failed to load sidebar directory:",Rt),pe(_t=>({..._t,[ue]:Et}))}},xe)},[Se,i,oe,m]),ve=l.useCallback(async()=>{if(!c)return;Le.current?.abort();const D=new AbortController;Le.current=D,Se.clear();try{const xe=(xs.getState().byRoot[c]?.expandedPaths??[]).map(st=>Bt(st)).filter(st=>!!st&&st!==c&&st.startsWith(`${c}/`)),ue=[c,...xe];je.current=new Set(je.current);for(const st of ue)je.current.delete(st);pe(st=>{if(Object.keys(st).length===0)return st;const Nt={...st};let Rt=!1;for(const Et of ue)Et in Nt&&(delete Nt[Et],Rt=!0);return Rt?Nt:st});const it=()=>D.signal.aborted;await de(c,it);for(let st=0;st<xe.length&&!D.signal.aborted;st+=3){const Nt=xe.slice(st,st+3);await Promise.all(Nt.map(Rt=>de(Rt,it)))}}catch(E){if(D.signal.aborted)return;console.error("Failed to refresh sidebar tree:",E)}finally{Le.current===D&&(Le.current=null)}},[Se,de,c]),v=l.useCallback(async D=>{if(!D){await ve();return}const E=Bt(D);je.current=new Set(je.current),je.current.delete(E),await de(E,void 0,!0)},[de,ve]);l.useEffect(()=>{c&&(Le.current?.abort(),je.current=new Set,Se.clear(),pe({}),we(D=>Object.keys(D).length===0?D:{}),de(c))},[Se,de,c,p,m]),l.useEffect(()=>{if(!t||!c||Oe.length===0)return;const D=Oe.map(ue=>Bt(ue)).filter(ue=>!!ue&&ue!==c&&ue.startsWith(`${c}/`)&&!je.current.has(ue)&&!Se.has(ue)).sort((ue,it)=>ue.split("/").length-it.split("/").length);if(D.length===0)return;let E=!1;const xe=()=>E;return(async()=>{for(let ue=0;ue<D.length&&!E;ue+=3){const it=D.slice(ue,ue+3);await Promise.all(it.map(st=>de(st,xe)))}})(),()=>{E=!0}},[Se,Oe,de,c,t]);const ae=l.useRef(t);l.useEffect(()=>{const D=t&&!ae.current;ae.current=t,D&&ve()},[ve,t]);const W=l.useCallback(({directories:D})=>{if(!c)return;const E=new Set((xs.getState().byRoot[c]?.expandedPaths??[]).map(Et=>Bt(Et))),xe=c==="/"?"/":`${c}/`,ue=Et=>{for(let _t=Et;_t!==c;_t=Mr(_t))if(!_t.startsWith(xe)||!E.has(_t))return!1;return!0},it=Et=>{for(let _t=Et;_t===c||_t.startsWith(xe);_t=Mr(_t)){if(je.current.has(_t))return _t;if(_t===c)break}return null},st=new Set,Nt=new Set;for(const Et of D??je.current){const _t=it(Bt(Et));_t&&(ue(_t)?st:Nt).add(_t)}Nt.size>0&&(je.current=new Set([...je.current].filter(Et=>!Nt.has(Et))));const Rt=[...st].filter(Et=>(Ee.current.get(Et)??0)<=Vf);(async()=>{for(let Et=0;Et<Rt.length;Et+=3)await Promise.all(Rt.slice(Et,Et+3).map(_t=>de(_t,void 0,!0)))})()},[de,c]);Hf({root:c,active:t,whileInactive:"drop",onChanges:W}),l.useEffect(()=>{if(!t)return;if(!e||$){j([]),_(!1);return}const D=S.trim();if(!D){j([]),_(!1);return}let E=!1;return _(!0),h(e,D,150,{includeHidden:p,respectGitignore:!m,type:"file"}).then(xe=>{if(E)return;const it=xe.filter(st=>m||!zS(st.path)).map(st=>({name:st.name,path:Bt(st.path),type:"file",extension:st.extension,relativePath:st.relativePath}));j(it)}).catch(()=>{E||j([])}).finally(()=>{E||_(!1)}),()=>{E=!0}},[$,e,S,h,p,m,t]);const me=l.useMemo(()=>{const D=new Map;if(!g?.files)return D;for(const E of g.files)E.index==="A"||E.working_dir==="?"?D.set(E.path,"git-added"):E.index==="D"?D.set(E.path,"git-deleted"):(E.index==="M"||E.working_dir==="M")&&D.set(E.path,"git-modified");return D},[g]),he=l.useMemo(()=>{const D=new Map;if(!g?.files||!c)return D;for(const E of g.files){const xe=E.index==="M"||E.working_dir==="M",ue=E.index==="A"||E.working_dir==="?";if(!xe&&!ue)continue;const it=E.path.split("/");if(it.length<=1)continue;let st=c;for(let Nt=0;Nt<it.length-1;Nt++){st=`${st}/${it[Nt]}`;let Rt=D.get(st);Rt||(Rt={modified:0,added:0},D.set(st,Rt)),xe&&Rt.modified++,ue&&Rt.added++}}return D},[g,c]),Je=l.useCallback(D=>{if(me.size===0)return null;const E=D.startsWith(c+"/")?D.slice(c.length+1):D;return me.get(E)??null},[me,c]),Fe=l.useCallback(D=>{if(he.size===0)return null;const E=he.get(D);return E&&E.modified+E.added>0?E:null},[he]),fe=l.useCallback(async(D,E)=>{if(!c)return;const xe=await $a(i,D.path,{directory:c});if(!xe.ok){Ba(D.path,xe);return}Ue(c,D.path),Me(c,D.path),x(d,D.path,{preview:!E?.pin&&!X.getState().isMobile})},[Me,i,x,d,c,Ue]),ke=l.useCallback(async(D,E)=>{if(!c)return;const xe=await $a(i,D.path,{directory:c});if(!xe.ok){Ba(D.path,xe);return}Ue(c,D.path),Me(c,D.path),z({path:D.path,key:Qd(D)}),q(d,D.path,D.line,D.column,{preview:!E?.pin&&!X.getState().isMobile})},[Me,i,q,d,c,Ue]),rt=l.useCallback((D,E)=>{mi(D),zo(null),D.dataTransfer.setData(cr,E.relativePath),D.dataTransfer.effectAllowed="copy"},[]),ge=l.useCallback((D,E)=>{hi(D)&&ke(E)},[ke]),[lt,Ct]=l.useState(null),bt=l.useCallback(()=>Ct(null),[]),kt=l.useRef(null),ht=O1(kt,{onSettled:bt}),St=l.useCallback(async D=>{const E=Bt(D);if(!c)return;const xe=xs.getState().byRoot[c]?.expandedPaths.includes(E)??!1;ht(D,xe,()=>{const ue=Array.from(kt.current?.querySelectorAll("[data-tree-disclosure-path]")??[],it=>it.dataset.treeDisclosurePath??"");Ct(xe?null:ue.slice(ue.indexOf(D)+1)),ze(c,E)}),je.current.has(E)||await de(E)},[de,c,ze,ht]),{canUpload:yt,uploadingDirectory:xt,uploadFiles:vt,pickFiles:ct,uploadElements:Pt}=qf({root:c,refreshDirectory:v}),Dt=xt!==null,pt=xt??ne,mt=l.useCallback((D,E)=>{const xe=MS(E);xe.length!==0&&(H(null),vt(D,xe))},[vt]),Ot=l.useCallback(D=>{if(zo(D),!D){F(null),te(null);return}requestAnimationFrame(()=>{nu()?.path===D.path&&F(D.path)})},[]),Ut=l.useCallback(async(D,E)=>{const xe=DS(D,E),ue=await za(i,{tabs:d,files:c},D.path,xe);if(ue==="conflict"){_e.error(o("sidebarFilesTree.toast.nameTaken",{name:xe.slice(xe.lastIndexOf("/")+1),folder:Xn(c,E)}));return}if(ue==="failed"){_e.error(o("sidebarFilesTree.toast.operationFailed"));return}E!==c&&B(c,E),await Promise.all([v(Mr(D.path)),v(E)]).catch(()=>{})},[B,i,d,v,c,o]),ss=l.useCallback((D,E)=>{if(X.getState().confirmFileTreeMove){Q({source:D,targetDirectory:E});return}Ut(D,E)},[Ut]),ps=l.useCallback(()=>{re&&(Q(null),Ut(re.source,re.targetDirectory))},[Ut,re]),ns=l.useCallback((D,E)=>!le||tu(D)?null:ru(E,null,c),[le,c]),ms=l.useCallback(D=>{const E=ar(D.dataTransfer);if(E){const xe=ns(D,E);if(te(xe),!xe)return;D.preventDefault(),D.dataTransfer.dropEffect="move";return}!yt||Dt||!c||!An(D.dataTransfer)||(D.preventDefault(),D.dataTransfer.dropEffect="copy",H(c))},[yt,ns,Dt,c]),ls=l.useCallback(D=>{if(!(D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget))){if(ar(D.dataTransfer)){te(null);return}An(D.dataTransfer)&&H(null)}},[]),rs=l.useCallback(D=>{const E=ar(D.dataTransfer);if(E){D.preventDefault(),te(null);const xe=ns(D,E);xe&&ou(D.dataTransfer,c,E)&&ss(E,xe);return}!yt||Dt||!c||!An(D.dataTransfer)||(D.preventDefault(),mt(c,D.dataTransfer))},[yt,ns,mt,ss,Dt,c]),Rs=l.useCallback(async D=>{if(D?.preventDefault(),!Ae||!J)return;Ze(!0);const E=()=>Ze(!1),xe=()=>Ne(null);if(J==="createFile"){if(!De.trim()){_e.error(o("sidebarFilesTree.toast.filenameRequired")),E();return}if(!i.writeFile){_e.error(o("sidebarFilesTree.toast.writeNotSupported")),E();return}const ue=Ae.path,it=ue?`${ue}/`:"",st=Bt(`${it}${De.trim()}`);await i.writeFile(st,"").then(async Nt=>{Nt.success&&(_e.success(o("sidebarFilesTree.toast.fileCreated")),await v(ue)),xe()}).catch(()=>_e.error(o("sidebarFilesTree.toast.operationFailed"))).finally(E);return}if(J==="createFolder"){if(!De.trim()){_e.error(o("sidebarFilesTree.toast.folderNameRequired")),E();return}const ue=Ae.path,it=ue?`${ue}/`:"",st=Bt(`${it}${De.trim()}`);await i.createDirectory(st).then(async Nt=>{Nt.success&&(_e.success(o("sidebarFilesTree.toast.folderCreated")),await v(ue)),xe()}).catch(()=>_e.error(o("sidebarFilesTree.toast.operationFailed"))).finally(E);return}if(J==="rename"){if(!De.trim()){_e.error(o("sidebarFilesTree.toast.nameRequired")),E();return}if(!i.rename){_e.error(o("sidebarFilesTree.toast.renameNotSupported")),E();return}const ue=Ae.path,it=ue.split("/").slice(0,-1).join("/"),st=it?`${it}/`:"",Nt=De.trim(),Rt=Bt(`${st}${Nt}`);try{const Et=await za(i,{tabs:d,files:c},ue,Rt);Et==="moved"?(_e.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await v(it),xe()):Et==="conflict"?_e.error(o("sidebarFilesTree.toast.nameTaken",{name:Nt,folder:Xn(c,it)})):_e.error(o("sidebarFilesTree.toast.operationFailed"))}catch{_e.error(o("sidebarFilesTree.toast.operationFailed"))}finally{E()}return}if(J==="delete"){if(!i.delete){_e.error(o("sidebarFilesTree.toast.deleteNotSupported")),E();return}const ue=Ae.path,it=ue.split("/").slice(0,-1).join("/");await i.delete(ue).then(async st=>{st.success&&(_e.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await v(it),c&&Re(c,ue),(ye===ue||ye&&ye.startsWith(ue+"/"))&&Ue(c,null)),xe()}).catch(()=>_e.error(o("sidebarFilesTree.toast.operationFailed"))).finally(E);return}E()},[J,Ae,De,i,d,v,Re,c,ye,Ue,o]),Vt=l.useMemo(()=>c?_S({root:c,childrenByDir:Z,expandedPaths:be,loadErrorsByDir:L}):[],[Z,be,L,c]),cs=l.useMemo(()=>new Map(Vt.flatMap((D,E)=>D.kind==="node"?[[D.node.path,E]]:[])),[Vt]),[Ht,ie]=l.useState(null),[Ge,gt]=l.useState(null),jt=l.useCallback(D=>{kt.current=D,gt(D)},[]),[It,Mt]=l.useState(null),Kt=l.useMemo(()=>[V,It,...lt??[]].flatMap(D=>D?[cs.get(D)??-1]:[]),[It,V,lt,cs]),Jt=l.useCallback(D=>AS($1(D),Kt,Vt.length),[Kt,Vt.length]),[gs,Cs]=l.useState(0);l.useLayoutEffect(()=>{if(!Ht||!Ge)return;const D=Ge.getBoundingClientRect().top-Ht.getBoundingClientRect().top+Ht.scrollTop;Cs(Math.max(0,Math.round(D)))},[Ge,Ht]);const Ts=l.useRef(null),U=l.useRef(new Map),Xe=l.useRef(null),ot=l.useCallback(D=>{const E=Math.max(0,...U.current.values());D.style.setProperty("--oc-file-tree-width",`${E}px`)},[]),Tt=l.useCallback((D,E)=>{const xe=D.dataset.treeRowPath,ue=kt.current;!xe||!ue||E<=ue.clientWidth+.5||U.current.get(xe)!==E&&(U.current.set(xe,E),Xe.current===null&&(Xe.current=requestAnimationFrame(()=>{Xe.current=null,kt.current&&ot(kt.current)})))},[ot]);l.useEffect(()=>()=>{Xe.current!==null&&cancelAnimationFrame(Xe.current)},[]),l.useLayoutEffect(()=>{if(!Ge)return;const D=U.current;for(const ue of D.keys())cs.has(ue)||D.delete(ue);const E=Ht?.scrollLeft??0;Ge.style.removeProperty("--oc-file-tree-width");const xe=Ge.clientWidth;for(const ue of Ge.children){const it=ue instanceof HTMLElement?ue.dataset.treeRowPath:void 0;if(!it)continue;const st=ue.getBoundingClientRect().width;st>xe+.5?D.set(it,st):D.delete(it)}ot(Ge),Ht&&(Ht.scrollLeft=E)},[Ge,cs,Ht,ot]);const Zt=L1({count:Vt.length,enabled:Ht!==null,getScrollElement:()=>Ht,estimateSize:D=>(Vt[D]?.kind==="node"?Ts.current:null)??OS,measureElement:(D,E,xe)=>{const ue=B1(D,E,xe);return D.dataset.treeRowPath&&(Ts.current=ue),E&&Tt(D,E.borderBoxSize?.[0]?.inlineSize??D.getBoundingClientRect().width),ue},getItemKey:D=>Vt[D]?.key??D,overscan:12,scrollMargin:gs,rangeExtractor:Jt}),Ds=D=>{if(D.kind==="error")return s.jsxs("div",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:qc(D.depth)},children:[s.jsx(Hc,{depth:D.depth}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:D.message,children:D.message}),s.jsxs(ft,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{v(D.directory)},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]});const{node:E,depth:xe,isExpanded:ue}=D,it=E.type==="directory";return s.jsx(qS,{node:E,root:c,isExpanded:ue,isActive:ye===E.path,isBrowserClient:u,depth:xe,isOpen:!it&&Ce.has(E.path),status:it?void 0:Je(E.path),badge:it?Fe(E.path):void 0,isDropTarget:it&&(pt===E.path||C===E.path),isDragSource:V===E.path,canUpload:yt&&!Dt,canMove:le,permissions:dt,downloadFile:i.downloadFile,onSelect:fe,onToggle:St,onRevealPath:nt,onOpenDialog:ut,onSetDropTarget:H,onDropFiles:mt,onPickFiles:ct,onMoveDragChange:Ot,onSetMoveDropTarget:te,onMoveDrop:ss})},Xt=l.useCallback(D=>{const E=D.target instanceof Element?D.target.closest("[data-tree-row-path]"):null;Mt(E?.dataset.treeRowPath??null)},[]),en=l.useCallback(D=>{D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget)||Mt(null)},[]);l.useEffect(()=>{const D=Te.current;if(!D||!Ht||!Ge)return;const E=cs.get(D);E===void 0||Ht.offsetParent===null||(Te.current=null,Zt.scrollToIndex(E,{align:"auto"}))});const Sn=!!(c&&Z[c]),tn=c?L[c]:null,Gn=S.trim().length>0,yo=!R&&!Gn&&I.length===0&&!tn&&Sn&&!!c,Kn=pt?Xn(c,pt):"",br=C?Xn(c,C):"",vo=re?re.source.path.slice(re.source.path.lastIndexOf("/")+1):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col border-b border-edge-muted",children:[s.jsx("div",{className:"flex h-8 shrink-0 items-center border-t border-edge-muted px-2",children:s.jsx(Jh,{className:"flex-1",start:null,groups:[[(Qe||qe||yt)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:Dt?"loader-4":"add",iconClassName:Dt?"animate-spin":void 0,menu:s.jsxs(s.Fragment,{children:[Qe?s.jsxs(qt,{onClick:()=>ut("createFile",{path:e,type:"directory"}),children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,qe?s.jsxs(qt,{onClick:()=>ut("createFolder",{path:e,type:"directory"}),children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,yt?s.jsxs(qt,{disabled:!c||Dt,onClick:()=>ct(c),children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})},{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:m,onSelect:()=>Uu(!m)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{ve()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{c&&ce(c)}}]]})}),s.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[P?s.jsxs(xn,{children:[s.jsx(bn,{asChild:!0,children:s.jsxs(ft,{variant:"ghost",size:"sm",className:"absolute inset-s-3 top-3 size-6 p-0 text-muted-foreground hover:text-foreground",title:o("sidebarFilesTree.search.mode.aria"),"aria-label":o("sidebarFilesTree.search.mode.aria"),children:[s.jsx(se,{name:$?"file-search":"search",className:"h-4 w-4"}),s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})}),s.jsx(wn,{align:"start",side:"bottom",children:s.jsxs(Mc,{value:k,onValueChange:D=>N(D==="contents"?"contents":"names"),children:[s.jsxs(Wr,{value:"names",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),s.jsxs(Wr,{value:"contents",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):s.jsx(se,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),s.jsx(Un,{ref:y,value:b,onChange:D=>w(D.target.value),placeholder:o($?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:$e("h-8 ps-8 typography-meta",$?"pe-16":"pe-8")}),$?s.jsx(ft,{variant:"chip",size:"xs","aria-pressed":T,onClick:()=>{A(D=>!D),y.current?.focus()},title:o("sidebarFilesTree.search.regexTitle"),"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"}):null,b.trim().length>0?s.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:$e("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",$?"inset-e-10":"inset-e-4"),onClick:()=>{w(""),y.current?.focus()},children:s.jsx(se,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsxs(fs,{ref:ie,outerClassName:"h-full min-h-0",className:$e("@container px-1.5 py-1.5 [overflow-anchor:none]",(pt===c||C===c)&&"bg-interactive-selection/10"),onDragEnter:ms,onDragOver:ms,onDragLeave:ls,onDrop:rs,children:[s.jsx("ul",{className:"flex flex-col",children:$&&K.status!=="idle"?s.jsx(RS,{state:K,activeMatchKey:M&&M.path===ye?M.key:null,onOpen:ke,onDragStart:rt,onDragEnd:ge}):R?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Gn&&I.length===0?s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):I.length>0?I.map(D=>{const E=ye===D.path;return s.jsx("li",{"data-file-tree-path":D.path,children:s.jsxs("button",{type:"button",onClick:()=>fe(D),onDoubleClick:()=>fe(D,{pin:!0}),draggable:!0,onDragStart:xe=>{mi(xe),zo(null);const ue=D.relativePath||wo(c??"",D.path);!ue||ue==="."||(xe.dataTransfer.setData(cr,ue),xe.dataTransfer.effectAllowed="copy")},onDragEnd:xe=>{hi(xe)&&fe(D)},className:$e("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",zi(E)),title:D.path,children:[s.jsx(uo,{filePath:D.path,extension:D.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`‎${D.relativePath??D.path}‎`})]})},D.path)}):tn?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:tn}),s.jsxs(ft,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ve()},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]}):Sn&&c?null:s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),yo?s.jsx("ul",{ref:jt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Zt.getTotalSize()},onFocus:Xt,onBlur:en,children:Zt.getVirtualItems().map(D=>{const E=Vt[D.index];if(!E)return null;const xe=E.kind==="node"?E.node.path:void 0;return s.jsx("li",{ref:Zt.measureElement,"data-index":D.index,"data-tree-row-path":xe,"data-tree-disclosure-path":E.kind==="node"?xe:`${E.directory}/`,"data-file-tree-path":E.kind==="node"&&E.node.type==="file"?xe:void 0,className:$e("absolute inset-x-0 top-0",E.kind==="node"&&"min-w-max"),style:{transform:`translateY(${D.start-gs}px)`},children:Ds(E)},D.key)})}):null]}),pt?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(se,{name:Dt?"loader-4":"folder-received",className:$e("size-4 flex-shrink-0",Dt&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Kn,children:o(Dt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Kn})})]}):C?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(se,{name:"folder-received",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:br,children:o("sidebarFilesTree.drop.moveTarget",{path:br})})]}):null]}),Pt,s.jsx(zn,{open:!!J,onOpenChange:D=>!D&&Ne(null),children:s.jsxs(Bn,{children:[s.jsxs($n,{children:[s.jsxs(Fn,{children:[J==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),J==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),J==="rename"&&o("sidebarFilesTree.dialog.rename.title"),J==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Ln,{children:[J==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ae?.path??o("sidebarFilesTree.dialog.rootFallback")}),J==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ae?.path??o("sidebarFilesTree.dialog.rootFallback")}),J==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ae?.name??""}),J==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ae?.name??""})]})]}),J!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Un,{value:De,onChange:D=>We(D.target.value),placeholder:o(J==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:D=>{D.key==="Enter"&&Rs()},autoFocus:!0})}),s.jsxs(Br,{children:[s.jsx(ft,{variant:"outline",onClick:()=>Ne(null),disabled:Ke,children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{variant:J==="delete"?"destructive":"default",onClick:()=>{Rs()},disabled:Ke||J!=="delete"&&!De.trim(),children:Ke?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):o(J==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),s.jsx(zn,{open:re!==null,onOpenChange:D=>{D||Q(null)},children:s.jsxs(Bn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs($n,{children:[s.jsx(Fn,{children:o("sidebarFilesTree.dialog.move.title")}),s.jsx(Ln,{children:re?o("sidebarFilesTree.dialog.move.description",{name:vo,folder:Xn(c,re.targetDirectory)}):null})]}),s.jsxs(Br,{className:"w-full sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>Y(!O),children:[s.jsx(Ko,{checked:!O,onChange:D=>Y(!D),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),s.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:()=>Q(null),children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{onClick:ps,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function ZS(t){return t.runtimeKey}const XS=mr(()=>At(()=>import("./WalkthroughView-CiQk4Tg_.js"),__vite__mapDeps([207,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,208,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,209,210,211,204,212])).then(t=>({default:t.WalkthroughView}))),YS=mr(()=>At(()=>import("./DiffView-BXm5iGeW.js"),__vite__mapDeps([213,1,2,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,208,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,186,187,188,189,190,191,192,193,194,195,181,182,183,214,185,196,197,198,199,200,201,202,203,206,209,212])).then(t=>({default:t.DiffView}))),JS=mr(()=>At(()=>import("./FilesView-CAXuJLle.js"),__vite__mapDeps([215,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,216,217,218,219,181,182,183,220,221,200,222,186,187,188,189,190,191,192,193,194,195,223,197,224,225,226,201,202,199,206,227,228,212,203,229])).then(t=>({default:t.FilesView}))),iu=l.lazy(()=>At(()=>import("./useAppFontEffects-DpDiWkkc.js").then(t=>t.rG),__vite__mapDeps([3,1,2,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.PluginPane}))),Tl=l.lazy(()=>At(()=>import("./GuestSurfacePane-Dw0Um8RG.js"),__vite__mapDeps([230,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.GuestSurfacePane}))),au={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-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},QS=t=>{const e=Be.c(12),{mode:n,docking:r}=t,[o,i]=l.useState(null),a=au[r.dock],u=Math.max(sg,o??r.size),c=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let d;e[0]!==a.page||e[1]!==c?(d=$e("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c,a.page),e[0]=a.page,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==a.vertical||e[4]!==u?(f=a.vertical?{height:u}:{width:u},e[3]=a.vertical,e[4]=u,e[5]=f):f=e[5];let p;e[6]!==n?(p=s.jsx(iu,{mode:n,onResize:i}),e[6]=n,e[7]=p):p=e[7];let m;return e[8]!==d||e[9]!==f||e[10]!==p?(m=s.jsx("div",{className:d,style:f,children:p}),e[8]=d,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},Nn=(t,e)=>`${t}\0${e}`,e2=({visible:t,active:e,fill:n=!1,side:r})=>{const{t:o}=at(),i=X(y=>y.contextEditorTreeWidth),a=X(y=>y.setContextEditorTreeWidth),[u,c]=l.useState(!1),d=l.useRef(0),f=l.useRef(i),p=l.useRef(null),m=l.useRef(null),h=l.useRef(null),x=l.useCallback(y=>{const I=h.current;I&&(I.style.width=`${y}px`,I.style.setProperty("--oc-editor-tree-width",`${y}px`))},[]),g=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}m.current=y.pointerId,c(!0),d.current=y.clientX,f.current=i,p.current=i,y.preventDefault()}},b=y=>{if(!u||m.current!==y.pointerId)return;const I=r==="left"?y.clientX-d.current:d.current-y.clientX,j=Qr(y.currentTarget)?-I:I,R=Ho(f.current+j);p.current!==R&&(p.current=R,x(R))},w=y=>{if(m.current!==y.pointerId)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const I=Ho(p.current??i);m.current=null,p.current=null,c(!1),a(I)},S=t?i:0;return s.jsxs("div",{ref:h,className:$e("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${u?p.current??S:S}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${u?p.current??i:i}px`,overflowX:"clip",transitionProperty:u?"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:$e("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!n&&s.jsx("div",{className:$e("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",u&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:b,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:$e("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u&&"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(GS,{visible:t&&e})})]})},cn=t=>{const e=Be.c(12),{zone:n,isOpen:r,interactive:o,hidden:i,className:a,children:u}=t,c=!r||i;let d;e[0]!==u||e[1]!==c?(d=s.jsx(Gc,{paused:c,children:u}),e[0]=u,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==o||e[4]!==d?(f=s.jsx(Wc.Provider,{value:!0,children:s.jsx(Xf.Provider,{value:o,children:d})}),e[3]=o,e[4]=d,e[5]=f):f=e[5];let p;e[6]!==a||e[7]!==f?(p=s.jsx("div",{className:a,children:f}),e[6]=a,e[7]=f,e[8]=p):p=e[8];let m;return e[9]!==p||e[10]!==n?(m=s.jsx(TS,{zone:n,children:p}),e[9]=p,e[10]=n,e[11]=m):m=e[11],m},t2=()=>{const{t}=at(),e=Gs()??"",n=l.useMemo(()=>e?us(e):"",[e]),r=X(B=>n?B.contextPanelByDirectory[n]:void 0),o=xr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,u=lo(o,e)??"",c=X(B=>B.contextSurfaceZones),d=X(B=>B.contextPanelByDirectory),f=X(B=>B.closeContextPanelTab),p=X(B=>B.closeContextFile),m=X(B=>B.openContextPanelTab),h=X(B=>B.openAgentBrowserTab),x=X(B=>B.openContextFile),g=X(B=>B.contextEditorTreeVisible),b=X(B=>B.contextEditorVisible),w=X(B=>B.fileTreeSide),S=xs(B=>B.setSelectedPath),y=ur(B=>B.headerSlot),I=l.useMemo(()=>r?.tabs??[],[r?.tabs]),j=Rr(B=>B.chatCovered),R=l.useMemo(()=>{const B=ce=>{const G=r?Fr(r,c,ce):null,Ce=ce==="bottom"&&j;return{activeTab:G,isOpen:!!(r&&lr(r,ce).isOpen&&G)&&!Ce}};return{left:B("left"),right:B("right"),bottom:B("bottom")}},[j,r,c]),_={left:Lo(R.left.isOpen),right:Lo(R.right.isOpen),bottom:Lo(R.bottom.isOpen)},P=B=>!_[B],k={left:rr(R.left.isOpen),right:rr(R.right.isOpen),bottom:rr(R.bottom.isOpen)},N={left:Er(R.left.isOpen,k.left,R.left.activeTab?.mode),right:Er(R.right.isOpen,k.right,R.right.activeTab?.mode),bottom:Er(R.bottom.isOpen,k.bottom,R.bottom.activeTab?.mode)},T=B=>{const ce=Go(c,B);return{zone:ce,...R[ce]}},A=T("file"),$=T("chat"),K=T("browser"),q=T("diff"),M=T("terminal"),z=T("walkthrough"),[ne,H]=l.useState([]),V=l.useCallback((B,ce)=>{H(G=>Vu(G,Nn(B,ce)))},[]),F=X(B=>B.liveBrowserTabLimit);l.useEffect(()=>Zv((B,ce)=>{const G=ce.directory?us(ce.directory):n;if(!G)return null;const Ce=h(G,B,ce.sessionId);return Ce&&V(G,Ce),Ce}),[n,h,V]),l.useEffect(()=>Xv((B,ce)=>X.getState().contextPanelByDirectory[B]?.tabs?.some(Ce=>Ce.id===ce&&Ce.mode==="browser")?(f(B,ce),!0):!1),[f]),l.useEffect(()=>Js(B=>{if(B.type!=="file-open-request")return;const ce=B.directory??e;ce&&x(ce,B.path)}),[e,x]),l.useEffect(()=>Js(B=>{if(B.type!=="plan-open-request")return;const ce=B.directory??e,G=Gf(ce,B.projectId);!ce||!G||X.getState().openProjectKnowledgePlan(ce,Qh(G),B.planId)}),[e]);const C=K.activeTab?.mode==="browser"?K.activeTab.id:null;l.useEffect(()=>{Kv(n,C)},[n,C]);const te=A.activeTab;l.useEffect(()=>{if(!u||te?.mode!=="file"||!te.targetPath)return;const B=js(te.targetPath)===js(u);S(us(u),te.targetPath,{allowOutsideRoot:!o&&B})},[u,o,te,S]);const re=l.useMemo(()=>I.some(B=>B.mode==="file"&&B.targetPath),[I]),Q=l.useMemo(()=>I.some(B=>B.mode==="file"),[I]),ee=re&&(b||!g),le=A.activeTab?.mode==="file",O=l.useCallback(B=>{n&&p(n,B)},[p,n]),Y=$.isOpen&&$.activeTab?.mode==="chat"?$.activeTab:null,Z=Y?ho(Y.dedupeKey):null,we=l.useMemo(()=>(Y?.targetDirectory?us(Y.targetDirectory):"")||n||null,[Y?.targetDirectory,n]),L=l.useMemo(()=>Z?{sessionId:Z,directory:we}:null,[Z,we]);l.useEffect(()=>{if(!we||!Z||typeof window>"u")return;const B=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Po(we,Z,!1);return}Kc(Z),Po(we,Z,!0)};B();const ce=window.setInterval(B,1e4);return window.addEventListener("focus",B),window.addEventListener("blur",B),document.addEventListener("visibilitychange",B),()=>{window.clearInterval(ce),window.removeEventListener("focus",B),window.removeEventListener("blur",B),document.removeEventListener("visibilitychange",B),Po(we,Z,!1)}},[we,Z]);const pe=q.activeTab,je=l.useCallback(B=>{!n||pe?.mode!=="diff"||m(n,{mode:"diff",targetPath:pe.targetPath,targetDirectory:pe.targetDirectory,stagedDiff:B==="staged",diffScope:B})},[pe,n,m]),Ee=K.isOpen&&K.activeTab?.mode==="browser"?K.activeTab.id:null;l.useEffect(()=>{Ee&&n&&V(n,Ee)},[n,Ee,V]);const{loadedBrowserTabs:Se,sleepingBrowserTabs:Le}=l.useMemo(()=>{const B=new Set(ne),ce=new Set;for(const[Ne,Ae]of Object.entries(d))for(const Ie of Ae.tabs)Ie.mode==="browser"&&Ie.ownerSessionId===null&&ce.add(Nn(Ne,Ie.id));const G=Hu(ne,ce,F),Ce=[],J=[];for(const[Ne,Ae]of Object.entries(d)){const Ie=Ne===n;for(const De of Ae.tabs){if(De.mode!=="browser")continue;const We=Nn(Ne,De.id),Ke=De.ownerSessionId===null,Ze=Ie&&De.id===Ee||(Ke?G.has(We):B.has(We));if(!Ze&&!Ie&&Ke)continue;const Qe={directory:Ne,id:De.id,targetPath:De.targetPath,ownerSessionId:De.ownerSessionId};(Ze?Ce:J).push(Qe)}}return Ce.sort((Ne,Ae)=>Nn(Ne.directory,Ne.id)<Nn(Ae.directory,Ae.id)?-1:1),{loadedBrowserTabs:Ce,sleepingBrowserTabs:J}},[d,n,F,ne,Ee]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const B=Le.map(ce=>Gv({tabId:ce.id,directory:ce.directory,ownerSessionId:ce.ownerSessionId,describe:()=>({title:"",url:ce.targetPath??""}),wake:()=>V(ce.directory,ce.id)}));return()=>B.forEach(ce=>ce())},[Le,V]);const Pe=l.useMemo(()=>I.filter(B=>B.mode==="diff"),[I]),Ve=l.useMemo(()=>I.find(B=>B.mode==="terminal")??null,[I]),Oe=l.useMemo(()=>I.find(B=>B.mode==="walkthrough")??null,[I]),be=l.useMemo(()=>I.filter(B=>Mn(B.mode)),[I]),ye=Ni(B=>B.guests),Ue=l.useMemo(()=>new Set(ye.filter(eg).map(B=>B.id)),[ye]),Te=l.useMemo(()=>{const B=new Map;for(const ce of ye){const G=tg(ce);G&&B.set(ce.id,G)}return B},[ye]),Me=M.zone,Re=l.useCallback(B=>{const ce=Gi({mode:"terminal",label:t("layout.mainTab.terminal"),from:Me},B);return{finish:()=>ce.finish(n),cancel:ce.cancel}},[n,t,Me]),ze=(B,ce)=>ce?y[B]:null;return s.jsxs(s.Fragment,{children:[Q?s.jsxs(cn,{zone:A.zone,interactive:N[A.zone],isOpen:A.isOpen,hidden:P(A.zone),className:$e("absolute inset-0 flex",w==="left"&&"flex-row-reverse",le?"flex":"hidden"),children:[i?s.jsx("div",{className:"h-full min-w-0 flex-1",children:s.jsx(Pr,{})}):re||!g?s.jsx("div",{className:$e("h-full min-w-0 flex-1",re&&!ee&&"hidden"),children:re?s.jsx(l.Suspense,{fallback:null,children:s.jsx(JS,{mode:"editor-only",visible:!P(A.zone)&&le&&ee,onCloseFile:O})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(se,{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,i?null:s.jsx(e2,{visible:g,active:A.isOpen&&le,fill:!ee,side:w})]}):null,Y&&Z&&L?s.jsx(cn,{zone:$.zone,interactive:N[$.zone],isOpen:$.isOpen,hidden:P($.zone),className:"absolute inset-0 bg-background",children:s.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:Z}),className:"h-full",children:s.jsx(xc,{pinnedSession:L,readOnly:Y.readOnly})})},Y.id):null,Se.map(B=>{const ce=B.directory===n&&K.activeTab?.id===B.id,G=B.directory===n?a??B.directory:B.directory;return s.jsx(cn,{zone:K.zone,interactive:N[K.zone],isOpen:K.isOpen,hidden:P(K.zone),className:$e("absolute inset-0",!ce&&"invisible pointer-events-none"),children:s.jsx("div",{className:"h-full","aria-hidden":!ce||void 0,children:s.jsx(Gc,{paused:!ce,children:B.directory===n&&i?s.jsx(Pr,{}):s.jsx(vS,{initialUrl:B.targetPath??"",directory:B.directory,siteDirectory:G,tabID:B.id,ownerSessionId:B.ownerSessionId,visible:ce&&K.isOpen},G)})})},Nn(B.directory,B.id))}),Pe.map(B=>{const ce=q.activeTab?.id===B.id;return s.jsx(cn,{zone:q.zone,interactive:N[q.zone],isOpen:q.isOpen,hidden:P(q.zone),className:$e("absolute inset-0",!ce&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(fn,{value:ze(q.zone,ce),children:i&&!B.targetDirectory?s.jsx(Pr,{}):s.jsx(YS,{directory:B.targetDirectory??a,visible:q.isOpen&&ce,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:B.diffScope??(B.stagedDiff?"staged":null),onDiffScopeChange:je,targetFilePath:B.targetPath,flushContent:!0})})})},B.id)}),Ve?s.jsx(cn,{zone:M.zone,interactive:N[M.zone],isOpen:M.isOpen,hidden:P(M.zone),className:$e("absolute inset-0",M.activeTab?.mode==="terminal"?"block":"hidden"),children:s.jsx(fn,{value:ze(M.zone,M.activeTab?.mode==="terminal"),children:s.jsx(Kf.Provider,{value:Re,children:s.jsx(Zf,{visible:M.isOpen&&M.activeTab?.mode==="terminal",directory:Ve.targetDirectory,onLastTabClosed:()=>{n&&f(n,Ve.id)}})})})}):null,Oe?s.jsx(cn,{zone:z.zone,interactive:N[z.zone],isOpen:z.isOpen,hidden:P(z.zone),className:$e("absolute inset-0",z.activeTab?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(fn,{value:ze(z.zone,z.activeTab?.mode==="walkthrough"),children:s.jsx(XS,{directory:Oe.targetDirectory??e,visible:z.isOpen&&z.activeTab?.mode==="walkthrough"})})})}):null,be.map(B=>{if(!Mn(B.mode))return null;const ce=T(B.mode),G=Lr(B.mode),Ce=Ue.has(G),J=Te.get(G),Ne=ce.activeTab?.id===B.id,Ae=Ne&&ce.isOpen;return Ce&&!J&&!Ae?null:s.jsx(cn,{zone:ce.zone,interactive:N[ce.zone],isOpen:ce.isOpen,hidden:P(ce.zone),className:$e("absolute inset-0",Ne?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:Ce?J?s.jsxs("div",{className:$e("flex h-full",au[J.dock].container),children:[s.jsx(QS,{mode:B.mode,docking:J}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ae?s.jsx(Tl,{mode:B.mode}):null})]}):s.jsx(Tl,{mode:B.mode}):s.jsx(iu,{mode:B.mode})})},B.id)})]})},s2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},n2=()=>{const t=Be.c(20),{t:e}=at(),n=qs(r2),r=qs(o2),o=l.useRef(null),[i,a]=l.useState(!1);let u,c;t[0]!==n?(u=()=>{if(!n){a(!1);return}const w=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(w)},c=[n],t[0]=n,t[1]=u,t[2]=c):(u=t[1],c=t[2]),l.useEffect(u,c);let d,f;if(t[3]!==n?(d=()=>{if(!n)return;const w=S=>{const y=o.current;y&&(y.style.transform=`translate(${S.clientX+12}px, ${S.clientY+12}px)`)};return window.addEventListener("pointermove",w),()=>window.removeEventListener("pointermove",w)},f=[n],t[3]=n,t[4]=d,t[5]=f):(d=t[4],f=t[5]),l.useEffect(d,f),!n)return null;const p=i?"opacity-100":"opacity-0";let m;t[6]!==p?(m=$e("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,t[7]=m):m=t[7];let h;t[8]!==m?(h=s.jsx("div",{className:m}),t[8]=m,t[9]=h):h=t[9];let x;t[10]!==n.frames||t[11]!==r||t[12]!==e?(x=Si.map(w=>{const S=n.frames[w];if(S.width<=0||S.height<=0)return null;const y=r===w;return s.jsx("div",{className:$e("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",y?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:S.left,top:S.top,width:S.width,height:S.height},children:s.jsx("span",{className:"typography-ui-label",children:e(s2[w])})},w)}),t[10]=n.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==n.label?(g=s.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:n.label}),t[14]=n.label,t[15]=g):g=t[15];let b;return t[16]!==h||t[17]!==x||t[18]!==g?(b=Ul.createPortal(s.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,x,g]}),document.body),t[16]=h,t[17]=x,t[18]=g,t[19]=b):b=t[19],b};function r2(t){return t.drag}function o2(t){return t.hovered}const Nl=320,i2=({rowWidth:t,leftWidth:e,rightWidth:n,sidebarWidth:r,opening:o})=>{let i=t-e-n;if(i>=Nl)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Nl)return{collapseSidebar:a,displace:null};const u=o==="left"?"right":"left";return{collapseSidebar:a,displace:(u==="left"?e:n)>0?u:null}},a2=({directoryKey:t,folded:e,readRowWidth:n})=>{const r=b=>{const w=b.contextPanelByDirectory[t];return{left:tr(w,b.contextSurfaceZones,"left"),right:tr(w,b.contextSurfaceZones,"right")}},o=(b,w,S)=>{const y=b.contextPanelByDirectory[t];return(S&&y?Fr(y,b.contextSurfaceZones,w):null)?b.contextZoneSizes[w]??vi:0},i=b=>{const w=b.contextPanelByDirectory[t];return w?Si.some(S=>lr(w,S).expanded&&qu(w,b,S)):!1};let a=null,u=!1,c=r(X.getState()),d=i(X.getState());const f=b=>{e.current=b,X.getState().setSidebarFoldedForExpandedZone(b==="expanded")},p=b=>{u=!0,X.getState().setSidebarOpen(b),u=!1},m=()=>{f(null),X.getState().isSidebarOpen||p(!0)};!e.current&&X.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?d:c[h])&&m(),!e.current&&d&&X.getState().isSidebarOpen&&(f("expanded"),p(!1));const x=(b,w,S)=>{const y=n();if(!y)return;const I=e.current==="expanded",j=i2({rowWidth:I?y-b.sidebarWidth:y,leftWidth:o(b,"left",S.left),rightWidth:o(b,"right",S.right),sidebarWidth:b.isSidebarOpen||I?b.sidebarWidth:null,opening:w});if(j.displace){const R=lr(b.contextPanelByDirectory[t],j.displace).activeTabId;R&&(a={side:j.displace,by:w,tabId:R})}j.collapseSidebar&&(f(w),b.isSidebarOpen&&p(!1)),j.displace&&b.closeContextZone(t,j.displace)},g=b=>{if(a?.side===b){e.current===b&&f(a.by);return}const w=a?.by===b?a:null;w&&(a=null),e.current===b&&(w?f(w.side):m()),w&&X.getState().setActiveContextPanelTab(t,w.tabId)};return X.subscribe((b,w)=>{b.isSidebarOpen!==w.isSidebarOpen&&!u&&f(null);const S=r(b),y=i(b),I=c,j=d;c=S,d=y;const R=["left","right"],_=R.filter(k=>S[k]&&!I[k]),P=R.filter(k=>!S[k]&&I[k]);for(const k of P){const N=k==="left"?"right":"left";_.includes(N)&&(e.current===k&&f(N),a?.by===k&&(a=null))}for(const k of P)g(k);for(const k of _)x(b,k,S);y&&!j&&b.isSidebarOpen?(f("expanded"),p(!1)):!y&&j&&e.current==="expanded"&&m()})},l2=()=>{const t=Be.c(5),e=Gs();let n;t[0]!==e?(n=e?us(e):"",t[0]=e,t[1]=n):n=t[1];const r=n,o=l.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return a2({directoryKey:r,folded:o,readRowWidth:c2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),l.useEffect(i,a),null};function c2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const d2=t=>{const e=Be.c(54),{open:n,onOpenChange:r}=t,{t:o}=at(),i=X(u2),a=X(f2),u=X(p2),c=X(m2),d=X(h2),f=Bi(),p=X(ng);let m;if(e[0]!==i||e[1]!==f||e[2]!==p){let H;e[4]!==p?(H=V=>p||V.id!=="workflows",e[4]=p,e[5]=H):H=e[5],m=Zo(i,f).filter(H),e[0]=i,e[1]=f,e[2]=p,e[3]=m}else m=e[3];const h=m,x=u.length===0;let g;if(e[6]!==u||e[7]!==h){let H;e[9]!==u?(H=V=>u.includes(V.id),e[9]=u,e[10]=H):H=e[10],g=h.every(H),e[6]=u,e[7]=h,e[8]=g}else g=e[8];const b=g,w=l.useRef(!1);let S;e[11]!==u||e[12]!==h||e[13]!==o?(S=h.map((H,V)=>({id:H.id,label:H.label??o(H.labelKey),visible:!u.includes(H.id),groupStart:V>0&&Zs(h[V-1])!==Zs(H)})),e[11]=u,e[12]=h,e[13]=o,e[14]=S):S=e[14];const y=S;let I;e[15]!==i||e[16]!==f||e[17]!==a?(I=H=>{const V=Zo(H,f).map(g2).filter(C=>H.includes(C)),F=new Set(V);a([...V,...i.filter(C=>!F.has(C))])},e[15]=i,e[16]=f,e[17]=a,e[18]=I):I=e[18];const j=I;let R;e[19]!==r?(R=(H,V)=>{if(!H&&V.reason==="escape-key"&&w.current){V.cancel(),V.allowPropagation();return}w.current=!1,r(H)},e[19]=r,e[20]=R):R=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=H=>{w.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(H.key)&&H.preventBaseUIHandler()},e[21]=_):_=e[21];let P;e[22]!==o?(P=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=P):P=e[23];let k;e[24]!==P?(k=s.jsx(Fn,{children:P}),e[24]=P,e[25]=k):k=e[25];let N;e[26]!==o?(N=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=N):N=e[27];let T;e[28]!==N?(T=s.jsx(Ln,{children:N}),e[28]=N,e[29]=T):T=e[29];let A;e[30]!==T||e[31]!==k?(A=s.jsxs($n,{children:[k,T]}),e[30]=T,e[31]=k,e[32]=A):A=e[32];let $;e[33]!==o?($=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=$):$=e[34];let K;e[35]===Symbol.for("react.memo_cache_sentinel")?(K=H=>{w.current=H},e[35]=K):K=e[35];let q;e[36]!==j||e[37]!==y||e[38]!==c||e[39]!==$?(q=s.jsx(Yf,{items:y,onVisibleChange:c,onReorder:j,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:$,onDraggingChange:K}),e[36]=j,e[37]=y,e[38]=c,e[39]=$,e[40]=q):q=e[40];let M;e[41]!==x||e[42]!==b||e[43]!==d||e[44]!==o?(M=x?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:o("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ft,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=b,e[43]=d,e[44]=o,e[45]=M):M=e[45];let z;e[46]!==A||e[47]!==q||e[48]!==M?(z=s.jsxs(Bn,{className:"max-w-md",onKeyDown:_,children:[A,q,M]}),e[46]=A,e[47]=q,e[48]=M,e[49]=z):z=e[49];let ne;return e[50]!==n||e[51]!==z||e[52]!==R?(ne=s.jsx(zn,{open:n,onOpenChange:R,children:z}),e[50]=n,e[51]=z,e[52]=R,e[53]=ne):ne=e[53],ne};function u2(t){return t.contextRailOrder}function f2(t){return t.setContextRailOrder}function p2(t){return t.contextRailHiddenSurfaces}function m2(t){return t.setContextRailSurfaceVisible}function h2(t){return t.setContextRailHiddenSurfaces}function g2(t){return t.id}const lu=150,x2=500,b2=[],w2=t=>{const e=Be.c(70),{surface:n,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:u,badgeAriaLabel:c,badgeDescription:d,orderNumber:f,showOrderNumber:p,onSelect:m}=t,h=X(S2);let x;e[0]!==h?(x=Ci("switch_context_surface",h),e[0]=h,e[1]=x):x=e[1];const g=x;let b;e[2]!==f||e[3]!==g?(b=g&&g!==wc&&f!=null&&f<=10?ws(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=b):b=e[4];const w=b;let S;e[5]!==n.id?(S={id:n.id},e[5]=n.id,e[6]=S):S=e[6];const{attributes:y,listeners:I,setNodeRef:j,transform:R,transition:_,isDragging:P}=ld(S),k=u!=null&&u>0;let N;e[7]!==R?(N=dd.Translate.toString(R),e[7]=R,e[8]=N):N=e[8];let T;e[9]!==N||e[10]!==_?(T={transform:N,transition:_},e[9]=N,e[10]=_,e[11]=T):T=e[11];const A=P&&"z-10 opacity-70";let $;e[12]!==A?($=$e("relative",A),e[12]=A,e[13]=$):$=e[13];let K;e[14]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx("div",{}),e[14]=K):K=e[14];let q;e[15]!==m||e[16]!==n?(q=()=>m(n),e[15]=m,e[16]=n,e[17]=q):q=e[17];const M=c??i,z=n.id,ne=r?"text-primary":"text-muted-foreground hover:text-foreground";let H;e[18]!==ne?(H=$e("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",ne),e[18]=ne,e[19]=H):H=e[19];let V;e[20]!==n.icon||e[21]!==n.iconSrc||e[22]!==n.id?(V=n.id==="diff"?s.jsx(hc,{className:"h-[17px] w-[17px]"}):s.jsx(Ti,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=n.icon,e[21]=n.iconSrc,e[22]=n.id,e[23]=V):V=e[23];let F;e[24]!==k||e[25]!==f||e[26]!==o||e[27]!==p?(F=p&&f!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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:f===10?"0":f}):k?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):o?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[24]=k,e[25]=f,e[26]=o,e[27]=p,e[28]=F):F=e[28];let C;e[29]!==y||e[30]!==r||e[31]!==I||e[32]!==n.id||e[33]!==M||e[34]!==H||e[35]!==V||e[36]!==F||e[37]!==q?(C=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",...y,...I,onClick:q,"aria-label":M,"aria-pressed":r,"data-context-surface":z,className:H,children:[V,F]})}),e[29]=y,e[30]=r,e[31]=I,e[32]=n.id,e[33]=M,e[34]=H,e[35]=V,e[36]=F,e[37]=q,e[38]=C):C=e[38];let te;e[39]!==h||e[40]!==n.id||e[41]!==w?(te=n.id==="terminal"?ws(Es("toggle_terminal",h),""):w,e[39]=h,e[40]=n.id,e[41]=w,e[42]=te):te=e[42];let re;e[43]!==i||e[44]!==te?(re=s.jsx(Hs,{label:i,shortcut:te}),e[43]=i,e[44]=te,e[45]=re):re=e[45];let Q;e[46]!==a?(Q=s.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[46]=a,e[47]=Q):Q=e[47];let ee;e[48]!==d?(ee=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[48]=d,e[49]=ee):ee=e[49];let le;e[50]!==n.id?(le=n.id==="context"?s.jsx(md,{}):null,e[50]=n.id,e[51]=le):le=e[51];let O;e[52]!==re||e[53]!==Q||e[54]!==ee||e[55]!==le?(O=s.jsx($t,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[re,Q,ee,le]})}),e[52]=re,e[53]=Q,e[54]=ee,e[55]=le,e[56]=O):O=e[56];let Y;e[57]!==C||e[58]!==O?(Y=s.jsx(oo,{render:K,children:s.jsxs(Lt,{delayDuration:lu,children:[C,O]})}),e[57]=C,e[58]=O,e[59]=Y):Y=e[59];let Z;e[60]!==n.mode?(Z=s.jsx(io,{children:s.jsx(mc,{mode:n.mode})}),e[60]=n.mode,e[61]=Z):Z=e[61];let we;e[62]!==Y||e[63]!==Z?(we=s.jsxs(gr,{children:[Y,Z]}),e[62]=Y,e[63]=Z,e[64]=we):we=e[64];let L;return e[65]!==j||e[66]!==we||e[67]!==T||e[68]!==$?(L=s.jsx("div",{ref:j,style:T,className:$,children:we}),e[65]=j,e[66]=we,e[67]=T,e[68]=$,e[69]=L):L=e[69],L},y2=t=>{if(!t)return{icon:"ticket-2"};const e=lg(t,"line");return e?{icon:e}:{icon:cg,iconSrc:dg(t)}},v2=()=>{const t=Be.c(122),{t:e}=at(),n=Gs();let r;t[0]!==n?(r=n?us(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Fe=>o?Fe.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=X(i),u=X(k2),c=X(j2),d=X(C2),f=X(T2),p=X(N2),m=X(E2),h=X(P2),x=X(I2),g=Gu();let b;t[4]!==g?(b=Fe=>g.some(fe=>fe.instances.defaultInstance!==null&&Fe.entries[Jn({provider:fe.id,instance:fe.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=b):b=t[5];const w=hn(b),S=hn(D2),y=rg(o||null),I=yi(y==="none"?null:y??g[0]?.id),j=y==="none"?"pullRequest":I.terminology.changeRequest,{screenWidth:R}=yn(),_=xr(),P=n??null;let k;t[6]!==_||t[7]!==P?(k=lo(_,P),t[6]=_,t[7]=P,t[8]=k):k=t[8];const N=k,T=og(N),A=co(T),{git:$}=Is(),K=Vn(_2),q=Vn(A2);let M,z;t[9]!==K||t[10]!==q||t[11]!==$||t[12]!==T||t[13]!==N?(M=()=>{if(!$||!N||!T||T===N)return;sa(()=>K(T,$));const Fe=Yt(N),fe=Yt(T);return Ur.onGitRefreshHint(ke=>{const rt=Yt(ke.directory);rt!==Fe&&rt!==fe||sa(()=>q(T,$,{silent:!0}))})},z=[K,q,$,T,N],t[9]=K,t[10]=q,t[11]=$,t[12]=T,t[13]=N,t[14]=M,t[15]=z):(M=t[14],z=t[15]),l.useEffect(M,z);let ne;t[16]!==x?(ne=Ci("switch_context_surface",x),t[16]=x,t[17]=ne):ne=t[17];const H=ne,[V,F]=l.useState(!1);let C,te;t[18]!==H?(te=()=>{const Fe=new Set;let fe=null,ke=!1;const rt=O2,ge=()=>{Ra(H,Fe)?!ke&&fe===null&&(fe=setTimeout(()=>F(!0),x2)):(ke=!1,fe!==null&&(clearTimeout(fe),fe=null),F(!1))},lt=kt=>{if(Fe.add(kt.key.toLowerCase()),rt(kt.key)&&Ra(H,Fe)){ke=!0,fe!==null&&(clearTimeout(fe),fe=null),F(!1);return}ge()},Ct=kt=>{Fe.delete(kt.key.toLowerCase()),ge()},bt=()=>{Fe.clear(),ke=!1,fe!==null&&(clearTimeout(fe),fe=null),F(!1)};return window.addEventListener("keydown",lt,!0),window.addEventListener("keyup",Ct,!0),window.addEventListener("blur",bt),()=>{window.removeEventListener("keydown",lt,!0),window.removeEventListener("keyup",Ct,!0),window.removeEventListener("blur",bt),fe!==null&&clearTimeout(fe)}},C=[H],t[18]=H,t[19]=C,t[20]=te):(C=t[19],te=t[20]),l.useEffect(te,C);let re;t[21]===Symbol.for("react.memo_cache_sentinel")?(re={activationConstraint:{distance:8}},t[21]=re):re=t[21];let Q;t[22]===Symbol.for("react.memo_cache_sentinel")?(Q={activationConstraint:{delay:200,tolerance:6}},t[22]=Q):Q=t[22];const ee=rd(Vr(id,re),Vr(od,Q)),le=Bi(),O=Ia(M2),Y=Ia(F2),Z=a?.tabs??b2,we=ig(Z,n||null);let L;t[23]!==h||t[24]!==a?(L=bi(a,h),t[23]=h,t[24]=a,t[25]=L):L=t[25];const pe=L,je=A?.files.length??0;let Ee;if(t[26]!==d||t[27]!==c||t[28]!==le||t[29]!==y||t[30]!==R||t[31]!==S||t[32]!==Z||t[33]!==I||t[34]!==we){let Fe;t[36]!==y||t[37]!==I?(Fe=fe=>fe.id==="pr"?{...fe,...y2(y==="none"?null:I)}:fe,t[36]=y,t[37]=I,t[38]=Fe):Fe=t[38],Ee=ag({railOrder:c,hiddenSurfaces:d,isVSCode:wi(),screenWidth:R,tabs:Z,sourceControlConnected:S,workflowsShown:we,extras:le}).map(Fe),t[26]=d,t[27]=c,t[28]=le,t[29]=y,t[30]=R,t[31]=S,t[32]=Z,t[33]=I,t[34]=we,t[35]=Ee}else Ee=t[35];const Se=Ee;let Le;t[39]!==Z?(Le=Z.some(L2),t[39]=Z,t[40]=Le):Le=t[40];const Pe=Le;let Ve,Oe;t[41]!==m||t[42]!==h||t[43]!==w||t[44]!==o||t[45]!==Pe||t[46]!==pe||t[47]!==S?(Ve=()=>{!o||!w||S||Pe||!pe.has("pr")||m(o,Go(h,"pr"))},Oe=[m,h,o,w,Pe,pe,S],t[41]=m,t[42]=h,t[43]=w,t[44]=o,t[45]=Pe,t[46]=pe,t[47]=S,t[48]=Ve,t[49]=Oe):(Ve=t[48],Oe=t[49]),l.useEffect(Ve,Oe);const[be,ye]=l.useState(!1),Ue=l.useRef(null),Te=l.useRef(null);let Me;t[50]!==j||t[51]!==Se||t[52]!==e?(Me=Fe=>{const fe=Se.find(rt=>rt.id===Fe.active.id),ke=Ue.current?.getBoundingClientRect().left;!fe||ke===void 0||(Te.current?.cancel(),Te.current=Gi({mode:fe.mode,label:fe.label??e(Ws(fe.labelKey,j)),from:Go(X.getState().contextSurfaceZones,fe.mode)},rt=>rt.x<ke-16))},t[50]=j,t[51]=Se,t[52]=e,t[53]=Me):Me=t[53];const Re=Me;let ze;t[54]===Symbol.for("react.memo_cache_sentinel")?(ze=()=>{Te.current?.cancel(),Te.current=null},t[54]=ze):ze=t[54];const B=ze;let ce,G;t[55]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>()=>Te.current?.cancel(),G=[],t[55]=ce,t[56]=G):(ce=t[55],G=t[56]),l.useEffect(ce,G);let Ce;t[57]!==o||t[58]!==le||t[59]!==f?(Ce=Fe=>{const fe=Te.current;if(Te.current=null,fe?.finish(o))return;const{active:ke,over:rt}=Fe;if(!rt||ke.id===rt.id)return;const ge=Zo(X.getState().contextRailOrder,le),lt=ht=>{const St=ge.find(yt=>yt.id===ht);return St?Zs(St):null};if(lt(ke.id)!==lt(rt.id))return;const Ct=ge.map($2),bt=Ct.indexOf(ke.id),kt=Ct.indexOf(rt.id);bt===-1||kt===-1||f(j1(Ct,bt,kt))},t[57]=o,t[58]=le,t[59]=f,t[60]=Ce):Ce=t[60];const J=Ce;let Ne;if(t[61]!==Se){Ne=[];for(const Fe of Se){const fe=Ne.at(-1);fe&&Zs(fe[0])===Zs(Fe)?fe.push(Fe):Ne.push([Fe])}t[61]=Se,t[62]=Ne}else Ne=t[62];const Ae=Ne;let Ie;t[63]!==Se?(Ie=Fe=>{const fe=Se.find(rt=>rt.id===Fe.active.id);if(!fe)return Jo(Fe);const ke=Zs(fe);return Jo({...Fe,droppableContainers:Fe.droppableContainers.filter(rt=>{const ge=Se.find(lt=>lt.id===rt.id);return ge!==void 0&&Zs(ge)===ke})})},t[63]=Se,t[64]=Ie):Ie=t[64];const De=Ie;if(!o)return null;let We,Ke,Ze,Qe,qe,et,He,Ye,dt,nt;if(t[65]!==j||t[66]!==je||t[67]!==Y||t[68]!==De||t[69]!==o||t[70]!==Ae||t[71]!==O||t[72]!==J||t[73]!==Re||t[74]!==p||t[75]!==V||t[76]!==ee||t[77]!==pe||t[78]!==e||t[79]!==u){let Fe=0;Ye=Ue,t[90]!==e?(dt=e("contextRail.aria.rail"),t[90]=e,t[91]=dt):dt=t[91],nt="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",We=ad,Ke=ee,Ze=De,Qe=Re,qe=B,et=J,He=Ae.map((fe,ke)=>s.jsxs(l.Fragment,{children:[ke>0?s.jsx("div",{"aria-hidden":"true",className:"h-px w-4 shrink-0 bg-edge-strong"}):null,s.jsx(cd,{items:fe.map(B2),strategy:k1,children:fe.map(rt=>{Fe=Fe+1;const ge=rt.label??e(Ws(rt.labelKey,j)),lt=rt.id==="git"&&!u?je:0,Ct=Mn(rt.mode)&&!pe.has(rt.mode)?O[Lr(rt.mode)]??0:0,bt=lt>0?lt:Ct>0?Ct:null,kt=bt!==null&&lt===0;return s.jsx(w2,{surface:rt,isActive:pe.has(rt.mode),showActivityDot:!1,label:ge,description:e(Ws(rt.descriptionKey,j)),badgeCount:bt,badgeAriaLabel:bt!==null?e(kt?bt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":bt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ge,count:bt}):null,badgeDescription:bt!==null?e(kt?bt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":bt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:bt}):null,orderNumber:Fe,showOrderNumber:V,onSelect:ht=>{Mn(ht.mode)&&Y(Lr(ht.mode)),p(o,ht.mode)}},rt.id)})})]},Zs(fe[0]))),t[65]=j,t[66]=je,t[67]=Y,t[68]=De,t[69]=o,t[70]=Ae,t[71]=O,t[72]=J,t[73]=Re,t[74]=p,t[75]=V,t[76]=ee,t[77]=pe,t[78]=e,t[79]=u,t[80]=We,t[81]=Ke,t[82]=Ze,t[83]=Qe,t[84]=qe,t[85]=et,t[86]=He,t[87]=Ye,t[88]=dt,t[89]=nt}else We=t[80],Ke=t[81],Ze=t[82],Qe=t[83],qe=t[84],et=t[85],He=t[86],Ye=t[87],dt=t[88],nt=t[89];let ut;t[92]!==We||t[93]!==Ke||t[94]!==Ze||t[95]!==Qe||t[96]!==qe||t[97]!==et||t[98]!==He?(ut=s.jsx(We,{sensors:Ke,collisionDetection:Ze,onDragStart:Qe,onDragCancel:qe,onDragEnd:et,children:He}),t[92]=We,t[93]=Ke,t[94]=Ze,t[95]=Qe,t[96]=qe,t[97]=et,t[98]=He,t[99]=ut):ut=t[99];let oe;t[100]!==e?(oe=e("contextRail.configure.open"),t[100]=e,t[101]=oe):oe=t[101];let de;t[102]===Symbol.for("react.memo_cache_sentinel")?(de=()=>ye(!0),t[102]=de):de=t[102];let ve;t[103]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx(se,{name:"equalizer-2",className:"h-[17px] w-[17px]"}),t[103]=ve):ve=t[103];let v;t[104]!==oe?(v=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":oe,onClick:de,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:ve})}),t[104]=oe,t[105]=v):v=t[105];let ae;t[106]!==e?(ae=e("contextRail.configure.open"),t[106]=e,t[107]=ae):ae=t[107];let W;t[108]!==ae?(W=s.jsx($t,{side:"left",sideOffset:8,children:ae}),t[108]=ae,t[109]=W):W=t[109];let me;t[110]!==v||t[111]!==W?(me=s.jsxs(Lt,{delayDuration:lu,children:[v,W]}),t[110]=v,t[111]=W,t[112]=me):me=t[112];let he;t[113]!==be?(he=s.jsx(d2,{open:be,onOpenChange:ye}),t[113]=be,t[114]=he):he=t[114];let Je;return t[115]!==Ye||t[116]!==dt||t[117]!==nt||t[118]!==ut||t[119]!==me||t[120]!==he?(Je=s.jsxs("nav",{ref:Ye,"aria-label":dt,className:nt,children:[ut,me,he]}),t[115]=Ye,t[116]=dt,t[117]=nt,t[118]=ut,t[119]=me,t[120]=he,t[121]=Je):Je=t[121],Je};function S2(t){return t.shortcutOverrides}function k2(t){return t.workStatusPanelVisible}function j2(t){return t.contextRailOrder}function C2(t){return t.contextRailHiddenSurfaces}function T2(t){return t.setContextRailOrder}function N2(t){return t.openContextSurface}function E2(t){return t.closeContextZone}function P2(t){return t.contextSurfaceZones}function I2(t){return t.shortcutOverrides}function R2(t){return t.status?.status==="connected"}function D2(t){return Object.values(t.entries).some(R2)}function _2(t){return t.ensureStatus}function A2(t){return t.fetchStatus}function O2(t){return t.length===1&&t>="0"&&t<="9"}function M2(t){return t.countByGuest}function F2(t){return t.clearBadge}function L2(t){return t.mode==="pr"&&t.targetPath}function $2(t){return t.id}function B2(t){return t.id}const Ms=t=>t?s.jsx("span",{className:"oc-title-rest",children:t}):void 0,ks=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},z2=()=>{const{t}=at(),{git:e,sourceControl:n}=Is(),[r,o]=l.useState(!1),[i,a]=l.useState(null),[u,c]=l.useState([]),[d,f]=l.useState(!1),[p,m]=l.useState(!1),[h,x]=l.useState(!1),[g,b]=l.useState(!1),[w,S]=l.useState(new Set),y=tt(G=>G.getWorktreeMetadata),I=tt(G=>G.newSessionDraft),j=tt(G=>G.setNewSessionDraftTarget),R=tt(G=>G.setDraftBootstrapPendingDirectory),_=fg,P=xg,k=tt(G=>G.deleteSessions),N=tt(G=>G.archiveSessions),T=tt(G=>G.unarchiveSessions),A=X(G=>G.showDeletionDialog),$=X(G=>G.setShowDeletionDialog),K=is(G=>G.currentDirectory),q=is(G=>G.homeDirectory),M=Gt(G=>G.projects),z=Gt(G=>G.activeProjectId),{isMobile:ne,isTablet:H,hasTouchInput:V}=yn(),F=ne||H||V,C=l.useMemo(()=>{const Ce=(z?M.find(J=>J.id===z)??null:null)?.path??K;return ks(Ce)},[z,K,M]),te=l.useCallback(G=>{const J=ks(G.projectDirectory)||C;return{id:(M.find(Ae=>ks(Ae.path)===J)??null)?.id??`path:${J}`,path:J}},[C,M]),re=g&&w.size>0,[Q,ee]=l.useState(!1),le=i?.mode==="worktree"?i.worktree??u[0]?.metadata??null:null,O=le?.path,Y=le?.branch,Z=le?te(le).path:null;l.useEffect(()=>{if(ee(!1),!O||!Z)return;let G=!1;return ug(Z,{path:O,branch:Y??""}).then(Ce=>{G||ee(Ce)}),()=>{G=!0}},[Y,O,Z]);const we=l.useMemo(()=>{if(!Q)return!1;const G=i?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!!G.status?.upstream?.split("/")[0]?.trim():u.length>0&&u.every(({metadata:Ce})=>typeof Ce.branch=="string"&&Ce.branch.trim().length>0&&!!Ce.status?.upstream?.split("/")[0]?.trim())},[Q,i?.worktree,u]),L=i?.mode==="worktree",pe=h||!L||!we,je=h||!L,Ee=l.useCallback(G=>{a({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),Se=l.useCallback(()=>{a(null),c([]),f(!1),m(!1),x(!1),b(!1),S(new Set)},[]),Le=l.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const Ae=G.sessions[0];await _(Ae.id)?_e.success(t("sessions.sidebar.session.delete.success")):_e.error(t("sessions.sidebar.session.delete.error"));return}const Ce=G.sessions.map(Ae=>Ae.id),{deletedIds:J,failedIds:Ne}=await k(Ce);if(J.length>0){const Ae=Ne.length>0?Ne.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Ne.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Ne.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.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:Ms(Ae)})}Ne.length>0&&_e.error(Ne.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Ne.length}),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[_,k,t]);l.useEffect(()=>Ur.onDirectoryRequest(()=>{o(!0)}),[]),l.useEffect(()=>{if(!i){c([]),f(!1),m(!1),b(!1),S(new Set);return}const G=i.sessions.map(Ne=>{const Ae=y(Ne.id);return Ae?{session:Ne,metadata:Ae}:null}).filter(Ne=>!!Ne);c(G),f(!1),b(!1),S(new Set);const Ce=new Map;if(i.worktree?.path&&Ce.set(ks(i.worktree.path),i.worktree),G.forEach(({metadata:Ne})=>{Ne.path&&Ce.set(ks(Ne.path),Ne)}),Ce.size===0){b(!0);return}let J=!1;return(async()=>{const Ne=new Map,Ae=new Set;await Promise.all(Array.from(Ce.entries()).map(async([Ie,De])=>{try{const We=await Da(De.path);Ne.set(Ie,We),We?.isDirty&&Ae.add(Ie)}catch{De.status&&(Ne.set(Ie,De.status),De.status.isDirty&&Ae.add(Ie))}})).catch(Ie=>{console.warn("Failed to inspect worktree status before deletion:",Ie)}),!J&&(S(Ae),b(!0),a(Ie=>{if(!Ie?.worktree?.path)return Ie;const De=ks(Ie.worktree.path),We=Ne.get(De);if(!We)return Ie;const Ke=Ie.worktree.status;return Ke?.isDirty===We.isDirty&&Ke?.ahead===We.ahead&&Ke?.behind===We.behind&&Ke?.upstream===We.upstream?Ie:{...Ie,worktree:{...Ie.worktree,status:We}}}),c(Ie=>Ie.map(De=>{const We=ks(De.metadata.path),Ke=Ne.get(We);return Ke?{session:De.session,metadata:{...De.metadata,status:Ke}}:De})))})(),()=>{J=!0}},[i,y]),l.useEffect(()=>{we||f(!1)},[we]);const Pe=l.useCallback(async(G,Ce,J)=>{const Ne=d&&we,Ae=te(G),Ie=ks(G.path),De=ks(Ae.path);try{await pg(Ae,G,{deleteRemoteBranch:Ne,deleteLocalBranch:Ce,remoteName:G.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:n}});const We=Ze=>!!(Ie&&Ze&&mg(Ie,Ze)),Ke=ks(I?.directoryOverride);return I?.open&&We(Ke)&&De&&(R(null),j({projectId:Ae.id,directoryOverride:De},{force:!0})),We(ks(K))&&De&&is.getState().setDirectory(De,{showOverlay:!1}),!0}catch(We){return _e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:J,description:Ms(We instanceof Error?We.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[we,K,d,te,e,I?.directoryOverride,I?.open,R,j,n,t]),Ve=l.useCallback((G,Ce,J)=>{const Ne=d&&we,Ae=_e.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:_a(G)}));return hg(G.path),(async()=>{try{const Ie=await gg({sessionIds:Ce,removeWorktree:()=>Pe(G,J,Ae),restoreSessions:We=>T(We,{undo:!0}),archiveSessions:async We=>We.length===1?await P(We[0])?{archivedIds:We,failedIds:[]}:{archivedIds:[],failedIds:We}:N(We)});if(!Ie.removed)return;Cc(Ce,{projectId:te(G).id}),_e.success(t(Ne?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ae,description:Ms(_a(G))});const{failedIds:De}=Ie.archive;De.length>0&&_e.error(De.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:De.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:De.length}),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(Ie){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ae,description:Ms(Ie instanceof Error?Ie.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{bg(G.path)}})()},[P,N,we,d,te,Pe,t,T]),Oe=l.useRef(new Set),be=l.useCallback(async(G,Ce)=>{const J=ks(G.path);if(!Oe.current.has(J)){Oe.current.add(J);try{const Ne=await Da(G.path).catch(()=>{});if(!wg(Ne)){Ee({sessions:Ce,mode:"worktree",worktree:G});return}await Ve(G,Ce.map(Ae=>Ae.id),!0)}finally{Oe.current.delete(J)}}},[Ee,Ve]);l.useEffect(()=>Ur.onDeleteRequest(G=>{if(!A&&(G.mode??"session")==="session"){Le(G);return}if(G.mode==="worktree"&&G.skipDialogIfSafe&&G.worktree){be(G.worktree,G.sessions);return}Ee(G)}),[Ee,A,Le,be]);const ye=l.useCallback(async()=>{if(i){x(!0);try{if(L){const G=i.worktree??u[0]?.metadata;if(!G){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),x(!1);return}Ve(G,i.sessions.map(Ce=>Ce.id),p&&Q),Se();return}if(i.sessions.length===1){const G=i.sessions[0];if(!await _(G.id)){_e.error(t("sessions.sidebar.session.delete.error")),x(!1);return}_e.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const G=i.sessions.map(Ne=>Ne.id),{deletedIds:Ce,failedIds:J}=await k(G);if(Ce.length>0){const Ne=J.length>0?J.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:J.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:J.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;_e.success(Ce.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ce.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ce.length}),{description:Ms(Ne),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(J.length>0&&(_e.error(J.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:J.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:J.length}),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Ce.length===0)){x(!1);return}}Se()}finally{x(!1)}}},[Q,i,u,p,_,k,Se,L,Ve,t]),Ue=i?.worktree??u[0]?.metadata??null;let Te="";if(i?.mode==="worktree"){const G=i.sessions.length;G===0?Te=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):G===1?Te=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:G}):Te=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:G})}else if(i){const G=i.sessions.length;G===1?Te=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):Te=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:G,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:G})}const Me=i?s.jsxs("div",{className:$e(L?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&s.jsxs("div",{className:$e(L?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-edge-muted bg-sidebar/60 p-3"),children:[L&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),s.jsxs("ul",{className:$e(L?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(G=>s.jsxs("li",{className:$e(L?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[s.jsx("span",{className:$e(!L&&"hidden"),children:"•"}),s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),i.sessions.length>5&&s.jsx("li",{className:$e(L?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:i.sessions.length-5})})]})]}),L?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(se,{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")}),Ue?.label?s.jsx("span",{className:"typography-micro text-muted-foreground",children:Ue.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Ue?kc(Ue.path,q):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-edge-muted bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Re=L&&Q?we?s.jsxs("button",{type:"button",onClick:()=>{pe||f(G=>!G)},disabled:pe,"aria-pressed":d,className:$e("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",pe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[d?s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,ze=L&&Q?s.jsxs("button",{type:"button",onClick:()=>{je||m(G=>!G)},disabled:je,"aria-pressed":p,className:$e("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",je?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,B=L?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:[ze,Re]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:Se,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:ye,disabled:h,children:t(h?"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:()=>$(!A),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":!A,children:[A?s.jsx(se,{name:"checkbox-blank",className:"size-4"}):s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:Se,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:ye,disabled:h,children:h?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),ce=L?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[F?s.jsx(yg,{open:!!i,onClose:()=>{h||Se()},title:ce,footer:s.jsx("div",{className:"flex justify-end gap-2",children:B}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Te&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:Te}),Me]})}):s.jsx(zn,{open:!!i,onOpenChange:G=>{if(!G){if(h)return;Se()}},children:s.jsxs(Bn,{className:$e(L?"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($n,{children:[s.jsxs(Fn,{className:$e(L&&"flex items-center gap-2"),children:[L&&s.jsx(se,{name:"delete-bin",className:"h-5 w-5"}),ce]}),Te&&s.jsx(Ln,{children:Te})]}),L?s.jsx(fs,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:Me}):s.jsx("div",{children:Me}),s.jsx(Br,{className:"mt-2 gap-2 pt-1 pb-1",children:B})]})}),s.jsx(Jf,{open:r,onOpenChange:o})]})},cu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],W2=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,U2=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,V2=t=>cu.some(({pattern:e})=>e.test(t));async function H2(t,e,n){if(!t)return null;const r=K2(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=Z2(n);if(o){const i=await X2(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await q2(t)){const o=await G2(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function q2(t){const e=`${t}/index.html`,n=await Xr(e,t);return typeof n=="string"&&n.trim().length>0}async function G2(){try{const t=await Vs("/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 K2(t){for(const e of t){const n=U2.exec(e.command.trim())?.[1];if(n&&V2(n)||e.source!=="shared"&&W2.test(e.name.trim()))return e}return null}function Z2(t){for(const{pattern:e}of cu)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function X2(t){const e=await Xr(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.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,o]of n){const i=await Xr(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Xr(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Vs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Jl()?.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 Vs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Y2(t){try{const e=await Xr(`${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 J2=/\{(worktree|branch)\}/g,Uo=63,Q2=new Set(["main","master"]),du=t=>/\{(worktree|branch)\}/.test(t??""),ek=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},uu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Uo)return e;const n=await ek(e);return n?`${e.slice(0,Uo-7).replace(/-+$/,"")}-${n}`:e.slice(0,Uo).replace(/-+$/,"")},tk=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},sk=async(t,e,n)=>{const r=n.includes("{branch}"),o=n.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:tk(i.current),linkedWorktree:o}},nk=async t=>!t.linkedWorktree||!t.branch||Q2.has(t.branch)?"":uu(t.branch.split("/").pop()??""),rk=t=>{const e=t.lastIndexOf("@"),n=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",u=i.split(".").map(c=>c.replace(/^-+|-+$/g,"")).filter(Boolean);return`${n}${u.join(".")}${a}`},ok=async(t,e)=>{const n={worktree:await nk(e),branch:e.branch?await uu(e.branch):""},r=t.replace(J2,(c,d)=>n[d]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",u=""]=o;return`${i}${rk(a)}${u}`},ik=async(t,e,n)=>du(e)?ok(e,await sk(t,n,e)):e,fu="oc.projectActions.selectedAction.v1",ak=ei(Ps(),ei(Ps(),Ps())),pu=()=>{const t=so().getItem(fu);if(t===null)return{};try{const e=ak.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},El=(t,e=as())=>pu()[e]?.[t]??null,lk=(t,e,n=as())=>{const r=pu();r[n]?.[t]!==e&&so().setItem(fu,JSON.stringify({...r,[n]:{...r[n],[t]:e}}))},ck=15e3,dk=3e3,uk=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}},fk=({projectRef:t,directory:e,allowMobile:n=!1})=>{const{t:r}=at(),{currentTheme:o}=no(),{terminal:i,runtime:a,git:u}=Is(),c=Gs(),{isMobile:d}=yn(),f=l.useMemo(()=>Us(),[]),p=va(v=>v.instances),m=va(v=>v.load),h=X(v=>v.terminalShell),x=X(v=>v.terminalLoginShells.includes(v.terminalShell)),g=X(v=>v.setSettingsPage),b=X(v=>v.setSettingsDialogOpen),w=X(v=>v.setSettingsProjectsSelectedId),S=X(v=>v.openContextPreview),y=wt(v=>v.ensureDirectory),I=wt(v=>v.reconcileServerSessions),j=wt(v=>v.setTabLabel),R=wt(v=>v.setTabIconKey),_=wt(v=>v.setActiveTab),P=wt(v=>v.setConnecting),k=wt(v=>v.setTabSessionId),N=wt(v=>v.setTabPurpose),T=wt(v=>v.allocateActionExecution),A=wt(v=>v.setTabLifecycle),$=wt(v=>v.setTabPreviewUrl),K=wt(v=>v.matchesActionExecution),q=wt(v=>v.captureStartedActionMutationRevisions),[M,z]=l.useState([]),ne=l.useRef(null),[H,V]=l.useState(()=>t?.id?El(t.id):null),[F,C]=l.useState(!1),te=l.useRef({}),re=l.useRef({}),Q=l.useRef({}),ee=l.useRef(new Set),le=l.useRef(0),[O,Y]=l.useState({}),Z=t?.id??null,we=t?.path??"";l.useEffect(()=>{V(Z?El(Z):null)},[Z]);const L=l.useMemo(()=>Z?{id:Z,path:we}:null,[Z,we]);l.useEffect(()=>{f&&m().catch(()=>{})},[f,m]);const pe=l.useCallback(async v=>{await qn(v)},[]),je=l.useCallback(async()=>{if(!L)return;const v=le.current+1;le.current=v,C(!0);try{const ae=await Io(L);if(le.current!==v)return;ne.current=ae;const W=ae.projectActions;z(W)}catch{if(le.current!==v)return}finally{le.current===v&&C(!1)}},[L]),Ee=l.useMemo(()=>To(e||L?.path||""),[e,L?.path]),Se=l.useMemo(()=>To(L?.path||""),[L?.path]),Le=l.useMemo(()=>To(c||"")||Ee,[c,Ee]),Pe=l.useRef(Le);l.useEffect(()=>{Pe.current=Le},[Le]);const Ve=wt(v=>Ee?v.getDirectoryState(Ee):void 0),Oe=wt(v=>Se&&Se!==Ee?v.getDirectoryState(Se):void 0),be=l.useMemo(()=>{const v=Ee?[{directory:Ee,state:Ve}]:[];return Se&&Se!==Ee&&v.push({directory:Se,state:Oe}),v},[Ve,Ee,Se,Oe]),ye=l.useMemo(()=>{const v=Ee?[Ee]:[];return Se&&Se!==Ee&&v.push(Se),v},[Ee,Se]),Ue=l.useCallback(v=>v.id!==rn&&v.runIn==="parent"&&Se||Ee,[Ee,Se]),Te=l.useCallback((v,ae,W)=>`${v}::${ae}::${W}`,[]),Me=l.useCallback((v,ae,W=wt.getState())=>v?W.getDirectoryState(v)?.tabs.find(me=>me.purpose.type==="project-action"&&me.purpose.actionId===ae)??null:null,[]),Re=l.useMemo(()=>{const v={};for(const{directory:ae,state:W}of be)for(const me of W?.tabs??[]){if(me.purpose.type!=="project-action"||!me.purpose.executionId||!me.terminalSessionId||me.lifecycle==="idle"||me.lifecycle==="exited")continue;const he=jn(ae,me.purpose.actionId),Je=Te(ae,me.purpose.actionId,me.purpose.executionId);v[he]={directory:ae,actionId:me.purpose.actionId,tabId:me.id,sessionId:me.terminalSessionId,executionId:me.purpose.executionId,status:me.lifecycle==="stopping"?"stopping":O[Je]?"waiting-for-preview":"running"}}return v},[Te,O,be]),ze=l.useCallback((v,ae,W)=>{const me=jn(v,ae),he=Te(v,ae,W),Fe=te.current[me]?.executionId===W,fe=globalThis.window,ke=rt=>{fe?.clearTimeout(Q.current[rt]),delete Q.current[rt]};Fe&&(delete te.current[me],ke(me)),re.current[he]?.(),delete re.current[he],ke(he),Y(rt=>{if(!rt[he])return rt;const ge={...rt};return delete ge[he],ge})},[Te]),B=l.useCallback(v=>{re.current[v]?.(),delete re.current[v]},[]),ce=l.useCallback(v=>{window.clearTimeout(Q.current[v]),delete Q.current[v]},[]);l.useEffect(()=>{const v=re.current,ae=Q.current;return()=>{for(const W of Object.keys(v))B(W);for(const W of Object.keys(ae))ce(W)}},[ce,B]),l.useEffect(()=>{const v=new Set(ye);for(const ae of Object.values(te.current))v.has(ae.directory)||ze(ae.directory,ae.actionId,ae.executionId);for(const ae of Object.keys(re.current)){const W=ae.split("::",1)[0]??"";v.has(W)||B(ae)}},[ze,B,ye]);const G=l.useCallback((v,ae)=>{X.getState().openContextPanelTab(v,{mode:"terminal",targetDirectory:ae===v?null:ae})},[]),Ce=l.useMemo(()=>({id:rn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),J=!d,Ne=l.useMemo(()=>J?[...M,Ce]:M,[M,Ce,J]),Ae=l.useMemo(()=>H?Ne.find(v=>v.id===H)??null:null,[Ne,H]);l.useEffect(()=>{je()},[je]);const[Ie,De]=l.useState(0),We=l.useCallback(()=>(De(v=>v+1),()=>De(v=>v-1)),[]),Ke=Ie>0;l.useEffect(()=>{if(!Ke)return;const v=ye.map(ae=>Qf(i,ae,q,W=>I(ae,W.sessions,{startedActionMutationRevisions:W.startedActionMutationRevisions})));return()=>{for(const ae of v)ae()}},[q,Ke,I,i,ye]),l.useEffect(()=>{for(const{directory:v,state:ae}of be)if(v)for(const W of ae?.tabs??[]){if(W.purpose.type!=="project-action")continue;const me=W.purpose.actionId,he=Ne.find(fe=>fe.id===me),Je=he?.name??me,Fe=he?.icon||"play";W.label!==Je&&j(v,W.id,Je),W.iconKey!==Fe&&R(v,W.id,Fe)}},[Ne,R,j,be]),l.useEffect(()=>{const v=globalThis.window;if(!v)return;const ae=W=>{const me=W.detail;Z&&(me?.projectId&&me.projectId!==Z||je())};return v.addEventListener(Sa,ae),()=>{v.removeEventListener(Sa,ae)}},[je,Z]),l.useEffect(()=>{const v=W=>{delete Q.current[W];const me=te.current[W];if(!me||me.openedUrl)return;const he=Te(me.directory,me.actionId,me.executionId),Je=me.announced;if(Je.length!==0){if(window.clearTimeout(Q.current[he]),delete Q.current[he],me.openedUrl=!0,Y(Fe=>{if(!Fe[he])return Fe;const fe={...Fe};return delete fe[he],fe}),Je.length===1){Bo(me.directory,[]),$(me.directory,me.tabId,Je[0],{locked:!1,autoOpened:!0}),S(me.directory,Je[0]);return}me.offering=!0,Bo(me.directory,Je),X.getState().openContextSurface(me.directory,"browser"),_e.info(r("projectActions.toast.multipleServers"))}},ae=()=>{const W=wt.getState(),me=W.sessions,he=Re;for(const[Je,Fe]of Object.entries(he)){const ke=me.get(Fe.directory)?.tabs.find(xt=>xt.id===Fe.tabId);if(!ke||ke.terminalSessionId!==Fe.sessionId){ze(Fe.directory,Fe.actionId,Fe.executionId);continue}const rt=te.current[Je],ge=rt?.executionId===Fe.executionId?rt:{hostDirectory:Pe.current||Fe.directory,directory:Fe.directory,tabId:Fe.tabId,actionId:Fe.actionId,executionId:Fe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};te.current[Je]=ge;const lt=Ne.find(xt=>xt.id===Fe.actionId),Ct=W.getBuffer(Fe.directory,Fe.tabId).chunks;if(!lt||Ct.length===0)continue;const bt=Ct.filter(xt=>ge.lastSeenChunkId===null||xt.id>ge.lastSeenChunkId);if(bt.length===0)continue;const kt=bt.map(xt=>xt.data).join(""),ht=`${ge.tail}${kt}`;for(const xt of op(ht))ge.proxiedPorts.includes(xt)||ge.proxiedPorts.push(xt);if(ge.openInPreview&&(!ge.openedUrl||ge.offering)){const xt=ip(ht,{proxiedPorts:ge.proxiedPorts,namedAddressesReachable:!ka()}),vt=ge.announced.length;for(const Pt of xt)ge.announced.includes(Pt)||ge.announced.push(Pt);const ct=ge.announced.length-vt;ge.offering&&ct>0?Bo(Fe.directory,ge.announced):!ge.openedUrl&&vt===0&&ge.announced.length>0&&(window.clearTimeout(Q.current[Je]),Q.current[Je]=window.setTimeout(()=>v(Je),dk))}const St=!ge.openedUrl&&lt.autoOpenUrl===!0&&!ge.openInPreview?ap(ht,{proxiedPorts:ge.proxiedPorts,namedAddressesReachable:!ka()}):null,yt=bt[bt.length-1]?.id??ge.lastSeenChunkId;if(ge.lastSeenChunkId=yt,ge.tail=ht.slice(-512),St)if(ge.openedUrl=!0,ge.openInPreview){const xt=he[Je];xt&&($(xt.directory,xt.tabId,St,{locked:!1,autoOpened:!1,expectedExecutionId:xt.executionId}),xt.status==="waiting-for-preview"&&Y(vt=>{const ct=Te(xt.directory,xt.actionId,xt.executionId);if(!vt[ct])return vt;const Pt={...vt};return delete Pt[ct],Pt}),window.clearTimeout(Q.current[Je]),delete Q.current[Je],S(xt.directory,St))}else pe(St),_e.success(r("projectActions.toast.openedUrlFromOutput"));te.current[Je]=ge}for(const Je of Object.keys(te.current))if(!he[Je]){const Fe=te.current[Je],fe=Fe?me.get(Fe.directory)?.tabs.find(rt=>rt.id===Fe.tabId):void 0;if(fe?.purpose.type==="project-action"&&fe.purpose.executionId===Fe?.executionId&&!!fe.terminalSessionId&&fe.lifecycle!=="idle"&&fe.lifecycle!=="exited")continue;delete te.current[Je],window.clearTimeout(Q.current[Je]),delete Q.current[Je]}};return ae(),wt.subscribe((W,me)=>{(W.sessions!==me.sessions||W.buffers!==me.buffers)&&ae()})},[ze,Pe,Ne,Te,S,pe,Re,$,r]),l.useEffect(()=>{for(const{directory:v,state:ae}of be)for(const W of ae?.tabs??[]){if(W.purpose.type!=="project-action"||!W.purpose.executionId||!W.terminalSessionId||W.lifecycle!=="running")continue;const me=W.purpose.actionId,he=W.purpose.executionId,Je=Te(v,me,he);if(re.current[Je])continue;const Fe=i.connect(W.terminalSessionId,{onEvent:fe=>{if(!K(v,W.id,he))return;fe.type==="snapshot"&&(wt.getState().replaceBuffer(v,W.id,fe.data??"",fe.sequence??0,na(fe)),fe.status==="running"&&wt.getState().setTabLifecycle(v,W.id,"running",{expectedExecutionId:he}),fe.status==="exited"&&(wt.getState().setTabLifecycle(v,W.id,"exited",{expectedExecutionId:he}),wt.getState().setTabPurpose(v,W.id,{type:"project-action",actionId:me,executionId:null}),ze(v,me,he)));const ke=fe.type==="data"?fe.data??"":"";ke&&wt.getState().appendToBuffer(v,W.id,ke,fe.sequence,fe.replayData),fe.type==="exit"&&(wt.getState().setTabLifecycle(v,W.id,"exited",{expectedExecutionId:he}),wt.getState().setTabPurpose(v,W.id,{type:"project-action",actionId:me,executionId:null}),ze(v,me,he))},onError:(fe,ke)=>{!ke||!K(v,W.id,he)||(wt.getState().setTabLifecycle(v,W.id,"exited",{expectedExecutionId:he}),wt.getState().setTabSessionId(v,W.id,null,{expectedExecutionId:he}),wt.getState().setTabPurpose(v,W.id,{type:"project-action",actionId:me,executionId:null}),ze(v,me,he))}},v);re.current[Je]=Fe.close}},[ze,Te,K,i,be]);const Ze=l.useCallback(async v=>{const ae=Ue(v);if(!ae)throw new Error(r("projectActions.error.noActiveDirectory"));const W=jn(ae,v.id);y(ae);const me=wt.getState(),he=Me(ae,v.id,me),Je=he?.id??me.createTab(ae);j(ae,Je,v.name),R(ae,Je,v.icon||"play"),he||N(ae,Je,{type:"project-action",actionId:v.id,executionId:null}),_(ae,Je);const fe=wt.getState().getDirectoryState(ae)?.tabs.find(ke=>ke.id===Je);return{executionDirectory:ae,key:W,tabId:Je,sessionId:fe?.terminalSessionId??null,executionId:fe?.purpose.type==="project-action"?fe.purpose.executionId:null}},[y,Ue,Me,_,R,j,N,r]),Qe=l.useCallback(async v=>{if(a.isVSCode||!n&&d)return;if(!Ee){_e.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ae=jn(Ue(v),v.id),W=Re[ae];if(W&&W.status==="running"||ee.current.has(ae))return;ee.current.add(ae);let me=null;try{const he=v.id===rn?await(async()=>{const pt=L??{id:"",path:Ee},[mt,Ot]=await Promise.all([Io(pt),Y2(Ee)]),Ut=await H2(Ee,mt.projectActions,Ot);if(!Ut)throw new Error(r("contextPanel.preview.noDevServer"));return mt.projectActions.find(ps=>ps.id===Ut.actionId)?.source==="shared"&&!await Aa(pt,mt)?null:{id:rn,name:r("projectActions.actions.autoDiscover"),command:Ut.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Ut.previewUrlHint||""}})():v;if(!he)return;const Je=he.autoOpenUrl===!0&&(he.openUrl||"").trim().length>0,Fe=!Je&&v.id!==rn,fe=Pe.current||Ee,{executionDirectory:ke,key:rt,tabId:ge}=await Ze(he),lt=ep(he.command);if(!lt)throw new Error(r("projectActions.error.failedToRunAction"));const Ct=he.autoOpenUrl===!0&&f&&(he.desktopOpenSshForward||"").trim().length>0,bt=he.autoOpenUrl&&he.openUrl||"";let kt=!1;const ht=du(bt)?await ik(u,bt,ke).catch(()=>(kt=!0,"")):bt,St=he.autoOpenUrl?uk(ht):null,yt=he.autoOpenUrl&&f?tp(he.desktopOpenSshForward,p):null;if(i.listSessions){const pt=Me(ke,he.id);if(pt?.purpose.type==="project-action"&&pt.purpose.executionId===null){const mt=await sp(i,ke,{captureStartedActionMutationRevisions:q});mt&&I(ke,mt.sessions,{startedActionMutationRevisions:mt.startedActionMutationRevisions})}}const xt=Me(ke,he.id);let vt,ct;if(xt?.lifecycle==="running"&&xt.terminalSessionId&&xt.purpose.type==="project-action"&&xt.purpose.executionId)vt=xt.terminalSessionId,ct=xt.purpose.executionId;else{const pt=xt?.purpose.type==="project-action"?xt.purpose.executionId:null;pt&&ze(ke,he.id,pt);const mt=T(ke,ge,he.id);if(!mt)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));me={directory:ke,tabId:ge,id:mt},P(ke,ge,!0,{expectedExecutionId:mt});const Ot=await np({terminal:i,createOptions:{cwd:ke,shell:h,loginShell:x,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:lt,isRunStillExpected:()=>K(ke,ge,mt),purpose:{type:"project-action",actionId:he.id,executionId:mt}});if(!K(ke,ge,mt)){Ot.sessionId===mt&&await i.close(Ot.sessionId).catch(()=>{});return}ct=Ot.purpose?.type==="project-action"?Ot.purpose.executionId:mt,vt=Ot.sessionId,N(ke,ge,{type:"project-action",actionId:he.id,executionId:ct}),k(ke,ge,vt,{expectedExecutionId:ct}),P(ke,ge,!1,{expectedExecutionId:ct})}Fe&&fe&&G(fe,ke),te.current[rt]={hostDirectory:fe,directory:ke,tabId:ge,actionId:he.id,executionId:ct,lastSeenChunkId:null,openedUrl:!!yt||!!St||Je,tail:"",openInPreview:he.id===rn,announced:[],offering:!1,proxiedPorts:[]};const Pt=Te(ke,he.id,ct);P(ke,ge,!0,{expectedExecutionId:ct});const Dt=i.connect(vt,{onEvent:pt=>{if(!K(ke,ge,ct)||pt.purpose?.type==="project-action"&&pt.purpose.executionId!==ct)return;pt.type==="snapshot"&&(wt.getState().replaceBuffer(ke,ge,pt.data??"",pt.sequence??0,na(pt)),wt.getState().setConnecting(ke,ge,!1,{expectedExecutionId:ct}),pt.purpose?.type==="project-action"&&wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:pt.purpose.actionId,executionId:pt.purpose.executionId}),pt.status==="running"&&wt.getState().setTabLifecycle(ke,ge,"running",{expectedExecutionId:ct}),pt.status==="exited"&&(wt.getState().setTabLifecycle(ke,ge,"exited",{expectedExecutionId:ct}),wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:he.id,executionId:null}),ze(ke,he.id,ct)));const mt=pt.type==="data"?pt.data??"":"";mt&&wt.getState().appendToBuffer(ke,ge,mt,pt.sequence,pt.replayData),pt.type==="exit"&&(wt.getState().setTabLifecycle(ke,ge,"exited",{expectedExecutionId:ct}),wt.getState().setConnecting(ke,ge,!1,{expectedExecutionId:ct}),wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:he.id,executionId:null}),ze(ke,he.id,ct))},onError:(pt,mt)=>{K(ke,ge,ct)&&(wt.getState().setConnecting(ke,ge,!1,{expectedExecutionId:ct}),mt&&(wt.getState().setTabLifecycle(ke,ge,"exited",{expectedExecutionId:ct}),wt.getState().setTabSessionId(ke,ge,null,{expectedExecutionId:ct}),wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:he.id,executionId:null}),ze(ke,he.id,ct)))}},ke);if(!K(ke,ge,ct)){Dt.close();return}re.current[Pt]?.(),re.current[Pt]=Dt.close,window.clearTimeout(Q.current[Pt]),delete Q.current[Pt],he.id===rn&&!St&&(Y(pt=>({...pt,[Pt]:!0})),Q.current[Pt]=window.setTimeout(()=>{delete Q.current[Pt];const pt=te.current[rt];!pt||pt.executionId!==ct||pt.openedUrl||pt.offering||K(ke,ge,ct)&&(Y(mt=>{if(!mt[Pt])return mt;const Ot={...mt};return delete Ot[Pt],Ot}),wt.getState().setActiveTab(ke,ge),G(pt.hostDirectory,ke))},ck)),yt?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),pe(yt),_e.success(r("projectActions.toast.openedForwardedUrl"))):St?($(ke,ge,St,{locked:!0,autoOpened:!0,expectedExecutionId:ct}),S(fe,St),_e.success(r("projectActions.toast.openedActionUrl"))):kt?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),_e.error(r("projectActions.error.openUrlTemplateUnresolved"))):Je?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),_e.error(r("projectActions.error.invalidCustomUrlFormat"))):Ct?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),_e.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(ke,ge,null,{locked:!1,autoOpened:!1,expectedExecutionId:ct})}catch(he){if(me&&K(me.directory,me.tabId,me.id)){const{directory:Je,tabId:Fe,id:fe}=me;ze(Je,v.id,fe),A(Je,Fe,"exited",{expectedExecutionId:fe}),N(Je,Fe,{type:"project-action",actionId:v.id,executionId:null})}if(he instanceof Error&&he.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(he instanceof Error&&(he.message==="COMMAND_MODE_UNSUPPORTED"||he.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){_e.error(r("projectActions.error.failedToCreateTerminalSession"));return}_e.error(he instanceof Error?he.message:r("projectActions.error.failedToRunAction"))}finally{ee.current.delete(ae)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Pe,p,Ze,u,n,d,f,Ee,x,h,pe,S,Re,G,a.isVSCode,Ue,K,ze,Te,Me,I,T,q,P,A,N,$,k,L,r,i]),qe=l.useCallback(async v=>{const ae=jn(Ue(v),v.id),W=Re[ae];W&&await rp({terminal:i,sessionId:W.sessionId,isExecutionStillCurrent:()=>K(W.directory,W.tabId,W.executionId),markStopping:()=>{A(W.directory,W.tabId,"stopping",{expectedExecutionId:W.executionId})},restoreRunning:()=>{A(W.directory,W.tabId,"running",{expectedExecutionId:W.executionId})},clearSession:()=>{k(W.directory,W.tabId,null,{expectedExecutionId:W.executionId})},finalizeExit:()=>{A(W.directory,W.tabId,"exited",{expectedExecutionId:W.executionId}),N(W.directory,W.tabId,{type:"project-action",actionId:W.actionId,executionId:null}),ze(W.directory,W.actionId,W.executionId)}})},[ze,Ue,K,Re,A,N,k,i]),et=l.useCallback(async v=>{if(v.source==="shared"&&L){const ae=ne.current?.trust.trusted?ne.current:await Io(L);if(ne.current=ae,!await Aa(L,ae))return;ne.current={...ae,trust:{...ae.trust,trusted:!0}}}await Qe(v)},[Qe,L]),He=l.useCallback(v=>Re[jn(Ue(v),v.id)]??null,[Ue,Re]),Ye=(Ae&&He(Ae)?Ae:null)??Ne.find(v=>He(v)!==null)??Ae??Ne[0]??null,dt=l.useCallback(v=>{const ae=He(v);if(ae?.status!=="stopping"){if(ae){qe(v);return}et(v)}},[et,He,qe]),nt=l.useCallback(v=>{et(v)},[et]),ut=l.useCallback(v=>{qe(v)},[qe]),oe=l.useCallback(v=>{V(v.id),Z&&lk(Z,v.id)},[Z]),de=l.useCallback(()=>{L?.id&&(w(L.id),g("projects"),b(!0))},[b,g,w,L?.id]),ve=!a.isVSCode&&(n||!d)&&!!L&&!!Ee;return l.useMemo(()=>({available:ve,actions:ve?Ne:[],shown:ve?Ye:null,isLoading:F,observe:We,runOf:He,select:oe,run:nt,stop:ut,toggle:dt,openSettings:de}),[ve,Ne,F,We,de,nt,He,oe,Ye,ut,dt])},pk=t=>{const e=Be.c(6);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const o=fk(r);let i;return e[3]!==n||e[4]!==o?(i=s.jsx(hd.Provider,{value:o,children:n}),e[3]=n,e[4]=o,e[5]=i):i=e[5],i},mk=t=>{const e=Be.c(4),{children:n}=t,r=xd(),o=xr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let u;return e[0]!==n||e[1]!==a||e[2]!==i?(u=s.jsx(pk,{projectRef:i,directory:a,children:n}),e[0]=n,e[1]=a,e[2]=i,e[3]=u):u=e[3],u};function hk(t){const e=[],n=(r,o)=>{const i=Yt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const gk=new Map,xk=t=>{const e=Be.c(23),{isVSCode:n}=t,r=Uc(),o=Gt(bk),i=is(wk),a=tt(yk);let u;e[0]!==n?(u=k=>n?gk:k.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const c=tt(u),d=!n;let f;e[2]!==c||e[3]!==o||e[4]!==d?(f=lp(o,c,{includeWorktrees:d}),e[2]=c,e[3]=o,e[4]=d,e[5]=f):f=e[5];const p=f,m=ts(vk),h=ts(Sk),x=ts(kk),g=`session-list-sync:${l.useId()}`;let b,w;e[6]!==g||e[7]!==r||e[8]!==i||e[9]!==a?(b=()=>(r.setBootstrapDemand(g,hk({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(g)),w=[g,r,i,a],e[6]=g,e[7]=r,e[8]=i,e[9]=a,e[10]=b,e[11]=w):(b=e[10],w=e[11]),l.useEffect(b,w);const S=l.useRef(null);let y,I;e[12]!==n||e[13]!==p?(y=()=>{const k=new Set(p),N=S.current;S.current=k;const T=N?[...k].filter(A=>!N.has(A)):n?[...k]:[];T.length&&Zc(T,Xo())},I=[n,p],e[12]=n,e[13]=p,e[14]=y,e[15]=I):(y=e[14],I=e[15]),l.useEffect(y,I);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],l.useEffect(jk,j);let R;e[17]!==h||e[18]!==m?(R=[...m,...h],e[17]=h,e[18]=m,e[19]=R):R=e[19];const _=R;let P;e[20]!==_||e[21]!==x?(P={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:_},e[20]=_,e[21]=x,e[22]=P):P=e[22],cp(P)};function bk(t){return t.projects}function wk(t){return t.currentDirectory}function yk(t){return t.currentSessionDirectory}function vk(t){return t.activeSessions}function Sk(t){return t.archivedSessions}function kk(t){return t.status==="ready"}function jk(){let t=null,e=!1;const n=new Set,r=Js(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")n.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),vg(Xo());return}const i=[...n];n.clear(),i.length&&Zc(i,Xo())},500)});return()=>{t&&clearTimeout(t),r()}}const Ck=()=>At(()=>import("./SettingsWindow-CKUU5T8p.js"),__vite__mapDeps([231,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,232,181,182,183,233,234,216,217,218,219,226,201,188,189,202,235,236,225,211,237,238,239])).then(t=>t.SettingsWindow),Tk=()=>At(()=>import("./CommandPalette-Dvsy8IHV.js"),__vite__mapDeps([240,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,237,181,182,183,206,205])).then(t=>t.CommandPalette),Nk=()=>At(()=>import("./HelpDialog-DuO4UnZT.js"),__vite__mapDeps([241,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.HelpDialog),Ek=()=>At(()=>import("./ProjectActionsDialog-Ctr7-_lb.js"),__vite__mapDeps([242,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.ProjectActionsDialog),Pk=()=>At(()=>import("./OpenCodeStatusDialog-ByN8gJ51.js"),__vite__mapDeps([243,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.OpenCodeStatusDialog),Ik=()=>At(()=>import("./RunOverview-DNSvGB7-.js"),__vite__mapDeps([244,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.RunOverview),Rk=()=>At(()=>import("./ScheduledTasksDialog-BNXOjpPY.js"),__vite__mapDeps([245,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,229,246,247,248])).then(t=>t.ScheduledTasksDialog),Dk=()=>At(()=>import("./ArchiveView-GN7gU2qK.js"),__vite__mapDeps([249,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,250])).then(t=>t.ArchiveView),_k=()=>At(()=>import("./IntegrationsCatalogView-BrLbP8hQ.js"),__vite__mapDeps([251,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,233])).then(t=>t.IntegrationsCatalogView),Ak=()=>At(()=>import("./UsageStatsView-D2AXngeb.js"),__vite__mapDeps([252,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.UsageStatsView),Ok=()=>At(()=>import("./SourceBoardView-BQittQF3.js"),__vite__mapDeps([253,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.SourceBoardView),Mk=()=>At(()=>import("./OverviewView-B6SMyBTp.js"),__vite__mapDeps([254,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.OverviewView),Fk=()=>At(()=>import("./WorktreesView-Bmnk7eXM.js"),__vite__mapDeps([255,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,250])).then(t=>t.WorktreesView),Lk=()=>At(()=>import("./SpacesView-D6UCwVZp.js"),__vite__mapDeps([256,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,238,181,182,183])).then(t=>t.SpacesView),$k=()=>At(()=>import("./SpaceAccessDialog-CeZrOBod.js"),__vite__mapDeps([257,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceAccessDialog),Bk=()=>At(()=>import("./SpaceApplyDialog-DurN0_0Z.js"),__vite__mapDeps([259,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182])).then(t=>t.SpaceApplyDialog),zk=()=>At(()=>import("./SpaceSetupOutput-BDkJcYrl.js"),__vite__mapDeps([260,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceSetupOutputDialog),Fs=()=>X.getState().closeMainSurfaces(),os=t=>{const e=Be.c(2),{needed:n,load:r,onFailure:o}=t,i=fo(n,r,o);let a;return e[0]!==i?(a=i?s.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},mu=l.memo(t=>{const e=Be.c(11),{isMobile:n}=t,r=X(Uk),o=!r&&!n,i=ao();let a;e[0]!==o||e[1]!==i?(a={enabled:o,layoutAnimationMs:i},e[0]=o,e[1]=i,e[2]=a):a=e[2];const u=wb(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(pb,{}),e[3]=c):c=e[3];const d=r||u.state!==!1;let f;e[4]!==d?(f=s.jsx(dp,{isVisible:d}),e[4]=d,e[5]=f):f=e[5];let p;return e[6]!==n||e[7]!==r||e[8]!==u||e[9]!==f?(p=s.jsx(fb,{isOpen:r,isMobile:n,className:"border-border",topBar:c,peek:u,children:f}),e[6]=n,e[7]=r,e[8]=u,e[9]=f,e[10]=p):p=e[10],p});mu.displayName="LeftSidebar";const Wk=()=>{const t=Be.c(111);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],xk(e),up();const n=X(Vk),r=X(Hk),o=X(qk),i=X(Gk);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const u=fo(o,Ck,a),c=X(Kk),d=X(Zk),f=X(Xk),p=X(Yk),m=X(Jk),h=X(Qk),x=X(ej),g=X(tj),b=X(sj),w=X(nj),S=X(rj),y=X(oj),I=X(ij),j=pn(aj),R=pn(lj),_=pn(cj),P=X(dj),k=Sg();let N;if(t[3]!==k||t[4]!==P){let nt;t[6]!==P?(nt=ut=>ut.id===P,t[6]=P,t[7]=nt):nt=t[7],N=k.find(nt),t[3]=k,t[4]=P,t[5]=N}else N=t[5];const T=N;let A,$;t[8]!==T||t[9]!==P?(A=()=>{P&&!T&&X.getState().setOpenGuestPage(null)},$=[P,T],t[8]=T,t[9]=P,t[10]=A,t[11]=$):(A=t[10],$=t[11]),l.useEffect(A,$);let K;t[12]===Symbol.for("react.memo_cache_sentinel")?(K=[],t[12]=K):K=t[12],l.useEffect(fj,K);let q;t[13]===Symbol.for("react.memo_cache_sentinel")?(q=[],t[13]=q):q=t[13],l.useEffect(pj,q);const M=d||f||p||m||h||x||!!g||b||c||!!T;let z,ne;t[14]!==M?(z=()=>{Xc(M)},ne=[M],t[14]=M,t[15]=z,t[16]=ne):(z=t[15],ne=t[16]),l.useLayoutEffect(z,ne);let H;t[17]===Symbol.for("react.memo_cache_sentinel")?(H=[],t[17]=H):H=t[17],l.useEffect(hj,H);let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=[],t[18]=V):V=t[18],l.useEffect(xj,V);const{isMobile:F}=yn();fp();let C,te;t[19]!==F||t[20]!==r?(C=()=>{X.getState().isMobile!==F&&r(F)},te=[F,r],t[19]=F,t[20]=r,t[21]=C,t[22]=te):(C=t[21],te=t[22]),l.useEffect(C,te);let re;t[23]!==w?(re=s.jsx(os,{needed:w,load:Tk,onFailure:bj}),t[23]=w,t[24]=re):re=t[24];let Q;t[25]!==S?(Q=s.jsx(os,{needed:S,load:Nk,onFailure:wj}),t[25]=S,t[26]=Q):Q=t[26];let ee;t[27]!==y?(ee=s.jsx(os,{needed:y,load:Ek,onFailure:yj}),t[27]=y,t[28]=ee):ee=t[28];let le;t[29]!==I?(le=s.jsx(os,{needed:I,load:Pk,onFailure:vj}),t[29]=I,t[30]=le):le=t[30];let O,Y;t[31]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(mp,{}),Y=s.jsx(z2,{}),t[31]=O,t[32]=Y):(O=t[31],Y=t[32]);let Z;t[33]!==j||t[34]!==R||t[35]!==_||t[36]!==n?(Z=n?s.jsxs(s.Fragment,{children:[s.jsx(os,{needed:j,load:$k,onFailure:Sj}),s.jsx(hp,{}),s.jsx(os,{needed:R,load:Bk,onFailure:kj}),s.jsx(gp,{}),s.jsx(os,{needed:_,load:zk,onFailure:jj})]}):null,t[33]=j,t[34]=R,t[35]=_,t[36]=n,t[37]=Z):Z=t[37];let we;t[38]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(yb,{}),t[38]=we):we=t[38];let L;t[39]!==F?(L=s.jsx(mu,{isMobile:F}),t[39]=F,t[40]=L):L=t[40];let pe;t[41]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(ub,{}),t[41]=pe):pe=t[41];let je;t[42]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx($o,{zone:"left"}),t[42]=je):je=t[42];const Ee=M&&"invisible";let Se;t[43]!==Ee?(Se=$e("absolute inset-0",Ee),t[43]=Ee,t[44]=Se):Se=t[44];const Le=!o&&!M;let Pe;t[45]!==Le?(Pe=s.jsx(Qt,{children:s.jsx(xc,{active:Le})}),t[45]=Le,t[46]=Pe):Pe=t[46];let Ve;t[47]!==Se||t[48]!==Pe?(Ve=s.jsx("div",{className:Se,children:Pe}),t[47]=Se,t[48]=Pe,t[49]=Ve):Ve=t[49];let Oe;t[50]!==c?(Oe=s.jsx(Qt,{children:s.jsx(os,{needed:c,load:Ik,onFailure:Fs})}),t[50]=c,t[51]=Oe):Oe=t[51];let be;t[52]!==d?(be=s.jsx(Qt,{children:s.jsx(os,{needed:d,load:Rk,onFailure:Fs})}),t[52]=d,t[53]=be):be=t[53];let ye;t[54]!==f?(ye=s.jsx(Qt,{children:s.jsx(os,{needed:f,load:Dk,onFailure:Fs})}),t[54]=f,t[55]=ye):ye=t[55];let Ue;t[56]!==p?(Ue=s.jsx(Qt,{children:s.jsx(os,{needed:p,load:_k,onFailure:Fs})}),t[56]=p,t[57]=Ue):Ue=t[57];let Te;t[58]!==m?(Te=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Ak,onFailure:Fs})})}),t[58]=m,t[59]=Te):Te=t[59];let Me;t[60]!==h?(Me=s.jsx(os,{needed:h,load:Ok,onFailure:Fs}),t[60]=h,t[61]=Me):Me=t[61];let Re;t[62]!==x?(Re=s.jsx(Qt,{children:s.jsx(os,{needed:x,load:Mk,onFailure:Fs})}),t[62]=x,t[63]=Re):Re=t[63];const ze=!!g;let B;t[64]!==ze?(B=s.jsx(Qt,{children:s.jsx(os,{needed:ze,load:Fk,onFailure:Fs})}),t[64]=ze,t[65]=B):B=t[65];let ce;t[66]!==b?(ce=b?s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Lk,onFailure:Fs})}):null,t[66]=b,t[67]=ce):ce=t[67];let G;t[68]!==T?(G=T&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(kg,{mode:`plugin:${T.id}`,surface:"page",item:null,onDismiss:Cj})})}),t[68]=T,t[69]=G):G=t[69];let Ce;t[70]!==Ve||t[71]!==Oe||t[72]!==be||t[73]!==ye||t[74]!==Ue||t[75]!==Te||t[76]!==Me||t[77]!==Re||t[78]!==B||t[79]!==ce||t[80]!==G?(Ce=s.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[Ve,Oe,be,ye,Ue,Te,Me,Re,B,ce,G]}),t[70]=Ve,t[71]=Oe,t[72]=be,t[73]=ye,t[74]=Ue,t[75]=Te,t[76]=Me,t[77]=Re,t[78]=B,t[79]=ce,t[80]=G,t[81]=Ce):Ce=t[81];let J;t[82]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx($o,{zone:"bottom"}),t[82]=J):J=t[82];let Ne;t[83]!==Ce?(Ne=s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[Ce,J]}),t[83]=Ce,t[84]=Ne):Ne=t[84];let Ae,Ie,De,We;t[85]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx($o,{zone:"right"}),Ie=s.jsx(t2,{}),De=s.jsx(n2,{}),We=s.jsx(l2,{}),t[85]=Ae,t[86]=Ie,t[87]=De,t[88]=We):(Ae=t[85],Ie=t[86],De=t[87],We=t[88]);let Ke;t[89]!==Ne?(Ke=s.jsx("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","data-page-scroll-lock":"true","data-workspace-row":"true",children:[je,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:[Ne,Ae,Ie,De,We]})]})}),t[89]=Ne,t[90]=Ke):Ke=t[90];let Ze;t[91]===Symbol.for("react.memo_cache_sentinel")?(Ze=s.jsx("div",{"data-page-scroll-lock":"true",children:s.jsx(Qt,{children:s.jsx(v2,{})})}),t[91]=Ze):Ze=t[91];let Qe;t[92]===Symbol.for("react.memo_cache_sentinel")?(Qe=s.jsx(Qt,{children:s.jsx(b1,{})}),t[92]=Qe):Qe=t[92];let qe;t[93]!==Ke?(qe=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[pe,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ke,Ze,Qe]})]}),t[93]=Ke,t[94]=qe):qe=t[94];let et;t[95]!==L||t[96]!==qe?(et=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[L,qe]}),t[95]=L,t[96]=qe,t[97]=et):et=t[97];let He;t[98]!==u||t[99]!==o||t[100]!==i?(He=u?s.jsx(u,{open:o,onOpenChange:i}):null,t[98]=u,t[99]=o,t[100]=i,t[101]=He):He=t[101];let Ye;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ye=null,t[102]=Ye):Ye=t[102];let dt;return t[103]!==re||t[104]!==Q||t[105]!==ee||t[106]!==le||t[107]!==Z||t[108]!==et||t[109]!==He?(dt=s.jsx(jg.Provider,{value:!0,children:s.jsx(pp,{children:s.jsx(mk,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[re,Q,ee,le,O,Y,Z,we,et,He,Ye]})})})}),t[103]=re,t[104]=Q,t[105]=ee,t[106]=le,t[107]=Z,t[108]=et,t[109]=He,t[110]=dt):dt=t[110],dt};function Uk(t){return t.isSidebarOpen}function Vk(t){return t.isolatedSpacesEnabled}function Hk(t){return t.setIsMobile}function qk(t){return t.isSettingsDialogOpen}function Gk(t){return t.setSettingsDialogOpen}function Kk(t){return t.runOverviewKey!==null}function Zk(t){return t.isScheduledTasksDialogOpen}function Xk(t){return t.isArchivePageOpen}function Yk(t){return t.isIntegrationsCatalogOpen}function Jk(t){return t.isUsageStatsPageOpen}function Qk(t){return t.isSourceBoardOpen}function ej(t){return t.isOverviewOpen}function tj(t){return t.worktreesPageProjectId}function sj(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function nj(t){return t.isCommandPaletteOpen}function rj(t){return t.isHelpDialogOpen}function oj(t){return t.isProjectActionsDialogOpen}function ij(t){return t.isOpenCodeStatusDialogOpen}function aj(t){return t.accessDialog!==null}function lj(t){return t.applyDialog!==null}function cj(t){return t.setupOutputDialog!==null}function dj(t){return t.openGuestPageId}function uj(){return X.getState().setOpenGuestPage(null)}function fj(){return Ql(uj)}function pj(){return x1()}function mj(){return Xc(!1)}function hj(){return mj}function gj(){return X.getState().closeMainSurfaces()}function xj(){const t=gj,e=tt.subscribe((n,r)=>{const o=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,i=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function bj(){return X.getState().setCommandPaletteOpen(!1)}function wj(){return X.getState().setHelpDialogOpen(!1)}function yj(){return X.getState().setProjectActionsDialogOpen(!1)}function vj(){return X.getState().setOpenCodeStatusDialogOpen(!1)}function Sj(){return pn.getState().closeAccessDialog()}function kj(){return pn.getState().closeApplyDialog()}function jj(){return pn.getState().closeSetupOutputDialog()}function Cj(){return X.getState().setOpenGuestPage(null)}const gi="openchamber_requests_in_flight",hu=1e3,Tj=300*1e3,Yr=Math.ceil(Tj/hu),Nj=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(gi)==="1"}catch{return!1}},gu=()=>({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 Ej=1;const Pj=(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))},Ij=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},xu=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,o)=>r-o),n},On=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},Rj=()=>{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,o)=>{const i=Ej++;Pj(i,Date.now());try{return await e(r,o)}finally{Ij(i)}};window.fetch=n},Pl=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Yn=t=>{t.length>Yr&&t.splice(0,t.length-Yr)},Dj=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=xu(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(On(e,50)),t.p90Samples.push(On(e,90)),t.p99Samples.push(On(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Yn(t.samples),Yn(t.p50Samples),Yn(t.p90Samples),Yn(t.p99Samples),Yn(t.maxSamples),t.lastSampleAt=Date.now()},_j=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(Dj,hu))},Il=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Rl=t=>{if(!(typeof window>"u"))try{if(t){Il(),Pl(),window.localStorage.setItem(gi,"1"),window.__openchamberRequestsInFlight__=gu(),Rj(),_j();return}window.localStorage.removeItem(gi),Il(),Pl(),delete window.__openchamberRequestsInFlight__}catch{}},b4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=gu();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},w4=()=>{if(typeof window>"u")return Dl();const t=window.__openchamberRequestsInFlight__;if(!Nj()||!t)return Dl();const e=xu(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:On(e,50),ageP90:On(e,90),ageP99:On(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:Yr}},Dl=()=>({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:Yr}),Aj=(t,e,n)=>Cg(t.filter(r=>!Yc(r)&&!r.parentID),e,n),Oj=()=>Aj(ts.getState().activeSessions,Ui.getState().ids,Wi.getState().rankById??Tg),Mj=(t,e,n)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=n>0?0:t.length-1;return r>=0&&(o=(r+n+t.length)%t.length),t[o]},Fj=()=>{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()??"":""},Lj=async()=>{const t=Fj()||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")},_l="openchamber:menu-action",Al="openchamber:check-for-updates",$j=t=>{const e=Be.c(21),{t:n}=at(),r=tt(Bj),o=X(zj),i=X(Wj),a=X(Uj),u=X(Vj),c=X(Hj),d=X(qj),f=X(Gj),p=bc(Kj),{setThemeMode:m}=no(),h=l.useRef(!1);let x;e[0]!==p?(x=()=>{h.current||(h.current=!0,p().then(Zj).finally(()=>{h.current=!1}))},e[0]=p,e[1]=x):x=e[1];const g=x,b=Xj;let w;e[2]!==c?(w=P=>{const k=tt.getState().currentSessionId,N=Mj(Oj(),k,P);N&&(c(!1),tt.getState().setCurrentSession(N.id,gn(N)))},e[2]=c,e[3]=w):w=e[3];const S=w,y=Yj;let I;e[4]!==S||e[5]!==t||e[6]!==r||e[7]!==f||e[8]!==i||e[9]!==c||e[10]!==d||e[11]!==m||e[12]!==n||e[13]!==o||e[14]!==a||e[15]!==u?(I=P=>{e:switch(P){case"about":{f(!0);break e}case"settings":{d(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{c(!1);const k=tt.getState(),N=is.getState().currentDirectory;r(k.currentSessionId&&N?{directoryOverride:N}:void 0);break e}case"new-worktree-session":{c(!1),Ig();break e}case"change-workspace":{b();break e}case"toggle-right-sidebar":{const k=is.getState().currentDirectory;if(!k)break e;const N=X.getState(),T=us(k),A=N.contextPanelByDirectory[T],$=A?Ku(A.tabs,N.contextSurfaceZones,"right",lr(A,"right").activeTabId):null;A?.isOpen?N.closeContextPanel(T):$?N.setActiveContextPanelTab(T,$):N.openContextSurface(T,"git");break e}case"open-right-sidebar-git":{const k=is.getState().currentDirectory;if(!k)break e;X.getState().openContextSurface(us(k),"git");break e}case"open-right-sidebar-files":{const k=is.getState().currentDirectory;if(!k)break e;X.getState().openContextSurface(us(k),"file");break e}case"toggle-terminal":{const k=is.getState().currentDirectory;if(!k)break e;X.getState().openContextSurface(us(k),"terminal");break e}case"toggle-context-panel-expanded":{Pg(is.getState().currentDirectory);break e}case"copy":{const k=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(k)||Lj();break e}case"theme-light":{m("light");break e}case"theme-dark":{m("dark");break e}case"theme-system":{m("system");break e}case"add-selection-to-chat":{Eg();break e}case"toggle-sidebar":{u();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{Oa(-1);break e}case"go-forward":{Oa(1);break e}case"previous-session":{S(-1);break e}case"next-session":{S(1);break e}case"previous-project":{y(-1);break e}case"next-project":{y(1);break e}case"help-dialog":{a();break e}case"download-logs":Ng().catch(()=>{_e.error(n("openCodeStatusDialog.toast.collectFailed"))})}},e[4]=S,e[5]=t,e[6]=r,e[7]=f,e[8]=i,e[9]=c,e[10]=d,e[11]=m,e[12]=n,e[13]=o,e[14]=a,e[15]=u,e[16]=I):I=e[16];const j=I;let R,_;e[17]!==j||e[18]!==g?(R=()=>{const P=N=>{const T=N.detail;T&&j(T)},k=()=>{g()};return window.addEventListener(_l,P),window.addEventListener(Al,k),()=>{window.removeEventListener(_l,P),window.removeEventListener(Al,k)}},_=[j,g],e[17]=j,e[18]=g,e[19]=R,e[20]=_):(R=e[19],_=e[20]),l.useEffect(R,_)};function Bj(t){return t.openNewSessionDraft}function zj(t){return t.toggleCommandPalette}function Wj(t){return t.setCommandPaletteOpen}function Uj(t){return t.toggleHelpDialog}function Vj(t){return t.toggleSidebar}function Hj(t){return t.setSessionSwitcherOpen}function qj(t){return t.setSettingsDialogOpen}function Gj(t){return t.setAboutDialogOpen}function Kj(t){return t.checkForUpdates}function Zj(){const{available:t,error:e}=bc.getState();if(e){_e.error("Failed to check for updates",{description:e});return}t||_e.success("You are on the latest version")}function Xj(){Ur.requestDirectoryDialog()}function Yj(t){const{activeProjectId:e,projects:n,setActiveProject:r}=Gt.getState();if(n.length===0)return;const o=n.findIndex(u=>u.id===e);let i=t>0?0:n.length-1;o>=0&&(i=(o+t+n.length)%n.length);const a=n[i];a&&r(a.id)}const Ol=(t,{isAdmitted:e,isPlaced:n,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||Yc(t)?!1:n||o.pinned&&r||o.work&&jc(t),Jj="openchamber:tray-action",Qj=5e3,e3=500,t3=20,Ml=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Fl=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,bu=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},wu=t=>t.title.trim()||"Question",s3=new Set,n3=(t,e)=>Og(t,e,s3,Wi.getState().rankById),r3=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},o3=(t,e,n,r,o)=>{if(!t)return"";const i=hr(n,r,t),a=e.project?.name,u=i?.label?.trim()||a?.trim()||r3(t),c=zr(t);let d=c&&o.get(c)||"";if(!d){for(const[f,p]of Vn.getState().directories)if(zr(f)===c){d=p.status?.current??"";break}}if(!d)for(const f of r.values()){const p=c?$r(f,c):void 0;if(p?.branch){d=p.branch;break}}return d?`${u} · ${d}`:u},i3=()=>{const{dictionary:t}=Ju.getState(),e=(c,d)=>Qu(t,c,d),{results:n,dropdownProviderIds:r,displayMode:o}=Pn.getState(),i=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:i,groups:[]};const a=new Map(n.map(c=>[c.providerId,c])),u=[];for(const c of Mg){if(!r.includes(c.id))continue;const d=a.get(c.id);if(!d||d.configured!==!0)continue;const f=[];for(const[m,h]of Object.entries(d.usage?.windows??{})){const x=i==="remaining"?h.remainingPercent:h.usedPercent;f.push({label:Lg(m),value:Fg(h,x,e)})}const p=!d.ok&&d.error?d.error:f.length===0?"No rate limits reported":null;u.push({provider:c.name,rows:f,status:p})}return{mode:i,groups:u}},a3=async()=>{try{if(eo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Zu();if(e&&ra(e,t))return"Local OpenChamber";const r=(await ki()).hosts.find(o=>e?ra(e,tc(o)):!1);return r?.label?.trim()?Xu(r.label.trim()):"Instance"}catch{return""}},l3=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=Yo()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,a]of o.children.entries()){const u=a.getState();u.vcs?.branch&&e.set(zr(i)??i,u.vcs.branch);for(const c of u.session)c?.id&&r.set(c.id,c.title);for(const[c,d]of Object.entries(u.session_status??{})){const f=d?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(c);(!m||m==="idle")&&t.set(c,p)}for(const[c,d]of Object.entries(u.permission??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:bu(f),directory:i,canSave:ed(f.save)})}for(const[c,d]of Object.entries(u.form??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:wu(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},c3=(t,e)=>{const n=ts.getState().activeSessions,r=Dg(n),o=j=>r.descendantsOf(j,"active").map(R=>R.id),i=Gt.getState().projects,a=tt.getState().availableWorktreesByProject,u=Ui.getState().ids,c=(j,R)=>{const _=gn(j),P=Fa(_,i,a);return Jr(_)||j.projectID===Yu?Ol(j,{isAdmitted:P,isPlaced:R.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):Ol(j,{isAdmitted:P,isPlaced:Zl(_)||hr(i,a,_)!==null,isPinned:Ag(u,j.directory,j.id),zones:R})},d=ec.getState(),f={chats:d.showChatsSection,pinned:d.showPinnedSection,work:X.getState().sessionWorkEnabled&&d.showWorkSection},p={chats:!0,pinned:!0,work:!0},m=X.getState().dockBadgeEnabled?n.filter(j=>Ma(j)&&c(j,f)).length:0;if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:m};const h=l3(),x=new Map(h.titleById);for(const j of n)j?.id&&j.title&&x.set(j.id,j.title);const g=Jc.getState().statusById,b=j=>{const R=h.statusById.get(j);return R&&R!=="idle"?R:g.get(j)?.status.type??R??"idle"},w=j=>{const R=j.map(_=>b(_));return R.includes("busy")?"busy":R.includes("retry")?"retry":"idle"},S=n.filter(j=>j?.id&&!j.parentID).filter(j=>c(j,p)).slice().sort(n3).slice(0,t3).map(j=>{const R=[j.id,...o(j.id)],_=gn(j)??"";return{id:j.id,title:j.title||"Untitled session",status:w(R),branch:_?h.branchByDirectory.get(_)??"":"",unseen:Ma(j)?1:0,hasError:_g(j),directory:_,subtitle:o3(_,j,i,a,h.branchByDirectory)}}),y=h.approvals.map(j=>({...j,sessionTitle:x.get(j.sessionId)||""})),I=new Set(y.map(j=>j.id));for(const[j,R]of Qc.getState().bySession){const _=x.get(j)||"";for(const P of R.permissions)I.has(P.id)||(I.add(P.id),y.push({kind:"permission",id:P.id,sessionId:j,sessionTitle:_,label:bu(P),directory:R.directory,canSave:ed(P.save)}));for(const P of[...R.forms,...R.pages])I.has(P.id)||(I.add(P.id),y.push({kind:"form",id:P.id,sessionId:j,sessionTitle:_,label:wu(P),directory:R.directory,canSave:!1}))}return{sessions:S,approvals:y.filter(j=>Fa(j.directory,i,a)),instanceName:t,usage:i3(),dockBadgeCount:m}},d3=()=>{l.useEffect(()=>{if(!Ml()||!Vo())return;const t=Fl();let e=!1,n="",r=null,o="";const i=()=>{if(e)return;const _=c3(o,t),P=JSON.stringify(_);P!==n&&(n=P,un("desktop_tray_update",_))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},e3))},u=ts.subscribe(()=>a()),c=X.subscribe((_,P)=>{(_.dockBadgeEnabled!==P.dockBadgeEnabled||_.sessionWorkEnabled!==P.sessionWorkEnabled)&&a()}),d=Gt.subscribe(()=>a()),f=tt.subscribe(()=>a()),p=Ui.subscribe(()=>a()),m=ec.subscribe((_,P)=>{(_.showChatsSection!==P.showChatsSection||_.showPinnedSection!==P.showPinnedSection||_.showWorkSection!==P.showWorkSection)&&a()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),u(),c(),d(),f(),p(),m()};if(!t)return i(),h;a3().then(_=>{e||(o=_,i())});const x=new Map,g=()=>{if(e)return;let _;try{_=Yo()}catch{return}const P=new Set;for(const[k,N]of _.children.entries())P.add(k),x.has(k)||x.set(k,N.subscribe(()=>a()));for(const[k,N]of x)P.has(k)||(N(),x.delete(k))};let b=null;try{b=Yo().subscribeRegistry(()=>{g(),a()})}catch{}g();const w=Vn.subscribe(()=>a()),S=Jc.subscribe(()=>a()),y=Qc.subscribe(()=>a()),I=Wi.subscribe(()=>a()),j=Pn.subscribe(()=>a());Pn.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:_,results:P}=Pn.getState();_.length>0&&_.some(N=>!P.some(T=>T.providerId===N))&&Pn.getState().fetchQuotas(_)});const R=window.setInterval(()=>{g(),i()},Qj);return i(),()=>{h(),window.clearInterval(R),w(),S(),y(),I(),j(),b?.();for(const _ of x.values())_();x.clear()}},[]),l.useEffect(()=>{if(!Ml()||!Fl()||!Vo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&Rg(o.sessionId,o.id,o.response).catch(()=>{_e.error("Failed to respond to permission request")})};let r=null;return e(Jj,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||n(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},u3=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,f3=(t,e,n,r)=>r||[t,e,n].filter(Boolean).join("|")||void 0,p3=t=>{t.kind!=="plugin"||!t.title||_e.info(t.title,{id:f3(t.kind,t.title,t.body,t.tag),description:t.body})},m3=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,h3=t=>{const e=Be.c(3),n=!0;let r,o;e[0]!==n?(r=()=>{if(!(Us()||!sc()||!globalThis.window))return Js(g3)},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function g3(t){if(t.type!=="notification")return;const e=X.getState();if(!e.nativeNotificationsEnabled)return;const n=u3();if(m3(t.payload,n)){p3(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&n)return;Jl()?.notifications?.notifyAgentCompletion(t.payload)}const x3=()=>{const t=Be.c(4),{t:e}=at(),n=X(b3);let r,o;t[0]!==n||t[1]!==e?(r=()=>Js(i=>{i.type==="browser-provider-reset"&&(n("builtin"),_e.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o)};function b3(t){return t.setBrowserProvider}const w3=()=>{const t=Be.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],l.useEffect(v3,e)};function y3(t){t.type==="guests-changed"?$g():t.type==="event-stream-ready"&&Bg()}function v3(){return Js(y3)}const S3=()=>{const t=Be.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>Js(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=zt.getState().providers,u=c=>a.find(d=>d.id===c);if(i.kind==="account"){const c=u(i.providerId)?.name||i.providerId;_e.info(i.fromAccount?e("chat.limitFailover.toast.account",{provider:c,from:i.fromAccount,to:i.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:c,to:i.toAccount}));return}_e.info(e("chat.limitFailover.toast.model",{model:La(u(i.providerId),i.modelId),fallback:La(u(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)},Ll="relay-limit-reached",k3=()=>{const t=Be.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>{const o=()=>{_e.error(e("relayConnection.limitReached.title"),{id:Ll,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:j3}})};return oa(nc()?.getStatus())&&o(),ef(a=>{oa(a)?o():(a.state==="connected"||a.state==="idle")&&_e.dismiss(Ll)})},r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)};function j3(){return nc()?.retry()}const $l=()=>{tf()||(zg(),Wg(xp.map(t=>t.id)))},C3=(t,e)=>{const n=Be.c(5);let r;n[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback($l,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout($l,3e3);return()=>clearTimeout(i)},n[0]=t,n[1]=r):r=n[1];let o;n[2]!==e||n[3]!==t?(o=[t,e],n[2]=e,n[3]=t,n[4]=o):o=n[4],l.useEffect(r,o)},Bl="pwa-install-toast-shown",zl="pwa-install-toast-dismissed",T3=()=>{const t=Be.c(6),{browserTab:e}=bp(),{t:n}=at(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let a,u;t[3]!==e?(a=()=>{if(typeof window>"u"||!sc()||!e)return;let c=null,d=null;const f=()=>{d!==null&&(_e.dismiss(d),d=null)},p=async()=>{if(!c)return;const x=c;c=null,f(),await x.prompt();const{outcome:g}=await x.userChoice;g==="accepted"&&_e.success(r.current("pwa.installPrompt.started"))},m=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),c=g;const b=ia(),w=sf();wp({dismissed:b.getItem(zl),sessionShown:w.getItem(Bl),hasActiveToast:d!==null})&&(w.setItem(Bl,"true"),d=_e.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{ia().setItem(zl,"true"),f()}}}))},h=()=>{c=null,f(),_e.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},u=[e],t[3]=e,t[4]=a,t[5]=u):(a=t[4],u=t[5]),l.useEffect(a,u)},yu=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,N3=()=>{xs.setState({byRoot:{},runtimeSnapshots:{}});const t=X.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const n of Si)t.closeContextZone(e,n)},E3=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",vu=async(t,e)=>{const n=(await ki()).hosts.find(o=>o.id===t);if(!n)throw new Error("host-not-found");if(n.relay){await af(n.id,e);return}const r=lf(tc(n));if(!r)throw new Error("host-not-found");cf({apiBaseUrl:r,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:df(n),sshForwarded:n.sshForwarded===!0})},P3=async t=>{const e=await ki(),n=await rf(t,e.hosts);await of({hosts:n.hosts,defaultHostId:e.defaultHostId||n.hostId,initialHostChoiceCompleted:!0}),await vu(n.hostId,{reconnectActive:!0})},I3=async t=>{const e=await nf();for(const n of e)try{n.type==="pairing"?await P3(n.link):await vu(n.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",n.type,o),t(E3(o))}},xi="project-config-invalid",R3=()=>{const t=Be.c(9),{t:e}=at(),n=zt(D3);let r;t[0]!==n?(r=m=>m.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const o=zt(r),[i,a]=Wt.useState(!1);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const m=zt.getState(),h=m.activeDirectoryKey;a(!0),Promise.all([m.loadProviders({directory:h,source:"projectConfigError:retry"}),m.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=u):u=t[2];const c=u;let d,f;t[3]!==o||t[4]!==i||t[5]!==e?(d=()=>{if(!o){_e.dismiss(xi);return}_e.error(e("projectConfigError.toast.title"),{id:xi,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:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&s.jsx(fs,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),i||c()}}})},f=[o,i,c,e],t[3]=o,t[4]=i,t[5]=e,t[6]=d,t[7]=f):(d=t[6],f=t[7]),Wt.useEffect(d,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],Wt.useEffect(A3,p),null};function D3(t){return t.activeDirectoryKey}function _3(){_e.dismiss(xi)}function A3(){return _3}const O3="\x1B",M3=new RegExp(`${O3}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Tr=Ps().transform(t=>t.replace(M3,"").trim()).nullish(),F3=Qs({isOpenCodeReady:dr().optional(),openCodeRunning:dr().optional(),lastOpenCodeError:Tr,opencodeBinaryResolved:Tr,lastOpenCodeLaunchDiagnostics:Qs({sourceBinary:Tr,binary:Tr}).nullish()}),L3=async(t,e=Vs)=>{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=F3.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}},$3=(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"}},B3=Qs({openchamberVersion:Ps()}),z3=async(t,e=Vs)=>{const n=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)return null;const r=B3.safeParse(await n.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},W3=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function U3({version:t}){const{t:e}=at(),[n,r]=l.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const u=await vp();r(u.available&&!u.installBlocked?{kind:"available",info:u}:{kind:"manual",info:u,error:null})}catch(u){r({kind:"manual",info:null,error:u instanceof Error?u.message:null})}},i=n.kind==="manual"?n:null,a=i?.info?.updateCommand||"openchamber update";return s.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),s.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),s.jsxs(ft,{type:"button",onClick:()=>{o()},disabled:n.kind==="checking",children:[s.jsx(se,{name:n.kind==="checking"?"loader":"download",className:n.kind==="checking"?"size-4 animate-spin":"size-4"}),n.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&s.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),s.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),s.jsx(yp,{open:n.kind==="available",onOpenChange:u=>{u||r({kind:"idle"})},info:n.kind==="available"?n.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Wl=mr(()=>At(()=>import("./OnboardingScreen-CIyOLCq2.js"),__vite__mapDeps([261,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.OnboardingScreen}))),V3=()=>At(()=>import("./AboutDialog-DBDN-gwQ.js"),__vite__mapDeps([262,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,239])).then(t=>t.AboutDialog),H3=()=>At(()=>import("./MemoryDebugPanel-C7shSvtT.js"),__vite__mapDeps([263,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.MemoryDebugPanel),q3=()=>{const t=Be.c(6),e=X(Y3),n=X(J3);let r;t[0]!==n?(r=()=>n(!1),t[0]=n,t[1]=r):r=t[1];const o=fo(e,V3,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==n?(i=s.jsx(o,{open:e,onOpenChange:n}),t[2]=o,t[3]=e,t[4]=n,t[5]=i):i=t[5],i},G3=t=>{const e=Be.c(3),{onClose:n}=t,r=fo(!0,H3,n);let o;return e[0]!==r||e[1]!==n?(o=r?s.jsx(r,{onClose:n}):null,e[0]=r,e[1]=n,e[2]=o):o=e[2],o},K3=t=>{const e=Be.c(47),{onRetry:n,isRetrying:r}=t,{t:o}=at(),[i,a]=l.useState(null);let u,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const k=new AbortController,N=as(),T=setTimeout(()=>k.abort(),5e3);return L3(k.signal).then(A=>{!k.signal.aborted&&as()===N&&a(A)}).catch(Q3).finally(()=>clearTimeout(T)),()=>{k.abort(),clearTimeout(T)}},c=[],e[0]=u,e[1]=c):(u=e[0],c=e[1]),l.useEffect(u,c);const[d,f]=l.useState(null);let p,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const k=new AbortController,N=as(),T=setTimeout(()=>k.abort(),5e3);return z3(k.signal).then(A=>{k.signal.aborted||as()!==N||f(A&&W3(A)?A:null)}).catch(e4).finally(()=>clearTimeout(T)),()=>{k.abort(),clearTimeout(T)}},m=[],e[2]=p,e[3]=m):(p=e[2],m=e[3]),l.useEffect(p,m);const h=zt(t4),x=i?null:h?.message??null;if(d){let k;e[4]!==d?(k=s.jsx(U3,{version:d}),e[4]=d,e[5]=k):k=e[5];let N;e[6]!==r||e[7]!==o?(N=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=N):N=e[8];let T;e[9]!==r||e[10]!==n||e[11]!==N?(T=s.jsx(ft,{type:"button",variant:"outline",onClick:n,disabled:r,children:N}),e[9]=r,e[10]=n,e[11]=N,e[12]=T):T=e[12];let A;return e[13]!==k||e[14]!==T?(A=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:[k,T]})}),e[13]=k,e[14]=T,e[15]=A):A=e[15],A}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let b;e[18]!==g?(b=s.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let w;e[20]!==i||e[21]!==h||e[22]!==o?(w=o($3(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=w):w=e[23];let S;e[24]!==w?(S=s.jsx("p",{className:"typography-markdown text-muted-foreground",children:w}),e[24]=w,e[25]=S):S=e[25];let y;e[26]!==b||e[27]!==S?(y=s.jsxs("div",{className:"flex flex-col gap-2",children:[b,S]}),e[26]=b,e[27]=S,e[28]=y):y=e[28];let I;e[29]!==x||e[30]!==o?(I=x&&s.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("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:x})]}),e[29]=x,e[30]=o,e[31]=I):I=e[31];let j;e[32]!==i||e[33]!==o?(j=i&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("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:i.error})]})]}),e[32]=i,e[33]=o,e[34]=j):j=e[34];let R;e[35]!==r||e[36]!==o?(R=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=R):R=e[37];let _;e[38]!==r||e[39]!==n||e[40]!==R?(_=s.jsx(ft,{type:"button",onClick:n,disabled:r,children:R}),e[38]=r,e[39]=n,e[40]=R,e[41]=_):_=e[41];let P;return e[42]!==I||e[43]!==j||e[44]!==_||e[45]!==y?(P=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:[y,I,j,_]})}),e[42]=I,e[43]=j,e[44]=_,e[45]=y,e[46]=P):P=e[46],P};function Z3({apis:t}){l.useEffect(()=>Ug(),[]),l.useEffect(()=>{uf("App:mounted"),ff()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=zt(O=>O.initializeApp),n=zt(O=>O.isInitialized),r=zt(O=>O.isConnected),o=zt(O=>O.providersLoaded),i=zt(O=>O.agentsLoaded),a=zt(O=>O.loadProviders),u=zt(O=>O.loadAgents),c=tt(O=>O.error),d=tt(O=>O.clearError),f=is(O=>O.currentDirectory),p=is(O=>O.isSwitchingDirectory),[m,h]=l.useState(!1),x=hn(O=>O.refreshAll),g=Gl(O=>O.refresh),[b,w]=l.useState(()=>t.runtime.isVSCode),[S,y]=l.useState(!1),[I,j]=l.useState(0),[R,_]=l.useState(0),[P,k]=l.useState(!1),N=X(O=>O.wideChatLayoutEnabled),T=X(O=>O.mobileKeyboardMode),A=l.useMemo(()=>Us(),[]),[$,K]=l.useState(()=>aa()),[q,M]=l.useState(()=>{const O=jo();return O!==null?la({isDesktopShell:!0,bootOutcome:O}):null}),z=l.useRef(!1),{t:ne}=at(),H=l.useRef(!1);l.useEffect(()=>{if(!n||$!=="valid"||H.current)return;const O=jo();O?.target!=="local"||O.status!=="ok"||!O.sshStartupFallbackHostId||(H.current=!0,_e.error(ne("desktopHostSwitcher.startup.title"),{description:ne("desktopHostSwitcher.startup.fellBackToLocal")}))},[$,n,ne]);const V=l.useRef(!1);l.useEffect(()=>{!n||!yu()||V.current||(V.current=!0,_e.info(ne("desktopSafeStart.title"),{description:ne("desktopSafeStart.description"),duration:1/0}))},[n,ne]),l.useEffect(()=>(ca(m),Rl(m),()=>{ca(!1),Rl(!1)}),[m]),l.useEffect(()=>{pf(T)},[T]),l.useEffect(()=>{w(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>Ql(O=>{kp(O)&&jp(O),_(Y=>Y+1),y(!1),j(Y=>Y+1)}),[]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",N),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[N]),l.useEffect(()=>(da(t),()=>da(null)),[t]),l.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:!0}),Vg(t.trackers))},[t.sourceControl,t.trackers,r,x,g,R]),Hg();const F=$==="valid",C=q?.screen==="main";l.useEffect(()=>{if(!mf({isDesktopShell:A,bootOutcomeKnown:F}))return;qg();const O=setTimeout(()=>{const Y=document.getElementById("initial-loading");Y&&(Y.classList.add("fade-out"),setTimeout(()=>{Y.remove()},300))},150);return()=>clearTimeout(O)},[A,F]),l.useEffect(()=>{if(!A||$!=="malformed")return;const O=document.getElementById("initial-loading");O&&(O.textContent="Desktop startup failed — please restart the app.")},[A,$]),l.useEffect(()=>{b||e()},[e,b]),l.useEffect(()=>{if(b||n)return;let O=!0,Y,Z=0;const we=10,L=1e3,pe=async()=>{if(!O)return;if(Z>=we){y(!0);return}const je=zt.getState();if(je.isInitialized){y(!1);return}Z+=1,await je.initializeApp();const Ee=zt.getState();if(!O)return;if(Ee.isInitialized){y(!1);return}if(Z>=we){y(!0);return}const Se=Math.min(L*Math.pow(2,Z-1),4e3);Y=setTimeout(pe,Se)};return Y=setTimeout(pe,L),()=>{O=!1,Y&&clearTimeout(Y)}},[I,n,b]),l.useEffect(()=>{n&&y(!1)},[n]),l.useEffect(()=>{if(!S)return;const O=document.getElementById("initial-loading");O&&(O.classList.add("fade-out"),setTimeout(()=>{O.remove()},300))},[S]),l.useEffect(()=>{if(b||!r||o&&i)return;let O=!0,Y=0;const Z=15,we=async()=>{const pe=zt.getState();if(!(pe.providersLoaded&&pe.agentsLoaded))try{pe.providersLoaded||await a({source:"startupRecovery"}),zt.getState().agentsLoaded||await u({source:"startupRecovery"})}catch{}};we();const L=setInterval(()=>{if(O){if(++Y>=Z){clearInterval(L);return}we()}},2e3);return()=>{O=!1,clearInterval(L)}},[r,b,u,a,o,i]),l.useEffect(()=>{p||b||r&&qo.setDirectory(f)},[f,p,r,b]),l.useEffect(()=>{if(typeof window>"u")return;const O=Y=>{const Z=Y.detail,we=typeof Z?.sessionId=="string"?Z.sessionId.trim():"";if(!we)return;const L=typeof Z?.directory=="string"&&Z.directory.trim().length>0?Z.directory.trim():null,pe=typeof Z?.messageId=="string"&&Z.messageId.trim()||null;ua(we,String(Z?.runtimeKey??"").trim(),pe)||i1(we,{directory:L,messageId:pe})};return window.addEventListener("openchamber:open-session",O),hf().then(Y=>{for(const Z of Y)ua(Z.sessionId,Z.runtimeKey,Z.messageId)||Gg(Z.sessionId,Z.messageId)}),()=>window.removeEventListener("openchamber:open-session",O)},[]),l.useEffect(()=>{if(!Us())return;const O=()=>{I3(Y=>{_e.error(ne(Y==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":Y==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",O),O(),()=>window.removeEventListener("openchamber:host-actions-ready",O)},[ne]);const te=l.useRef({attempt:null,running:!1,done:!1});l.useLayoutEffect(()=>{const O=te.current;O.attempt||(O.attempt=Cp({selectNow:!Tp().sessionId}))},[]),l.useEffect(()=>{const O=te.current,Y=()=>{const Z=O.attempt;if(!Z||O.running||O.done)return;const we=zt.getState().isInitialized;O.running=!0,Z().then(L=>{if(O.running=!1,L!=="failed"||we){O.done=!0;return}zt.getState().isInitialized&&Y()})};Y()},[n]),l.useEffect(()=>{if(typeof window>"u")return;const O=()=>{un("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Nr()})};return window.addEventListener("openchamber:open-mini-chat",O),()=>window.removeEventListener("openchamber:open-mini-chat",O)},[]),l.useEffect(()=>{if(typeof window>"u")return;const O=()=>{const Y=tt.getState().currentSessionId;Y&&Kc(Y)};return window.addEventListener("focus",O),()=>window.removeEventListener("focus",O)},[]),l.useEffect(()=>{if(typeof window>"u")return;const O=Y=>{const Z=Y.detail,we=typeof Z?.directory=="string"&&Z.directory.trim().length>0?Z.directory.trim():null,L=typeof Z?.projectId=="string"&&Z.projectId.trim().length>0?Z.projectId.trim():null,pe=!!(we||L);X.getState().setSessionSwitcherOpen(!1),tt.getState().openNewSessionDraft({target:pe?"project":"chat",selectedProjectId:pe?L:null,directoryOverride:pe?we:null,preserveDirectoryOverride:!!we})};return window.addEventListener("openchamber:open-draft-session",O),()=>window.removeEventListener("openchamber:open-draft-session",O)},[]),l.useEffect(()=>{typeof window>"u"||!n||p||z.current||(z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),Kg(),h3(),Np(f||null),x3(),Ep(t.sourceControl),Pp(t.trackers),w3(),S3(),Zg(),Ip(),k3(),C3(n&&r,R),T3(),Xg(),w1(),Rp();const re=l.useCallback(()=>{h(O=>!O)},[]);$j(re),d3(),y1(!0),l.useEffect(()=>{const O=()=>h(Y=>!Y);return window.addEventListener("openchamber:memory-debug-toggle",O),()=>window.removeEventListener("openchamber:memory-debug-toggle",O)},[]),l.useEffect(()=>{c&&setTimeout(()=>d(),5e3)},[d,c]),l.useEffect(()=>{if(!A||$!=="not-injected")return;let O=!1,Y=0;const Z=200,we=2e3,L=50,pe=()=>{if(O)return;Y++;const je=aa();if(je!=="not-injected"){if(O=!0,K(je),je==="valid"){const Se=jo();Se&&M(la({isDesktopShell:!0,bootOutcome:Se}))}return}const Ee=Math.min(Z*Math.pow(1.1,Y),we);if(Y>=L){const Se=document.getElementById("initial-loading");Se&&!Se.textContent?.includes("taking longer")&&(Se.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(pe,Ee)};return window.setTimeout(pe,Z),()=>{O=!0}},[A,$]);const Q=l.useCallback(async()=>{if(gf({isDesktopShell:Us(),isDesktopLocalOriginActive:eo()})){await xf();return}window.location.reload()},[]),ee=l.useCallback(async()=>{if(!P){y(!1),k(!0);try{await zt.getState().initializeApp()}finally{k(!1)}zt.getState().isInitialized||j(O=>O+1)}},[P]),le=O=>{if(O.screen==="recovery")return O.variant};if(A&&q&&q.screen!=="main"){if(q.screen==="chooser")return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Wl,{mode:"first-launch",localAvailable:q.localAvailable!==!1,onCliAvailable:Q,onChooseRemote:()=>{}})})})});const O=le(q),Y=q.screen==="recovery"&&"url"in q?q.url:void 0,Z=q.screen==="recovery"&&"hostId"in q?q.hostId:void 0;return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Wl,{mode:"recovery",recoveryVariant:O,recoveryHostUrl:Y,recoveryHostLabel:void 0,recoveryHostId:Z,localAvailable:q.localAvailable!==!1,onCliAvailable:Q})})})})}return S&&!n&&!b?s.jsx(Qt,{children:s.jsx(K3,{onRetry:()=>{ee()},isRetrying:P},R)}):s.jsx(Qt,{children:s.jsx(Yg,{sdk:qo.getSdkClient(),directory:f||"",children:s.jsx(Jg,{apis:t,children:s.jsx(Dp,{children:s.jsx(Qg,{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(e1,{backgroundWorkEnabled:!0}),s.jsx(_p,{}),s.jsx(R3,{}),s.jsx(Wk,{}),A?s.jsx(Ap,{ready:F&&C}):null,s.jsx(t1,{}),s.jsx(s1,{}),s.jsx(n1,{}),s.jsx(r1,{}),s.jsx(o1,{}),s.jsx(Op,{}),s.jsx(q3,{}),m&&s.jsx(G3,{onClose:()=>h(!1)})]})})})})},R)})}function X3(t){const e=Be.c(2);let n;return e[0]!==t?(n=s.jsx(Sp,{children:s.jsx(Z3,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function Y3(t){return t.isAboutDialogOpen}function J3(t){return t.setAboutDialogOpen}function Q3(){}function e4(){}function t4(t){return t.lastInitFailure}const s4=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();bf();yu()&&N3();Mp();Fp();wf().then(()=>{a1().catch(t=>{console.error("[main] settings init failed:",t)}),l1(),c1(),d1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Su=document.getElementById("root");if(!Su)throw new Error("Root element not found");u1();ku.createRoot(Su).render(s.jsx(Wt.StrictMode,{children:s.jsx(f1,{children:s.jsx(p1,{children:s.jsx(m1,{children:s.jsx(h1,{children:s.jsx(X3,{apis:s4})})})})})}));const y4=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Ha as P,qx as a,Nb as b,w4 as g,y4 as m,Aj as o,b4 as r,gd as u};
498
+ `),w0=t=>{const e=Be.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:u}=at();if(n.length===0)return null;let c;e[0]!==u?(c=u("contextPanel.browser.history.label"),e[0]=u,e[1]=c):c=e[1];let d;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==u){let p;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==u?(p=(m,h)=>s.jsxs("div",{role:"option","aria-selected":h===r,className:$e("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",h===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:x=>{x.preventDefault(),o(m.url)},onPointerEnter:()=>a(h),children:[s.jsx(se,{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:m.title||to(m.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),s.jsx("button",{type:"button",className:$e("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":u("contextPanel.browser.history.forget"),title:u("contextPanel.browser.history.forget"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),i(m.url)},children:s.jsx(se,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=u,e[14]=p):p=e[14],d=n.map(p),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=o,e[7]=u,e[8]=d}else d=e[8];let f;return e[15]!==c||e[16]!==d?(f=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":c,children:d}),e[15]=c,e[16]=d,e[17]=f):f=e[17],f},Ss=t=>{const e=Be.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:a}=t,u=a?"secondary":"ghost",c=a&&"text-foreground";let d;e[0]!==c?(d=$e("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",c),e[0]=c,e[1]=d):d=e[1];let f;e[2]!==n?(f=s.jsx(se,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==u||e[9]!==d||e[10]!==f?(p=s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{type:"button",variant:u,size:"xs",className:d,onClick:o,disabled:i,"aria-label":r,"aria-pressed":a,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=a,e[8]=u,e[9]=d,e[10]=f,e[11]=p):p=e[11];let m;e[12]!==r?(m=s.jsx($t,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let h;return e[14]!==p||e[15]!==m?(h=s.jsxs(Lt,{children:[p,m]}),e[14]=p,e[15]=m,e[16]=h):h=e[16],h},Wd=t=>{const e=Be.c(110),{address:n,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:u,onBack:c,onForward:d,onReload:f,onOpenExternal:p,canOpenExternal:m,canGoBack:h,canGoForward:x,isLoading:g,onAnnotate:b,onOpenDevTools:w,isAnnotating:S,onHardReload:y,onZoomIn:I,onZoomOut:j,onZoomReset:R,zoomPercent:_,onClearCookies:P,onClearCache:k,onToggleDeviceBar:N,isDeviceBarOpen:T}=t;let A;e[0]!==o?(A=o===void 0?[]:o,e[0]=o,e[1]=A):A=e[1];const $=A,K=m===void 0?!0:m,q=_===void 0?100:_,{t:M}=at(),[z,ne]=l.useState(!1),[H,V]=l.useState(-1);let F;e[2]!==z||e[3]!==$?(F=z?$:[],e[2]=z,e[3]=$,e[4]=F):F=e[4];const C=F;let te;e[5]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{V(-1)},e[5]=te):te=e[5];let re;e[6]!==n||e[7]!==z?(re=[n,z],e[6]=n,e[7]=z,e[8]=re):re=e[8],l.useEffect(te,re);let Q;e[9]!==u?(Q=qe=>{ne(!1),V(-1),u(qe)},e[9]=u,e[10]=Q):Q=e[10];const ee=Q;let le;e[11]!==H||e[12]!==ee||e[13]!==C?(le=qe=>{if(C.length!==0){if(qe.key==="ArrowDown"||qe.key==="ArrowUp"){qe.preventDefault();const et=qe.key==="ArrowDown"?1:-1,He=C.length;V(Ye=>{const dt=Ye+et;return dt<-1?He-1:dt>=He?-1:dt});return}if(qe.key==="Escape"&&H>=0){qe.preventDefault(),V(-1);return}if(qe.key==="Enter"&&H>=0){qe.preventDefault();const et=C[H];et&&ee(et.url)}}},e[11]=H,e[12]=ee,e[13]=C,e[14]=le):le=e[14];const O=le;let Y;e[15]!==M?(Y=M("contextPanel.browser.back"),e[15]=M,e[16]=Y):Y=e[16];const Z=!h;let we;e[17]!==c||e[18]!==Y||e[19]!==Z?(we=s.jsx(Ss,{icon:"arrow-left",label:Y,onClick:c,disabled:Z}),e[17]=c,e[18]=Y,e[19]=Z,e[20]=we):we=e[20];let L;e[21]!==M?(L=M("contextPanel.browser.forward"),e[21]=M,e[22]=L):L=e[22];const pe=!x;let je;e[23]!==d||e[24]!==L||e[25]!==pe?(je=s.jsx(Ss,{icon:"arrow-right",label:L,onClick:d,disabled:pe}),e[23]=d,e[24]=L,e[25]=pe,e[26]=je):je=e[26];let Ee;e[27]!==g||e[28]!==M?(Ee=M(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=M,e[29]=Ee):Ee=e[29];let Se;e[30]!==f||e[31]!==Ee?(Se=s.jsx(Ss,{icon:"refresh",label:Ee,onClick:f}),e[30]=f,e[31]=Ee,e[32]=Se):Se=e[32];let Le;e[33]!==y||e[34]!==M?(Le=y?s.jsx(Ss,{icon:"restart",label:M("contextPanel.browser.hardReload"),onClick:y}):null,e[33]=y,e[34]=M,e[35]=Le):Le=e[35];let Pe;e[36]!==n||e[37]!==ee?(Pe=qe=>{qe.preventDefault(),ee(n)},e[36]=n,e[37]=ee,e[38]=Pe):Pe=e[38];let Ve;e[39]!==r?(Ve=r?s.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:s.jsx(se,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=Ve):Ve=e[40];let Oe;e[41]!==a?(Oe=qe=>a(qe.target.value),e[41]=a,e[42]=Oe):Oe=e[42];let be,ye;e[43]===Symbol.for("react.memo_cache_sentinel")?(be=()=>ne(!0),ye=()=>ne(!1),e[43]=be,e[44]=ye):(be=e[43],ye=e[44]);const Ue=C.length>0,Te=r&&"ps-8";let Me;e[45]!==Te?(Me=$e("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",Te,"typography-micro text-foreground outline-none"),e[45]=Te,e[46]=Me):Me=e[46];let Re;e[47]!==M?(Re=M("contextPanel.browser.addressAria"),e[47]=M,e[48]=Re):Re=e[48];let ze;e[49]!==n||e[50]!==O||e[51]!==Oe||e[52]!==Ue||e[53]!==Me||e[54]!==Re?(ze=s.jsx("input",{value:n,onChange:Oe,onFocus:be,onBlur:ye,onKeyDown:O,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Ue,"aria-controls":"openchamber-browser-address-suggestions",className:Me,"aria-label":Re}),e[49]=n,e[50]=O,e[51]=Oe,e[52]=Ue,e[53]=Me,e[54]=Re,e[55]=ze):ze=e[55];let B;e[56]!==i?(B=qe=>i?.(qe),e[56]=i,e[57]=B):B=e[57];let ce;e[58]!==H||e[59]!==ee||e[60]!==B||e[61]!==C?(ce=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(w0,{entries:C,activeIndex:H,onSelect:ee,onForget:B,onHighlight:V})}),e[58]=H,e[59]=ee,e[60]=B,e[61]=C,e[62]=ce):ce=e[62];let G;e[63]!==Pe||e[64]!==Ve||e[65]!==ze||e[66]!==ce?(G=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Pe,children:[Ve,ze,ce]}),e[63]=Pe,e[64]=Ve,e[65]=ze,e[66]=ce,e[67]=G):G=e[67];let Ce;e[68]!==I||e[69]!==j||e[70]!==R||e[71]!==M||e[72]!==q?(Ce=j&&I?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(Ss,{icon:"subtract",label:M("contextPanel.browser.zoomOut"),onClick:j}),q!==100&&R?s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsxs(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:R,"aria-label":M("contextPanel.browser.zoomReset"),children:[q,"%"]})}),s.jsx($t,{sideOffset:6,children:M("contextPanel.browser.zoomReset")})]}):null,s.jsx(Ss,{icon:"add",label:M("contextPanel.browser.zoomIn"),onClick:I})]}):null,e[68]=I,e[69]=j,e[70]=R,e[71]=M,e[72]=q,e[73]=Ce):Ce=e[73];let J;e[74]!==P||e[75]!==M?(J=P?s.jsx(Ss,{icon:"delete-bin",label:M("contextPanel.browser.clearCookies"),onClick:P}):null,e[74]=P,e[75]=M,e[76]=J):J=e[76];let Ne;e[77]!==k||e[78]!==M?(Ne=k?s.jsx(Ss,{icon:"database-2",label:M("contextPanel.browser.clearCache"),onClick:k}):null,e[77]=k,e[78]=M,e[79]=Ne):Ne=e[79];let Ae;e[80]!==T||e[81]!==N||e[82]!==M?(Ae=N?s.jsx(Ss,{icon:"smartphone",label:M("contextPanel.browser.deviceToolbar"),onClick:N,pressed:T}):null,e[80]=T,e[81]=N,e[82]=M,e[83]=Ae):Ae=e[83];let Ie;e[84]!==S||e[85]!==b||e[86]!==M?(Ie=b?s.jsx(Ss,{icon:"markup",label:M("contextPanel.browser.annotate.toggle"),onClick:b,pressed:S}):null,e[84]=S,e[85]=b,e[86]=M,e[87]=Ie):Ie=e[87];let De;e[88]!==w||e[89]!==M?(De=w?s.jsx(Ss,{icon:"terminal-box",label:M("contextPanel.browser.devTools"),onClick:w}):null,e[88]=w,e[89]=M,e[90]=De):De=e[90];let We;e[91]!==M?(We=M("contextPanel.browser.openExternal"),e[91]=M,e[92]=We):We=e[92];const Ke=!K;let Ze;e[93]!==p||e[94]!==We||e[95]!==Ke?(Ze=s.jsx(Ss,{icon:"external-link",label:We,onClick:p,disabled:Ke}),e[93]=p,e[94]=We,e[95]=Ke,e[96]=Ze):Ze=e[96];let Qe;return e[97]!==we||e[98]!==je||e[99]!==Se||e[100]!==Le||e[101]!==G||e[102]!==Ce||e[103]!==J||e[104]!==Ne||e[105]!==Ae||e[106]!==Ie||e[107]!==De||e[108]!==Ze?(Qe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[we,je,Se,Le,G,Ce,J,Ne,Ae,Ie,De,Ze]}),e[97]=we,e[98]=je,e[99]=Se,e[100]=Le,e[101]=G,e[102]=Ce,e[103]=J,e[104]=Ne,e[105]=Ae,e[106]=Ie,e[107]=De,e[108]=Ze,e[109]=Qe):Qe=e[109],Qe},Gr={kind:"fill"},pl=240,y0=3840,Ud=[{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}],ml=t=>Number.isFinite(t)?Math.round(Math.min(y0,Math.max(pl,t))):pl,Kr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Vd=t=>{const e=Ud.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},v0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},S0=(t,e)=>{const n=Kr(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},k0=["mobile","tablet","desktop","fill"],j0={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},hl=t=>typeof t=="string"&&k0.includes(t),ui=t=>t==="fill"?Gr:Vd(j0[t])??Gr,Sr=t=>{const e=Kr(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=ui(n),o=Kr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},C0=t=>{const e=Be.c(70),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:u}=at();let c;e[0]!==n?(c=Kr(n),e[0]=n,e[1]=c):c=e[1];const d=c,f=n.kind==="preset"?n.id:"";let p;e[2]!==r||e[3]!==d?(p=(le,O)=>{const Y=Number.parseInt(O,10);if(!Number.isFinite(Y))return;const Z=d??{width:1280,height:800};r({kind:"custom",width:ml(le==="width"?Y:Z.width),height:ml(le==="height"?Y:Z.height)})},e[2]=r,e[3]=d,e[4]=p):p=e[4];const m=p;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=$e("oc-raised oc-field h-6 w-14 rounded-full bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none"),e[5]=h):h=e[5];const x=h;let g;e[6]!==r?(g=le=>{const O=Vd(le.target.value);r(O??Gr)},e[6]=r,e[7]=g):g=e[7];let b;e[8]!==u?(b=u("contextPanel.browser.device.preset"),e[8]=u,e[9]=b):b=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=$e("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=w):w=e[10];let S;e[11]!==u?(S=u("contextPanel.browser.device.responsive"),e[11]=u,e[12]=S):S=e[12];let y;e[13]!==S?(y=s.jsx("option",{value:"",children:S}),e[13]=S,e[14]=y):y=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=Ud.map(T0),e[15]=I):I=e[15];let j;e[16]!==f||e[17]!==g||e[18]!==b||e[19]!==y?(j=s.jsxs("select",{value:f,onChange:g,"aria-label":b,className:w,children:[y,I]}),e[16]=f,e[17]=g,e[18]=b,e[19]=y,e[20]=j):j=e[20];const R=d?String(d.width):"";let _;e[21]!==m?(_=le=>m("width",le.target.value),e[21]=m,e[22]=_):_=e[22];let P;e[23]!==u?(P=u("contextPanel.browser.device.width"),e[23]=u,e[24]=P):P=e[24];let k;e[25]!==R||e[26]!==_||e[27]!==P?(k=s.jsx("input",{value:R,onChange:_,placeholder:"—",inputMode:"numeric","aria-label":P,className:x}),e[25]=R,e[26]=_,e[27]=P,e[28]=k):k=e[28];let N;e[29]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=N):N=e[29];const T=d?String(d.height):"";let A;e[30]!==m?(A=le=>m("height",le.target.value),e[30]=m,e[31]=A):A=e[31];let $;e[32]!==u?($=u("contextPanel.browser.device.height"),e[32]=u,e[33]=$):$=e[33];let K;e[34]!==T||e[35]!==A||e[36]!==$?(K=s.jsx("input",{value:T,onChange:A,placeholder:"—",inputMode:"numeric","aria-label":$,className:x}),e[34]=T,e[35]=A,e[36]=$,e[37]=K):K=e[37];let q;e[38]!==r||e[39]!==n?(q=()=>r(v0(n)),e[38]=r,e[39]=n,e[40]=q):q=e[40];const M=!d;let z;e[41]!==u?(z=u("contextPanel.browser.device.rotate"),e[41]=u,e[42]=z):z=e[42];let ne;e[43]===Symbol.for("react.memo_cache_sentinel")?(ne=s.jsx(se,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=ne):ne=e[43];let H;e[44]!==q||e[45]!==M||e[46]!==z?(H=s.jsx(Ft,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:q,disabled:M,"aria-label":z,children:ne})}),e[44]=q,e[45]=M,e[46]=z,e[47]=H):H=e[47];let V;e[48]!==u?(V=u("contextPanel.browser.device.rotate"),e[48]=u,e[49]=V):V=e[49];let F;e[50]!==V?(F=s.jsx($t,{sideOffset:6,children:V}),e[50]=V,e[51]=F):F=e[51];let C;e[52]!==H||e[53]!==F?(C=s.jsxs(Lt,{children:[H,F]}),e[52]=H,e[53]=F,e[54]=C):C=e[54];let te;e[55]!==a||e[56]!==d?(te=d&&a<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[55]=a,e[56]=d,e[57]=te):te=e[57];let re;e[58]===Symbol.for("react.memo_cache_sentinel")?(re=["system","light","dark"],e[58]=re):re=e[58];let Q;e[59]!==o||e[60]!==i||e[61]!==u?(Q=s.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:re.map(le=>s.jsx(ft,{type:"button",variant:o===le?"secondary":"ghost",size:"xs",className:$e("shrink-0 rounded-full px-2.5 typography-micro",o===le?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(le),"aria-pressed":o===le,children:u(le==="system"?"contextPanel.browser.device.schemeSystem":le==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},le))}),e[59]=o,e[60]=i,e[61]=u,e[62]=Q):Q=e[62];let ee;return e[63]!==j||e[64]!==k||e[65]!==K||e[66]!==C||e[67]!==te||e[68]!==Q?(ee=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,k,N,K,C,te,Q]}),e[63]=j,e[64]=k,e[65]=K,e[66]=C,e[67]=te,e[68]=Q,e[69]=ee):ee=e[69],ee};function T0(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Zr=new Map,fi=new Set,Hd=()=>{for(const t of fi)t()},Bo=(t,e)=>{const n=t.trim();n&&(e.length===0?Zr.delete(n):Zr.set(n,[...e]),Hd())},N0=t=>{Zr.delete(t.trim())&&Hd()},qd=[],E0=t=>Zr.get(t.trim())??qd,P0=t=>(fi.add(t),()=>{fi.delete(t)}),I0=t=>{const e=Be.c(2);let n;return e[0]!==t?(n=()=>E0(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(P0,n,R0)};function R0(){return qd}const Gd="oc.browser.hiddenDevServerPorts.v1",D0=ei(Ps(),ud(mo().int().positive())),pi=new Set,Kd=[];let kr=null;const Ji=()=>{const t=so().getItem(Gd);if(kr&&kr.raw===t)return kr.value;let e={};if(t!==null)try{const n=D0.safeParse(JSON.parse(t));n.success&&(e=n.data)}catch{e={}}return kr={raw:t,value:e},e},Zd=t=>{so().setItem(Gd,JSON.stringify(t));for(const e of pi)e()},_0=(t=as())=>Ji()[t]??Kd,A0=t=>{const e=as(),n=Ji(),r=n[e]??[];r.includes(t)||Zd({...n,[e]:[...r,t].sort((o,i)=>o-i)})},O0=()=>{const t=as(),e=Ji();if(!e[t])return;const n={...e};delete n[t],Zd(n)},M0=t=>(pi.add(t),()=>{pi.delete(t)}),F0=()=>l.useSyncExternalStore(M0,L0,$0);function L0(){return _0()}function $0(){return Kd}const B0=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},z0=2e3,W0=t=>gc("http://localhost",t),Xd=t=>{const e=Be.c(62),{onOpen:n,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=at();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={kind:"loading"},e[0]=u):u=e[0];const[c,d]=l.useState(u),f=I0(i);let p;e[1]!==i?(p=()=>W0(i),e[1]=i,e[2]=p):p=e[2];const[m]=l.useState(p);let h;e[3]!==i?(h=()=>Uf(i),e[3]=i,e[4]=h):h=e[4];const[x]=l.useState(h);let g;e[5]!==i?(g=Zl(i),e[5]=i,e[6]=g):g=e[6];const b=g,w=Yi(i),S=_u(i);let y,I;e[7]!==i||e[8]!==S||e[9]!==o?(y=()=>{if(S){d({kind:"ready",servers:[]});return}if(!o)return;let ee=!0,le=null;const O=new AbortController,Y=()=>{Cv(O.signal,i).then(Z=>{ee&&(d(Z),le=setTimeout(Y,z0))})};return Y(),()=>{ee=!1,le&&clearTimeout(le),O.abort()}},I=[i,S,o],e[7]=i,e[8]=S,e[9]=o,e[10]=y,e[11]=I):(y=e[10],I=e[11]),l.useEffect(y,I);const j=Gt(U0),R=tt(V0);let _;if(e[12]!==j||e[13]!==R){const ee=j.map(H0);let le;e[15]!==R?(le=[...R].flatMap(q0),e[15]=R,e[16]=le):le=e[16],_=[...ee,...le],e[12]=j,e[13]=R,e[14]=_}else _=e[14];const P=_;let k;e[17]!==f||e[18]!==i||e[19]!==c.kind||e[20]!==c.servers||e[21]!==P?(k=Rv({candidates:Ev({announced:f,discovered:c.kind==="ready"?c.servers:null}),folders:P,directory:i}),e[17]=f,e[18]=i,e[19]=c.kind,e[20]=c.servers,e[21]=P,e[22]=k):k=e[22];const N=k,T=F0(),[A,$]=l.useState(!1);let K;if(e[23]!==N||e[24]!==T||e[25]!==A){let ee;e[27]!==T||e[28]!==A?(ee=le=>le.announced||!T.includes(le.port)&&(A||!le.outsideWork),e[27]=T,e[28]=A,e[29]=ee):ee=e[29],K=N.filter(ee),e[23]=N,e[24]=T,e[25]=A,e[26]=K}else K=e[26];const q=K,M=N.length-q.length;let z;e[30]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(Fh,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=z):z=e[30];let ne;e[31]!==a?(ne=a("contextPanel.browser.empty"),e[31]=a,e[32]=ne):ne=e[32];let H;e[33]!==ne?(H=s.jsx("span",{className:"typography-ui-header text-foreground",children:ne}),e[33]=ne,e[34]=H):H=e[34];let V;e[35]!==a?(V=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=V):V=e[36];let F;e[37]!==V?(F=s.jsx("span",{className:"typography-micro text-muted-foreground",children:V}),e[37]=V,e[38]=F):F=e[38];let C;e[39]!==H||e[40]!==F?(C=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[H,F]}),e[39]=H,e[40]=F,e[41]=C):C=e[41];let te;e[42]!==f||e[43]!==N.length||e[44]!==i||e[45]!==M||e[46]!==b||e[47]!==n||e[48]!==m||e[49]!==w||e[50]!==x||e[51]!==a||e[52]!==q?(te=N.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-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),m&&!x?s.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx(fs,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:q.map(ee=>s.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[s.jsxs(ft,{type:"button",variant:"outline",size:"sm",className:$e("min-w-0 flex-1 justify-start gap-2",m&&"cursor-default opacity-60"),"aria-disabled":m||void 0,onClick:()=>{m||(N0(i),n(ee.url))},children:[b?s.jsx("span",{className:"shrink-0",role:"img","aria-label":w??a("contextPanel.browser.spaceAddress"),title:w??a("contextPanel.browser.spaceAddress"),children:s.jsx(se,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):s.jsx(se,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsxs("span",{className:"truncate",children:[to(ee.url)||ee.url,s.jsx("span",{className:"typography-micro text-muted-foreground",children:B0(ee.url)})]}),x?s.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:s.jsx(se,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):ee.folderName?s.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:ee.directory,children:[s.jsx(se,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",dir:"auto",children:ee.folderName})]}):null]}),ee.announced?null:s.jsx(ft,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>A0(ee.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:ee.port}),title:a("contextPanel.browser.devServers.hide",{port:ee.port}),children:s.jsx(se,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},ee.port))}),M>0?s.jsx(ft,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{O0(),$(!0)},children:M===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:M}):a("contextPanel.browser.devServers.showHiddenPlural",{count:M})}):null]}):null,e[42]=f,e[43]=N.length,e[44]=i,e[45]=M,e[46]=b,e[47]=n,e[48]=m,e[49]=w,e[50]=x,e[51]=a,e[52]=q,e[53]=te):te=e[53];let re;e[54]!==N.length||e[55]!==c.kind||e[56]!==a?(re=N.length===0&&c.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=N.length,e[55]=c.kind,e[56]=a,e[57]=re):re=e[57];let Q;return e[58]!==C||e[59]!==te||e[60]!==re?(Q=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:[z,C,te,re]}),e[58]=C,e[59]=te,e[60]=re,e[61]=Q):Q=e[61],Q};function U0(t){return t.projects}function V0(t){return t.availableWorktreesByProject}function H0(t){return{path:t.path,projectPath:t.path}}function q0(t){const[e,n]=t;return n.map(r=>({path:r.path,projectPath:e}))}const G0=3e4,K0=3,Z0=250,X0={attempts:0,windowStartedAt:null},Y0=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=G0,r=n?0:t.attempts;return r>=K0?null:{delayMs:Z0*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},J0=-3,jr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",In=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Q0=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:Lh),[i,a]=l.useState(e),[u,c]=l.useState(""),[d,f]=l.useState(!1),[p,m]=l.useState(!1),h=l.useRef(n);h.current=n;const x=l.useRef(X0);return l.useEffect(()=>{if(!t)return;const g=()=>{try{const N=t.getURL();return jr(N)?N:""}catch{return""}},b=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},w=N=>{jr(N)&&(a(N),h.current(N))},S=()=>{const N=g();o({kind:"loading",url:N})},y=()=>{const N=g();let T="";try{T=t.getTitle()||""}catch{T=""}c(T),w(N),b(),o(A=>A.kind==="failed"?A:{kind:"ready",url:N,title:T})},I=N=>{const T=In(N);jr(T.url)&&(w(T.url),b())},j=N=>{const T=In(N),A=Array.isArray(T.favicons)?T.favicons.find(Boolean):"",$=g();if(!A||!$)return;let K=-1;try{K=t.getWebContentsId()}catch{return}!Number.isFinite(K)||K<0||Td.getState().resolve($,A,K)},R=N=>{const T=In(N);typeof T.title=="string"&&c(T.title)},_=N=>{const T=In(N);if(T.isMainFrame===!1)return;const A=typeof T.errorCode=="number"?T.errorCode:0;A!==J0&&o({kind:"failed",url:jr(T.validatedURL)?T.validatedURL:g(),code:A,description:typeof T.errorDescription=="string"?T.errorDescription:""})};let P=null;const k=()=>{const N=g(),T=Y0(x.current,Date.now());if(!T){o({kind:"failed",url:N,code:0,description:"",crashed:!0});return}x.current=T.state,o({kind:"loading",url:N}),P=setTimeout(()=>{P=null;try{t.reload()}catch{o({kind:"failed",url:N,code:0,description:"",crashed:!0})}},T.delayMs)};t.addEventListener("did-start-loading",S),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",I),t.addEventListener("did-navigate-in-page",I),t.addEventListener("page-title-updated",R),t.addEventListener("page-favicon-updated",j),t.addEventListener("did-fail-load",_),t.addEventListener("render-process-gone",k),t.addEventListener("crashed",k);try{!t.isLoading()&&g()&&y()}catch{}return()=>{P!==null&&clearTimeout(P),t.removeEventListener("render-process-gone",k),t.removeEventListener("crashed",k),t.removeEventListener("did-start-loading",S),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",I),t.removeEventListener("did-navigate-in-page",I),t.removeEventListener("page-title-updated",R),t.removeEventListener("page-favicon-updated",j),t.removeEventListener("did-fail-load",_)}},[t]),{status:r,url:i,title:u,canGoBack:d,canGoForward:p}},gl=1e3,Yd=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},eS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},tS=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},sS=(t,e)=>{const n=l.useRef(0),r=l.useRef(0),o=l.useRef(0),i=l.useRef(null),a=l.useCallback(()=>{if(!t||document.activeElement!==t)return;const u=i.current;u&&u.isConnected&&u!==document.body?u.focus({preventScroll:!0}):t.blur()},[t]);return l.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=tS());const u=c=>{if(document.activeElement!==t){i.current=eS(c);return}const d=e.current,f=n.current>r.current||Date.now()<o.current;d&&Yd(d)&&!f||r.current>0||a()};return document.addEventListener("focusin",u,!0),()=>document.removeEventListener("focusin",u,!0)},[a,e,t]),l.useCallback(async u=>{const c=t!==null&&document.activeElement===t;let d=!1;const f=()=>{d&&(d=!1,r.current-=1,o.current=Date.now()+gl,!c&&r.current===0&&a())},p=()=>(d||(d=!0,r.current+=1),f);n.current+=1;try{return await u(p)}finally{n.current-=1,o.current=Date.now()+gl,f()}},[a,t])},nS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),rS=()=>document.visibilityState==="visible",oS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Cr=.5,iS=-3,aS=4,lS="persist:openchamber-browser",Jd=(t,e,n)=>js(t)!==null&&Yl(e)?{icon:"instance",label:n}:void 0,xl=t=>{const e=js(t);return e?`openchamber-space-preview:${e}`:lS},bl="openchamber:browser-panel-open-tab",cS=Qs({webContentsId:mo(),url:Ps().min(1),background:dr()}),wl=20,dS=600,uS=2e4,fS=15e3,yl=500,vl=5e3,pS=3e4,mS=3e3,Sl=1e3,hS=250,gS=Qs({quiet:dr()}),xS=()=>new Promise(t=>{let e=0,n=0,r=0,o;const i=d=>{clearTimeout(o),t(d)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},u=()=>{n=e,r=performance.now()+Sl,o=setTimeout(c,Sl)},c=()=>{e>n||performance.now()-r>hS?u():i(!1)};requestAnimationFrame(a),u()}),bS=t=>{if(!t||Yd(t))return()=>{};const e=t.getBoundingClientRect(),n=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=n}},wS=({initialUrl:t,directory:e,siteDirectory:n,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=at(),{currentTheme:u}=no(),c=l.useRef(null),[d,f]=l.useState(null),p=l.useCallback(oe=>{c.current=oe,f(oe)},[]),m=X(oe=>oe.setContextPanelTabTargetPath),h=l.useRef(Rn(t)),x=h.current!==Xs?h.current:"",[g,b]=l.useState(x?null:Xs),w=Yi(n),[S,y]=l.useState(x),[I,j]=l.useState(!1),[R,_]=l.useState(!1),[P,k]=l.useState(0),N=l.useRef(0),[T,A]=l.useState(!1),[$,K]=l.useState(Gr),q=l.useRef($);q.current=$;const M=l.useRef([]),[z,ne]=l.useState("system"),[H,V]=l.useState({width:0,height:0}),F=l.useRef(null),C=l.useRef(null),te=us(e),re=l.useRef(!!x&&!Au(te,r)),Q=l.useRef(null);l.useEffect(()=>{Xl(te,r)},[te,r]);const ee=l.useRef(!1),le=l.useRef(Date.now()),O=l.useCallback(oe=>{!oe||oe===Xs||!e||!r||m(e,r,oe)},[e,r,m]),Y=Q0(d,{initialUrl:x,onUrlChange:l.useCallback(oe=>{const de=kn(oe);y(de),O(de)},[O])}),[Z,we]=l.useState(null),[L,pe]=l.useState(js(n)===null);l.useEffect(()=>{const oe=js(n);if(oe===null){pe(!0);return}let de=!0;return pe(!1),En("desktop_space_preview_prepare",{spaceId:oe}).then(()=>{de&&pe(!0)}).catch(()=>{de&&we(x||"http://localhost/")}),()=>{de=!1}},[n,x]);const je=$h(e),Ee=Bh(),Se=Y.status.kind==="loading",Le=_n(zd(n)),Pe=_n(oe=>oe.recordVisit),Ve=_n(oe=>oe.forget);l.useEffect(()=>{Y.status.kind==="ready"&&Pe(n,{url:kn(Y.status.url),title:Y.status.title})},[n,Y.status,Pe]);const Oe=l.useMemo(()=>Bd(Le,S),[Le,S]),be=l.useCallback(oe=>{const de=Rn(oe);de!==Xs&&(re.current=!1,y(de),we(null),ba(de,n).then(ve=>{const v=c.current;if(!v){b(ve);return}try{v.loadURL(ve)}catch{b(ve)}}).catch(ve=>{ve instanceof wa&&we(de)}))},[n]);l.useEffect(()=>{if(!x)return;let oe=!0;return ba(x,n).then(de=>{oe&&b(de)}).catch(de=>{if(oe){if(de instanceof wa){we(x),re.current=!1,b(Xs);return}b(x)}}),()=>{oe=!1}},[]);const ye=l.useMemo(()=>({executeJavaScript:async(oe,de)=>{const ve=c.current;if(!ve)throw new Error("Browser view is not available");return ve.executeJavaScript(oe,de)},capturePage:async()=>{const oe=c.current;if(!oe)return null;const de=oe.getWebContentsId();return Number.isFinite(de)?await En("desktop_browser_capture_page",{webContentsId:de}):null}}),[]),Ue=l.useCallback(()=>{if(I){j(!1),Eo(ye);return}if(!Y.url){_e.error(a("contextPanel.browser.annotate.noPage"));return}const oe=zh(u.metadata.variant==="light"?"light":"dark");j(!0),Wh({host:ye,theme:oe,labels:Ee}).then(async de=>{j(!1),de&&await je(de)}).catch(()=>{j(!1),_e.error(a("contextPanel.browser.annotate.failed"))})},[ye,je,u,I,Y.url,Ee,a]);l.useEffect(()=>{if(!I)return;const oe=de=>{Ic(de)||de.key!=="Escape"||(de.preventDefault(),de.stopImmediatePropagation(),j(!1),Eo(ye))};return window.addEventListener("keydown",oe,!0),()=>window.removeEventListener("keydown",oe,!0)},[ye,I]);const Te=l.useRef(!1);l.useEffect(()=>{if(!d)return;const oe=()=>{Te.current=!0};return d.addEventListener("dom-ready",oe),d.addEventListener("did-fail-load",oe),()=>{d.removeEventListener("dom-ready",oe),d.removeEventListener("did-fail-load",oe)}},[d]);const Me=l.useCallback(async()=>{const oe=Date.now()+fS;for(;!(c.current&&Te.current)&&Date.now()<oe;)await new Promise(de=>setTimeout(de,100));return c.current},[]),Re=l.useCallback(async(oe=8e3)=>{const de=Date.now();for(;;){const ve=c.current;if(!ve)return!1;let v=!1;try{v=ve.isLoading()}catch{return!1}if(!v)return!0;if(Date.now()-de>oe)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),ze=l.useCallback(async(oe,de)=>{const ve=g0({quietMs:yl,maxMs:de});let v;const ae=new Promise(W=>{v=setTimeout(()=>W(null),de+1e3)});try{const W=gS.safeParse(await Promise.race([oe.executeJavaScript(ve,!1),ae]));return W.success&&W.data.quiet}catch{return!1}finally{clearTimeout(v)}},[]),B=l.useCallback(async(oe,de=pS)=>{const ve=Date.now(),v=await Re(Math.min(25e3,Math.max(0,de-vl))),ae=de-(Date.now()-ve),W=v&&ae>yl&&await ze(oe,Math.min(vl,ae));let me="";try{me=oe.getTitle()||""}catch{me=""}return{title:me,settled:W}},[Re,ze]),ce=l.useCallback(async(oe,de,ve)=>{const v=await Me();if(!v)throw new Error("The browser panel is not ready");const ae=()=>{hl(de.viewport)&&(K(ui(de.viewport)),A(!0))};if(oe==="browser.back"||oe==="browser.forward"){const ke=oe==="browser.back";if(!(ke?v.canGoBack():v.canGoForward()))throw new Error(ke?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");ke?v.goBack():v.goForward(),await new Promise(lt=>setTimeout(lt,150)),await Re();let ge="";try{ge=v.getTitle()||""}catch{ge=""}return{url:kn(v.getURL()),title:ge}}if(oe==="browser.capture"){const ke=bS(F.current);try{if(!await xS())throw new Error("The OpenChamber window is not being drawn (minimized, on a workspace or tab that is not shown, or the screen is locked or off), so nothing can be captured. browser.snapshot still reads the page.");await Re()&&await ze(v,mS);const rt=await ye.capturePage();if(!rt)throw new Error("The page could not be captured");let ge="";try{ge=v.getTitle()||""}catch{ge=""}return{...rt,url:kn(v.getURL()),title:ge,viewport:Sr(q.current)}}finally{ke()}}if(oe==="browser.resize"){if(!hl(de.viewport))throw new Error("viewport is required");return ae(),await new Promise(ke=>setTimeout(ke,200)),await Re(),{viewport:Sr(ui(de.viewport))}}if(oe==="browser.open"){const ke=typeof de.url=="string"?de.url:"";if(!ke)throw new Error("url is required");return ae(),be(ke),await new Promise(rt=>setTimeout(rt,150)),{url:Rn(ke),...await B(v),opened:!0,viewport:Sr(q.current)}}if(oe==="browser.settle"){const ke=mo().safeParse(de.budgetMs);return B(v,ke.success?ke.data:void 0)}await Re();const W=ke=>typeof ke=="string"&&ke?ke:void 0,he=(()=>{switch(oe){case"browser.snapshot":return u0({selector:W(de.selector)});case"browser.click":return f0({selector:W(de.selector),text:W(de.text)});case"browser.type":return p0({selector:String(de.selector??""),value:String(de.value??""),submit:de.submit===!0});case"browser.select":return m0({selector:String(de.selector??""),label:typeof de.label=="string"?de.label:void 0,value:typeof de.value=="string"?de.value:void 0});case"browser.inspect":return b0({selector:String(de.selector??"")});case"browser.scroll":return h0({selector:W(de.selector),direction:W(de.direction)});default:return null}})();if(!he)throw new Error(`Unsupported browser action: ${oe}`);let Je=()=>{};(oe==="browser.click"||oe==="browser.type")&&(await En("desktop_browser_keep_page_focused",{webContentsId:v.getWebContentsId()}).then(rt=>rt.focused===!0).catch(()=>!1)||(Je=ve(),v.focus({preventScroll:!0})));let Fe;try{Fe=await v.executeJavaScript(he,!0)}finally{Je()}if(!Fe||typeof Fe!="object")throw new Error("The page returned no result");const fe=Fe;if(fe.ok!==!0)throw new Error(typeof fe.error=="string"&&fe.error?fe.error:"Browser action failed");if(oe==="browser.snapshot"){const ke=M.current;return{...fe,viewport:Sr(q.current),...ke.length>0?{consoleProblems:[...ke]}:{}}}return(oe==="browser.click"||oe==="browser.select"||oe==="browser.type"&&de.submit===!0)&&(await new Promise(ke=>setTimeout(ke,150)),await Re()),Fe},[ye,be,B,Re,ze,Me]),G=sS(d,F),[Ce,J]=l.useState(!1),Ne=l.useCallback((oe,de)=>(J(!0),G(ve=>ce(oe,de,ve))),[G,ce]),Ae=l.useCallback(()=>{const oe=c.current;if(!oe)return{title:"",url:""};let de="",ve="";try{de=oe.getTitle()||""}catch{de=""}try{ve=kn(oe.getURL())}catch{ve=""}return{title:de,url:ve}},[]);l.useEffect(()=>qv({tabId:r,directory:te,ownerSessionId:o,describe:Ae,run:Ne}),[Ae,o,Ne,te,r]),l.useEffect(()=>{const oe=ye;return()=>{Eo(oe)}},[ye]),l.useEffect(()=>{if(!d)return;const oe=ve=>{const v=ve;if(typeof v.level!="number"||v.level<2)return;const ae=v.sourceId?`${v.sourceId}${v.line?`:${v.line}`:""}`:"";M.current.push({level:v.level>=3?"error":"warning",message:String(v.message??"").slice(0,400),source:ae}),M.current.length>wl&&M.current.splice(0,M.current.length-wl)},de=()=>{M.current=[]};return d.addEventListener("console-message",oe),d.addEventListener("did-start-loading",de),()=>{d.removeEventListener("console-message",oe),d.removeEventListener("did-start-loading",de)}},[d]);const Ie=l.useRef(new Set),De=l.useCallback(oe=>{Ie.current.clear(),be(oe)},[be]),We=l.useRef(Y.status);We.current=Y.status;const Ke=l.useRef(!1);Y.status.kind==="ready"&&Y.status.url&&(Ke.current=!0),l.useEffect(()=>Ou(te,r,oe=>{Fu(We.current,Ke.current)&&De(oe)}),[De,te,r]),l.useEffect(()=>{if(!d)return;const oe=ve=>{const v=In(ve),ae=typeof v.url=="string"?v.url:"";!ae||!ya(ae,n)||(ve.preventDefault(),be(ae))},de=ve=>{const v=In(ve);if(v.isMainFrame===!1||v.errorCode===-3)return;const ae=typeof v.validatedURL=="string"?v.validatedURL:"";!ae||!ya(ae,n)||Ie.current.has(ae)||(Ie.current.add(ae),be(ae))};return d.addEventListener("will-navigate",oe),d.addEventListener("did-fail-load",de),()=>{d.removeEventListener("will-navigate",oe),d.removeEventListener("did-fail-load",de)}},[n,be,d]),l.useEffect(()=>{if(!d)return;const oe=de=>{if(!(de instanceof CustomEvent))return;const ve=cS.safeParse(de.detail);if(!ve.success)return;let v=-1;try{v=d.getWebContentsId()}catch{return}ve.data.webContentsId===v&&X.getState().openContextBrowser(te,ve.data.url,{reveal:!ve.data.background})};return window.addEventListener(bl,oe),()=>window.removeEventListener(bl,oe)},[te,d]);const Ze=l.useCallback(oe=>{const de=Math.min(aS,Math.max(iS,oe));N.current=de,k(de);try{c.current?.setZoomLevel(de)}catch{}},[]);l.useEffect(()=>{const oe=de=>{if(!(de instanceof CustomEvent))return;const ve=de.detail,v=c.current;!v||document.activeElement!==v||(ve==="zoom-in"?Ze(N.current+Cr):ve==="zoom-out"?Ze(N.current-Cr):ve==="zoom-reset"&&Ze(0))};return window.addEventListener("openchamber:zoom",oe),()=>window.removeEventListener("openchamber:zoom",oe)},[Ze]);const Qe=l.useCallback(oe=>{En("desktop_browser_clear_data",{partition:xl(n),cookies:oe==="cookies",cache:oe==="cache"}).then(()=>{_e.success(a(oe==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{c.current?.reloadIgnoringCache()}catch{}}).catch(()=>_e.error(a("contextPanel.browser.clearFailed")))},[n,a]);l.useEffect(()=>{const oe=F.current;if(!oe||typeof ResizeObserver>"u")return;const de=new ResizeObserver(ve=>{const v=ve[0]?.contentRect;v&&V({width:v.width,height:v.height})});return de.observe(oe),()=>de.disconnect()},[]);const qe=l.useCallback(oe=>{ne(oe);const de=c.current;if(!de)return;let ve=-1;try{ve=de.getWebContentsId()}catch{return}En("desktop_browser_set_color_scheme",{webContentsId:ve,scheme:oe}).catch(v=>{ne("system"),_e.error(v instanceof Error?v.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),et=l.useCallback(()=>{try{Se?c.current?.stop():c.current?.reload()}catch{}},[Se]),He=Y.status,Ye=l.useSyncExternalStore(nS,rS),dt=i&&Ye||o!==null||Ce;l.useEffect(()=>{const oe=W=>{_(!0);const me=setTimeout(()=>{try{c.current?.reload()}catch{}},W);return()=>clearTimeout(me)};if(He.kind==="loading")return;const de=re.current||Q.current===He;if(re.current&&(He.kind==="failed"||He.kind==="ready"&&He.url)&&(re.current=!1,Q.current=He),He.kind==="failed"){const W=Mu(He,{run:C.current,restored:de,watched:dt,now:Date.now()});if(C.current=W.run,W.next==="retry")return oe(W.delayMs);_(W.next==="pause");return}if(C.current=null,He.kind!=="ready"||!He.url||!Yl(He.url)){ee.current=!0,_(!1);return}if(de||ee.current||Date.now()-le.current>uS){ee.current=!0,_(!1);return}let ve=!1,v=null;return(js(n)?Promise.resolve(null):Tv(kn(He.url))).then(W=>{if(!ve){if(W===null||W<500){ee.current=!0,_(!1);return}v=oe(dS)}}),()=>{ve=!0,v?.()}},[n,He,dt]);const nt=Y.status.kind==="failed"&&!R?Y.status:null,ut=S0($,H);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Wd,{address:S,onAddressChange:y,onSubmit:De,suggestions:Oe,onForgetSuggestion:oe=>Ve(n,oe),onBack:()=>{try{c.current?.goBack()}catch{}},onForward:()=>{try{c.current?.goForward()}catch{}},onReload:et,onOpenExternal:()=>{qn(Y.url||S)},addressMark:Jd(n,S,w??a("contextPanel.browser.spaceAddress")),canOpenExternal:js(n)===null,canGoBack:Y.canGoBack,canGoForward:Y.canGoForward,isLoading:Se,onAnnotate:Ue,isAnnotating:I,onOpenDevTools:()=>{try{c.current?.openDevTools()}catch{}},onHardReload:()=>{try{c.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ze(P+Cr),onZoomOut:()=>Ze(P-Cr),onZoomReset:()=>Ze(0),zoomPercent:Math.round(Math.pow(1.2,P)*100),onClearCookies:()=>Qe("cookies"),onClearCache:()=>Qe("cache"),onToggleDeviceBar:()=>A(oe=>!oe),isDeviceBarOpen:T}),T?s.jsx(C0,{viewport:$,onViewportChange:K,colorScheme:z,onColorSchemeChange:qe,scale:ut?.scale??1}):null,s.jsxs("div",{ref:F,className:$e("relative min-h-0 flex-1 bg-background",ut&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&L?s.jsx("webview",{ref:p,src:g,partition:xl(n),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:ut?{width:`${ut.width}px`,height:`${ut.height}px`,transform:`scale(${ut.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!x&&!Y.url&&!Se?s.jsx(Xd,{onOpen:De,directory:n,visible:i}):null,R?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:a("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,Z?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[js(n)!==null?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a(js(n)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:Z})})]}):null,nt&&!Z?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:nt.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:nt.crashed?a("contextPanel.browser.crashedHint"):nt.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,Se?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 bg-[var(--primary)]"})}):null]})]})},yS=t=>{const e=Be.c(75),{initialUrl:n,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:u}=at(),c=X(SS);let d;e[0]!==n?(d=Rn(n),e[0]=n,e[1]=d):d=e[1];const f=d,p=f!==Xs?f:"",[m,h]=l.useState(p);let x;e[2]!==o||e[3]!==p?(x=Co(p,o),e[2]=o,e[3]=p,e[4]=x):x=e[4];const[g,b]=l.useState(x);let w;e[5]!==o||e[6]!==p?(w=gc(p,o)?p:"",e[5]=o,e[6]=p,e[7]=w):w=e[7];const[S,y]=l.useState(w);let I;e[8]!==o?(I=js(o),e[8]=o,e[9]=I):I=e[9];const j=I!==null,R=Yi(o);let _;e[10]!==p?(_=p?[p]:[],e[10]=p,e[11]=_):_=e[11];const[P,k]=l.useState(_),[N,T]=l.useState(p?0:-1),[A,$]=l.useReducer(kS,0);let K,q;e[12]!==i||e[13]!==r?(K=()=>{Xl(us(r),i)},q=[r,i],e[12]=i,e[13]=r,e[14]=K,e[15]=q):(K=e[14],q=e[15]),l.useEffect(K,q);let M;e[16]!==c||e[17]!==i||e[18]!==r?(M=Oe=>{!Oe||Oe===Xs||!r||!i||c(r,i,Oe)},e[16]=c,e[17]=i,e[18]=r,e[19]=M):M=e[19];const z=M;let ne;e[20]!==o?(ne=zd(o),e[20]=o,e[21]=ne):ne=e[21];const H=_n(ne),V=_n(jS),F=_n(CS);let C;e[22]!==m||e[23]!==H?(C=Bd(H,m),e[22]=m,e[23]=H,e[24]=C):C=e[24];const te=C;let re;e[25]!==o||e[26]!==N||e[27]!==z||e[28]!==V?(re=Oe=>{const be=Rn(Oe);if(be===Xs)return;h(be);const ye=Co(be,o);b(ye),y(ye?"":be),z(be),V(o,{url:be}),k(Ue=>{const Te=N>=0?Ue.slice(0,N+1):[];return Te[Te.length-1]===be?(T(Te.length-1),Te):(T(Te.length),[...Te,be])})},e[25]=o,e[26]=N,e[27]=z,e[28]=V,e[29]=re):re=e[29];const Q=re;let ee;e[30]!==o||e[31]!==P||e[32]!==z?(ee=Oe=>{const be=P[Oe];if(!be)return;T(Oe),h(be);const ye=Co(be,o);b(ye),y(ye?"":be),z(be)},e[30]=o,e[31]=P,e[32]=z,e[33]=ee):ee=e[33];const le=ee;let O;e[34]!==o||e[35]!==F?(O=Oe=>F(o,Oe),e[34]=o,e[35]=F,e[36]=O):O=e[36];let Y,Z;e[37]!==le||e[38]!==N?(Y=()=>le(N-1),Z=()=>le(N+1),e[37]=le,e[38]=N,e[39]=Y,e[40]=Z):(Y=e[39],Z=e[40]);let we;e[41]!==m||e[42]!==g?(we=()=>{qn(g||m)},e[41]=m,e[42]=g,e[43]=we):we=e[43];let L;e[44]!==R||e[45]!==u?(L=R??u("contextPanel.browser.spaceAddress"),e[44]=R,e[45]=u,e[46]=L):L=e[46];let pe;e[47]!==m||e[48]!==o||e[49]!==L?(pe=Jd(o,m,L),e[47]=m,e[48]=o,e[49]=L,e[50]=pe):pe=e[50];const je=!S,Ee=N>0,Se=N>=0&&N<P.length-1;let Le;e[51]!==m||e[52]!==Q||e[53]!==te||e[54]!==O||e[55]!==Y||e[56]!==Z||e[57]!==we||e[58]!==pe||e[59]!==je||e[60]!==Ee||e[61]!==Se?(Le=s.jsx(Wd,{address:m,onAddressChange:h,onSubmit:Q,suggestions:te,onForgetSuggestion:O,onBack:Y,onForward:Z,onReload:$,onOpenExternal:we,addressMark:pe,canOpenExternal:je,canGoBack:Ee,canGoForward:Se,isLoading:!1}),e[51]=m,e[52]=Q,e[53]=te,e[54]=O,e[55]=Y,e[56]=Z,e[57]=we,e[58]=pe,e[59]=je,e[60]=Ee,e[61]=Se,e[62]=Le):Le=e[62];let Pe;e[63]!==o||e[64]!==j||e[65]!==g||e[66]!==Q||e[67]!==A||e[68]!==u||e[69]!==S||e[70]!==a?(Pe=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:S?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[j?s.jsx(se,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:u(j?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:to(S)})}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:u("contextPanel.browser.remoteLoopback.hint")})]}):g?s.jsx("iframe",{src:g,title:u("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${A}`):s.jsx(Xd,{onOpen:Q,directory:o,visible:a})}),e[63]=o,e[64]=j,e[65]=g,e[66]=Q,e[67]=A,e[68]=u,e[69]=S,e[70]=a,e[71]=Pe):Pe=e[71];let Ve;return e[72]!==Le||e[73]!==Pe?(Ve=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Le,Pe]}),e[72]=Le,e[73]=Pe,e[74]=Ve):Ve=e[74],Ve},vS=t=>{const e=Be.c(3),[n]=l.useState(oS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(wS,{...t}):s.jsx(yS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function SS(t){return t.setContextPanelTabTargetPath}function kS(t){return t+1}function jS(t){return t.recordVisit}function CS(t){return t.forget}const TS=t=>{const e=Be.c(13),{zone:n,children:r}=t,[o]=l.useState(NS);let i;e[0]!==n?(i=m=>m.body[n],e[0]=n,e[1]=i):i=e[1];const a=ur(i);let u,c;e[2]!==a||e[3]!==o||e[4]!==n?(u=()=>{const m=a??ur.getState().body[n];if(!m){o.remove();return}if(o.parentElement===m)return;const h=document.activeElement;m.moveBefore&&o.isConnected?m.moveBefore(o,null):m.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:!0})},c=[a,o,n],e[2]=a,e[3]=o,e[4]=n,e[5]=u,e[6]=c):(u=e[5],c=e[6]),l.useLayoutEffect(u,c);let d,f;e[7]!==o?(d=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=d,e[9]=f):(d=e[8],f=e[9]),l.useLayoutEffect(d,f);let p;return e[10]!==r||e[11]!==o?(p=Ul.createPortal(r,o),e[10]=r,e[11]=o,e[12]=p):p=e[12],p};function NS(){const t=document.createElement("div");return t.style.display="contents",t}const ES=200,Qd=t=>`${t.path}:${t.line}:${t.column}`,kl={status:"idle"},PS=t=>{const e=Be.c(9),{searchContents:n,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:u,active:c}=t,[d,f]=l.useState(kl);let p,m;return e[0]!==c||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==u||e[6]!==n?(p=()=>{if(!c||!n||!r||!o.trim()){f(kl);return}const h=new AbortController;let x=!1;return f({status:"searching"}),n({directory:r,query:o,regex:i,limit:ES,includeHidden:a,respectGitignore:u,signal:h.signal}).then(g=>{x||f(g.status==="ok"?{status:"results",matches:g.matches,stopped:g.stopped}:g)}).catch(g=>{x||f({status:"failed",message:g instanceof Error?g.message:String(g)})}),()=>{x=!0,h.abort()}},m=[c,r,a,o,i,u,n],e[0]=c,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=u,e[6]=n,e[7]=p,e[8]=m):(p=e[7],m=e[8]),l.useEffect(p,m),d},ln=t=>{const e=Be.c(5),{className:n,children:r}=t;let o;e[0]!==n?(o=$e("px-2 py-1 typography-meta text-muted-foreground",n),e[0]=n,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=s.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},IS=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},RS=t=>{const e=Be.c(44),{state:n,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:u}=at();switch(n.status){case"idle":return null;case"searching":{let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=p):p=e[0];let m;e[1]!==u?(m=u("sidebarFilesTree.state.searching"),e[1]=u,e[2]=m):m=e[2];let h;return e[3]!==m?(h=s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[p,m]}),e[3]=m,e[4]=h):h=e[4],h}case"unavailable":{let p;e[5]!==u?(p=u("sidebarFilesTree.contentSearch.unavailable"),e[5]=u,e[6]=p):p=e[6];let m;return e[7]!==p?(m=s.jsx(ln,{children:p}),e[7]=p,e[8]=m):m=e[8],m}case"invalid-pattern":{let p;e[9]!==u?(p=u("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=u,e[10]=p):p=e[10];let m;e[11]!==p?(m=s.jsx("span",{className:"text-[var(--status-error)]",children:p}),e[11]=p,e[12]=m):m=e[12];let h;e[13]!==n.message?(h=s.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:n.message}),e[13]=n.message,e[14]=h):h=e[14];let x;return e[15]!==m||e[16]!==h?(x=s.jsxs(ln,{className:"flex flex-col gap-0.5",children:[m,h]}),e[15]=m,e[16]=h,e[17]=x):x=e[17],x}case"failed":{let p;e[18]!==n.message||e[19]!==u?(p=u("sidebarFilesTree.contentSearch.failed",{message:n.message}),e[18]=n.message,e[19]=u,e[20]=p):p=e[20];let m;return e[21]!==p?(m=s.jsx(ln,{className:"text-[var(--status-error)]",children:p}),e[21]=p,e[22]=m):m=e[22],m}}if(n.matches.length===0){let p;return e[23]!==n.stopped||e[24]!==u?(p=n.stopped==="deadline"?s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.deadline")}):s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.empty")}),e[23]=n.stopped,e[24]=u,e[25]=p):p=e[25],p}let c;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==n.matches){let p;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(p=m=>{const{name:h,directory:x}=IS(m.relativePath),g=Qd(m),b=r===g;return s.jsx("li",{"data-file-tree-path":m.path,children:s.jsxs("button",{type:"button",onClick:()=>o(m),onDoubleClick:()=>o(m,{pin:!0}),draggable:!!i,onDragStart:i?w=>i(w,m):void 0,onDragEnd:a?w=>a(w,m):void 0,className:$e("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",zi(b)),title:`${m.relativePath}:${m.line}`,children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsx(uo,{filePath:m.path,className:"size-3.5 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`‎${x}‎`}):s.jsx("span",{className:"flex-1"}),s.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:m.line})]}),s.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[m.cutStart?"…":null,s.jsx(Uh,{segments:Vh(m.text,m.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=p):p=e[36],c=n.matches.map(p),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=n.matches,e[31]=c}else c=e[31];let d;e[37]!==n.matches.length||e[38]!==n.stopped||e[39]!==u?(d=n.stopped==="limit"?s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.limit",{count:n.matches.length})}):n.stopped==="deadline"?s.jsx(ln,{children:u("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=n.matches.length,e[38]=n.stopped,e[39]=u,e[40]=d):d=e[40];let f;return e[41]!==c||e[42]!==d?(f=s.jsxs(s.Fragment,{children:[c,d]}),e[41]=c,e[42]=d,e[43]=f):f=e[43],f},jl=8;let pr=null;const eu=(t,e)=>Math.abs(e.clientX-t.x)<=jl&&Math.abs(e.clientY-t.y)<=jl,mi=t=>{pr={x:t.clientX,y:t.clientY}},hi=t=>{const e=pr;return pr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:eu(e,t)},tu=t=>pr!==null&&eu(pr,t);let su=null;const zo=t=>{su=t},nu=()=>su,Cl=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},ru=(t,e,n)=>{const r=e===null?n:e.type==="directory"?e.path:Cl(e.path);return!r||Cl(t.path)===r||t.type==="directory"&&Lu(r,t.path,t.path)!==null?null:r},DS=(t,e)=>{const n=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${n}`:`${e}/${n}`},_S=({root:t,childrenByDir:e,expandedPaths:n,loadErrorsByDir:r})=>{const o=[],i=(a,u)=>{for(const c of e[a]??[]){const d=c.type==="directory"&&n.has(c.path);if(o.push({kind:"node",key:c.path,node:c,depth:u,isExpanded:d}),!d)continue;const f=r[c.path];f&&o.push({kind:"error",key:`error:${c.path}`,directory:c.path,depth:u+1,message:f}),i(c.path,u+1)}};return i(t,0),o},AS=(t,e,n)=>{const r=e.filter(o=>o>=0&&o<n&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},OS=28,An=t=>Array.from(t.types).includes("Files"),ar=t=>Array.from(t.types).includes(cr)?nu():null,ou=(t,e,n)=>t.getData(cr)===wo(e,n.path),MS=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},FS=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),Bt=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},wo=(t,e)=>{const n=Bt(e),r=Bt(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Xn=(t,e)=>{const n=wo(t,e);if(n!==".")return n;const r=Bt(t);return r.split("/").filter(Boolean).pop()??r},Mr=t=>{const e=Bt(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},LS=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),$S=new Set(["node_modules"]),BS=t=>$S.has(t),zS=t=>{const e=Bt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},WS=8,_s=new Map,Qi=t=>JSON.stringify([as(),t]),US=t=>{const e=Qi(t),n=_s.get(e);return n?(n.touchedAt=Date.now(),_s.delete(e),_s.set(e,n),n):null},Wo=t=>{const e=Qi(t),n=_s.get(e);if(n)return n.touchedAt=Date.now(),n;if(_s.size>=WS){const o=_s.keys().next().value;o!==void 0&&_s.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return _s.set(e,r),r},VS=t=>{const e=Be.c(131),{node:n,root:r,isExpanded:o,isActive:i,isBrowserClient:a,depth:u,isOpen:c,status:d,badge:f,isDropTarget:p,isDragSource:m,canUpload:h,canMove:x,permissions:g,downloadFile:b,onSelect:w,onToggle:S,onRevealPath:y,onOpenDialog:I,onSetDropTarget:j,onDropFiles:R,onPickFiles:_,onMoveDragChange:P,onSetMoveDropTarget:k,onMoveDrop:N}=t,{t:T}=at(),A=n.type==="directory";let $;e[0]!==A||e[1]!==n.path?($=A?n.path:Mr(n.path),e[0]=A,e[1]=n.path,e[2]=$):$=e[2];const K=$,{canRename:q,canCreateFile:M,canCreateFolder:z,canDelete:ne,canReveal:H}=g,V=!A&&!!b,F=H&&!a,C=A&&h,te=q||M||z||C||ne||V||F,[re,Q]=l.useState(!1),[ee,le]=l.useState(!1);let O;e[3]!==te?(O=ve=>{te&&(ve?.preventDefault(),le(!0))},e[3]=te,e[4]=O):O=e[4];const Y=O;let Z;e[5]!==A||e[6]!==n||e[7]!==w||e[8]!==S?(Z=()=>{A?S(n.path):w(n)},e[5]=A,e[6]=n,e[7]=w,e[8]=S,e[9]=Z):Z=e[9];const we=Z;let L;e[10]!==A||e[11]!==n||e[12]!==w?(L=()=>{A||w(n,{pin:!0})},e[10]=A,e[11]=n,e[12]=w,e[13]=L):L=e[13];const pe=L;let je;e[14]===Symbol.for("react.memo_cache_sentinel")?(je=ve=>{ve.stopPropagation(),le(!1),Q(!0)},e[14]=je):je=e[14];const Ee=je;let Se;e[15]!==M||e[16]!==z||e[17]!==ne||e[18]!==q||e[19]!==F||e[20]!==C||e[21]!==b||e[22]!==a||e[23]!==A||e[24]!==n||e[25]!==I||e[26]!==_||e[27]!==y||e[28]!==T?(Se=ve=>{const{Item:v,Separator:ae}=ve;return s.jsxs(s.Fragment,{children:[q&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("rename",n)},children:[s.jsx(se,{name:"edit",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.rename")]}),s.jsxs(v,{onClick:W=>{W.stopPropagation(),ro(n.path).then(me=>{if(me.ok){_e.success(T("sidebarFilesTree.toast.pathCopied"));return}_e.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(se,{name:"link",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.copyPath")]}),!A&&b&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),b(n.path).catch(me=>{console.error("Download failed:",me),_e.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"download",className:"me-2 h-4 w-4"})," ",T(a?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),F&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),y(n.path)},children:[s.jsx(se,{name:"folder-received",className:"me-2 h-4 w-4"})," ",T(Gh())]}),!A&&F&&eo()&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),Hl(n.path).then(me=>{me||_e.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(se,{name:"external-link",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.openInDefaultApp")]}),A&&(M||z||C)&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{}),M&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("createFile",n)},children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.newFile")]}),z&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("createFolder",n)},children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.newFolder")]}),C&&s.jsxs(v,{onClick:W=>{W.stopPropagation(),_(n.path)},children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.uploadFiles")]})]}),ne&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{}),s.jsxs(v,{onClick:W=>{W.stopPropagation(),I("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(se,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",T("sidebarFilesTree.menu.delete")]})]})]})},e[15]=M,e[16]=z,e[17]=ne,e[18]=q,e[19]=F,e[20]=C,e[21]=b,e[22]=a,e[23]=A,e[24]=n,e[25]=I,e[26]=_,e[27]=y,e[28]=T,e[29]=Se):Se=e[29];const Le=Se;let Pe;e[30]!==x||e[31]!==n.path||e[32]!==n.type||e[33]!==P||e[34]!==r?(Pe=ve=>{mi(ve);const v=wo(r,n.path);!v||v==="."||(ve.dataTransfer.setData(cr,v),ve.dataTransfer.effectAllowed=x?"copyMove":"copy",x&&P({path:n.path,type:n.type}))},e[30]=x,e[31]=n.path,e[32]=n.type,e[33]=P,e[34]=r,e[35]=Pe):Pe=e[35];const Ve=Pe;let Oe;e[36]!==x||e[37]!==we||e[38]!==P?(Oe=ve=>{x&&P(null),hi(ve)&&we()},e[36]=x,e[37]=we,e[38]=P,e[39]=Oe):Oe=e[39];const be=Oe;let ye;e[40]!==h||e[41]!==j||e[42]!==K?(ye=ve=>{!h||!K||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),ve.dataTransfer.dropEffect="copy",j(K))},e[40]=h,e[41]=j,e[42]=K,e[43]=ye):ye=e[43];const Ue=ye;let Te;e[44]!==h||e[45]!==j||e[46]!==K?(Te=ve=>{!h||!K||!An(ve.dataTransfer)||ve.relatedTarget instanceof Node&&ve.currentTarget.contains(ve.relatedTarget)||(ve.stopPropagation(),j(null))},e[44]=h,e[45]=j,e[46]=K,e[47]=Te):Te=e[47];const Me=Te;let Re;e[48]!==h||e[49]!==R||e[50]!==K?(Re=ve=>{!h||!K||!An(ve.dataTransfer)||(ve.preventDefault(),ve.stopPropagation(),R(K,ve.dataTransfer))},e[48]=h,e[49]=R,e[50]=K,e[51]=Re):Re=e[51];const ze=Re;let B;e[52]!==n.path||e[53]!==n.type||e[54]!==r?(B=(ve,v)=>tu(ve)?null:ru(v,{path:n.path,type:n.type},r),e[52]=n.path,e[53]=n.type,e[54]=r,e[55]=B):B=e[55];const ce=B;let G;e[56]!==x||e[57]!==ce||e[58]!==Ue||e[59]!==k?(G=ve=>{const v=x?ar(ve.dataTransfer):null;if(!v){Ue(ve);return}ve.stopPropagation();const ae=ce(ve,v);k(ae),ae&&(ve.preventDefault(),ve.dataTransfer.dropEffect="move")},e[56]=x,e[57]=ce,e[58]=Ue,e[59]=k,e[60]=G):G=e[60];const Ce=G;let J;e[61]!==x||e[62]!==ce||e[63]!==ze||e[64]!==N||e[65]!==k||e[66]!==r?(J=ve=>{const v=x?ar(ve.dataTransfer):null;if(!v){ze(ve);return}ve.stopPropagation(),ve.preventDefault(),k(null);const ae=ce(ve,v);ae&&ou(ve.dataTransfer,r,v)&&N(v,ae)},e[61]=x,e[62]=ce,e[63]=ze,e[64]=N,e[65]=k,e[66]=r,e[67]=J):J=e[67];const Ne=J;let Ae;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ae={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ae):Ae=e[68];let Ie;e[69]!==Y||e[70]!==Me||e[71]!==Ce||e[72]!==Ne?(Ie=s.jsx("div",{className:"group relative flex items-center typography-meta",style:Ae,onContextMenu:Y,onDragEnter:Ce,onDragOver:Ce,onDragLeave:Me,onDrop:Ne}),e[69]=Y,e[70]=Me,e[71]=Ce,e[72]=Ne,e[73]=Ie):Ie=e[73];let De;e[74]!==u?(De=s.jsx(Hc,{depth:u}),e[74]=u,e[75]=De):De=e[75];let We;e[76]!==i||e[77]!==m||e[78]!==p?(We=$e("oc-file-tree-row flex w-full items-center gap-1.5 rounded-md py-1 text-start select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary [--oc-file-tree-row-fill:var(--interactive-selection)] [--oc-file-tree-row-ring:var(--primary)]":zi(i),m&&"opacity-50"),e[76]=i,e[77]=m,e[78]=p,e[79]=We):We=e[79];let Ke;e[80]!==u?(Ke=qc(u),e[80]=u,e[81]=Ke):Ke=e[81];let Ze;e[82]!==Ke?(Ze={paddingInlineStart:Ke},e[82]=Ke,e[83]=Ze):Ze=e[83];let Qe;e[84]!==A||e[85]!==o||e[86]!==n.extension||e[87]!==n.path?(Qe=A?s.jsx(Hh,{expanded:o}):s.jsx(uo,{filePath:n.path,extension:n.extension,className:"ms-0.5 size-3.5"}),e[84]=A,e[85]=o,e[86]=n.extension,e[87]=n.path,e[88]=Qe):Qe=e[88];let qe;e[89]!==n.name||e[90]!==n.path?(qe=s.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:n.path,children:n.name}),e[89]=n.name,e[90]=n.path,e[91]=qe):qe=e[91];let et;e[92]!==A||e[93]!==c||e[94]!==d?(et=!A&&s.jsx(Kh,{isOpen:c,status:d}),e[92]=A,e[93]=c,e[94]=d,e[95]=et):et=e[95];let He;e[96]!==f||e[97]!==A?(He=A&&f&&s.jsx(Zh,{badge:f}),e[96]=f,e[97]=A,e[98]=He):He=e[98];let Ye;e[99]!==et||e[100]!==He?(Ye=s.jsxs(Xh,{className:"pe-2",children:[et,He]}),e[99]=et,e[100]=He,e[101]=Ye):Ye=e[101];let dt;e[102]!==Y||e[103]!==pe||e[104]!==be||e[105]!==Ve||e[106]!==we||e[107]!==We||e[108]!==Ze||e[109]!==Qe||e[110]!==qe||e[111]!==Ye?(dt=s.jsxs("button",{type:"button",onClick:we,onDoubleClick:pe,onContextMenu:Y,draggable:!0,onDragStart:Ve,onDragEnd:be,className:We,style:Ze,children:[Qe,qe,Ye]}),e[102]=Y,e[103]=pe,e[104]=be,e[105]=Ve,e[106]=we,e[107]=We,e[108]=Ze,e[109]=Qe,e[110]=qe,e[111]=Ye,e[112]=dt):dt=e[112];let nt;e[113]!==re||e[114]!==te||e[115]!==i||e[116]!==p||e[117]!==Le||e[118]!==T?(nt=te&&s.jsx("div",{className:$e("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100",qh(i||p)),children:s.jsxs(xn,{open:re,onOpenChange:Q,children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(bn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Ee,title:T("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":T("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(se,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx($t,{side:"bottom",sideOffset:6,children:T("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(wn,{align:"end",side:"bottom",onCloseAutoFocus:()=>Q(!1),children:Le({Item:qt,Separator:mn})})]})}),e[113]=re,e[114]=te,e[115]=i,e[116]=p,e[117]=Le,e[118]=T,e[119]=nt):nt=e[119];let ut;e[120]!==Ie||e[121]!==De||e[122]!==dt||e[123]!==nt?(ut=s.jsxs(oo,{render:Ie,children:[De,dt,nt]}),e[120]=Ie,e[121]=De,e[122]=dt,e[123]=nt,e[124]=ut):ut=e[124];let oe;e[125]!==Le?(oe=s.jsx(io,{className:"min-w-[180px]",children:Le({Item:Ns,Separator:Dn})}),e[125]=Le,e[126]=oe):oe=e[126];let de;return e[127]!==ee||e[128]!==ut||e[129]!==oe?(de=s.jsxs(gr,{open:ee,onOpenChange:le,children:[ut,oe]}),e[127]=ee,e[128]=ut,e[129]=oe,e[130]=de):de=e[130],de},HS=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles&&t.onPickFiles===e.onPickFiles&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,qS=l.memo(VS,HS),GS=t=>{const e=Be.c(14),{visible:n}=t,r=n===void 0?!0:n,o=Vn(ZS),i=Gs()??"",a=xr();let u,c,d,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(c=lo(a,i)??"",a?.kind==="preparing"){let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Pr,{}),e[7]=m):m=e[7],f=m;break e}u=KS,d=JSON.stringify([o,c])}e[0]=a,e[1]=i,e[2]=o,e[3]=u,e[4]=c,e[5]=d,e[6]=f}else u=e[3],c=e[4],d=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[8]!==u||e[9]!==c||e[10]!==i||e[11]!==d||e[12]!==r?(p=s.jsx(u,{visible:r,currentDirectory:c,panelDirectory:i},d),e[8]=u,e[9]=c,e[10]=i,e[11]=d,e[12]=r,e[13]=p):p=e[13],p},KS=({visible:t,currentDirectory:e,panelDirectory:n})=>{const r=l.useRef(t);r.current=t;const{t:o}=at(),{files:i,runtime:a}=Is(),u=$u(a.platform),c=Bt(e.trim()),d=Bt(n.trim()),f=Qi(c),p=Bu(),m=zu(),h=Wu(D=>D.searchFiles),x=X(D=>D.openContextFile),g=co(t?e:null),[b,w]=l.useState(""),S=Yh(b,200),y=l.useRef(null),[I,j]=l.useState([]),[R,_]=l.useState(!1),P=!!i.searchContents,[k,N]=l.useState("names"),[T,A]=l.useState(!1),$=P&&k==="contents",K=PS({searchContents:i.searchContents,directory:e,query:S,regex:T,includeHidden:p,respectGitignore:!m,active:t&&$}),q=X(D=>D.openContextFileAtLine),[M,z]=l.useState(null),[ne,H]=l.useState(null),[V,F]=l.useState(null),[C,te]=l.useState(null),[re,Q]=l.useState(null),{hasTouchOnlyPointer:ee}=yn(),le=!!(i.rename&&c)&&!ee,O=X(D=>D.confirmFileTreeMove),Y=X(D=>D.setConfirmFileTreeMove),[Z,we]=l.useState({}),[L,pe]=l.useState({}),je=l.useRef(new Set),Ee=l.useRef(new Map),Se=l.useMemo(()=>new _1,[]);l.useEffect(()=>()=>Se.clear(),[Se]);const Le=l.useRef(null);l.useEffect(()=>{if(H(null),te(null),Q(null),!c){we({}),pe({}),je.current=new Set;return}const D=US(c);D?(we({...D.childrenByDir}),pe({...D.loadErrorsByDir}),je.current=new Set(D.loadedDirs)):(we({}),pe({}),je.current=new Set)},[c]),l.useEffect(()=>{if(!c)return;const D=Wo(c);D.childrenByDir=Z},[c,Z]),l.useEffect(()=>{if(!c)return;const D=Wo(c);D.loadErrorsByDir=L},[c,L]),l.useEffect(()=>{if(!c)return;const D=Wo(c);D.loadedDirs=new Set(je.current)},[c,Z,L]),l.useEffect(()=>()=>{if(!c)return;const D=_s.get(f);D&&D.loadedDirs.size===0&&Object.keys(D.childrenByDir).length===0&&_s.delete(f)},[f,c]);const Pe=l.useMemo(()=>[],[]),Ve=l.useMemo(()=>[],[]),Oe=xs(D=>c?D.byRoot[c]?.expandedPaths??Pe:Pe),be=l.useMemo(()=>new Set(Oe),[Oe]),ye=xs(D=>c?D.byRoot[c]?.selectedPath??null:null),Ue=xs(D=>D.setSelectedPath),Te=l.useRef(null);l.useEffect(()=>{Te.current=ye},[ye]);const Me=xs(D=>D.addOpenPath),Re=xs(D=>D.removeOpenPathsByPrefix),ze=xs(D=>D.toggleExpandedPath),B=xs(D=>D.expandPath),ce=xs(D=>D.collapseAllExpandedPaths),G=X(D=>d?D.contextPanelByDirectory[d]?.tabs??Ve:Ve),Ce=l.useMemo(()=>new Set(G.map(D=>D.mode==="file"?D.targetPath:null).filter(D=>typeof D=="string"&&D.length>0).map(D=>Bt(D))),[G]),[J,Ne]=l.useState(null),[Ae,Ie]=l.useState(null),[De,We]=l.useState(""),[Ke,Ze]=l.useState(!1),Qe=!!i.writeFile,qe=!!i.createDirectory,et=!!i.rename,He=!!i.delete,Ye=!!i.revealPath,dt=l.useMemo(()=>({canRename:et,canCreateFile:Qe,canCreateFolder:qe,canDelete:He,canReveal:Ye}),[et,Qe,qe,He,Ye]),nt=l.useCallback(D=>{i.revealPath&&i.revealPath(D).catch(()=>{_e.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),ut=l.useCallback((D,E)=>{Ne(D),Ie(E),We(D==="rename"&&E.name||""),Ze(!1)},[]),oe=l.useCallback((D,E)=>{const xe=E.filter(ue=>ue&&typeof ue.name=="string"&&ue.name.length>0).filter(ue=>p||!ue.name.startsWith(".")).filter(ue=>m||!BS(ue.name)).map(ue=>{const it=ue.name,st=Bt(ue.path||""),Nt=st?LS(st)?st:Bt(`${D}/${st}`):Bt(`${D}/${it}`),Rt=ue.isDirectory?"directory":"file",Et=Rt==="file"&&it.includes(".")?it.split(".").pop()?.toLowerCase():void 0;return{name:it,path:Nt,type:Rt,extension:Et}});return FS(xe)},[m,p]),de=l.useCallback(async(D,E,xe=!1)=>{if(!r.current||E?.())return;const ue=Bt(D.trim());if(!ue||!xe&&je.current.has(ue))return;const it=as();return Se.run(ue,async st=>{const Nt=()=>!st()||as()!==it;try{const Rt=!m,Et=i.listDirectory?(await i.listDirectory(ue,{respectGitignore:Rt})).entries:await qo.listLocalDirectory(ue,{respectGitignore:Rt});if(Nt())return;Ee.current.set(ue,Et.length);const _t=oe(ue,Et);je.current=new Set(je.current),je.current.add(ue),pe(ys=>{if(!ys[ue])return ys;const sn={...ys};return delete sn[ue],sn}),we(ys=>ys[ue]&&A1(ys[ue],_t)?ys:{...ys,[ue]:_t})}catch(Rt){if(Nt())return;const Et=Rt instanceof Error?Rt.message:String(Rt??"");console.error("Failed to load sidebar directory:",Rt),pe(_t=>({..._t,[ue]:Et}))}},xe)},[Se,i,oe,m]),ve=l.useCallback(async()=>{if(!c)return;Le.current?.abort();const D=new AbortController;Le.current=D,Se.clear();try{const xe=(xs.getState().byRoot[c]?.expandedPaths??[]).map(st=>Bt(st)).filter(st=>!!st&&st!==c&&st.startsWith(`${c}/`)),ue=[c,...xe];je.current=new Set(je.current);for(const st of ue)je.current.delete(st);pe(st=>{if(Object.keys(st).length===0)return st;const Nt={...st};let Rt=!1;for(const Et of ue)Et in Nt&&(delete Nt[Et],Rt=!0);return Rt?Nt:st});const it=()=>D.signal.aborted;await de(c,it);for(let st=0;st<xe.length&&!D.signal.aborted;st+=3){const Nt=xe.slice(st,st+3);await Promise.all(Nt.map(Rt=>de(Rt,it)))}}catch(E){if(D.signal.aborted)return;console.error("Failed to refresh sidebar tree:",E)}finally{Le.current===D&&(Le.current=null)}},[Se,de,c]),v=l.useCallback(async D=>{if(!D){await ve();return}const E=Bt(D);je.current=new Set(je.current),je.current.delete(E),await de(E,void 0,!0)},[de,ve]);l.useEffect(()=>{c&&(Le.current?.abort(),je.current=new Set,Se.clear(),pe({}),we(D=>Object.keys(D).length===0?D:{}),de(c))},[Se,de,c,p,m]),l.useEffect(()=>{if(!t||!c||Oe.length===0)return;const D=Oe.map(ue=>Bt(ue)).filter(ue=>!!ue&&ue!==c&&ue.startsWith(`${c}/`)&&!je.current.has(ue)&&!Se.has(ue)).sort((ue,it)=>ue.split("/").length-it.split("/").length);if(D.length===0)return;let E=!1;const xe=()=>E;return(async()=>{for(let ue=0;ue<D.length&&!E;ue+=3){const it=D.slice(ue,ue+3);await Promise.all(it.map(st=>de(st,xe)))}})(),()=>{E=!0}},[Se,Oe,de,c,t]);const ae=l.useRef(t);l.useEffect(()=>{const D=t&&!ae.current;ae.current=t,D&&ve()},[ve,t]);const W=l.useCallback(({directories:D})=>{if(!c)return;const E=new Set((xs.getState().byRoot[c]?.expandedPaths??[]).map(Et=>Bt(Et))),xe=c==="/"?"/":`${c}/`,ue=Et=>{for(let _t=Et;_t!==c;_t=Mr(_t))if(!_t.startsWith(xe)||!E.has(_t))return!1;return!0},it=Et=>{for(let _t=Et;_t===c||_t.startsWith(xe);_t=Mr(_t)){if(je.current.has(_t))return _t;if(_t===c)break}return null},st=new Set,Nt=new Set;for(const Et of D??je.current){const _t=it(Bt(Et));_t&&(ue(_t)?st:Nt).add(_t)}Nt.size>0&&(je.current=new Set([...je.current].filter(Et=>!Nt.has(Et))));const Rt=[...st].filter(Et=>(Ee.current.get(Et)??0)<=Vf);(async()=>{for(let Et=0;Et<Rt.length;Et+=3)await Promise.all(Rt.slice(Et,Et+3).map(_t=>de(_t,void 0,!0)))})()},[de,c]);Hf({root:c,active:t,whileInactive:"drop",onChanges:W}),l.useEffect(()=>{if(!t)return;if(!e||$){j([]),_(!1);return}const D=S.trim();if(!D){j([]),_(!1);return}let E=!1;return _(!0),h(e,D,150,{includeHidden:p,respectGitignore:!m,type:"file"}).then(xe=>{if(E)return;const it=xe.filter(st=>m||!zS(st.path)).map(st=>({name:st.name,path:Bt(st.path),type:"file",extension:st.extension,relativePath:st.relativePath}));j(it)}).catch(()=>{E||j([])}).finally(()=>{E||_(!1)}),()=>{E=!0}},[$,e,S,h,p,m,t]);const me=l.useMemo(()=>{const D=new Map;if(!g?.files)return D;for(const E of g.files)E.index==="A"||E.working_dir==="?"?D.set(E.path,"git-added"):E.index==="D"?D.set(E.path,"git-deleted"):(E.index==="M"||E.working_dir==="M")&&D.set(E.path,"git-modified");return D},[g]),he=l.useMemo(()=>{const D=new Map;if(!g?.files||!c)return D;for(const E of g.files){const xe=E.index==="M"||E.working_dir==="M",ue=E.index==="A"||E.working_dir==="?";if(!xe&&!ue)continue;const it=E.path.split("/");if(it.length<=1)continue;let st=c;for(let Nt=0;Nt<it.length-1;Nt++){st=`${st}/${it[Nt]}`;let Rt=D.get(st);Rt||(Rt={modified:0,added:0},D.set(st,Rt)),xe&&Rt.modified++,ue&&Rt.added++}}return D},[g,c]),Je=l.useCallback(D=>{if(me.size===0)return null;const E=D.startsWith(c+"/")?D.slice(c.length+1):D;return me.get(E)??null},[me,c]),Fe=l.useCallback(D=>{if(he.size===0)return null;const E=he.get(D);return E&&E.modified+E.added>0?E:null},[he]),fe=l.useCallback(async(D,E)=>{if(!c)return;const xe=await $a(i,D.path,{directory:c});if(!xe.ok){Ba(D.path,xe);return}Ue(c,D.path),Me(c,D.path),x(d,D.path,{preview:!E?.pin&&!X.getState().isMobile})},[Me,i,x,d,c,Ue]),ke=l.useCallback(async(D,E)=>{if(!c)return;const xe=await $a(i,D.path,{directory:c});if(!xe.ok){Ba(D.path,xe);return}Ue(c,D.path),Me(c,D.path),z({path:D.path,key:Qd(D)}),q(d,D.path,D.line,D.column,{preview:!E?.pin&&!X.getState().isMobile})},[Me,i,q,d,c,Ue]),rt=l.useCallback((D,E)=>{mi(D),zo(null),D.dataTransfer.setData(cr,E.relativePath),D.dataTransfer.effectAllowed="copy"},[]),ge=l.useCallback((D,E)=>{hi(D)&&ke(E)},[ke]),[lt,Ct]=l.useState(null),bt=l.useCallback(()=>Ct(null),[]),kt=l.useRef(null),ht=O1(kt,{onSettled:bt}),St=l.useCallback(async D=>{const E=Bt(D);if(!c)return;const xe=xs.getState().byRoot[c]?.expandedPaths.includes(E)??!1;ht(D,xe,()=>{const ue=Array.from(kt.current?.querySelectorAll("[data-tree-disclosure-path]")??[],it=>it.dataset.treeDisclosurePath??"");Ct(xe?null:ue.slice(ue.indexOf(D)+1)),ze(c,E)}),je.current.has(E)||await de(E)},[de,c,ze,ht]),{canUpload:yt,uploadingDirectory:xt,uploadFiles:vt,pickFiles:ct,uploadElements:Pt}=qf({root:c,refreshDirectory:v}),Dt=xt!==null,pt=xt??ne,mt=l.useCallback((D,E)=>{const xe=MS(E);xe.length!==0&&(H(null),vt(D,xe))},[vt]),Ot=l.useCallback(D=>{if(zo(D),!D){F(null),te(null);return}requestAnimationFrame(()=>{nu()?.path===D.path&&F(D.path)})},[]),Ut=l.useCallback(async(D,E)=>{const xe=DS(D,E),ue=await za(i,{tabs:d,files:c},D.path,xe);if(ue==="conflict"){_e.error(o("sidebarFilesTree.toast.nameTaken",{name:xe.slice(xe.lastIndexOf("/")+1),folder:Xn(c,E)}));return}if(ue==="failed"){_e.error(o("sidebarFilesTree.toast.operationFailed"));return}E!==c&&B(c,E),await Promise.all([v(Mr(D.path)),v(E)]).catch(()=>{})},[B,i,d,v,c,o]),ss=l.useCallback((D,E)=>{if(X.getState().confirmFileTreeMove){Q({source:D,targetDirectory:E});return}Ut(D,E)},[Ut]),ps=l.useCallback(()=>{re&&(Q(null),Ut(re.source,re.targetDirectory))},[Ut,re]),ns=l.useCallback((D,E)=>!le||tu(D)?null:ru(E,null,c),[le,c]),ms=l.useCallback(D=>{const E=ar(D.dataTransfer);if(E){const xe=ns(D,E);if(te(xe),!xe)return;D.preventDefault(),D.dataTransfer.dropEffect="move";return}!yt||Dt||!c||!An(D.dataTransfer)||(D.preventDefault(),D.dataTransfer.dropEffect="copy",H(c))},[yt,ns,Dt,c]),ls=l.useCallback(D=>{if(!(D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget))){if(ar(D.dataTransfer)){te(null);return}An(D.dataTransfer)&&H(null)}},[]),rs=l.useCallback(D=>{const E=ar(D.dataTransfer);if(E){D.preventDefault(),te(null);const xe=ns(D,E);xe&&ou(D.dataTransfer,c,E)&&ss(E,xe);return}!yt||Dt||!c||!An(D.dataTransfer)||(D.preventDefault(),mt(c,D.dataTransfer))},[yt,ns,mt,ss,Dt,c]),Rs=l.useCallback(async D=>{if(D?.preventDefault(),!Ae||!J)return;Ze(!0);const E=()=>Ze(!1),xe=()=>Ne(null);if(J==="createFile"){if(!De.trim()){_e.error(o("sidebarFilesTree.toast.filenameRequired")),E();return}if(!i.writeFile){_e.error(o("sidebarFilesTree.toast.writeNotSupported")),E();return}const ue=Ae.path,it=ue?`${ue}/`:"",st=Bt(`${it}${De.trim()}`);await i.writeFile(st,"").then(async Nt=>{Nt.success&&(_e.success(o("sidebarFilesTree.toast.fileCreated")),await v(ue)),xe()}).catch(()=>_e.error(o("sidebarFilesTree.toast.operationFailed"))).finally(E);return}if(J==="createFolder"){if(!De.trim()){_e.error(o("sidebarFilesTree.toast.folderNameRequired")),E();return}const ue=Ae.path,it=ue?`${ue}/`:"",st=Bt(`${it}${De.trim()}`);await i.createDirectory(st).then(async Nt=>{Nt.success&&(_e.success(o("sidebarFilesTree.toast.folderCreated")),await v(ue)),xe()}).catch(()=>_e.error(o("sidebarFilesTree.toast.operationFailed"))).finally(E);return}if(J==="rename"){if(!De.trim()){_e.error(o("sidebarFilesTree.toast.nameRequired")),E();return}if(!i.rename){_e.error(o("sidebarFilesTree.toast.renameNotSupported")),E();return}const ue=Ae.path,it=ue.split("/").slice(0,-1).join("/"),st=it?`${it}/`:"",Nt=De.trim(),Rt=Bt(`${st}${Nt}`);try{const Et=await za(i,{tabs:d,files:c},ue,Rt);Et==="moved"?(_e.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await v(it),xe()):Et==="conflict"?_e.error(o("sidebarFilesTree.toast.nameTaken",{name:Nt,folder:Xn(c,it)})):_e.error(o("sidebarFilesTree.toast.operationFailed"))}catch{_e.error(o("sidebarFilesTree.toast.operationFailed"))}finally{E()}return}if(J==="delete"){if(!i.delete){_e.error(o("sidebarFilesTree.toast.deleteNotSupported")),E();return}const ue=Ae.path,it=ue.split("/").slice(0,-1).join("/");await i.delete(ue).then(async st=>{st.success&&(_e.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await v(it),c&&Re(c,ue),(ye===ue||ye&&ye.startsWith(ue+"/"))&&Ue(c,null)),xe()}).catch(()=>_e.error(o("sidebarFilesTree.toast.operationFailed"))).finally(E);return}E()},[J,Ae,De,i,d,v,Re,c,ye,Ue,o]),Vt=l.useMemo(()=>c?_S({root:c,childrenByDir:Z,expandedPaths:be,loadErrorsByDir:L}):[],[Z,be,L,c]),cs=l.useMemo(()=>new Map(Vt.flatMap((D,E)=>D.kind==="node"?[[D.node.path,E]]:[])),[Vt]),[Ht,ie]=l.useState(null),[Ge,gt]=l.useState(null),jt=l.useCallback(D=>{kt.current=D,gt(D)},[]),[It,Mt]=l.useState(null),Kt=l.useMemo(()=>[V,It,...lt??[]].flatMap(D=>D?[cs.get(D)??-1]:[]),[It,V,lt,cs]),Jt=l.useCallback(D=>AS($1(D),Kt,Vt.length),[Kt,Vt.length]),[gs,Cs]=l.useState(0);l.useLayoutEffect(()=>{if(!Ht||!Ge)return;const D=Ge.getBoundingClientRect().top-Ht.getBoundingClientRect().top+Ht.scrollTop;Cs(Math.max(0,Math.round(D)))},[Ge,Ht]);const Ts=l.useRef(null),U=l.useRef(new Map),Xe=l.useRef(null),ot=l.useCallback(D=>{const E=Math.max(0,...U.current.values());D.style.setProperty("--oc-file-tree-width",`${E}px`)},[]),Tt=l.useCallback((D,E)=>{const xe=D.dataset.treeRowPath,ue=kt.current;!xe||!ue||E<=ue.clientWidth+.5||U.current.get(xe)!==E&&(U.current.set(xe,E),Xe.current===null&&(Xe.current=requestAnimationFrame(()=>{Xe.current=null,kt.current&&ot(kt.current)})))},[ot]);l.useEffect(()=>()=>{Xe.current!==null&&cancelAnimationFrame(Xe.current)},[]),l.useLayoutEffect(()=>{if(!Ge)return;const D=U.current;for(const ue of D.keys())cs.has(ue)||D.delete(ue);const E=Ht?.scrollLeft??0;Ge.style.removeProperty("--oc-file-tree-width");const xe=Ge.clientWidth;for(const ue of Ge.children){const it=ue instanceof HTMLElement?ue.dataset.treeRowPath:void 0;if(!it)continue;const st=ue.getBoundingClientRect().width;st>xe+.5?D.set(it,st):D.delete(it)}ot(Ge),Ht&&(Ht.scrollLeft=E)},[Ge,cs,Ht,ot]);const Zt=L1({count:Vt.length,enabled:Ht!==null,getScrollElement:()=>Ht,estimateSize:D=>(Vt[D]?.kind==="node"?Ts.current:null)??OS,measureElement:(D,E,xe)=>{const ue=B1(D,E,xe);return D.dataset.treeRowPath&&(Ts.current=ue),E&&Tt(D,E.borderBoxSize?.[0]?.inlineSize??D.getBoundingClientRect().width),ue},getItemKey:D=>Vt[D]?.key??D,overscan:12,scrollMargin:gs,rangeExtractor:Jt}),Ds=D=>{if(D.kind==="error")return s.jsxs("div",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:qc(D.depth)},children:[s.jsx(Hc,{depth:D.depth}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:D.message,children:D.message}),s.jsxs(ft,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{v(D.directory)},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]});const{node:E,depth:xe,isExpanded:ue}=D,it=E.type==="directory";return s.jsx(qS,{node:E,root:c,isExpanded:ue,isActive:ye===E.path,isBrowserClient:u,depth:xe,isOpen:!it&&Ce.has(E.path),status:it?void 0:Je(E.path),badge:it?Fe(E.path):void 0,isDropTarget:it&&(pt===E.path||C===E.path),isDragSource:V===E.path,canUpload:yt&&!Dt,canMove:le,permissions:dt,downloadFile:i.downloadFile,onSelect:fe,onToggle:St,onRevealPath:nt,onOpenDialog:ut,onSetDropTarget:H,onDropFiles:mt,onPickFiles:ct,onMoveDragChange:Ot,onSetMoveDropTarget:te,onMoveDrop:ss})},Xt=l.useCallback(D=>{const E=D.target instanceof Element?D.target.closest("[data-tree-row-path]"):null;Mt(E?.dataset.treeRowPath??null)},[]),en=l.useCallback(D=>{D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget)||Mt(null)},[]);l.useEffect(()=>{const D=Te.current;if(!D||!Ht||!Ge)return;const E=cs.get(D);E===void 0||Ht.offsetParent===null||(Te.current=null,Zt.scrollToIndex(E,{align:"auto"}))});const Sn=!!(c&&Z[c]),tn=c?L[c]:null,Gn=S.trim().length>0,yo=!R&&!Gn&&I.length===0&&!tn&&Sn&&!!c,Kn=pt?Xn(c,pt):"",br=C?Xn(c,C):"",vo=re?re.source.path.slice(re.source.path.lastIndexOf("/")+1):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col border-b border-edge-muted",children:[s.jsx("div",{className:"flex h-8 shrink-0 items-center border-t border-edge-muted px-2",children:s.jsx(Jh,{className:"flex-1",start:null,groups:[[(Qe||qe||yt)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:Dt?"loader-4":"add",iconClassName:Dt?"animate-spin":void 0,menu:s.jsxs(s.Fragment,{children:[Qe?s.jsxs(qt,{onClick:()=>ut("createFile",{path:e,type:"directory"}),children:[s.jsx(se,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,qe?s.jsxs(qt,{onClick:()=>ut("createFolder",{path:e,type:"directory"}),children:[s.jsx(se,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,yt?s.jsxs(qt,{disabled:!c||Dt,onClick:()=>ct(c),children:[s.jsx(se,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})},{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:m,onSelect:()=>Uu(!m)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{ve()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{c&&ce(c)}}]]})}),s.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[P?s.jsxs(xn,{children:[s.jsx(bn,{asChild:!0,children:s.jsxs(ft,{variant:"ghost",size:"sm",className:"absolute inset-s-3 top-3 size-6 p-0 text-muted-foreground hover:text-foreground",title:o("sidebarFilesTree.search.mode.aria"),"aria-label":o("sidebarFilesTree.search.mode.aria"),children:[s.jsx(se,{name:$?"file-search":"search",className:"h-4 w-4"}),s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})}),s.jsx(wn,{align:"start",side:"bottom",children:s.jsxs(Mc,{value:k,onValueChange:D=>N(D==="contents"?"contents":"names"),children:[s.jsxs(Wr,{value:"names",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),s.jsxs(Wr,{value:"contents",closeOnClick:!0,className:"items-center",children:[s.jsx(se,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):s.jsx(se,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),s.jsx(Un,{ref:y,value:b,onChange:D=>w(D.target.value),placeholder:o($?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:$e("h-8 ps-8 typography-meta",$?"pe-16":"pe-8")}),$?s.jsx(ft,{variant:"chip",size:"xs","aria-pressed":T,onClick:()=>{A(D=>!D),y.current?.focus()},title:o("sidebarFilesTree.search.regexTitle"),"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"}):null,b.trim().length>0?s.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:$e("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",$?"inset-e-10":"inset-e-4"),onClick:()=>{w(""),y.current?.focus()},children:s.jsx(se,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsxs(fs,{ref:ie,outerClassName:"h-full min-h-0",className:$e("@container px-1.5 py-1.5 [overflow-anchor:none]",(pt===c||C===c)&&"bg-interactive-selection/10"),onDragEnter:ms,onDragOver:ms,onDragLeave:ls,onDrop:rs,children:[s.jsx("ul",{className:"flex flex-col",children:$&&K.status!=="idle"?s.jsx(RS,{state:K,activeMatchKey:M&&M.path===ye?M.key:null,onOpen:ke,onDragStart:rt,onDragEnd:ge}):R?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(se,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Gn&&I.length===0?s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):I.length>0?I.map(D=>{const E=ye===D.path;return s.jsx("li",{"data-file-tree-path":D.path,children:s.jsxs("button",{type:"button",onClick:()=>fe(D),onDoubleClick:()=>fe(D,{pin:!0}),draggable:!0,onDragStart:xe=>{mi(xe),zo(null);const ue=D.relativePath||wo(c??"",D.path);!ue||ue==="."||(xe.dataTransfer.setData(cr,ue),xe.dataTransfer.effectAllowed="copy")},onDragEnd:xe=>{hi(xe)&&fe(D)},className:$e("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",zi(E)),title:D.path,children:[s.jsx(uo,{filePath:D.path,extension:D.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`‎${D.relativePath??D.path}‎`})]})},D.path)}):tn?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:tn}),s.jsxs(ft,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ve()},children:[s.jsx(se,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]}):Sn&&c?null:s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),yo?s.jsx("ul",{ref:jt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Zt.getTotalSize()},onFocus:Xt,onBlur:en,children:Zt.getVirtualItems().map(D=>{const E=Vt[D.index];if(!E)return null;const xe=E.kind==="node"?E.node.path:void 0;return s.jsx("li",{ref:Zt.measureElement,"data-index":D.index,"data-tree-row-path":xe,"data-tree-disclosure-path":E.kind==="node"?xe:`${E.directory}/`,"data-file-tree-path":E.kind==="node"&&E.node.type==="file"?xe:void 0,className:$e("absolute inset-x-0 top-0",E.kind==="node"&&"min-w-max"),style:{transform:`translateY(${D.start-gs}px)`},children:Ds(E)},D.key)})}):null]}),pt?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(se,{name:Dt?"loader-4":"folder-received",className:$e("size-4 flex-shrink-0",Dt&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Kn,children:o(Dt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Kn})})]}):C?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(se,{name:"folder-received",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:br,children:o("sidebarFilesTree.drop.moveTarget",{path:br})})]}):null]}),Pt,s.jsx(zn,{open:!!J,onOpenChange:D=>!D&&Ne(null),children:s.jsxs(Bn,{children:[s.jsxs($n,{children:[s.jsxs(Fn,{children:[J==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),J==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),J==="rename"&&o("sidebarFilesTree.dialog.rename.title"),J==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Ln,{children:[J==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ae?.path??o("sidebarFilesTree.dialog.rootFallback")}),J==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ae?.path??o("sidebarFilesTree.dialog.rootFallback")}),J==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ae?.name??""}),J==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ae?.name??""})]})]}),J!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Un,{value:De,onChange:D=>We(D.target.value),placeholder:o(J==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:D=>{D.key==="Enter"&&Rs()},autoFocus:!0})}),s.jsxs(Br,{children:[s.jsx(ft,{variant:"outline",onClick:()=>Ne(null),disabled:Ke,children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{variant:J==="delete"?"destructive":"default",onClick:()=>{Rs()},disabled:Ke||J!=="delete"&&!De.trim(),children:Ke?s.jsx(se,{name:"loader-4",className:"size-4 animate-spin"}):o(J==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),s.jsx(zn,{open:re!==null,onOpenChange:D=>{D||Q(null)},children:s.jsxs(Bn,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs($n,{children:[s.jsx(Fn,{children:o("sidebarFilesTree.dialog.move.title")}),s.jsx(Ln,{children:re?o("sidebarFilesTree.dialog.move.description",{name:vo,folder:Xn(c,re.targetDirectory)}):null})]}),s.jsxs(Br,{className:"w-full sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>Y(!O),children:[s.jsx(Ko,{checked:!O,onChange:D=>Y(!D),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),s.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:()=>Q(null),children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{onClick:ps,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function ZS(t){return t.runtimeKey}const XS=mr(()=>At(()=>import("./WalkthroughView-BnT4-pMh.js"),__vite__mapDeps([207,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,208,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,209,210,211,204,212])).then(t=>({default:t.WalkthroughView}))),YS=mr(()=>At(()=>import("./DiffView-CQOHl1hv.js"),__vite__mapDeps([213,1,2,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,208,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,186,187,188,189,190,191,192,193,194,195,181,182,183,214,185,196,197,198,199,200,201,202,203,206,209,212])).then(t=>({default:t.DiffView}))),JS=mr(()=>At(()=>import("./FilesView-D00Dnc8i.js"),__vite__mapDeps([215,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,216,217,218,219,181,182,183,220,221,200,222,186,187,188,189,190,191,192,193,194,195,223,197,224,225,226,201,202,199,206,227,228,212,203,229])).then(t=>({default:t.FilesView}))),iu=l.lazy(()=>At(()=>import("./useAppFontEffects-C_TEX3sk.js").then(t=>t.rG),__vite__mapDeps([3,1,2,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.PluginPane}))),Tl=l.lazy(()=>At(()=>import("./GuestSurfacePane-OM2GGOiX.js"),__vite__mapDeps([230,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.GuestSurfacePane}))),au={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-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},QS=t=>{const e=Be.c(12),{mode:n,docking:r}=t,[o,i]=l.useState(null),a=au[r.dock],u=Math.max(sg,o??r.size),c=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let d;e[0]!==a.page||e[1]!==c?(d=$e("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c,a.page),e[0]=a.page,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==a.vertical||e[4]!==u?(f=a.vertical?{height:u}:{width:u},e[3]=a.vertical,e[4]=u,e[5]=f):f=e[5];let p;e[6]!==n?(p=s.jsx(iu,{mode:n,onResize:i}),e[6]=n,e[7]=p):p=e[7];let m;return e[8]!==d||e[9]!==f||e[10]!==p?(m=s.jsx("div",{className:d,style:f,children:p}),e[8]=d,e[9]=f,e[10]=p,e[11]=m):m=e[11],m},Nn=(t,e)=>`${t}\0${e}`,e2=({visible:t,active:e,fill:n=!1,side:r})=>{const{t:o}=at(),i=X(y=>y.contextEditorTreeWidth),a=X(y=>y.setContextEditorTreeWidth),[u,c]=l.useState(!1),d=l.useRef(0),f=l.useRef(i),p=l.useRef(null),m=l.useRef(null),h=l.useRef(null),x=l.useCallback(y=>{const I=h.current;I&&(I.style.width=`${y}px`,I.style.setProperty("--oc-editor-tree-width",`${y}px`))},[]),g=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}m.current=y.pointerId,c(!0),d.current=y.clientX,f.current=i,p.current=i,y.preventDefault()}},b=y=>{if(!u||m.current!==y.pointerId)return;const I=r==="left"?y.clientX-d.current:d.current-y.clientX,j=Qr(y.currentTarget)?-I:I,R=Ho(f.current+j);p.current!==R&&(p.current=R,x(R))},w=y=>{if(m.current!==y.pointerId)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const I=Ho(p.current??i);m.current=null,p.current=null,c(!1),a(I)},S=t?i:0;return s.jsxs("div",{ref:h,className:$e("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${u?p.current??S:S}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${u?p.current??i:i}px`,overflowX:"clip",transitionProperty:u?"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:$e("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!n&&s.jsx("div",{className:$e("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",u&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:b,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:$e("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u&&"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(GS,{visible:t&&e})})]})},cn=t=>{const e=Be.c(12),{zone:n,isOpen:r,interactive:o,hidden:i,className:a,children:u}=t,c=!r||i;let d;e[0]!==u||e[1]!==c?(d=s.jsx(Gc,{paused:c,children:u}),e[0]=u,e[1]=c,e[2]=d):d=e[2];let f;e[3]!==o||e[4]!==d?(f=s.jsx(Wc.Provider,{value:!0,children:s.jsx(Xf.Provider,{value:o,children:d})}),e[3]=o,e[4]=d,e[5]=f):f=e[5];let p;e[6]!==a||e[7]!==f?(p=s.jsx("div",{className:a,children:f}),e[6]=a,e[7]=f,e[8]=p):p=e[8];let m;return e[9]!==p||e[10]!==n?(m=s.jsx(TS,{zone:n,children:p}),e[9]=p,e[10]=n,e[11]=m):m=e[11],m},t2=()=>{const{t}=at(),e=Gs()??"",n=l.useMemo(()=>e?us(e):"",[e]),r=X(B=>n?B.contextPanelByDirectory[n]:void 0),o=xr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,u=lo(o,e)??"",c=X(B=>B.contextSurfaceZones),d=X(B=>B.contextPanelByDirectory),f=X(B=>B.closeContextPanelTab),p=X(B=>B.closeContextFile),m=X(B=>B.openContextPanelTab),h=X(B=>B.openAgentBrowserTab),x=X(B=>B.openContextFile),g=X(B=>B.contextEditorTreeVisible),b=X(B=>B.contextEditorVisible),w=X(B=>B.fileTreeSide),S=xs(B=>B.setSelectedPath),y=ur(B=>B.headerSlot),I=l.useMemo(()=>r?.tabs??[],[r?.tabs]),j=Rr(B=>B.chatCovered),R=l.useMemo(()=>{const B=ce=>{const G=r?Fr(r,c,ce):null,Ce=ce==="bottom"&&j;return{activeTab:G,isOpen:!!(r&&lr(r,ce).isOpen&&G)&&!Ce}};return{left:B("left"),right:B("right"),bottom:B("bottom")}},[j,r,c]),_={left:Lo(R.left.isOpen),right:Lo(R.right.isOpen),bottom:Lo(R.bottom.isOpen)},P=B=>!_[B],k={left:rr(R.left.isOpen),right:rr(R.right.isOpen),bottom:rr(R.bottom.isOpen)},N={left:Er(R.left.isOpen,k.left,R.left.activeTab?.mode),right:Er(R.right.isOpen,k.right,R.right.activeTab?.mode),bottom:Er(R.bottom.isOpen,k.bottom,R.bottom.activeTab?.mode)},T=B=>{const ce=Go(c,B);return{zone:ce,...R[ce]}},A=T("file"),$=T("chat"),K=T("browser"),q=T("diff"),M=T("terminal"),z=T("walkthrough"),[ne,H]=l.useState([]),V=l.useCallback((B,ce)=>{H(G=>Vu(G,Nn(B,ce)))},[]),F=X(B=>B.liveBrowserTabLimit);l.useEffect(()=>Zv((B,ce)=>{const G=ce.directory?us(ce.directory):n;if(!G)return null;const Ce=h(G,B,ce.sessionId);return Ce&&V(G,Ce),Ce}),[n,h,V]),l.useEffect(()=>Xv((B,ce)=>X.getState().contextPanelByDirectory[B]?.tabs?.some(Ce=>Ce.id===ce&&Ce.mode==="browser")?(f(B,ce),!0):!1),[f]),l.useEffect(()=>Js(B=>{if(B.type!=="file-open-request")return;const ce=B.directory??e;ce&&x(ce,B.path)}),[e,x]),l.useEffect(()=>Js(B=>{if(B.type!=="plan-open-request")return;const ce=B.directory??e,G=Gf(ce,B.projectId);!ce||!G||X.getState().openProjectKnowledgePlan(ce,Qh(G),B.planId)}),[e]);const C=K.activeTab?.mode==="browser"?K.activeTab.id:null;l.useEffect(()=>{Kv(n,C)},[n,C]);const te=A.activeTab;l.useEffect(()=>{if(!u||te?.mode!=="file"||!te.targetPath)return;const B=js(te.targetPath)===js(u);S(us(u),te.targetPath,{allowOutsideRoot:!o&&B})},[u,o,te,S]);const re=l.useMemo(()=>I.some(B=>B.mode==="file"&&B.targetPath),[I]),Q=l.useMemo(()=>I.some(B=>B.mode==="file"),[I]),ee=re&&(b||!g),le=A.activeTab?.mode==="file",O=l.useCallback(B=>{n&&p(n,B)},[p,n]),Y=$.isOpen&&$.activeTab?.mode==="chat"?$.activeTab:null,Z=Y?ho(Y.dedupeKey):null,we=l.useMemo(()=>(Y?.targetDirectory?us(Y.targetDirectory):"")||n||null,[Y?.targetDirectory,n]),L=l.useMemo(()=>Z?{sessionId:Z,directory:we}:null,[Z,we]);l.useEffect(()=>{if(!we||!Z||typeof window>"u")return;const B=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Po(we,Z,!1);return}Kc(Z),Po(we,Z,!0)};B();const ce=window.setInterval(B,1e4);return window.addEventListener("focus",B),window.addEventListener("blur",B),document.addEventListener("visibilitychange",B),()=>{window.clearInterval(ce),window.removeEventListener("focus",B),window.removeEventListener("blur",B),document.removeEventListener("visibilitychange",B),Po(we,Z,!1)}},[we,Z]);const pe=q.activeTab,je=l.useCallback(B=>{!n||pe?.mode!=="diff"||m(n,{mode:"diff",targetPath:pe.targetPath,targetDirectory:pe.targetDirectory,stagedDiff:B==="staged",diffScope:B})},[pe,n,m]),Ee=K.isOpen&&K.activeTab?.mode==="browser"?K.activeTab.id:null;l.useEffect(()=>{Ee&&n&&V(n,Ee)},[n,Ee,V]);const{loadedBrowserTabs:Se,sleepingBrowserTabs:Le}=l.useMemo(()=>{const B=new Set(ne),ce=new Set;for(const[Ne,Ae]of Object.entries(d))for(const Ie of Ae.tabs)Ie.mode==="browser"&&Ie.ownerSessionId===null&&ce.add(Nn(Ne,Ie.id));const G=Hu(ne,ce,F),Ce=[],J=[];for(const[Ne,Ae]of Object.entries(d)){const Ie=Ne===n;for(const De of Ae.tabs){if(De.mode!=="browser")continue;const We=Nn(Ne,De.id),Ke=De.ownerSessionId===null,Ze=Ie&&De.id===Ee||(Ke?G.has(We):B.has(We));if(!Ze&&!Ie&&Ke)continue;const Qe={directory:Ne,id:De.id,targetPath:De.targetPath,ownerSessionId:De.ownerSessionId};(Ze?Ce:J).push(Qe)}}return Ce.sort((Ne,Ae)=>Nn(Ne.directory,Ne.id)<Nn(Ae.directory,Ae.id)?-1:1),{loadedBrowserTabs:Ce,sleepingBrowserTabs:J}},[d,n,F,ne,Ee]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const B=Le.map(ce=>Gv({tabId:ce.id,directory:ce.directory,ownerSessionId:ce.ownerSessionId,describe:()=>({title:"",url:ce.targetPath??""}),wake:()=>V(ce.directory,ce.id)}));return()=>B.forEach(ce=>ce())},[Le,V]);const Pe=l.useMemo(()=>I.filter(B=>B.mode==="diff"),[I]),Ve=l.useMemo(()=>I.find(B=>B.mode==="terminal")??null,[I]),Oe=l.useMemo(()=>I.find(B=>B.mode==="walkthrough")??null,[I]),be=l.useMemo(()=>I.filter(B=>Mn(B.mode)),[I]),ye=Ni(B=>B.guests),Ue=l.useMemo(()=>new Set(ye.filter(eg).map(B=>B.id)),[ye]),Te=l.useMemo(()=>{const B=new Map;for(const ce of ye){const G=tg(ce);G&&B.set(ce.id,G)}return B},[ye]),Me=M.zone,Re=l.useCallback(B=>{const ce=Gi({mode:"terminal",label:t("layout.mainTab.terminal"),from:Me},B);return{finish:()=>ce.finish(n),cancel:ce.cancel}},[n,t,Me]),ze=(B,ce)=>ce?y[B]:null;return s.jsxs(s.Fragment,{children:[Q?s.jsxs(cn,{zone:A.zone,interactive:N[A.zone],isOpen:A.isOpen,hidden:P(A.zone),className:$e("absolute inset-0 flex",w==="left"&&"flex-row-reverse",le?"flex":"hidden"),children:[i?s.jsx("div",{className:"h-full min-w-0 flex-1",children:s.jsx(Pr,{})}):re||!g?s.jsx("div",{className:$e("h-full min-w-0 flex-1",re&&!ee&&"hidden"),children:re?s.jsx(l.Suspense,{fallback:null,children:s.jsx(JS,{mode:"editor-only",visible:!P(A.zone)&&le&&ee,onCloseFile:O})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(se,{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,i?null:s.jsx(e2,{visible:g,active:A.isOpen&&le,fill:!ee,side:w})]}):null,Y&&Z&&L?s.jsx(cn,{zone:$.zone,interactive:N[$.zone],isOpen:$.isOpen,hidden:P($.zone),className:"absolute inset-0 bg-background",children:s.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:Z}),className:"h-full",children:s.jsx(xc,{pinnedSession:L,readOnly:Y.readOnly})})},Y.id):null,Se.map(B=>{const ce=B.directory===n&&K.activeTab?.id===B.id,G=B.directory===n?a??B.directory:B.directory;return s.jsx(cn,{zone:K.zone,interactive:N[K.zone],isOpen:K.isOpen,hidden:P(K.zone),className:$e("absolute inset-0",!ce&&"invisible pointer-events-none"),children:s.jsx("div",{className:"h-full","aria-hidden":!ce||void 0,children:s.jsx(Gc,{paused:!ce,children:B.directory===n&&i?s.jsx(Pr,{}):s.jsx(vS,{initialUrl:B.targetPath??"",directory:B.directory,siteDirectory:G,tabID:B.id,ownerSessionId:B.ownerSessionId,visible:ce&&K.isOpen},G)})})},Nn(B.directory,B.id))}),Pe.map(B=>{const ce=q.activeTab?.id===B.id;return s.jsx(cn,{zone:q.zone,interactive:N[q.zone],isOpen:q.isOpen,hidden:P(q.zone),className:$e("absolute inset-0",!ce&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(fn,{value:ze(q.zone,ce),children:i&&!B.targetDirectory?s.jsx(Pr,{}):s.jsx(YS,{directory:B.targetDirectory??a,visible:q.isOpen&&ce,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:B.diffScope??(B.stagedDiff?"staged":null),onDiffScopeChange:je,targetFilePath:B.targetPath,flushContent:!0})})})},B.id)}),Ve?s.jsx(cn,{zone:M.zone,interactive:N[M.zone],isOpen:M.isOpen,hidden:P(M.zone),className:$e("absolute inset-0",M.activeTab?.mode==="terminal"?"block":"hidden"),children:s.jsx(fn,{value:ze(M.zone,M.activeTab?.mode==="terminal"),children:s.jsx(Kf.Provider,{value:Re,children:s.jsx(Zf,{visible:M.isOpen&&M.activeTab?.mode==="terminal",directory:Ve.targetDirectory,onLastTabClosed:()=>{n&&f(n,Ve.id)}})})})}):null,Oe?s.jsx(cn,{zone:z.zone,interactive:N[z.zone],isOpen:z.isOpen,hidden:P(z.zone),className:$e("absolute inset-0",z.activeTab?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(fn,{value:ze(z.zone,z.activeTab?.mode==="walkthrough"),children:s.jsx(XS,{directory:Oe.targetDirectory??e,visible:z.isOpen&&z.activeTab?.mode==="walkthrough"})})})}):null,be.map(B=>{if(!Mn(B.mode))return null;const ce=T(B.mode),G=Lr(B.mode),Ce=Ue.has(G),J=Te.get(G),Ne=ce.activeTab?.id===B.id,Ae=Ne&&ce.isOpen;return Ce&&!J&&!Ae?null:s.jsx(cn,{zone:ce.zone,interactive:N[ce.zone],isOpen:ce.isOpen,hidden:P(ce.zone),className:$e("absolute inset-0",Ne?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:Ce?J?s.jsxs("div",{className:$e("flex h-full",au[J.dock].container),children:[s.jsx(QS,{mode:B.mode,docking:J}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ae?s.jsx(Tl,{mode:B.mode}):null})]}):s.jsx(Tl,{mode:B.mode}):s.jsx(iu,{mode:B.mode})})},B.id)})]})},s2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},n2=()=>{const t=Be.c(20),{t:e}=at(),n=qs(r2),r=qs(o2),o=l.useRef(null),[i,a]=l.useState(!1);let u,c;t[0]!==n?(u=()=>{if(!n){a(!1);return}const w=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(w)},c=[n],t[0]=n,t[1]=u,t[2]=c):(u=t[1],c=t[2]),l.useEffect(u,c);let d,f;if(t[3]!==n?(d=()=>{if(!n)return;const w=S=>{const y=o.current;y&&(y.style.transform=`translate(${S.clientX+12}px, ${S.clientY+12}px)`)};return window.addEventListener("pointermove",w),()=>window.removeEventListener("pointermove",w)},f=[n],t[3]=n,t[4]=d,t[5]=f):(d=t[4],f=t[5]),l.useEffect(d,f),!n)return null;const p=i?"opacity-100":"opacity-0";let m;t[6]!==p?(m=$e("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,t[7]=m):m=t[7];let h;t[8]!==m?(h=s.jsx("div",{className:m}),t[8]=m,t[9]=h):h=t[9];let x;t[10]!==n.frames||t[11]!==r||t[12]!==e?(x=Si.map(w=>{const S=n.frames[w];if(S.width<=0||S.height<=0)return null;const y=r===w;return s.jsx("div",{className:$e("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",y?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:S.left,top:S.top,width:S.width,height:S.height},children:s.jsx("span",{className:"typography-ui-label",children:e(s2[w])})},w)}),t[10]=n.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==n.label?(g=s.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:n.label}),t[14]=n.label,t[15]=g):g=t[15];let b;return t[16]!==h||t[17]!==x||t[18]!==g?(b=Ul.createPortal(s.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,x,g]}),document.body),t[16]=h,t[17]=x,t[18]=g,t[19]=b):b=t[19],b};function r2(t){return t.drag}function o2(t){return t.hovered}const Nl=320,i2=({rowWidth:t,leftWidth:e,rightWidth:n,sidebarWidth:r,opening:o})=>{let i=t-e-n;if(i>=Nl)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Nl)return{collapseSidebar:a,displace:null};const u=o==="left"?"right":"left";return{collapseSidebar:a,displace:(u==="left"?e:n)>0?u:null}},a2=({directoryKey:t,folded:e,readRowWidth:n})=>{const r=b=>{const w=b.contextPanelByDirectory[t];return{left:tr(w,b.contextSurfaceZones,"left"),right:tr(w,b.contextSurfaceZones,"right")}},o=(b,w,S)=>{const y=b.contextPanelByDirectory[t];return(S&&y?Fr(y,b.contextSurfaceZones,w):null)?b.contextZoneSizes[w]??vi:0},i=b=>{const w=b.contextPanelByDirectory[t];return w?Si.some(S=>lr(w,S).expanded&&qu(w,b,S)):!1};let a=null,u=!1,c=r(X.getState()),d=i(X.getState());const f=b=>{e.current=b,X.getState().setSidebarFoldedForExpandedZone(b==="expanded")},p=b=>{u=!0,X.getState().setSidebarOpen(b),u=!1},m=()=>{f(null),X.getState().isSidebarOpen||p(!0)};!e.current&&X.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?d:c[h])&&m(),!e.current&&d&&X.getState().isSidebarOpen&&(f("expanded"),p(!1));const x=(b,w,S)=>{const y=n();if(!y)return;const I=e.current==="expanded",j=i2({rowWidth:I?y-b.sidebarWidth:y,leftWidth:o(b,"left",S.left),rightWidth:o(b,"right",S.right),sidebarWidth:b.isSidebarOpen||I?b.sidebarWidth:null,opening:w});if(j.displace){const R=lr(b.contextPanelByDirectory[t],j.displace).activeTabId;R&&(a={side:j.displace,by:w,tabId:R})}j.collapseSidebar&&(f(w),b.isSidebarOpen&&p(!1)),j.displace&&b.closeContextZone(t,j.displace)},g=b=>{if(a?.side===b){e.current===b&&f(a.by);return}const w=a?.by===b?a:null;w&&(a=null),e.current===b&&(w?f(w.side):m()),w&&X.getState().setActiveContextPanelTab(t,w.tabId)};return X.subscribe((b,w)=>{b.isSidebarOpen!==w.isSidebarOpen&&!u&&f(null);const S=r(b),y=i(b),I=c,j=d;c=S,d=y;const R=["left","right"],_=R.filter(k=>S[k]&&!I[k]),P=R.filter(k=>!S[k]&&I[k]);for(const k of P){const N=k==="left"?"right":"left";_.includes(N)&&(e.current===k&&f(N),a?.by===k&&(a=null))}for(const k of P)g(k);for(const k of _)x(b,k,S);y&&!j&&b.isSidebarOpen?(f("expanded"),p(!1)):!y&&j&&e.current==="expanded"&&m()})},l2=()=>{const t=Be.c(5),e=Gs();let n;t[0]!==e?(n=e?us(e):"",t[0]=e,t[1]=n):n=t[1];const r=n,o=l.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return a2({directoryKey:r,folded:o,readRowWidth:c2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),l.useEffect(i,a),null};function c2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const d2=t=>{const e=Be.c(54),{open:n,onOpenChange:r}=t,{t:o}=at(),i=X(u2),a=X(f2),u=X(p2),c=X(m2),d=X(h2),f=Bi(),p=X(ng);let m;if(e[0]!==i||e[1]!==f||e[2]!==p){let H;e[4]!==p?(H=V=>p||V.id!=="workflows",e[4]=p,e[5]=H):H=e[5],m=Zo(i,f).filter(H),e[0]=i,e[1]=f,e[2]=p,e[3]=m}else m=e[3];const h=m,x=u.length===0;let g;if(e[6]!==u||e[7]!==h){let H;e[9]!==u?(H=V=>u.includes(V.id),e[9]=u,e[10]=H):H=e[10],g=h.every(H),e[6]=u,e[7]=h,e[8]=g}else g=e[8];const b=g,w=l.useRef(!1);let S;e[11]!==u||e[12]!==h||e[13]!==o?(S=h.map((H,V)=>({id:H.id,label:H.label??o(H.labelKey),visible:!u.includes(H.id),groupStart:V>0&&Zs(h[V-1])!==Zs(H)})),e[11]=u,e[12]=h,e[13]=o,e[14]=S):S=e[14];const y=S;let I;e[15]!==i||e[16]!==f||e[17]!==a?(I=H=>{const V=Zo(H,f).map(g2).filter(C=>H.includes(C)),F=new Set(V);a([...V,...i.filter(C=>!F.has(C))])},e[15]=i,e[16]=f,e[17]=a,e[18]=I):I=e[18];const j=I;let R;e[19]!==r?(R=(H,V)=>{if(!H&&V.reason==="escape-key"&&w.current){V.cancel(),V.allowPropagation();return}w.current=!1,r(H)},e[19]=r,e[20]=R):R=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=H=>{w.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(H.key)&&H.preventBaseUIHandler()},e[21]=_):_=e[21];let P;e[22]!==o?(P=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=P):P=e[23];let k;e[24]!==P?(k=s.jsx(Fn,{children:P}),e[24]=P,e[25]=k):k=e[25];let N;e[26]!==o?(N=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=N):N=e[27];let T;e[28]!==N?(T=s.jsx(Ln,{children:N}),e[28]=N,e[29]=T):T=e[29];let A;e[30]!==T||e[31]!==k?(A=s.jsxs($n,{children:[k,T]}),e[30]=T,e[31]=k,e[32]=A):A=e[32];let $;e[33]!==o?($=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=$):$=e[34];let K;e[35]===Symbol.for("react.memo_cache_sentinel")?(K=H=>{w.current=H},e[35]=K):K=e[35];let q;e[36]!==j||e[37]!==y||e[38]!==c||e[39]!==$?(q=s.jsx(Yf,{items:y,onVisibleChange:c,onReorder:j,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:$,onDraggingChange:K}),e[36]=j,e[37]=y,e[38]=c,e[39]=$,e[40]=q):q=e[40];let M;e[41]!==x||e[42]!==b||e[43]!==d||e[44]!==o?(M=x?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:o("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ft,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=b,e[43]=d,e[44]=o,e[45]=M):M=e[45];let z;e[46]!==A||e[47]!==q||e[48]!==M?(z=s.jsxs(Bn,{className:"max-w-md",onKeyDown:_,children:[A,q,M]}),e[46]=A,e[47]=q,e[48]=M,e[49]=z):z=e[49];let ne;return e[50]!==n||e[51]!==z||e[52]!==R?(ne=s.jsx(zn,{open:n,onOpenChange:R,children:z}),e[50]=n,e[51]=z,e[52]=R,e[53]=ne):ne=e[53],ne};function u2(t){return t.contextRailOrder}function f2(t){return t.setContextRailOrder}function p2(t){return t.contextRailHiddenSurfaces}function m2(t){return t.setContextRailSurfaceVisible}function h2(t){return t.setContextRailHiddenSurfaces}function g2(t){return t.id}const lu=150,x2=500,b2=[],w2=t=>{const e=Be.c(70),{surface:n,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:u,badgeAriaLabel:c,badgeDescription:d,orderNumber:f,showOrderNumber:p,onSelect:m}=t,h=X(S2);let x;e[0]!==h?(x=Ci("switch_context_surface",h),e[0]=h,e[1]=x):x=e[1];const g=x;let b;e[2]!==f||e[3]!==g?(b=g&&g!==wc&&f!=null&&f<=10?ws(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=b):b=e[4];const w=b;let S;e[5]!==n.id?(S={id:n.id},e[5]=n.id,e[6]=S):S=e[6];const{attributes:y,listeners:I,setNodeRef:j,transform:R,transition:_,isDragging:P}=ld(S),k=u!=null&&u>0;let N;e[7]!==R?(N=dd.Translate.toString(R),e[7]=R,e[8]=N):N=e[8];let T;e[9]!==N||e[10]!==_?(T={transform:N,transition:_},e[9]=N,e[10]=_,e[11]=T):T=e[11];const A=P&&"z-10 opacity-70";let $;e[12]!==A?($=$e("relative",A),e[12]=A,e[13]=$):$=e[13];let K;e[14]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx("div",{}),e[14]=K):K=e[14];let q;e[15]!==m||e[16]!==n?(q=()=>m(n),e[15]=m,e[16]=n,e[17]=q):q=e[17];const M=c??i,z=n.id,ne=r?"text-primary":"text-muted-foreground hover:text-foreground";let H;e[18]!==ne?(H=$e("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",ne),e[18]=ne,e[19]=H):H=e[19];let V;e[20]!==n.icon||e[21]!==n.iconSrc||e[22]!==n.id?(V=n.id==="diff"?s.jsx(hc,{className:"h-[17px] w-[17px]"}):s.jsx(Ti,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=n.icon,e[21]=n.iconSrc,e[22]=n.id,e[23]=V):V=e[23];let F;e[24]!==k||e[25]!==f||e[26]!==o||e[27]!==p?(F=p&&f!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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:f===10?"0":f}):k?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):o?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[24]=k,e[25]=f,e[26]=o,e[27]=p,e[28]=F):F=e[28];let C;e[29]!==y||e[30]!==r||e[31]!==I||e[32]!==n.id||e[33]!==M||e[34]!==H||e[35]!==V||e[36]!==F||e[37]!==q?(C=s.jsx(Ft,{asChild:!0,children:s.jsxs("button",{type:"button",...y,...I,onClick:q,"aria-label":M,"aria-pressed":r,"data-context-surface":z,className:H,children:[V,F]})}),e[29]=y,e[30]=r,e[31]=I,e[32]=n.id,e[33]=M,e[34]=H,e[35]=V,e[36]=F,e[37]=q,e[38]=C):C=e[38];let te;e[39]!==h||e[40]!==n.id||e[41]!==w?(te=n.id==="terminal"?ws(Es("toggle_terminal",h),""):w,e[39]=h,e[40]=n.id,e[41]=w,e[42]=te):te=e[42];let re;e[43]!==i||e[44]!==te?(re=s.jsx(Hs,{label:i,shortcut:te}),e[43]=i,e[44]=te,e[45]=re):re=e[45];let Q;e[46]!==a?(Q=s.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[46]=a,e[47]=Q):Q=e[47];let ee;e[48]!==d?(ee=d?s.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null,e[48]=d,e[49]=ee):ee=e[49];let le;e[50]!==n.id?(le=n.id==="context"?s.jsx(md,{}):null,e[50]=n.id,e[51]=le):le=e[51];let O;e[52]!==re||e[53]!==Q||e[54]!==ee||e[55]!==le?(O=s.jsx($t,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[re,Q,ee,le]})}),e[52]=re,e[53]=Q,e[54]=ee,e[55]=le,e[56]=O):O=e[56];let Y;e[57]!==C||e[58]!==O?(Y=s.jsx(oo,{render:K,children:s.jsxs(Lt,{delayDuration:lu,children:[C,O]})}),e[57]=C,e[58]=O,e[59]=Y):Y=e[59];let Z;e[60]!==n.mode?(Z=s.jsx(io,{children:s.jsx(mc,{mode:n.mode})}),e[60]=n.mode,e[61]=Z):Z=e[61];let we;e[62]!==Y||e[63]!==Z?(we=s.jsxs(gr,{children:[Y,Z]}),e[62]=Y,e[63]=Z,e[64]=we):we=e[64];let L;return e[65]!==j||e[66]!==we||e[67]!==T||e[68]!==$?(L=s.jsx("div",{ref:j,style:T,className:$,children:we}),e[65]=j,e[66]=we,e[67]=T,e[68]=$,e[69]=L):L=e[69],L},y2=t=>{if(!t)return{icon:"ticket-2"};const e=lg(t,"line");return e?{icon:e}:{icon:cg,iconSrc:dg(t)}},v2=()=>{const t=Be.c(122),{t:e}=at(),n=Gs();let r;t[0]!==n?(r=n?us(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Fe=>o?Fe.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=X(i),u=X(k2),c=X(j2),d=X(C2),f=X(T2),p=X(N2),m=X(E2),h=X(P2),x=X(I2),g=Gu();let b;t[4]!==g?(b=Fe=>g.some(fe=>fe.instances.defaultInstance!==null&&Fe.entries[Jn({provider:fe.id,instance:fe.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=b):b=t[5];const w=hn(b),S=hn(D2),y=rg(o||null),I=yi(y==="none"?null:y??g[0]?.id),j=y==="none"?"pullRequest":I.terminology.changeRequest,{screenWidth:R}=yn(),_=xr(),P=n??null;let k;t[6]!==_||t[7]!==P?(k=lo(_,P),t[6]=_,t[7]=P,t[8]=k):k=t[8];const N=k,T=og(N),A=co(T),{git:$}=Is(),K=Vn(_2),q=Vn(A2);let M,z;t[9]!==K||t[10]!==q||t[11]!==$||t[12]!==T||t[13]!==N?(M=()=>{if(!$||!N||!T||T===N)return;sa(()=>K(T,$));const Fe=Yt(N),fe=Yt(T);return Ur.onGitRefreshHint(ke=>{const rt=Yt(ke.directory);rt!==Fe&&rt!==fe||sa(()=>q(T,$,{silent:!0}))})},z=[K,q,$,T,N],t[9]=K,t[10]=q,t[11]=$,t[12]=T,t[13]=N,t[14]=M,t[15]=z):(M=t[14],z=t[15]),l.useEffect(M,z);let ne;t[16]!==x?(ne=Ci("switch_context_surface",x),t[16]=x,t[17]=ne):ne=t[17];const H=ne,[V,F]=l.useState(!1);let C,te;t[18]!==H?(te=()=>{const Fe=new Set;let fe=null,ke=!1;const rt=O2,ge=()=>{Ra(H,Fe)?!ke&&fe===null&&(fe=setTimeout(()=>F(!0),x2)):(ke=!1,fe!==null&&(clearTimeout(fe),fe=null),F(!1))},lt=kt=>{if(Fe.add(kt.key.toLowerCase()),rt(kt.key)&&Ra(H,Fe)){ke=!0,fe!==null&&(clearTimeout(fe),fe=null),F(!1);return}ge()},Ct=kt=>{Fe.delete(kt.key.toLowerCase()),ge()},bt=()=>{Fe.clear(),ke=!1,fe!==null&&(clearTimeout(fe),fe=null),F(!1)};return window.addEventListener("keydown",lt,!0),window.addEventListener("keyup",Ct,!0),window.addEventListener("blur",bt),()=>{window.removeEventListener("keydown",lt,!0),window.removeEventListener("keyup",Ct,!0),window.removeEventListener("blur",bt),fe!==null&&clearTimeout(fe)}},C=[H],t[18]=H,t[19]=C,t[20]=te):(C=t[19],te=t[20]),l.useEffect(te,C);let re;t[21]===Symbol.for("react.memo_cache_sentinel")?(re={activationConstraint:{distance:8}},t[21]=re):re=t[21];let Q;t[22]===Symbol.for("react.memo_cache_sentinel")?(Q={activationConstraint:{delay:200,tolerance:6}},t[22]=Q):Q=t[22];const ee=rd(Vr(id,re),Vr(od,Q)),le=Bi(),O=Ia(M2),Y=Ia(F2),Z=a?.tabs??b2,we=ig(Z,n||null);let L;t[23]!==h||t[24]!==a?(L=bi(a,h),t[23]=h,t[24]=a,t[25]=L):L=t[25];const pe=L,je=A?.files.length??0;let Ee;if(t[26]!==d||t[27]!==c||t[28]!==le||t[29]!==y||t[30]!==R||t[31]!==S||t[32]!==Z||t[33]!==I||t[34]!==we){let Fe;t[36]!==y||t[37]!==I?(Fe=fe=>fe.id==="pr"?{...fe,...y2(y==="none"?null:I)}:fe,t[36]=y,t[37]=I,t[38]=Fe):Fe=t[38],Ee=ag({railOrder:c,hiddenSurfaces:d,isVSCode:wi(),screenWidth:R,tabs:Z,sourceControlConnected:S,workflowsShown:we,extras:le}).map(Fe),t[26]=d,t[27]=c,t[28]=le,t[29]=y,t[30]=R,t[31]=S,t[32]=Z,t[33]=I,t[34]=we,t[35]=Ee}else Ee=t[35];const Se=Ee;let Le;t[39]!==Z?(Le=Z.some(L2),t[39]=Z,t[40]=Le):Le=t[40];const Pe=Le;let Ve,Oe;t[41]!==m||t[42]!==h||t[43]!==w||t[44]!==o||t[45]!==Pe||t[46]!==pe||t[47]!==S?(Ve=()=>{!o||!w||S||Pe||!pe.has("pr")||m(o,Go(h,"pr"))},Oe=[m,h,o,w,Pe,pe,S],t[41]=m,t[42]=h,t[43]=w,t[44]=o,t[45]=Pe,t[46]=pe,t[47]=S,t[48]=Ve,t[49]=Oe):(Ve=t[48],Oe=t[49]),l.useEffect(Ve,Oe);const[be,ye]=l.useState(!1),Ue=l.useRef(null),Te=l.useRef(null);let Me;t[50]!==j||t[51]!==Se||t[52]!==e?(Me=Fe=>{const fe=Se.find(rt=>rt.id===Fe.active.id),ke=Ue.current?.getBoundingClientRect().left;!fe||ke===void 0||(Te.current?.cancel(),Te.current=Gi({mode:fe.mode,label:fe.label??e(Ws(fe.labelKey,j)),from:Go(X.getState().contextSurfaceZones,fe.mode)},rt=>rt.x<ke-16))},t[50]=j,t[51]=Se,t[52]=e,t[53]=Me):Me=t[53];const Re=Me;let ze;t[54]===Symbol.for("react.memo_cache_sentinel")?(ze=()=>{Te.current?.cancel(),Te.current=null},t[54]=ze):ze=t[54];const B=ze;let ce,G;t[55]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>()=>Te.current?.cancel(),G=[],t[55]=ce,t[56]=G):(ce=t[55],G=t[56]),l.useEffect(ce,G);let Ce;t[57]!==o||t[58]!==le||t[59]!==f?(Ce=Fe=>{const fe=Te.current;if(Te.current=null,fe?.finish(o))return;const{active:ke,over:rt}=Fe;if(!rt||ke.id===rt.id)return;const ge=Zo(X.getState().contextRailOrder,le),lt=ht=>{const St=ge.find(yt=>yt.id===ht);return St?Zs(St):null};if(lt(ke.id)!==lt(rt.id))return;const Ct=ge.map($2),bt=Ct.indexOf(ke.id),kt=Ct.indexOf(rt.id);bt===-1||kt===-1||f(j1(Ct,bt,kt))},t[57]=o,t[58]=le,t[59]=f,t[60]=Ce):Ce=t[60];const J=Ce;let Ne;if(t[61]!==Se){Ne=[];for(const Fe of Se){const fe=Ne.at(-1);fe&&Zs(fe[0])===Zs(Fe)?fe.push(Fe):Ne.push([Fe])}t[61]=Se,t[62]=Ne}else Ne=t[62];const Ae=Ne;let Ie;t[63]!==Se?(Ie=Fe=>{const fe=Se.find(rt=>rt.id===Fe.active.id);if(!fe)return Jo(Fe);const ke=Zs(fe);return Jo({...Fe,droppableContainers:Fe.droppableContainers.filter(rt=>{const ge=Se.find(lt=>lt.id===rt.id);return ge!==void 0&&Zs(ge)===ke})})},t[63]=Se,t[64]=Ie):Ie=t[64];const De=Ie;if(!o)return null;let We,Ke,Ze,Qe,qe,et,He,Ye,dt,nt;if(t[65]!==j||t[66]!==je||t[67]!==Y||t[68]!==De||t[69]!==o||t[70]!==Ae||t[71]!==O||t[72]!==J||t[73]!==Re||t[74]!==p||t[75]!==V||t[76]!==ee||t[77]!==pe||t[78]!==e||t[79]!==u){let Fe=0;Ye=Ue,t[90]!==e?(dt=e("contextRail.aria.rail"),t[90]=e,t[91]=dt):dt=t[91],nt="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",We=ad,Ke=ee,Ze=De,Qe=Re,qe=B,et=J,He=Ae.map((fe,ke)=>s.jsxs(l.Fragment,{children:[ke>0?s.jsx("div",{"aria-hidden":"true",className:"h-px w-4 shrink-0 bg-edge-strong"}):null,s.jsx(cd,{items:fe.map(B2),strategy:k1,children:fe.map(rt=>{Fe=Fe+1;const ge=rt.label??e(Ws(rt.labelKey,j)),lt=rt.id==="git"&&!u?je:0,Ct=Mn(rt.mode)&&!pe.has(rt.mode)?O[Lr(rt.mode)]??0:0,bt=lt>0?lt:Ct>0?Ct:null,kt=bt!==null&&lt===0;return s.jsx(w2,{surface:rt,isActive:pe.has(rt.mode),showActivityDot:!1,label:ge,description:e(Ws(rt.descriptionKey,j)),badgeCount:bt,badgeAriaLabel:bt!==null?e(kt?bt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":bt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ge,count:bt}):null,badgeDescription:bt!==null?e(kt?bt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":bt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:bt}):null,orderNumber:Fe,showOrderNumber:V,onSelect:ht=>{Mn(ht.mode)&&Y(Lr(ht.mode)),p(o,ht.mode)}},rt.id)})})]},Zs(fe[0]))),t[65]=j,t[66]=je,t[67]=Y,t[68]=De,t[69]=o,t[70]=Ae,t[71]=O,t[72]=J,t[73]=Re,t[74]=p,t[75]=V,t[76]=ee,t[77]=pe,t[78]=e,t[79]=u,t[80]=We,t[81]=Ke,t[82]=Ze,t[83]=Qe,t[84]=qe,t[85]=et,t[86]=He,t[87]=Ye,t[88]=dt,t[89]=nt}else We=t[80],Ke=t[81],Ze=t[82],Qe=t[83],qe=t[84],et=t[85],He=t[86],Ye=t[87],dt=t[88],nt=t[89];let ut;t[92]!==We||t[93]!==Ke||t[94]!==Ze||t[95]!==Qe||t[96]!==qe||t[97]!==et||t[98]!==He?(ut=s.jsx(We,{sensors:Ke,collisionDetection:Ze,onDragStart:Qe,onDragCancel:qe,onDragEnd:et,children:He}),t[92]=We,t[93]=Ke,t[94]=Ze,t[95]=Qe,t[96]=qe,t[97]=et,t[98]=He,t[99]=ut):ut=t[99];let oe;t[100]!==e?(oe=e("contextRail.configure.open"),t[100]=e,t[101]=oe):oe=t[101];let de;t[102]===Symbol.for("react.memo_cache_sentinel")?(de=()=>ye(!0),t[102]=de):de=t[102];let ve;t[103]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx(se,{name:"equalizer-2",className:"h-[17px] w-[17px]"}),t[103]=ve):ve=t[103];let v;t[104]!==oe?(v=s.jsx(Ft,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":oe,onClick:de,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:ve})}),t[104]=oe,t[105]=v):v=t[105];let ae;t[106]!==e?(ae=e("contextRail.configure.open"),t[106]=e,t[107]=ae):ae=t[107];let W;t[108]!==ae?(W=s.jsx($t,{side:"left",sideOffset:8,children:ae}),t[108]=ae,t[109]=W):W=t[109];let me;t[110]!==v||t[111]!==W?(me=s.jsxs(Lt,{delayDuration:lu,children:[v,W]}),t[110]=v,t[111]=W,t[112]=me):me=t[112];let he;t[113]!==be?(he=s.jsx(d2,{open:be,onOpenChange:ye}),t[113]=be,t[114]=he):he=t[114];let Je;return t[115]!==Ye||t[116]!==dt||t[117]!==nt||t[118]!==ut||t[119]!==me||t[120]!==he?(Je=s.jsxs("nav",{ref:Ye,"aria-label":dt,className:nt,children:[ut,me,he]}),t[115]=Ye,t[116]=dt,t[117]=nt,t[118]=ut,t[119]=me,t[120]=he,t[121]=Je):Je=t[121],Je};function S2(t){return t.shortcutOverrides}function k2(t){return t.workStatusPanelVisible}function j2(t){return t.contextRailOrder}function C2(t){return t.contextRailHiddenSurfaces}function T2(t){return t.setContextRailOrder}function N2(t){return t.openContextSurface}function E2(t){return t.closeContextZone}function P2(t){return t.contextSurfaceZones}function I2(t){return t.shortcutOverrides}function R2(t){return t.status?.status==="connected"}function D2(t){return Object.values(t.entries).some(R2)}function _2(t){return t.ensureStatus}function A2(t){return t.fetchStatus}function O2(t){return t.length===1&&t>="0"&&t<="9"}function M2(t){return t.countByGuest}function F2(t){return t.clearBadge}function L2(t){return t.mode==="pr"&&t.targetPath}function $2(t){return t.id}function B2(t){return t.id}const Ms=t=>t?s.jsx("span",{className:"oc-title-rest",children:t}):void 0,ks=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},z2=()=>{const{t}=at(),{git:e,sourceControl:n}=Is(),[r,o]=l.useState(!1),[i,a]=l.useState(null),[u,c]=l.useState([]),[d,f]=l.useState(!1),[p,m]=l.useState(!1),[h,x]=l.useState(!1),[g,b]=l.useState(!1),[w,S]=l.useState(new Set),y=tt(G=>G.getWorktreeMetadata),I=tt(G=>G.newSessionDraft),j=tt(G=>G.setNewSessionDraftTarget),R=tt(G=>G.setDraftBootstrapPendingDirectory),_=fg,P=xg,k=tt(G=>G.deleteSessions),N=tt(G=>G.archiveSessions),T=tt(G=>G.unarchiveSessions),A=X(G=>G.showDeletionDialog),$=X(G=>G.setShowDeletionDialog),K=is(G=>G.currentDirectory),q=is(G=>G.homeDirectory),M=Gt(G=>G.projects),z=Gt(G=>G.activeProjectId),{isMobile:ne,isTablet:H,hasTouchInput:V}=yn(),F=ne||H||V,C=l.useMemo(()=>{const Ce=(z?M.find(J=>J.id===z)??null:null)?.path??K;return ks(Ce)},[z,K,M]),te=l.useCallback(G=>{const J=ks(G.projectDirectory)||C;return{id:(M.find(Ae=>ks(Ae.path)===J)??null)?.id??`path:${J}`,path:J}},[C,M]),re=g&&w.size>0,[Q,ee]=l.useState(!1),le=i?.mode==="worktree"?i.worktree??u[0]?.metadata??null:null,O=le?.path,Y=le?.branch,Z=le?te(le).path:null;l.useEffect(()=>{if(ee(!1),!O||!Z)return;let G=!1;return ug(Z,{path:O,branch:Y??""}).then(Ce=>{G||ee(Ce)}),()=>{G=!0}},[Y,O,Z]);const we=l.useMemo(()=>{if(!Q)return!1;const G=i?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!!G.status?.upstream?.split("/")[0]?.trim():u.length>0&&u.every(({metadata:Ce})=>typeof Ce.branch=="string"&&Ce.branch.trim().length>0&&!!Ce.status?.upstream?.split("/")[0]?.trim())},[Q,i?.worktree,u]),L=i?.mode==="worktree",pe=h||!L||!we,je=h||!L,Ee=l.useCallback(G=>{a({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),Se=l.useCallback(()=>{a(null),c([]),f(!1),m(!1),x(!1),b(!1),S(new Set)},[]),Le=l.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const Ae=G.sessions[0];await _(Ae.id)?_e.success(t("sessions.sidebar.session.delete.success")):_e.error(t("sessions.sidebar.session.delete.error"));return}const Ce=G.sessions.map(Ae=>Ae.id),{deletedIds:J,failedIds:Ne}=await k(Ce);if(J.length>0){const Ae=Ne.length>0?Ne.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Ne.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Ne.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.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:Ms(Ae)})}Ne.length>0&&_e.error(Ne.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Ne.length}),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[_,k,t]);l.useEffect(()=>Ur.onDirectoryRequest(()=>{o(!0)}),[]),l.useEffect(()=>{if(!i){c([]),f(!1),m(!1),b(!1),S(new Set);return}const G=i.sessions.map(Ne=>{const Ae=y(Ne.id);return Ae?{session:Ne,metadata:Ae}:null}).filter(Ne=>!!Ne);c(G),f(!1),b(!1),S(new Set);const Ce=new Map;if(i.worktree?.path&&Ce.set(ks(i.worktree.path),i.worktree),G.forEach(({metadata:Ne})=>{Ne.path&&Ce.set(ks(Ne.path),Ne)}),Ce.size===0){b(!0);return}let J=!1;return(async()=>{const Ne=new Map,Ae=new Set;await Promise.all(Array.from(Ce.entries()).map(async([Ie,De])=>{try{const We=await Da(De.path);Ne.set(Ie,We),We?.isDirty&&Ae.add(Ie)}catch{De.status&&(Ne.set(Ie,De.status),De.status.isDirty&&Ae.add(Ie))}})).catch(Ie=>{console.warn("Failed to inspect worktree status before deletion:",Ie)}),!J&&(S(Ae),b(!0),a(Ie=>{if(!Ie?.worktree?.path)return Ie;const De=ks(Ie.worktree.path),We=Ne.get(De);if(!We)return Ie;const Ke=Ie.worktree.status;return Ke?.isDirty===We.isDirty&&Ke?.ahead===We.ahead&&Ke?.behind===We.behind&&Ke?.upstream===We.upstream?Ie:{...Ie,worktree:{...Ie.worktree,status:We}}}),c(Ie=>Ie.map(De=>{const We=ks(De.metadata.path),Ke=Ne.get(We);return Ke?{session:De.session,metadata:{...De.metadata,status:Ke}}:De})))})(),()=>{J=!0}},[i,y]),l.useEffect(()=>{we||f(!1)},[we]);const Pe=l.useCallback(async(G,Ce,J)=>{const Ne=d&&we,Ae=te(G),Ie=ks(G.path),De=ks(Ae.path);try{await pg(Ae,G,{deleteRemoteBranch:Ne,deleteLocalBranch:Ce,remoteName:G.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:n}});const We=Ze=>!!(Ie&&Ze&&mg(Ie,Ze)),Ke=ks(I?.directoryOverride);return I?.open&&We(Ke)&&De&&(R(null),j({projectId:Ae.id,directoryOverride:De},{force:!0})),We(ks(K))&&De&&is.getState().setDirectory(De,{showOverlay:!1}),!0}catch(We){return _e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:J,description:Ms(We instanceof Error?We.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[we,K,d,te,e,I?.directoryOverride,I?.open,R,j,n,t]),Ve=l.useCallback((G,Ce,J)=>{const Ne=d&&we,Ae=_e.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:_a(G)}));return hg(G.path),(async()=>{try{const Ie=await gg({sessionIds:Ce,removeWorktree:()=>Pe(G,J,Ae),restoreSessions:We=>T(We,{undo:!0}),archiveSessions:async We=>We.length===1?await P(We[0])?{archivedIds:We,failedIds:[]}:{archivedIds:[],failedIds:We}:N(We)});if(!Ie.removed)return;Cc(Ce,{projectId:te(G).id}),_e.success(t(Ne?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ae,description:Ms(_a(G))});const{failedIds:De}=Ie.archive;De.length>0&&_e.error(De.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:De.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:De.length}),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(Ie){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ae,description:Ms(Ie instanceof Error?Ie.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{bg(G.path)}})()},[P,N,we,d,te,Pe,t,T]),Oe=l.useRef(new Set),be=l.useCallback(async(G,Ce)=>{const J=ks(G.path);if(!Oe.current.has(J)){Oe.current.add(J);try{const Ne=await Da(G.path).catch(()=>{});if(!wg(Ne)){Ee({sessions:Ce,mode:"worktree",worktree:G});return}await Ve(G,Ce.map(Ae=>Ae.id),!0)}finally{Oe.current.delete(J)}}},[Ee,Ve]);l.useEffect(()=>Ur.onDeleteRequest(G=>{if(!A&&(G.mode??"session")==="session"){Le(G);return}if(G.mode==="worktree"&&G.skipDialogIfSafe&&G.worktree){be(G.worktree,G.sessions);return}Ee(G)}),[Ee,A,Le,be]);const ye=l.useCallback(async()=>{if(i){x(!0);try{if(L){const G=i.worktree??u[0]?.metadata;if(!G){_e.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),x(!1);return}Ve(G,i.sessions.map(Ce=>Ce.id),p&&Q),Se();return}if(i.sessions.length===1){const G=i.sessions[0];if(!await _(G.id)){_e.error(t("sessions.sidebar.session.delete.error")),x(!1);return}_e.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const G=i.sessions.map(Ne=>Ne.id),{deletedIds:Ce,failedIds:J}=await k(G);if(Ce.length>0){const Ne=J.length>0?J.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:J.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:J.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;_e.success(Ce.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ce.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ce.length}),{description:Ms(Ne),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(J.length>0&&(_e.error(J.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:J.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:J.length}),{description:Ms(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Ce.length===0)){x(!1);return}}Se()}finally{x(!1)}}},[Q,i,u,p,_,k,Se,L,Ve,t]),Ue=i?.worktree??u[0]?.metadata??null;let Te="";if(i?.mode==="worktree"){const G=i.sessions.length;G===0?Te=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):G===1?Te=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:G}):Te=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:G})}else if(i){const G=i.sessions.length;G===1?Te=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):Te=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:G,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:G})}const Me=i?s.jsxs("div",{className:$e(L?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&s.jsxs("div",{className:$e(L?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-edge-muted bg-sidebar/60 p-3"),children:[L&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),s.jsxs("ul",{className:$e(L?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(G=>s.jsxs("li",{className:$e(L?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[s.jsx("span",{className:$e(!L&&"hidden"),children:"•"}),s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),i.sessions.length>5&&s.jsx("li",{className:$e(L?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:i.sessions.length-5})})]})]}),L?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(se,{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")}),Ue?.label?s.jsx("span",{className:"typography-micro text-muted-foreground",children:Ue.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Ue?kc(Ue.path,q):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-edge-muted bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Re=L&&Q?we?s.jsxs("button",{type:"button",onClick:()=>{pe||f(G=>!G)},disabled:pe,"aria-pressed":d,className:$e("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",pe?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[d?s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,ze=L&&Q?s.jsxs("button",{type:"button",onClick:()=>{je||m(G=>!G)},disabled:je,"aria-pressed":p,className:$e("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",je?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(se,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,B=L?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:[ze,Re]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:Se,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:ye,disabled:h,children:t(h?"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:()=>$(!A),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":!A,children:[A?s.jsx(se,{name:"checkbox-blank",className:"size-4"}):s.jsx(se,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:Se,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:ye,disabled:h,children:h?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),ce=L?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[F?s.jsx(yg,{open:!!i,onClose:()=>{h||Se()},title:ce,footer:s.jsx("div",{className:"flex justify-end gap-2",children:B}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Te&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:Te}),Me]})}):s.jsx(zn,{open:!!i,onOpenChange:G=>{if(!G){if(h)return;Se()}},children:s.jsxs(Bn,{className:$e(L?"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($n,{children:[s.jsxs(Fn,{className:$e(L&&"flex items-center gap-2"),children:[L&&s.jsx(se,{name:"delete-bin",className:"h-5 w-5"}),ce]}),Te&&s.jsx(Ln,{children:Te})]}),L?s.jsx(fs,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:Me}):s.jsx("div",{children:Me}),s.jsx(Br,{className:"mt-2 gap-2 pt-1 pb-1",children:B})]})}),s.jsx(Jf,{open:r,onOpenChange:o})]})},cu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],W2=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,U2=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,V2=t=>cu.some(({pattern:e})=>e.test(t));async function H2(t,e,n){if(!t)return null;const r=K2(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=Z2(n);if(o){const i=await X2(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await q2(t)){const o=await G2(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function q2(t){const e=`${t}/index.html`,n=await Xr(e,t);return typeof n=="string"&&n.trim().length>0}async function G2(){try{const t=await Vs("/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 K2(t){for(const e of t){const n=U2.exec(e.command.trim())?.[1];if(n&&V2(n)||e.source!=="shared"&&W2.test(e.name.trim()))return e}return null}function Z2(t){for(const{pattern:e}of cu)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function X2(t){const e=await Xr(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.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,o]of n){const i=await Xr(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Xr(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Vs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Jl()?.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 Vs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Y2(t){try{const e=await Xr(`${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 J2=/\{(worktree|branch)\}/g,Uo=63,Q2=new Set(["main","master"]),du=t=>/\{(worktree|branch)\}/.test(t??""),ek=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},uu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Uo)return e;const n=await ek(e);return n?`${e.slice(0,Uo-7).replace(/-+$/,"")}-${n}`:e.slice(0,Uo).replace(/-+$/,"")},tk=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},sk=async(t,e,n)=>{const r=n.includes("{branch}"),o=n.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:tk(i.current),linkedWorktree:o}},nk=async t=>!t.linkedWorktree||!t.branch||Q2.has(t.branch)?"":uu(t.branch.split("/").pop()??""),rk=t=>{const e=t.lastIndexOf("@"),n=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",u=i.split(".").map(c=>c.replace(/^-+|-+$/g,"")).filter(Boolean);return`${n}${u.join(".")}${a}`},ok=async(t,e)=>{const n={worktree:await nk(e),branch:e.branch?await uu(e.branch):""},r=t.replace(J2,(c,d)=>n[d]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",u=""]=o;return`${i}${rk(a)}${u}`},ik=async(t,e,n)=>du(e)?ok(e,await sk(t,n,e)):e,fu="oc.projectActions.selectedAction.v1",ak=ei(Ps(),ei(Ps(),Ps())),pu=()=>{const t=so().getItem(fu);if(t===null)return{};try{const e=ak.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},El=(t,e=as())=>pu()[e]?.[t]??null,lk=(t,e,n=as())=>{const r=pu();r[n]?.[t]!==e&&so().setItem(fu,JSON.stringify({...r,[n]:{...r[n],[t]:e}}))},ck=15e3,dk=3e3,uk=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}},fk=({projectRef:t,directory:e,allowMobile:n=!1})=>{const{t:r}=at(),{currentTheme:o}=no(),{terminal:i,runtime:a,git:u}=Is(),c=Gs(),{isMobile:d}=yn(),f=l.useMemo(()=>Us(),[]),p=va(v=>v.instances),m=va(v=>v.load),h=X(v=>v.terminalShell),x=X(v=>v.terminalLoginShells.includes(v.terminalShell)),g=X(v=>v.setSettingsPage),b=X(v=>v.setSettingsDialogOpen),w=X(v=>v.setSettingsProjectsSelectedId),S=X(v=>v.openContextPreview),y=wt(v=>v.ensureDirectory),I=wt(v=>v.reconcileServerSessions),j=wt(v=>v.setTabLabel),R=wt(v=>v.setTabIconKey),_=wt(v=>v.setActiveTab),P=wt(v=>v.setConnecting),k=wt(v=>v.setTabSessionId),N=wt(v=>v.setTabPurpose),T=wt(v=>v.allocateActionExecution),A=wt(v=>v.setTabLifecycle),$=wt(v=>v.setTabPreviewUrl),K=wt(v=>v.matchesActionExecution),q=wt(v=>v.captureStartedActionMutationRevisions),[M,z]=l.useState([]),ne=l.useRef(null),[H,V]=l.useState(()=>t?.id?El(t.id):null),[F,C]=l.useState(!1),te=l.useRef({}),re=l.useRef({}),Q=l.useRef({}),ee=l.useRef(new Set),le=l.useRef(0),[O,Y]=l.useState({}),Z=t?.id??null,we=t?.path??"";l.useEffect(()=>{V(Z?El(Z):null)},[Z]);const L=l.useMemo(()=>Z?{id:Z,path:we}:null,[Z,we]);l.useEffect(()=>{f&&m().catch(()=>{})},[f,m]);const pe=l.useCallback(async v=>{await qn(v)},[]),je=l.useCallback(async()=>{if(!L)return;const v=le.current+1;le.current=v,C(!0);try{const ae=await Io(L);if(le.current!==v)return;ne.current=ae;const W=ae.projectActions;z(W)}catch{if(le.current!==v)return}finally{le.current===v&&C(!1)}},[L]),Ee=l.useMemo(()=>To(e||L?.path||""),[e,L?.path]),Se=l.useMemo(()=>To(L?.path||""),[L?.path]),Le=l.useMemo(()=>To(c||"")||Ee,[c,Ee]),Pe=l.useRef(Le);l.useEffect(()=>{Pe.current=Le},[Le]);const Ve=wt(v=>Ee?v.getDirectoryState(Ee):void 0),Oe=wt(v=>Se&&Se!==Ee?v.getDirectoryState(Se):void 0),be=l.useMemo(()=>{const v=Ee?[{directory:Ee,state:Ve}]:[];return Se&&Se!==Ee&&v.push({directory:Se,state:Oe}),v},[Ve,Ee,Se,Oe]),ye=l.useMemo(()=>{const v=Ee?[Ee]:[];return Se&&Se!==Ee&&v.push(Se),v},[Ee,Se]),Ue=l.useCallback(v=>v.id!==rn&&v.runIn==="parent"&&Se||Ee,[Ee,Se]),Te=l.useCallback((v,ae,W)=>`${v}::${ae}::${W}`,[]),Me=l.useCallback((v,ae,W=wt.getState())=>v?W.getDirectoryState(v)?.tabs.find(me=>me.purpose.type==="project-action"&&me.purpose.actionId===ae)??null:null,[]),Re=l.useMemo(()=>{const v={};for(const{directory:ae,state:W}of be)for(const me of W?.tabs??[]){if(me.purpose.type!=="project-action"||!me.purpose.executionId||!me.terminalSessionId||me.lifecycle==="idle"||me.lifecycle==="exited")continue;const he=jn(ae,me.purpose.actionId),Je=Te(ae,me.purpose.actionId,me.purpose.executionId);v[he]={directory:ae,actionId:me.purpose.actionId,tabId:me.id,sessionId:me.terminalSessionId,executionId:me.purpose.executionId,status:me.lifecycle==="stopping"?"stopping":O[Je]?"waiting-for-preview":"running"}}return v},[Te,O,be]),ze=l.useCallback((v,ae,W)=>{const me=jn(v,ae),he=Te(v,ae,W),Fe=te.current[me]?.executionId===W,fe=globalThis.window,ke=rt=>{fe?.clearTimeout(Q.current[rt]),delete Q.current[rt]};Fe&&(delete te.current[me],ke(me)),re.current[he]?.(),delete re.current[he],ke(he),Y(rt=>{if(!rt[he])return rt;const ge={...rt};return delete ge[he],ge})},[Te]),B=l.useCallback(v=>{re.current[v]?.(),delete re.current[v]},[]),ce=l.useCallback(v=>{window.clearTimeout(Q.current[v]),delete Q.current[v]},[]);l.useEffect(()=>{const v=re.current,ae=Q.current;return()=>{for(const W of Object.keys(v))B(W);for(const W of Object.keys(ae))ce(W)}},[ce,B]),l.useEffect(()=>{const v=new Set(ye);for(const ae of Object.values(te.current))v.has(ae.directory)||ze(ae.directory,ae.actionId,ae.executionId);for(const ae of Object.keys(re.current)){const W=ae.split("::",1)[0]??"";v.has(W)||B(ae)}},[ze,B,ye]);const G=l.useCallback((v,ae)=>{X.getState().openContextPanelTab(v,{mode:"terminal",targetDirectory:ae===v?null:ae})},[]),Ce=l.useMemo(()=>({id:rn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),J=!d,Ne=l.useMemo(()=>J?[...M,Ce]:M,[M,Ce,J]),Ae=l.useMemo(()=>H?Ne.find(v=>v.id===H)??null:null,[Ne,H]);l.useEffect(()=>{je()},[je]);const[Ie,De]=l.useState(0),We=l.useCallback(()=>(De(v=>v+1),()=>De(v=>v-1)),[]),Ke=Ie>0;l.useEffect(()=>{if(!Ke)return;const v=ye.map(ae=>Qf(i,ae,q,W=>I(ae,W.sessions,{startedActionMutationRevisions:W.startedActionMutationRevisions})));return()=>{for(const ae of v)ae()}},[q,Ke,I,i,ye]),l.useEffect(()=>{for(const{directory:v,state:ae}of be)if(v)for(const W of ae?.tabs??[]){if(W.purpose.type!=="project-action")continue;const me=W.purpose.actionId,he=Ne.find(fe=>fe.id===me),Je=he?.name??me,Fe=he?.icon||"play";W.label!==Je&&j(v,W.id,Je),W.iconKey!==Fe&&R(v,W.id,Fe)}},[Ne,R,j,be]),l.useEffect(()=>{const v=globalThis.window;if(!v)return;const ae=W=>{const me=W.detail;Z&&(me?.projectId&&me.projectId!==Z||je())};return v.addEventListener(Sa,ae),()=>{v.removeEventListener(Sa,ae)}},[je,Z]),l.useEffect(()=>{const v=W=>{delete Q.current[W];const me=te.current[W];if(!me||me.openedUrl)return;const he=Te(me.directory,me.actionId,me.executionId),Je=me.announced;if(Je.length!==0){if(window.clearTimeout(Q.current[he]),delete Q.current[he],me.openedUrl=!0,Y(Fe=>{if(!Fe[he])return Fe;const fe={...Fe};return delete fe[he],fe}),Je.length===1){Bo(me.directory,[]),$(me.directory,me.tabId,Je[0],{locked:!1,autoOpened:!0}),S(me.directory,Je[0]);return}me.offering=!0,Bo(me.directory,Je),X.getState().openContextSurface(me.directory,"browser"),_e.info(r("projectActions.toast.multipleServers"))}},ae=()=>{const W=wt.getState(),me=W.sessions,he=Re;for(const[Je,Fe]of Object.entries(he)){const ke=me.get(Fe.directory)?.tabs.find(xt=>xt.id===Fe.tabId);if(!ke||ke.terminalSessionId!==Fe.sessionId){ze(Fe.directory,Fe.actionId,Fe.executionId);continue}const rt=te.current[Je],ge=rt?.executionId===Fe.executionId?rt:{hostDirectory:Pe.current||Fe.directory,directory:Fe.directory,tabId:Fe.tabId,actionId:Fe.actionId,executionId:Fe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};te.current[Je]=ge;const lt=Ne.find(xt=>xt.id===Fe.actionId),Ct=W.getBuffer(Fe.directory,Fe.tabId).chunks;if(!lt||Ct.length===0)continue;const bt=Ct.filter(xt=>ge.lastSeenChunkId===null||xt.id>ge.lastSeenChunkId);if(bt.length===0)continue;const kt=bt.map(xt=>xt.data).join(""),ht=`${ge.tail}${kt}`;for(const xt of op(ht))ge.proxiedPorts.includes(xt)||ge.proxiedPorts.push(xt);if(ge.openInPreview&&(!ge.openedUrl||ge.offering)){const xt=ip(ht,{proxiedPorts:ge.proxiedPorts,namedAddressesReachable:!ka()}),vt=ge.announced.length;for(const Pt of xt)ge.announced.includes(Pt)||ge.announced.push(Pt);const ct=ge.announced.length-vt;ge.offering&&ct>0?Bo(Fe.directory,ge.announced):!ge.openedUrl&&vt===0&&ge.announced.length>0&&(window.clearTimeout(Q.current[Je]),Q.current[Je]=window.setTimeout(()=>v(Je),dk))}const St=!ge.openedUrl&&lt.autoOpenUrl===!0&&!ge.openInPreview?ap(ht,{proxiedPorts:ge.proxiedPorts,namedAddressesReachable:!ka()}):null,yt=bt[bt.length-1]?.id??ge.lastSeenChunkId;if(ge.lastSeenChunkId=yt,ge.tail=ht.slice(-512),St)if(ge.openedUrl=!0,ge.openInPreview){const xt=he[Je];xt&&($(xt.directory,xt.tabId,St,{locked:!1,autoOpened:!1,expectedExecutionId:xt.executionId}),xt.status==="waiting-for-preview"&&Y(vt=>{const ct=Te(xt.directory,xt.actionId,xt.executionId);if(!vt[ct])return vt;const Pt={...vt};return delete Pt[ct],Pt}),window.clearTimeout(Q.current[Je]),delete Q.current[Je],S(xt.directory,St))}else pe(St),_e.success(r("projectActions.toast.openedUrlFromOutput"));te.current[Je]=ge}for(const Je of Object.keys(te.current))if(!he[Je]){const Fe=te.current[Je],fe=Fe?me.get(Fe.directory)?.tabs.find(rt=>rt.id===Fe.tabId):void 0;if(fe?.purpose.type==="project-action"&&fe.purpose.executionId===Fe?.executionId&&!!fe.terminalSessionId&&fe.lifecycle!=="idle"&&fe.lifecycle!=="exited")continue;delete te.current[Je],window.clearTimeout(Q.current[Je]),delete Q.current[Je]}};return ae(),wt.subscribe((W,me)=>{(W.sessions!==me.sessions||W.buffers!==me.buffers)&&ae()})},[ze,Pe,Ne,Te,S,pe,Re,$,r]),l.useEffect(()=>{for(const{directory:v,state:ae}of be)for(const W of ae?.tabs??[]){if(W.purpose.type!=="project-action"||!W.purpose.executionId||!W.terminalSessionId||W.lifecycle!=="running")continue;const me=W.purpose.actionId,he=W.purpose.executionId,Je=Te(v,me,he);if(re.current[Je])continue;const Fe=i.connect(W.terminalSessionId,{onEvent:fe=>{if(!K(v,W.id,he))return;fe.type==="snapshot"&&(wt.getState().replaceBuffer(v,W.id,fe.data??"",fe.sequence??0,na(fe)),fe.status==="running"&&wt.getState().setTabLifecycle(v,W.id,"running",{expectedExecutionId:he}),fe.status==="exited"&&(wt.getState().setTabLifecycle(v,W.id,"exited",{expectedExecutionId:he}),wt.getState().setTabPurpose(v,W.id,{type:"project-action",actionId:me,executionId:null}),ze(v,me,he)));const ke=fe.type==="data"?fe.data??"":"";ke&&wt.getState().appendToBuffer(v,W.id,ke,fe.sequence,fe.replayData),fe.type==="exit"&&(wt.getState().setTabLifecycle(v,W.id,"exited",{expectedExecutionId:he}),wt.getState().setTabPurpose(v,W.id,{type:"project-action",actionId:me,executionId:null}),ze(v,me,he))},onError:(fe,ke)=>{!ke||!K(v,W.id,he)||(wt.getState().setTabLifecycle(v,W.id,"exited",{expectedExecutionId:he}),wt.getState().setTabSessionId(v,W.id,null,{expectedExecutionId:he}),wt.getState().setTabPurpose(v,W.id,{type:"project-action",actionId:me,executionId:null}),ze(v,me,he))}},v);re.current[Je]=Fe.close}},[ze,Te,K,i,be]);const Ze=l.useCallback(async v=>{const ae=Ue(v);if(!ae)throw new Error(r("projectActions.error.noActiveDirectory"));const W=jn(ae,v.id);y(ae);const me=wt.getState(),he=Me(ae,v.id,me),Je=he?.id??me.createTab(ae);j(ae,Je,v.name),R(ae,Je,v.icon||"play"),he||N(ae,Je,{type:"project-action",actionId:v.id,executionId:null}),_(ae,Je);const fe=wt.getState().getDirectoryState(ae)?.tabs.find(ke=>ke.id===Je);return{executionDirectory:ae,key:W,tabId:Je,sessionId:fe?.terminalSessionId??null,executionId:fe?.purpose.type==="project-action"?fe.purpose.executionId:null}},[y,Ue,Me,_,R,j,N,r]),Qe=l.useCallback(async v=>{if(a.isVSCode||!n&&d)return;if(!Ee){_e.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ae=jn(Ue(v),v.id),W=Re[ae];if(W&&W.status==="running"||ee.current.has(ae))return;ee.current.add(ae);let me=null;try{const he=v.id===rn?await(async()=>{const pt=L??{id:"",path:Ee},[mt,Ot]=await Promise.all([Io(pt),Y2(Ee)]),Ut=await H2(Ee,mt.projectActions,Ot);if(!Ut)throw new Error(r("contextPanel.preview.noDevServer"));return mt.projectActions.find(ps=>ps.id===Ut.actionId)?.source==="shared"&&!await Aa(pt,mt)?null:{id:rn,name:r("projectActions.actions.autoDiscover"),command:Ut.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Ut.previewUrlHint||""}})():v;if(!he)return;const Je=he.autoOpenUrl===!0&&(he.openUrl||"").trim().length>0,Fe=!Je&&v.id!==rn,fe=Pe.current||Ee,{executionDirectory:ke,key:rt,tabId:ge}=await Ze(he),lt=ep(he.command);if(!lt)throw new Error(r("projectActions.error.failedToRunAction"));const Ct=he.autoOpenUrl===!0&&f&&(he.desktopOpenSshForward||"").trim().length>0,bt=he.autoOpenUrl&&he.openUrl||"";let kt=!1;const ht=du(bt)?await ik(u,bt,ke).catch(()=>(kt=!0,"")):bt,St=he.autoOpenUrl?uk(ht):null,yt=he.autoOpenUrl&&f?tp(he.desktopOpenSshForward,p):null;if(i.listSessions){const pt=Me(ke,he.id);if(pt?.purpose.type==="project-action"&&pt.purpose.executionId===null){const mt=await sp(i,ke,{captureStartedActionMutationRevisions:q});mt&&I(ke,mt.sessions,{startedActionMutationRevisions:mt.startedActionMutationRevisions})}}const xt=Me(ke,he.id);let vt,ct;if(xt?.lifecycle==="running"&&xt.terminalSessionId&&xt.purpose.type==="project-action"&&xt.purpose.executionId)vt=xt.terminalSessionId,ct=xt.purpose.executionId;else{const pt=xt?.purpose.type==="project-action"?xt.purpose.executionId:null;pt&&ze(ke,he.id,pt);const mt=T(ke,ge,he.id);if(!mt)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));me={directory:ke,tabId:ge,id:mt},P(ke,ge,!0,{expectedExecutionId:mt});const Ot=await np({terminal:i,createOptions:{cwd:ke,shell:h,loginShell:x,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:lt,isRunStillExpected:()=>K(ke,ge,mt),purpose:{type:"project-action",actionId:he.id,executionId:mt}});if(!K(ke,ge,mt)){Ot.sessionId===mt&&await i.close(Ot.sessionId).catch(()=>{});return}ct=Ot.purpose?.type==="project-action"?Ot.purpose.executionId:mt,vt=Ot.sessionId,N(ke,ge,{type:"project-action",actionId:he.id,executionId:ct}),k(ke,ge,vt,{expectedExecutionId:ct}),P(ke,ge,!1,{expectedExecutionId:ct})}Fe&&fe&&G(fe,ke),te.current[rt]={hostDirectory:fe,directory:ke,tabId:ge,actionId:he.id,executionId:ct,lastSeenChunkId:null,openedUrl:!!yt||!!St||Je,tail:"",openInPreview:he.id===rn,announced:[],offering:!1,proxiedPorts:[]};const Pt=Te(ke,he.id,ct);P(ke,ge,!0,{expectedExecutionId:ct});const Dt=i.connect(vt,{onEvent:pt=>{if(!K(ke,ge,ct)||pt.purpose?.type==="project-action"&&pt.purpose.executionId!==ct)return;pt.type==="snapshot"&&(wt.getState().replaceBuffer(ke,ge,pt.data??"",pt.sequence??0,na(pt)),wt.getState().setConnecting(ke,ge,!1,{expectedExecutionId:ct}),pt.purpose?.type==="project-action"&&wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:pt.purpose.actionId,executionId:pt.purpose.executionId}),pt.status==="running"&&wt.getState().setTabLifecycle(ke,ge,"running",{expectedExecutionId:ct}),pt.status==="exited"&&(wt.getState().setTabLifecycle(ke,ge,"exited",{expectedExecutionId:ct}),wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:he.id,executionId:null}),ze(ke,he.id,ct)));const mt=pt.type==="data"?pt.data??"":"";mt&&wt.getState().appendToBuffer(ke,ge,mt,pt.sequence,pt.replayData),pt.type==="exit"&&(wt.getState().setTabLifecycle(ke,ge,"exited",{expectedExecutionId:ct}),wt.getState().setConnecting(ke,ge,!1,{expectedExecutionId:ct}),wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:he.id,executionId:null}),ze(ke,he.id,ct))},onError:(pt,mt)=>{K(ke,ge,ct)&&(wt.getState().setConnecting(ke,ge,!1,{expectedExecutionId:ct}),mt&&(wt.getState().setTabLifecycle(ke,ge,"exited",{expectedExecutionId:ct}),wt.getState().setTabSessionId(ke,ge,null,{expectedExecutionId:ct}),wt.getState().setTabPurpose(ke,ge,{type:"project-action",actionId:he.id,executionId:null}),ze(ke,he.id,ct)))}},ke);if(!K(ke,ge,ct)){Dt.close();return}re.current[Pt]?.(),re.current[Pt]=Dt.close,window.clearTimeout(Q.current[Pt]),delete Q.current[Pt],he.id===rn&&!St&&(Y(pt=>({...pt,[Pt]:!0})),Q.current[Pt]=window.setTimeout(()=>{delete Q.current[Pt];const pt=te.current[rt];!pt||pt.executionId!==ct||pt.openedUrl||pt.offering||K(ke,ge,ct)&&(Y(mt=>{if(!mt[Pt])return mt;const Ot={...mt};return delete Ot[Pt],Ot}),wt.getState().setActiveTab(ke,ge),G(pt.hostDirectory,ke))},ck)),yt?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),pe(yt),_e.success(r("projectActions.toast.openedForwardedUrl"))):St?($(ke,ge,St,{locked:!0,autoOpened:!0,expectedExecutionId:ct}),S(fe,St),_e.success(r("projectActions.toast.openedActionUrl"))):kt?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),_e.error(r("projectActions.error.openUrlTemplateUnresolved"))):Je?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),_e.error(r("projectActions.error.invalidCustomUrlFormat"))):Ct?($(ke,ge,null,{locked:!0,expectedExecutionId:ct}),_e.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(ke,ge,null,{locked:!1,autoOpened:!1,expectedExecutionId:ct})}catch(he){if(me&&K(me.directory,me.tabId,me.id)){const{directory:Je,tabId:Fe,id:fe}=me;ze(Je,v.id,fe),A(Je,Fe,"exited",{expectedExecutionId:fe}),N(Je,Fe,{type:"project-action",actionId:v.id,executionId:null})}if(he instanceof Error&&he.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(he instanceof Error&&(he.message==="COMMAND_MODE_UNSUPPORTED"||he.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){_e.error(r("projectActions.error.failedToCreateTerminalSession"));return}_e.error(he instanceof Error?he.message:r("projectActions.error.failedToRunAction"))}finally{ee.current.delete(ae)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Pe,p,Ze,u,n,d,f,Ee,x,h,pe,S,Re,G,a.isVSCode,Ue,K,ze,Te,Me,I,T,q,P,A,N,$,k,L,r,i]),qe=l.useCallback(async v=>{const ae=jn(Ue(v),v.id),W=Re[ae];W&&await rp({terminal:i,sessionId:W.sessionId,isExecutionStillCurrent:()=>K(W.directory,W.tabId,W.executionId),markStopping:()=>{A(W.directory,W.tabId,"stopping",{expectedExecutionId:W.executionId})},restoreRunning:()=>{A(W.directory,W.tabId,"running",{expectedExecutionId:W.executionId})},clearSession:()=>{k(W.directory,W.tabId,null,{expectedExecutionId:W.executionId})},finalizeExit:()=>{A(W.directory,W.tabId,"exited",{expectedExecutionId:W.executionId}),N(W.directory,W.tabId,{type:"project-action",actionId:W.actionId,executionId:null}),ze(W.directory,W.actionId,W.executionId)}})},[ze,Ue,K,Re,A,N,k,i]),et=l.useCallback(async v=>{if(v.source==="shared"&&L){const ae=ne.current?.trust.trusted?ne.current:await Io(L);if(ne.current=ae,!await Aa(L,ae))return;ne.current={...ae,trust:{...ae.trust,trusted:!0}}}await Qe(v)},[Qe,L]),He=l.useCallback(v=>Re[jn(Ue(v),v.id)]??null,[Ue,Re]),Ye=(Ae&&He(Ae)?Ae:null)??Ne.find(v=>He(v)!==null)??Ae??Ne[0]??null,dt=l.useCallback(v=>{const ae=He(v);if(ae?.status!=="stopping"){if(ae){qe(v);return}et(v)}},[et,He,qe]),nt=l.useCallback(v=>{et(v)},[et]),ut=l.useCallback(v=>{qe(v)},[qe]),oe=l.useCallback(v=>{V(v.id),Z&&lk(Z,v.id)},[Z]),de=l.useCallback(()=>{L?.id&&(w(L.id),g("projects"),b(!0))},[b,g,w,L?.id]),ve=!a.isVSCode&&(n||!d)&&!!L&&!!Ee;return l.useMemo(()=>({available:ve,actions:ve?Ne:[],shown:ve?Ye:null,isLoading:F,observe:We,runOf:He,select:oe,run:nt,stop:ut,toggle:dt,openSettings:de}),[ve,Ne,F,We,de,nt,He,oe,Ye,ut,dt])},pk=t=>{const e=Be.c(6);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const o=fk(r);let i;return e[3]!==n||e[4]!==o?(i=s.jsx(hd.Provider,{value:o,children:n}),e[3]=n,e[4]=o,e[5]=i):i=e[5],i},mk=t=>{const e=Be.c(4),{children:n}=t,r=xd(),o=xr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let u;return e[0]!==n||e[1]!==a||e[2]!==i?(u=s.jsx(pk,{projectRef:i,directory:a,children:n}),e[0]=n,e[1]=a,e[2]=i,e[3]=u):u=e[3],u};function hk(t){const e=[],n=(r,o)=>{const i=Yt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const gk=new Map,xk=t=>{const e=Be.c(23),{isVSCode:n}=t,r=Uc(),o=Gt(bk),i=is(wk),a=tt(yk);let u;e[0]!==n?(u=k=>n?gk:k.availableWorktreesByProject,e[0]=n,e[1]=u):u=e[1];const c=tt(u),d=!n;let f;e[2]!==c||e[3]!==o||e[4]!==d?(f=lp(o,c,{includeWorktrees:d}),e[2]=c,e[3]=o,e[4]=d,e[5]=f):f=e[5];const p=f,m=ts(vk),h=ts(Sk),x=ts(kk),g=`session-list-sync:${l.useId()}`;let b,w;e[6]!==g||e[7]!==r||e[8]!==i||e[9]!==a?(b=()=>(r.setBootstrapDemand(g,hk({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(g)),w=[g,r,i,a],e[6]=g,e[7]=r,e[8]=i,e[9]=a,e[10]=b,e[11]=w):(b=e[10],w=e[11]),l.useEffect(b,w);const S=l.useRef(null);let y,I;e[12]!==n||e[13]!==p?(y=()=>{const k=new Set(p),N=S.current;S.current=k;const T=N?[...k].filter(A=>!N.has(A)):n?[...k]:[];T.length&&Zc(T,Xo())},I=[n,p],e[12]=n,e[13]=p,e[14]=y,e[15]=I):(y=e[14],I=e[15]),l.useEffect(y,I);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],l.useEffect(jk,j);let R;e[17]!==h||e[18]!==m?(R=[...m,...h],e[17]=h,e[18]=m,e[19]=R):R=e[19];const _=R;let P;e[20]!==_||e[21]!==x?(P={enabled:!0,hasAuthoritativeGlobalSessions:x,sessions:_},e[20]=_,e[21]=x,e[22]=P):P=e[22],cp(P)};function bk(t){return t.projects}function wk(t){return t.currentDirectory}function yk(t){return t.currentSessionDirectory}function vk(t){return t.activeSessions}function Sk(t){return t.archivedSessions}function kk(t){return t.status==="ready"}function jk(){let t=null,e=!1;const n=new Set,r=Js(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")n.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),vg(Xo());return}const i=[...n];n.clear(),i.length&&Zc(i,Xo())},500)});return()=>{t&&clearTimeout(t),r()}}const Ck=()=>At(()=>import("./SettingsWindow-CnjurTti.js"),__vite__mapDeps([231,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,232,181,182,183,233,234,216,217,218,219,226,201,188,189,202,235,236,225,211,237,238,239])).then(t=>t.SettingsWindow),Tk=()=>At(()=>import("./CommandPalette-CLlDfj5e.js"),__vite__mapDeps([240,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,237,181,182,183,206,205])).then(t=>t.CommandPalette),Nk=()=>At(()=>import("./HelpDialog-DNqqtAW-.js"),__vite__mapDeps([241,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.HelpDialog),Ek=()=>At(()=>import("./ProjectActionsDialog-C3rXp1WV.js"),__vite__mapDeps([242,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.ProjectActionsDialog),Pk=()=>At(()=>import("./OpenCodeStatusDialog-BgseXyBy.js"),__vite__mapDeps([243,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.OpenCodeStatusDialog),Ik=()=>At(()=>import("./RunOverview-BqmEhK3a.js"),__vite__mapDeps([244,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.RunOverview),Rk=()=>At(()=>import("./ScheduledTasksDialog-CXyiyIDe.js"),__vite__mapDeps([245,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,229,246,247,248])).then(t=>t.ScheduledTasksDialog),Dk=()=>At(()=>import("./ArchiveView-BsWIv-C4.js"),__vite__mapDeps([249,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,250])).then(t=>t.ArchiveView),_k=()=>At(()=>import("./IntegrationsCatalogView-C4-oLIEz.js"),__vite__mapDeps([251,1,2,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,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,233])).then(t=>t.IntegrationsCatalogView),Ak=()=>At(()=>import("./UsageStatsView-CWV-BYPI.js"),__vite__mapDeps([252,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.UsageStatsView),Ok=()=>At(()=>import("./SourceBoardView-BoMdMgmW.js"),__vite__mapDeps([253,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.SourceBoardView),Mk=()=>At(()=>import("./OverviewView-CohMMobq.js"),__vite__mapDeps([254,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.OverviewView),Fk=()=>At(()=>import("./WorktreesView-D_VUAXdo.js"),__vite__mapDeps([255,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,250])).then(t=>t.WorktreesView),Lk=()=>At(()=>import("./SpacesView-DNI1yLAG.js"),__vite__mapDeps([256,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,238,181,182,183])).then(t=>t.SpacesView),$k=()=>At(()=>import("./SpaceAccessDialog-q5blJXG5.js"),__vite__mapDeps([257,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceAccessDialog),Bk=()=>At(()=>import("./SpaceApplyDialog-Csq1Z7zY.js"),__vite__mapDeps([259,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182])).then(t=>t.SpaceApplyDialog),zk=()=>At(()=>import("./SpaceSetupOutput-Bzeasxqg.js"),__vite__mapDeps([260,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,258])).then(t=>t.SpaceSetupOutputDialog),Fs=()=>X.getState().closeMainSurfaces(),os=t=>{const e=Be.c(2),{needed:n,load:r,onFailure:o}=t,i=fo(n,r,o);let a;return e[0]!==i?(a=i?s.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},mu=l.memo(t=>{const e=Be.c(11),{isMobile:n}=t,r=X(Uk),o=!r&&!n,i=ao();let a;e[0]!==o||e[1]!==i?(a={enabled:o,layoutAnimationMs:i},e[0]=o,e[1]=i,e[2]=a):a=e[2];const u=wb(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(pb,{}),e[3]=c):c=e[3];const d=r||u.state!==!1;let f;e[4]!==d?(f=s.jsx(dp,{isVisible:d}),e[4]=d,e[5]=f):f=e[5];let p;return e[6]!==n||e[7]!==r||e[8]!==u||e[9]!==f?(p=s.jsx(fb,{isOpen:r,isMobile:n,className:"border-border",topBar:c,peek:u,children:f}),e[6]=n,e[7]=r,e[8]=u,e[9]=f,e[10]=p):p=e[10],p});mu.displayName="LeftSidebar";const Wk=()=>{const t=Be.c(111);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],xk(e),up();const n=X(Vk),r=X(Hk),o=X(qk),i=X(Gk);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const u=fo(o,Ck,a),c=X(Kk),d=X(Zk),f=X(Xk),p=X(Yk),m=X(Jk),h=X(Qk),x=X(ej),g=X(tj),b=X(sj),w=X(nj),S=X(rj),y=X(oj),I=X(ij),j=pn(aj),R=pn(lj),_=pn(cj),P=X(dj),k=Sg();let N;if(t[3]!==k||t[4]!==P){let nt;t[6]!==P?(nt=ut=>ut.id===P,t[6]=P,t[7]=nt):nt=t[7],N=k.find(nt),t[3]=k,t[4]=P,t[5]=N}else N=t[5];const T=N;let A,$;t[8]!==T||t[9]!==P?(A=()=>{P&&!T&&X.getState().setOpenGuestPage(null)},$=[P,T],t[8]=T,t[9]=P,t[10]=A,t[11]=$):(A=t[10],$=t[11]),l.useEffect(A,$);let K;t[12]===Symbol.for("react.memo_cache_sentinel")?(K=[],t[12]=K):K=t[12],l.useEffect(fj,K);let q;t[13]===Symbol.for("react.memo_cache_sentinel")?(q=[],t[13]=q):q=t[13],l.useEffect(pj,q);const M=d||f||p||m||h||x||!!g||b||c||!!T;let z,ne;t[14]!==M?(z=()=>{Xc(M)},ne=[M],t[14]=M,t[15]=z,t[16]=ne):(z=t[15],ne=t[16]),l.useLayoutEffect(z,ne);let H;t[17]===Symbol.for("react.memo_cache_sentinel")?(H=[],t[17]=H):H=t[17],l.useEffect(hj,H);let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=[],t[18]=V):V=t[18],l.useEffect(xj,V);const{isMobile:F}=yn();fp();let C,te;t[19]!==F||t[20]!==r?(C=()=>{X.getState().isMobile!==F&&r(F)},te=[F,r],t[19]=F,t[20]=r,t[21]=C,t[22]=te):(C=t[21],te=t[22]),l.useEffect(C,te);let re;t[23]!==w?(re=s.jsx(os,{needed:w,load:Tk,onFailure:bj}),t[23]=w,t[24]=re):re=t[24];let Q;t[25]!==S?(Q=s.jsx(os,{needed:S,load:Nk,onFailure:wj}),t[25]=S,t[26]=Q):Q=t[26];let ee;t[27]!==y?(ee=s.jsx(os,{needed:y,load:Ek,onFailure:yj}),t[27]=y,t[28]=ee):ee=t[28];let le;t[29]!==I?(le=s.jsx(os,{needed:I,load:Pk,onFailure:vj}),t[29]=I,t[30]=le):le=t[30];let O,Y;t[31]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(mp,{}),Y=s.jsx(z2,{}),t[31]=O,t[32]=Y):(O=t[31],Y=t[32]);let Z;t[33]!==j||t[34]!==R||t[35]!==_||t[36]!==n?(Z=n?s.jsxs(s.Fragment,{children:[s.jsx(os,{needed:j,load:$k,onFailure:Sj}),s.jsx(hp,{}),s.jsx(os,{needed:R,load:Bk,onFailure:kj}),s.jsx(gp,{}),s.jsx(os,{needed:_,load:zk,onFailure:jj})]}):null,t[33]=j,t[34]=R,t[35]=_,t[36]=n,t[37]=Z):Z=t[37];let we;t[38]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(yb,{}),t[38]=we):we=t[38];let L;t[39]!==F?(L=s.jsx(mu,{isMobile:F}),t[39]=F,t[40]=L):L=t[40];let pe;t[41]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(ub,{}),t[41]=pe):pe=t[41];let je;t[42]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx($o,{zone:"left"}),t[42]=je):je=t[42];const Ee=M&&"invisible";let Se;t[43]!==Ee?(Se=$e("absolute inset-0",Ee),t[43]=Ee,t[44]=Se):Se=t[44];const Le=!o&&!M;let Pe;t[45]!==Le?(Pe=s.jsx(Qt,{children:s.jsx(xc,{active:Le})}),t[45]=Le,t[46]=Pe):Pe=t[46];let Ve;t[47]!==Se||t[48]!==Pe?(Ve=s.jsx("div",{className:Se,children:Pe}),t[47]=Se,t[48]=Pe,t[49]=Ve):Ve=t[49];let Oe;t[50]!==c?(Oe=s.jsx(Qt,{children:s.jsx(os,{needed:c,load:Ik,onFailure:Fs})}),t[50]=c,t[51]=Oe):Oe=t[51];let be;t[52]!==d?(be=s.jsx(Qt,{children:s.jsx(os,{needed:d,load:Rk,onFailure:Fs})}),t[52]=d,t[53]=be):be=t[53];let ye;t[54]!==f?(ye=s.jsx(Qt,{children:s.jsx(os,{needed:f,load:Dk,onFailure:Fs})}),t[54]=f,t[55]=ye):ye=t[55];let Ue;t[56]!==p?(Ue=s.jsx(Qt,{children:s.jsx(os,{needed:p,load:_k,onFailure:Fs})}),t[56]=p,t[57]=Ue):Ue=t[57];let Te;t[58]!==m?(Te=m&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Ak,onFailure:Fs})})}),t[58]=m,t[59]=Te):Te=t[59];let Me;t[60]!==h?(Me=s.jsx(os,{needed:h,load:Ok,onFailure:Fs}),t[60]=h,t[61]=Me):Me=t[61];let Re;t[62]!==x?(Re=s.jsx(Qt,{children:s.jsx(os,{needed:x,load:Mk,onFailure:Fs})}),t[62]=x,t[63]=Re):Re=t[63];const ze=!!g;let B;t[64]!==ze?(B=s.jsx(Qt,{children:s.jsx(os,{needed:ze,load:Fk,onFailure:Fs})}),t[64]=ze,t[65]=B):B=t[65];let ce;t[66]!==b?(ce=b?s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Lk,onFailure:Fs})}):null,t[66]=b,t[67]=ce):ce=t[67];let G;t[68]!==T?(G=T&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(kg,{mode:`plugin:${T.id}`,surface:"page",item:null,onDismiss:Cj})})}),t[68]=T,t[69]=G):G=t[69];let Ce;t[70]!==Ve||t[71]!==Oe||t[72]!==be||t[73]!==ye||t[74]!==Ue||t[75]!==Te||t[76]!==Me||t[77]!==Re||t[78]!==B||t[79]!==ce||t[80]!==G?(Ce=s.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[Ve,Oe,be,ye,Ue,Te,Me,Re,B,ce,G]}),t[70]=Ve,t[71]=Oe,t[72]=be,t[73]=ye,t[74]=Ue,t[75]=Te,t[76]=Me,t[77]=Re,t[78]=B,t[79]=ce,t[80]=G,t[81]=Ce):Ce=t[81];let J;t[82]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx($o,{zone:"bottom"}),t[82]=J):J=t[82];let Ne;t[83]!==Ce?(Ne=s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[Ce,J]}),t[83]=Ce,t[84]=Ne):Ne=t[84];let Ae,Ie,De,We;t[85]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx($o,{zone:"right"}),Ie=s.jsx(t2,{}),De=s.jsx(n2,{}),We=s.jsx(l2,{}),t[85]=Ae,t[86]=Ie,t[87]=De,t[88]=We):(Ae=t[85],Ie=t[86],De=t[87],We=t[88]);let Ke;t[89]!==Ne?(Ke=s.jsx("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","data-page-scroll-lock":"true","data-workspace-row":"true",children:[je,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:[Ne,Ae,Ie,De,We]})]})}),t[89]=Ne,t[90]=Ke):Ke=t[90];let Ze;t[91]===Symbol.for("react.memo_cache_sentinel")?(Ze=s.jsx("div",{"data-page-scroll-lock":"true",children:s.jsx(Qt,{children:s.jsx(v2,{})})}),t[91]=Ze):Ze=t[91];let Qe;t[92]===Symbol.for("react.memo_cache_sentinel")?(Qe=s.jsx(Qt,{children:s.jsx(b1,{})}),t[92]=Qe):Qe=t[92];let qe;t[93]!==Ke?(qe=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[pe,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ke,Ze,Qe]})]}),t[93]=Ke,t[94]=qe):qe=t[94];let et;t[95]!==L||t[96]!==qe?(et=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[L,qe]}),t[95]=L,t[96]=qe,t[97]=et):et=t[97];let He;t[98]!==u||t[99]!==o||t[100]!==i?(He=u?s.jsx(u,{open:o,onOpenChange:i}):null,t[98]=u,t[99]=o,t[100]=i,t[101]=He):He=t[101];let Ye;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ye=null,t[102]=Ye):Ye=t[102];let dt;return t[103]!==re||t[104]!==Q||t[105]!==ee||t[106]!==le||t[107]!==Z||t[108]!==et||t[109]!==He?(dt=s.jsx(jg.Provider,{value:!0,children:s.jsx(pp,{children:s.jsx(mk,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[re,Q,ee,le,O,Y,Z,we,et,He,Ye]})})})}),t[103]=re,t[104]=Q,t[105]=ee,t[106]=le,t[107]=Z,t[108]=et,t[109]=He,t[110]=dt):dt=t[110],dt};function Uk(t){return t.isSidebarOpen}function Vk(t){return t.isolatedSpacesEnabled}function Hk(t){return t.setIsMobile}function qk(t){return t.isSettingsDialogOpen}function Gk(t){return t.setSettingsDialogOpen}function Kk(t){return t.runOverviewKey!==null}function Zk(t){return t.isScheduledTasksDialogOpen}function Xk(t){return t.isArchivePageOpen}function Yk(t){return t.isIntegrationsCatalogOpen}function Jk(t){return t.isUsageStatsPageOpen}function Qk(t){return t.isSourceBoardOpen}function ej(t){return t.isOverviewOpen}function tj(t){return t.worktreesPageProjectId}function sj(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function nj(t){return t.isCommandPaletteOpen}function rj(t){return t.isHelpDialogOpen}function oj(t){return t.isProjectActionsDialogOpen}function ij(t){return t.isOpenCodeStatusDialogOpen}function aj(t){return t.accessDialog!==null}function lj(t){return t.applyDialog!==null}function cj(t){return t.setupOutputDialog!==null}function dj(t){return t.openGuestPageId}function uj(){return X.getState().setOpenGuestPage(null)}function fj(){return Ql(uj)}function pj(){return x1()}function mj(){return Xc(!1)}function hj(){return mj}function gj(){return X.getState().closeMainSurfaces()}function xj(){const t=gj,e=tt.subscribe((n,r)=>{const o=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,i=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function bj(){return X.getState().setCommandPaletteOpen(!1)}function wj(){return X.getState().setHelpDialogOpen(!1)}function yj(){return X.getState().setProjectActionsDialogOpen(!1)}function vj(){return X.getState().setOpenCodeStatusDialogOpen(!1)}function Sj(){return pn.getState().closeAccessDialog()}function kj(){return pn.getState().closeApplyDialog()}function jj(){return pn.getState().closeSetupOutputDialog()}function Cj(){return X.getState().setOpenGuestPage(null)}const gi="openchamber_requests_in_flight",hu=1e3,Tj=300*1e3,Yr=Math.ceil(Tj/hu),Nj=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(gi)==="1"}catch{return!1}},gu=()=>({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 Ej=1;const Pj=(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))},Ij=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},xu=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,o)=>r-o),n},On=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},Rj=()=>{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,o)=>{const i=Ej++;Pj(i,Date.now());try{return await e(r,o)}finally{Ij(i)}};window.fetch=n},Pl=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Yn=t=>{t.length>Yr&&t.splice(0,t.length-Yr)},Dj=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=xu(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(On(e,50)),t.p90Samples.push(On(e,90)),t.p99Samples.push(On(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Yn(t.samples),Yn(t.p50Samples),Yn(t.p90Samples),Yn(t.p99Samples),Yn(t.maxSamples),t.lastSampleAt=Date.now()},_j=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(Dj,hu))},Il=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Rl=t=>{if(!(typeof window>"u"))try{if(t){Il(),Pl(),window.localStorage.setItem(gi,"1"),window.__openchamberRequestsInFlight__=gu(),Rj(),_j();return}window.localStorage.removeItem(gi),Il(),Pl(),delete window.__openchamberRequestsInFlight__}catch{}},b4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=gu();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},w4=()=>{if(typeof window>"u")return Dl();const t=window.__openchamberRequestsInFlight__;if(!Nj()||!t)return Dl();const e=xu(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:On(e,50),ageP90:On(e,90),ageP99:On(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:Yr}},Dl=()=>({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:Yr}),Aj=(t,e,n)=>Cg(t.filter(r=>!Yc(r)&&!r.parentID),e,n),Oj=()=>Aj(ts.getState().activeSessions,Ui.getState().ids,Wi.getState().rankById??Tg),Mj=(t,e,n)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=n>0?0:t.length-1;return r>=0&&(o=(r+n+t.length)%t.length),t[o]},Fj=()=>{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()??"":""},Lj=async()=>{const t=Fj()||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")},_l="openchamber:menu-action",Al="openchamber:check-for-updates",$j=t=>{const e=Be.c(21),{t:n}=at(),r=tt(Bj),o=X(zj),i=X(Wj),a=X(Uj),u=X(Vj),c=X(Hj),d=X(qj),f=X(Gj),p=bc(Kj),{setThemeMode:m}=no(),h=l.useRef(!1);let x;e[0]!==p?(x=()=>{h.current||(h.current=!0,p().then(Zj).finally(()=>{h.current=!1}))},e[0]=p,e[1]=x):x=e[1];const g=x,b=Xj;let w;e[2]!==c?(w=P=>{const k=tt.getState().currentSessionId,N=Mj(Oj(),k,P);N&&(c(!1),tt.getState().setCurrentSession(N.id,gn(N)))},e[2]=c,e[3]=w):w=e[3];const S=w,y=Yj;let I;e[4]!==S||e[5]!==t||e[6]!==r||e[7]!==f||e[8]!==i||e[9]!==c||e[10]!==d||e[11]!==m||e[12]!==n||e[13]!==o||e[14]!==a||e[15]!==u?(I=P=>{e:switch(P){case"about":{f(!0);break e}case"settings":{d(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{c(!1);const k=tt.getState(),N=is.getState().currentDirectory;r(k.currentSessionId&&N?{directoryOverride:N}:void 0);break e}case"new-worktree-session":{c(!1),Ig();break e}case"change-workspace":{b();break e}case"toggle-right-sidebar":{const k=is.getState().currentDirectory;if(!k)break e;const N=X.getState(),T=us(k),A=N.contextPanelByDirectory[T],$=A?Ku(A.tabs,N.contextSurfaceZones,"right",lr(A,"right").activeTabId):null;A?.isOpen?N.closeContextPanel(T):$?N.setActiveContextPanelTab(T,$):N.openContextSurface(T,"git");break e}case"open-right-sidebar-git":{const k=is.getState().currentDirectory;if(!k)break e;X.getState().openContextSurface(us(k),"git");break e}case"open-right-sidebar-files":{const k=is.getState().currentDirectory;if(!k)break e;X.getState().openContextSurface(us(k),"file");break e}case"toggle-terminal":{const k=is.getState().currentDirectory;if(!k)break e;X.getState().openContextSurface(us(k),"terminal");break e}case"toggle-context-panel-expanded":{Pg(is.getState().currentDirectory);break e}case"copy":{const k=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(k)||Lj();break e}case"theme-light":{m("light");break e}case"theme-dark":{m("dark");break e}case"theme-system":{m("system");break e}case"add-selection-to-chat":{Eg();break e}case"toggle-sidebar":{u();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{Oa(-1);break e}case"go-forward":{Oa(1);break e}case"previous-session":{S(-1);break e}case"next-session":{S(1);break e}case"previous-project":{y(-1);break e}case"next-project":{y(1);break e}case"help-dialog":{a();break e}case"download-logs":Ng().catch(()=>{_e.error(n("openCodeStatusDialog.toast.collectFailed"))})}},e[4]=S,e[5]=t,e[6]=r,e[7]=f,e[8]=i,e[9]=c,e[10]=d,e[11]=m,e[12]=n,e[13]=o,e[14]=a,e[15]=u,e[16]=I):I=e[16];const j=I;let R,_;e[17]!==j||e[18]!==g?(R=()=>{const P=N=>{const T=N.detail;T&&j(T)},k=()=>{g()};return window.addEventListener(_l,P),window.addEventListener(Al,k),()=>{window.removeEventListener(_l,P),window.removeEventListener(Al,k)}},_=[j,g],e[17]=j,e[18]=g,e[19]=R,e[20]=_):(R=e[19],_=e[20]),l.useEffect(R,_)};function Bj(t){return t.openNewSessionDraft}function zj(t){return t.toggleCommandPalette}function Wj(t){return t.setCommandPaletteOpen}function Uj(t){return t.toggleHelpDialog}function Vj(t){return t.toggleSidebar}function Hj(t){return t.setSessionSwitcherOpen}function qj(t){return t.setSettingsDialogOpen}function Gj(t){return t.setAboutDialogOpen}function Kj(t){return t.checkForUpdates}function Zj(){const{available:t,error:e}=bc.getState();if(e){_e.error("Failed to check for updates",{description:e});return}t||_e.success("You are on the latest version")}function Xj(){Ur.requestDirectoryDialog()}function Yj(t){const{activeProjectId:e,projects:n,setActiveProject:r}=Gt.getState();if(n.length===0)return;const o=n.findIndex(u=>u.id===e);let i=t>0?0:n.length-1;o>=0&&(i=(o+t+n.length)%n.length);const a=n[i];a&&r(a.id)}const Ol=(t,{isAdmitted:e,isPlaced:n,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||Yc(t)?!1:n||o.pinned&&r||o.work&&jc(t),Jj="openchamber:tray-action",Qj=5e3,e3=500,t3=20,Ml=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Fl=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,bu=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},wu=t=>t.title.trim()||"Question",s3=new Set,n3=(t,e)=>Og(t,e,s3,Wi.getState().rankById),r3=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},o3=(t,e,n,r,o)=>{if(!t)return"";const i=hr(n,r,t),a=e.project?.name,u=i?.label?.trim()||a?.trim()||r3(t),c=zr(t);let d=c&&o.get(c)||"";if(!d){for(const[f,p]of Vn.getState().directories)if(zr(f)===c){d=p.status?.current??"";break}}if(!d)for(const f of r.values()){const p=c?$r(f,c):void 0;if(p?.branch){d=p.branch;break}}return d?`${u} · ${d}`:u},i3=()=>{const{dictionary:t}=Ju.getState(),e=(c,d)=>Qu(t,c,d),{results:n,dropdownProviderIds:r,displayMode:o}=Pn.getState(),i=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:i,groups:[]};const a=new Map(n.map(c=>[c.providerId,c])),u=[];for(const c of Mg){if(!r.includes(c.id))continue;const d=a.get(c.id);if(!d||d.configured!==!0)continue;const f=[];for(const[m,h]of Object.entries(d.usage?.windows??{})){const x=i==="remaining"?h.remainingPercent:h.usedPercent;f.push({label:Lg(m),value:Fg(h,x,e)})}const p=!d.ok&&d.error?d.error:f.length===0?"No rate limits reported":null;u.push({provider:c.name,rows:f,status:p})}return{mode:i,groups:u}},a3=async()=>{try{if(eo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Zu();if(e&&ra(e,t))return"Local OpenChamber";const r=(await ki()).hosts.find(o=>e?ra(e,tc(o)):!1);return r?.label?.trim()?Xu(r.label.trim()):"Instance"}catch{return""}},l3=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=Yo()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,a]of o.children.entries()){const u=a.getState();u.vcs?.branch&&e.set(zr(i)??i,u.vcs.branch);for(const c of u.session)c?.id&&r.set(c.id,c.title);for(const[c,d]of Object.entries(u.session_status??{})){const f=d?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(c);(!m||m==="idle")&&t.set(c,p)}for(const[c,d]of Object.entries(u.permission??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:bu(f),directory:i,canSave:ed(f.save)})}for(const[c,d]of Object.entries(u.form??{}))for(const f of d??[]){if(!f?.id)continue;const p=f.sessionID||c;n.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:wu(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},c3=(t,e)=>{const n=ts.getState().activeSessions,r=Dg(n),o=j=>r.descendantsOf(j,"active").map(R=>R.id),i=Gt.getState().projects,a=tt.getState().availableWorktreesByProject,u=Ui.getState().ids,c=(j,R)=>{const _=gn(j),P=Fa(_,i,a);return Jr(_)||j.projectID===Yu?Ol(j,{isAdmitted:P,isPlaced:R.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):Ol(j,{isAdmitted:P,isPlaced:Zl(_)||hr(i,a,_)!==null,isPinned:Ag(u,j.directory,j.id),zones:R})},d=ec.getState(),f={chats:d.showChatsSection,pinned:d.showPinnedSection,work:X.getState().sessionWorkEnabled&&d.showWorkSection},p={chats:!0,pinned:!0,work:!0},m=X.getState().dockBadgeEnabled?n.filter(j=>Ma(j)&&c(j,f)).length:0;if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:m};const h=l3(),x=new Map(h.titleById);for(const j of n)j?.id&&j.title&&x.set(j.id,j.title);const g=Jc.getState().statusById,b=j=>{const R=h.statusById.get(j);return R&&R!=="idle"?R:g.get(j)?.status.type??R??"idle"},w=j=>{const R=j.map(_=>b(_));return R.includes("busy")?"busy":R.includes("retry")?"retry":"idle"},S=n.filter(j=>j?.id&&!j.parentID).filter(j=>c(j,p)).slice().sort(n3).slice(0,t3).map(j=>{const R=[j.id,...o(j.id)],_=gn(j)??"";return{id:j.id,title:j.title||"Untitled session",status:w(R),branch:_?h.branchByDirectory.get(_)??"":"",unseen:Ma(j)?1:0,hasError:_g(j),directory:_,subtitle:o3(_,j,i,a,h.branchByDirectory)}}),y=h.approvals.map(j=>({...j,sessionTitle:x.get(j.sessionId)||""})),I=new Set(y.map(j=>j.id));for(const[j,R]of Qc.getState().bySession){const _=x.get(j)||"";for(const P of R.permissions)I.has(P.id)||(I.add(P.id),y.push({kind:"permission",id:P.id,sessionId:j,sessionTitle:_,label:bu(P),directory:R.directory,canSave:ed(P.save)}));for(const P of[...R.forms,...R.pages])I.has(P.id)||(I.add(P.id),y.push({kind:"form",id:P.id,sessionId:j,sessionTitle:_,label:wu(P),directory:R.directory,canSave:!1}))}return{sessions:S,approvals:y.filter(j=>Fa(j.directory,i,a)),instanceName:t,usage:i3(),dockBadgeCount:m}},d3=()=>{l.useEffect(()=>{if(!Ml()||!Vo())return;const t=Fl();let e=!1,n="",r=null,o="";const i=()=>{if(e)return;const _=c3(o,t),P=JSON.stringify(_);P!==n&&(n=P,un("desktop_tray_update",_))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},e3))},u=ts.subscribe(()=>a()),c=X.subscribe((_,P)=>{(_.dockBadgeEnabled!==P.dockBadgeEnabled||_.sessionWorkEnabled!==P.sessionWorkEnabled)&&a()}),d=Gt.subscribe(()=>a()),f=tt.subscribe(()=>a()),p=Ui.subscribe(()=>a()),m=ec.subscribe((_,P)=>{(_.showChatsSection!==P.showChatsSection||_.showPinnedSection!==P.showPinnedSection||_.showWorkSection!==P.showWorkSection)&&a()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),u(),c(),d(),f(),p(),m()};if(!t)return i(),h;a3().then(_=>{e||(o=_,i())});const x=new Map,g=()=>{if(e)return;let _;try{_=Yo()}catch{return}const P=new Set;for(const[k,N]of _.children.entries())P.add(k),x.has(k)||x.set(k,N.subscribe(()=>a()));for(const[k,N]of x)P.has(k)||(N(),x.delete(k))};let b=null;try{b=Yo().subscribeRegistry(()=>{g(),a()})}catch{}g();const w=Vn.subscribe(()=>a()),S=Jc.subscribe(()=>a()),y=Qc.subscribe(()=>a()),I=Wi.subscribe(()=>a()),j=Pn.subscribe(()=>a());Pn.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:_,results:P}=Pn.getState();_.length>0&&_.some(N=>!P.some(T=>T.providerId===N))&&Pn.getState().fetchQuotas(_)});const R=window.setInterval(()=>{g(),i()},Qj);return i(),()=>{h(),window.clearInterval(R),w(),S(),y(),I(),j(),b?.();for(const _ of x.values())_();x.clear()}},[]),l.useEffect(()=>{if(!Ml()||!Fl()||!Vo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&Rg(o.sessionId,o.id,o.response).catch(()=>{_e.error("Failed to respond to permission request")})};let r=null;return e(Jj,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||n(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},u3=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,f3=(t,e,n,r)=>r||[t,e,n].filter(Boolean).join("|")||void 0,p3=t=>{t.kind!=="plugin"||!t.title||_e.info(t.title,{id:f3(t.kind,t.title,t.body,t.tag),description:t.body})},m3=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,h3=t=>{const e=Be.c(3),n=!0;let r,o;e[0]!==n?(r=()=>{if(!(Us()||!sc()||!globalThis.window))return Js(g3)},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function g3(t){if(t.type!=="notification")return;const e=X.getState();if(!e.nativeNotificationsEnabled)return;const n=u3();if(m3(t.payload,n)){p3(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&n)return;Jl()?.notifications?.notifyAgentCompletion(t.payload)}const x3=()=>{const t=Be.c(4),{t:e}=at(),n=X(b3);let r,o;t[0]!==n||t[1]!==e?(r=()=>Js(i=>{i.type==="browser-provider-reset"&&(n("builtin"),_e.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o)};function b3(t){return t.setBrowserProvider}const w3=()=>{const t=Be.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],l.useEffect(v3,e)};function y3(t){t.type==="guests-changed"?$g():t.type==="event-stream-ready"&&Bg()}function v3(){return Js(y3)}const S3=()=>{const t=Be.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>Js(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=zt.getState().providers,u=c=>a.find(d=>d.id===c);if(i.kind==="account"){const c=u(i.providerId)?.name||i.providerId;_e.info(i.fromAccount?e("chat.limitFailover.toast.account",{provider:c,from:i.fromAccount,to:i.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:c,to:i.toAccount}));return}_e.info(e("chat.limitFailover.toast.model",{model:La(u(i.providerId),i.modelId),fallback:La(u(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)},Ll="relay-limit-reached",k3=()=>{const t=Be.c(3),{t:e}=at();let n,r;t[0]!==e?(n=()=>{const o=()=>{_e.error(e("relayConnection.limitReached.title"),{id:Ll,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:j3}})};return oa(nc()?.getStatus())&&o(),ef(a=>{oa(a)?o():(a.state==="connected"||a.state==="idle")&&_e.dismiss(Ll)})},r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),l.useEffect(n,r)};function j3(){return nc()?.retry()}const $l=()=>{tf()||(zg(),Wg(xp.map(t=>t.id)))},C3=(t,e)=>{const n=Be.c(5);let r;n[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback($l,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout($l,3e3);return()=>clearTimeout(i)},n[0]=t,n[1]=r):r=n[1];let o;n[2]!==e||n[3]!==t?(o=[t,e],n[2]=e,n[3]=t,n[4]=o):o=n[4],l.useEffect(r,o)},Bl="pwa-install-toast-shown",zl="pwa-install-toast-dismissed",T3=()=>{const t=Be.c(6),{browserTab:e}=bp(),{t:n}=at(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let a,u;t[3]!==e?(a=()=>{if(typeof window>"u"||!sc()||!e)return;let c=null,d=null;const f=()=>{d!==null&&(_e.dismiss(d),d=null)},p=async()=>{if(!c)return;const x=c;c=null,f(),await x.prompt();const{outcome:g}=await x.userChoice;g==="accepted"&&_e.success(r.current("pwa.installPrompt.started"))},m=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),c=g;const b=ia(),w=sf();wp({dismissed:b.getItem(zl),sessionShown:w.getItem(Bl),hasActiveToast:d!==null})&&(w.setItem(Bl,"true"),d=_e.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{ia().setItem(zl,"true"),f()}}}))},h=()=>{c=null,f(),_e.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},u=[e],t[3]=e,t[4]=a,t[5]=u):(a=t[4],u=t[5]),l.useEffect(a,u)},yu=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,N3=()=>{xs.setState({byRoot:{},runtimeSnapshots:{}});const t=X.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const n of Si)t.closeContextZone(e,n)},E3=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",vu=async(t,e)=>{const n=(await ki()).hosts.find(o=>o.id===t);if(!n)throw new Error("host-not-found");if(n.relay){await af(n.id,e);return}const r=lf(tc(n));if(!r)throw new Error("host-not-found");cf({apiBaseUrl:r,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:df(n),sshForwarded:n.sshForwarded===!0})},P3=async t=>{const e=await ki(),n=await rf(t,e.hosts);await of({hosts:n.hosts,defaultHostId:e.defaultHostId||n.hostId,initialHostChoiceCompleted:!0}),await vu(n.hostId,{reconnectActive:!0})},I3=async t=>{const e=await nf();for(const n of e)try{n.type==="pairing"?await P3(n.link):await vu(n.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",n.type,o),t(E3(o))}},xi="project-config-invalid",R3=()=>{const t=Be.c(9),{t:e}=at(),n=zt(D3);let r;t[0]!==n?(r=m=>m.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const o=zt(r),[i,a]=Wt.useState(!1);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const m=zt.getState(),h=m.activeDirectoryKey;a(!0),Promise.all([m.loadProviders({directory:h,source:"projectConfigError:retry"}),m.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=u):u=t[2];const c=u;let d,f;t[3]!==o||t[4]!==i||t[5]!==e?(d=()=>{if(!o){_e.dismiss(xi);return}_e.error(e("projectConfigError.toast.title"),{id:xi,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:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&s.jsx(fs,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:m=>{m.preventDefault(),i||c()}}})},f=[o,i,c,e],t[3]=o,t[4]=i,t[5]=e,t[6]=d,t[7]=f):(d=t[6],f=t[7]),Wt.useEffect(d,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],Wt.useEffect(A3,p),null};function D3(t){return t.activeDirectoryKey}function _3(){_e.dismiss(xi)}function A3(){return _3}const O3="\x1B",M3=new RegExp(`${O3}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Tr=Ps().transform(t=>t.replace(M3,"").trim()).nullish(),F3=Qs({isOpenCodeReady:dr().optional(),openCodeRunning:dr().optional(),lastOpenCodeError:Tr,opencodeBinaryResolved:Tr,lastOpenCodeLaunchDiagnostics:Qs({sourceBinary:Tr,binary:Tr}).nullish()}),L3=async(t,e=Vs)=>{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=F3.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}},$3=(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"}},B3=Qs({openchamberVersion:Ps()}),z3=async(t,e=Vs)=>{const n=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)return null;const r=B3.safeParse(await n.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},W3=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function U3({version:t}){const{t:e}=at(),[n,r]=l.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const u=await vp();r(u.available&&!u.installBlocked?{kind:"available",info:u}:{kind:"manual",info:u,error:null})}catch(u){r({kind:"manual",info:null,error:u instanceof Error?u.message:null})}},i=n.kind==="manual"?n:null,a=i?.info?.updateCommand||"openchamber update";return s.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),s.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),s.jsxs(ft,{type:"button",onClick:()=>{o()},disabled:n.kind==="checking",children:[s.jsx(se,{name:n.kind==="checking"?"loader":"download",className:n.kind==="checking"?"size-4 animate-spin":"size-4"}),n.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&s.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),s.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),s.jsx(yp,{open:n.kind==="available",onOpenChange:u=>{u||r({kind:"idle"})},info:n.kind==="available"?n.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Wl=mr(()=>At(()=>import("./OnboardingScreen-DZVhaQUC.js"),__vite__mapDeps([261,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.OnboardingScreen}))),V3=()=>At(()=>import("./AboutDialog-BTYnMXM0.js"),__vite__mapDeps([262,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,239])).then(t=>t.AboutDialog),H3=()=>At(()=>import("./MemoryDebugPanel-DzMnnl_P.js"),__vite__mapDeps([263,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,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,205,206])).then(t=>t.MemoryDebugPanel),q3=()=>{const t=Be.c(6),e=X(Y3),n=X(J3);let r;t[0]!==n?(r=()=>n(!1),t[0]=n,t[1]=r):r=t[1];const o=fo(e,V3,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==n?(i=s.jsx(o,{open:e,onOpenChange:n}),t[2]=o,t[3]=e,t[4]=n,t[5]=i):i=t[5],i},G3=t=>{const e=Be.c(3),{onClose:n}=t,r=fo(!0,H3,n);let o;return e[0]!==r||e[1]!==n?(o=r?s.jsx(r,{onClose:n}):null,e[0]=r,e[1]=n,e[2]=o):o=e[2],o},K3=t=>{const e=Be.c(47),{onRetry:n,isRetrying:r}=t,{t:o}=at(),[i,a]=l.useState(null);let u,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const k=new AbortController,N=as(),T=setTimeout(()=>k.abort(),5e3);return L3(k.signal).then(A=>{!k.signal.aborted&&as()===N&&a(A)}).catch(Q3).finally(()=>clearTimeout(T)),()=>{k.abort(),clearTimeout(T)}},c=[],e[0]=u,e[1]=c):(u=e[0],c=e[1]),l.useEffect(u,c);const[d,f]=l.useState(null);let p,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const k=new AbortController,N=as(),T=setTimeout(()=>k.abort(),5e3);return z3(k.signal).then(A=>{k.signal.aborted||as()!==N||f(A&&W3(A)?A:null)}).catch(e4).finally(()=>clearTimeout(T)),()=>{k.abort(),clearTimeout(T)}},m=[],e[2]=p,e[3]=m):(p=e[2],m=e[3]),l.useEffect(p,m);const h=zt(t4),x=i?null:h?.message??null;if(d){let k;e[4]!==d?(k=s.jsx(U3,{version:d}),e[4]=d,e[5]=k):k=e[5];let N;e[6]!==r||e[7]!==o?(N=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=N):N=e[8];let T;e[9]!==r||e[10]!==n||e[11]!==N?(T=s.jsx(ft,{type:"button",variant:"outline",onClick:n,disabled:r,children:N}),e[9]=r,e[10]=n,e[11]=N,e[12]=T):T=e[12];let A;return e[13]!==k||e[14]!==T?(A=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:[k,T]})}),e[13]=k,e[14]=T,e[15]=A):A=e[15],A}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let b;e[18]!==g?(b=s.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let w;e[20]!==i||e[21]!==h||e[22]!==o?(w=o($3(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=w):w=e[23];let S;e[24]!==w?(S=s.jsx("p",{className:"typography-markdown text-muted-foreground",children:w}),e[24]=w,e[25]=S):S=e[25];let y;e[26]!==b||e[27]!==S?(y=s.jsxs("div",{className:"flex flex-col gap-2",children:[b,S]}),e[26]=b,e[27]=S,e[28]=y):y=e[28];let I;e[29]!==x||e[30]!==o?(I=x&&s.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("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:x})]}),e[29]=x,e[30]=o,e[31]=I):I=e[31];let j;e[32]!==i||e[33]!==o?(j=i&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("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:i.error})]})]}),e[32]=i,e[33]=o,e[34]=j):j=e[34];let R;e[35]!==r||e[36]!==o?(R=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=R):R=e[37];let _;e[38]!==r||e[39]!==n||e[40]!==R?(_=s.jsx(ft,{type:"button",onClick:n,disabled:r,children:R}),e[38]=r,e[39]=n,e[40]=R,e[41]=_):_=e[41];let P;return e[42]!==I||e[43]!==j||e[44]!==_||e[45]!==y?(P=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:[y,I,j,_]})}),e[42]=I,e[43]=j,e[44]=_,e[45]=y,e[46]=P):P=e[46],P};function Z3({apis:t}){l.useEffect(()=>Ug(),[]),l.useEffect(()=>{uf("App:mounted"),ff()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=zt(O=>O.initializeApp),n=zt(O=>O.isInitialized),r=zt(O=>O.isConnected),o=zt(O=>O.providersLoaded),i=zt(O=>O.agentsLoaded),a=zt(O=>O.loadProviders),u=zt(O=>O.loadAgents),c=tt(O=>O.error),d=tt(O=>O.clearError),f=is(O=>O.currentDirectory),p=is(O=>O.isSwitchingDirectory),[m,h]=l.useState(!1),x=hn(O=>O.refreshAll),g=Gl(O=>O.refresh),[b,w]=l.useState(()=>t.runtime.isVSCode),[S,y]=l.useState(!1),[I,j]=l.useState(0),[R,_]=l.useState(0),[P,k]=l.useState(!1),N=X(O=>O.wideChatLayoutEnabled),T=X(O=>O.mobileKeyboardMode),A=l.useMemo(()=>Us(),[]),[$,K]=l.useState(()=>aa()),[q,M]=l.useState(()=>{const O=jo();return O!==null?la({isDesktopShell:!0,bootOutcome:O}):null}),z=l.useRef(!1),{t:ne}=at(),H=l.useRef(!1);l.useEffect(()=>{if(!n||$!=="valid"||H.current)return;const O=jo();O?.target!=="local"||O.status!=="ok"||!O.sshStartupFallbackHostId||(H.current=!0,_e.error(ne("desktopHostSwitcher.startup.title"),{description:ne("desktopHostSwitcher.startup.fellBackToLocal")}))},[$,n,ne]);const V=l.useRef(!1);l.useEffect(()=>{!n||!yu()||V.current||(V.current=!0,_e.info(ne("desktopSafeStart.title"),{description:ne("desktopSafeStart.description"),duration:1/0}))},[n,ne]),l.useEffect(()=>(ca(m),Rl(m),()=>{ca(!1),Rl(!1)}),[m]),l.useEffect(()=>{pf(T)},[T]),l.useEffect(()=>{w(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>Ql(O=>{kp(O)&&jp(O),_(Y=>Y+1),y(!1),j(Y=>Y+1)}),[]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",N),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[N]),l.useEffect(()=>(da(t),()=>da(null)),[t]),l.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:!0}),Vg(t.trackers))},[t.sourceControl,t.trackers,r,x,g,R]),Hg();const F=$==="valid",C=q?.screen==="main";l.useEffect(()=>{if(!mf({isDesktopShell:A,bootOutcomeKnown:F}))return;qg();const O=setTimeout(()=>{const Y=document.getElementById("initial-loading");Y&&(Y.classList.add("fade-out"),setTimeout(()=>{Y.remove()},300))},150);return()=>clearTimeout(O)},[A,F]),l.useEffect(()=>{if(!A||$!=="malformed")return;const O=document.getElementById("initial-loading");O&&(O.textContent="Desktop startup failed — please restart the app.")},[A,$]),l.useEffect(()=>{b||e()},[e,b]),l.useEffect(()=>{if(b||n)return;let O=!0,Y,Z=0;const we=10,L=1e3,pe=async()=>{if(!O)return;if(Z>=we){y(!0);return}const je=zt.getState();if(je.isInitialized){y(!1);return}Z+=1,await je.initializeApp();const Ee=zt.getState();if(!O)return;if(Ee.isInitialized){y(!1);return}if(Z>=we){y(!0);return}const Se=Math.min(L*Math.pow(2,Z-1),4e3);Y=setTimeout(pe,Se)};return Y=setTimeout(pe,L),()=>{O=!1,Y&&clearTimeout(Y)}},[I,n,b]),l.useEffect(()=>{n&&y(!1)},[n]),l.useEffect(()=>{if(!S)return;const O=document.getElementById("initial-loading");O&&(O.classList.add("fade-out"),setTimeout(()=>{O.remove()},300))},[S]),l.useEffect(()=>{if(b||!r||o&&i)return;let O=!0,Y=0;const Z=15,we=async()=>{const pe=zt.getState();if(!(pe.providersLoaded&&pe.agentsLoaded))try{pe.providersLoaded||await a({source:"startupRecovery"}),zt.getState().agentsLoaded||await u({source:"startupRecovery"})}catch{}};we();const L=setInterval(()=>{if(O){if(++Y>=Z){clearInterval(L);return}we()}},2e3);return()=>{O=!1,clearInterval(L)}},[r,b,u,a,o,i]),l.useEffect(()=>{p||b||r&&qo.setDirectory(f)},[f,p,r,b]),l.useEffect(()=>{if(typeof window>"u")return;const O=Y=>{const Z=Y.detail,we=typeof Z?.sessionId=="string"?Z.sessionId.trim():"";if(!we)return;const L=typeof Z?.directory=="string"&&Z.directory.trim().length>0?Z.directory.trim():null,pe=typeof Z?.messageId=="string"&&Z.messageId.trim()||null;ua(we,String(Z?.runtimeKey??"").trim(),pe)||i1(we,{directory:L,messageId:pe})};return window.addEventListener("openchamber:open-session",O),hf().then(Y=>{for(const Z of Y)ua(Z.sessionId,Z.runtimeKey,Z.messageId)||Gg(Z.sessionId,Z.messageId)}),()=>window.removeEventListener("openchamber:open-session",O)},[]),l.useEffect(()=>{if(!Us())return;const O=()=>{I3(Y=>{_e.error(ne(Y==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":Y==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",O),O(),()=>window.removeEventListener("openchamber:host-actions-ready",O)},[ne]);const te=l.useRef({attempt:null,running:!1,done:!1});l.useLayoutEffect(()=>{const O=te.current;O.attempt||(O.attempt=Cp({selectNow:!Tp().sessionId}))},[]),l.useEffect(()=>{const O=te.current,Y=()=>{const Z=O.attempt;if(!Z||O.running||O.done)return;const we=zt.getState().isInitialized;O.running=!0,Z().then(L=>{if(O.running=!1,L!=="failed"||we){O.done=!0;return}zt.getState().isInitialized&&Y()})};Y()},[n]),l.useEffect(()=>{if(typeof window>"u")return;const O=()=>{un("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Nr()})};return window.addEventListener("openchamber:open-mini-chat",O),()=>window.removeEventListener("openchamber:open-mini-chat",O)},[]),l.useEffect(()=>{if(typeof window>"u")return;const O=()=>{const Y=tt.getState().currentSessionId;Y&&Kc(Y)};return window.addEventListener("focus",O),()=>window.removeEventListener("focus",O)},[]),l.useEffect(()=>{if(typeof window>"u")return;const O=Y=>{const Z=Y.detail,we=typeof Z?.directory=="string"&&Z.directory.trim().length>0?Z.directory.trim():null,L=typeof Z?.projectId=="string"&&Z.projectId.trim().length>0?Z.projectId.trim():null,pe=!!(we||L);X.getState().setSessionSwitcherOpen(!1),tt.getState().openNewSessionDraft({target:pe?"project":"chat",selectedProjectId:pe?L:null,directoryOverride:pe?we:null,preserveDirectoryOverride:!!we})};return window.addEventListener("openchamber:open-draft-session",O),()=>window.removeEventListener("openchamber:open-draft-session",O)},[]),l.useEffect(()=>{typeof window>"u"||!n||p||z.current||(z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),Kg(),h3(),Np(f||null),x3(),Ep(t.sourceControl),Pp(t.trackers),w3(),S3(),Zg(),Ip(),k3(),C3(n&&r,R),T3(),Xg(),w1(),Rp();const re=l.useCallback(()=>{h(O=>!O)},[]);$j(re),d3(),y1(!0),l.useEffect(()=>{const O=()=>h(Y=>!Y);return window.addEventListener("openchamber:memory-debug-toggle",O),()=>window.removeEventListener("openchamber:memory-debug-toggle",O)},[]),l.useEffect(()=>{c&&setTimeout(()=>d(),5e3)},[d,c]),l.useEffect(()=>{if(!A||$!=="not-injected")return;let O=!1,Y=0;const Z=200,we=2e3,L=50,pe=()=>{if(O)return;Y++;const je=aa();if(je!=="not-injected"){if(O=!0,K(je),je==="valid"){const Se=jo();Se&&M(la({isDesktopShell:!0,bootOutcome:Se}))}return}const Ee=Math.min(Z*Math.pow(1.1,Y),we);if(Y>=L){const Se=document.getElementById("initial-loading");Se&&!Se.textContent?.includes("taking longer")&&(Se.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(pe,Ee)};return window.setTimeout(pe,Z),()=>{O=!0}},[A,$]);const Q=l.useCallback(async()=>{if(gf({isDesktopShell:Us(),isDesktopLocalOriginActive:eo()})){await xf();return}window.location.reload()},[]),ee=l.useCallback(async()=>{if(!P){y(!1),k(!0);try{await zt.getState().initializeApp()}finally{k(!1)}zt.getState().isInitialized||j(O=>O+1)}},[P]),le=O=>{if(O.screen==="recovery")return O.variant};if(A&&q&&q.screen!=="main"){if(q.screen==="chooser")return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Wl,{mode:"first-launch",localAvailable:q.localAvailable!==!1,onCliAvailable:Q,onChooseRemote:()=>{}})})})});const O=le(q),Y=q.screen==="recovery"&&"url"in q?q.url:void 0,Z=q.screen==="recovery"&&"hostId"in q?q.hostId:void 0;return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Wl,{mode:"recovery",recoveryVariant:O,recoveryHostUrl:Y,recoveryHostLabel:void 0,recoveryHostId:Z,localAvailable:q.localAvailable!==!1,onCliAvailable:Q})})})})}return S&&!n&&!b?s.jsx(Qt,{children:s.jsx(K3,{onRetry:()=>{ee()},isRetrying:P},R)}):s.jsx(Qt,{children:s.jsx(Yg,{sdk:qo.getSdkClient(),directory:f||"",children:s.jsx(Jg,{apis:t,children:s.jsx(Dp,{children:s.jsx(Qg,{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(e1,{backgroundWorkEnabled:!0}),s.jsx(_p,{}),s.jsx(R3,{}),s.jsx(Wk,{}),A?s.jsx(Ap,{ready:F&&C}):null,s.jsx(t1,{}),s.jsx(s1,{}),s.jsx(n1,{}),s.jsx(r1,{}),s.jsx(o1,{}),s.jsx(Op,{}),s.jsx(q3,{}),m&&s.jsx(G3,{onClose:()=>h(!1)})]})})})})},R)})}function X3(t){const e=Be.c(2);let n;return e[0]!==t?(n=s.jsx(Sp,{children:s.jsx(Z3,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function Y3(t){return t.isAboutDialogOpen}function J3(t){return t.setAboutDialogOpen}function Q3(){}function e4(){}function t4(t){return t.lastInitFailure}const s4=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();bf();yu()&&N3();Mp();Fp();wf().then(()=>{a1().catch(t=>{console.error("[main] settings init failed:",t)}),l1(),c1(),d1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Su=document.getElementById("root");if(!Su)throw new Error("Root element not found");u1();ku.createRoot(Su).render(s.jsx(Wt.StrictMode,{children:s.jsx(f1,{children:s.jsx(p1,{children:s.jsx(m1,{children:s.jsx(h1,{children:s.jsx(X3,{apis:s4})})})})})}));const y4=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Ha as P,qx as a,Nb as b,w4 as g,y4 as m,Aj as o,b4 as r,gd as u};