@openchamber/web 2.7.1 → 2.7.2-canary.20261113.19
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.
- package/dist/assets/{AboutDialog-Byc63m0u.js → AboutDialog-DZBVspvU.js} +1 -1
- package/dist/assets/{AboutLogo-BwwjES_b.js → AboutLogo-ChxCGRUm.js} +1 -1
- package/dist/assets/{ArchiveView-DIg8Bq5r.js → ArchiveView-BZJ26vYO.js} +1 -1
- package/dist/assets/{ChangeRequestDiffUnavailable-DtCWp1bf.js → ChangeRequestDiffUnavailable-DWvRZnAG.js} +1 -1
- package/dist/assets/{CommandPalette-D1G7W43z.js → CommandPalette-ynDRBNPC.js} +1 -1
- package/dist/assets/{DataFileArtifact-BPwh4rIZ.js → DataFileArtifact-z9fPrgyu.js} +1 -1
- package/dist/assets/{DiffView-B9-zXR21.js → DiffView-BZ72jtft.js} +1 -1
- package/dist/assets/{FilesView-CTKhKCjC.js → FilesView-C6unlf1o.js} +3 -3
- package/dist/assets/{GitView-2p131yFW.js → GitView-C5sudp8H.js} +1 -1
- package/dist/assets/{GuestPanelContent-BY7I-Y-o.js → GuestPanelContent-VypuCChp.js} +1 -1
- package/dist/assets/{HelpDialog-BfDxlsKj.js → HelpDialog-BCLY1SdQ.js} +1 -1
- package/dist/assets/{IntegrationsCatalogView-DX9AlNKS.js → IntegrationsCatalogView-CCC5vFCc.js} +1 -1
- package/dist/assets/{JsonTreeView-Ghbn2jaO.js → JsonTreeView-B1jPqBE_.js} +1 -1
- package/dist/assets/{MarkdownDiffPreview-CcER_eYB.js → MarkdownDiffPreview-BRsvVmm6.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DjBAwXof.js → MarkdownRendererImpl-Bja7xPRh.js} +4 -4
- package/dist/assets/{MemoryDebugPanel-MrH6vI6i.js → MemoryDebugPanel-BiidelAZ.js} +1 -1
- package/dist/assets/{NoteEditor-DnaXw3v6.js → NoteEditor-CDhrox_N.js} +1 -1
- package/dist/assets/{OfficeArtifact-av3so80I.js → OfficeArtifact-CSzZ3l3x.js} +2 -2
- package/dist/assets/{OfficeDocumentDiff-C-XvqPYx.js → OfficeDocumentDiff-DIZPU2-t.js} +1 -1
- package/dist/assets/{OnboardingScreen-Dlbi5e0G.js → OnboardingScreen-BNELvFqK.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-BZzdMaVU.js → OpenCodeStatusDialog-riJvcyNM.js} +1 -1
- package/dist/assets/{OverviewView-CQ82APO2.js → OverviewView-DrjJJdxp.js} +1 -1
- package/dist/assets/{PatchDiff-EZ_WbikC.js → PatchDiff-CbSen5Gt.js} +1 -1
- package/dist/assets/{PlanView-jUry4bXu.js → PlanView-Bi7nN60G.js} +1 -1
- package/dist/assets/{ProjectActionsDialog-Bt6OXdLD.js → ProjectActionsDialog-5SwtkdoL.js} +1 -1
- package/dist/assets/{ReplyCommand-CLNJlG5f.js → ReplyCommand-B-b5HiGJ.js} +1 -1
- package/dist/assets/{ReplyUiBlock-DthlzVWC.js → ReplyUiBlock-SITDS2N8.js} +1 -1
- package/dist/assets/{ReviewCards-qePUMD-z.js → ReviewCards-ClKfTGPh.js} +1 -1
- package/dist/assets/{RunOverview-CvD2Q7KM.js → RunOverview-Zx7ypz3K.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-Dtdb6owf.js → ScheduledTasksDialog-BqkQPZwR.js} +1 -1
- package/dist/assets/{SettingsView-JBCXhydZ.js → SettingsView-CcxtXPxF.js} +1 -1
- package/dist/assets/{SettingsWindow-RJIA1rl5.js → SettingsWindow-rjA8cpzb.js} +1 -1
- package/dist/assets/{SidebarSectionsManager-4i4NcHs0.js → SidebarSectionsManager-DFbc8Xwd.js} +1 -1
- package/dist/assets/{SourceBoardView-BuYJw-Sp.js → SourceBoardView-ClskEpR_.js} +1 -1
- package/dist/assets/{SpaceAccessDialog-B4-bPo9e.js → SpaceAccessDialog-VIsmK3Lq.js} +1 -1
- package/dist/assets/{SpaceApplyDialog-DjTQ5PZT.js → SpaceApplyDialog-CE4GGYR-.js} +1 -1
- package/dist/assets/{SpaceRow-CYk17vzn.js → SpaceRow-DoksNK04.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-DRDEgMzx.js → SpaceSetupOutput-CCkZT6Bi.js} +1 -1
- package/dist/assets/{SpacesView-BSt0xE6N.js → SpacesView-BBtBwQ17.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CTwpN0TO.js → SubmoduleDiffSummary-DoIUrBdP.js} +1 -1
- package/dist/assets/{TableArtifact-BGTFUrHC.js → TableArtifact-CxUbqjYv.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DcQ4eDvb.js → ToolOutputDialog-DPLjXvqn.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-idv0MY3G.js → ToolPartDiffPreview-B2wDDrfp.js} +1 -1
- package/dist/assets/{UiBlock-CVYWc3Px.js → UiBlock-DwXhgpqK.js} +2 -2
- package/dist/assets/{UsageStatsView-Cgo61IDa.js → UsageStatsView-BqLNssJZ.js} +1 -1
- package/dist/assets/{WalkthroughView-CYr8y2pi.js → WalkthroughView-B7KbSsAT.js} +1 -1
- package/dist/assets/{WorktreesView-Duwvqggr.js → WorktreesView-C-AdzkFm.js} +1 -1
- package/dist/assets/{appThemeRegistry-DgyhfFpu.js → appThemeRegistry-3vWr61EA.js} +1 -1
- package/dist/assets/{ar-zwtOisVI.js → ar-D4S57MOa.js} +1 -1
- package/dist/assets/{codeHighlight-DQ8KOMKI.js → codeHighlight-vTDDxBjH.js} +1 -1
- package/dist/assets/{columnWidthMemory-Ol4D51DU.js → columnWidthMemory-CaG5_n8B.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-P_6wH9ys.js → computeVirtualFileMetrics-oAeWRt0Z.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-9zXH1DLm.js → contextFileOpenGuard-BTdwRRDI.js} +1 -1
- package/dist/assets/{date-time-CRucRasX.js → date-time-De4cJmG-.js} +1 -1
- package/dist/assets/{de-5cm4El6N.js → de-YPT7BRkX.js} +1 -1
- package/dist/assets/{documentClient-BbTBnbCU.js → documentClient-ByzYQ2D3.js} +2 -2
- package/dist/assets/{documentHost-Dxv6OV6h.js → documentHost-DaJ0XQTx.js} +1 -1
- package/dist/assets/{editorCodeMetrics-BzYZ4PzQ.js → editorCodeMetrics-CkrWYimB.js} +1 -1
- package/dist/assets/{es-CYh9u5rf.js → es-BqIzbLh0.js} +1 -1
- package/dist/assets/{fileContentPoller-p6RiDNz7.js → fileContentPoller-BXbgYIo0.js} +1 -1
- package/dist/assets/{flexokiTheme-BNUmLj3l.js → flexokiTheme-Yh7J7UaE.js} +1 -1
- package/dist/assets/{fr-gZGCwYzk.js → fr-Bm6tuRAq.js} +1 -1
- package/dist/assets/{he-DWb3dvEl.js → he-B2vIErcj.js} +1 -1
- package/dist/assets/{highlights-DWR6MS75.js → highlights-B2QjzKD7.js} +1 -1
- package/dist/assets/{index-BcEWRtz8.js → index-CsjRKzmq.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-u4U22OVN.js → initializeSharedPreferences-vJOU8q9Y.js} +1 -1
- package/dist/assets/{install-CkKsKExH.js → install-BXZHlgVP.js} +1 -1
- package/dist/assets/{install-request-C0o_6GEa.js → install-request-e6fA_Hb1.js} +1 -1
- package/dist/assets/{isDiffPlainText-B70cjgtm.js → isDiffPlainText-CBdbdXoZ.js} +1 -1
- package/dist/assets/{isFilePlainText-DNNat5m3.js → isFilePlainText-DTR6Yek4.js} +1 -1
- package/dist/assets/{ja-CAeb9wyo.js → ja-D6qPQWDj.js} +1 -1
- package/dist/assets/{katex.min-2cmqKX7p.js → katex.min-BRXXWH9j.js} +4 -4
- package/dist/assets/{ko-DuYqVIuP.js → ko-CISJffvx.js} +1 -1
- package/dist/assets/{main-D9Ri_lHo.js → main-C4tbgFgt.js} +2 -2
- package/dist/assets/{main-kUMMbMdC.js → main-Dhneuvk9.js} +4 -4
- package/dist/assets/{miniChat-HoE2mQuK.js → miniChat-BjuV8rx7.js} +2 -2
- package/dist/assets/{mobile-BFQ0eaJT.js → mobile-iSTV6yUg.js} +2 -2
- package/dist/assets/{moveWorkspacePath-BkzUq9fV.js → moveWorkspacePath-BEX7mjeu.js} +1 -1
- package/dist/assets/{nl-BPlUOQoY.js → nl-B61i4I1-.js} +1 -1
- package/dist/assets/{officeDocument-C74tIqpD.js → officeDocument-CaOOikR3.js} +1 -1
- package/dist/assets/{parseDiffFromFile-COnIA377.js → parseDiffFromFile-BSeCTEcW.js} +1 -1
- package/dist/assets/{pierreDiffTint-9AmpxGGB.js → pierreDiffTint-BKAarfyR.js} +1 -1
- package/dist/assets/{pl-DZRSuGdV.js → pl-B7tMuoTp.js} +1 -1
- package/dist/assets/{pt-BR-fU-ttTba.js → pt-BR-DM4sowqf.js} +1 -1
- package/dist/assets/{relocateRestoredSession-DawfZWX6.js → relocateRestoredSession-B9bwH9_3.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-q30Gq6wf.js → renderElectronMiniChatApp-Ds-rupUf.js} +2 -2
- package/dist/assets/{renderMarkdownForExport-0rL6OK8T.js → renderMarkdownForExport-CO6kiTFz.js} +1 -1
- package/dist/assets/{renderMobileApp-B_PjVgBu.js → renderMobileApp-vACiOPun.js} +3 -3
- package/dist/assets/{resolveLanguages-dF0QdGAX.js → resolveLanguages-DwXFSp4e.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BsAAA4Nf.js → runtimeEndpointReset-0CHuG78d.js} +5 -5
- package/dist/assets/{scheduledTasksApi-CB-Xtp2P.js → scheduledTasksApi-B5hRhk34.js} +1 -1
- package/dist/assets/{shiki-CVNu2J2E.js → shiki-BNrvceeX.js} +1 -1
- package/dist/assets/{space-apply-BmOleF8W.js → space-apply-DlPRGjzD.js} +1 -1
- package/dist/assets/{space-close-DqG3RGoP.js → space-close-DP8YXlG0.js} +1 -1
- package/dist/assets/{spaceNetwork-DUGLrihG.js → spaceNetwork-DBQETFXl.js} +1 -1
- package/dist/assets/{stream-tokenizer-Bzos6Fhy.js → stream-tokenizer-DTPG8KqC.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-BRUbLAuj.js → textMateThemeFromAppTheme-OzgrN6CB.js} +1 -1
- package/dist/assets/{tr-CD93vntx.js → tr-yjYoCwBy.js} +1 -1
- package/dist/assets/{uk-DTqcJvdn.js → uk-5yOoSRye.js} +1 -1
- package/dist/assets/{useAppFontEffects-xaAfmUwn.js → useAppFontEffects-BkjZnJsc.js} +15 -15
- package/dist/assets/{useBranchPullRequestRequest-CIftwmmA.js → useBranchPullRequestRequest-FtZEfVLl.js} +1 -1
- package/dist/assets/{useCallableModelProviders-DYpBJMqj.js → useCallableModelProviders-CiB4Z_LE.js} +1 -1
- package/dist/assets/{useDiffFindSurface-CqxU53Ed.js → useDiffFindSurface-CwoUylJl.js} +1 -1
- package/dist/assets/{useGitCleanLine-CmVX9s9E.js → useGitCleanLine-e7HoRw02.js} +1 -1
- package/dist/assets/{useInlineCommentController-C-V8vqSj.js → useInlineCommentController-CJmX7RR7.js} +1 -1
- package/dist/assets/{useMarkdownLocalAssets-BfOLz9Xm.js → useMarkdownLocalAssets-Cqxh_vbH.js} +1 -1
- package/dist/assets/{useRootScrollLock-Ciuj2iZ_.js → useRootScrollLock-BDtmtwPT.js} +1 -1
- package/dist/assets/{useWalkthroughReview-BdjnKO7o.js → useWalkthroughReview-CeQ95bk7.js} +1 -1
- package/dist/assets/{useWholeFileComment-DkYtu1tm.js → useWholeFileComment-CHOMIHNo.js} +1 -1
- package/dist/assets/{useWorktreeArchiveActions-DGzuZU_x.js → useWorktreeArchiveActions-BhGDka1f.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CSQf665k.js → vendor-codemirror-language-data-ClBHCVu_.js} +2 -2
- package/dist/assets/{zh-CN-BJ4oeBCY.js → zh-CN-CCV5QMTb.js} +1 -1
- package/dist/assets/{zh-TW-BMW1G3F_.js → zh-TW-CKda-uV0.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-2p131yFW.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-xaAfmUwn.js","assets/katex.min-2cmqKX7p.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-B_hXR7jf.js","assets/vendor-opencode-client-NJGkA1Ku.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-DKWxHuRR.css","assets/vendor-base-ui-CHqK1aDI.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-Bw3q1rnq.js","assets/vendor-tanstack-virtual-core-B4TJYmIq.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-CSQf665k.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-iLtL-MFj.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-BsAAA4Nf.js","assets/space-apply-BmOleF8W.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-CmVX9s9E.js","assets/useBranchPullRequestRequest-CIftwmmA.js","assets/parseDiffFromFile-COnIA377.js","assets/computeVirtualFileMetrics-P_6wH9ys.js","assets/themeResolver-Dybtoo13.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-B70cjgtm.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-9AmpxGGB.js","assets/ReviewCards-qePUMD-z.js","assets/useInlineCommentController-C-V8vqSj.js","assets/appThemeRegistry-DgyhfFpu.js","assets/textMateThemeFromAppTheme-BRUbLAuj.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/editorCodeMetrics-BzYZ4PzQ.js","assets/OfficeDocumentDiff-C-XvqPYx.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/documentClient-BbTBnbCU.js","assets/useRootScrollLock-Ciuj2iZ_.js","assets/moveWorkspacePath-BkzUq9fV.js","assets/contextFileOpenGuard-9zXH1DLm.js","assets/install-request-C0o_6GEa.js","assets/WalkthroughView-CYr8y2pi.js","assets/ChangeRequestDiffUnavailable-DtCWp1bf.js","assets/useDiffFindSurface-CqxU53Ed.js","assets/useWalkthroughReview-BdjnKO7o.js","assets/useCallableModelProviders-DYpBJMqj.js","assets/useWholeFileComment-DkYtu1tm.js","assets/DiffView-B9-zXR21.js","assets/SubmoduleDiffSummary-CTwpN0TO.js","assets/FilesView-CTKhKCjC.js","assets/flexokiTheme-BNUmLj3l.js","assets/vendor-codemirror-search-CWqbGraJ.js","assets/vendor-replit-codemirror-vim-DTiXsOdM.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-BfOLz9Xm.js","assets/fileContentPoller-p6RiDNz7.js","assets/JsonTreeView-Ghbn2jaO.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-DNNat5m3.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-DQ8KOMKI.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-CB-Xtp2P.js","assets/GuestPanelContent-BY7I-Y-o.js","assets/SettingsWindow-RJIA1rl5.js","assets/SettingsView-JBCXhydZ.js","assets/install-CkKsKExH.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SpaceRow-CYk17vzn.js","assets/AboutLogo-BwwjES_b.js","assets/pageTitle-BT3-HFbv.js","assets/CommandPalette-D1G7W43z.js","assets/HelpDialog-BfDxlsKj.js","assets/ProjectActionsDialog-Bt6OXdLD.js","assets/OpenCodeStatusDialog-BZzdMaVU.js","assets/RunOverview-CvD2Q7KM.js","assets/ScheduledTasksDialog-Dtdb6owf.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-CRucRasX.js","assets/ArchiveView-DIg8Bq5r.js","assets/useWorktreeArchiveActions-DGzuZU_x.js","assets/IntegrationsCatalogView-DX9AlNKS.js","assets/UsageStatsView-Cgo61IDa.js","assets/SourceBoardView-BuYJw-Sp.js","assets/OverviewView-CQ82APO2.js","assets/WorktreesView-Duwvqggr.js","assets/SpacesView-BSt0xE6N.js","assets/SpaceAccessDialog-B4-bPo9e.js","assets/spaceNetwork-DUGLrihG.js","assets/SpaceApplyDialog-DjTQ5PZT.js","assets/SpaceSetupOutput-DRDEgMzx.js","assets/OnboardingScreen-Dlbi5e0G.js","assets/AboutDialog-Byc63m0u.js","assets/MemoryDebugPanel-MrH6vI6i.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as Ue,j as n,R as c,r as $t,a as Gl,h as _u}from"./vendor-react--VO_rL_p.js";import{l as zt,cZ as Au,c_ as Zl,u as K,bG as Ps,m as pr,b3 as qt,b5 as to,n as Jt,b2 as Ou,bM as so,cy as rs,c$ as Ei,b7 as no,d0 as Mu,ck as Xl,d1 as yt,d2 as Fu,bD as Br,bE as Ys,bF as Qo,c5 as Lu,bN as Yl,bB as Pi,d3 as Bu,cm as Jl,ce as ca,ba as Ql,d4 as $u,d5 as mr,d6 as $r,d7 as er,d8 as zu,d9 as Kn,da as Wu,db as ei,dc as jr,dd as Ii,de as ro,cQ as Pn,bo as zr,j as zs,df as jn,dg as Uu,dh as bs,b as dn,di as hr,dj as ec,dk as Vu,dl as Zs,dm as Hu,dn as tc,dp as Ku,dq as qu,dr as sc,ds as Gu,cB as Zu,cj as Xu,ct as Yu,co as Ju,bC as Qu,bI as us,v as ti,cp as ef,dt as tf,du as sf,bY as si,dv as Ri,dw as nf,by as rf,bg as da,cT as nc,dx as ua,bf as rc,dy as of,dz as af,w as oc,cs as lf,dA as fa,b_ as Di,dB as ic,c7 as cf,be as df,t as uf,q as ff,bH as ac,cG as pa,cH as lc,cW as pf,cz as mf,cD as ma,dC as hf,dD as gf,c3 as xf,c1 as bf,dE as wf,c8 as yf,cF as vf,dF as Sf,dG as kf,dH as jf,dI as ha,dJ as Po,dK as ga,dL as xa,dM as Cf,bP as ba,dN as Tf,dO as Nf,bQ as wa,dP as Ef,c2 as Pf,i as If,a as Rf}from"./katex.min-2cmqKX7p.js";import{_ as Ft}from"./vendor-vite-runtime-DD1OZmLC.js";import{bZ as Df,b_ as cc,b$ as _f,c0 as Af,c1 as Of,r as _i,c2 as Mf,c3 as Ff,c4 as Lf,c5 as Bf,n as ya,c6 as $f,aW as zf,c7 as Wf,aZ as va,c8 as Uf,aa as dc,ac as uc,ai as fc,ae as pc,ab as mc,a9 as Ai,ah as hc,af as gc,ad as xc,aK as Vf,aL as Hf,aP as Kf,aQ as qf,aR as Gf,aN as Zf,K as Xf,aM as Yf,N as Jf,a8 as Qf,aj as ep,bA as tp,c9 as bc,ca as Ir,cb as sp,cc as np,cd as wc,ce as bn,cf as Sa,cg as ka,ch as Io,ci as ja,M as rp,an as op,aO as Rr,bx as ip,by as ap,aT as lp,bW as yc,cj as cp,bz as dp,ck as up,cl as fp,cm as Ca,cn as Ro,co as sn,cp as wn,cq as pp,cr as Ta,cs as mp,ct as hp,cu as gp,cv as xp,cw as bp,cx as wp,cy as yp,cz as Na,cA as vp,cB as Sp,cC as kp,cD as jp,cE as Cp,bB as Tp,bw as Np,bV as Ep,bC as Pp,bX as Ip,cF as Rp,bR as Dp,bS as _p,aV as vc,cG as Ap,cH as Op,cI as Mp,cJ as Fp,cK as Lp,bU as Bp,cL as $p,bN as zp,cM as Wp,cN as Up,bK as Vp,bJ as Hp,bE as Kp,bF as qp,bG as Gp,bH as Zp,bI as Xp,bD as Yp,bL as Jp,bY as Qp,bQ as em,bP as tm,bT as sm,cO as nm,cP as rm}from"./runtimeEndpointReset-BsAAA4Nf.js";import{bi as oo,_ as Gt,a1 as nt,cQ as gr,a3 as Ze,fz as om,cR as im,I as ce,fA as am,u as lt,lR as nn,Z as ts,lS as lm,az as ws,aD as Ws,aA as Oi,lT as Sc,b1 as Bs,gM as kc,gK as cm,gL as dm,lU as jc,bb as xr,ag as St,af as kt,ah as jt,kd as Us,cU as Cc,bd as br,lV as um,lW as fm,lX as pm,lY as mm,lZ as hm,$ as gm,l_ as xm,l$ as Tc,cZ as Mi,b4 as bm,a0 as wm,m0 as ym,A as Oe,bC as vm,m1 as Sm,m2 as km,kr as Nc,m3 as jm,bL as Hs,fS as Cm,ay as Tm,be as vs,b8 as io,bc as ao,br as Cn,m4 as Nm,m5 as lo,P as hn,m6 as Em,fX as Ec,m7 as Pm,ih as wr,ii as co,cL as Wr,fY as Im,kQ as Rm,m8 as Dm,bl as tr,g4 as Pc,m9 as _m,t as sr,q as nr,D as rr,l as or,F as ir,o as Ur,B as ut,ma as In,a6 as fn,a7 as pn,a8 as mn,mb as Ic,mc as Fi,n as as,ck as Xt,md as Rc,me as Am,d7 as Dc,mf as Om,mg as Mm,bP as ks,mh as Fm,cp as un,mi as Ea,bV as Dr,ae as qn,mj as Lm,a9 as $s,gw as Bm,cA as Li,mk as $m,ml as _c,mm as Bi,em as zm,d_ as Vr,et as Ac,eg as $i,eh as zi,mn as Oc,aR as ns,y as Rn,C as ni,hK as Wm,ie as Um,hV as Vm,iA as Hm,mo as Km,hr as Mc,bR as Ls,K as Wi,bK as qm,au as hs,bQ as Fc,cr as Pa,cq as Un,hs as Gm,cs as Zm,cH as uo,cC as Xm,hu as Do,mp as Ym,z as Jm,aT as Qm,aU as eh,aV as th,aW as sh,aX as nh,aQ as Ia,bW as Lc,bT as Hr,mq as rh,mr as oh,ms as ih,aZ as On,bI as ah,bM as fo,bO as lh,bS as ch,bN as Dn,ip as dh,bU as uh,hx as fh,cB as po,mt as Bc,mu as $c,mv as ph,ea as mh,e6 as hh,e9 as gh,mw as xh,ei as bh,e7 as Ra,mx as wh,iK as yh,my as vh,mz as Sh,e8 as Da,es as kh,ec as jh,cl as Ch,mA as Th,mB as Nh,mC as Eh,mD as Ui,mE as Vi,mF as Ph,mG as Ih,mH as Rh,mI as Dh,mJ as _h,lu as Hi,mK as Ah,mL as Oh,mM as Mh,mN as Fh,mO as Ki,mP as Lh,bJ as Bh,mQ as $h,mR as zh,bY as zc,mS as Wc,bt as Wh,mT as Uh,x as Uc,mU as Vh,mV as Sn,c5 as Hh,bH as Kh,as as qh,mW as Gh,W as Bt,mX as Zh,mY as Xh,dJ as Yh,mZ as Vc,m_ as Jh,m$ as _r,n0 as yn,k1 as Qh,n1 as cn,ep as eg,n2 as tg,n3 as Hc,kX as Kc,e_ as mo,n4 as sg,el as ng,dQ as rg,n5 as qi,n6 as og,cG as ig,cE as ag,n7 as lg,n8 as _o,d6 as Gi,fB as _n,n9 as qc,bj as cg,na as dg,nb as ug,nc as fg,nd as Ao,ne as pg,nf as mg,hd as Zi,c$ as hg,ha as gg,ke as xg,kf as bg,d8 as wg,ng as ar,h9 as Gc,h8 as Zc,kg as yg,kh as vg,hb as Sg,d0 as kg,eF as jg,cj as Cg,lC as Tg,c7 as Ng,nh as Oo,lm as Eg,ll as Pg,ni as Xc,nj as Yc,nk as Ig,nl as ri,nm as Gs,e2 as Rg,kb as Dg,lk as _a,nn as _g,no as Ag,ba as lr,np as Aa,nq as Og,nr as Mg,ns as Fg,kv as Lg,kw as Bg,nt as $g,kx as Oa,nu as zg,ky as Ma,kz as Wg,dB as Ug,nv as Vg,nw as Hg,nx as Kg,bs as qg,k as Gg,l0 as Zg,cW as Mo,kA as Xg,kB as Yg,ny as Fa,kC as Jg,c_ as Qg,kF as e1,kD as t1,kE as s1,nz as Fo,nA as La,lP as n1,kT as Xi,eC as yr,kN as r1,nB as o1,nC as Jc,fo as i1,gP as oi,nD as Qc,jy as ho,kZ as a1,di as l1,nE as c1,nF as ed,fV as d1,nG as u1,nH as td,eE as f1,eD as Yi,nI as p1,nJ as Ba,nK as m1,nL as h1,eG as g1,G as ii,nM as sd,cu as nd,cv as rd,cw as od,cx as id,nN as ai,cy as ad,kn as ld,nO as Lo,nP as x1,gO as b1,k$ as w1,a2 as y1,nQ as v1,nR as S1,nS as cd,b2 as $a,fh as k1,ki as j1,nT as C1,kl as T1,nU as N1,dK as za,nV as E1,kp as P1,nW as I1,lv as R1,g9 as D1,nX as _1,go as Wa,b9 as A1,ga as O1,gc as M1,gb as F1,gk as L1,gj as B1,gd as $1,lw as z1,gi as W1,ge as U1,gf as V1,gg as H1,gh as K1,a as q1,s as G1,b as Z1,c as X1,lI as Y1,al as J1,gr as Q1,gs as ex,gt as tx}from"./useAppFontEffects-xaAfmUwn.js";import{f as dd,u as ud,S as sx,W as fd,a as nx,b as rx,c as ox}from"./useRootScrollLock-Ciuj2iZ_.js";import{h as pd,i as Kr,T as md,M as hd,D as gd,f as li}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as ix,h as ax,u as xd,S as bd,v as lx,a as cx}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as wd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{C as dx}from"./vendor-base-ui-CHqK1aDI.js";import{a as rn,O as ux,d as fx,D as px,b as mx,u as hx,m as Ua}from"./moveWorkspacePath-BkzUq9fV.js";import{u as ci,c as go,p as gx}from"./vendor-zustand-C9tWdk0j.js";import{o as Js,s as Ss,n as xo,c as yd,h as xx,f as cr,a as di}from"./vendor-zod-B_hXR7jf.js";import{u as bx}from"./vendor-tanstack-react-virtual-Bw3q1rnq.js";import{v as Va,t as Ha}from"./contextFileOpenGuard-9zXH1DLm.js";import{d as wx,m as yx}from"./vendor-tanstack-virtual-core-B4TJYmIq.js";import{r as vx}from"./install-request-C0o_6GEa.js";function Sx(t){const e=Ue.c(37),{directory:s,className:r}=t,{currentTheme:o}=oo(),i=Gt(Cx),a=nt(jx),d=zt(kx),u=Au(s);let l;e[0]!==s||e[1]!==d?(l=Zl(s,d),e[0]=s,e[1]=d,e[2]=l):l=e[2];const f=l;let m;e[3]!==s||e[4]!==f||e[5]!==i||e[6]!==u||e[7]!==a?(m=f||!s?null:gr(i,a,s,u),e[3]=s,e[4]=f,e[5]=i,e[6]=u,e[7]=a,e[8]=m):m=e[8];const p=m;if(f){let L;e[9]!==r?(L=Ze("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=L):L=e[10];let v;return e[11]!==L?(v=n.jsx(ce,{name:"chat-4",className:L}),e[11]=L,e[12]=v):v=e[12],v}if(!p)return null;const h=p.icon?om[p.icon]:null;let x;e[13]!==p.color?(x=im(p.color)??void 0,e[13]=p.color,e[14]=x):x=e[14];const g=x;let w;e[15]!==r||e[16]!==g||e[17]!==h?(w=h?n.jsx(ce,{name:h,className:Ze("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):n.jsx(ce,{name:"folder",className:Ze("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]=w):w=e[18];const b=w;if(!p.iconImage)return b;let j;e[19]!==r?(j=Ze("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=j):j=e[20];let y;e[21]!==p.iconBackground?(y=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[21]=p.iconBackground,e[22]=y):y=e[22];let E;e[23]!==p.iconImage||e[24]!==p.id?(E={id:p.id,iconImage:p.iconImage},e[23]=p.iconImage,e[24]=p.id,e[25]=E):E=e[25];let A;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(A={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=A):A=e[28];let R;e[29]!==b||e[30]!==E||e[31]!==A?(R=n.jsx(am,{project:E,options:A,className:"h-full w-full object-contain",fallback:b}),e[29]=b,e[30]=E,e[31]=A,e[32]=R):R=e[32];let _;return e[33]!==j||e[34]!==y||e[35]!==R?(_=n.jsx("span",{className:j,style:y,children:R}),e[33]=j,e[34]=y,e[35]=R,e[36]=_):_=e[36],_}function kx(t){return t.homeDirectory}function jx(t){return t.availableWorktreesByProject}function Cx(t){return t.projects}const Vn=24,Tx=(t,e,s=Vn)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},Nx=({transform:t})=>({...t,y:0}),Ex=16,Px=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*Ex:t.deltaY;t.currentTarget.scrollLeft+=to(t.currentTarget)?-e:e},Ix=t=>{const e=Ue.c(118),{tab:s,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:d,onPin:u,onClose:l,renderMenu:f,closeOtherTabs:m,onMenuOpenChangeComplete:p,menuReturnsFocus:h,children:x}=t,{t:g}=lt(),w=K(Dx);let b;e[0]!==w?(b=Oi("switch_session_tab",w),e[0]=w,e[1]=b):b=e[1];const j=b;let y;e[2]!==r||e[3]!==j?(y=j&&j!==Sc&&r<=9?ws(`${j}+${r}`):void 0,e[2]=r,e[3]=j,e[4]=y):y=e[4];const E=y,[A,R]=c.useState(!1);let _;e[5]!==s.id?(_={id:s.id},e[5]=s.id,e[6]=_):_=e[6];const{attributes:L,listeners:v,setNodeRef:C,transform:S,transition:k,isDragging:N}=xd(_);let $;e[7]!==g||e[8]!==s.session.title?($=s.session.title?.trim()||g("sessions.sidebar.session.untitled"),e[7]=g,e[8]=s.session.title,e[9]=$):$=e[9];const B=$,D=s.id;let W;e[10]!==s.session?(W=Bs(s.session),e[10]=s.session,e[11]=W):W=e[11];const H=cc(D,W),U=kc(s.id),se=U!==null,z=cm(s.id),Q=dm(s.id),O=se||z&&(!o||Q)&&!se;let ne;e[12]!==d||e[13]!==s?(ne=()=>d(s),e[12]=d,e[13]=s,e[14]=ne):ne=e[14];let V;e[15]!==m||e[16]!==s.id?(V=()=>m(s.id),e[15]=m,e[16]=s.id,e[17]=V):V=e[17];let J,F,re,q,ge,Z,de,Se,ue,ke,Me,We,Le,Ve,Ne,me;if(e[18]!==L||e[19]!==x||e[20]!==A||e[21]!==o||e[22]!==H||e[23]!==N||e[24]!==i||e[25]!==z||e[26]!==v||e[27]!==h||e[28]!==l||e[29]!==p||e[30]!==u||e[31]!==d||e[32]!==f||e[33]!==C||e[34]!==w||e[35]!==O||e[36]!==a||e[37]!==g||e[38]!==ne||e[39]!==V||e[40]!==s||e[41]!==E||e[42]!==B||e[43]!==S||e[44]!==k||e[45]!==U){const _e={session:s.session,open:A,isActive:o,select:ne,closeOtherTabs:V,components:_f};ue=C;let Ie;e[62]!==S?(Ie=wd.Translate.toString(S),e[62]=S,e[63]=Ie):Ie=e[63],e[64]!==Ie||e[65]!==k?(ke={transform:Ie,transition:k},e[64]=Ie,e[65]=k,e[66]=ke):ke=e[66];const tt=N&&"z-10 opacity-60";e[67]!==tt?(Me=Ze("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",tt),e[67]=tt,e[68]=Me):Me=e[68],We=o?"true":"false",e[69]!==o?(Le=o?{"data-active-session-tab":!0}:{},e[69]=o,e[70]=Le):Le=e[70],Ve=L,Ne=v,F=xr,ge=A,Z=R,e[71]!==p?(de=rt=>p?.(rt),e[71]=p,e[72]=de):de=e[72];let Ke;e[73]!==x||e[74]!==o||e[75]!==H||e[76]!==i||e[77]!==z||e[78]!==l||e[79]!==u||e[80]!==d||e[81]!==w||e[82]!==O||e[83]!==a||e[84]!==g||e[85]!==s||e[86]!==B||e[87]!==U?(Ke=n.jsx(St,{asChild:!0,children:n.jsx(dx,{render:rt=>n.jsx("div",{...rt,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:ve=>{if(ve.altKey){Af(s.id,z,g);return}const M=Bs(s.session);if(ve.shiftKey&&M&&!pr()){Of(s.id,M,B);return}o||d(s)},onDoubleClick:i?()=>u(s.id):void 0,onKeyDown:o?void 0:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),d(s))},onAuxClick:ve=>{ve.button===1&&(ve.preventDefault(),l(s.id))},className:Ze("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:n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[n.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[n.jsx(Sx,{directory:Bs(s.session),className:Ze(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.closeTab"),onClick:ve=>{ve.stopPropagation(),l(s.id)},onPointerDown:_x,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:n.jsx(ce,{name:"close",className:"size-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:g("header.sessionTabs.closeTab"),shortcut:o?ws(Ps()?"mod+w":Ws("close_session_tab",w),""):void 0})})]})]}),n.jsx("div",{className:Ze("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?x:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.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:B})})}),H?n.jsx(ce,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":g("sessions.aiRename.generating")}):O?n.jsx(Cc,{state:U??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[73]=x,e[74]=o,e[75]=H,e[76]=i,e[77]=z,e[78]=l,e[79]=u,e[80]=d,e[81]=w,e[82]=O,e[83]=a,e[84]=g,e[85]=s,e[86]=B,e[87]=U,e[88]=Ke):Ke=e[88];let ze;e[89]!==E||e[90]!==B?(ze=n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:B,shortcut:E})}),e[89]=E,e[90]=B,e[91]=ze):ze=e[91],e[92]!==Ke||e[93]!==ze?(Se=n.jsxs(kt,{children:[Ke,ze]}),e[92]=Ke,e[93]=ze,e[94]=Se):Se=e[94],J=br,e[95]!==h?(me=()=>h?.()??!0,e[95]=h,e[96]=me):me=e[96],re="min-w-[190px]",q=f(_e),e[18]=L,e[19]=x,e[20]=A,e[21]=o,e[22]=H,e[23]=N,e[24]=i,e[25]=z,e[26]=v,e[27]=h,e[28]=l,e[29]=p,e[30]=u,e[31]=d,e[32]=f,e[33]=C,e[34]=w,e[35]=O,e[36]=a,e[37]=g,e[38]=ne,e[39]=V,e[40]=s,e[41]=E,e[42]=B,e[43]=S,e[44]=k,e[45]=U,e[46]=J,e[47]=F,e[48]=re,e[49]=q,e[50]=ge,e[51]=Z,e[52]=de,e[53]=Se,e[54]=ue,e[55]=ke,e[56]=Me,e[57]=We,e[58]=Le,e[59]=Ve,e[60]=Ne,e[61]=me}else J=e[46],F=e[47],re=e[48],q=e[49],ge=e[50],Z=e[51],de=e[52],Se=e[53],ue=e[54],ke=e[55],Me=e[56],We=e[57],Le=e[58],Ve=e[59],Ne=e[60],me=e[61];let ye;e[97]!==J||e[98]!==re||e[99]!==q||e[100]!==me?(ye=n.jsx(J,{finalFocus:me,className:re,children:q}),e[97]=J,e[98]=re,e[99]=q,e[100]=me,e[101]=ye):ye=e[101];let je;e[102]!==F||e[103]!==ge||e[104]!==Z||e[105]!==de||e[106]!==Se||e[107]!==ye?(je=n.jsxs(F,{open:ge,onOpenChange:Z,onOpenChangeComplete:de,children:[Se,ye]}),e[102]=F,e[103]=ge,e[104]=Z,e[105]=de,e[106]=Se,e[107]=ye,e[108]=je):je=e[108];let Be;return e[109]!==ue||e[110]!==ke||e[111]!==Me||e[112]!==We||e[113]!==Le||e[114]!==Ve||e[115]!==Ne||e[116]!==je?(Be=n.jsx("div",{ref:ue,style:ke,className:Me,"data-active":We,...Le,...Ve,...Ne,children:je}),e[109]=ue,e[110]=ke,e[111]=Me,e[112]=We,e[113]=Le,e[114]=Ve,e[115]=Ne,e[116]=je,e[117]=Be):Be=e[117],Be},Rx=t=>{const e=Ue.c(110),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,menuReturnsFocus:i,children:a}=t,d=o===void 0?!1:o,{t:u,direction:l}=lt(),f=l==="rtl",m=nn(Ax),p=nn(Ox),h=nn(Mx),x=nn(Fx),g=nn(Lx),w=nn(Bx),b=nt($x),j=nt(zx),y=ts(Wx),E=K(Ux),A=nn(Vx),R=ts(Hx),_=nt(Kx),L=nt(qx),v=nt(Gx),C=nt(Zx),S=nt(Xx),k=nt(Yx);let N;e[0]!==k?(N=oe=>{const be=k??oe.activeProjectId;return oe.projects.find($e=>$e.id===be)?.path??null},e[0]=k,e[1]=N):N=e[1];const $=Gt(N),B=Df(b);let D,W;e[2]!==B||e[3]!==_||e[4]!==b||e[5]!==S||e[6]!==C||e[7]!==L||e[8]!==$||e[9]!==h||e[10]!==A||e[11]!==E||e[12]!==R?(D=()=>{if(!E)A(um,Jx);else{if(!R)return;const oe=qt(),be=!b&&L&&C,$e=b?_:L&&!C?S??$:null,De=be?fm(oe):pm(oe,$e);if(!De)return;A(De,()=>mm($e,ts.getState().activeSessions,Gt.getState().projects.map(Qx)))}b&&h(b,B)},W=[B,_,b,S,C,L,$,h,A,E,R],e[2]=B,e[3]=_,e[4]=b,e[5]=S,e[6]=C,e[7]=L,e[8]=$,e[9]=h,e[10]=A,e[11]=E,e[12]=R,e[13]=D,e[14]=W):(D=e[13],W=e[14]),c.useEffect(D,W);let H;if(e[15]!==y){H=new Map;for(const oe of y)H.set(oe.id,oe);e[15]=y,e[16]=H}else H=e[16];const U=H;let se;if(e[17]!==U||e[18]!==m){se=[];for(const oe of m){const be=U.get(oe);be&&se.push({id:oe,session:be})}e[17]=U,e[18]=m,e[19]=se}else se=e[19];const z=se;let Q;e[20]!==j?(Q=oe=>{j(oe.id,Bs(oe.session))},e[20]=j,e[21]=Q):Q=e[21];const ie=Q,O=eb,ne=!b&&L;let V;e[22]!==ne||e[23]!==v?(V=oe=>!ne||!v?"":(oe.drafts.find($e=>$e.id===v)?.text??"").split(/\r?\n/).find(tb)?.trim()??"",e[22]=ne,e[23]=v,e[24]=V):V=e[24];const J=lm(V),F=K(sb),re=nb;let q;e[25]!==b||e[26]!==ne||e[27]!==z?(q=z.some(oe=>oe.id===b)||ne&&z.length>0,e[25]=b,e[26]=ne,e[27]=z,e[28]=q):q=e[28];const ge=q;let Z,de;e[29]!==ge?(Z=()=>{if(ge)return _i(rb,{current:document.body})},de=[ge],e[29]=ge,e[30]=Z,e[31]=de):(Z=e[30],de=e[31]),c.useEffect(Z,de);let Se;e[32]!==g||e[33]!==b||e[34]!==ie||e[35]!==z?(Se=oe=>{if(g(oe),b&&b!==oe){const be=z.find($e=>$e.id===oe);be&&ie(be)}},e[32]=g,e[33]=b,e[34]=ie,e[35]=z,e[36]=Se):Se=e[36];const ue=Se;let ke;e[37]===Symbol.for("react.memo_cache_sentinel")?(ke={activationConstraint:{distance:8}},e[37]=ke):ke=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me={activationConstraint:{delay:200,tolerance:6}},e[38]=Me):Me=e[38];const We=pd(Kr(hd,ke),Kr(md,Me));let Le;e[39]!==w?(Le=oe=>{const{active:be,over:$e}=oe;$e&&be.id!==$e.id&&w(String(be.id),String($e.id))},e[39]=w,e[40]=Le):Le=e[40];const Ve=Le,Ne=c.useRef(null);let me;e[41]===Symbol.for("react.memo_cache_sentinel")?(me={left:!1,right:!1},e[41]=me):me=e[41];const[ye,je]=c.useState(me);let Be;e[42]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>{const oe=Ne.current;if(!oe)return;const be=oe.scrollWidth-oe.clientWidth,$e=to(oe)?be+oe.scrollLeft:oe.scrollLeft,De=$e>2,ee=$e<be-2;je(le=>le.left===De&&le.right===ee?le:{left:De,right:ee})},e[42]=Be):Be=e[42];const _e=Be;let Ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>{_e();const oe=Ne.current;if(!oe||!globalThis.ResizeObserver)return;const be=new ResizeObserver(_e);return be.observe(oe),()=>be.disconnect()},e[43]=Ie):Ie=e[43];let tt;e[44]!==z.length?(tt=[_e,z.length],e[44]=z.length,e[45]=tt):tt=e[45],c.useEffect(Ie,tt);let Ke;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ke=()=>{const oe=Ne.current,be=oe?.querySelector("[data-active-session-tab]");if(!oe||!be)return;const $e=Tx(oe.getBoundingClientRect(),be.getBoundingClientRect());$e!==0&&(oe.scrollLeft=oe.scrollLeft+$e,_e())},e[46]=Ke):Ke=e[46];let ze;e[47]!==b?(ze=[b,_e],e[47]=b,e[48]=ze):ze=e[48],c.useEffect(Ke,ze);const rt=ye.left&&ye.right?`linear-gradient(to right, transparent, black ${Vn}px, black calc(100% - ${Vn}px), transparent)`:ye.left?`linear-gradient(to right, transparent, black ${Vn}px)`:ye.right?`linear-gradient(to right, black calc(100% - ${Vn}px), transparent)`:void 0;let ve;e[49]!==z?(ve=z.map(ob),e[49]=z,e[50]=ve):ve=e[50];const M=ve;let Ce;e[51]!==b||e[52]!==z?(Ce=!!b&&!z.some(oe=>oe.id===b),e[51]=b,e[52]=z,e[53]=Ce):Ce=e[53];const He=Ce;let Xe;e[54]!==u?(Xe=u("header.sessionTabs.stripAria"),e[54]=u,e[55]=Xe):Xe=e[55];let G;e[56]!==rt?(G=rt?{maskImage:rt,WebkitMaskImage:rt}:void 0,e[56]=rt,e[57]=G):G=e[57];let Ee;e[58]===Symbol.for("react.memo_cache_sentinel")?(Ee=[Nx],e[58]=Ee):Ee=e[58];const Pe=f?ix:ax;let Fe;e[59]!==a||e[60]!==b||e[61]!==ue||e[62]!==ie||e[63]!==i||e[64]!==r||e[65]!==x||e[66]!==p||e[67]!==s||e[68]!==d||e[69]!==z?(Fe=z.map((oe,be)=>n.jsx(Ix,{tabNumber:be+1,tab:oe,isActive:oe.id===b,isPreview:oe.id===p,suppressControls:oe.id===b&&d,onSelect:ie,onPin:x,onClose:O,renderMenu:s,closeOtherTabs:ue,onMenuOpenChangeComplete:r,menuReturnsFocus:i,children:oe.id===b?a:null},oe.id)),e[59]=a,e[60]=b,e[61]=ue,e[62]=ie,e[63]=i,e[64]=r,e[65]=x,e[66]=p,e[67]=s,e[68]=d,e[69]=z,e[70]=Fe):Fe=e[70];let Te;e[71]!==Pe||e[72]!==Fe||e[73]!==M?(Te=n.jsx(bd,{items:M,strategy:Pe,children:Fe}),e[71]=Pe,e[72]=Fe,e[73]=M,e[74]=Te):Te=e[74];let Ae;e[75]!==Ve||e[76]!==We||e[77]!==Te?(Ae=n.jsx(gd,{sensors:We,collisionDetection:li,modifiers:Ee,onDragEnd:Ve,children:Te}),e[75]=Ve,e[76]=We,e[77]=Te,e[78]=Ae):Ae=e[78];let qe;e[79]!==J||e[80]!==ne||e[81]!==u?(qe=ne?n.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:[n.jsx(ce,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),n.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:n.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:J||u("sessions.switcher.draftTitle")})})]}):null,e[79]=J,e[80]=ne,e[81]=u,e[82]=qe):qe=e[82];let Ge;e[83]!==a||e[84]!==He?(Ge=He?n.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:n.jsx("div",{className:"min-w-0 flex-1",children:a})}):null,e[83]=a,e[84]=He,e[85]=Ge):Ge=e[85];let Je;e[86]!==G||e[87]!==Ae||e[88]!==qe||e[89]!==Ge?(Je=n.jsxs("div",{ref:Ne,onScroll:_e,onWheel:Px,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:G,children:[Ae,qe,Ge]}),e[86]=G,e[87]=Ae,e[88]=qe,e[89]=Ge,e[90]=Je):Je=e[90];let st;e[91]!==u?(st=u("sessions.sidebar.header.actions.newSession"),e[91]=u,e[92]=st):st=e[92];let mt;e[93]===Symbol.for("react.memo_cache_sentinel")?(mt=n.jsx(ce,{name:"add",className:"size-4"}),e[93]=mt):mt=e[93];let Y;e[94]!==st?(Y=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:re,"aria-label":st,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:mt})}),e[94]=st,e[95]=Y):Y=e[95];let fe;e[96]!==u?(fe=u("sessions.sidebar.header.actions.newSession"),e[96]=u,e[97]=fe):fe=e[97];let Re;e[98]!==F?(Re=ws(Ws("new_chat",F),""),e[98]=F,e[99]=Re):Re=e[99];let T;e[100]!==fe||e[101]!==Re?(T=n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:fe,shortcut:Re})}),e[100]=fe,e[101]=Re,e[102]=T):T=e[102];let ae;e[103]!==Y||e[104]!==T?(ae=n.jsxs(kt,{children:[Y,T]}),e[103]=Y,e[104]=T,e[105]=ae):ae=e[105];let pe;return e[106]!==Xe||e[107]!==Je||e[108]!==ae?(pe=n.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Xe,children:[Je,ae]}),e[106]=Xe,e[107]=Je,e[108]=ae,e[109]=pe):pe=e[109],pe};function Dx(t){return t.shortcutOverrides}function _x(t){return t.stopPropagation()}function Ax(t){return t.tabIds}function Ox(t){return t.previewTabId}function Mx(t){return t.ensureTab}function Fx(t){return t.pinTab}function Lx(t){return t.closeOtherTabs}function Bx(t){return t.reorderTabs}function $x(t){return t.currentSessionId}function zx(t){return t.setCurrentSession}function Wx(t){return t.activeSessions}function Ux(t){return t.sessionTabsPerWorkspace}function Vx(t){return t.enterScope}function Hx(t){return t.hasLoaded}function Kx(t){return t.currentSessionDirectory}function qx(t){return t.newSessionDraft.open}function Gx(t){return t.newSessionDraft.workDraftId??null}function Zx(t){return t.newSessionDraft.target==="chat"}function Xx(t){return t.newSessionDraft.directoryOverride}function Yx(t){return t.newSessionDraft.selectedProjectId??null}function Jx(){return[]}function Qx(t){return t.path}function eb(t){jc(t)}function tb(t){return t.trim()}function sb(t){return t.shortcutOverrides}function nb(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:s}=nt.getState(),r=t?zt.getState().currentDirectory:e.directoryOverride;s(r?{directoryOverride:r}:void 0)}function rb(){const t=nt.getState().currentSessionId;t?jc(t):hm(-1)}function ob(t){return t.id}const ib=(t,e)=>{const s=!!t.time?.archived,r=e.projects.flatMap(d=>{const u=Jt(d.path);return u?[{id:d.id,normalizedPath:u}]:[]}),i=gm(s?[]:[t],r,e.availableWorktreesByProject,e.isVSCode,s?[t]:[],e.authoritativeProjects,e.spaces).bySessionId.get(t.id),a=xm(e.activeSessions,e.resolveLegacyScope).runKeyBySessionId.has(t.id);return{projectId:i?.projectId??null,folderOwnerKey:Mf(t,i,a),ownsWork:!a&&(!i||i.kind==="project")&&Tc(t,e.lookup)===null}},ab=(t,e)=>{const s=new Map(e.map(d=>[d.id,d])),r=new Map;for(const d of e){if(d.parentID||d.time?.archived)continue;const u=Tc(d,f=>s.get(f));if(!u)continue;const l=r.get(u);l?l.push(d):r.set(u,[d])}const o=[],i=new Set,a=[t];for(;a.length>0;){const d=a.pop();!d||i.has(d.id)||(i.add(d.id),Mi(d)&&o.push(d),a.push(...r.get(d.id)??[]))}return o};function Ka({sessionId:t,open:e,slots:s,onRename:r,onExport:o,onMoveSession:i,onArchive:a,onDelete:d}){const{t:u}=lt(),l=c.useMemo(()=>pr(),[]),f=ts(S=>S.entityById.get(t)),m=ts(S=>{const k=S.entityById.get(t);return!k||bm(k,S.entityById)}),p=ts(S=>S.activeSessions),h=nt(S=>S.unarchiveSession),x=nt(S=>S.availableWorktreesByProject),g=nt(S=>S.worktreeMetadata),w=K(S=>S.sessionWorkEnabled),b=Gt(S=>S.projects),j=wm(S=>S.projects),y=Ou(!l),E=Ff(S=>S.load),A=c.useMemo(()=>f?ib(f,{projects:b,availableWorktreesByProject:x,authoritativeProjects:j,spaces:y,isVSCode:l,activeSessions:p,resolveLegacyScope:S=>Jt(g.get(S.id)?.projectDirectory??S.directory??null),lookup:S=>ts.getState().entityById.get(S)}):null,[p,j,x,l,b,f,y,g]);if(!f||!A)return null;const R=!!f.time?.archived,_=Jt(f.directory??null),L=w&&A.ownsWork&&!R&&!f.parentID&&!so(f.directory),v=L?ab(f,p):[],C=async()=>{await h(f.id)?Oe.success(u("sessions.sidebar.session.restore.success")):Oe.error(u("sessions.sidebar.session.restore.error"))};return n.jsx(Lf,{session:f,directory:_,open:e,slots:s,archived:R,pinned:ym(f),work:L?{inWork:v.length>0,toggle:()=>{Bf(f.id,_,v,u)}}:null,projectId:A.projectId,currentWorktree:nt.getState().getWorktreeMetadata(f.id)??null,descendants:[],startWorktreeLoad:E,folders:A.folderOwnerKey?{ownerKey:A.folderOwnerKey,projectId:A.projectId}:null,onRename:r,onExport:()=>o(f,_),onMoveSession:()=>{_&&i(f.id,_)},onArchive:a,onRestore:R&&m?()=>{C()}:null,onDelete:d})}const lb=t=>{const e=Nc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},cb=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,vd=()=>{const t=Ue.c(4),e=nt(db),s=nt(ub)??void 0,r=vm(e??"",s,lb,cb),{context:o}=Sm(e,s),i=o>0?o:km;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 db(t){return t.currentSessionId}function ub(t){return t.currentSessionDirectory}const qa=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),As=18,ui=2,fi=(As-ui)/2,Ga=2*Math.PI*fi,fb=t=>{const e=Ue.c(9),{percent:s,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,s));let d;e[0]!==o?(d=Ze("shrink-0",o),e[0]=o,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("circle",{cx:As/2,cy:As/2,r:fi,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ui}),e[2]=u):u=e[2];let l;e[3]!==i||e[4]!==a?(l=a>0?n.jsx("circle",{cx:As/2,cy:As/2,r:fi,fill:"none",stroke:i,strokeWidth:ui,strokeLinecap:"round",strokeDasharray:Ga,strokeDashoffset:Ga*(1-a/100),transform:`rotate(-90 ${As/2} ${As/2})`}):null,e[3]=i,e[4]=a,e[5]=l):l=e[5];let f;return e[6]!==d||e[7]!==l?(f=n.jsxs("svg",{viewBox:`0 0 ${As} ${As}`,className:d,"aria-hidden":"true",children:[u,l]}),e[6]=d,e[7]=l,e[8]=f):f=e[8],f},Sd=()=>{const t=Ue.c(16),{t:e}=lt(),{sessionId:s,fill:r,limit:o}=vd(),{totalCost:i}=jm(s);if(!s||!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:qa(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let d;t[4]!==o||t[5]!==e?(d=e("contextUsage.tooltip.contextLimit",{tokens:qa(o)}),t[4]=o,t[5]=e,t[6]=d):d=t[6];let u;t[7]!==e||t[8]!==i?(u=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:dd(i)})]:[],t[7]=e,t[8]=i,t[9]=u):u=t[9];let l;t[10]!==a||t[11]!==d||t[12]!==u?(l=[a,d,...u],t[10]=a,t[11]=d,t[12]=u,t[13]=l):l=t[13];const f=l;let m;return t[14]!==f?(m=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(pb)}),t[14]=f,t[15]=m):m=t[15],m};function pb(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const mb="—",hb={safe:"var(--muted-foreground)",warn:"var(--status-warning)",critical:"var(--status-error)"},gb=t=>{const e=Ue.c(35),{buttonClassName:s}=t,{t:r}=lt(),{sessionId:o,fill:i,limit:a}=vd(),d=Hs();let u;e[0]!==d?(u=d?rs(d):"",e[0]=d,e[1]=u):u=e[1];const l=u,f=K(bb);let m;e[2]!==l?(m=N=>l!==""&&Ei(N.contextPanelByDirectory[l],N.contextSurfaceZones).has("context"),e[2]=l,e[3]=m):m=e[3];const p=K(m),h=K(wb);if(!o||!i||h)return null;const x=i.state==="measured"?i.totalTokens/a*100:null,g=x===null?void 0:hb[Cm(Math.round(x))];let w;e[4]!==l||e[5]!==f?(w=l?()=>f(l,"context"):void 0,e[4]=l,e[5]=f,e[6]=w):w=e[6];let b;e[7]!==r?(b=r("contextUsage.aria.label"),e[7]=r,e[8]=b):b=e[8];const j=p&&"text-foreground";let y;e[9]!==s||e[10]!==j?(y=Ze(s,"w-auto gap-1.5 px-1 tabular-nums",j),e[9]=s,e[10]=j,e[11]=y):y=e[11];const E=x??0;let A;e[12]!==g||e[13]!==E?(A=n.jsx(fb,{percent:E,arcColor:g,className:"size-4"}),e[12]=g,e[13]=E,e[14]=A):A=e[14];let R;e[15]!==x?(R=x===null?mb:`${Math.min(x,999).toFixed(1)}%`,e[15]=x,e[16]=R):R=e[16];let _;e[17]!==R?(_=n.jsx("span",{dir:"ltr",className:"typography-meta",children:R}),e[17]=R,e[18]=_):_=e[18];let L;e[19]!==p||e[20]!==_||e[21]!==w||e[22]!==b||e[23]!==y||e[24]!==A?(L=n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:w,"aria-label":b,"aria-pressed":p,className:y,children:[A,_]})}),e[19]=p,e[20]=_,e[21]=w,e[22]=b,e[23]=y,e[24]=A,e[25]=L):L=e[25];let v;e[26]!==p||e[27]!==r?(v=p?null:n.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=p,e[27]=r,e[28]=v):v=e[28];let C;e[29]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Sd,{}),e[29]=C):C=e[29];let S;e[30]!==v?(S=n.jsx(jt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[v,C]})}),e[30]=v,e[31]=S):S=e[31];let k;return e[32]!==L||e[33]!==S?(k=n.jsxs(kt,{children:[L,S]}),e[32]=L,e[33]=S,e[34]=k):k=e[34],k},xb=c.memo(gb);function bb(t){return t.openContextSurface}function wb(t){return t.workStatusPanelVisible&&!t.workStatusHiddenSections.includes("session")}const kd=c.createContext(null),jd=()=>c.useContext(kd),yb=t=>{const e=Ue.c(4),s=jd()?.observe;let r,o;e[0]!==t||e[1]!==s?(r=()=>t&&s?s():void 0,o=[t,s],e[0]=t,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]),c.useEffect(r,o)},Za=t=>{const e=Ue.c(12),{run:s,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,d=o===void 0?!1:o;if(s?.status==="stopping"||s?.status==="waiting-for-preview"){let l;e[0]!==i?(l=Ze("size-4 shrink-0 animate-spin text-[var(--status-warning)]",i),e[0]=i,e[1]=l):l=e[1];let f;return e[2]!==l?(f=n.jsx(ce,{name:"loader-4",className:l}),e[2]=l,e[3]=f):f=e[3],f}if(s){const l=d?"stop-large":"stop";let f;e[4]!==i?(f=Ze("size-4 shrink-0 text-[var(--status-error)]",i),e[4]=i,e[5]=f):f=e[5];let m;return e[6]!==l||e[7]!==f?(m=n.jsx(ce,{name:l,className:f}),e[6]=l,e[7]=f,e[8]=m):m=e[8],m}let u;return e[9]!==i||e[10]!==a?(u=a?n.jsx(ce,{name:"play",className:Ze("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=u):u=e[11],u},vb=t=>{const e=Ue.c(68),{directory:s,buttonClassName:r}=t,{t:o}=lt(),i=rn(kb),a=rn(jb),d=rn(Cb),u=rn(Tb),l=Tm(u),f=rn(Nb),m=rn(Eb),p=rn(Pb);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]),c.useEffect(h,x);const g=Ps()&&no();let w;e[3]!==a||e[4]!==i?(w=a.find(J=>J.id===i)??a.find(Ib)??a[0]??ux[0],e[3]=a,e[4]=i,e[5]=w):w=e[5];const b=w;if(!g||!s||a.length===0)return null;let j;e[6]!==s?(j=async J=>{await Mu(s,J.id,J.appName)||await Xl(s,J.appName)},e[6]=s,e[7]=j):j=e[7];const y=j;let E;e[8]!==y||e[9]!==p?(E=async J=>{await p(J.id),await y(J)},e[8]=y,e[9]=p,e[10]=E):E=e[10];const A=E;let R;e[11]!==s||e[12]!==o?(R=async()=>{(await io(s)).ok&&Oe.success(o("openInApp.toast.pathCopied"))},e[11]=s,e[12]=o,e[13]=R):R=e[13];const _=R;let L;e[14]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"inline-flex"}),e[14]=L):L=e[14];let v;e[15]!==y||e[16]!==b?(v=()=>{y(b)},e[15]=y,e[16]=b,e[17]=v):v=e[17];let C;e[18]!==l||e[19]!==r?(C=Ze(r,l),e[18]=l,e[19]=r,e[20]=C):C=e[20];let S;e[21]!==b.label||e[22]!==o?(S=o("openInApp.actions.openInAria",{app:b.label}),e[21]=b.label,e[22]=o,e[23]=S):S=e[23];let k;e[24]!==b.icon?(k=n.jsx(ce,{name:b.icon,className:"size-4"}),e[24]=b.icon,e[25]=k):k=e[25];let N;e[26]!==S||e[27]!==k||e[28]!==v||e[29]!==C?(N=n.jsx(ao,{render:L,children:n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:v,className:C,"aria-label":S,children:k})})}),e[26]=S,e[27]=k,e[28]=v,e[29]=C,e[30]=N):N=e[30];let $;e[31]!==b.label||e[32]!==o?($=o("openInApp.actions.openInAria",{app:b.label}),e[31]=b.label,e[32]=o,e[33]=$):$=e[33];let B;e[34]!==$?(B=n.jsx(jt,{side:"bottom",children:$}),e[34]=$,e[35]=B):B=e[35];let D;e[36]!==N||e[37]!==B?(D=n.jsxs(kt,{children:[N,B]}),e[36]=N,e[37]=B,e[38]=D):D=e[38];let W;e[39]!==_?(W=()=>{_()},e[39]=_,e[40]=W):W=e[40];let H;e[41]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(ce,{name:"file-copy",className:"h-4 w-4"}),e[41]=H):H=e[41];let U;e[42]!==o?(U=o("openInApp.actions.copyPath"),e[42]=o,e[43]=U):U=e[43];let se;e[44]!==U?(se=n.jsx("span",{className:"typography-ui-label text-foreground",children:U}),e[44]=U,e[45]=se):se=e[45];let z;e[46]!==W||e[47]!==se?(z=n.jsxs(vs,{className:"flex items-center gap-2",onClick:W,children:[H,se]}),e[46]=W,e[47]=se,e[48]=z):z=e[48];let Q;e[49]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx(Cn,{}),e[49]=Q):Q=e[49];let ie;if(e[50]!==a||e[51]!==A||e[52]!==b.id){let J;e[54]!==A||e[55]!==b.id?(J=F=>n.jsxs(vs,{className:"flex items-center gap-2",onClick:()=>{A(F)},children:[n.jsx(ce,{name:F.icon,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:F.label}),b.id===F.id?n.jsx(ce,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},F.id),e[54]=A,e[55]=b.id,e[56]=J):J=e[56],ie=a.map(J),e[50]=a,e[51]=A,e[52]=b.id,e[53]=ie}else ie=e[53];let O;e[57]!==d||e[58]!==m||e[59]!==o?(O=d?n.jsxs(vs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[n.jsx(ce,{name:"refresh",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=d,e[58]=m,e[59]=o,e[60]=O):O=e[60];let ne;e[61]!==z||e[62]!==ie||e[63]!==O?(ne=n.jsxs(br,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[z,Q,ie,O]}),e[61]=z,e[62]=ie,e[63]=O,e[64]=ne):ne=e[64];let V;return e[65]!==D||e[66]!==ne?(V=n.jsxs(xr,{children:[D,ne]}),e[65]=D,e[66]=ne,e[67]=V):V=e[67],V},Sb=c.memo(vb);function kb(t){return t.selectedAppId}function jb(t){return t.availableApps}function Cb(t){return t.isCacheStale}function Tb(t){return t.isScanning}function Nb(t){return t.initialize}function Eb(t){return t.loadInstalledApps}function Pb(t){return t.selectApp}function Ib(t){return t.id===fx}const Hn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Rb=({projects:t,worktreesByProject:e,directory:s,activeProjectId:r})=>{const o=Hn(s??"");if(o){const i=gr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function Cd(){const t=Gt(w=>w.projects),e=Gt(w=>w.activeProjectId),s=nt(w=>w.availableWorktreesByProject),r=nt(w=>w.currentSessionId),o=Nm(r??null),i=nt(w=>r?w.worktreeMetadata.get(r)?.path??"":""),a=nt(w=>w.newSessionDraft?.open?Hn(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),d=nt(w=>w.newSessionDraft?.open?w.newSessionDraft.target==="chat":null),u=c.useMemo(()=>Hn(i||""),[i]),l=c.useMemo(()=>Hn(o||""),[o]),f=u||l||a,m=c.useMemo(()=>Rb({projects:t,worktreesByProject:s,directory:f,activeProjectId:e}),[e,f,t,s]),p=c.useMemo(()=>Hn(f||m?.path||""),[f,m?.path]),h=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),x=d??so(l),g=c.useRef(null);return c.useEffect(()=>{h&&p&&!x&&(g.current={projectRef:h,directory:p})},[p,h,x]),c.useMemo(()=>x?null:h&&p?{projectRef:h,directory:p}:g.current,[h,p,x])}const Db=t=>{const e=Ue.c(67),{buttonClassName:s}=t,{t:r}=lt(),o=jd(),i=K(Mb),[a,d]=c.useState(!1),u=K(Fb);let l;e[0]!==u?(l=ws(Ws("open_project_actions",u),""),e[0]=u,e[1]=l):l=e[1];const f=l,m=o?.available?o.shown:null;let p;e[2]!==o||e[3]!==m?(p=m&&o?o.runOf(m):null,e[2]=o,e[3]=m,e[4]=p):p=e[4];const h=p;yb(!0);let x;e[5]!==h?(x=ne=>h?ne.getDirectoryState(h.directory)?.tabs.find(V=>V.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=x):x=e[6];const g=yt(x);if(!o||!m)return null;let w;e[7]!==m.name||e[8]!==h||e[9]!==r?(w=h?r("projectActions.actions.stopNamedAria",{name:m.name}):r("projectActions.actions.runNamedAria",{name:m.name}),e[7]=m.name,e[8]=h,e[9]=r,e[10]=w):w=e[10];const b=w;let j;e[11]!==s||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(j=h&&g?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:s,"aria-label":r("projectActions.actions.openPreview"),children:n.jsx(ce,{name:"global",className:"size-4"})})}),n.jsx(jt,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=s,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=j):j=e[16];let y;e[17]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"inline-flex"}),e[17]=y):y=e[17];let E;e[18]!==o||e[19]!==m?(E=()=>o.toggle(m),e[18]=o,e[19]=m,e[20]=E):E=e[20];const A=o.isLoading||h?.status==="stopping",R=a&&"text-foreground";let _;e[21]!==s||e[22]!==R?(_=Ze(s,R),e[21]=s,e[22]=R,e[23]=_):_=e[23];let L;e[24]!==m||e[25]!==h?(L=h?n.jsx(Za,{run:h,large:!0}):n.jsx(ce,{name:ya(m),className:"size-4"}),e[24]=m,e[25]=h,e[26]=L):L=e[26];let v;e[27]!==b||e[28]!==_||e[29]!==L||e[30]!==E||e[31]!==A?(v=n.jsx(ao,{render:y,children:n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:E,disabled:A,className:_,"aria-label":b,children:L})})}),e[27]=b,e[28]=_,e[29]=L,e[30]=E,e[31]=A,e[32]=v):v=e[32];let C;e[33]!==b?(C=n.jsx("span",{children:b}),e[33]=b,e[34]=C):C=e[34];let S;e[35]!==r?(S=r("projectActions.header.allActions"),e[35]=r,e[36]=S):S=e[36];let k;e[37]!==f||e[38]!==S?(k=n.jsx("span",{className:"typography-micro text-muted-foreground",children:n.jsx(Us,{label:S,shortcut:f})}),e[37]=f,e[38]=S,e[39]=k):k=e[39];let N;e[40]!==C||e[41]!==k?(N=n.jsx(jt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[C,k]})}),e[40]=C,e[41]=k,e[42]=N):N=e[42];let $;e[43]!==v||e[44]!==N?($=n.jsxs(kt,{children:[v,N]}),e[43]=v,e[44]=N,e[45]=$):$=e[45];const B=o.openSettings;let D;e[46]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(ce,{name:"add",className:"h-4 w-4"}),e[46]=D):D=e[46];let W;e[47]!==r?(W=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=W):W=e[48];let H;e[49]!==W?(H=n.jsx("span",{className:"typography-ui-label text-foreground",children:W}),e[49]=W,e[50]=H):H=e[50];let U;e[51]!==o.openSettings||e[52]!==H?(U=n.jsxs(vs,{className:"flex items-center gap-2",onClick:B,children:[D,H]}),e[51]=o.openSettings,e[52]=H,e[53]=U):U=e[53];let se;e[54]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(Cn,{}),e[54]=se):se=e[54];let z;e[55]!==o||e[56]!==r?(z=o.actions.map(ne=>n.jsxs(vs,{className:"flex items-center gap-2",onClick:()=>{o.select(ne),o.toggle(ne)},children:[n.jsx(ce,{name:ya(ne),className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ne.name}),ne.source==="shared"?n.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,n.jsx(Za,{run:o.runOf(ne),className:"ms-auto"})]},ne.id)),e[55]=o,e[56]=r,e[57]=z):z=e[57];let Q;e[58]!==U||e[59]!==z?(Q=n.jsxs(br,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[U,se,z]}),e[58]=U,e[59]=z,e[60]=Q):Q=e[60];let ie;e[61]!==$||e[62]!==Q?(ie=n.jsxs(xr,{onOpenChange:d,children:[$,Q]}),e[61]=$,e[62]=Q,e[63]=ie):ie=e[63];let O;return e[64]!==ie||e[65]!==j?(O=n.jsxs(n.Fragment,{children:[j,ie]}),e[64]=ie,e[65]=j,e[66]=O):O=e[66],O},_b=c.memo(Db),Ab=t=>{const e=Ue.c(8),{buttonClassName:s}=t,r=Cd();if(!r)return null;let o;e[0]!==s||e[1]!==r.directory?(o=n.jsx(Sb,{directory:r.directory,buttonClassName:s}),e[0]=s,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==s?(i=n.jsx(_b,{buttonClassName:s}),e[3]=s,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=n.jsxs(n.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},Ob=c.memo(Ab);function Mb(t){return t.openContextPreview}function Fb(t){return t.shortcutOverrides}const Bo="--oc-titlebar-controls-width",pi=new Set;let Gn=null;const Td=t=>{Gn===null?t.style.removeProperty(Bo):t.style.getPropertyValue(Bo)!==Gn&&t.style.setProperty(Bo,Gn)},Lb=t=>{const e=`${Math.round(t)}px`;e!==Gn&&(Gn=e,pi.forEach(Td))},Nd=t=>{if(t)return pi.add(t),Td(t),()=>{pi.delete(t)}},Bn="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",$n=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Bb=()=>{Fu("ui.header.render");const{t,direction:e}=lt(),s=K(X=>X.isSidebarOpen),r=lo(),o=K(X=>X.sessionTabsEnabled),i=nt(X=>!!X.newSessionDraft?.open),a=nt(X=>X.currentSessionId),d=ts(ci(c.useCallback(X=>{if(!a)return null;const ot=[...X.activeSessions,...X.archivedSessions].find(_t=>_t.id===a);if(!ot)return null;const xt=ot;return{title:ot.title??null,directory:xt.directory??null,created:ot.time?.created??null,slug:xt.slug??null}},[a]))),u=Gt(ci(X=>{if(!X.activeProjectId)return null;const ot=X.projects.find(xt=>xt.id===X.activeProjectId);return ot?{id:ot.id,path:ot.path,label:ot.label}:null})),l=c.useMemo(()=>{if(!u)return null;const X=u.label?.trim();if(X)return X;const ot=u.path.split(/[\\/]/).filter(Boolean);return ot[ot.length-1]??null},[u]),{isMobile:f}=hn(),m=c.useRef(null),[p,h]=c.useState(()=>typeof window>"u"?!1:Ps()),x=c.useMemo(()=>Br(),[]),g=Em(),[w,b]=c.useState(!1),j=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:y,side:E}=ud(),A=c.useMemo(()=>{if(typeof window>"u")return null;const X=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X;if(typeof navigator>"u")return null;const ot=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ot)return null;const xt=Number.parseInt(ot[1],10),_t=Number.parseInt(ot[2],10);return Number.isNaN(xt)?null:xt===10?_t:xt},[]);$t.useEffect(()=>{typeof window>"u"||h(Ps())},[]);const R=c.useMemo(()=>pr(),[]),_=K(X=>X.shortcutOverrides),L=K(X=>X.workStatusPanelVisible),v=K(X=>X.workStatusPanelEnabled),C=K(X=>X.setWorkStatusPanelEnabled),S=K(X=>X.workStatusPanelFits),k=K(X=>X.workStatusOverlayOpen),N=K(X=>X.setWorkStatusOverlayOpen),B=v&&S||k,D=c.useCallback(()=>{if(v&&!S){N(!k);return}C(!v)},[N,C,k,v,S]),W=a?d??null:null,H=c.useRef(null),[U,se]=c.useState(0);c.useEffect(()=>{if(!a){H.current&&(H.current=null,se(_t=>_t+1));return}if(W){H.current={sessionId:a,session:W,expiresAt:Date.now()+2e3};return}const X=H.current;if(!X||X.sessionId!==a)return;const ot=X.expiresAt-Date.now();if(ot<=0){H.current=null,se(_t=>_t+1);return}const xt=window.setTimeout(()=>{H.current?.sessionId===a&&(H.current=null),se(_t=>_t+1)},ot);return()=>{window.clearTimeout(xt)}},[a,W]);const z=(()=>{if(W)return W;if(!a)return null;const X=H.current;return X&&X.sessionId===a&&X.expiresAt>Date.now()?X.session:null})(),Q=nt(X=>a?X.worktreeMetadata.get(a)?.path??"":""),ie=nt(X=>a?X.worktreeMetadata.get(a)?.branch?.trim()??null:null),O=Ec(X=>a?X.getAttachment(a):void 0),ne=c.useMemo(()=>O?Pm(O,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,O]),V=c.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]),J=c.useMemo(()=>$n(Q||""),[Q]),F=c.useMemo(()=>{const X=typeof z?.directory=="string"?z.directory:"";return $n(X||"")},[z?.directory]),re=cc(a??"",F),q=nt(X=>X.newSessionDraft?.open?$n(X.newSessionDraft.bootstrapPendingDirectory??X.newSessionDraft.directoryOverride??""):""),ge=nt(X=>X.newSessionDraft.target),Z=nt(X=>X.newSessionDraft.selectedProjectId),de=nt(X=>X.currentSessionDirectory),Se=zt(X=>X.homeDirectory),ue=wr(),ke=c.useMemo(()=>J||F||(co(ue,q)??""),[q,ue,F,J]),Me=nt(X=>{const ot=$n(J||F||"");if(!ot)return null;for(const xt of X.availableWorktreesByProject.values()){const te=Wr(xt,ot)?.branch?.trim();if(te)return te}return null}),Le=Im(ke||null)||ie||Me,Ve=i?ge==="chat":Zl(F||de,Se),Ne=!Ve&&!L&&!!(l||Le||!i&&V),me=c.useMemo(()=>{if(!a)return l??"OpenChamber";const X=z?.title?.trim();return X&&X.length>0?X:"Untitled Session"},[l,z?.title,a]),ye=nt(X=>X.updateSessionTitle),je=nt(X=>X.archiveSessions),Be=nt(X=>X.deleteSessions),[_e,Ie]=c.useState(!1),[tt,Ke]=c.useState(!1),ze=c.useRef(null),[rt,ve]=c.useState(""),[M,Ce]=c.useState(null),He=$f(),[Xe,G]=c.useState(null),Ee=ts(X=>Xe&&X.entityById.get(Xe)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Pe=c.useRef(null),Fe=c.useRef(!1);Fe.current=_e;const Te=c.useCallback(()=>{a&&(Fe.current=!0,ve(z?.title?.trim()||me),Ie(!0))},[z?.title,a,me]),Ae=c.useRef(Te);Ae.current=Te;const qe=c.useCallback(X=>{X&&(X.focus(),X.select())},[]);c.useEffect(()=>{if(Ke(!1),G(null),a&&ze.current===a){ze.current=null,Ae.current();return}Ie(!1),ve("")},[a]);const Ge=c.useCallback(async()=>{if(!a)return;const X=rt.trim();X&&X!==z?.title?.trim()&&await ye(a,X),Ie(!1)},[z?.title,a,rt,ye]);c.useEffect(()=>{if(!_e)return;const X=ot=>{const xt=ot.target;(!xt||!Pe.current?.contains(xt))&&Ge()};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[_e,Ge]);const Je=c.useCallback(async(X,ot)=>{const xt=[ot,...Rm(ot,[],X==="delete")],_t=nt.getState().currentSessionId===ot?ot:null;if(X==="delete"){const{failedIds:gt}=await Be(xt);gt.length>0?Oe.error(t("sessions.sidebar.session.delete.error")):Oe.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:te,failedIds:Qe}=await je(xt);if(Qe.length>0){Oe.error(t("sessions.sidebar.session.archive.error"));return}Oe.success(t("sessions.sidebar.session.archive.success"),Dm(te,_t,t))},[je,Be,t]),st=c.useCallback(async()=>{Xe&&(G(null),await Je("delete",Xe))},[Xe,Je]),mt=K(X=>X.openGuestPageId),Y=tr(X=>X.guests.find(ot=>ot.id===mt)),fe=K(X=>X.isScheduledTasksDialogOpen),Re=K(X=>X.isArchivePageOpen),T=K(X=>X.isIntegrationsCatalogOpen),ae=K(X=>X.isUsageStatsPageOpen),pe=K(X=>X.isSourceBoardOpen),oe=K(X=>X.isOverviewOpen),be=K(X=>X.worktreesPageProjectId),$e=K(X=>X.isolatedSpacesEnabled?X.spacesPageProjectId:null),De=K(X=>X.runOverviewKey),ee=zf(De),le=be??$e,et=Gt(X=>{if(!le)return null;const ot=X.projects.find(xt=>xt.id===le);return ot?.label?.trim()||ot?.path?.split("/").pop()||null}),xe=c.useMemo(()=>Y?{title:Y.pageTitle??Y.name,subtitle:null}:fe?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Re?{title:t("sessions.archivePage.title"),subtitle:null}:T?{title:t("integrationsCatalog.page.title"),subtitle:null}:ae?{title:t("usageStats.title"),subtitle:null}:pe?{title:t("sourceBoard.title"),subtitle:null}:oe?{title:t("overview.title"),subtitle:null}:be?{title:t("sessions.worktreesPage.title",{project:et??""}),subtitle:null}:$e?{title:t("spaces.page.title",{project:et??""}),subtitle:null}:De?{title:ee??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Y,Re,T,ee,De,fe,pe,oe,ae,$e,et,t,be]),bt=c.useCallback(()=>{Ys("desktop_open_draft_mini_chat_window",{directory:Ve?"":q,projectId:Ve?null:Z,...Qo()}).catch(X=>{console.warn("[header] failed to open draft mini chat window",X)})},[q,Z,Ve]),Tt=c.useCallback(()=>{if(i){bt();return}a&&Ys("desktop_open_session_mini_chat_window",{sessionId:a,directory:F||$n(de||"")||J,...Qo()}).catch(X=>{console.warn("[header] failed to open session mini chat window",X)})},[a,bt,i,de,F,J]),vt=x&&(i||!!a),Rt=Bn,Ye=c.useMemo(()=>p&&j&&!w?"88px":g?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||y)&&!R?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,w,j,g,R,y]),ft=(!p||y)&&!R?"calc(0.625rem + var(--oc-wco-right-inset, 0px))":"0.625rem",Nt=e==="rtl",ht=Nt?ft:Ye,Ct=Nt?Ye:ft,pt=y&&E!==Yl(e);$t.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",ht)},[ht]);const It=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",Ht=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";$t.useEffect(()=>{if(!p||!j){b(!1);return}let X=!1;const ot=async()=>{try{const _t=await Ys("desktop_is_window_fullscreen");X||b(_t===!0)}catch{X||b(!1)}},xt=()=>{ot()};return ot(),window.addEventListener("openchamber:window-resized",xt),()=>{X=!0,window.removeEventListener("openchamber:window-resized",xt)}},[p,j]);const dt=c.useMemo(()=>!p||!j||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[p,j,A]),ct=c.useMemo(()=>p&&j&&!w?A!==null&&A<=15?"56px":"44px":"0px",[p,w,j,A]),Mt=c.useMemo(()=>{const ot=`max(${p&&j?"2.75rem":"3rem"}, ${ct}, var(--oc-wco-titlebar-height, 0px))`,xt=p&&!y||R;if(xt&&ct==="0px")return{};const _t={minHeight:ot,height:ot};return!pt&&(!xt||Nt)&&(_t.paddingInlineEnd=Ct),_t},[pt,p,j,Nt,R,Ct,ct,y]),Wt=c.useRef(null),Zt=c.useCallback(X=>{!X||X===Wt.current||(Wt.current=X,document.documentElement.style.setProperty("--oc-header-height",`${X}px`))},[]),Kt=c.useCallback(()=>{typeof document>"u"||Zt(m.current?.getBoundingClientRect().height)},[Zt]);$t.useEffect(()=>{if(typeof window>"u")return;Kt();const X=m.current;if(!X||typeof ResizeObserver>"u")return()=>{};let ot=0;const xt=()=>{ot||(ot=requestAnimationFrame(()=>{ot=0,Kt()}))},_t=new ResizeObserver(te=>{const Qe=te[te.length-1];Zt(Qe?.borderBoxSize?.[0]?.blockSize??Qe?.target.getBoundingClientRect().height)});return _t.observe(X),window.addEventListener("resize",xt),window.addEventListener("orientationchange",xt),()=>{ot&&cancelAnimationFrame(ot),_t.disconnect(),window.removeEventListener("resize",xt),window.removeEventListener("orientationchange",xt)}},[Zt,Kt]),$t.useEffect(()=>{Kt()},[Kt,f,dt]);const ls=c.useCallback(async X=>{const ot=X.target;ot.closest(".app-region-no-drag")||ot.closest("button, a, input, select, textarea")||X.button===0&&p&&await Lu()},[p]);Pc({rename_current_session:()=>{if(!a||f)return!1;Te()},archive_current_session:()=>{if(!a||f||ts.getState().entityById.get(a)?.time.archived)return!1;Je("archive",a)}});const Ut=c.useCallback((X,ot)=>{Ce({sessionId:X,directory:ot})},[]),Qt=He.requestExport,cs=c.useCallback(({session:X,open:ot,isActive:xt,select:_t,closeOtherTabs:te,components:Qe})=>{const{Item:gt,Separator:wt}=Qe;return n.jsxs(n.Fragment,{children:[n.jsx(Wf,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(gt,{onClick:te,className:"[&>svg]:me-1",children:[n.jsx(ce,{name:"close-circle",className:"me-1 h-4 w-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(wt,{}),n.jsx(Ka,{sessionId:X.id,open:ot,slots:Qe,onRename:()=>{xt||_t(),ze.current=X.id},onExport:Qt,onMoveSession:Ut,onArchive:()=>{Je("archive",X.id)},onDelete:()=>G(X.id)})]})},[Qt,Ut,Je,t]),js=()=>n.jsxs("div",{onMouseDown:ls,className:Ze("app-region-drag relative flex h-12 select-none items-center",pt?"pe-0":"pe-2.5",dt),style:Mt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:It,transitionDuration:`${r}ms`,transitionTimingFunction:In}}),n.jsx("div",{ref:Nd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Ht,transitionDuration:`${r}ms`,transitionTimingFunction:In}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[xe?n.jsxs(n.Fragment,{children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{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:()=>K.getState().closeMainSurfaces(),children:n.jsx(ce,{name:"arrow-left",className:"size-4"})})}),n.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:xe.title}),xe.subtitle?n.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:xe.subtitle}):null]})]}):R||!o?n.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:[re?n.jsx(ce,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsxs(kt,{children:[n.jsx(sx,{align:"start",children:n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:Rt,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(ce,{name:"history",className:"h-4 w-4"})})})}),n.jsx(jt,{side:"bottom",children:n.jsx(Us,{label:t("sessions.switcher.openAria"),shortcut:ws(Ws("open_session_list",_),"")})})]}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[_e?n.jsxs("form",{ref:Pe,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Ge()},children:[n.jsx("input",{ref:qe,value:rt,onChange:X=>ve(X.target.value),onKeyDown:X=>va(X,()=>Ie(!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"}),n.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:n.jsx(ce,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Ie(!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:n.jsx(ce,{name:"close",className:"size-4"})})]}):i?null:n.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:me}),Ne?n.jsxs("span",{className:Ze("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:[l?n.jsx("span",{dir:"auto",className:"truncate",children:l}):null,Le?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(ce,{name:"git-branch",className:Ze("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{dir:"ltr",className:Ze("truncate",i&&"text-muted-foreground"),children:Le})]}):null,!i&&V?n.jsxs("span",{className:Ze("inline-flex min-w-0 items-center gap-0.5",V==="attention"||V==="invalid"||V==="missing"?"text-status-warning":"text-muted-foreground"),children:[n.jsx(ce,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:ne})]}):null]}):null]}),n.jsx("div",{className:Ze("flex h-[1.125rem] shrink-0 items-center justify-center",Ne?"self-start":"self-center"),children:a&&!i&&!_e?n.jsxs(fn,{open:tt,onOpenChange:Ke,onOpenChangeComplete:X=>{!X&&ze.current&&ze.current===a&&(ze.current=null,Te())},children:[n.jsx(pn,{asChild:!0,children:n.jsx(ut,{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:n.jsx(ce,{name:"more",className:"size-4"})})}),n.jsx(mn,{align:"end",className:"min-w-[190px]",children:n.jsx(Ka,{sessionId:a,open:tt,slots:Uf,onRename:()=>{ze.current=a},onExport:Qt,onMoveSession:Ut,onArchive:()=>{Je("archive",a)},onDelete:()=>G(a)})})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(Rx,{renderMenu:cs,suppressActiveTabControls:_e,menuReturnsFocus:()=>!Fe.current,onMenuOpenChangeComplete:X=>{!X&&ze.current&&ze.current===a&&(ze.current=null,Te())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:_e?n.jsxs("form",{ref:Pe,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Ge()},children:[n.jsx("input",{ref:qe,value:rt,onChange:X=>ve(X.target.value),onKeyDown:X=>va(X,()=>Ie(!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"}),n.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:n.jsx(ce,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Ie(!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:n.jsx(ce,{name:"close",className:"size-4"})})]}):n.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"):me})})})}),xe||R||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!R&&!xe?n.jsxs(n.Fragment,{children:[n.jsx(xb,{buttonClassName:Bn}),n.jsx(Ob,{buttonClassName:Bn})]}):null,vt?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Tt,className:Bn,children:n.jsx(ce,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(jt,{side:"bottom",children:n.jsx(Us,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?ws(Ws("new_mini_chat",_),""):void 0})})]}):null,R?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":B,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:D,className:Ze(Bn,B&&"oc-selected text-interactive-selection-foreground hover:text-interactive-selection-foreground"),children:n.jsx(ce,{name:"panel-card",className:"h-4 w-4"})})}),n.jsx(jt,{side:"bottom",children:t(v&&!S?k?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":v?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),n.jsx(fd,{visible:pt,position:E})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:js()}),M?n.jsx(_m,{open:!0,onOpenChange:X=>{X||Ce(null)},sessionId:M.sessionId,sourceDirectory:M.directory}):null,He.dialog,n.jsx(sr,{open:Xe!==null,onOpenChange:X=>{X||G(null)},children:n.jsxs(nr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(rr,{children:[n.jsx(or,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),n.jsx(ir,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Ee})})]}),n.jsxs(Ur,{children:[n.jsx(ut,{variant:"outline",size:"sm",onClick:()=>G(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{st()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},Xa=280,Ya=264,Ja=500,$b=({isOpen:t,isMobile:e,children:s,className:r,topBar:o,peek:i})=>{const{t:a,direction:d}=lt(),u=K(z=>z.sidebarWidth),l=K(z=>z.setSidebarWidth),[f,m]=c.useState(!1),p=c.useRef(0),h=c.useRef(u||Xa),x=c.useRef(null),g=c.useRef(null),w=c.useRef(null),b=c.useRef(null),j=c.useRef(null),y=c.useCallback(z=>Math.min(Ja,Math.max(Ya,z)),[]),E=c.useCallback(()=>{const z=j.current;if(z?.isConnected)return z;const Q=document.querySelector("[data-titlebar-left-controls]");return j.current=Q,Q},[]),A=c.useCallback(z=>{const Q=b.current;if(!Q)return;Q.style.width=`${z}px`,Q.style.minWidth=`${z}px`,Q.style.maxWidth=`${z}px`,Q.style.setProperty("--oc-left-sidebar-width",`${z}px`);const ie=E();ie&&ie.style.setProperty("--oc-left-sidebar-width",`${z}px`)},[E]);c.useEffect(()=>{e&&f&&m(!1)},[e,f]),c.useEffect(()=>{f||(x.current=null,g.current=null,w.current?.(),w.current=null)},[f]),c.useEffect(()=>{!t&&f&&m(!1)},[t,f]),c.useEffect(()=>()=>{w.current?.(),w.current=null},[]);const R=Math.min(Ja,Math.max(Ya,u||Xa)),_=t?R:0,L=f?x.current??_:_,v=f?L:R;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${v}px`);const z=j.current;!f&&z&&z.style.removeProperty("--oc-left-sidebar-width")},[v,f]);const[C,S]=c.useState(!t);t&&C&&S(!1);const k=lo(),N=c.useRef(t),$=c.useRef(t);if(c.useLayoutEffect(()=>{N.current=t,$.current!==t&&($.current=t,Ic(k),t||Fi(()=>{N.current||S(!0)}))},[t,k]),e)return null;const B=z=>{if(t){try{z.currentTarget.setPointerCapture(z.pointerId)}catch{}g.current=z.pointerId,m(!0),p.current=z.clientX,h.current=_,x.current=_,A(_),w.current?.(),w.current=Rc(),z.preventDefault()}},D=z=>{if(e||!f||g.current!==z.pointerId)return;const Q=(z.clientX-p.current)*(d==="rtl"?-1:1),ie=y(h.current+Q);x.current!==ie&&(x.current=ie,A(ie))},W=z=>{if(g.current!==z.pointerId||e)return;try{z.currentTarget.releasePointerCapture(z.pointerId)}catch{}const Q=y(x.current??_);g.current=null,x.current=null,m(!1),l(Q),w.current?.(),w.current=null},H=!t&&i?i.state:!1,U=H!==!1,se=U&&i&&i.animationMs>0?`${H==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${In} forwards`:void 0;return n.jsxs("div",{ref:b,"data-left-sidebar":"",className:Ze("relative flex h-full",!U&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${L}px`,minWidth:`${L}px`,maxWidth:`${L}px`,"--oc-left-sidebar-width":`${v}px`,overflowX:U?void 0:"clip",transitionDuration:`${k}ms`,transitionTimingFunction:In},children:[t&&n.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&&n.jsx("div",{className:Ze("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:B,onPointerMove:D,onPointerUp:W,onPointerCancel:W,onLostPointerCapture:W,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":U?H:void 0,className:Ze("flex h-full shrink-0 flex-col",U?"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&&!U&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${k}ms`,overflowX:"hidden",contentVisibility:C&&!U?"hidden":void 0,animation:se,"--oc-peek-offset":d==="rtl"?"100%":"-100%"},inert:!t&&!U||void 0,onPointerEnter:U?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:U?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:U?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,n.jsx(as,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(Xt,{children:s})})]})]})},zb=t=>{const e=Ue.c(5),{actionsSlotRef:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={height:"var(--oc-header-height, 3rem)"},e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{"aria-hidden":!0,className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{"aria-hidden":!0,ref:Nd,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),e[2]=i):i=e[2];let a;return e[3]!==s?(a=n.jsxs("div",{className:"flex shrink-0",style:r,children:[o,i,n.jsx("div",{className:"app-region-drag flex min-w-0 flex-1 items-center justify-end",children:n.jsx("div",{ref:s,className:"app-region-no-drag flex items-center"})})]}),e[3]=s,e[4]=a):a=e[4],a},Wb=50,Ub=18,Vb=300,Hb='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',Ed=t=>!document.getElementById("root")?.contains(t),Kb=t=>{if((to(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Ub)return!1;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},Qa=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(Hb)).some(s=>Ed(s)&&s.getClientRects().length>0)},qb=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=c.useState(!1),o=Am()?0:e,i=o>0,a=c.useRef(null),d=c.useRef(null),u=c.useRef(null),l=c.useCallback(()=>{d.current!==null&&clearTimeout(d.current),u.current!==null&&clearTimeout(u.current),d.current=null,u.current=null},[]),f=c.useCallback(()=>{l(),r(x=>x==="in"&&i?"out":!1)},[i,l]),m=c.useCallback(()=>{u.current!==null&&clearTimeout(u.current),u.current=setTimeout(()=>{if(u.current=null,Qa(a.current)){m();return}f()},Vb)},[f]),p=c.useCallback(()=>{u.current!==null&&clearTimeout(u.current),u.current=null},[]);c.useEffect(()=>{t||(l(),r(!1))},[l,t]),c.useEffect(()=>l,[l]),c.useEffect(()=>{if(s!=="in")return;const x=b=>{const j=b.target;j instanceof Element&&(a.current?.contains(j)||Ed(j)||f())},g=b=>{Dc(b)||b.key!=="Escape"||b.defaultPrevented||Qa(a.current)||f()},w=b=>{b.relatedTarget===null&&m()};return document.addEventListener("pointerdown",x,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",w),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",w)}},[f,m,s]),c.useEffect(()=>{if(!t||s!==!1)return;const x=()=>{d.current!==null&&clearTimeout(d.current),d.current=null},g=b=>{if(b.pointerType!=="mouse"||b.buttons!==0||!Kb(b)){x();return}d.current===null&&(d.current=setTimeout(()=>{d.current=null,r("in")},Wb))},w=b=>{b.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",w),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",w),x()}},[t,s]);const h=c.useMemo(()=>({onPointerEnter:()=>{p(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{s==="in"&&m()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?!1:g)}}),[p,m,s]);return{state:t?s:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},$o="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",Gb=()=>{const t=Ue.c(46),{t:e,locale:s,direction:r}=lt(),o=K(Zb),i=K(Xb),a=K(Yb),d=c.useRef(null),u=ws(Ws("toggle_sidebar",a)),l=Jb,f=K(Qb),{usesFramelessChrome:m,side:p}=ud();let h;t[0]!==s?(h=Q=>{const ie=Q.currentTarget.getBoundingClientRect();Ys("desktop_show_app_menu",{x:ie.left,y:ie.bottom,locale:s}).catch(ew)},t[0]=s,t[1]=h):h=t[1];const x=h;let g,w;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const Q=d.current;if(!Q)return;const ie=()=>{const ne=Math.max(Q.getBoundingClientRect().width,Q.scrollWidth);Lb(ne)};if(ie(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(ie);return O.observe(Q),()=>{O.disconnect()}},w=[],t[2]=g,t[3]=w):(g=t[2],w=t[3]),c.useEffect(g,w);const b="",j="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 E;t[4]!==y?(E={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:y},t[4]=y,t[5]=E):E=t[5];const A="flex min-w-0 items-center gap-2";let R;t[6]!==r||t[7]!==m||t[8]!==p?(R=m&&p===Yl(r)?n.jsx(fd,{visible:!0,position:p}):null,t[6]=r,t[7]=m,t[8]=p,t[9]=R):R=t[9];let _;t[10]!==x||t[11]!==e||t[12]!==m?(_=m?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:Ze($o,"shrink-0"),children:n.jsx(ce,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(jt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=m,t[13]=_):_=t[13];const L=kt;let v;t[14]!==e?(v=e("header.actions.openSessionsAria"),t[14]=e,t[15]=v):v=t[15];const C=i&&"text-foreground";let S;t[16]!==C?(S=Ze($o,"shrink-0",C),t[16]=C,t[17]=S):S=t[17];let k;t[18]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ce,{name:"panel-left",className:"h-4 w-4"}),t[18]=k):k=t[18];let N;t[19]!==i||t[20]!==v||t[21]!==S||t[22]!==o?(N=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":v,"aria-pressed":i,className:S,children:k})}),t[19]=i,t[20]=v,t[21]=S,t[22]=o,t[23]=N):N=t[23];const $=jt,B=e("header.actions.openSessionsWithShortcut",{shortcut:u});let D;t[24]!==B?(D=n.jsx("p",{children:B}),t[24]=B,t[25]=D):D=t[25];let W;t[26]!==$||t[27]!==D?(W=n.jsx($,{children:D}),t[26]=$,t[27]=D,t[28]=W):W=t[28];let H;t[29]!==L||t[30]!==N||t[31]!==W?(H=n.jsxs(L,{children:[N,W]}),t[29]=L,t[30]=N,t[31]=W,t[32]=H):H=t[32];let U;t[33]!==l||t[34]!==a||t[35]!==e||t[36]!==f?(U=f?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:l,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ze($o,"-ms-1 shrink-0"),children:n.jsx(ce,{name:"edit-box",className:"h-4 w-4"})})}),n.jsx(jt,{children:n.jsx(Us,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:ws(Ws("new_chat",a),"")})})]}),t[33]=l,t[34]=a,t[35]=e,t[36]=f,t[37]=U):U=t[37];let se;t[38]!==H||t[39]!==U||t[40]!==R||t[41]!==_?(se=n.jsxs("div",{ref:d,className:A,children:[R,_,H,U]}),t[38]=H,t[39]=U,t[40]=R,t[41]=_,t[42]=se):se=t[42];let z;return t[43]!==se||t[44]!==E?(z=n.jsx("div",{"data-titlebar-left-controls":b,className:j,style:E,children:se}),t[43]=se,t[44]=E,t[45]=z):z=t[45],z};function Zb(t){return t.toggleSidebar}function Xb(t){return t.isSidebarOpen}function Yb(t){return t.shortcutOverrides}function Jb(){K.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function Qb(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 ew(t){console.warn("[titlebar] failed to open app menu",t)}function tw(t,e,s){const r=Ue.c(5),[o,i]=c.useState();let a,d;return r[0]!==s||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let u=!1;return(async()=>{const[l,f]=await Promise.all([Om(t),Mm(t)]).catch(sw);if(u)return;const m=Jt(l),p=Jt(f);if(!m||!p||p===m)return;const h=s||"",x=p.split("/").filter(Boolean).pop()||p;i({source:"sdk",path:p,projectDirectory:m,branch:h,label:h||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!0}},d=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=a,r[4]=d):(a=r[3],d=r[4]),c.useEffect(a,d),e??o}function sw(){return["",""]}const nw=()=>{const t=Ue.c(3),e=K(rw),s=K(ow);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(!0)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function rw(t){return t.setSettingsDialogOpen}function ow(t){return t.setSettingsPage}const el="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",iw=({className:t,identity:e})=>{const{t:s}=lt(),{sourceControl:r}=ks(),o=Fm(e),i=Pi(e.provider),a=i.label,d=o?.status??null,u=un(b=>b.setStatus),[l,f]=c.useState(!1),m=c.useCallback(async b=>{if(!(!b||l)){f(!0);try{u(e,await r.authActivate(e,b))}catch(j){console.error("Failed to switch source control account:",j)}finally{f(!1)}}},[e,l,u,r]);if(d?.status!=="connected")return null;const p=d.user.username||null,h=d.user.avatarUrl??null,x=d.accounts,g=p?s("header.sourceControl.connectedWithLogin",{login:p,provider:a}):s("header.sourceControl.connected",{provider:a}),w=h?n.jsx("img",{src:h,alt:p?s("header.sourceControl.avatarWithLogin",{login:p}):s("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?n.jsx("div",{className:Ze(el,t),title:g,children:w}):n.jsxs(fn,{children:[n.jsx(pn,{asChild:!0,children:n.jsx("button",{type:"button",className:Ze(el,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:l,children:w})}),n.jsxs(mn,{align:"end",className:"w-64",children:[n.jsx(Dr,{className:"typography-ui-header font-semibold text-foreground",children:s("header.sourceControl.accountsTitle",{provider:a})}),n.jsx(qn,{}),x.map(b=>{const j=b.user,y=!!b.current,E=s(Lm(b.source??"oauth"));return n.jsxs($s,{className:"gap-2",disabled:l,onSelect:()=>{y||m(b.id)},children:[j?.avatarUrl?n.jsx("img",{src:j.avatarUrl,alt:j.username?s("header.sourceControl.avatarWithLogin",{login:j.username}):s("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-edge bg-muted",children:n.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:j?.name?.trim()||j.username||i.label}),j.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:j.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:E})]}):null]}),y?n.jsx(ce,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})},aw=t=>JSON.stringify(Bm(t)),lw=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},Pd=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function cw(t){if(!Pd(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function dw(t,e,s){const r=Ue.c(18),{sourceControl:o}=ks(),i=Pi(t.provider).features.referenceSearch,[a,d]=$t.useState(null);let u;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(u=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]=u):u=r[4];const l=u;let f;r[5]!==t||r[6]!==l||r[7]!==e||r[8]!==i||r[9]!==o?(f=()=>{if(!i)return;let p=!1;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(p||!h.connected)return;const x=h.items.find(g=>g.kind==="pull"&&g.number===e);x&&d({key:l,pull:x})}).catch(uw),()=>{p=!0}},r[5]=t,r[6]=l,r[7]=e,r[8]=i,r[9]=o,r[10]=f):f=r[10];let m;return r[11]!==t||r[12]!==l||r[13]!==e||r[14]!==s||r[15]!==i||r[16]!==o?(m=[t,l,e,s,i,o],r[11]=t,r[12]=l,r[13]=e,r[14]=s,r[15]=i,r[16]=o,r[17]=m):m=r[17],$t.useEffect(f,m),a?.key===l?a.pull:null}function uw(){}const fw=t=>{const e=Ue.c(99),{directory:s,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:d}=ks(),u=Hs(),l=Gt(pw),[f,m]=$t.useState(0),[p,h]=$t.useState(!1),x=Li(),g=dw(r,o.number,f);let w;e[0]!==o?(w=$m(o),e[0]=o,e[1]=w):w=e[1];const b=w;let j;e[2]!==g||e[3]!==b?(j=g?{...b,labels:g.labels,commentCount:g.commentCount}:b,e[2]=g,e[3]=b,e[4]=j):j=e[4];const y=j,[E,A]=$t.useState(null),R=E?.number===o.number?E.sha:null,{detail:_,latest:L,refresh:v}=_c(s,y,!0,R),C=L.status==="ready"?L.value.pull:null,S=dc(y);let k;e[5]!==i||e[6]!==v?(k=()=>{v(),m(mw),i()},e[5]=i,e[6]=v,e[7]=k):k=e[7];const N=k,$=uc(y,r,N);let B;e[8]!==r||e[9]!==i||e[10]!==y.number||e[11]!==y.sourceRepo.owner||e[12]!==y.sourceRepo.repo||e[13]!==v||e[14]!==d?(B=async()=>{const M={owner:y.sourceRepo.owner,repo:y.sourceRepo.repo,number:y.number};await d.refreshProviderReads(r,{item:M}).catch(hw),Ac(M),m(gw),await Promise.all([v(),i()])},e[8]=r,e[9]=i,e[10]=y.number,e[11]=y.sourceRepo.owner,e[12]=y.sourceRepo.repo,e[13]=v,e[14]=d,e[15]=B):B=e[15];const D=B;let W;e[16]!==y?(W={source:"repository",reference:y},e[16]=y,e[17]=W):W=e[17];const H=W,U=u??s;let se;e[18]!==_||e[19]!==a?(se=_.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]=se):se=e[20];const z=se,Q=z.status==="ready"?z.value.pull?.stack??null:a??null,ie=Bi(),O=Gt(xw),ne=nt(bw),V=gr(O,ne,s),[J,F]=$t.useState(!1);let re;e[21]===Symbol.for("react.memo_cache_sentinel")?(re={status:"idle"},e[21]=re):re=e[21];const q=V?()=>F(!0):void 0,ge=C?.submitRequirements,Z=L.status==="error",de=o.mergeable??null;let Se;e[22]!==r||e[23]!==H||e[24]!==N||e[25]!==Q||e[26]!==Z||e[27]!==de||e[28]!==q||e[29]!==ge?(Se=n.jsx(Ai,{item:H,project:null,context:r,onStartWorktree:yw,onChanged:N,worktreeAvailable:!1,stack:Q,onStartOnTop:q,submitRequirements:ge,submitRequirementsUnreadable:Z,mergeable:de}),e[22]=r,e[23]=H,e[24]=N,e[25]=Q,e[26]=Z,e[27]=de,e[28]=q,e[29]=ge,e[30]=Se):Se=e[30];let ue;e[31]!==o.number||e[32]!==C||e[33]!==R?(ue=C?.revisions?{revisions:C.revisions,selected:R,onSelect:M=>A(M?{number:o.number,sha:M}:null)}:void 0,e[31]=o.number,e[32]=C,e[33]=R,e[34]=ue):ue=e[34];let ke;e[35]!==s||e[36]!==ie?(ke=M=>{ie(M.url,s)},e[35]=s,e[36]=ie,e[37]=ke):ke=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>h(!0),e[38]=Me):Me=e[38];let We;e[39]!==r||e[40]!==H||e[41]!==y.state||e[42]!==N?(We=y.state!=="merged"?n.jsx(fc,{item:H,context:r,onChanged:N}):void 0,e[39]=r,e[40]=H,e[41]=y.state,e[42]=N,e[43]=We):We=e[43];let Le;e[44]!==S.attachComment||e[45]!==S.attachComments?(Le={onAttach:S.attachComment,onAttachAll:S.attachComments},e[44]=S.attachComment,e[45]=S.attachComments,e[46]=Le):Le=e[46];let Ve;e[47]!==r||e[48]!==y||e[49]!==N?(Ve=n.jsx(hc,{reference:y,context:r,onChanged:N}),e[47]=r,e[48]=y,e[49]=N,e[50]=Ve):Ve=e[50];let Ne;e[51]!==r||e[52]!==_||e[53]!==y||e[54]!==N?(Ne=n.jsx(gc,{pull:y,detail:_,context:r,onChanged:N}),e[51]=r,e[52]=_,e[53]=y,e[54]=N,e[55]=Ne):Ne=e[55];const me=C?.voteLabels;let ye;e[56]!==C?.revisions?(ye=C?.revisions?.at(-1)?.sha,e[56]=C?.revisions,e[57]=ye):ye=e[57];const je=R===null;let Be;e[58]!==r||e[59]!==y||e[60]!==N||e[61]!==me||e[62]!==ye||e[63]!==je?(Be=n.jsx(pc,{reference:y,context:r,onRefresh:N,voteLabels:me,latestRevision:ye,onLatestRevision:je},y.number),e[58]=r,e[59]=y,e[60]=N,e[61]=me,e[62]=ye,e[63]=je,e[64]=Be):Be=e[64];const _e=l??"";let Ie;e[65]!==U||e[66]!==_e?(Ie={id:_e,path:U},e[65]=U,e[66]=_e,e[67]=Ie):Ie=e[67];let tt;e[68]!==r||e[69]!==U||e[70]!==y||e[71]!==R||e[72]!==Ie?(tt=n.jsx(xc,{pull:y,project:Ie,repository:null,context:r,projectOwnsDirectory:vw,currentDirectory:U,revision:R}),e[68]=r,e[69]=U,e[70]=y,e[71]=R,e[72]=Ie,e[73]=tt):tt=e[73];let Ke;e[74]!==s||e[75]!==H||e[76]!==x||e[77]!==D||e[78]!==z||e[79]!==Se||e[80]!==ue||e[81]!==ke||e[82]!==We||e[83]!==Le||e[84]!==Ve||e[85]!==Ne||e[86]!==Be||e[87]!==tt||e[88]!==$?(Ke=n.jsx($i,{item:H,directory:s,pullStatus:zi,trackerDetail:re,repositoryDetail:z,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:ww,now:x,footer:Se,revisionChoice:ue,onOpenStackLayer:ke,onOpenChecks:Me,onRefresh:D,stateMenu:We,commentAttachments:Le,threadActions:$,labelsControl:Ve,reviewersControl:Ne,reply:Be,pullLinks:tt}),e[74]=s,e[75]=H,e[76]=x,e[77]=D,e[78]=z,e[79]=Se,e[80]=ue,e[81]=ke,e[82]=We,e[83]=Le,e[84]=Ve,e[85]=Ne,e[86]=Be,e[87]=tt,e[88]=$,e[89]=Ke):Ke=e[89];let ze;e[90]!==S.attachFailedChecks||e[91]!==p||e[92]!==r||e[93]!==y?(ze=n.jsx(mc,{pull:y,context:r,open:p,onOpenChange:h,onAttachFailed:S.attachFailedChecks}),e[90]=S.attachFailedChecks,e[91]=p,e[92]=r,e[93]=y,e[94]=ze):ze=e[94];const rt=V?n.jsx(zm,{open:J,onOpenChange:F,project:{id:V.id,path:Vr(V.path)??V.path},initialSourceBranch:y.head,onWorktreeCreated:Sw}):null;let ve;return e[95]!==Ke||e[96]!==ze||e[97]!==rt?(ve=n.jsxs(n.Fragment,{children:[Ke,ze,rt]}),e[95]=Ke,e[96]=ze,e[97]=rt,e[98]=ve):ve=e[98],ve};function pw(t){return t.activeProjectId}function mw(t){return t+1}function hw(){}function gw(t){return t+1}function xw(t){return t.projects}function bw(t){return t.availableWorktreesByProject}function ww(){}function yw(){}function vw(){return!0}function Sw(t){nt.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const kw=/^Change-Id:\s*I[0-9a-f]{40}$/,jw=50,Cw=t=>(t.replace(/\r\n/g,`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-C5sudp8H.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BkjZnJsc.js","assets/katex.min-BRXXWH9j.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod-B_hXR7jf.js","assets/vendor-opencode-client-NJGkA1Ku.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-DKWxHuRR.css","assets/vendor-base-ui-CHqK1aDI.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-Bw3q1rnq.js","assets/vendor-tanstack-virtual-core-B4TJYmIq.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-ClBHCVu_.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-iLtL-MFj.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-0CHuG78d.js","assets/space-apply-DlPRGjzD.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-e7HoRw02.js","assets/useBranchPullRequestRequest-FtZEfVLl.js","assets/parseDiffFromFile-BSeCTEcW.js","assets/computeVirtualFileMetrics-oAeWRt0Z.js","assets/themeResolver-Dybtoo13.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-CBdbdXoZ.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-BKAarfyR.js","assets/ReviewCards-ClKfTGPh.js","assets/useInlineCommentController-CJmX7RR7.js","assets/appThemeRegistry-3vWr61EA.js","assets/textMateThemeFromAppTheme-OzgrN6CB.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/editorCodeMetrics-CkrWYimB.js","assets/OfficeDocumentDiff-DIZPU2-t.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/documentClient-ByzYQ2D3.js","assets/useRootScrollLock-BDtmtwPT.js","assets/moveWorkspacePath-BEX7mjeu.js","assets/contextFileOpenGuard-BTdwRRDI.js","assets/install-request-e6fA_Hb1.js","assets/WalkthroughView-B7KbSsAT.js","assets/ChangeRequestDiffUnavailable-DWvRZnAG.js","assets/useDiffFindSurface-CwoUylJl.js","assets/useWalkthroughReview-CeQ95bk7.js","assets/useCallableModelProviders-CiB4Z_LE.js","assets/useWholeFileComment-CHOMIHNo.js","assets/DiffView-BZ72jtft.js","assets/SubmoduleDiffSummary-DoIUrBdP.js","assets/FilesView-C6unlf1o.js","assets/flexokiTheme-Yh7J7UaE.js","assets/vendor-codemirror-search-CWqbGraJ.js","assets/vendor-replit-codemirror-vim-DTiXsOdM.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-Cqxh_vbH.js","assets/fileContentPoller-BXbgYIo0.js","assets/JsonTreeView-B1jPqBE_.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-DTR6Yek4.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-vTDDxBjH.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/scheduledTasksApi-B5hRhk34.js","assets/GuestPanelContent-VypuCChp.js","assets/SettingsWindow-rjA8cpzb.js","assets/SettingsView-CcxtXPxF.js","assets/install-BXZHlgVP.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SpaceRow-DoksNK04.js","assets/AboutLogo-ChxCGRUm.js","assets/pageTitle-BT3-HFbv.js","assets/CommandPalette-ynDRBNPC.js","assets/HelpDialog-BCLY1SdQ.js","assets/ProjectActionsDialog-5SwtkdoL.js","assets/OpenCodeStatusDialog-riJvcyNM.js","assets/RunOverview-Zx7ypz3K.js","assets/ScheduledTasksDialog-BqkQPZwR.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/date-time-De4cJmG-.js","assets/ArchiveView-BZJ26vYO.js","assets/useWorktreeArchiveActions-BhGDka1f.js","assets/IntegrationsCatalogView-CCC5vFCc.js","assets/UsageStatsView-BqLNssJZ.js","assets/SourceBoardView-ClskEpR_.js","assets/OverviewView-DrjJJdxp.js","assets/WorktreesView-C-AdzkFm.js","assets/SpacesView-BBtBwQ17.js","assets/SpaceAccessDialog-VIsmK3Lq.js","assets/spaceNetwork-DBQETFXl.js","assets/SpaceApplyDialog-CE4GGYR-.js","assets/SpaceSetupOutput-CCkZT6Bi.js","assets/OnboardingScreen-BNELvFqK.js","assets/AboutDialog-DZBVspvU.js","assets/MemoryDebugPanel-BiidelAZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as Ue,j as n,R as c,r as $t,a as Gl,h as _u}from"./vendor-react--VO_rL_p.js";import{l as zt,cZ as Au,c_ as Zl,u as K,bG as Ps,m as pr,b3 as qt,b5 as to,n as Jt,b2 as Ou,bM as so,cy as rs,c$ as Ei,b7 as no,d0 as Mu,ck as Xl,d1 as yt,d2 as Fu,bD as Br,bE as Ys,bF as Qo,c5 as Lu,bN as Yl,bB as Pi,d3 as Bu,cm as Jl,ce as ca,ba as Ql,d4 as $u,d5 as mr,d6 as $r,d7 as er,d8 as zu,d9 as Kn,da as Wu,db as ei,dc as jr,dd as Ii,de as ro,cQ as Pn,bo as zr,j as zs,df as jn,dg as Uu,dh as bs,b as dn,di as hr,dj as ec,dk as Vu,dl as Zs,dm as Hu,dn as tc,dp as Ku,dq as qu,dr as sc,ds as Gu,cB as Zu,cj as Xu,ct as Yu,co as Ju,bC as Qu,bI as us,v as ti,cp as ef,dt as tf,du as sf,bY as si,dv as Ri,dw as nf,by as rf,bg as da,cT as nc,dx as ua,bf as rc,dy as of,dz as af,w as oc,cs as lf,dA as fa,b_ as Di,dB as ic,c7 as cf,be as df,t as uf,q as ff,bH as ac,cG as pa,cH as lc,cW as pf,cz as mf,cD as ma,dC as hf,dD as gf,c3 as xf,c1 as bf,dE as wf,c8 as yf,cF as vf,dF as Sf,dG as kf,dH as jf,dI as ha,dJ as Po,dK as ga,dL as xa,dM as Cf,bP as ba,dN as Tf,dO as Nf,bQ as wa,dP as Ef,c2 as Pf,i as If,a as Rf}from"./katex.min-BRXXWH9j.js";import{_ as Ft}from"./vendor-vite-runtime-DD1OZmLC.js";import{bZ as Df,b_ as cc,b$ as _f,c0 as Af,c1 as Of,r as _i,c2 as Mf,c3 as Ff,c4 as Lf,c5 as Bf,n as ya,c6 as $f,aW as zf,c7 as Wf,aZ as va,c8 as Uf,aa as dc,ac as uc,ai as fc,ae as pc,ab as mc,a9 as Ai,ah as hc,af as gc,ad as xc,aK as Vf,aL as Hf,aP as Kf,aQ as qf,aR as Gf,aN as Zf,K as Xf,aM as Yf,N as Jf,a8 as Qf,aj as ep,bA as tp,c9 as bc,ca as Ir,cb as sp,cc as np,cd as wc,ce as bn,cf as Sa,cg as ka,ch as Io,ci as ja,M as rp,an as op,aO as Rr,bx as ip,by as ap,aT as lp,bW as yc,cj as cp,bz as dp,ck as up,cl as fp,cm as Ca,cn as Ro,co as sn,cp as wn,cq as pp,cr as Ta,cs as mp,ct as hp,cu as gp,cv as xp,cw as bp,cx as wp,cy as yp,cz as Na,cA as vp,cB as Sp,cC as kp,cD as jp,cE as Cp,bB as Tp,bw as Np,bV as Ep,bC as Pp,bX as Ip,cF as Rp,bR as Dp,bS as _p,aV as vc,cG as Ap,cH as Op,cI as Mp,cJ as Fp,cK as Lp,bU as Bp,cL as $p,bN as zp,cM as Wp,cN as Up,bK as Vp,bJ as Hp,bE as Kp,bF as qp,bG as Gp,bH as Zp,bI as Xp,bD as Yp,bL as Jp,bY as Qp,bQ as em,bP as tm,bT as sm,cO as nm,cP as rm}from"./runtimeEndpointReset-0CHuG78d.js";import{bi as oo,_ as Gt,a1 as nt,cQ as gr,a3 as Ze,fz as om,cR as im,I as ce,fA as am,u as lt,lR as nn,Z as ts,lS as lm,az as ws,aD as Ws,aA as Oi,lT as Sc,b1 as Bs,gM as kc,gK as cm,gL as dm,lU as jc,bb as xr,ag as St,af as kt,ah as jt,kd as Us,cU as Cc,bd as br,lV as um,lW as fm,lX as pm,lY as mm,lZ as hm,$ as gm,l_ as xm,l$ as Tc,cZ as Mi,b4 as bm,a0 as wm,m0 as ym,A as Oe,bC as vm,m1 as Sm,m2 as km,kr as Nc,m3 as jm,bL as Hs,fS as Cm,ay as Tm,be as vs,b8 as io,bc as ao,br as Cn,m4 as Nm,m5 as lo,P as hn,m6 as Em,fX as Ec,m7 as Pm,ih as wr,ii as co,cL as Wr,fY as Im,kQ as Rm,m8 as Dm,bl as tr,g4 as Pc,m9 as _m,t as sr,q as nr,D as rr,l as or,F as ir,o as Ur,B as ut,ma as In,a6 as fn,a7 as pn,a8 as mn,mb as Ic,mc as Fi,n as as,ck as Xt,md as Rc,me as Am,d7 as Dc,mf as Om,mg as Mm,bP as ks,mh as Fm,cp as un,mi as Ea,bV as Dr,ae as qn,mj as Lm,a9 as $s,gw as Bm,cA as Li,mk as $m,ml as _c,mm as Bi,em as zm,d_ as Vr,et as Ac,eg as $i,eh as zi,mn as Oc,aR as ns,y as Rn,C as ni,hK as Wm,ie as Um,hV as Vm,iA as Hm,mo as Km,hr as Mc,bR as Ls,K as Wi,bK as qm,au as hs,bQ as Fc,cr as Pa,cq as Un,hs as Gm,cs as Zm,cH as uo,cC as Xm,hu as Do,mp as Ym,z as Jm,aT as Qm,aU as eh,aV as th,aW as sh,aX as nh,aQ as Ia,bW as Lc,bT as Hr,mq as rh,mr as oh,ms as ih,aZ as On,bI as ah,bM as fo,bO as lh,bS as ch,bN as Dn,ip as dh,bU as uh,hx as fh,cB as po,mt as Bc,mu as $c,mv as ph,ea as mh,e6 as hh,e9 as gh,mw as xh,ei as bh,e7 as Ra,mx as wh,iK as yh,my as vh,mz as Sh,e8 as Da,es as kh,ec as jh,cl as Ch,mA as Th,mB as Nh,mC as Eh,mD as Ui,mE as Vi,mF as Ph,mG as Ih,mH as Rh,mI as Dh,mJ as _h,lu as Hi,mK as Ah,mL as Oh,mM as Mh,mN as Fh,mO as Ki,mP as Lh,bJ as Bh,mQ as $h,mR as zh,bY as zc,mS as Wc,bt as Wh,mT as Uh,x as Uc,mU as Vh,mV as Sn,c5 as Hh,bH as Kh,as as qh,mW as Gh,W as Bt,mX as Zh,mY as Xh,dJ as Yh,mZ as Vc,m_ as Jh,m$ as _r,n0 as yn,k1 as Qh,n1 as cn,ep as eg,n2 as tg,n3 as Hc,kX as Kc,e_ as mo,n4 as sg,el as ng,dQ as rg,n5 as qi,n6 as og,cG as ig,cE as ag,n7 as lg,n8 as _o,d6 as Gi,fB as _n,n9 as qc,bj as cg,na as dg,nb as ug,nc as fg,nd as Ao,ne as pg,nf as mg,hd as Zi,c$ as hg,ha as gg,ke as xg,kf as bg,d8 as wg,ng as ar,h9 as Gc,h8 as Zc,kg as yg,kh as vg,hb as Sg,d0 as kg,eF as jg,cj as Cg,lC as Tg,c7 as Ng,nh as Oo,lm as Eg,ll as Pg,ni as Xc,nj as Yc,nk as Ig,nl as ri,nm as Gs,e2 as Rg,kb as Dg,lk as _a,nn as _g,no as Ag,ba as lr,np as Aa,nq as Og,nr as Mg,ns as Fg,kv as Lg,kw as Bg,nt as $g,kx as Oa,nu as zg,ky as Ma,kz as Wg,dB as Ug,nv as Vg,nw as Hg,nx as Kg,bs as qg,k as Gg,l0 as Zg,cW as Mo,kA as Xg,kB as Yg,ny as Fa,kC as Jg,c_ as Qg,kF as e1,kD as t1,kE as s1,nz as Fo,nA as La,lP as n1,kT as Xi,eC as yr,kN as r1,nB as o1,nC as Jc,fo as i1,gP as oi,nD as Qc,jy as ho,kZ as a1,di as l1,nE as c1,nF as ed,fV as d1,nG as u1,nH as td,eE as f1,eD as Yi,nI as p1,nJ as Ba,nK as m1,nL as h1,eG as g1,G as ii,nM as sd,cu as nd,cv as rd,cw as od,cx as id,nN as ai,cy as ad,kn as ld,nO as Lo,nP as x1,gO as b1,k$ as w1,a2 as y1,nQ as v1,nR as S1,nS as cd,b2 as $a,fh as k1,ki as j1,nT as C1,kl as T1,nU as N1,dK as za,nV as E1,kp as P1,nW as I1,lv as R1,g9 as D1,nX as _1,go as Wa,b9 as A1,ga as O1,gc as M1,gb as F1,gk as L1,gj as B1,gd as $1,lw as z1,gi as W1,ge as U1,gf as V1,gg as H1,gh as K1,a as q1,s as G1,b as Z1,c as X1,lI as Y1,al as J1,gr as Q1,gs as ex,gt as tx}from"./useAppFontEffects-BkjZnJsc.js";import{f as dd,u as ud,S as sx,W as fd,a as nx,b as rx,c as ox}from"./useRootScrollLock-BDtmtwPT.js";import{h as pd,i as Kr,T as md,M as hd,D as gd,f as li}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as ix,h as ax,u as xd,S as bd,v as lx,a as cx}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as wd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{C as dx}from"./vendor-base-ui-CHqK1aDI.js";import{a as rn,O as ux,d as fx,D as px,b as mx,u as hx,m as Ua}from"./moveWorkspacePath-BEX7mjeu.js";import{u as ci,c as go,p as gx}from"./vendor-zustand-C9tWdk0j.js";import{o as Js,s as Ss,n as xo,c as yd,h as xx,f as cr,a as di}from"./vendor-zod-B_hXR7jf.js";import{u as bx}from"./vendor-tanstack-react-virtual-Bw3q1rnq.js";import{v as Va,t as Ha}from"./contextFileOpenGuard-BTdwRRDI.js";import{d as wx,m as yx}from"./vendor-tanstack-virtual-core-B4TJYmIq.js";import{r as vx}from"./install-request-e6fA_Hb1.js";function Sx(t){const e=Ue.c(37),{directory:s,className:r}=t,{currentTheme:o}=oo(),i=Gt(Cx),a=nt(jx),d=zt(kx),u=Au(s);let l;e[0]!==s||e[1]!==d?(l=Zl(s,d),e[0]=s,e[1]=d,e[2]=l):l=e[2];const f=l;let m;e[3]!==s||e[4]!==f||e[5]!==i||e[6]!==u||e[7]!==a?(m=f||!s?null:gr(i,a,s,u),e[3]=s,e[4]=f,e[5]=i,e[6]=u,e[7]=a,e[8]=m):m=e[8];const p=m;if(f){let L;e[9]!==r?(L=Ze("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=L):L=e[10];let v;return e[11]!==L?(v=n.jsx(ce,{name:"chat-4",className:L}),e[11]=L,e[12]=v):v=e[12],v}if(!p)return null;const h=p.icon?om[p.icon]:null;let x;e[13]!==p.color?(x=im(p.color)??void 0,e[13]=p.color,e[14]=x):x=e[14];const g=x;let w;e[15]!==r||e[16]!==g||e[17]!==h?(w=h?n.jsx(ce,{name:h,className:Ze("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):n.jsx(ce,{name:"folder",className:Ze("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]=w):w=e[18];const b=w;if(!p.iconImage)return b;let j;e[19]!==r?(j=Ze("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[19]=r,e[20]=j):j=e[20];let y;e[21]!==p.iconBackground?(y=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[21]=p.iconBackground,e[22]=y):y=e[22];let E;e[23]!==p.iconImage||e[24]!==p.id?(E={id:p.id,iconImage:p.iconImage},e[23]=p.iconImage,e[24]=p.id,e[25]=E):E=e[25];let A;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(A={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=A):A=e[28];let R;e[29]!==b||e[30]!==E||e[31]!==A?(R=n.jsx(am,{project:E,options:A,className:"h-full w-full object-contain",fallback:b}),e[29]=b,e[30]=E,e[31]=A,e[32]=R):R=e[32];let _;return e[33]!==j||e[34]!==y||e[35]!==R?(_=n.jsx("span",{className:j,style:y,children:R}),e[33]=j,e[34]=y,e[35]=R,e[36]=_):_=e[36],_}function kx(t){return t.homeDirectory}function jx(t){return t.availableWorktreesByProject}function Cx(t){return t.projects}const Vn=24,Tx=(t,e,s=Vn)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},Nx=({transform:t})=>({...t,y:0}),Ex=16,Px=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*Ex:t.deltaY;t.currentTarget.scrollLeft+=to(t.currentTarget)?-e:e},Ix=t=>{const e=Ue.c(118),{tab:s,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:d,onPin:u,onClose:l,renderMenu:f,closeOtherTabs:m,onMenuOpenChangeComplete:p,menuReturnsFocus:h,children:x}=t,{t:g}=lt(),w=K(Dx);let b;e[0]!==w?(b=Oi("switch_session_tab",w),e[0]=w,e[1]=b):b=e[1];const j=b;let y;e[2]!==r||e[3]!==j?(y=j&&j!==Sc&&r<=9?ws(`${j}+${r}`):void 0,e[2]=r,e[3]=j,e[4]=y):y=e[4];const E=y,[A,R]=c.useState(!1);let _;e[5]!==s.id?(_={id:s.id},e[5]=s.id,e[6]=_):_=e[6];const{attributes:L,listeners:v,setNodeRef:C,transform:S,transition:k,isDragging:N}=xd(_);let $;e[7]!==g||e[8]!==s.session.title?($=s.session.title?.trim()||g("sessions.sidebar.session.untitled"),e[7]=g,e[8]=s.session.title,e[9]=$):$=e[9];const B=$,D=s.id;let W;e[10]!==s.session?(W=Bs(s.session),e[10]=s.session,e[11]=W):W=e[11];const H=cc(D,W),U=kc(s.id),se=U!==null,z=cm(s.id),Q=dm(s.id),O=se||z&&(!o||Q)&&!se;let ne;e[12]!==d||e[13]!==s?(ne=()=>d(s),e[12]=d,e[13]=s,e[14]=ne):ne=e[14];let V;e[15]!==m||e[16]!==s.id?(V=()=>m(s.id),e[15]=m,e[16]=s.id,e[17]=V):V=e[17];let J,F,re,q,ge,Z,de,Se,ue,ke,Me,We,Le,Ve,Ne,me;if(e[18]!==L||e[19]!==x||e[20]!==A||e[21]!==o||e[22]!==H||e[23]!==N||e[24]!==i||e[25]!==z||e[26]!==v||e[27]!==h||e[28]!==l||e[29]!==p||e[30]!==u||e[31]!==d||e[32]!==f||e[33]!==C||e[34]!==w||e[35]!==O||e[36]!==a||e[37]!==g||e[38]!==ne||e[39]!==V||e[40]!==s||e[41]!==E||e[42]!==B||e[43]!==S||e[44]!==k||e[45]!==U){const _e={session:s.session,open:A,isActive:o,select:ne,closeOtherTabs:V,components:_f};ue=C;let Ie;e[62]!==S?(Ie=wd.Translate.toString(S),e[62]=S,e[63]=Ie):Ie=e[63],e[64]!==Ie||e[65]!==k?(ke={transform:Ie,transition:k},e[64]=Ie,e[65]=k,e[66]=ke):ke=e[66];const tt=N&&"z-10 opacity-60";e[67]!==tt?(Me=Ze("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",tt),e[67]=tt,e[68]=Me):Me=e[68],We=o?"true":"false",e[69]!==o?(Le=o?{"data-active-session-tab":!0}:{},e[69]=o,e[70]=Le):Le=e[70],Ve=L,Ne=v,F=xr,ge=A,Z=R,e[71]!==p?(de=rt=>p?.(rt),e[71]=p,e[72]=de):de=e[72];let Ke;e[73]!==x||e[74]!==o||e[75]!==H||e[76]!==i||e[77]!==z||e[78]!==l||e[79]!==u||e[80]!==d||e[81]!==w||e[82]!==O||e[83]!==a||e[84]!==g||e[85]!==s||e[86]!==B||e[87]!==U?(Ke=n.jsx(St,{asChild:!0,children:n.jsx(dx,{render:rt=>n.jsx("div",{...rt,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:ve=>{if(ve.altKey){Af(s.id,z,g);return}const M=Bs(s.session);if(ve.shiftKey&&M&&!pr()){Of(s.id,M,B);return}o||d(s)},onDoubleClick:i?()=>u(s.id):void 0,onKeyDown:o?void 0:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),d(s))},onAuxClick:ve=>{ve.button===1&&(ve.preventDefault(),l(s.id))},className:Ze("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:n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[n.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[n.jsx(Sx,{directory:Bs(s.session),className:Ze(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.closeTab"),onClick:ve=>{ve.stopPropagation(),l(s.id)},onPointerDown:_x,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:n.jsx(ce,{name:"close",className:"size-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:g("header.sessionTabs.closeTab"),shortcut:o?ws(Ps()?"mod+w":Ws("close_session_tab",w),""):void 0})})]})]}),n.jsx("div",{className:Ze("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?x:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.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:B})})}),H?n.jsx(ce,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":g("sessions.aiRename.generating")}):O?n.jsx(Cc,{state:U??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[73]=x,e[74]=o,e[75]=H,e[76]=i,e[77]=z,e[78]=l,e[79]=u,e[80]=d,e[81]=w,e[82]=O,e[83]=a,e[84]=g,e[85]=s,e[86]=B,e[87]=U,e[88]=Ke):Ke=e[88];let ze;e[89]!==E||e[90]!==B?(ze=n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:B,shortcut:E})}),e[89]=E,e[90]=B,e[91]=ze):ze=e[91],e[92]!==Ke||e[93]!==ze?(Se=n.jsxs(kt,{children:[Ke,ze]}),e[92]=Ke,e[93]=ze,e[94]=Se):Se=e[94],J=br,e[95]!==h?(me=()=>h?.()??!0,e[95]=h,e[96]=me):me=e[96],re="min-w-[190px]",q=f(_e),e[18]=L,e[19]=x,e[20]=A,e[21]=o,e[22]=H,e[23]=N,e[24]=i,e[25]=z,e[26]=v,e[27]=h,e[28]=l,e[29]=p,e[30]=u,e[31]=d,e[32]=f,e[33]=C,e[34]=w,e[35]=O,e[36]=a,e[37]=g,e[38]=ne,e[39]=V,e[40]=s,e[41]=E,e[42]=B,e[43]=S,e[44]=k,e[45]=U,e[46]=J,e[47]=F,e[48]=re,e[49]=q,e[50]=ge,e[51]=Z,e[52]=de,e[53]=Se,e[54]=ue,e[55]=ke,e[56]=Me,e[57]=We,e[58]=Le,e[59]=Ve,e[60]=Ne,e[61]=me}else J=e[46],F=e[47],re=e[48],q=e[49],ge=e[50],Z=e[51],de=e[52],Se=e[53],ue=e[54],ke=e[55],Me=e[56],We=e[57],Le=e[58],Ve=e[59],Ne=e[60],me=e[61];let ye;e[97]!==J||e[98]!==re||e[99]!==q||e[100]!==me?(ye=n.jsx(J,{finalFocus:me,className:re,children:q}),e[97]=J,e[98]=re,e[99]=q,e[100]=me,e[101]=ye):ye=e[101];let je;e[102]!==F||e[103]!==ge||e[104]!==Z||e[105]!==de||e[106]!==Se||e[107]!==ye?(je=n.jsxs(F,{open:ge,onOpenChange:Z,onOpenChangeComplete:de,children:[Se,ye]}),e[102]=F,e[103]=ge,e[104]=Z,e[105]=de,e[106]=Se,e[107]=ye,e[108]=je):je=e[108];let Be;return e[109]!==ue||e[110]!==ke||e[111]!==Me||e[112]!==We||e[113]!==Le||e[114]!==Ve||e[115]!==Ne||e[116]!==je?(Be=n.jsx("div",{ref:ue,style:ke,className:Me,"data-active":We,...Le,...Ve,...Ne,children:je}),e[109]=ue,e[110]=ke,e[111]=Me,e[112]=We,e[113]=Le,e[114]=Ve,e[115]=Ne,e[116]=je,e[117]=Be):Be=e[117],Be},Rx=t=>{const e=Ue.c(110),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,menuReturnsFocus:i,children:a}=t,d=o===void 0?!1:o,{t:u,direction:l}=lt(),f=l==="rtl",m=nn(Ax),p=nn(Ox),h=nn(Mx),x=nn(Fx),g=nn(Lx),w=nn(Bx),b=nt($x),j=nt(zx),y=ts(Wx),E=K(Ux),A=nn(Vx),R=ts(Hx),_=nt(Kx),L=nt(qx),v=nt(Gx),C=nt(Zx),S=nt(Xx),k=nt(Yx);let N;e[0]!==k?(N=oe=>{const be=k??oe.activeProjectId;return oe.projects.find($e=>$e.id===be)?.path??null},e[0]=k,e[1]=N):N=e[1];const $=Gt(N),B=Df(b);let D,W;e[2]!==B||e[3]!==_||e[4]!==b||e[5]!==S||e[6]!==C||e[7]!==L||e[8]!==$||e[9]!==h||e[10]!==A||e[11]!==E||e[12]!==R?(D=()=>{if(!E)A(um,Jx);else{if(!R)return;const oe=qt(),be=!b&&L&&C,$e=b?_:L&&!C?S??$:null,De=be?fm(oe):pm(oe,$e);if(!De)return;A(De,()=>mm($e,ts.getState().activeSessions,Gt.getState().projects.map(Qx)))}b&&h(b,B)},W=[B,_,b,S,C,L,$,h,A,E,R],e[2]=B,e[3]=_,e[4]=b,e[5]=S,e[6]=C,e[7]=L,e[8]=$,e[9]=h,e[10]=A,e[11]=E,e[12]=R,e[13]=D,e[14]=W):(D=e[13],W=e[14]),c.useEffect(D,W);let H;if(e[15]!==y){H=new Map;for(const oe of y)H.set(oe.id,oe);e[15]=y,e[16]=H}else H=e[16];const U=H;let se;if(e[17]!==U||e[18]!==m){se=[];for(const oe of m){const be=U.get(oe);be&&se.push({id:oe,session:be})}e[17]=U,e[18]=m,e[19]=se}else se=e[19];const z=se;let Q;e[20]!==j?(Q=oe=>{j(oe.id,Bs(oe.session))},e[20]=j,e[21]=Q):Q=e[21];const ie=Q,O=eb,ne=!b&&L;let V;e[22]!==ne||e[23]!==v?(V=oe=>!ne||!v?"":(oe.drafts.find($e=>$e.id===v)?.text??"").split(/\r?\n/).find(tb)?.trim()??"",e[22]=ne,e[23]=v,e[24]=V):V=e[24];const J=lm(V),F=K(sb),re=nb;let q;e[25]!==b||e[26]!==ne||e[27]!==z?(q=z.some(oe=>oe.id===b)||ne&&z.length>0,e[25]=b,e[26]=ne,e[27]=z,e[28]=q):q=e[28];const ge=q;let Z,de;e[29]!==ge?(Z=()=>{if(ge)return _i(rb,{current:document.body})},de=[ge],e[29]=ge,e[30]=Z,e[31]=de):(Z=e[30],de=e[31]),c.useEffect(Z,de);let Se;e[32]!==g||e[33]!==b||e[34]!==ie||e[35]!==z?(Se=oe=>{if(g(oe),b&&b!==oe){const be=z.find($e=>$e.id===oe);be&&ie(be)}},e[32]=g,e[33]=b,e[34]=ie,e[35]=z,e[36]=Se):Se=e[36];const ue=Se;let ke;e[37]===Symbol.for("react.memo_cache_sentinel")?(ke={activationConstraint:{distance:8}},e[37]=ke):ke=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me={activationConstraint:{delay:200,tolerance:6}},e[38]=Me):Me=e[38];const We=pd(Kr(hd,ke),Kr(md,Me));let Le;e[39]!==w?(Le=oe=>{const{active:be,over:$e}=oe;$e&&be.id!==$e.id&&w(String(be.id),String($e.id))},e[39]=w,e[40]=Le):Le=e[40];const Ve=Le,Ne=c.useRef(null);let me;e[41]===Symbol.for("react.memo_cache_sentinel")?(me={left:!1,right:!1},e[41]=me):me=e[41];const[ye,je]=c.useState(me);let Be;e[42]===Symbol.for("react.memo_cache_sentinel")?(Be=()=>{const oe=Ne.current;if(!oe)return;const be=oe.scrollWidth-oe.clientWidth,$e=to(oe)?be+oe.scrollLeft:oe.scrollLeft,De=$e>2,ee=$e<be-2;je(le=>le.left===De&&le.right===ee?le:{left:De,right:ee})},e[42]=Be):Be=e[42];const _e=Be;let Ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>{_e();const oe=Ne.current;if(!oe||!globalThis.ResizeObserver)return;const be=new ResizeObserver(_e);return be.observe(oe),()=>be.disconnect()},e[43]=Ie):Ie=e[43];let tt;e[44]!==z.length?(tt=[_e,z.length],e[44]=z.length,e[45]=tt):tt=e[45],c.useEffect(Ie,tt);let Ke;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ke=()=>{const oe=Ne.current,be=oe?.querySelector("[data-active-session-tab]");if(!oe||!be)return;const $e=Tx(oe.getBoundingClientRect(),be.getBoundingClientRect());$e!==0&&(oe.scrollLeft=oe.scrollLeft+$e,_e())},e[46]=Ke):Ke=e[46];let ze;e[47]!==b?(ze=[b,_e],e[47]=b,e[48]=ze):ze=e[48],c.useEffect(Ke,ze);const rt=ye.left&&ye.right?`linear-gradient(to right, transparent, black ${Vn}px, black calc(100% - ${Vn}px), transparent)`:ye.left?`linear-gradient(to right, transparent, black ${Vn}px)`:ye.right?`linear-gradient(to right, black calc(100% - ${Vn}px), transparent)`:void 0;let ve;e[49]!==z?(ve=z.map(ob),e[49]=z,e[50]=ve):ve=e[50];const M=ve;let Ce;e[51]!==b||e[52]!==z?(Ce=!!b&&!z.some(oe=>oe.id===b),e[51]=b,e[52]=z,e[53]=Ce):Ce=e[53];const He=Ce;let Xe;e[54]!==u?(Xe=u("header.sessionTabs.stripAria"),e[54]=u,e[55]=Xe):Xe=e[55];let G;e[56]!==rt?(G=rt?{maskImage:rt,WebkitMaskImage:rt}:void 0,e[56]=rt,e[57]=G):G=e[57];let Ee;e[58]===Symbol.for("react.memo_cache_sentinel")?(Ee=[Nx],e[58]=Ee):Ee=e[58];const Pe=f?ix:ax;let Fe;e[59]!==a||e[60]!==b||e[61]!==ue||e[62]!==ie||e[63]!==i||e[64]!==r||e[65]!==x||e[66]!==p||e[67]!==s||e[68]!==d||e[69]!==z?(Fe=z.map((oe,be)=>n.jsx(Ix,{tabNumber:be+1,tab:oe,isActive:oe.id===b,isPreview:oe.id===p,suppressControls:oe.id===b&&d,onSelect:ie,onPin:x,onClose:O,renderMenu:s,closeOtherTabs:ue,onMenuOpenChangeComplete:r,menuReturnsFocus:i,children:oe.id===b?a:null},oe.id)),e[59]=a,e[60]=b,e[61]=ue,e[62]=ie,e[63]=i,e[64]=r,e[65]=x,e[66]=p,e[67]=s,e[68]=d,e[69]=z,e[70]=Fe):Fe=e[70];let Te;e[71]!==Pe||e[72]!==Fe||e[73]!==M?(Te=n.jsx(bd,{items:M,strategy:Pe,children:Fe}),e[71]=Pe,e[72]=Fe,e[73]=M,e[74]=Te):Te=e[74];let Ae;e[75]!==Ve||e[76]!==We||e[77]!==Te?(Ae=n.jsx(gd,{sensors:We,collisionDetection:li,modifiers:Ee,onDragEnd:Ve,children:Te}),e[75]=Ve,e[76]=We,e[77]=Te,e[78]=Ae):Ae=e[78];let qe;e[79]!==J||e[80]!==ne||e[81]!==u?(qe=ne?n.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:[n.jsx(ce,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),n.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:n.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:J||u("sessions.switcher.draftTitle")})})]}):null,e[79]=J,e[80]=ne,e[81]=u,e[82]=qe):qe=e[82];let Ge;e[83]!==a||e[84]!==He?(Ge=He?n.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:n.jsx("div",{className:"min-w-0 flex-1",children:a})}):null,e[83]=a,e[84]=He,e[85]=Ge):Ge=e[85];let Je;e[86]!==G||e[87]!==Ae||e[88]!==qe||e[89]!==Ge?(Je=n.jsxs("div",{ref:Ne,onScroll:_e,onWheel:Px,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:G,children:[Ae,qe,Ge]}),e[86]=G,e[87]=Ae,e[88]=qe,e[89]=Ge,e[90]=Je):Je=e[90];let st;e[91]!==u?(st=u("sessions.sidebar.header.actions.newSession"),e[91]=u,e[92]=st):st=e[92];let mt;e[93]===Symbol.for("react.memo_cache_sentinel")?(mt=n.jsx(ce,{name:"add",className:"size-4"}),e[93]=mt):mt=e[93];let Y;e[94]!==st?(Y=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:re,"aria-label":st,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:mt})}),e[94]=st,e[95]=Y):Y=e[95];let fe;e[96]!==u?(fe=u("sessions.sidebar.header.actions.newSession"),e[96]=u,e[97]=fe):fe=e[97];let Re;e[98]!==F?(Re=ws(Ws("new_chat",F),""),e[98]=F,e[99]=Re):Re=e[99];let T;e[100]!==fe||e[101]!==Re?(T=n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:fe,shortcut:Re})}),e[100]=fe,e[101]=Re,e[102]=T):T=e[102];let ae;e[103]!==Y||e[104]!==T?(ae=n.jsxs(kt,{children:[Y,T]}),e[103]=Y,e[104]=T,e[105]=ae):ae=e[105];let pe;return e[106]!==Xe||e[107]!==Je||e[108]!==ae?(pe=n.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Xe,children:[Je,ae]}),e[106]=Xe,e[107]=Je,e[108]=ae,e[109]=pe):pe=e[109],pe};function Dx(t){return t.shortcutOverrides}function _x(t){return t.stopPropagation()}function Ax(t){return t.tabIds}function Ox(t){return t.previewTabId}function Mx(t){return t.ensureTab}function Fx(t){return t.pinTab}function Lx(t){return t.closeOtherTabs}function Bx(t){return t.reorderTabs}function $x(t){return t.currentSessionId}function zx(t){return t.setCurrentSession}function Wx(t){return t.activeSessions}function Ux(t){return t.sessionTabsPerWorkspace}function Vx(t){return t.enterScope}function Hx(t){return t.hasLoaded}function Kx(t){return t.currentSessionDirectory}function qx(t){return t.newSessionDraft.open}function Gx(t){return t.newSessionDraft.workDraftId??null}function Zx(t){return t.newSessionDraft.target==="chat"}function Xx(t){return t.newSessionDraft.directoryOverride}function Yx(t){return t.newSessionDraft.selectedProjectId??null}function Jx(){return[]}function Qx(t){return t.path}function eb(t){jc(t)}function tb(t){return t.trim()}function sb(t){return t.shortcutOverrides}function nb(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:s}=nt.getState(),r=t?zt.getState().currentDirectory:e.directoryOverride;s(r?{directoryOverride:r}:void 0)}function rb(){const t=nt.getState().currentSessionId;t?jc(t):hm(-1)}function ob(t){return t.id}const ib=(t,e)=>{const s=!!t.time?.archived,r=e.projects.flatMap(d=>{const u=Jt(d.path);return u?[{id:d.id,normalizedPath:u}]:[]}),i=gm(s?[]:[t],r,e.availableWorktreesByProject,e.isVSCode,s?[t]:[],e.authoritativeProjects,e.spaces).bySessionId.get(t.id),a=xm(e.activeSessions,e.resolveLegacyScope).runKeyBySessionId.has(t.id);return{projectId:i?.projectId??null,folderOwnerKey:Mf(t,i,a),ownsWork:!a&&(!i||i.kind==="project")&&Tc(t,e.lookup)===null}},ab=(t,e)=>{const s=new Map(e.map(d=>[d.id,d])),r=new Map;for(const d of e){if(d.parentID||d.time?.archived)continue;const u=Tc(d,f=>s.get(f));if(!u)continue;const l=r.get(u);l?l.push(d):r.set(u,[d])}const o=[],i=new Set,a=[t];for(;a.length>0;){const d=a.pop();!d||i.has(d.id)||(i.add(d.id),Mi(d)&&o.push(d),a.push(...r.get(d.id)??[]))}return o};function Ka({sessionId:t,open:e,slots:s,onRename:r,onExport:o,onMoveSession:i,onArchive:a,onDelete:d}){const{t:u}=lt(),l=c.useMemo(()=>pr(),[]),f=ts(S=>S.entityById.get(t)),m=ts(S=>{const k=S.entityById.get(t);return!k||bm(k,S.entityById)}),p=ts(S=>S.activeSessions),h=nt(S=>S.unarchiveSession),x=nt(S=>S.availableWorktreesByProject),g=nt(S=>S.worktreeMetadata),w=K(S=>S.sessionWorkEnabled),b=Gt(S=>S.projects),j=wm(S=>S.projects),y=Ou(!l),E=Ff(S=>S.load),A=c.useMemo(()=>f?ib(f,{projects:b,availableWorktreesByProject:x,authoritativeProjects:j,spaces:y,isVSCode:l,activeSessions:p,resolveLegacyScope:S=>Jt(g.get(S.id)?.projectDirectory??S.directory??null),lookup:S=>ts.getState().entityById.get(S)}):null,[p,j,x,l,b,f,y,g]);if(!f||!A)return null;const R=!!f.time?.archived,_=Jt(f.directory??null),L=w&&A.ownsWork&&!R&&!f.parentID&&!so(f.directory),v=L?ab(f,p):[],C=async()=>{await h(f.id)?Oe.success(u("sessions.sidebar.session.restore.success")):Oe.error(u("sessions.sidebar.session.restore.error"))};return n.jsx(Lf,{session:f,directory:_,open:e,slots:s,archived:R,pinned:ym(f),work:L?{inWork:v.length>0,toggle:()=>{Bf(f.id,_,v,u)}}:null,projectId:A.projectId,currentWorktree:nt.getState().getWorktreeMetadata(f.id)??null,descendants:[],startWorktreeLoad:E,folders:A.folderOwnerKey?{ownerKey:A.folderOwnerKey,projectId:A.projectId}:null,onRename:r,onExport:()=>o(f,_),onMoveSession:()=>{_&&i(f.id,_)},onArchive:a,onRestore:R&&m?()=>{C()}:null,onDelete:d})}const lb=t=>{const e=Nc(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},cb=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,vd=()=>{const t=Ue.c(4),e=nt(db),s=nt(ub)??void 0,r=vm(e??"",s,lb,cb),{context:o}=Sm(e,s),i=o>0?o:km;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 db(t){return t.currentSessionId}function ub(t){return t.currentSessionDirectory}const qa=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),As=18,ui=2,fi=(As-ui)/2,Ga=2*Math.PI*fi,fb=t=>{const e=Ue.c(9),{percent:s,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,s));let d;e[0]!==o?(d=Ze("shrink-0",o),e[0]=o,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("circle",{cx:As/2,cy:As/2,r:fi,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ui}),e[2]=u):u=e[2];let l;e[3]!==i||e[4]!==a?(l=a>0?n.jsx("circle",{cx:As/2,cy:As/2,r:fi,fill:"none",stroke:i,strokeWidth:ui,strokeLinecap:"round",strokeDasharray:Ga,strokeDashoffset:Ga*(1-a/100),transform:`rotate(-90 ${As/2} ${As/2})`}):null,e[3]=i,e[4]=a,e[5]=l):l=e[5];let f;return e[6]!==d||e[7]!==l?(f=n.jsxs("svg",{viewBox:`0 0 ${As} ${As}`,className:d,"aria-hidden":"true",children:[u,l]}),e[6]=d,e[7]=l,e[8]=f):f=e[8],f},Sd=()=>{const t=Ue.c(16),{t:e}=lt(),{sessionId:s,fill:r,limit:o}=vd(),{totalCost:i}=jm(s);if(!s||!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:qa(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let d;t[4]!==o||t[5]!==e?(d=e("contextUsage.tooltip.contextLimit",{tokens:qa(o)}),t[4]=o,t[5]=e,t[6]=d):d=t[6];let u;t[7]!==e||t[8]!==i?(u=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:dd(i)})]:[],t[7]=e,t[8]=i,t[9]=u):u=t[9];let l;t[10]!==a||t[11]!==d||t[12]!==u?(l=[a,d,...u],t[10]=a,t[11]=d,t[12]=u,t[13]=l):l=t[13];const f=l;let m;return t[14]!==f?(m=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(pb)}),t[14]=f,t[15]=m):m=t[15],m};function pb(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const mb="—",hb={safe:"var(--muted-foreground)",warn:"var(--status-warning)",critical:"var(--status-error)"},gb=t=>{const e=Ue.c(35),{buttonClassName:s}=t,{t:r}=lt(),{sessionId:o,fill:i,limit:a}=vd(),d=Hs();let u;e[0]!==d?(u=d?rs(d):"",e[0]=d,e[1]=u):u=e[1];const l=u,f=K(bb);let m;e[2]!==l?(m=N=>l!==""&&Ei(N.contextPanelByDirectory[l],N.contextSurfaceZones).has("context"),e[2]=l,e[3]=m):m=e[3];const p=K(m),h=K(wb);if(!o||!i||h)return null;const x=i.state==="measured"?i.totalTokens/a*100:null,g=x===null?void 0:hb[Cm(Math.round(x))];let w;e[4]!==l||e[5]!==f?(w=l?()=>f(l,"context"):void 0,e[4]=l,e[5]=f,e[6]=w):w=e[6];let b;e[7]!==r?(b=r("contextUsage.aria.label"),e[7]=r,e[8]=b):b=e[8];const j=p&&"text-foreground";let y;e[9]!==s||e[10]!==j?(y=Ze(s,"w-auto gap-1.5 px-1 tabular-nums",j),e[9]=s,e[10]=j,e[11]=y):y=e[11];const E=x??0;let A;e[12]!==g||e[13]!==E?(A=n.jsx(fb,{percent:E,arcColor:g,className:"size-4"}),e[12]=g,e[13]=E,e[14]=A):A=e[14];let R;e[15]!==x?(R=x===null?mb:`${Math.min(x,999).toFixed(1)}%`,e[15]=x,e[16]=R):R=e[16];let _;e[17]!==R?(_=n.jsx("span",{dir:"ltr",className:"typography-meta",children:R}),e[17]=R,e[18]=_):_=e[18];let L;e[19]!==p||e[20]!==_||e[21]!==w||e[22]!==b||e[23]!==y||e[24]!==A?(L=n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:w,"aria-label":b,"aria-pressed":p,className:y,children:[A,_]})}),e[19]=p,e[20]=_,e[21]=w,e[22]=b,e[23]=y,e[24]=A,e[25]=L):L=e[25];let v;e[26]!==p||e[27]!==r?(v=p?null:n.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=p,e[27]=r,e[28]=v):v=e[28];let C;e[29]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Sd,{}),e[29]=C):C=e[29];let S;e[30]!==v?(S=n.jsx(jt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[v,C]})}),e[30]=v,e[31]=S):S=e[31];let k;return e[32]!==L||e[33]!==S?(k=n.jsxs(kt,{children:[L,S]}),e[32]=L,e[33]=S,e[34]=k):k=e[34],k},xb=c.memo(gb);function bb(t){return t.openContextSurface}function wb(t){return t.workStatusPanelVisible&&!t.workStatusHiddenSections.includes("session")}const kd=c.createContext(null),jd=()=>c.useContext(kd),yb=t=>{const e=Ue.c(4),s=jd()?.observe;let r,o;e[0]!==t||e[1]!==s?(r=()=>t&&s?s():void 0,o=[t,s],e[0]=t,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]),c.useEffect(r,o)},Za=t=>{const e=Ue.c(12),{run:s,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,d=o===void 0?!1:o;if(s?.status==="stopping"||s?.status==="waiting-for-preview"){let l;e[0]!==i?(l=Ze("size-4 shrink-0 animate-spin text-[var(--status-warning)]",i),e[0]=i,e[1]=l):l=e[1];let f;return e[2]!==l?(f=n.jsx(ce,{name:"loader-4",className:l}),e[2]=l,e[3]=f):f=e[3],f}if(s){const l=d?"stop-large":"stop";let f;e[4]!==i?(f=Ze("size-4 shrink-0 text-[var(--status-error)]",i),e[4]=i,e[5]=f):f=e[5];let m;return e[6]!==l||e[7]!==f?(m=n.jsx(ce,{name:l,className:f}),e[6]=l,e[7]=f,e[8]=m):m=e[8],m}let u;return e[9]!==i||e[10]!==a?(u=a?n.jsx(ce,{name:"play",className:Ze("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=u):u=e[11],u},vb=t=>{const e=Ue.c(68),{directory:s,buttonClassName:r}=t,{t:o}=lt(),i=rn(kb),a=rn(jb),d=rn(Cb),u=rn(Tb),l=Tm(u),f=rn(Nb),m=rn(Eb),p=rn(Pb);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]),c.useEffect(h,x);const g=Ps()&&no();let w;e[3]!==a||e[4]!==i?(w=a.find(J=>J.id===i)??a.find(Ib)??a[0]??ux[0],e[3]=a,e[4]=i,e[5]=w):w=e[5];const b=w;if(!g||!s||a.length===0)return null;let j;e[6]!==s?(j=async J=>{await Mu(s,J.id,J.appName)||await Xl(s,J.appName)},e[6]=s,e[7]=j):j=e[7];const y=j;let E;e[8]!==y||e[9]!==p?(E=async J=>{await p(J.id),await y(J)},e[8]=y,e[9]=p,e[10]=E):E=e[10];const A=E;let R;e[11]!==s||e[12]!==o?(R=async()=>{(await io(s)).ok&&Oe.success(o("openInApp.toast.pathCopied"))},e[11]=s,e[12]=o,e[13]=R):R=e[13];const _=R;let L;e[14]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx("div",{className:"inline-flex"}),e[14]=L):L=e[14];let v;e[15]!==y||e[16]!==b?(v=()=>{y(b)},e[15]=y,e[16]=b,e[17]=v):v=e[17];let C;e[18]!==l||e[19]!==r?(C=Ze(r,l),e[18]=l,e[19]=r,e[20]=C):C=e[20];let S;e[21]!==b.label||e[22]!==o?(S=o("openInApp.actions.openInAria",{app:b.label}),e[21]=b.label,e[22]=o,e[23]=S):S=e[23];let k;e[24]!==b.icon?(k=n.jsx(ce,{name:b.icon,className:"size-4"}),e[24]=b.icon,e[25]=k):k=e[25];let N;e[26]!==S||e[27]!==k||e[28]!==v||e[29]!==C?(N=n.jsx(ao,{render:L,children:n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:v,className:C,"aria-label":S,children:k})})}),e[26]=S,e[27]=k,e[28]=v,e[29]=C,e[30]=N):N=e[30];let $;e[31]!==b.label||e[32]!==o?($=o("openInApp.actions.openInAria",{app:b.label}),e[31]=b.label,e[32]=o,e[33]=$):$=e[33];let B;e[34]!==$?(B=n.jsx(jt,{side:"bottom",children:$}),e[34]=$,e[35]=B):B=e[35];let D;e[36]!==N||e[37]!==B?(D=n.jsxs(kt,{children:[N,B]}),e[36]=N,e[37]=B,e[38]=D):D=e[38];let W;e[39]!==_?(W=()=>{_()},e[39]=_,e[40]=W):W=e[40];let H;e[41]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(ce,{name:"file-copy",className:"h-4 w-4"}),e[41]=H):H=e[41];let U;e[42]!==o?(U=o("openInApp.actions.copyPath"),e[42]=o,e[43]=U):U=e[43];let se;e[44]!==U?(se=n.jsx("span",{className:"typography-ui-label text-foreground",children:U}),e[44]=U,e[45]=se):se=e[45];let z;e[46]!==W||e[47]!==se?(z=n.jsxs(vs,{className:"flex items-center gap-2",onClick:W,children:[H,se]}),e[46]=W,e[47]=se,e[48]=z):z=e[48];let Q;e[49]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx(Cn,{}),e[49]=Q):Q=e[49];let ie;if(e[50]!==a||e[51]!==A||e[52]!==b.id){let J;e[54]!==A||e[55]!==b.id?(J=F=>n.jsxs(vs,{className:"flex items-center gap-2",onClick:()=>{A(F)},children:[n.jsx(ce,{name:F.icon,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:F.label}),b.id===F.id?n.jsx(ce,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},F.id),e[54]=A,e[55]=b.id,e[56]=J):J=e[56],ie=a.map(J),e[50]=a,e[51]=A,e[52]=b.id,e[53]=ie}else ie=e[53];let O;e[57]!==d||e[58]!==m||e[59]!==o?(O=d?n.jsxs(vs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[n.jsx(ce,{name:"refresh",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[57]=d,e[58]=m,e[59]=o,e[60]=O):O=e[60];let ne;e[61]!==z||e[62]!==ie||e[63]!==O?(ne=n.jsxs(br,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[z,Q,ie,O]}),e[61]=z,e[62]=ie,e[63]=O,e[64]=ne):ne=e[64];let V;return e[65]!==D||e[66]!==ne?(V=n.jsxs(xr,{children:[D,ne]}),e[65]=D,e[66]=ne,e[67]=V):V=e[67],V},Sb=c.memo(vb);function kb(t){return t.selectedAppId}function jb(t){return t.availableApps}function Cb(t){return t.isCacheStale}function Tb(t){return t.isScanning}function Nb(t){return t.initialize}function Eb(t){return t.loadInstalledApps}function Pb(t){return t.selectApp}function Ib(t){return t.id===fx}const Hn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Rb=({projects:t,worktreesByProject:e,directory:s,activeProjectId:r})=>{const o=Hn(s??"");if(o){const i=gr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function Cd(){const t=Gt(w=>w.projects),e=Gt(w=>w.activeProjectId),s=nt(w=>w.availableWorktreesByProject),r=nt(w=>w.currentSessionId),o=Nm(r??null),i=nt(w=>r?w.worktreeMetadata.get(r)?.path??"":""),a=nt(w=>w.newSessionDraft?.open?Hn(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),d=nt(w=>w.newSessionDraft?.open?w.newSessionDraft.target==="chat":null),u=c.useMemo(()=>Hn(i||""),[i]),l=c.useMemo(()=>Hn(o||""),[o]),f=u||l||a,m=c.useMemo(()=>Rb({projects:t,worktreesByProject:s,directory:f,activeProjectId:e}),[e,f,t,s]),p=c.useMemo(()=>Hn(f||m?.path||""),[f,m?.path]),h=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),x=d??so(l),g=c.useRef(null);return c.useEffect(()=>{h&&p&&!x&&(g.current={projectRef:h,directory:p})},[p,h,x]),c.useMemo(()=>x?null:h&&p?{projectRef:h,directory:p}:g.current,[h,p,x])}const Db=t=>{const e=Ue.c(67),{buttonClassName:s}=t,{t:r}=lt(),o=jd(),i=K(Mb),[a,d]=c.useState(!1),u=K(Fb);let l;e[0]!==u?(l=ws(Ws("open_project_actions",u),""),e[0]=u,e[1]=l):l=e[1];const f=l,m=o?.available?o.shown:null;let p;e[2]!==o||e[3]!==m?(p=m&&o?o.runOf(m):null,e[2]=o,e[3]=m,e[4]=p):p=e[4];const h=p;yb(!0);let x;e[5]!==h?(x=ne=>h?ne.getDirectoryState(h.directory)?.tabs.find(V=>V.id===h.tabId)?.previewUrl??null:null,e[5]=h,e[6]=x):x=e[6];const g=yt(x);if(!o||!m)return null;let w;e[7]!==m.name||e[8]!==h||e[9]!==r?(w=h?r("projectActions.actions.stopNamedAria",{name:m.name}):r("projectActions.actions.runNamedAria",{name:m.name}),e[7]=m.name,e[8]=h,e[9]=r,e[10]=w):w=e[10];const b=w;let j;e[11]!==s||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(j=h&&g?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:s,"aria-label":r("projectActions.actions.openPreview"),children:n.jsx(ce,{name:"global",className:"size-4"})})}),n.jsx(jt,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=s,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=j):j=e[16];let y;e[17]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"inline-flex"}),e[17]=y):y=e[17];let E;e[18]!==o||e[19]!==m?(E=()=>o.toggle(m),e[18]=o,e[19]=m,e[20]=E):E=e[20];const A=o.isLoading||h?.status==="stopping",R=a&&"text-foreground";let _;e[21]!==s||e[22]!==R?(_=Ze(s,R),e[21]=s,e[22]=R,e[23]=_):_=e[23];let L;e[24]!==m||e[25]!==h?(L=h?n.jsx(Za,{run:h,large:!0}):n.jsx(ce,{name:ya(m),className:"size-4"}),e[24]=m,e[25]=h,e[26]=L):L=e[26];let v;e[27]!==b||e[28]!==_||e[29]!==L||e[30]!==E||e[31]!==A?(v=n.jsx(ao,{render:y,children:n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:E,disabled:A,className:_,"aria-label":b,children:L})})}),e[27]=b,e[28]=_,e[29]=L,e[30]=E,e[31]=A,e[32]=v):v=e[32];let C;e[33]!==b?(C=n.jsx("span",{children:b}),e[33]=b,e[34]=C):C=e[34];let S;e[35]!==r?(S=r("projectActions.header.allActions"),e[35]=r,e[36]=S):S=e[36];let k;e[37]!==f||e[38]!==S?(k=n.jsx("span",{className:"typography-micro text-muted-foreground",children:n.jsx(Us,{label:S,shortcut:f})}),e[37]=f,e[38]=S,e[39]=k):k=e[39];let N;e[40]!==C||e[41]!==k?(N=n.jsx(jt,{side:"bottom",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[C,k]})}),e[40]=C,e[41]=k,e[42]=N):N=e[42];let $;e[43]!==v||e[44]!==N?($=n.jsxs(kt,{children:[v,N]}),e[43]=v,e[44]=N,e[45]=$):$=e[45];const B=o.openSettings;let D;e[46]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(ce,{name:"add",className:"h-4 w-4"}),e[46]=D):D=e[46];let W;e[47]!==r?(W=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=W):W=e[48];let H;e[49]!==W?(H=n.jsx("span",{className:"typography-ui-label text-foreground",children:W}),e[49]=W,e[50]=H):H=e[50];let U;e[51]!==o.openSettings||e[52]!==H?(U=n.jsxs(vs,{className:"flex items-center gap-2",onClick:B,children:[D,H]}),e[51]=o.openSettings,e[52]=H,e[53]=U):U=e[53];let se;e[54]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(Cn,{}),e[54]=se):se=e[54];let z;e[55]!==o||e[56]!==r?(z=o.actions.map(ne=>n.jsxs(vs,{className:"flex items-center gap-2",onClick:()=>{o.select(ne),o.toggle(ne)},children:[n.jsx(ce,{name:ya(ne),className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ne.name}),ne.source==="shared"?n.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,n.jsx(Za,{run:o.runOf(ne),className:"ms-auto"})]},ne.id)),e[55]=o,e[56]=r,e[57]=z):z=e[57];let Q;e[58]!==U||e[59]!==z?(Q=n.jsxs(br,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[U,se,z]}),e[58]=U,e[59]=z,e[60]=Q):Q=e[60];let ie;e[61]!==$||e[62]!==Q?(ie=n.jsxs(xr,{onOpenChange:d,children:[$,Q]}),e[61]=$,e[62]=Q,e[63]=ie):ie=e[63];let O;return e[64]!==ie||e[65]!==j?(O=n.jsxs(n.Fragment,{children:[j,ie]}),e[64]=ie,e[65]=j,e[66]=O):O=e[66],O},_b=c.memo(Db),Ab=t=>{const e=Ue.c(8),{buttonClassName:s}=t,r=Cd();if(!r)return null;let o;e[0]!==s||e[1]!==r.directory?(o=n.jsx(Sb,{directory:r.directory,buttonClassName:s}),e[0]=s,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==s?(i=n.jsx(_b,{buttonClassName:s}),e[3]=s,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=n.jsxs(n.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},Ob=c.memo(Ab);function Mb(t){return t.openContextPreview}function Fb(t){return t.shortcutOverrides}const Bo="--oc-titlebar-controls-width",pi=new Set;let Gn=null;const Td=t=>{Gn===null?t.style.removeProperty(Bo):t.style.getPropertyValue(Bo)!==Gn&&t.style.setProperty(Bo,Gn)},Lb=t=>{const e=`${Math.round(t)}px`;e!==Gn&&(Gn=e,pi.forEach(Td))},Nd=t=>{if(t)return pi.add(t),Td(t),()=>{pi.delete(t)}},Bn="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",$n=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Bb=()=>{Fu("ui.header.render");const{t,direction:e}=lt(),s=K(X=>X.isSidebarOpen),r=lo(),o=K(X=>X.sessionTabsEnabled),i=nt(X=>!!X.newSessionDraft?.open),a=nt(X=>X.currentSessionId),d=ts(ci(c.useCallback(X=>{if(!a)return null;const ot=[...X.activeSessions,...X.archivedSessions].find(_t=>_t.id===a);if(!ot)return null;const xt=ot;return{title:ot.title??null,directory:xt.directory??null,created:ot.time?.created??null,slug:xt.slug??null}},[a]))),u=Gt(ci(X=>{if(!X.activeProjectId)return null;const ot=X.projects.find(xt=>xt.id===X.activeProjectId);return ot?{id:ot.id,path:ot.path,label:ot.label}:null})),l=c.useMemo(()=>{if(!u)return null;const X=u.label?.trim();if(X)return X;const ot=u.path.split(/[\\/]/).filter(Boolean);return ot[ot.length-1]??null},[u]),{isMobile:f}=hn(),m=c.useRef(null),[p,h]=c.useState(()=>typeof window>"u"?!1:Ps()),x=c.useMemo(()=>Br(),[]),g=Em(),[w,b]=c.useState(!1),j=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:y,side:E}=ud(),A=c.useMemo(()=>{if(typeof window>"u")return null;const X=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X;if(typeof navigator>"u")return null;const ot=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ot)return null;const xt=Number.parseInt(ot[1],10),_t=Number.parseInt(ot[2],10);return Number.isNaN(xt)?null:xt===10?_t:xt},[]);$t.useEffect(()=>{typeof window>"u"||h(Ps())},[]);const R=c.useMemo(()=>pr(),[]),_=K(X=>X.shortcutOverrides),L=K(X=>X.workStatusPanelVisible),v=K(X=>X.workStatusPanelEnabled),C=K(X=>X.setWorkStatusPanelEnabled),S=K(X=>X.workStatusPanelFits),k=K(X=>X.workStatusOverlayOpen),N=K(X=>X.setWorkStatusOverlayOpen),B=v&&S||k,D=c.useCallback(()=>{if(v&&!S){N(!k);return}C(!v)},[N,C,k,v,S]),W=a?d??null:null,H=c.useRef(null),[U,se]=c.useState(0);c.useEffect(()=>{if(!a){H.current&&(H.current=null,se(_t=>_t+1));return}if(W){H.current={sessionId:a,session:W,expiresAt:Date.now()+2e3};return}const X=H.current;if(!X||X.sessionId!==a)return;const ot=X.expiresAt-Date.now();if(ot<=0){H.current=null,se(_t=>_t+1);return}const xt=window.setTimeout(()=>{H.current?.sessionId===a&&(H.current=null),se(_t=>_t+1)},ot);return()=>{window.clearTimeout(xt)}},[a,W]);const z=(()=>{if(W)return W;if(!a)return null;const X=H.current;return X&&X.sessionId===a&&X.expiresAt>Date.now()?X.session:null})(),Q=nt(X=>a?X.worktreeMetadata.get(a)?.path??"":""),ie=nt(X=>a?X.worktreeMetadata.get(a)?.branch?.trim()??null:null),O=Ec(X=>a?X.getAttachment(a):void 0),ne=c.useMemo(()=>O?Pm(O,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,O]),V=c.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]),J=c.useMemo(()=>$n(Q||""),[Q]),F=c.useMemo(()=>{const X=typeof z?.directory=="string"?z.directory:"";return $n(X||"")},[z?.directory]),re=cc(a??"",F),q=nt(X=>X.newSessionDraft?.open?$n(X.newSessionDraft.bootstrapPendingDirectory??X.newSessionDraft.directoryOverride??""):""),ge=nt(X=>X.newSessionDraft.target),Z=nt(X=>X.newSessionDraft.selectedProjectId),de=nt(X=>X.currentSessionDirectory),Se=zt(X=>X.homeDirectory),ue=wr(),ke=c.useMemo(()=>J||F||(co(ue,q)??""),[q,ue,F,J]),Me=nt(X=>{const ot=$n(J||F||"");if(!ot)return null;for(const xt of X.availableWorktreesByProject.values()){const te=Wr(xt,ot)?.branch?.trim();if(te)return te}return null}),Le=Im(ke||null)||ie||Me,Ve=i?ge==="chat":Zl(F||de,Se),Ne=!Ve&&!L&&!!(l||Le||!i&&V),me=c.useMemo(()=>{if(!a)return l??"OpenChamber";const X=z?.title?.trim();return X&&X.length>0?X:"Untitled Session"},[l,z?.title,a]),ye=nt(X=>X.updateSessionTitle),je=nt(X=>X.archiveSessions),Be=nt(X=>X.deleteSessions),[_e,Ie]=c.useState(!1),[tt,Ke]=c.useState(!1),ze=c.useRef(null),[rt,ve]=c.useState(""),[M,Ce]=c.useState(null),He=$f(),[Xe,G]=c.useState(null),Ee=ts(X=>Xe&&X.entityById.get(Xe)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Pe=c.useRef(null),Fe=c.useRef(!1);Fe.current=_e;const Te=c.useCallback(()=>{a&&(Fe.current=!0,ve(z?.title?.trim()||me),Ie(!0))},[z?.title,a,me]),Ae=c.useRef(Te);Ae.current=Te;const qe=c.useCallback(X=>{X&&(X.focus(),X.select())},[]);c.useEffect(()=>{if(Ke(!1),G(null),a&&ze.current===a){ze.current=null,Ae.current();return}Ie(!1),ve("")},[a]);const Ge=c.useCallback(async()=>{if(!a)return;const X=rt.trim();X&&X!==z?.title?.trim()&&await ye(a,X),Ie(!1)},[z?.title,a,rt,ye]);c.useEffect(()=>{if(!_e)return;const X=ot=>{const xt=ot.target;(!xt||!Pe.current?.contains(xt))&&Ge()};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[_e,Ge]);const Je=c.useCallback(async(X,ot)=>{const xt=[ot,...Rm(ot,[],X==="delete")],_t=nt.getState().currentSessionId===ot?ot:null;if(X==="delete"){const{failedIds:gt}=await Be(xt);gt.length>0?Oe.error(t("sessions.sidebar.session.delete.error")):Oe.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:te,failedIds:Qe}=await je(xt);if(Qe.length>0){Oe.error(t("sessions.sidebar.session.archive.error"));return}Oe.success(t("sessions.sidebar.session.archive.success"),Dm(te,_t,t))},[je,Be,t]),st=c.useCallback(async()=>{Xe&&(G(null),await Je("delete",Xe))},[Xe,Je]),mt=K(X=>X.openGuestPageId),Y=tr(X=>X.guests.find(ot=>ot.id===mt)),fe=K(X=>X.isScheduledTasksDialogOpen),Re=K(X=>X.isArchivePageOpen),T=K(X=>X.isIntegrationsCatalogOpen),ae=K(X=>X.isUsageStatsPageOpen),pe=K(X=>X.isSourceBoardOpen),oe=K(X=>X.isOverviewOpen),be=K(X=>X.worktreesPageProjectId),$e=K(X=>X.isolatedSpacesEnabled?X.spacesPageProjectId:null),De=K(X=>X.runOverviewKey),ee=zf(De),le=be??$e,et=Gt(X=>{if(!le)return null;const ot=X.projects.find(xt=>xt.id===le);return ot?.label?.trim()||ot?.path?.split("/").pop()||null}),xe=c.useMemo(()=>Y?{title:Y.pageTitle??Y.name,subtitle:null}:fe?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Re?{title:t("sessions.archivePage.title"),subtitle:null}:T?{title:t("integrationsCatalog.page.title"),subtitle:null}:ae?{title:t("usageStats.title"),subtitle:null}:pe?{title:t("sourceBoard.title"),subtitle:null}:oe?{title:t("overview.title"),subtitle:null}:be?{title:t("sessions.worktreesPage.title",{project:et??""}),subtitle:null}:$e?{title:t("spaces.page.title",{project:et??""}),subtitle:null}:De?{title:ee??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Y,Re,T,ee,De,fe,pe,oe,ae,$e,et,t,be]),bt=c.useCallback(()=>{Ys("desktop_open_draft_mini_chat_window",{directory:Ve?"":q,projectId:Ve?null:Z,...Qo()}).catch(X=>{console.warn("[header] failed to open draft mini chat window",X)})},[q,Z,Ve]),Tt=c.useCallback(()=>{if(i){bt();return}a&&Ys("desktop_open_session_mini_chat_window",{sessionId:a,directory:F||$n(de||"")||J,...Qo()}).catch(X=>{console.warn("[header] failed to open session mini chat window",X)})},[a,bt,i,de,F,J]),vt=x&&(i||!!a),Rt=Bn,Ye=c.useMemo(()=>p&&j&&!w?"88px":g?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||y)&&!R?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,w,j,g,R,y]),ft=(!p||y)&&!R?"calc(0.625rem + var(--oc-wco-right-inset, 0px))":"0.625rem",Nt=e==="rtl",ht=Nt?ft:Ye,Ct=Nt?Ye:ft,pt=y&&E!==Yl(e);$t.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",ht)},[ht]);const It=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",Ht=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";$t.useEffect(()=>{if(!p||!j){b(!1);return}let X=!1;const ot=async()=>{try{const _t=await Ys("desktop_is_window_fullscreen");X||b(_t===!0)}catch{X||b(!1)}},xt=()=>{ot()};return ot(),window.addEventListener("openchamber:window-resized",xt),()=>{X=!0,window.removeEventListener("openchamber:window-resized",xt)}},[p,j]);const dt=c.useMemo(()=>!p||!j||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[p,j,A]),ct=c.useMemo(()=>p&&j&&!w?A!==null&&A<=15?"56px":"44px":"0px",[p,w,j,A]),Mt=c.useMemo(()=>{const ot=`max(${p&&j?"2.75rem":"3rem"}, ${ct}, var(--oc-wco-titlebar-height, 0px))`,xt=p&&!y||R;if(xt&&ct==="0px")return{};const _t={minHeight:ot,height:ot};return!pt&&(!xt||Nt)&&(_t.paddingInlineEnd=Ct),_t},[pt,p,j,Nt,R,Ct,ct,y]),Wt=c.useRef(null),Zt=c.useCallback(X=>{!X||X===Wt.current||(Wt.current=X,document.documentElement.style.setProperty("--oc-header-height",`${X}px`))},[]),Kt=c.useCallback(()=>{typeof document>"u"||Zt(m.current?.getBoundingClientRect().height)},[Zt]);$t.useEffect(()=>{if(typeof window>"u")return;Kt();const X=m.current;if(!X||typeof ResizeObserver>"u")return()=>{};let ot=0;const xt=()=>{ot||(ot=requestAnimationFrame(()=>{ot=0,Kt()}))},_t=new ResizeObserver(te=>{const Qe=te[te.length-1];Zt(Qe?.borderBoxSize?.[0]?.blockSize??Qe?.target.getBoundingClientRect().height)});return _t.observe(X),window.addEventListener("resize",xt),window.addEventListener("orientationchange",xt),()=>{ot&&cancelAnimationFrame(ot),_t.disconnect(),window.removeEventListener("resize",xt),window.removeEventListener("orientationchange",xt)}},[Zt,Kt]),$t.useEffect(()=>{Kt()},[Kt,f,dt]);const ls=c.useCallback(async X=>{const ot=X.target;ot.closest(".app-region-no-drag")||ot.closest("button, a, input, select, textarea")||X.button===0&&p&&await Lu()},[p]);Pc({rename_current_session:()=>{if(!a||f)return!1;Te()},archive_current_session:()=>{if(!a||f||ts.getState().entityById.get(a)?.time.archived)return!1;Je("archive",a)}});const Ut=c.useCallback((X,ot)=>{Ce({sessionId:X,directory:ot})},[]),Qt=He.requestExport,cs=c.useCallback(({session:X,open:ot,isActive:xt,select:_t,closeOtherTabs:te,components:Qe})=>{const{Item:gt,Separator:wt}=Qe;return n.jsxs(n.Fragment,{children:[n.jsx(Wf,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(gt,{onClick:te,className:"[&>svg]:me-1",children:[n.jsx(ce,{name:"close-circle",className:"me-1 h-4 w-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(wt,{}),n.jsx(Ka,{sessionId:X.id,open:ot,slots:Qe,onRename:()=>{xt||_t(),ze.current=X.id},onExport:Qt,onMoveSession:Ut,onArchive:()=>{Je("archive",X.id)},onDelete:()=>G(X.id)})]})},[Qt,Ut,Je,t]),js=()=>n.jsxs("div",{onMouseDown:ls,className:Ze("app-region-drag relative flex h-12 select-none items-center",pt?"pe-0":"pe-2.5",dt),style:Mt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:It,transitionDuration:`${r}ms`,transitionTimingFunction:In}}),n.jsx("div",{ref:Nd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Ht,transitionDuration:`${r}ms`,transitionTimingFunction:In}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[xe?n.jsxs(n.Fragment,{children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{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:()=>K.getState().closeMainSurfaces(),children:n.jsx(ce,{name:"arrow-left",className:"size-4"})})}),n.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:xe.title}),xe.subtitle?n.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:xe.subtitle}):null]})]}):R||!o?n.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:[re?n.jsx(ce,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsxs(kt,{children:[n.jsx(sx,{align:"start",children:n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:Rt,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(ce,{name:"history",className:"h-4 w-4"})})})}),n.jsx(jt,{side:"bottom",children:n.jsx(Us,{label:t("sessions.switcher.openAria"),shortcut:ws(Ws("open_session_list",_),"")})})]}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[_e?n.jsxs("form",{ref:Pe,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Ge()},children:[n.jsx("input",{ref:qe,value:rt,onChange:X=>ve(X.target.value),onKeyDown:X=>va(X,()=>Ie(!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"}),n.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:n.jsx(ce,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Ie(!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:n.jsx(ce,{name:"close",className:"size-4"})})]}):i?null:n.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:me}),Ne?n.jsxs("span",{className:Ze("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:[l?n.jsx("span",{dir:"auto",className:"truncate",children:l}):null,Le?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(ce,{name:"git-branch",className:Ze("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{dir:"ltr",className:Ze("truncate",i&&"text-muted-foreground"),children:Le})]}):null,!i&&V?n.jsxs("span",{className:Ze("inline-flex min-w-0 items-center gap-0.5",V==="attention"||V==="invalid"||V==="missing"?"text-status-warning":"text-muted-foreground"),children:[n.jsx(ce,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:ne})]}):null]}):null]}),n.jsx("div",{className:Ze("flex h-[1.125rem] shrink-0 items-center justify-center",Ne?"self-start":"self-center"),children:a&&!i&&!_e?n.jsxs(fn,{open:tt,onOpenChange:Ke,onOpenChangeComplete:X=>{!X&&ze.current&&ze.current===a&&(ze.current=null,Te())},children:[n.jsx(pn,{asChild:!0,children:n.jsx(ut,{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:n.jsx(ce,{name:"more",className:"size-4"})})}),n.jsx(mn,{align:"end",className:"min-w-[190px]",children:n.jsx(Ka,{sessionId:a,open:tt,slots:Uf,onRename:()=>{ze.current=a},onExport:Qt,onMoveSession:Ut,onArchive:()=>{Je("archive",a)},onDelete:()=>G(a)})})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(Rx,{renderMenu:cs,suppressActiveTabControls:_e,menuReturnsFocus:()=>!Fe.current,onMenuOpenChangeComplete:X=>{!X&&ze.current&&ze.current===a&&(ze.current=null,Te())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:_e?n.jsxs("form",{ref:Pe,"data-session-rename-form":"header",className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:X=>X.stopPropagation(),onSubmit:X=>{X.preventDefault(),Ge()},children:[n.jsx("input",{ref:qe,value:rt,onChange:X=>ve(X.target.value),onKeyDown:X=>va(X,()=>Ie(!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"}),n.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:n.jsx(ce,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Ie(!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:n.jsx(ce,{name:"close",className:"size-4"})})]}):n.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"):me})})})}),xe||R||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!R&&!xe?n.jsxs(n.Fragment,{children:[n.jsx(xb,{buttonClassName:Bn}),n.jsx(Ob,{buttonClassName:Bn})]}):null,vt?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Tt,className:Bn,children:n.jsx(ce,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(jt,{side:"bottom",children:n.jsx(Us,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?ws(Ws("new_mini_chat",_),""):void 0})})]}):null,R?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":B,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:D,className:Ze(Bn,B&&"oc-selected text-interactive-selection-foreground hover:text-interactive-selection-foreground"),children:n.jsx(ce,{name:"panel-card",className:"h-4 w-4"})})}),n.jsx(jt,{side:"bottom",children:t(v&&!S?k?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":v?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),n.jsx(fd,{visible:pt,position:E})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:js()}),M?n.jsx(_m,{open:!0,onOpenChange:X=>{X||Ce(null)},sessionId:M.sessionId,sourceDirectory:M.directory}):null,He.dialog,n.jsx(sr,{open:Xe!==null,onOpenChange:X=>{X||G(null)},children:n.jsxs(nr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(rr,{children:[n.jsx(or,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),n.jsx(ir,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Ee})})]}),n.jsxs(Ur,{children:[n.jsx(ut,{variant:"outline",size:"sm",onClick:()=>G(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{st()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},Xa=280,Ya=264,Ja=500,$b=({isOpen:t,isMobile:e,children:s,className:r,topBar:o,peek:i})=>{const{t:a,direction:d}=lt(),u=K(z=>z.sidebarWidth),l=K(z=>z.setSidebarWidth),[f,m]=c.useState(!1),p=c.useRef(0),h=c.useRef(u||Xa),x=c.useRef(null),g=c.useRef(null),w=c.useRef(null),b=c.useRef(null),j=c.useRef(null),y=c.useCallback(z=>Math.min(Ja,Math.max(Ya,z)),[]),E=c.useCallback(()=>{const z=j.current;if(z?.isConnected)return z;const Q=document.querySelector("[data-titlebar-left-controls]");return j.current=Q,Q},[]),A=c.useCallback(z=>{const Q=b.current;if(!Q)return;Q.style.width=`${z}px`,Q.style.minWidth=`${z}px`,Q.style.maxWidth=`${z}px`,Q.style.setProperty("--oc-left-sidebar-width",`${z}px`);const ie=E();ie&&ie.style.setProperty("--oc-left-sidebar-width",`${z}px`)},[E]);c.useEffect(()=>{e&&f&&m(!1)},[e,f]),c.useEffect(()=>{f||(x.current=null,g.current=null,w.current?.(),w.current=null)},[f]),c.useEffect(()=>{!t&&f&&m(!1)},[t,f]),c.useEffect(()=>()=>{w.current?.(),w.current=null},[]);const R=Math.min(Ja,Math.max(Ya,u||Xa)),_=t?R:0,L=f?x.current??_:_,v=f?L:R;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${v}px`);const z=j.current;!f&&z&&z.style.removeProperty("--oc-left-sidebar-width")},[v,f]);const[C,S]=c.useState(!t);t&&C&&S(!1);const k=lo(),N=c.useRef(t),$=c.useRef(t);if(c.useLayoutEffect(()=>{N.current=t,$.current!==t&&($.current=t,Ic(k),t||Fi(()=>{N.current||S(!0)}))},[t,k]),e)return null;const B=z=>{if(t){try{z.currentTarget.setPointerCapture(z.pointerId)}catch{}g.current=z.pointerId,m(!0),p.current=z.clientX,h.current=_,x.current=_,A(_),w.current?.(),w.current=Rc(),z.preventDefault()}},D=z=>{if(e||!f||g.current!==z.pointerId)return;const Q=(z.clientX-p.current)*(d==="rtl"?-1:1),ie=y(h.current+Q);x.current!==ie&&(x.current=ie,A(ie))},W=z=>{if(g.current!==z.pointerId||e)return;try{z.currentTarget.releasePointerCapture(z.pointerId)}catch{}const Q=y(x.current??_);g.current=null,x.current=null,m(!1),l(Q),w.current?.(),w.current=null},H=!t&&i?i.state:!1,U=H!==!1,se=U&&i&&i.animationMs>0?`${H==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${In} forwards`:void 0;return n.jsxs("div",{ref:b,"data-left-sidebar":"",className:Ze("relative flex h-full",!U&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${L}px`,minWidth:`${L}px`,maxWidth:`${L}px`,"--oc-left-sidebar-width":`${v}px`,overflowX:U?void 0:"clip",transitionDuration:`${k}ms`,transitionTimingFunction:In},children:[t&&n.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&&n.jsx("div",{className:Ze("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:B,onPointerMove:D,onPointerUp:W,onPointerCancel:W,onLostPointerCapture:W,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":U?H:void 0,className:Ze("flex h-full shrink-0 flex-col",U?"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&&!U&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${k}ms`,overflowX:"hidden",contentVisibility:C&&!U?"hidden":void 0,animation:se,"--oc-peek-offset":d==="rtl"?"100%":"-100%"},inert:!t&&!U||void 0,onPointerEnter:U?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:U?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:U?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,n.jsx(as,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(Xt,{children:s})})]})]})},zb=t=>{const e=Ue.c(5),{actionsSlotRef:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={height:"var(--oc-header-height, 3rem)"},e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{"aria-hidden":!0,className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{"aria-hidden":!0,ref:Nd,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),e[2]=i):i=e[2];let a;return e[3]!==s?(a=n.jsxs("div",{className:"flex shrink-0",style:r,children:[o,i,n.jsx("div",{className:"app-region-drag flex min-w-0 flex-1 items-center justify-end",children:n.jsx("div",{ref:s,className:"app-region-no-drag flex items-center"})})]}),e[3]=s,e[4]=a):a=e[4],a},Wb=50,Ub=18,Vb=300,Hb='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',Ed=t=>!document.getElementById("root")?.contains(t),Kb=t=>{if((to(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Ub)return!1;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},Qa=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(Hb)).some(s=>Ed(s)&&s.getClientRects().length>0)},qb=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=c.useState(!1),o=Am()?0:e,i=o>0,a=c.useRef(null),d=c.useRef(null),u=c.useRef(null),l=c.useCallback(()=>{d.current!==null&&clearTimeout(d.current),u.current!==null&&clearTimeout(u.current),d.current=null,u.current=null},[]),f=c.useCallback(()=>{l(),r(x=>x==="in"&&i?"out":!1)},[i,l]),m=c.useCallback(()=>{u.current!==null&&clearTimeout(u.current),u.current=setTimeout(()=>{if(u.current=null,Qa(a.current)){m();return}f()},Vb)},[f]),p=c.useCallback(()=>{u.current!==null&&clearTimeout(u.current),u.current=null},[]);c.useEffect(()=>{t||(l(),r(!1))},[l,t]),c.useEffect(()=>l,[l]),c.useEffect(()=>{if(s!=="in")return;const x=b=>{const j=b.target;j instanceof Element&&(a.current?.contains(j)||Ed(j)||f())},g=b=>{Dc(b)||b.key!=="Escape"||b.defaultPrevented||Qa(a.current)||f()},w=b=>{b.relatedTarget===null&&m()};return document.addEventListener("pointerdown",x,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",w),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",w)}},[f,m,s]),c.useEffect(()=>{if(!t||s!==!1)return;const x=()=>{d.current!==null&&clearTimeout(d.current),d.current=null},g=b=>{if(b.pointerType!=="mouse"||b.buttons!==0||!Kb(b)){x();return}d.current===null&&(d.current=setTimeout(()=>{d.current=null,r("in")},Wb))},w=b=>{b.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",w),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",w),x()}},[t,s]);const h=c.useMemo(()=>({onPointerEnter:()=>{p(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{s==="in"&&m()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?!1:g)}}),[p,m,s]);return{state:t?s:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},$o="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",Gb=()=>{const t=Ue.c(46),{t:e,locale:s,direction:r}=lt(),o=K(Zb),i=K(Xb),a=K(Yb),d=c.useRef(null),u=ws(Ws("toggle_sidebar",a)),l=Jb,f=K(Qb),{usesFramelessChrome:m,side:p}=ud();let h;t[0]!==s?(h=Q=>{const ie=Q.currentTarget.getBoundingClientRect();Ys("desktop_show_app_menu",{x:ie.left,y:ie.bottom,locale:s}).catch(ew)},t[0]=s,t[1]=h):h=t[1];const x=h;let g,w;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const Q=d.current;if(!Q)return;const ie=()=>{const ne=Math.max(Q.getBoundingClientRect().width,Q.scrollWidth);Lb(ne)};if(ie(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(ie);return O.observe(Q),()=>{O.disconnect()}},w=[],t[2]=g,t[3]=w):(g=t[2],w=t[3]),c.useEffect(g,w);const b="",j="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 E;t[4]!==y?(E={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:y},t[4]=y,t[5]=E):E=t[5];const A="flex min-w-0 items-center gap-2";let R;t[6]!==r||t[7]!==m||t[8]!==p?(R=m&&p===Yl(r)?n.jsx(fd,{visible:!0,position:p}):null,t[6]=r,t[7]=m,t[8]=p,t[9]=R):R=t[9];let _;t[10]!==x||t[11]!==e||t[12]!==m?(_=m?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:Ze($o,"shrink-0"),children:n.jsx(ce,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(jt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=m,t[13]=_):_=t[13];const L=kt;let v;t[14]!==e?(v=e("header.actions.openSessionsAria"),t[14]=e,t[15]=v):v=t[15];const C=i&&"text-foreground";let S;t[16]!==C?(S=Ze($o,"shrink-0",C),t[16]=C,t[17]=S):S=t[17];let k;t[18]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ce,{name:"panel-left",className:"h-4 w-4"}),t[18]=k):k=t[18];let N;t[19]!==i||t[20]!==v||t[21]!==S||t[22]!==o?(N=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":v,"aria-pressed":i,className:S,children:k})}),t[19]=i,t[20]=v,t[21]=S,t[22]=o,t[23]=N):N=t[23];const $=jt,B=e("header.actions.openSessionsWithShortcut",{shortcut:u});let D;t[24]!==B?(D=n.jsx("p",{children:B}),t[24]=B,t[25]=D):D=t[25];let W;t[26]!==$||t[27]!==D?(W=n.jsx($,{children:D}),t[26]=$,t[27]=D,t[28]=W):W=t[28];let H;t[29]!==L||t[30]!==N||t[31]!==W?(H=n.jsxs(L,{children:[N,W]}),t[29]=L,t[30]=N,t[31]=W,t[32]=H):H=t[32];let U;t[33]!==l||t[34]!==a||t[35]!==e||t[36]!==f?(U=f?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:l,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ze($o,"-ms-1 shrink-0"),children:n.jsx(ce,{name:"edit-box",className:"h-4 w-4"})})}),n.jsx(jt,{children:n.jsx(Us,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:ws(Ws("new_chat",a),"")})})]}),t[33]=l,t[34]=a,t[35]=e,t[36]=f,t[37]=U):U=t[37];let se;t[38]!==H||t[39]!==U||t[40]!==R||t[41]!==_?(se=n.jsxs("div",{ref:d,className:A,children:[R,_,H,U]}),t[38]=H,t[39]=U,t[40]=R,t[41]=_,t[42]=se):se=t[42];let z;return t[43]!==se||t[44]!==E?(z=n.jsx("div",{"data-titlebar-left-controls":b,className:j,style:E,children:se}),t[43]=se,t[44]=E,t[45]=z):z=t[45],z};function Zb(t){return t.toggleSidebar}function Xb(t){return t.isSidebarOpen}function Yb(t){return t.shortcutOverrides}function Jb(){K.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function Qb(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 ew(t){console.warn("[titlebar] failed to open app menu",t)}function tw(t,e,s){const r=Ue.c(5),[o,i]=c.useState();let a,d;return r[0]!==s||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let u=!1;return(async()=>{const[l,f]=await Promise.all([Om(t),Mm(t)]).catch(sw);if(u)return;const m=Jt(l),p=Jt(f);if(!m||!p||p===m)return;const h=s||"",x=p.split("/").filter(Boolean).pop()||p;i({source:"sdk",path:p,projectDirectory:m,branch:h,label:h||x,name:x,worktreeRoot:p,worktreeStatus:"ready",headState:h?"branch":"unborn",worktreeSource:"existing"})})(),()=>{u=!0}},d=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=a,r[4]=d):(a=r[3],d=r[4]),c.useEffect(a,d),e??o}function sw(){return["",""]}const nw=()=>{const t=Ue.c(3),e=K(rw),s=K(ow);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(!0)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function rw(t){return t.setSettingsDialogOpen}function ow(t){return t.setSettingsPage}const el="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-edge bg-muted/80",iw=({className:t,identity:e})=>{const{t:s}=lt(),{sourceControl:r}=ks(),o=Fm(e),i=Pi(e.provider),a=i.label,d=o?.status??null,u=un(b=>b.setStatus),[l,f]=c.useState(!1),m=c.useCallback(async b=>{if(!(!b||l)){f(!0);try{u(e,await r.authActivate(e,b))}catch(j){console.error("Failed to switch source control account:",j)}finally{f(!1)}}},[e,l,u,r]);if(d?.status!=="connected")return null;const p=d.user.username||null,h=d.user.avatarUrl??null,x=d.accounts,g=p?s("header.sourceControl.connectedWithLogin",{login:p,provider:a}):s("header.sourceControl.connected",{provider:a}),w=h?n.jsx("img",{src:h,alt:p?s("header.sourceControl.avatarWithLogin",{login:p}):s("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?n.jsx("div",{className:Ze(el,t),title:g,children:w}):n.jsxs(fn,{children:[n.jsx(pn,{asChild:!0,children:n.jsx("button",{type:"button",className:Ze(el,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:l,children:w})}),n.jsxs(mn,{align:"end",className:"w-64",children:[n.jsx(Dr,{className:"typography-ui-header font-semibold text-foreground",children:s("header.sourceControl.accountsTitle",{provider:a})}),n.jsx(qn,{}),x.map(b=>{const j=b.user,y=!!b.current,E=s(Lm(b.source??"oauth"));return n.jsxs($s,{className:"gap-2",disabled:l,onSelect:()=>{y||m(b.id)},children:[j?.avatarUrl?n.jsx("img",{src:j.avatarUrl,alt:j.username?s("header.sourceControl.avatarWithLogin",{login:j.username}):s("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-edge bg-muted",children:n.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:j?.name?.trim()||j.username||i.label}),j.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:j.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:E})]}):null]}),y?n.jsx(ce,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})},aw=t=>JSON.stringify(Bm(t)),lw=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},Pd=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function cw(t){if(!Pd(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function dw(t,e,s){const r=Ue.c(18),{sourceControl:o}=ks(),i=Pi(t.provider).features.referenceSearch,[a,d]=$t.useState(null);let u;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(u=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]=u):u=r[4];const l=u;let f;r[5]!==t||r[6]!==l||r[7]!==e||r[8]!==i||r[9]!==o?(f=()=>{if(!i)return;let p=!1;return o.references(t,{kind:"pull",query:`#${e}`}).then(h=>{if(p||!h.connected)return;const x=h.items.find(g=>g.kind==="pull"&&g.number===e);x&&d({key:l,pull:x})}).catch(uw),()=>{p=!0}},r[5]=t,r[6]=l,r[7]=e,r[8]=i,r[9]=o,r[10]=f):f=r[10];let m;return r[11]!==t||r[12]!==l||r[13]!==e||r[14]!==s||r[15]!==i||r[16]!==o?(m=[t,l,e,s,i,o],r[11]=t,r[12]=l,r[13]=e,r[14]=s,r[15]=i,r[16]=o,r[17]=m):m=r[17],$t.useEffect(f,m),a?.key===l?a.pull:null}function uw(){}const fw=t=>{const e=Ue.c(99),{directory:s,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:d}=ks(),u=Hs(),l=Gt(pw),[f,m]=$t.useState(0),[p,h]=$t.useState(!1),x=Li(),g=dw(r,o.number,f);let w;e[0]!==o?(w=$m(o),e[0]=o,e[1]=w):w=e[1];const b=w;let j;e[2]!==g||e[3]!==b?(j=g?{...b,labels:g.labels,commentCount:g.commentCount}:b,e[2]=g,e[3]=b,e[4]=j):j=e[4];const y=j,[E,A]=$t.useState(null),R=E?.number===o.number?E.sha:null,{detail:_,latest:L,refresh:v}=_c(s,y,!0,R),C=L.status==="ready"?L.value.pull:null,S=dc(y);let k;e[5]!==i||e[6]!==v?(k=()=>{v(),m(mw),i()},e[5]=i,e[6]=v,e[7]=k):k=e[7];const N=k,$=uc(y,r,N);let B;e[8]!==r||e[9]!==i||e[10]!==y.number||e[11]!==y.sourceRepo.owner||e[12]!==y.sourceRepo.repo||e[13]!==v||e[14]!==d?(B=async()=>{const M={owner:y.sourceRepo.owner,repo:y.sourceRepo.repo,number:y.number};await d.refreshProviderReads(r,{item:M}).catch(hw),Ac(M),m(gw),await Promise.all([v(),i()])},e[8]=r,e[9]=i,e[10]=y.number,e[11]=y.sourceRepo.owner,e[12]=y.sourceRepo.repo,e[13]=v,e[14]=d,e[15]=B):B=e[15];const D=B;let W;e[16]!==y?(W={source:"repository",reference:y},e[16]=y,e[17]=W):W=e[17];const H=W,U=u??s;let se;e[18]!==_||e[19]!==a?(se=_.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]=se):se=e[20];const z=se,Q=z.status==="ready"?z.value.pull?.stack??null:a??null,ie=Bi(),O=Gt(xw),ne=nt(bw),V=gr(O,ne,s),[J,F]=$t.useState(!1);let re;e[21]===Symbol.for("react.memo_cache_sentinel")?(re={status:"idle"},e[21]=re):re=e[21];const q=V?()=>F(!0):void 0,ge=C?.submitRequirements,Z=L.status==="error",de=o.mergeable??null;let Se;e[22]!==r||e[23]!==H||e[24]!==N||e[25]!==Q||e[26]!==Z||e[27]!==de||e[28]!==q||e[29]!==ge?(Se=n.jsx(Ai,{item:H,project:null,context:r,onStartWorktree:yw,onChanged:N,worktreeAvailable:!1,stack:Q,onStartOnTop:q,submitRequirements:ge,submitRequirementsUnreadable:Z,mergeable:de}),e[22]=r,e[23]=H,e[24]=N,e[25]=Q,e[26]=Z,e[27]=de,e[28]=q,e[29]=ge,e[30]=Se):Se=e[30];let ue;e[31]!==o.number||e[32]!==C||e[33]!==R?(ue=C?.revisions?{revisions:C.revisions,selected:R,onSelect:M=>A(M?{number:o.number,sha:M}:null)}:void 0,e[31]=o.number,e[32]=C,e[33]=R,e[34]=ue):ue=e[34];let ke;e[35]!==s||e[36]!==ie?(ke=M=>{ie(M.url,s)},e[35]=s,e[36]=ie,e[37]=ke):ke=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>h(!0),e[38]=Me):Me=e[38];let We;e[39]!==r||e[40]!==H||e[41]!==y.state||e[42]!==N?(We=y.state!=="merged"?n.jsx(fc,{item:H,context:r,onChanged:N}):void 0,e[39]=r,e[40]=H,e[41]=y.state,e[42]=N,e[43]=We):We=e[43];let Le;e[44]!==S.attachComment||e[45]!==S.attachComments?(Le={onAttach:S.attachComment,onAttachAll:S.attachComments},e[44]=S.attachComment,e[45]=S.attachComments,e[46]=Le):Le=e[46];let Ve;e[47]!==r||e[48]!==y||e[49]!==N?(Ve=n.jsx(hc,{reference:y,context:r,onChanged:N}),e[47]=r,e[48]=y,e[49]=N,e[50]=Ve):Ve=e[50];let Ne;e[51]!==r||e[52]!==_||e[53]!==y||e[54]!==N?(Ne=n.jsx(gc,{pull:y,detail:_,context:r,onChanged:N}),e[51]=r,e[52]=_,e[53]=y,e[54]=N,e[55]=Ne):Ne=e[55];const me=C?.voteLabels;let ye;e[56]!==C?.revisions?(ye=C?.revisions?.at(-1)?.sha,e[56]=C?.revisions,e[57]=ye):ye=e[57];const je=R===null;let Be;e[58]!==r||e[59]!==y||e[60]!==N||e[61]!==me||e[62]!==ye||e[63]!==je?(Be=n.jsx(pc,{reference:y,context:r,onRefresh:N,voteLabels:me,latestRevision:ye,onLatestRevision:je},y.number),e[58]=r,e[59]=y,e[60]=N,e[61]=me,e[62]=ye,e[63]=je,e[64]=Be):Be=e[64];const _e=l??"";let Ie;e[65]!==U||e[66]!==_e?(Ie={id:_e,path:U},e[65]=U,e[66]=_e,e[67]=Ie):Ie=e[67];let tt;e[68]!==r||e[69]!==U||e[70]!==y||e[71]!==R||e[72]!==Ie?(tt=n.jsx(xc,{pull:y,project:Ie,repository:null,context:r,projectOwnsDirectory:vw,currentDirectory:U,revision:R}),e[68]=r,e[69]=U,e[70]=y,e[71]=R,e[72]=Ie,e[73]=tt):tt=e[73];let Ke;e[74]!==s||e[75]!==H||e[76]!==x||e[77]!==D||e[78]!==z||e[79]!==Se||e[80]!==ue||e[81]!==ke||e[82]!==We||e[83]!==Le||e[84]!==Ve||e[85]!==Ne||e[86]!==Be||e[87]!==tt||e[88]!==$?(Ke=n.jsx($i,{item:H,directory:s,pullStatus:zi,trackerDetail:re,repositoryDetail:z,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:ww,now:x,footer:Se,revisionChoice:ue,onOpenStackLayer:ke,onOpenChecks:Me,onRefresh:D,stateMenu:We,commentAttachments:Le,threadActions:$,labelsControl:Ve,reviewersControl:Ne,reply:Be,pullLinks:tt}),e[74]=s,e[75]=H,e[76]=x,e[77]=D,e[78]=z,e[79]=Se,e[80]=ue,e[81]=ke,e[82]=We,e[83]=Le,e[84]=Ve,e[85]=Ne,e[86]=Be,e[87]=tt,e[88]=$,e[89]=Ke):Ke=e[89];let ze;e[90]!==S.attachFailedChecks||e[91]!==p||e[92]!==r||e[93]!==y?(ze=n.jsx(mc,{pull:y,context:r,open:p,onOpenChange:h,onAttachFailed:S.attachFailedChecks}),e[90]=S.attachFailedChecks,e[91]=p,e[92]=r,e[93]=y,e[94]=ze):ze=e[94];const rt=V?n.jsx(zm,{open:J,onOpenChange:F,project:{id:V.id,path:Vr(V.path)??V.path},initialSourceBranch:y.head,onWorktreeCreated:Sw}):null;let ve;return e[95]!==Ke||e[96]!==ze||e[97]!==rt?(ve=n.jsxs(n.Fragment,{children:[Ke,ze,rt]}),e[95]=Ke,e[96]=ze,e[97]=rt,e[98]=ve):ve=e[98],ve};function pw(t){return t.activeProjectId}function mw(t){return t+1}function hw(){}function gw(t){return t+1}function xw(t){return t.projects}function bw(t){return t.availableWorktreesByProject}function ww(){}function yw(){}function vw(){return!0}function Sw(t){nt.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const kw=/^Change-Id:\s*I[0-9a-f]{40}$/,jw=50,Cw=t=>(t.replace(/\r\n/g,`
|
|
3
3
|
`).trim().split(/\n[ \t]*\n/).at(-1)??"").split(`
|
|
4
4
|
`).some(r=>kw.test(r.trim())),Tw=t=>{const e=t[0]??null,s=t.filter(r=>!Cw(r.body));return{status:"ready",commits:t.length,subject:e?.message.trim()||null,tip:e?.hash??null,missing:s.length===0?"none":s.length===1&&s[0]===e?"tip":"many",missingCount:s.length}};function Nw(t,e,s,r,o){const i=Ue.c(15),[a,d]=c.useState(null);let u;i[0]!==e||i[1]!==s||i[2]!==t||i[3]!==o?(u=JSON.stringify([t,e,s,o]),i[0]=e,i[1]=s,i[2]=t,i[3]=o,i[4]=u):u=i[4];const l=u;let f,m;if(i[5]!==e||i[6]!==s||i[7]!==t||i[8]!==r||i[9]!==l?(f=()=>{if(!r||!t||!e||!s)return;let h=!1;return d({key:l,value:{status:"loading"}}),Oc(t,{from:e,to:s,maxCount:jw}).then(x=>{h||d({key:l,value:Tw(x.all)})}).catch(()=>{h||d({key:l,value:{status:"error"}})}),()=>{h=!0}},m=[e,s,t,r,l],i[5]=e,i[6]=s,i[7]=t,i[8]=r,i[9]=l,i[10]=f,i[11]=m):(f=i[10],m=i[11]),c.useEffect(f,m),!r)return null;let p;return i[12]!==l||i[13]!==a?(p=a?.key===l?a.value:{status:"loading"},i[12]=l,i[13]=a,i[14]=p):p=i[14],p}const Ew=t=>{const e=Ue.c(111),{preflight:s,topic:r,onTopicChange:o,hashtags:i,onHashtagsChange:a,wip:d,onWipChange:u,privateChange:l,onPrivateChange:f,onAddChangeId:m,disabled:p}=t,{t:h}=lt(),x=s?.status==="ready"?s:null;let g=null;if(x?.commits===0){let Z;e[0]!==h?(Z=h("gitView.change.push.nothingToPush"),e[0]=h,e[1]=Z):Z=e[1];let de;e[2]!==Z?(de=n.jsx("span",{className:"text-muted-foreground",children:Z}),e[2]=Z,e[3]=de):de=e[3],g=de}else if(x?.missing==="tip"){let Z;e[4]!==h?(Z=h("gitView.change.changeId.missingTip"),e[4]=h,e[5]=Z):Z=e[5];let de;e[6]!==Z?(de=n.jsx("span",{className:"min-w-0 flex-1 text-[var(--status-warning)]",children:Z}),e[6]=Z,e[7]=de):de=e[7];let Se;e[8]!==p||e[9]!==m||e[10]!==h?(Se=m?n.jsx(ns,{sideOffset:8,label:h("contextTooltips.git.addChangeId"),className:"shrink-0",children:n.jsx(ut,{size:"xs",variant:"outline",className:"shrink-0",onClick:m,disabled:p,children:h("gitView.change.changeId.add")})}):null,e[8]=p,e[9]=m,e[10]=h,e[11]=Se):Se=e[11];let ue;e[12]!==de||e[13]!==Se?(ue=n.jsxs(n.Fragment,{children:[de,Se]}),e[12]=de,e[13]=Se,e[14]=ue):ue=e[14],g=ue}else if(x?.missing==="many"){let Z;e[15]!==x.missingCount||e[16]!==h?(Z=h("gitView.change.changeId.missingMany",{count:x.missingCount}),e[15]=x.missingCount,e[16]=h,e[17]=Z):Z=e[17];let de;e[18]!==Z?(de=n.jsx("span",{className:"text-[var(--status-warning)]",children:Z}),e[18]=Z,e[19]=de):de=e[19],g=de}else if(s?.status==="error"){let Z;e[20]!==h?(Z=h("gitView.change.push.readFailed"),e[20]=h,e[21]=Z):Z=e[21];let de;e[22]!==Z?(de=n.jsx("span",{className:"text-[var(--status-error-text)]",children:Z}),e[22]=Z,e[23]=de):de=e[23],g=de}let w;e[24]!==h?(w=h("gitView.change.push.subject"),e[24]=h,e[25]=w):w=e[25];let b;e[26]!==w?(b=n.jsx("div",{className:"typography-micro text-muted-foreground",children:w}),e[26]=w,e[27]=b):b=e[27];const j=x?.subject??void 0;let y;e[28]!==s?.status||e[29]!==x?.subject?(y=x?.subject??(s?.status==="loading"?n.jsx(ce,{name:"loader-4",className:"size-3.5 animate-spin text-muted-foreground"}):null),e[28]=s?.status,e[29]=x?.subject,e[30]=y):y=e[30];let E;e[31]!==j||e[32]!==y?(E=n.jsx("div",{className:"min-h-5 truncate typography-ui-label text-foreground",title:j,children:y}),e[31]=j,e[32]=y,e[33]=E):E=e[33];let A;e[34]!==h?(A=h("gitView.change.push.subjectHint"),e[34]=h,e[35]=A):A=e[35];let R;e[36]!==A?(R=n.jsx("div",{className:"typography-micro text-muted-foreground",children:A}),e[36]=A,e[37]=R):R=e[37];let _;e[38]!==b||e[39]!==E||e[40]!==R?(_=n.jsxs("div",{className:"space-y-1",children:[b,E,R]}),e[38]=b,e[39]=E,e[40]=R,e[41]=_):_=e[41];let L;e[42]!==h?(L=h("gitView.change.push.topic"),e[42]=h,e[43]=L):L=e[43];let v;e[44]!==L?(v=n.jsx("div",{className:"typography-micro text-muted-foreground",children:L}),e[44]=L,e[45]=v):v=e[45];let C;e[46]!==o?(C=Z=>o(Z.target.value),e[46]=o,e[47]=C):C=e[47];let S;e[48]!==h?(S=h("gitView.change.push.optional"),e[48]=h,e[49]=S):S=e[49];let k;e[50]!==p||e[51]!==C||e[52]!==S||e[53]!==r?(k=n.jsx(Rn,{value:r,onChange:C,placeholder:S,disabled:p}),e[50]=p,e[51]=C,e[52]=S,e[53]=r,e[54]=k):k=e[54];let N;e[55]!==v||e[56]!==k?(N=n.jsxs("label",{className:"space-y-1",children:[v,k]}),e[55]=v,e[56]=k,e[57]=N):N=e[57];let $;e[58]!==h?($=h("gitView.change.push.hashtags"),e[58]=h,e[59]=$):$=e[59];let B;e[60]!==$?(B=n.jsx("div",{className:"typography-micro text-muted-foreground",children:$}),e[60]=$,e[61]=B):B=e[61];let D;e[62]!==a?(D=Z=>a(Z.target.value),e[62]=a,e[63]=D):D=e[63];let W;e[64]!==h?(W=h("gitView.change.push.hashtagsPlaceholder"),e[64]=h,e[65]=W):W=e[65];let H;e[66]!==p||e[67]!==i||e[68]!==D||e[69]!==W?(H=n.jsx(Rn,{value:i,onChange:D,placeholder:W,disabled:p}),e[66]=p,e[67]=i,e[68]=D,e[69]=W,e[70]=H):H=e[70];let U;e[71]!==B||e[72]!==H?(U=n.jsxs("label",{className:"space-y-1",children:[B,H]}),e[71]=B,e[72]=H,e[73]=U):U=e[73];let se;e[74]!==N||e[75]!==U?(se=n.jsxs("div",{className:"flex flex-col gap-3",children:[N,U]}),e[74]=N,e[75]=U,e[76]=se):se=e[76];let z;e[77]!==h?(z=h("gitView.change.push.wip"),e[77]=h,e[78]=z):z=e[78];let Q;e[79]!==p||e[80]!==u||e[81]!==z||e[82]!==d?(Q=n.jsx(ni,{checked:d,onChange:u,disabled:p,ariaLabel:z}),e[79]=p,e[80]=u,e[81]=z,e[82]=d,e[83]=Q):Q=e[83];let ie;e[84]!==h?(ie=h("gitView.change.push.wip"),e[84]=h,e[85]=ie):ie=e[85];let O;e[86]!==Q||e[87]!==ie?(O=n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[Q,ie]}),e[86]=Q,e[87]=ie,e[88]=O):O=e[88];let ne;e[89]!==h?(ne=h("gitView.change.push.private"),e[89]=h,e[90]=ne):ne=e[90];let V;e[91]!==p||e[92]!==f||e[93]!==l||e[94]!==ne?(V=n.jsx(ni,{checked:l,onChange:f,disabled:p,ariaLabel:ne}),e[91]=p,e[92]=f,e[93]=l,e[94]=ne,e[95]=V):V=e[95];let J;e[96]!==h?(J=h("gitView.change.push.private"),e[96]=h,e[97]=J):J=e[97];let F;e[98]!==V||e[99]!==J?(F=n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[V,J]}),e[98]=V,e[99]=J,e[100]=F):F=e[100];let re;e[101]!==O||e[102]!==F?(re=n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[O,F]}),e[101]=O,e[102]=F,e[103]=re):re=e[103];let q;e[104]!==g?(q=n.jsx("div",{className:"flex min-h-7 items-center gap-2 typography-micro",children:g}),e[104]=g,e[105]=q):q=e[105];let ge;return e[106]!==se||e[107]!==re||e[108]!==q||e[109]!==_?(ge=n.jsxs("div",{className:"flex flex-col gap-3",children:[_,se,re,q]}),e[106]=se,e[107]=re,e[108]=q,e[109]=_,e[110]=ge):ge=e[110],ge};function Pw(t,e){const{git:s,sourceControl:r}=ks(),{t:o}=lt(),i=Vf(),a=Hf({directory:t,branch:e,chooseContributor:i.choose}),d=Wm(t,s,r),u=async(p,h)=>{const x=d.start();if(!x)return Oe.info(o("gitView.pr.toast.gitBusy")),!1;try{return await h(x),x.isCurrent()}catch(g){if(g instanceof Um){if(g.code==="stale-runtime")return!1;const w=g.code==="review-option-invalid"?o("gitView.change.push.invalidOption"):a.errorMessage(g);return w?Oe.info(w):Oe.error(p),!1}return g instanceof Vm||g instanceof Hm?(Oe.error(p,{description:g.message||void 0}),!1):(Oe.error(p,{description:g instanceof Error?Gf(g,o):String(g)}),!1)}finally{x.finish()}},l=()=>u(o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")}),async p=>{await(await a.prepare("push",{onOperation:p.onOperation}))()}),f=p=>t?u(o("gitView.change.push.toast.failed"),async h=>{await Km({directory:t,git:s,sourceControl:r,review:p,onOperation:h.onOperation})}):Promise.resolve(!1),m=n.jsxs(n.Fragment,{children:[a.context?n.jsx(Kf,{context:a.context,onSelect:a.settle}):null,a.confirmDialog,n.jsx(qf,{candidates:i.candidates,onSelect:i.settle})]});return{push:l,pushForReview:f,dialogs:m}}const Iw=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"}},Rw=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=nt.getState(),o=s?r(s):null;!s||!o||Jt(o)!==Jt(t)||rh(s,o,oh({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},Dw=t=>{const e=t?.changeRequest??t?.pr;return e?ih({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},_w=[2e3,5e3];let tl=0;const Aw=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(tl+=1,`source-control-${Date.now().toString(36)}-${tl.toString(36)}`)},Ow=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),Id="openchamber:pr-create-as-draft:v1",sl=()=>{try{return localStorage.getItem(Id)==="true"}catch{return!1}},Mw=t=>{try{localStorage.setItem(Id,String(t))}catch{}},zo=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),qs=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):""},Fw=(t,e)=>{const s=qs(t);if(!s||s.includes("->"))return"";if(e){const o=`${e}/`;return s.startsWith(o)?s.slice(o.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},Lw=(t,e)=>`${t}::${e}`,Wo=new Map,nl=On;function Bw(t,e,s){const r=Ue.c(14);let o;r[0]!==s?(o=s?aw(s):null,r[0]=s,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[d,u]=c.useState(a);let l,f;r[3]!==i||r[4]!==t||r[5]!==s||r[6]!==e?(l=()=>{if(!t||!s||!i)return;let p=!1;return(async()=>{try{const h=await lw(e,s);p||u({contextKey:i,detectedUpstream:h.upstream,upstreamBranches:h.branches})}catch{}})(),()=>{p=!0}},f=[i,t,s,e],r[3]=i,r[4]=t,r[5]=s,r[6]=e,r[7]=l,r[8]=f):(l=r[7],f=r[8]),c.useEffect(l,f);let m;return r[9]!==i||r[10]!==d.contextKey||r[11]!==d.detectedUpstream||r[12]!==d.upstreamBranches?(m=d.contextKey===i?{detectedUpstream:d.detectedUpstream,upstreamBranches:d.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=d.contextKey,r[11]=d.detectedUpstream,r[12]=d.upstreamBranches,r[13]=m):m=r[13],m}const $w=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:a})=>{const{t:d}=lt(),u=Mc(t),l=Bu(),f=Jl(P=>P.byId),m=P=>f.has(P),p=l(u?.provider),h=p.terminology.changeRequest,x=p.features.createByPush,g=c.useCallback((P,we)=>d(Ls(P,h),we),[h,d]),w=nw(),{sourceControl:b,git:j}=ks(),y=Wi(),E=un(P=>P.entries),{isMobile:A,hasTouchInput:R,screenWidth:_}=hn(),L=K(P=>P.openContextSurface),v=qm(P=>P.requestTarget),C=!A&&_>=768&&!pr(),S=c.useMemo(()=>Lw(t,e),[t,e]),k=c.useMemo(()=>Wo.get(S)??null,[S]),N=hs(P=>P.ensureEntry),$=hs(P=>P.setParams),B=hs(P=>P.beginActiveContextsLoad),D=hs(P=>P.commitActiveContexts),W=hs(P=>P.releaseActiveContexts),H=c.useId(),U=hs(P=>P.startWatching),se=hs(P=>P.stopWatching),z=hs(P=>P.refresh),[Q,ie]=c.useState(()=>k?.title??zo(e)),[O,ne]=c.useState(()=>k?.body??""),[V,J]=c.useState(()=>k?.draft??sl()),[F,re]=c.useState(()=>k?.additionalContext??""),[q,ge]=c.useState(()=>k?.targetBaseBranchChosen===!0),[Z,de]=c.useState(()=>{const P=typeof k?.targetBaseBranch=="string"?qs(k.targetBaseBranch):"";return P||qs(s)}),Se=c.useCallback(P=>{ge(!0),de(P)},[]),[ue,ke]=c.useState(!1),[Me,We]=c.useState(!1),[Le,Ve]=c.useState(""),[Ne,me]=c.useState(""),[ye,je]=c.useState(!1),[Be,_e]=c.useState(0),[Ie,tt]=c.useState(!1),Ke=Fc(t,b),ze=Ke.scope.runtimeKey;c.useEffect(()=>{if(!t)return;const P=Ke.scope.runtimeKey,we=B(P,t,H),he=Ke.contexts.filter(at=>Pa(E[Un(at)],at).connected);return D(P,t,H,we,he),()=>{W(P,t,H)}},[B,Ke.contexts,Ke.scope.runtimeKey,D,t,W,E,H]);const ve=Ke.contexts[0]??null,M=hs(P=>{if(!ve||!Z)return null;const we=Gm(P.entries,ve,Z);if(!we||we.defaultBranch===Z)return null;const he=we.changeRequest??we.pr??null;return he?.state==="open"?he:null}),Ce=un(P=>u?P.entries[Un(u)]?.hasChecked===!0:!1),He=ve?.primaryRemote??null,Xe=c.useMemo(()=>ve?Un(ve):"",[ve]),G=un(P=>P.entries[Xe]),Ee=ve?Pa(G,ve):{authChecked:G?.hasChecked??!1,connected:!1},Pe=Ee.authChecked,[Fe,Te]=c.useState(0),[Ae,qe]=c.useState({key:"",status:"loading",capabilities:null}),[Ge,Je]=c.useState(!1),{detectedUpstream:st,upstreamBranches:mt}=Bw(t,b,ve);c.useEffect(()=>{if(!ve)return;let P=!1;const we=Un(ve);return qe({key:we,status:"loading",capabilities:null}),b.capabilities(ve).then(he=>{P||qe({key:we,status:"ready",capabilities:he})}).catch(()=>{P||qe({key:we,status:"error",capabilities:null})}),()=>{P=!0}},[Fe,ve,b]);const Y=Ae.key===Xe?Ae:null,fe=Y?.status==="ready"?Y.capabilities:null;c.useEffect(()=>{Je(!1)},[t]);const T=!!(t&&e&&s&&(e!==s||st!==null||x)),ae=c.useMemo(()=>ve?Zm(ve,e):"",[e,ve]),pe=c.useRef(ae);pe.current=ae;const oe=c.useCallback((P,we)=>P===qt()&&we===pe.current,[]),be=hs(P=>P.entries[ae]),$e=c.useMemo(()=>ae?[ae]:[],[ae]);uo(Xm($e));const De=be?.isLoading??!1,ee=Ee.connected?be?.status??null:null,le=Ke.error?g("settings.sourceControl.instance.status.operationFailed"):be?.error??null,et=be?.isInitialStatusResolved??!1,xe=c.useMemo(()=>{const P=Ge?null:He,we=new Set;for(const it of i){const Et=Fw(it,P);!Et||Et==="HEAD"||we.add(Et)}if(Ge)for(const it of mt)it&&it!=="HEAD"&&we.add(it);const he=qs(s);he&&he!=="HEAD"&&we.add(he);const at=qs(Z);return at&&at!=="HEAD"&&we.add(at),Array.from(we).sort((it,Et)=>it.localeCompare(Et))},[s,i,He,Z,mt,Ge]);c.useEffect(()=>{const P=qs(s);if(!Z&&P){de(P);return}if(xe.length!==0&&!xe.includes(Z)){const we=xe.includes(P)?P:xe[0];we&&de(we)}},[xe,s,Z]);const bt=c.useRef([]),Tt=c.useRef(new Map),vt=c.useCallback(P=>{const we=Tt.current.get(P);if(we?.inFlight)return null;if(we)return we.inFlight=!0,we.key;const he=Aw();return Tt.current.set(P,{key:he,inFlight:!0}),he},[]),Rt=c.useCallback((P,we,he)=>{const at=Tt.current.get(P);!at||at.key!==we||(he?at.inFlight=!1:Tt.current.delete(P))},[]);c.useEffect(()=>{st&&Je(!0)},[st]),c.useEffect(()=>{Ge&&st?.defaultBranch&&de(st.defaultBranch)},[Ge,st?.defaultBranch]);const Ye=ee?.changeRequest??ee?.pr??null,ft=ee?.identity??ve,Nt=c.useMemo(()=>ee?.project??(ee?.repo&&ft?{...ee.repo,...ft,id:Do(ee.repo.owner,ee.repo.repo),name:ee.repo.repo}:null),[ee?.project,ee?.repo,ft]),ht=Ye?.state==="merged"||Ye?.state==="closed",Ct=ht?null:Ye,pt=ee?.ci?.summary??ee?.checks??null,[It,Ht]=c.useState(!1),dt=c.useRef(!0);c.useEffect(()=>(dt.current=!0,()=>{dt.current=!1}),[]);const ct=c.useCallback(async P=>{await z(ae,P)},[ae,z]),Mt=c.useCallback((P,we)=>{bt.current.forEach(he=>{window.clearTimeout(he)}),bt.current=_w.map(he=>window.setTimeout(()=>{oe(P,we)&&z(we,{force:!0,silent:!0,markInitialResolved:!0})},he))},[oe,z]),Wt=c.useCallback(async(P,we,he)=>{await cw({error:P,isCurrent:()=>oe(we,he),refresh:()=>z(he,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>Mt(we,he)})},[oe,z,Mt]);c.useEffect(()=>{!ve||!ae||(N(ae),$(ae,{directory:t,branch:e,remoteName:ve.primaryRemote,canShow:T,identity:ve,readContext:ve,sourceControl:b,authChecked:Ee.authChecked,connected:Ee.connected}))},[e,T,t,N,ae,ve,b,Ee.authChecked,Ee.connected,$]);const Zt=600,Kt=c.useCallback(async()=>{if(It)return;Ht(!0);const P=Date.now();try{if(await ct({force:!0}),Ye&&ee?.repo&&ft){const we={owner:ee.repo.owner,repo:ee.repo.repo,number:Ye.number};await b.refreshProviderReads(ft,{item:we}).catch(()=>{})}}finally{const we=Zt-(Date.now()-P);we>0&&await new Promise(he=>window.setTimeout(he,we)),dt.current&&Ht(!1)}},[It,Ye,ct,b,ee?.repo,ft]);c.useEffect(()=>{if(!(!ve||!ae))return U(ae),()=>{se(ae)}},[ae,ve,U,se]),c.useEffect(()=>{const P=Wo.get(S)??null;ie(P?.title??zo(e)),ne(P?.body??""),J(P?.draft??sl());const we=P?.targetBaseBranchChosen===!0&&!!P.targetBaseBranch;ge(we),de(we&&P?.targetBaseBranch?qs(P.targetBaseBranch):qs(s))},[s,e,S]),c.useEffect(()=>{!ve||!ae||!Ee.connected||ct({markInitialResolved:!0})},[ae,ve,ct,Ee.connected]),c.useEffect(()=>{!T||!ve||!Ee.connected||ct({force:!0,silent:!0,markInitialResolved:!0})},[T,ve,ct,Ee.connected]),c.useEffect(()=>{const P=()=>{const he=hs.getState().entries[ae]?.lastRefreshAt??0;Date.now()-he>6e4&&ct({force:!0,silent:!0})},we=()=>{document.visibilityState==="visible"&&P()};return window.addEventListener("focus",P),document.addEventListener("visibilitychange",we),()=>{window.removeEventListener("focus",P),document.removeEventListener("visibilitychange",we)}},[ae,ct]),c.useEffect(()=>{Pe&&!Ee.connected&&ct({force:!0,silent:!0,markInitialResolved:!0})},[ct,Ee.connected,Pe]),c.useEffect(()=>{!t||!e||Wo.set(S,{title:Q,body:O,draft:V,additionalContext:F,targetBaseBranch:Z,targetBaseBranchChosen:q})},[S,Q,O,V,F,Z,q,t,e]),c.useEffect(()=>()=>{bt.current.forEach(P=>{window.clearTimeout(P)}),bt.current=[]},[ae,ze]),c.useEffect(()=>()=>{Tt.current.clear()},[]);const ls=Ge&&st?.defaultBranchSha?st.defaultBranchSha:ve?`${ve.primaryRemote}/${Z}`:Z;c.useEffect(()=>{if(!t||!e||!ls)return;let P=!1;return Oc(t,{from:ls,to:e,maxCount:2}).then(we=>{const he=we.all.length===1?we.all[0]?.message.trim():"";P||!he||ie(at=>at===zo(e)?he:at)}).catch(()=>{}),()=>{P=!0}},[e,ls,t]);const Ut=x?ee?.localRevision?.uploadedAs===null:!r||o>0,Qt=Pw(t,e),cs=Nw(t,ls,e,x&&T,Be),js=c.useId(),Rs=P=>{J(P),Mw(P)},X=c.useCallback(async()=>{if(!ue&&t){ke(!0);try{const we={base:ls,head:e,...ve?.provider?{changeRequestProvider:l(ve.provider)}:{}};F&&(we.context=F);const he=await Ym(t,we);he.title?.trim()&&ie(he.title.trim()),he.body?.trim()&&ne(he.body.trim()),a?.()}catch(P){const we=P instanceof Error?P.message:String(P);Oe.error(g("gitView.pr.toast.generateDescriptionFailed"),{description:we})}finally{ke(!1)}}},[F,e,ls,l,t,ue,a,ve,g]),ot=c.useCallback(async()=>{if(fe?.changeRequests!==!0){Oe.error(g("gitView.pr.toast.createPrFailed"),{description:g("gitView.pr.capabilitiesUnavailable")});return}const P=Q.trim();if(!P){Oe.error(g("gitView.pr.toast.titleRequired"));return}const we=Z.trim();if(!we){Oe.error(g("gitView.pr.toast.baseBranchRequired"));return}if(!Ge&&we===e){Oe.error(g("gitView.pr.toast.baseMustDifferFromHead"));return}const he=Ge?st:Nt;if(!ve||!he){Oe.error(g("gitView.pr.toast.createPrFailed"),{description:le??g("gitView.pr.statusUnavailable")});return}if(Ut&&(We(!0),!await Qt.push())){We(!1);return}const at=qt(),it=ae,Et={owner:he.owner,name:he.name},Dt=O.trim()?O:void 0,Pt=Ge?void 0:ve.primaryRemote,Ot=Ge?ve.primaryRemote:void 0,ms=Ow(at,ve,[Et.owner,Et.name,e,we,P,Dt,V,Pt,Ot]),en=vt(ms);if(!en){We(!1);return}We(!0);let No=!1,la=!1;try{const Ds={...ve,idempotencyKey:en,target:{project:Et,head:e,base:we},title:P,draft:V};Dt!==void 0&&(Ds.body=Dt),Pt&&(Ds.remote=Pt),Ot&&(Ds.headRemote=Ot);const tn=await b.changeRequestCreate(Ds);if(la=!0,Rt(ms,en,!1),!oe(at,it)||(tn.result.stacked===!1?Oe.warning(g("stacks.toast.createdNotStacked"),{description:g("stacks.toast.createdNotStackedDescription",{base:we})}):Oe.success(g(tn.result.stacked?"stacks.toast.createdStacked":"gitView.pr.toast.prCreated")),await ct({force:!0}),!oe(at,it)))return;const kr=hs.getState().entries[it]?.status,Eo=kr?.changeRequest??kr?.pr;Eo&&Eo.number===tn.target.number&&Rw(t,Eo),Mt(at,it)}catch(Ds){const tn=Ds instanceof Error?Ds:new Error(String(Ds));No=Pd(tn);const kr=tn.message;Oe.error(g("gitView.pr.toast.createPrFailed"),{description:kr}),No&&await Wt(tn,at,it)}finally{la||Rt(ms,en,No),We(!1)}},[vt,O,e,Qt,st,t,V,le,Rt,oe,Ut,ae,ve,Wt,ct,Mt,b,fe?.changeRequests,Nt,Z,Q,Ge,g]),xt=async()=>{const P=Z.trim();if(!P){Oe.error(g("gitView.pr.toast.baseBranchRequired"));return}const we={target:P,wip:V,private:ye};Le.trim()&&(we.topic=Le.trim());const he=Ne.split(/[\s,]+/).filter(Boolean);he.length>0&&(we.hashtags=he),We(!0);try{if(!await Qt.pushForReview(we))return;Oe.success(g("gitView.change.push.toast.pushed")),await ct({force:!0})}finally{We(!1)}},_t=async P=>{We(!0);try{if(!await Qt.pushForReview({target:P.base}))return;Oe.success(g("gitView.change.push.toast.uploaded")),await ct({force:!0})}finally{We(!1)}},te=j.addChangeIdToHead,Qe=async()=>{const P=cs?.status==="ready"?cs.tip:null;if(!(!te||!P||!await y.confirm({title:g("gitView.change.changeId.confirmTitle"),message:g("gitView.change.changeId.confirmMessage"),action:g("gitView.change.changeId.add")})))try{await te(t,P),Oe.success(g("gitView.change.changeId.toast.added"))}catch(he){Oe.error(g("gitView.change.changeId.toast.failed"),{description:he instanceof Error?he.message:String(he)})}finally{_e(he=>he+1)}},gt="border-0 bg-transparent rounded-none px-4 py-3";if(!T)return n.jsx("section",{className:gt,children:n.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[n.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:g("gitView.pullRequest.availableOnFeatureBranches")}),u?n.jsx(iw,{identity:u}):null]})});const wt=ee?.changeRequest&&ee.changeRequest.state==="open"?ee.changeRequest:Ct&&Nt&&ft?{...ft,id:`${Do(Nt.owner,Nt.name)}#${Ct.number}`,number:Ct.number,project:{...ft,id:Nt.id,owner:Nt.owner,name:Nt.name,url:Nt.url??""},title:Ct.title,body:Ct.body,url:Ct.url,state:Ct.state,draft:Ct.draft,base:Ct.base,head:Ct.head,headSha:Ct.headSha,mergeable:Ct.mergeable,mergeableState:Ct.mergeableState}:null;if(wt&&ve){const P=n.jsx(fw,{directory:t,context:ve,changeRequest:wt,onChanged:()=>ct({force:!0,silent:!0,markInitialResolved:!0}),statusStack:ee?.stack});if(!(x&&Ut))return n.jsx("div",{className:"h-full min-h-0",children:P});const we=wt.revisionNumber!==void 0?wt.revisionNumber+1:null;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-edge-muted px-4 py-2",children:[n.jsx(ce,{name:"arrow-up",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:g("gitView.change.push.notUploaded")}),n.jsx(ns,{sideOffset:8,label:g("contextTooltips.git.uploadPatchset"),className:"shrink-0",children:n.jsxs(ut,{size:"sm",className:"shrink-0",onClick:()=>{_t(wt)},disabled:Me,children:[Me?n.jsx(ce,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(ce,{name:"upload-2",className:"size-4"}),we!==null?g("gitView.change.push.uploadPatchset",{number:we}):g("gitView.change.push.uploadNew")]})}),Qt.dialogs]}),n.jsx("div",{className:"min-h-0 flex-1",children:P})]})}const At=Nt?.url||null,Vt=Ge&&st?.url?st.url:At,ys=Y?.status==="error",os=!!ee?.connected,Cs=!!(!ve&&u&&Ke.status==="ready"&&Ce),Ts=!!(ft&&Pe&&ee?.connected===!1)||Cs,ds=ft??u,ss=ds?l(ds.provider).label:null,ps=Dw(ee),Qs=ps?`var(--pr-${ps})`:"var(--status-info)",Ks=ps==="draft"?"git-pr-draft":ps==="merged"?"git-merge":ps==="closed"?"git-close-pull-request":"git-pull-request",xn=ss?g("gitView.pr.actions.openOnProviderAria",{provider:ss}):g("gitView.header.openPullRequest"),ko=Ye?[g(Ye.state==="merged"?"sessions.sidebar.group.pr.status.merged":Ye.state==="closed"?"sessions.sidebar.group.pr.status.closed":Ye.draft?"sessions.sidebar.group.pr.status.draft":"sessions.sidebar.group.pr.status.open"),Ye.state==="open"&&Ye.mergeable===!1?g("gitView.pr.notMergeable"):null,Ye.state==="open"&&typeof Ye.mergeableState=="string"&&Ye.mergeableState&&Ye.mergeableState!=="unknown"?Ye.mergeableState:null].filter(Boolean).join(" · "):"",jo=pt?pt.total>0?`${pt.success}/${pt.total} ${g("gitView.pr.checks.label")}`:`${pt.state} ${g("gitView.pr.checks.label")}`:"",vr="px-0 py-3 border-b border-edge-muted flex flex-col gap-1",Mn="flex flex-col gap-3 py-3",Fn=n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:De||It,onClick:()=>{Kt()},"aria-label":g("gitView.pr.actions.refreshAria"),children:n.jsx(ce,{name:De||It?"loader-4":"refresh",className:Ze("size-4 text-muted-foreground",(De||It)&&"animate-spin")})})}),n.jsx(jt,{children:n.jsx("p",{children:g("gitView.pr.actions.refresh")})})]}),Co=Ie||F.trim().length>0,Ln=Ut?r?o===1?g("gitView.pr.unpushed.one"):g("gitView.pr.unpushed.many",{count:o}):g("gitView.pr.unpushed.unpublished"):null,Sr=g(Ut?V?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":V?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),To=Me||!os||fe?.changeRequests!==!0||!Z.trim()||!Ge&&Z.trim()===e,I=Me||!os||!Z.trim()||cs?.status!=="ready"||cs.commits===0||cs.missing!=="none";return n.jsxs("section",{className:gt,children:[Ye?n.jsxs("div",{className:vr,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(ns,{sideOffset:8,label:xn,className:"shrink-0",children:n.jsxs(ut,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{nl(Ye.url)},"aria-label":xn,children:[n.jsx(ce,{name:Ks,className:"size-4 shrink-0",style:{color:Qs}}),ss?g("gitView.pr.actions.openOnProvider",{provider:ss}):g("gitView.header.openPullRequest")]})}),n.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.pullRequest.title")}),n.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ca(l(ft?.provider),Ye.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Fn})]}),n.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[n.jsx("span",{style:{color:Qs},children:ko}),pt?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${Iw(pt.state)}`}),jo]}):null,r&&He&&r.split("/")[0]!==He?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",He]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:C&&ve&&m(ve.provider)?n.jsx(ns,{sideOffset:8,label:g("contextTooltips.git.walkthrough"),className:"shrink-0",children:n.jsxs(ut,{variant:"outline",size:"sm",className:"pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",onClick:()=>{v(t,{source:{kind:"pr",number:Ye.number,...Nt?{sourceRepo:{owner:Nt.owner,repo:Nt.name}}:{}},context:ve}),L(t,"walkthrough")},"aria-label":g("walkthrough.action.open"),children:[n.jsx(ce,{name:"route",className:"size-4"}),n.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:g("walkthrough.action.open")})]})}):null})]})]}):null,n.jsxs("div",{className:Mn,children:[ys?n.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[n.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:g("gitView.pr.capabilitiesUnavailable")}),n.jsx(ut,{variant:"outline",size:"sm",onClick:()=>Te(P=>P+1),children:g("settings.sourceControl.transport.retry")})]}):null,Ts&&ss?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.pr.providerNotConnected",{provider:ss})}),n.jsx(ut,{variant:"outline",size:"sm",onClick:w,className:"w-fit",children:g("gitView.pr.actions.openSettings")})]}):null,le?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.pr.statusUnavailable")}),n.jsx("div",{dir:"auto",className:"typography-meta text-muted-foreground break-words",children:le}),Ke.error?n.jsx(ut,{variant:"outline",size:"sm",onClick:()=>{Ke.retry()},disabled:Ke.status==="loading",children:g("settings.sourceControl.transport.retry")}):null,Vt?n.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:Vt,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(ce,{name:"external-link",className:"size-4"}),g("gitView.pr.actions.repo")]})}):null]}):null,(Ct||!Ye&&!et)&&!le&&!Ts&&(Ke.status==="loading"||ve)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(Jm,{className:"size-4"}),g("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[Ye&&ht?n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md oc-tile-inset px-2.5 py-2",children:[n.jsx(ce,{name:Ye.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Qs}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Ye.state==="merged"?g("gitView.pr.history.merged",{number:Ye.number,base:Ye.base||Z}):g("gitView.pr.history.closed",{number:Ye.number})}),n.jsx(ns,{sideOffset:8,label:xn,className:"shrink-0",children:n.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{nl(Ye.url)},"aria-label":xn,children:n.jsx(ce,{name:"external-link",className:"size-3.5"})})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(ce,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{dir:"ltr",className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),n.jsx(ce,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),Ge&&st?n.jsx("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:Do(st.owner,st.name)}):null,xe.length>0?n.jsxs(Qm,{value:Z,onValueChange:Se,children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(eh,{className:"w-auto min-w-0","aria-label":g("gitView.pr.field.baseBranch"),children:n.jsx(th,{placeholder:g("gitView.pr.placeholder.selectBaseBranch")})})}),n.jsx(jt,{children:n.jsx("p",{children:g("gitView.pr.field.baseBranch")})})]}),n.jsx(sh,{children:xe.map(P=>n.jsx(nh,{value:P,children:P},P))})]}):n.jsx(Rn,{value:Z,onChange:P=>Se(P.target.value),placeholder:g("gitView.pr.placeholder.main"),"aria-label":g("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),n.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[Vt?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:Vt,target:"_blank",rel:"noopener noreferrer","aria-label":g("gitView.pr.actions.repo"),children:n.jsx(ce,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(jt,{children:n.jsx("p",{children:g("gitView.pr.actions.repo")})})]}):null,Fn]})]}),M?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[n.jsx(ce,{name:"stack",className:"size-3.5 shrink-0"}),n.jsx("span",{className:"truncate",children:g("stacks.create.stacksOn",{reference:ca(l(ve?.provider),M.number)})})]}):null,x?n.jsx(Ew,{preflight:cs,topic:Le,onTopicChange:Ve,hashtags:Ne,onHashtagsChange:me,wip:V,onWipChange:Rs,privateChange:ye,onPrivateChange:je,onAddChangeId:te?()=>{Qe()}:void 0,disabled:Me}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.title")}),n.jsx(Rn,{value:Q,onChange:P=>ie(P.target.value),placeholder:g("gitView.pr.placeholder.title"),autoCorrect:R?"on":"off",autoCapitalize:R?"sentences":"off",spellCheck:R})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:js,className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsx(ns,{sideOffset:8,label:g("contextTooltips.git.generateDescription"),children:n.jsxs(ut,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:X,disabled:ue||Me,children:[ue?n.jsx(ce,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(ce,{name:"ai-generate-2",className:"size-3.5 text-primary"}),g("gitView.commit.generate")]})}),n.jsxs(fn,{children:[n.jsx(ns,{sideOffset:8,label:g("gitView.pr.generate.optionsAria"),children:n.jsx(pn,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:ue||Me,"aria-label":g("gitView.pr.generate.optionsAria"),children:n.jsx(ce,{name:"arrow-down-s",className:"size-3.5"})})})}),n.jsx(mn,{align:"end",className:"w-60",children:n.jsxs($s,{onSelect:()=>tt(!0),children:[n.jsx(ce,{name:"sticky-note",className:"size-4 shrink-0"}),g("gitView.pr.generate.withNotes")]})})]})]})]}),Co?n.jsxs("div",{className:"relative",children:[n.jsx(Ia,{value:F,onChange:P=>re(P.target.value),className:"min-h-[72px] pe-9",placeholder:g("gitView.pr.placeholder.additionalContext"),"aria-label":g("gitView.pr.generate.notesAria"),autoFocus:Ie&&!F}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{re(""),tt(!1)},"aria-label":g("gitView.pr.generate.removeNotesAria"),children:n.jsx(ce,{name:"close",className:"size-3.5"})})}),n.jsx(jt,{children:n.jsx("p",{children:g("gitView.pr.generate.removeNotesAria")})})]})]}):null,n.jsx(Ia,{id:js,value:O,onChange:P=>ne(P.target.value),className:"min-h-[140px]",placeholder:g("gitView.pr.placeholder.whatChanged"),autoCorrect:R?"on":"off",autoCapitalize:R?"sentences":"off",spellCheck:R})]})]}),Ln&&!x?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx(ce,{name:"arrow-up",className:"size-3.5 shrink-0"}),Ln]}):null,n.jsx("div",{className:"flex justify-end",children:x?n.jsx(ns,{sideOffset:8,label:g("contextTooltips.git.pushForReview"),children:n.jsxs(ut,{size:"sm",className:"justify-center gap-2",onClick:()=>{xt()},disabled:I,children:[Me?n.jsx(ce,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(ce,{name:"upload-2",className:"size-4"}),n.jsx("span",{children:g("gitView.change.push.forReview")})]})}):n.jsxs("div",{className:"flex items-center",children:[n.jsx(ns,{sideOffset:8,label:g("contextTooltips.git.createChangeRequest"),children:n.jsxs(ut,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:ot,disabled:To,children:[Me?n.jsx(ce,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(ce,{name:V?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:Sr})]})}),n.jsxs(fn,{children:[n.jsx(ns,{sideOffset:8,label:g("gitView.pr.createKindAria"),children:n.jsx(pn,{asChild:!0,children:n.jsx(ut,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:Me,"aria-label":g("gitView.pr.createKindAria"),children:n.jsx(ce,{name:"arrow-down-s",className:"size-4"})})})}),n.jsx(mn,{align:"end",className:"w-56",children:n.jsxs(Lc,{value:V?"draft":"ready",onValueChange:P=>Rs(P==="draft"),children:[n.jsx(Hr,{value:"ready",children:g("gitView.pr.actions.createPr")}),n.jsx(Hr,{value:"draft",children:g("gitView.pr.actions.createDraftPr")})]})})]})]})}),Qt.dialogs,y.dialog]})]})]})},zw=()=>{const t=Ue.c(98),{t:e}=lt(),{git:s,sourceControl:r}=ks(),o=Hs();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={recheckOnOpen:!0},t[0]=i):i=t[0];const{rootIsGitRepo:a,gitDirectory:d,nestedRepos:u,repositoryOptions:l,unreadable:f}=ah(o??null,i),m=fo(d??null),p=lh(d??null),h=ch(d??null),x=Fc(d,r),{ensureAll:g,ensureNestedRepos:w,selectNestedRepo:b}=Dn(ci(Ww)),j=nt(Uw),y=nt(Vw),E=nt(Hw),A=nt(Kw);let R;t[1]!==o?(R=Jt(o),t[1]=o,t[2]=R):R=t[2];const _=R;let L;e:{if(!_){L=void 0;break e}let me;t[3]!==A||t[4]!==_||t[5]!==E?(me=Wr(A,_)??Wr(E.values(),_),t[3]=A,t[4]=_,t[5]=E,t[6]=me):me=t[6],L=me}const v=L;let C;t[7]!==j||t[8]!==v||t[9]!==y?.open||t[10]!==E?(C=()=>{if(j)return E.get(j)??v;if(y?.open)return v},t[7]=j,t[8]=v,t[9]=y?.open,t[10]=E,t[11]=C):C=t[11],y?.open;let S;t[12]!==C?(S=C(),t[12]=C,t[13]=S):S=t[13];const k=S;let N;t[14]!==j?(N=me=>j?me.getAttachment(j):void 0,t[14]=j,t[15]=N):N=t[15];const $=Ec(N),B=$&&!$.degraded&&!$.legacy?$.worktreeRoot??void 0:void 0,D=tw(o,k,m?.current??void 0);let W,H;t[16]!==g||t[17]!==s||t[18]!==d?(W=()=>{!d||!s||g(d,s)},H=[d,g,s],t[16]=g,t[17]=s,t[18]=d,t[19]=W,t[20]=H):(W=t[19],H=t[20]),c.useEffect(W,H);const[U,se]=c.useState(null);let z;t[21]!==B||t[22]!==D?.projectDirectory?(z=()=>{const me=B||D?.projectDirectory;if(!me){se(null);return}let ye=!1;return dh(me).then(je=>{if(ye)return;const Be=je.trim();se(Be&&Be!=="HEAD"?Be:null)}).catch(()=>{ye||se(null)}),()=>{ye=!0}},t[21]=B,t[22]=D?.projectDirectory,t[23]=z):z=t[23];const Q=D?.projectDirectory;let ie;t[24]!==B||t[25]!==Q?(ie=[B,Q],t[24]=B,t[25]=Q,t[26]=ie):ie=t[26],c.useEffect(z,ie);let O;e:{if(!p?.all){let ye;t[27]===Symbol.for("react.memo_cache_sentinel")?(ye=[],t[27]=ye):ye=t[27],O=ye;break e}let me;t[28]!==p.all?(me=p.all.filter(qw).sort(),t[28]=p.all,t[29]=me):me=t[29],O=me}const ne=O;let V;e:{if(!p?.all){let ye;t[30]===Symbol.for("react.memo_cache_sentinel")?(ye=[],t[30]=ye):ye=t[30],V=ye;break e}let me;t[31]!==p.all?(me=p.all.filter(Gw).map(Zw).sort(),t[31]=p.all,t[32]=me):me=t[32],V=me}const J=V,F=m?.current??null,re=x.contexts[0]?.primaryRemote,q=re?p?.defaultBranches?.[re]:void 0;let ge;t[33]!==x.contexts[0]||t[34]!==x.read?.repository.remotes||t[35]!==F||t[36]!==q||t[37]!==ne||t[38]!==U||t[39]!==D?.createdFromBranch?(ge=()=>Yf({remoteNames:new Set(x.contexts[0]?.primaryRemote?[x.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(x.read?.repository.remotes.map(Xw)??[]),localBranches:ne,worktreeCreatedFromBranch:D?.createdFromBranch,rootBranchHint:U,defaultBranch:q,headBranch:F,fallbackToConventional:!1}),t[33]=x.contexts[0],t[34]=x.read?.repository.remotes,t[35]=F,t[36]=q,t[37]=ne,t[38]=U,t[39]=D?.createdFromBranch,t[40]=ge):ge=t[40],D?.createdFromBranch;let Z;t[41]!==ge?(Z=ge(),t[41]=ge,t[42]=Z):Z=t[42];const Se=Zf(d??null,F,!0,x,p,Z),ue=Ql(Mc(o??null)?.provider);if(!o){let me;t[43]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(ce,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[43]=me):me=t[43];let ye;t[44]!==ue||t[45]!==e?(ye=e(Ls("gitView.pullRequest.title",ue)),t[44]=ue,t[45]=e,t[46]=ye):ye=t[46];let je;t[47]!==ye?(je=n.jsx("div",{className:"typography-ui-header text-foreground",children:ye}),t[47]=ye,t[48]=je):je=t[48];let Be;t[49]!==ue||t[50]!==e?(Be=e(Ls("gitView.pullRequest.createHint",ue)),t[49]=ue,t[50]=e,t[51]=Be):Be=t[51];let _e;t[52]!==Be?(_e=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Be}),t[52]=Be,t[53]=_e):_e=t[53];let Ie;return t[54]!==je||t[55]!==_e?(Ie=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[me,je,_e]}),t[54]=je,t[55]=_e,t[56]=Ie):Ie=t[56],Ie}if(f){let me;return t[57]!==f.directory||t[58]!==f.message?(me=n.jsx(Xf,{directory:f.directory,message:f.message}),t[57]=f.directory,t[58]=f.message,t[59]=me):me=t[59],me}if(a===!1&&h!==!0){let me;t[60]!==o||t[61]!==w?(me=()=>{w(o,{force:!0})},t[60]=o,t[61]=w,t[62]=me):me=t[62];let ye;return t[63]!==o||t[64]!==h||t[65]!==u||t[66]!==a||t[67]!==me?(ye=n.jsx(Jf,{root:o,rootIsGitRepo:a,resolvedIsGitRepo:h,nestedRepos:u,onRetryDiscovery:me}),t[63]=o,t[64]=h,t[65]=u,t[66]=a,t[67]=me,t[68]=ye):ye=t[68],ye}if(!F){let me;t[69]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(ce,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[69]=me):me=t[69];let ye;t[70]!==ue||t[71]!==e?(ye=e(Ls("gitView.pullRequest.title",ue)),t[70]=ue,t[71]=e,t[72]=ye):ye=t[72];let je;t[73]!==ye?(je=n.jsx("div",{className:"typography-ui-header text-foreground",children:ye}),t[73]=ye,t[74]=je):je=t[74];let Be;t[75]!==ue||t[76]!==e?(Be=e(Ls("gitView.pullRequest.createHint",ue)),t[75]=ue,t[76]=e,t[77]=Be):Be=t[77];let _e;t[78]!==Be?(_e=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Be}),t[78]=Be,t[79]=_e):_e=t[79];let Ie;return t[80]!==je||t[81]!==_e?(Ie=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[me,je,_e]}),t[80]=je,t[81]=_e,t[82]=Ie):Ie=t[82],Ie}let ke;t[83]!==o||t[84]!==d||t[85]!==l||t[86]!==b?(ke=l?n.jsx("div",{className:"flex shrink-0 items-center border-b border-edge px-4 py-2",children:n.jsx(uh,{repositories:l,selectedRepository:d??null,onSelectRepository:me=>{o&&b(o,me)},repositoryRoot:o??void 0})}):null,t[83]=o,t[84]=d,t[85]=l,t[86]=b,t[87]=ke):ke=t[87];const Me=d??o,We=m?.tracking??void 0,Le=m?.ahead??0;let Ve;t[88]!==Se||t[89]!==F||t[90]!==J||t[91]!==Me||t[92]!==We||t[93]!==Le?(Ve=n.jsx(as,{as:fh,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx($w,{directory:Me,branch:F,baseBranch:Se,trackingBranch:We,ahead:Le,remoteBranches:J})}),t[88]=Se,t[89]=F,t[90]=J,t[91]=Me,t[92]=We,t[93]=Le,t[94]=Ve):Ve=t[94];let Ne;return t[95]!==ke||t[96]!==Ve?(Ne=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ke,Ve]}),t[95]=ke,t[96]=Ve,t[97]=Ne):Ne=t[97],Ne};function Ww(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function Uw(t){return t.currentSessionId}function Vw(t){return t.newSessionDraft}function Hw(t){return t.worktreeMetadata}function Kw(t){return t.availableWorktrees}function qw(t){return!t.startsWith("remotes/")}function Gw(t){return t.startsWith("remotes/")}function Zw(t){return t.replace(/^remotes\//,"")}function Xw(t){return t.name}const Rd=[],Yw=t=>{const e=Ue.c(17),s=po(),r=Bc();let o;e[0]!==t.url||e[1]!==r||e[2]!==s?(o=$c(t.url,s,r),e[0]=t.url,e[1]=r,e[2]=s,e[3]=o):o=e[3];const i=o;Qf(t.visible);const{panelDirectory:a,tabId:d,url:u}=t;let l;e[4]!==a||e[5]!==d||e[6]!==u?(l=()=>{vh(a,d)&&(On(u),K.getState().closeContextPanelTab(a,d))},e[4]=a,e[5]=d,e[6]=u,e[7]=l):l=e[7];const f=l;let m;e[8]!==a||e[9]!==d?(m=()=>Sh(a,d),e[8]=a,e[9]=d,e[10]=m):m=e[10];const p=m;let h;if(e[11]!==f||e[12]!==t||e[13]!==p||e[14]!==i||e[15]!==u){const x=i?i.source==="tracker"?n.jsx(Qw,{url:u,provider:i.provider,identifier:i.identifier,visible:t.visible,onUnavailable:f,onShown:p}):n.jsx(Jw,{...t,kind:i.kind,onUnavailable:f,onShown:p}):n.jsx(Ji,{url:u});h=n.jsx("div",{className:"h-full min-h-0",children:x}),e[11]=f,e[12]=t,e[13]=p,e[14]=i,e[15]=u,e[16]=h}else h=e[16];return h},Zn=t=>{const e=Ue.c(8),{message:s,onRetry:r}=t,{t:o}=lt();let i;e[0]!==s?(i=n.jsx("span",{children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==r||e[3]!==o?(a=r?n.jsx(ut,{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 d;return e[5]!==i||e[6]!==a?(d=n.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]=d):d=e[7],d},Ji=t=>{const e=Ue.c(14),{url:s}=t,{t:r}=lt();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=n.jsx("span",{children:o}),e[2]=o,e[3]=i):i=e[3];let a;e[4]!==s?(a=()=>{On(s)},e[4]=s,e[5]=a):a=e[5];let d;e[6]!==r?(d=r("contextPanel.preview.actions.openExternal"),e[6]=r,e[7]=d):d=e[7];let u;e[8]!==a||e[9]!==d?(u=n.jsx(ut,{size:"sm",variant:"outline",onClick:a,children:d}),e[8]=a,e[9]=d,e[10]=u):u=e[10];let l;return e[11]!==i||e[12]!==u?(l=n.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,u]}),e[11]=i,e[12]=u,e[13]=l):l=e[13],l},rl=t=>{const e=Ue.c(25),{enabled:s,directory:r,url:o,kind:i,linked:a}=t;let d;e[0]!==r||e[1]!==s||e[2]!==i||e[3]!==a||e[4]!==o?(d={enabled:s,directory:r,kind:i,filter:Da,query:o,linked:a},e[0]=r,e[1]=s,e[2]=i,e[3]=a,e[4]=o,e[5]=d):d=e[5];const u=Ra(d),l=po();let f;e[6]!==o||e[7]!==l?(f=S=>S.find(k=>kh(k.url,o,l))??null,e[6]=o,e[7]=l,e[8]=f):f=e[8];const m=f;let p;if(e[9]!==i||e[10]!==o||e[11]!==l){const S=i==="issue"?wh(o,l):null,k=l.match(o);p=S?.descriptor.terminology.sharedNumberSpace&&k?yh(S,"pull",k.number):null,e[9]=i,e[10]=o,e[11]=l,e[12]=p}else p=e[12];const h=p,x=ey,[g,w]=$t.useState(null),b=g===o;s&&h&&!b&&x(u)&&!m(u.items)&&w(o);const j=s&&b&&h!==null,y=h??"";let E;e[13]!==r||e[14]!==a||e[15]!==j||e[16]!==y?(E={enabled:j,directory:r,kind:"pull",filter:Da,query:y,linked:a},e[13]=r,e[14]=a,e[15]=j,e[16]=y,e[17]=E):E=e[17];const A=Ra(E),R=b?A:u;let _;e[18]!==R.items||e[19]!==m?(_=m(R.items),e[18]=R.items,e[19]=m,e[20]=_):_=e[20];const L=_,v=s&&x(R)&&!L;let C;return e[21]!==R||e[22]!==L||e[23]!==v?(C={lookup:R,reference:L,missing:v},e[21]=R,e[22]=L,e[23]=v,e[24]=C):C=e[24],C},Jw=t=>{const e=Ue.c(128),{url:s,directory:r,panelDirectory:o,foreign:i,visible:a,kind:d,onUnavailable:u,onShown:l}=t,{t:f}=lt(),{sourceControl:m}=ks(),p=Gt(ty),h=hh(r,s),x=h.directory,g=po(),w=gh(x),b=w&&w!=="missing"?w:null,j=h.status==="ready";let y;e[0]!==d||e[1]!==x||e[2]!==j||e[3]!==s?(y={enabled:j,directory:x,url:s,kind:d,linked:!1},e[0]=d,e[1]=x,e[2]=j,e[3]=s,e[4]=y):y=e[4];const E=rl(y);let A;e[5]!==s||e[6]!==g?(A=g.match(s),e[5]=s,e[6]=g,e[7]=A):A=e[7];const R=A,_=b!==null&&R?.provider===b.provider&&R.instance===b.instance,L=h.status==="ready"&&!E.reference&&(E.missing||E.lookup.status==="error"&&!h.owned),v=L&&_;let C;e[8]!==d||e[9]!==x||e[10]!==v||e[11]!==s?(C={enabled:v,directory:x,url:s,kind:d,linked:!0},e[8]=d,e[9]=x,e[10]=v,e[11]=s,e[12]=C):C=e[12];const S=rl(C),k=E.reference??S.reference,N=E.reference||!L?E.lookup:S.lookup,$=k?.linked===!0;let B;e[13]!==b||e[14]!==$?(B=b&&$?{...b,linked:!0}:b,e[13]=b,e[14]=$,e[15]=B):B=e[15];const D=B,W=$?null:D;let H;if(e[16]!==N.followed||e[17]!==k?.number){let Te;e[19]!==k?.number?(Te=Ae=>!jh(Ae)&&Ae.number===k?.number,e[19]=k?.number,e[20]=Te):Te=e[20],H=N.followed.filter(Te),e[16]=N.followed,e[17]=k?.number,e[18]=H}else H=e[18];uo(a?H:Rd);const se=L&&!k&&(!_||S.missing||S.lookup.status==="error");let z,Q;e[21]!==u||e[22]!==se?(z=()=>{se&&u()},Q=[u,se],e[21]=u,e[22]=se,e[23]=z,e[24]=Q):(z=e[23],Q=e[24]),$t.useEffect(z,Q);const ie=k!==null;let O,ne;e[25]!==ie||e[26]!==l?(O=()=>{ie&&l()},ne=[ie,l],e[25]=ie,e[26]=l,e[27]=O,e[28]=ne):(O=e[27],ne=e[28]),$t.useEffect(O,ne);const{detail:V,refresh:J}=_c(x,k,!0);let F;e[29]!==k?(F=k?[k]:[],e[29]=k,e[30]=F):F=e[30];const re=xh(x,F),q=dc(k),[ge,Z]=$t.useState(!1),de=Li(),{retry:Se}=N;let ue;e[31]!==J||e[32]!==Se?(ue=()=>Promise.all([J(),Se()]).then(sy),e[31]=J,e[32]=Se,e[33]=ue):ue=e[33];const ke=ue,Me=uc(k,W,ke),We=Bi(),Le=V.status==="ready"?V.value.pull?.stack??null:null;let Ve;e[34]!==k||e[35]!==ke||e[36]!==m||e[37]!==W?(Ve=async()=>{if(W&&k){const Te={owner:k.sourceRepo.owner,repo:k.sourceRepo.repo,number:k.number};await m.refreshProviderReads(W,{item:Te}).catch(ny),Ac(Te)}await ke()},e[34]=k,e[35]=ke,e[36]=m,e[37]=W,e[38]=Ve):Ve=e[38];const Ne=Ve;if(!k){if(se){let Ae;return e[39]!==s?(Ae=n.jsx(Ji,{url:s}),e[39]=s,e[40]=Ae):Ae=e[40],Ae}if(h.status==="failed"){let Ae;e[41]!==f?(Ae=f("gitView.empty.discoverFailed"),e[41]=f,e[42]=Ae):Ae=e[42];let qe;return e[43]!==h.retry||e[44]!==Ae?(qe=n.jsx(Zn,{message:Ae,onRetry:h.retry}),e[43]=h.retry,e[44]=Ae,e[45]=qe):qe=e[45],qe}let Te;return e[46]!==N.error||e[47]!==N.status||e[48]!==Se||e[49]!==f?(Te=N.status==="error"?n.jsx(Zn,{message:N.error??f("contextPanel.tracker.loadFailed"),onRetry:()=>{Se()}}):n.jsx(Zn,{message:f("common.loading")}),e[46]=N.error,e[47]=N.status,e[48]=Se,e[49]=f,e[50]=Te):Te=e[50],Te}let me;e[51]!==k?(me={source:"repository",reference:k},e[51]=k,e[52]=me):me=e[52];const ye=me,je=k.kind==="pull"?k:null;let Be;e[53]!==je||e[54]!==re?(Be=je?re(je):zi,e[53]=je,e[54]=re,e[55]=Be):Be=e[55];let _e;e[56]===Symbol.for("react.memo_cache_sentinel")?(_e={status:"idle"},e[56]=_e):_e=e[56];let Ie;e[57]!==ke?(Ie=()=>{ke()},e[57]=ke,e[58]=Ie):Ie=e[58];let tt;e[59]!==D||e[60]!==ye||e[61]!==Le||e[62]!==Ie?(tt=n.jsx(Ai,{item:ye,project:null,context:D,onStartWorktree:oy,onChanged:Ie,worktreeAvailable:!1,stack:Le}),e[59]=D,e[60]=ye,e[61]=Le,e[62]=Ie,e[63]=tt):tt=e[63];let Ke;e[64]!==r||e[65]!==We?(Ke=Te=>{We(Te.url,r)},e[64]=r,e[65]=We,e[66]=Ke):Ke=e[66];let ze;e[67]!==D||e[68]!==je?(ze=je&&D?()=>Z(!0):void 0,e[67]=D,e[68]=je,e[69]=ze):ze=e[69];const rt=D?Ne:void 0;let ve;e[70]!==V.status||e[71]!==V.value||e[72]!==ye||e[73]!==k||e[74]!==ke||e[75]!==W?(ve=k.state!=="merged"&&W&&(k.kind!=="discussion"||bh(k,V.status==="ready"?V.value.discussion:void 0))?n.jsx(fc,{item:ye,context:W,onChanged:()=>{ke()}}):void 0,e[70]=V.status,e[71]=V.value,e[72]=ye,e[73]=k,e[74]=ke,e[75]=W,e[76]=ve):ve=e[76];let M;e[77]!==q.attachComment||e[78]!==q.attachComments?(M={onAttach:q.attachComment,onAttachAll:q.attachComments},e[77]=q.attachComment,e[78]=q.attachComments,e[79]=M):M=e[79];let Ce;e[80]!==k||e[81]!==ke||e[82]!==W?(Ce=W?n.jsx(hc,{reference:k,context:W,onChanged:ke}):void 0,e[80]=k,e[81]=ke,e[82]=W,e[83]=Ce):Ce=e[83];let He;e[84]!==V||e[85]!==je||e[86]!==ke||e[87]!==W?(He=je&&W?n.jsx(gc,{pull:je,detail:V,context:W,onChanged:ke}):void 0,e[84]=V,e[85]=je,e[86]=ke,e[87]=W,e[88]=He):He=e[88];let Xe;e[89]!==V.status||e[90]!==V.value||e[91]!==k||e[92]!==ke||e[93]!==W?(Xe=W&&(V.status!=="ready"||V.value.discussion?.canComment!==!1)?n.jsx(pc,{reference:k,context:W,onRefresh:ke}):void 0,e[89]=V.status,e[90]=V.value,e[91]=k,e[92]=ke,e[93]=W,e[94]=Xe):Xe=e[94];let G;e[95]!==p||e[96]!==D||e[97]!==r||e[98]!==i||e[99]!==o||e[100]!==je||e[101]!==x?(G=je&&D?n.jsx(xc,{pull:je,project:{id:p??"",path:r},repository:x,context:D,projectOwnsDirectory:()=>!i,currentDirectory:o}):null,e[95]=p,e[96]=D,e[97]=r,e[98]=i,e[99]=o,e[100]=je,e[101]=x,e[102]=G):G=e[102];let Ee;e[103]!==V||e[104]!==ye||e[105]!==de||e[106]!==x||e[107]!==Be||e[108]!==tt||e[109]!==Ke||e[110]!==ze||e[111]!==rt||e[112]!==ve||e[113]!==M||e[114]!==Ce||e[115]!==He||e[116]!==Xe||e[117]!==G||e[118]!==Me?(Ee=n.jsx($i,{item:ye,directory:x,pullStatus:Be,trackerDetail:_e,repositoryDetail:V,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:ry,now:de,footer:tt,onOpenStackLayer:Ke,onOpenChecks:ze,onRefresh:rt,threadActions:Me,stateMenu:ve,commentAttachments:M,labelsControl:Ce,reviewersControl:He,reply:Xe,pullLinks:G}),e[103]=V,e[104]=ye,e[105]=de,e[106]=x,e[107]=Be,e[108]=tt,e[109]=Ke,e[110]=ze,e[111]=rt,e[112]=ve,e[113]=M,e[114]=Ce,e[115]=He,e[116]=Xe,e[117]=G,e[118]=Me,e[119]=Ee):Ee=e[119];let Pe;e[120]!==q.attachFailedChecks||e[121]!==ge||e[122]!==D||e[123]!==je?(Pe=je&&D?n.jsx(mc,{pull:je,context:D,open:ge,onOpenChange:Z,onAttachFailed:q.attachFailedChecks}):null,e[120]=q.attachFailedChecks,e[121]=ge,e[122]=D,e[123]=je,e[124]=Pe):Pe=e[124];let Fe;return e[125]!==Ee||e[126]!==Pe?(Fe=n.jsxs(n.Fragment,{children:[Ee,Pe]}),e[125]=Ee,e[126]=Pe,e[127]=Fe):Fe=e[127],Fe},Qw=t=>{const e=Ue.c(50),{url:s,provider:r,identifier:o,visible:i,onUnavailable:a,onShown:d}=t,{t:u}=lt(),l=ph(r);let f;e[0]!==o||e[1]!==r||e[2]!==l?(f=l==="ready"?{provider:r,id:o}:null,e[0]=o,e[1]=r,e[2]=l,e[3]=f):f=e[3];const{detail:m,refresh:p,followed:h}=mh(f,!0);uo(i?h:Rd);const x=Bi(),g=Li(),w=l!=="ready",b=m.status==="error",j=m.status==="ready";let y,E;e[4]!==w||e[5]!==b||e[6]!==a?(y=()=>{(w||b)&&a()},E=[w,b,a],e[4]=w,e[5]=b,e[6]=a,e[7]=y,e[8]=E):(y=e[7],E=e[8]),$t.useEffect(y,E);let A,R;if(e[9]!==d||e[10]!==j?(A=()=>{j&&d()},R=[d,j],e[9]=d,e[10]=j,e[11]=A,e[12]=R):(A=e[11],R=e[12]),$t.useEffect(A,R),w){let D;return e[13]!==s?(D=n.jsx(Ji,{url:s}),e[13]=s,e[14]=D):D=e[14],D}if(m.status==="error"){let D;e[15]!==m.error||e[16]!==u?(D=m.error||u("contextPanel.tracker.loadFailed"),e[15]=m.error,e[16]=u,e[17]=D):D=e[17];let W;e[18]!==p?(W=()=>{p()},e[18]=p,e[19]=W):W=e[19];let H;return e[20]!==D||e[21]!==W?(H=n.jsx(Zn,{message:D,onRetry:W}),e[20]=D,e[21]=W,e[22]=H):H=e[22],H}if(m.status!=="ready"){let D;e[23]!==u?(D=u("common.loading"),e[23]=u,e[24]=D):D=e[24];let W;return e[25]!==D?(W=n.jsx(Zn,{message:D}),e[25]=D,e[26]=W):W=e[26],W}let _;e[27]!==m.value||e[28]!==r?(_={source:"tracker",provider:r,item:m.value},e[27]=m.value,e[28]=r,e[29]=_):_=e[29];const L=_;let v;e[30]===Symbol.for("react.memo_cache_sentinel")?(v={status:"idle"},e[30]=v):v=e[30];let C;e[31]!==p?(C=()=>{p()},e[31]=p,e[32]=C):C=e[32];let S;e[33]!==L||e[34]!==C?(S=n.jsx(Ai,{item:L,project:null,context:null,onStartWorktree:ay,onChanged:C,worktreeAvailable:!1}),e[33]=L,e[34]=C,e[35]=S):S=e[35];let k;e[36]!==p?(k=()=>{p()},e[36]=p,e[37]=k):k=e[37];let N;e[38]!==m.value||e[39]!==k?(N=n.jsx(ep,{item:m.value,onChanged:k}),e[38]=m.value,e[39]=k,e[40]=N):N=e[40];let $;e[41]!==x?($=D=>{x(D.url,null)},e[41]=x,e[42]=$):$=e[42];let B;return e[43]!==m||e[44]!==L||e[45]!==g||e[46]!==N||e[47]!==$||e[48]!==S?(B=n.jsx($i,{item:L,directory:null,pullStatus:zi,trackerDetail:m,repositoryDetail:v,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:iy,now:g,footer:S,trackerStateControl:N,onOpenTrackerItem:$}),e[43]=m,e[44]=L,e[45]=g,e[46]=N,e[47]=$,e[48]=S,e[49]=B):B=e[49],B};function ey(t){return(t.status==="ready"||t.status==="unavailable")&&!t.refreshing}function ty(t){return t.activeProjectId}function sy(){}function ny(){}function ry(){}function oy(){}function iy(){}function ay(){}const qr=new Map,ly=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},cy=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},dy=(t,e)=>{if(e.length===0)return qr;const s=new Set(e),r=new Map,o=new Map;for(const i of t)for(const a of i.session){if(!s.has(a.id))continue;const d=a.title?.trim();if(!d)continue;const u=cy(a),l=r.get(a.id);l!==void 0&&l>u||(r.set(a.id,u),o.set(a.id,d))}return o.size===0?qr:o},bo=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,uy=t=>t.kind==="record",fy=t=>{const e=Ue.c(5),{node:s}=t,r=s.tone==="string"?"text-foreground":"font-mono text-muted-foreground";let o;e[0]!==r?(o=Ze("whitespace-pre-wrap break-words",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==s.text||e[3]!==o?(i=n.jsx("span",{dir:"auto",className:o,children:s.text}),e[2]=s.text,e[3]=o,e[4]=i):i=e[4],i},py=t=>{const e=Ue.c(4),{node:s}=t;let r;e[0]!==s.entries?(r=s.entries.map(my),e[0]=s.entries,e[1]=r):r=e[1];let o;return e[2]!==r?(o=n.jsx("dl",{className:"flex flex-col gap-1.5",children:r}),e[2]=r,e[3]=o):o=e[3],o},wo=t=>{const e=Ue.c(13),{node:s}=t;if(s.kind==="scalar"){let i;return e[0]!==s?(i=n.jsx(fy,{node:s}),e[0]=s,e[1]=i):i=e[1],i}if(s.kind==="record"){let i;return e[2]!==s?(i=n.jsx(py,{node:s}),e[2]=s,e[3]=i):i=e[3],i}if(s.items.length===0){let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("span",{className:"font-mono text-muted-foreground",children:"[]"}),e[4]=i):i=e[4],i}if(s.items.every(uy)){let i;e[5]!==s.items?(i=s.items.map(hy),e[5]=s.items,e[6]=i):i=e[6];let a;return e[7]!==i?(a=n.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]!==s.items?(r=s.items.map(gy),e[9]=s.items,e[10]=r):r=e[10];let o;return e[11]!==r?(o=n.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},Dd=t=>{const e=Ue.c(24),{answer:s}=t,{t:r}=lt(),[o,i]=c.useState(!1);if(s.kind==="text"){let g;return e[0]!==s.text?(g=n.jsx(Ch,{content:s.text,singleTilde:!1,className:"typography-markdown-body",enableFileReferences:!1}),e[0]=s.text,e[1]=g):g=e[1],g}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>i(xy),e[2]=a):a=e[2];let d;e[3]!==o||e[4]!==r?(d=r(o?"workflows.panel.answer.formatted":"workflows.panel.answer.raw"),e[3]=o,e[4]=r,e[5]=d):d=e[5];let u;e[6]!==o||e[7]!==d?(u=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",onClick:a,"aria-pressed":o,className:"typography-micro text-muted-foreground hover:text-foreground",children:d})}),e[6]=o,e[7]=d,e[8]=u):u=e[8];const l=o?"contextTooltips.workspace.workflow.answerFormatted":"contextTooltips.workspace.workflow.answerRaw";let f;e[9]!==r||e[10]!==l?(f=r(l),e[9]=r,e[10]=l,e[11]=f):f=e[11];let m;e[12]!==f?(m=n.jsx(jt,{sideOffset:6,children:f}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==u||e[15]!==m?(p=n.jsx("div",{className:"flex justify-end",children:n.jsxs(kt,{children:[u,m]})}),e[14]=u,e[15]=m,e[16]=p):p=e[16];let h;e[17]!==s.tree||e[18]!==s.value||e[19]!==o?(h=o?n.jsx("pre",{dir:"ltr",className:"overflow-x-auto whitespace-pre-wrap break-words font-mono typography-meta text-foreground",children:JSON.stringify(s.value,null,2)}):n.jsx(wo,{node:s.tree}),e[17]=s.tree,e[18]=s.value,e[19]=o,e[20]=h):h=e[20];let x;return e[21]!==p||e[22]!==h?(x=n.jsxs("div",{className:"flex flex-col gap-2",children:[p,h]}),e[21]=p,e[22]=h,e[23]=x):x=e[23],x};function my(t){const[e,s]=t,r=s.kind==="scalar"&&s.text.length<=60&&!s.text.includes(`
|
|
5
|
-
`);return n.jsxs("div",{className:Ze("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[n.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),n.jsx("dd",{className:"min-w-0 typography-meta",children:n.jsx(wo,{node:s})})]},e)}function hy(t,e){return n.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:n.jsx(wo,{node:t})},e)}function gy(t,e){return n.jsx("li",{className:"typography-meta",children:n.jsx(wo,{node:t})},e)}function xy(t){return!t}const _d=t=>t.slice(t.indexOf("/")+1),Qi=t=>{const e=Ue.c(7),{start:s,end:r,className:o}=t,i=Dh(s!==void 0&&r===void 0);if(s===void 0)return null;let a;e[0]!==o?(a=Ze("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const d=(r??i)-s;let u;e[2]!==d?(u=_h(d),e[2]=d,e[3]=u):u=e[3];let l;return e[4]!==a||e[5]!==u?(l=n.jsx("span",{className:a,dir:"auto",children:u}),e[4]=a,e[5]=u,e[6]=l):l=e[6],l},by=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 s=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:s?void 0:Math.max(...r,...e)}},wy=t=>{const e=Ue.c(18),{run:s,groups:r}=t,{t:o}=lt();let i,a,d,u,l,f;if(e[0]!==r||e[1]!==s||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=r.filter(Cy);if(p.length===0){f=null;break e}i=as,a="overlay-scrollbar-wrapper--no-gutter",d=!1,u="flex gap-1.5 pb-1";let h;e[9]!==s||e[10]!==o?(h=x=>{const g=x.agents.length,w=by(x.agents),b=s.state==="running"&&s.currentPhase===x.title;return n.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[n.jsx("div",{className:Ze("truncate typography-meta",b?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?n.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):n.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?n.jsx(Qi,{start:w.start,end:w.end,className:"ms-auto"}):null]}),n.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?n.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]=s,e[10]=o,e[11]=h):h=e[11],l=p.map(h)}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=d,e[6]=u,e[7]=l,e[8]=f}else i=e[3],a=e[4],d=e[5],u=e[6],l=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[12]!==i||e[13]!==a||e[14]!==d||e[15]!==u||e[16]!==l?(m=n.jsx(i,{outerClassName:a,fillContainer:d,className:u,children:l}),e[12]=i,e[13]=a,e[14]=d,e[15]=u,e[16]=l,e[17]=m):m=e[17],m},yy=t=>{const e=Ue.c(30),{run:s,agent:r,onOpenSession:o}=t,{t:i}=lt(),[a,d]=c.useState(null),[u,l]=c.useState(!1),[f,m]=c.useState(!1);let p;e[0]!==r.key||e[1]!==s.id?(p=()=>{let E=!0;return l(!1),Ah(s.id,r.key).then(A=>{E&&d(A)}).catch(()=>{E&&l(!0)}),()=>{E=!1}},e[0]=r.key,e[1]=s.id,e[2]=p):p=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==s.id?(h=[r.key,r.state,s.id],e[3]=r.key,e[4]=r.state,e[5]=s.id,e[6]=h):h=e[6],c.useEffect(p,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?n.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]!==u||e[11]!==i?(g=u?n.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.loadFailed")}):null,e[10]=u,e[11]=i,e[12]=g):g=e[12];let w;e[13]!==a||e[14]!==u||e[15]!==i?(w=!a&&!u?n.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),n.jsx(Hi,{})]}):null,e[13]=a,e[14]=u,e[15]=i,e[16]=w):w=e[16];let b;e[17]!==a||e[18]!==f||e[19]!==i?(b=a?n.jsxs(n.Fragment,{children:[n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),n.jsx("div",{className:"mt-1",children:a.result===void 0?n.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):n.jsx(Dd,{answer:a.result})})]}),n.jsxs("section",{children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:()=>m(Ty),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[n.jsx(ce,{name:"arrow-right-s",className:Ze("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]})}),n.jsx(jt,{sideOffset:6,children:i(f?"contextTooltips.workspace.workflow.promptHide":"contextTooltips.workspace.workflow.promptShow")})]}),f?n.jsx(as,{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]=b):b=e[20];let j;e[21]!==o||e[22]!==i?(j=o?n.jsx("div",{children:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[n.jsx(ce,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}),n.jsx(jt,{sideOffset:6,children:i("contextTooltips.workspace.workflow.agentSession")})]})}):null,e[21]=o,e[22]=i,e[23]=j):j=e[23];let y;return e[24]!==x||e[25]!==g||e[26]!==w||e[27]!==b||e[28]!==j?(y=n.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,w,b,j]}),e[24]=x,e[25]=g,e[26]=w,e[27]=b,e[28]=j,e[29]=y):y=e[29],y},vy=t=>{const e=Ue.c(57),{run:s,agent:r,showModel:o,columns:i,open:a,onToggle:d,onOpenSession:u}=t,{t:l}=lt();let f,m,p,h,x,g,w,b,j,y,E;if(e[0]!==r||e[1]!==i.tokens||e[2]!==d||e[3]!==a||e[4]!==o||e[5]!==l){const v=Ih(r.state),C=Rh(r);f="button",h=d,x=a,g=r.label,w="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 S=v.icon,k=v.color?{color:v.color}:void 0,N=l(v.labelKey);e[17]!==v||e[18]!==k||e[19]!==N?(b=n.jsx(ce,{name:S,className:"size-3.5 shrink-0",style:k,"aria-label":N}),e[17]=v,e[18]=k,e[19]=N,e[20]=b):b=e[20],e[21]!==r.label?(j=n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=j):j=e[22],e[23]!==r.replayed||e[24]!==l?(y=r.replayed?n.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:l("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=l,e[25]=y):y=e[25],e[26]!==r.model||e[27]!==o?(E=o&&r.model?n.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:_d(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=E):E=e[28];const $=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==$?(m=n.jsx(Qi,{start:$,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=$,e[31]=m):m=e[31],p=i.tokens?n.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:C===null||r.replayed?"":Ui(C)}):null,e[0]=r,e[1]=i.tokens,e[2]=d,e[3]=a,e[4]=o,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=w,e[13]=b,e[14]=j,e[15]=y,e[16]=E}else f=e[6],m=e[7],p=e[8],h=e[9],x=e[10],g=e[11],w=e[12],b=e[13],j=e[14],y=e[15],E=e[16];let A;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(A=i.cost?n.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?Vi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=A):A=e[35];let R;e[36]!==f||e[37]!==m||e[38]!==p||e[39]!==A||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==w||e[44]!==b||e[45]!==j||e[46]!==y||e[47]!==E?(R=n.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:w,children:[b,j,y,E,m,p,A]}),e[36]=f,e[37]=m,e[38]=p,e[39]=A,e[40]=h,e[41]=x,e[42]=g,e[43]=w,e[44]=b,e[45]=j,e[46]=y,e[47]=E,e[48]=R):R=e[48];let _;e[49]!==r||e[50]!==u||e[51]!==a||e[52]!==s?(_=a?n.jsx(yy,{run:s,agent:r,onOpenSession:u}):null,e[49]=r,e[50]=u,e[51]=a,e[52]=s,e[53]=_):_=e[53];let L;return e[54]!==R||e[55]!==_?(L=n.jsxs(n.Fragment,{children:[R,_]}),e[54]=R,e[55]=_,e[56]=L):L=e[56],L},Sy=(t,e)=>{const s=Ph(t);if(s.measured===0)return null;const r=[];return e.tokens&&r.push(Ui(s.tokens)),e.cost&&s.cost>0&&r.push(Vi(s.cost)),r.length>0?r.join(" · "):null},ky=t=>{const e=new Set(t.map(r=>r.model??null)),[s]=e;return e.size===1&&s?_d(s):null},jy=t=>{const e=Ue.c(51),{run:s,directory:r}=t,{t:o}=lt();let i;e[0]!==s?(i=Th(s),e[0]=s,e[1]=i):i=e[1];const a=i,d=Nh(r),[u,l]=c.useState(Ny),[f,m]=c.useState(Ey);let p,h,x,g,w,b;if(e[2]!==a||e[3]!==u||e[4]!==d||e[5]!==s||e[6]!==o||e[7]!==f){const E=Eh(s),A=E.measured>0,R=E.cost>0;let _,L,v;if(e[14]!==a||e[15]!==u||e[16]!==d||e[17]!==s||e[18]!==o||e[19]!==A||e[20]!==R||e[21]!==f){const C={tokens:A,cost:R},S=s.agents.filter(Py).length,k=Iy;w="flex h-full min-h-0 flex-col";let N;e[28]!==a||e[29]!==s?(N=n.jsx(wy,{run:s,groups:a}),e[28]=a,e[29]=s,e[30]=N):N=e[30];const $=a.map(B=>{if(B.agents.length===0)return null;const D=B.title??"",W=B.done+B.failed===B.agents.length,U=(s.state==="running"&&W)===f.has(D),se=ky(B.agents),z=Sy(B.agents,C);return n.jsxs("section",{className:"mt-3",children:[n.jsxs("button",{type:"button",onClick:()=>k(m,D),"aria-expanded":U,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:[n.jsx(ce,{name:"arrow-right-s",className:Ze("size-3.5 shrink-0 transition-transform",U&&"rotate-90 rtl:-rotate-90")}),n.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:B.title??o("chat.workflow.phase.unphased")}),se?n.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${se}`}):null,z?n.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:z}):null,n.jsx("span",{className:Ze("shrink-0 tabular-nums font-normal",!z&&"ms-auto"),dir:"auto",children:z?`· ${B.done}/${B.agents.length}`:`${B.done}/${B.agents.length}`})]}),U?B.agents.map(Q=>{const ie=Q.sessionId;return n.jsx(vy,{run:s,agent:Q,showModel:se===null,columns:C,open:u.has(Q.key),onToggle:()=>k(l,Q.key),onOpenSession:ie?()=>d(ie,Q.label):null},Q.key)}):null]},D)});e[31]!==N||e[32]!==$?(b=n.jsxs(as,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[N,$]}),e[31]=N,e[32]=$,e[33]=b):b=e[33],p="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",L="auto",v=o("workflows.panel.summary.agents",{done:S,total:s.agents.length}),e[14]=a,e[15]=u,e[16]=d,e[17]=s,e[18]=o,e[19]=A,e[20]=R,e[21]=f,e[22]=_,e[23]=L,e[24]=v,e[25]=p,e[26]=w,e[27]=b}else _=e[22],L=e[23],v=e[24],p=e[25],w=e[26],b=e[27];e[34]!==_||e[35]!==L||e[36]!==v?(h=n.jsx("span",{className:_,dir:L,children:v}),e[34]=_,e[35]=L,e[36]=v,e[37]=h):h=e[37],e[38]!==s.endedAt||e[39]!==s.startedAt||e[40]!==s.state?(x=s.startedAt!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx(Qi,{start:s.startedAt,end:s.state==="running"?void 0:s.endedAt??s.startedAt})]}):null,e[38]=s.endedAt,e[39]=s.startedAt,e[40]=s.state,e[41]=x):x=e[41],g=E.measured>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:Ui(E.tokens)})}),E.cost>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("span",{className:"tabular-nums",dir:"ltr",children:Vi(E.cost)})]}):null]}):null,e[2]=a,e[3]=u,e[4]=d,e[5]=s,e[6]=o,e[7]=f,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=w,e[13]=b}else p=e[8],h=e[9],x=e[10],g=e[11],w=e[12],b=e[13];let j;e[42]!==p||e[43]!==h||e[44]!==x||e[45]!==g?(j=n.jsxs("div",{className:p,children:[h,x,g]}),e[42]=p,e[43]=h,e[44]=x,e[45]=g,e[46]=j):j=e[46];let y;return e[47]!==w||e[48]!==b||e[49]!==j?(y=n.jsxs("div",{className:w,children:[b,j]}),e[47]=w,e[48]=b,e[49]=j,e[50]=y):y=e[50],y};function Cy(t){return t.title!==null}function Ty(t){return!t}function Ny(){return new Set}function Ey(){return new Set}function Py(t){return t.state==="completed"}function Iy(t,e){return t(s=>{const r=new Set(s);return r.has(e)?r.delete(e):r.add(e),r})}const Ry={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},Dy=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents",tooltipKey:"contextTooltips.workspace.workflow.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log",tooltipKey:"contextTooltips.workspace.workflow.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result",tooltipKey:"contextTooltips.workspace.workflow.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script",tooltipKey:"contextTooltips.workspace.workflow.view.script"}],_y=1500,Ay=(t,e)=>{const s=Ue.c(11),[r,o]=c.useState(null),[i,a]=c.useState(null),d=c.useRef(null),u=e!=="agents",l=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;s[0]!==t.id||s[1]!==u?(f=()=>{if(!u)return;let g=!0;const w=d.current?.runId===t.id?d.current.at:0,b=Math.max(0,w+_y-Date.now()),j=setTimeout(()=>{d.current={runId:t.id,at:Date.now()},Vh(t.id).then(y=>{g&&(o(y),a(null))}).catch(()=>{g&&a(t.id)})},b);return()=>{g=!1,clearTimeout(j)}},s[0]=t.id,s[1]=u,s[2]=f):f=s[2];let m;s[3]!==l||s[4]!==t.id||s[5]!==t.state||s[6]!==u?(m=[l,t.id,t.state,u],s[3]=l,s[4]=t.id,s[5]=t.state,s[6]=u,s[7]=m):m=s[7],c.useEffect(f,m);const p=r?.runId===t.id?r:null,h=i===t.id;let x;return s[8]!==p||s[9]!==h?(x={detail:p,failed:h},s[8]=p,s[9]=h,s[10]=x):x=s[10],x},Oy=t=>new Intl.DateTimeFormat(Uc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),My=t=>{const e=Ue.c(8),{run:s,detail:r}=t,{t:o}=lt(),i=r?.logs??s.logs;if(i.length===0){let u;e[0]!==o?(u=o("workflows.panel.log.empty"),e[0]=o,e[1]=u):u=e[1];let l;return e[2]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[2]=u,e[3]=l):l=e[3],l}let a;e[4]!==i?(a=i.map(Ky),e[4]=i,e[5]=a):a=e[5];let d;return e[6]!==a?(d=n.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=d):d=e[7],d},Fy=t=>{const e=Ue.c(24),{run:s,detail:r,failed:o}=t,{t:i}=lt();if(s.error&&(s.state==="failed"||s.state==="stopped")){const u=s.state==="failed"?"var(--status-error)":void 0;let l;e[0]!==u?(l={color:u},e[0]=u,e[1]=l):l=e[1];let f;return e[2]!==s.error||e[3]!==l?(f=n.jsx("p",{dir:"auto",className:"px-4 py-6 typography-meta",style:l,children:s.error}),e[2]=s.error,e[3]=l,e[4]=f):f=e[4],f}if(s.state==="awaiting-approval"||s.state==="running"||s.state==="declined"){let u;e[5]!==i?(u=i("workflows.panel.result.pending"),e[5]=i,e[6]=u):u=e[6];let l;return e[7]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[7]=u,e[8]=l):l=e[8],l}if(o&&!r){let u;e[9]!==i?(u=i("workflows.panel.detail.loadFailed"),e[9]=i,e[10]=u):u=e[10];let l;return e[11]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[11]=u,e[12]=l):l=e[12],l}if(!r){let u;e[13]!==i?(u=i("workflows.panel.agent.loading"),e[13]=i,e[14]=u):u=e[14];let l;e[15]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Hi,{}),e[15]=l):l=e[15];let f;return e[16]!==u?(f=n.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[u,l]}),e[16]=u,e[17]=f):f=e[17],f}const{result:a}=r;if(!a||a.kind==="json"&&a.value===null){let u;e[18]!==i?(u=i("workflows.panel.result.none"),e[18]=i,e[19]=u):u=e[19];let l;return e[20]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=l):l=e[21],l}let d;return e[22]!==a?(d=n.jsx("div",{className:"px-4 py-3",children:n.jsx(Dd,{answer:a})}),e[22]=a,e[23]=d):d=e[23],d},Ly=t=>{const e=Ue.c(16),{detail:s,failed:r}=t,{t:o}=lt();if(!s){let m;e[0]!==r||e[1]!==o?(m=r?o("workflows.panel.detail.loadFailed"):n.jsxs(n.Fragment,{children:[o("workflows.panel.agent.loading"),n.jsx(Hi,{})]}),e[0]=r,e[1]=o,e[2]=m):m=e[2];let p;return e[3]!==m?(p=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:m}),e[3]=m,e[4]=p):p=e[4],p}const i=s.args;let a;e[5]!==i?(a=i!=null&&JSON.stringify(i)!=="{}",e[5]=i,e[6]=a):a=e[6];const d=a;let u;e[7]!==i||e[8]!==d||e[9]!==o?(u=d?n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),n.jsx(as,{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]=d,e[9]=o,e[10]=u):u=e[10];let l;e[11]!==s.script?(l=n.jsx(as,{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:s.script}),e[11]=s.script,e[12]=l):l=e[12];let f;return e[13]!==u||e[14]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[u,l]}),e[13]=u,e[14]=l,e[15]=f):f=e[15],f},By=t=>{const e=Ue.c(83),{run:s}=t,{t:r}=lt(),{pending:o,act:i}=Uh(),a=o===s.id;if(s.state==="awaiting-approval"){let d;e[0]!==r?(d=r("contextTooltips.workspace.workflow.approve"),e[0]=r,e[1]=d):d=e[1];let u;e[2]!==i||e[3]!==s.id?(u=()=>i(s.id,"approve"),e[2]=i,e[3]=s.id,e[4]=u):u=e[4];let l;e[5]!==r?(l=r("chat.workflow.action.run"),e[5]=r,e[6]=l):l=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ce,{name:"play",className:"size-3.5"}),e[7]=f):f=e[7];let m;e[8]!==r?(m=r("chat.workflow.action.run"),e[8]=r,e[9]=m):m=e[9];let p;e[10]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[10]=m,e[11]=p):p=e[11];let h;e[12]!==a||e[13]!==u||e[14]!==l||e[15]!==p?(h=n.jsxs(ut,{type:"button",size:"sm",disabled:a,onClick:u,"aria-label":l,children:[f,p]}),e[12]=a,e[13]=u,e[14]=l,e[15]=p,e[16]=h):h=e[16];let x;e[17]!==d||e[18]!==h?(x=n.jsx(ns,{label:d,side:"bottom",className:"shrink-0",children:h}),e[17]=d,e[18]=h,e[19]=x):x=e[19];let g;e[20]!==r?(g=r("contextTooltips.workspace.workflow.decline"),e[20]=r,e[21]=g):g=e[21];let w;e[22]!==i||e[23]!==s.id?(w=()=>i(s.id,"decline"),e[22]=i,e[23]=s.id,e[24]=w):w=e[24];let b;e[25]!==r?(b=r("chat.workflow.action.decline"),e[25]=r,e[26]=b):b=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(ce,{name:"close",className:"size-3.5"}),e[27]=j):j=e[27];let y;e[28]!==r?(y=r("chat.workflow.action.decline"),e[28]=r,e[29]=y):y=e[29];let E;e[30]!==y?(E=n.jsx("span",{className:"workflows-header__action-label",children:y}),e[30]=y,e[31]=E):E=e[31];let A;e[32]!==a||e[33]!==w||e[34]!==b||e[35]!==E?(A=n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:w,"aria-label":b,children:[j,E]}),e[32]=a,e[33]=w,e[34]=b,e[35]=E,e[36]=A):A=e[36];let R;e[37]!==A||e[38]!==g?(R=n.jsx(ns,{label:g,side:"bottom",className:"shrink-0",children:A}),e[37]=A,e[38]=g,e[39]=R):R=e[39];let _;return e[40]!==R||e[41]!==x?(_=n.jsxs(n.Fragment,{children:[x,R]}),e[40]=R,e[41]=x,e[42]=_):_=e[42],_}if(s.state==="running"){let d;e[43]!==r?(d=r("contextTooltips.workspace.workflow.stop"),e[43]=r,e[44]=d):d=e[44];let u;e[45]!==i||e[46]!==s.id?(u=()=>i(s.id,"stop"),e[45]=i,e[46]=s.id,e[47]=u):u=e[47];let l;e[48]!==r?(l=r("chat.workflow.action.stop"),e[48]=r,e[49]=l):l=e[49];let f;e[50]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ce,{name:"stop",className:"size-3.5"}),e[50]=f):f=e[50];let m;e[51]!==r?(m=r("chat.workflow.action.stop"),e[51]=r,e[52]=m):m=e[52];let p;e[53]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[53]=m,e[54]=p):p=e[54];let h;e[55]!==a||e[56]!==u||e[57]!==l||e[58]!==p?(h=n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":l,children:[f,p]}),e[55]=a,e[56]=u,e[57]=l,e[58]=p,e[59]=h):h=e[59];let x;return e[60]!==d||e[61]!==h?(x=n.jsx(ns,{label:d,side:"bottom",className:"shrink-0",children:h}),e[60]=d,e[61]=h,e[62]=x):x=e[62],x}if(s.state==="failed"||s.state==="stopped"){let d;e[63]!==r?(d=r("contextTooltips.workspace.workflow.resume"),e[63]=r,e[64]=d):d=e[64];let u;e[65]!==i||e[66]!==s.id?(u=()=>i(s.id,"resume"),e[65]=i,e[66]=s.id,e[67]=u):u=e[67];let l;e[68]!==r?(l=r("chat.workflow.action.resume"),e[68]=r,e[69]=l):l=e[69];let f;e[70]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ce,{name:"restart",className:"size-3.5"}),e[70]=f):f=e[70];let m;e[71]!==r?(m=r("chat.workflow.action.resume"),e[71]=r,e[72]=m):m=e[72];let p;e[73]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[73]=m,e[74]=p):p=e[74];let h;e[75]!==a||e[76]!==u||e[77]!==l||e[78]!==p?(h=n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":l,children:[f,p]}),e[75]=a,e[76]=u,e[77]=l,e[78]=p,e[79]=h):h=e[79];let x;return e[80]!==d||e[81]!==h?(x=n.jsx(ns,{label:d,side:"bottom",className:"shrink-0",children:h}),e[80]=d,e[81]=h,e[82]=x):x=e[82],x}return null},$y=()=>{const t=Ue.c(2),e=ts(qy);let s;return t[0]!==e?(s={get:r=>e.get(r)?.title},t[0]=e,t[1]=s):s=t[1],s},ol=t=>{const e=Ue.c(31),{run:s,selected:r,caption:o,onSelect:i}=t,{t:a}=lt();let d,u,l,f,m,p,h;if(e[0]!==i||e[1]!==s.state||e[2]!==a){const E=Wc(s.state);u=$s,h=i,d=ce,l=E.icon,f="size-3.5 shrink-0",m=E.color?{color:E.color}:void 0,p=a(E.labelKey),e[0]=i,e[1]=s.state,e[2]=a,e[3]=d,e[4]=u,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h}else d=e[3],u=e[4],l=e[5],f=e[6],m=e[7],p=e[8],h=e[9];let x;e[10]!==d||e[11]!==l||e[12]!==f||e[13]!==m||e[14]!==p?(x=n.jsx(d,{name:l,className:f,style:m,"aria-label":p}),e[10]=d,e[11]=l,e[12]=f,e[13]=m,e[14]=p,e[15]=x):x=e[15];let g;e[16]!==s.name?(g=n.jsx("span",{className:"truncate",dir:"auto",children:s.name}),e[16]=s.name,e[17]=g):g=e[17];let w;e[18]!==o?(w=o?n.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=w):w=e[19];let b;e[20]!==g||e[21]!==w?(b=n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,w]}),e[20]=g,e[21]=w,e[22]=b):b=e[22];let j;e[23]!==r?(j=r?n.jsx(ce,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=j):j=e[24];let y;return e[25]!==u||e[26]!==j||e[27]!==h||e[28]!==x||e[29]!==b?(y=n.jsxs(u,{onSelect:h,children:[x,b,j]}),e[25]=u,e[26]=j,e[27]=h,e[28]=x,e[29]=b,e[30]=y):y=e[30],y},zy=t=>{const e=Ue.c(63),{runs:s,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:d,onRunSaved:u,onDelete:l}=t,{t:f}=lt();let m;e[0]!==r.state?(m=Wc(r.state),e[0]=r.state,e[1]=m):m=e[1];const p=m;let h,x,g,w,b,j,y;if(e[2]!==p.color||e[3]!==p.icon||e[4]!==d||e[5]!==s||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const L=s.slice().reverse();let v;e[18]!==o?(v=Q=>Q.parentSessionId===o,e[18]=o,e[19]=v):v=e[19];const C=L.filter(v);let S;e[20]!==o?(S=Q=>Q.parentSessionId!==o,e[20]=o,e[21]=S):S=e[21];const k=L.filter(S);x=fn;let N;e[22]!==f?(N=f("workflows.panel.runPicker"),e[22]=f,e[23]=N):N=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=Ze(Wh(),"max-w-[14rem] shrink-0"),e[24]=$):$=e[24];let B;e[25]!==p.color?(B=p.color?{color:p.color}:void 0,e[25]=p.color,e[26]=B):B=e[26];let D;e[27]!==p.icon||e[28]!==B?(D=n.jsx(ce,{name:p.icon,className:"size-3.5",style:B}),e[27]=p.icon,e[28]=B,e[29]=D):D=e[29];let W;e[30]!==r.name?(W=n.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=W):W=e[31];let H;e[32]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(ce,{name:"arrow-down-s",className:"size-4"}),e[32]=H):H=e[32];let U;e[33]!==D||e[34]!==W||e[35]!==N?(U=n.jsx(St,{asChild:!0,children:n.jsx(pn,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":N,className:$,children:[D,W,H]})})}),e[33]=D,e[34]=W,e[35]=N,e[36]=U):U=e[36];let se;e[37]!==f?(se=f("contextTooltips.workspace.workflow.pickRun"),e[37]=f,e[38]=se):se=e[38];let z;e[39]!==se?(z=n.jsx(jt,{side:"bottom",sideOffset:6,children:se}),e[39]=se,e[40]=z):z=e[40],e[41]!==U||e[42]!==z?(y=n.jsxs(kt,{children:[U,z]}),e[41]=U,e[42]=z,e[43]=y):y=e[43],h=mn,g="start",w="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",b=C.length>0?n.jsxs(n.Fragment,{children:[n.jsx(Dr,{children:f("workflows.panel.picker.thisSession")}),C.map(Q=>n.jsx(ol,{run:Q,selected:Q.id===r.id,onSelect:()=>d(Q.id)},Q.id))]}):null,j=k.length>0?n.jsxs(n.Fragment,{children:[C.length>0?n.jsx(qn,{}):null,n.jsx(Dr,{children:f("workflows.panel.picker.otherSessions")}),k.map(Q=>n.jsx(ol,{run:Q,selected:Q.id===r.id,caption:i.get(Q.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>d(Q.id)},Q.id))]}):null,e[2]=p.color,e[3]=p.icon,e[4]=d,e[5]=s,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]=w,e[15]=b,e[16]=j,e[17]=y}else h=e[11],x=e[12],g=e[13],w=e[14],b=e[15],j=e[16],y=e[17];let E;e[44]!==u||e[45]!==a||e[46]!==f?(E=a.length>0?n.jsxs(n.Fragment,{children:[n.jsx(qn,{}),n.jsx(Dr,{children:f("workflows.panel.picker.saved")}),a.map(L=>n.jsxs($s,{disabled:!!L.error,onSelect:()=>u(L.name),title:L.error??L.description,children:[n.jsx(ce,{name:"play",className:"size-3.5 shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:L.name})]},L.name))]}):null,e[44]=u,e[45]=a,e[46]=f,e[47]=E):E=e[47];let A;e[48]!==l||e[49]!==f?(A=l?n.jsxs(n.Fragment,{children:[n.jsx(qn,{}),n.jsxs($s,{variant:"destructive",onSelect:l,children:[n.jsx(ce,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[48]=l,e[49]=f,e[50]=A):A=e[50];let R;e[51]!==h||e[52]!==g||e[53]!==w||e[54]!==b||e[55]!==j||e[56]!==E||e[57]!==A?(R=n.jsxs(h,{align:g,className:w,children:[b,j,E,A]}),e[51]=h,e[52]=g,e[53]=w,e[54]=b,e[55]=j,e[56]=E,e[57]=A,e[58]=R):R=e[58];let _;return e[59]!==x||e[60]!==y||e[61]!==R?(_=n.jsxs(x,{children:[y,R]}),e[59]=x,e[60]=y,e[61]=R,e[62]=_):_=e[62],_},Wy=(t,e,s,r)=>{const o=Ue.c(11),{t:i}=lt(),{confirm:a,dialog:d}=Wi(),u=Ki(Gy);let l;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==u||o[4]!==r||o[5]!==s||o[6]!==i?(l=async p=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:p}),message:i(s?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const x=await Lh({directory:t,scriptDirectory:e,sessionId:s,name:p});s?u(r,x.runId):(u(x.sessionId,x.runId),nt.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;Oe.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]=u,o[4]=r,o[5]=s,o[6]=i,o[7]=l):l=o[7];const f=l;let m;return o[8]!==d||o[9]!==f?(m={run:f,dialog:d},o[8]=d,o[9]=f,o[10]=m):m=o[10],m},Uy=t=>{const e=Ue.c(23),{saved:s,onRunSaved:r}=t,{t:o}=lt();if(s.length===0){let m;e[0]!==o?(m=o("workflows.panel.emptyProject"),e[0]=o,e[1]=m):m=e[1];let p;return e[2]!==m?(p=n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3],p}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=n.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[6]=i,e[7]=a):a=e[7];let d;e[8]!==o?(d=o("workflows.panel.picker.saved"),e[8]=o,e[9]=d):d=e[9];let u;e[10]!==d?(u=n.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:d}),e[10]=d,e[11]=u):u=e[11];let l;if(e[12]!==r||e[13]!==s||e[14]!==o){let m;e[16]!==r||e[17]!==o?(m=p=>n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:p.name}),p.description||p.error?n.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:p.error??p.description,children:p.error??p.description}):null]}),n.jsx(ns,{label:o("workflows.panel.saved.runAria",{name:p.name}),className:"shrink-0",children:n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:!!p.error,onClick:()=>r(p.name),"aria-label":o("workflows.panel.saved.runAria",{name:p.name}),children:[n.jsx(ce,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})})]},p.name),e[16]=r,e[17]=o,e[18]=m):m=e[18],l=s.map(m),e[12]=r,e[13]=s,e[14]=o,e[15]=l}else l=e[15];let f;return e[19]!==a||e[20]!==u||e[21]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[a,u,l]}),e[19]=a,e[20]=u,e[21]=l,e[22]=f):f=e[22],f},Vy=t=>{const e=Ue.c(17),{directory:s}=t,r=nt(Zy),o=Oh(s),i=Mh(o),a=Fh(o?.savedDirectory??null),d=r??`directory:${s??""}`;let u;e[0]!==d?(u=w=>w.selectedBySession[d],e[0]=d,e[1]=u):u=e[1];const l=Ki(u),{run:f,dialog:m}=Wy(s,o?.savedDirectory??null,r,d);let p;e[2]!==i||e[3]!==l||e[4]!==r?(p=i.find(w=>w.id===l)??i.filter(w=>w.parentSessionId===r).at(-1)??i.at(-1)??null,e[2]=i,e[3]=l,e[4]=r,e[5]=p):p=e[5];const h=p;let x;e[6]!==s||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==d||e[12]!==r?(x=h?n.jsx(Hy,{sessionId:r,selectionKey:d,runs:i,saved:a,run:h,directory:s,onRunSaved:w=>{f(w)}}):n.jsx(Uy,{saved:a,onRunSaved:w=>{f(w)}}),e[6]=s,e[7]=h,e[8]=f,e[9]=i,e[10]=a,e[11]=d,e[12]=r,e[13]=x):x=e[13];let g;return e[14]!==m||e[15]!==x?(g=n.jsxs(n.Fragment,{children:[m,x]}),e[14]=m,e[15]=x,e[16]=g):g=e[16],g},Hy=t=>{const e=Ue.c(58),{sessionId:s,selectionKey:r,runs:o,saved:i,run:a,directory:d,onRunSaved:u}=t,{t:l}=lt(),f=Ki(Xy),m=$y(),[p,h]=c.useState("agents"),{detail:x,failed:g}=Ay(a,p),w=c.useRef(null);Bh(w,Ry);const{confirm:b,dialog:j}=Wi(),y=a.state==="running"||a.state==="awaiting-approval",E=a.parentSessionId!==s;let A;e[0]!==b||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==l?(A=async()=>{if(await b({title:l("workflows.panel.delete.title",{name:a.name}),message:l("workflows.panel.delete.message"),action:l("workflows.panel.delete.confirm"),destructive:!0}))try{await $h(a.id),zh.getState().remove(a.parentSessionId,a.id)}catch(Q){const ie=Q;Oe.error(l("workflows.panel.delete.failed"),{description:ie instanceof Error?ie.message:void 0})}},e[0]=b,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=l,e[5]=A):A=e[5];const R=A;let _;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(_=()=>{f(a.parentSessionId,a.id),nt.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 L=_;let v;e[11]!==f||e[12]!==r?(v=z=>f(r,z),e[11]=f,e[12]=r,e[13]=v):v=e[13];let C;e[14]!==R||e[15]!==y?(C=y?null:()=>{R()},e[14]=R,e[15]=y,e[16]=C):C=e[16];let S;e[17]!==u||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==s||e[22]!==m||e[23]!==v||e[24]!==C?(S=n.jsx(zy,{runs:o,selected:a,sessionId:s,sessionTitles:m,saved:i,onSelect:v,onRunSaved:u,onDelete:C}),e[17]=u,e[18]=a,e[19]=o,e[20]=i,e[21]=s,e[22]=m,e[23]=v,e[24]=C,e[25]=S):S=e[25];let k;e[26]!==l?(k=l("workflows.panel.view.label"),e[26]=l,e[27]=k):k=e[27];let N;e[28]!==l||e[29]!==p?(N=Dy.map(z=>{const Q=z.id===p;return n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:()=>h(z.id),"aria-current":Q?"page":void 0,"aria-label":l(z.labelKey),className:Ze("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",Q?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[n.jsx(ce,{name:z.icon,className:"size-3.5 shrink-0"}),n.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:l(z.labelKey)})]})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:l(z.tooltipKey)})]},z.id)}),e[28]=l,e[29]=p,e[30]=N):N=e[30];let $;e[31]!==k||e[32]!==N?($=n.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":k,children:N}),e[31]=k,e[32]=N,e[33]=$):$=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=B):B=e[34];let D;e[35]!==E||e[36]!==L||e[37]!==a.parentSessionId||e[38]!==m||e[39]!==l?(D=E?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{type:"button",size:"sm",variant:"ghost",onClick:L,"aria-label":l("workflows.panel.agent.openSession"),children:[n.jsx(ce,{name:"chat-4",className:"size-3.5"}),n.jsx("span",{className:"workflows-header__action-label",children:l("workflows.panel.agent.openSession")})]})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:m.get(a.parentSessionId)||l("workflows.panel.picker.untitledSession")})]}):null,e[35]=E,e[36]=L,e[37]=a.parentSessionId,e[38]=m,e[39]=l,e[40]=D):D=e[40];let W;e[41]!==a?(W=n.jsx(By,{run:a}),e[41]=a,e[42]=W):W=e[42];let H;e[43]!==D||e[44]!==W||e[45]!==S||e[46]!==$?(H=n.jsx(zc,{children:n.jsxs("div",{ref:w,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[S,$,B,D,W]})}),e[43]=D,e[44]=W,e[45]=S,e[46]=$,e[47]=H):H=e[47];let U;e[48]!==x||e[49]!==d||e[50]!==g||e[51]!==a||e[52]!==p?(U=p==="agents"?n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(jy,{run:a,directory:d},a.id)}):n.jsxs(as,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[p==="log"?n.jsx(My,{run:a,detail:x}):null,p==="result"?n.jsx(Fy,{run:a,detail:x,failed:g}):null,p==="script"?n.jsx(Ly,{detail:x,failed:g}):null]}),e[48]=x,e[49]=d,e[50]=g,e[51]=a,e[52]=p,e[53]=U):U=e[53];let se;return e[54]!==j||e[55]!==H||e[56]!==U?(se=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,H,U]}),e[54]=j,e[55]=H,e[56]=U,e[57]=se):se=e[57],se};function Ky(t,e){return n.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[n.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:Oy(t.at)}),n.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function qy(t){return t.entityById}function Gy(t){return t.select}function Zy(t){return t.currentSessionId}function Xy(t){return t.select}const il=60,Yy=t=>{try{return new URL(t).origin}catch{return""}},Uo=new Set,Ad=go()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=Yy(s);!i||!r||e().byOrigin[i]||Uo.has(i)||(Uo.add(i),Sn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const d=typeof a?.dataUrl=="string"?a.dataUrl:"";d&&t(u=>{const l={...u.byOrigin,[i]:d},f=Object.keys(l);if(f.length<=il)return{byOrigin:l};for(const m of f.slice(0,f.length-il))delete l[m];return{byOrigin:l}})}).catch(()=>{}).finally(()=>{Uo.delete(i)}))}})),ea=t=>t,mi=t=>{const e=ea(t).type;return typeof e=="string"?e:""},Jy=t=>{const e=ea(t).tool;return typeof e=="string"?e:""},Qy=t=>{const e=ea(t).text;return typeof e=="string"?e:""},ev=t=>{const e=mi(t);return e==="tool"?Jy(t).trim().toLowerCase()||"tool":e||"unknown"},tv=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=ev(s);e.includes(r)||e.push(r)}return e.join(" + ")},sv=t=>t.replace(/\s+/g," ").trim(),nv=t=>{for(const s of t)if(mi(s)==="text"){const r=sv(Qy(s));if(r.length===0)continue;return r}const e=t.filter(s=>mi(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},rv=(t,e,s)=>`${s(t)} / ${s(e)}`,ov=t=>{if(t==="12h")return!0;if(t==="24h")return!1},iv=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=ov(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},av=(t,{windowTokens:e,compacted:s=!1})=>{const r=s?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}},hi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Gr={user:0,assistant:0,tool:0,other:0},Os=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Od=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...hi,total:Os(s)};if(!s||typeof s!="object")return hi;const r=s,o=Os(r.input),i=Os(r.output),a=Os(r.reasoning),d=Os(r.cache?.read),u=Os(r.cache?.write),l=Os(r.total);return{input:o,output:i,reasoning:a,cacheRead:d,cacheWrite:u,total:l>0?l:o+i+a+d+u}},lv=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},fs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+fs(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+fs(s),0):0,cv=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...Gr,assistant:fs(s.text)+fs(s.content)};const o=lv(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:fs(s.input)+fs(s.output)+fs(s.error)+fs(s.call?.input)+fs(s.call?.output)+fs(s.call?.error)+fs(s.raw)+Math.round(fs(s.metadata)*.25)+Math.round(fs(s.state)*.1)+Math.round(($u(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}},Md=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),dv=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",al=new WeakMap,uv=t=>{const e=al.get(t);if(e)return e;const s=dv(t);let r={...Gr};for(const o of t.parts)r=Md(r,cv(o,s));return al.set(t,r),r},fv=(t,e)=>{if(t.length===0)return{...Gr};const s=t.reduce((r,o)=>Md(r,uv(o)),{...Gr});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},ln=t=>t.toLocaleString(Uc()),pv=(t,e)=>!t||!Number.isFinite(t)?"-":Yh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),mv=(t,e,s)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},ll=t=>{const e=Ue.c(21),{title:s,figures:r}=t,{t:o}=lt();let i,a,d,u;if(e[0]!==r?.cacheHitPercent||e[1]!==r?.cacheRead||e[2]!==r?.cacheWrite||e[3]!==r?.output||e[4]!==r?.prompt||e[5]!==r?.reasoning||e[6]!==o||e[7]!==s){const m=[{label:o("contextSidebar.tokens.input"),value:r?.prompt??null,format:"count"},{label:o("contextSidebar.tokens.output"),value:r?.output??null,format:"count"},{label:o("contextSidebar.tokens.reasoning"),value:r?.reasoning??null,format:"count"},{label:o("contextSidebar.tokens.cacheRead"),value:r?.cacheRead??null,format:"count"},{label:o("contextSidebar.tokens.cacheWrite"),value:r?.cacheWrite??null,format:"count"},{label:o("contextSidebar.tokens.cacheHit"),value:r?.cacheHitPercent??null,format:"percent"}];d="mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",e[12]!==s?(u=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:s}),e[12]=s,e[13]=u):u=e[13],i="grid grid-cols-3 gap-x-4 gap-y-2.5",a=m.map(xv),e[0]=r?.cacheHitPercent,e[1]=r?.cacheRead,e[2]=r?.cacheWrite,e[3]=r?.output,e[4]=r?.prompt,e[5]=r?.reasoning,e[6]=o,e[7]=s,e[8]=i,e[9]=a,e[10]=d,e[11]=u}else i=e[8],a=e[9],d=e[10],u=e[11];let l;e[14]!==i||e[15]!==a?(l=n.jsx("div",{className:i,children:a}),e[14]=i,e[15]=a,e[16]=l):l=e[16];let f;return e[17]!==d||e[18]!==u||e[19]!==l?(f=n.jsxs("div",{className:d,children:[u,l]}),e[17]=d,e[18]=u,e[19]=l,e[20]=f):f=e[20],f},hv=c.memo(function(e){const s=Ue.c(54),{message:r,isExpanded:o,isCopied:i,timeFormatPreference:a,onToggle:d,onCopy:u}=e,{t:l}=lt(),f=r.info.role,m=f==="assistant",p=f==="user",h=r.info.time?.created??null;let x;s[0]!==r.parts?(x=tv(r.parts),s[0]=r.parts,s[1]=x):x=s[1];const g=x;let w,b,j,y;if(s[2]!==m||s[3]!==p||s[4]!==r||s[5]!==h||s[6]!==g||s[7]!==a){const H=m?Od(r):null;let U;s[12]!==p||s[13]!==r.parts?(U=p?nv(r.parts):"",s[12]=p,s[13]=r.parts,s[14]=U):U=s[14],y=U;let se;s[15]!==h||s[16]!==a?(se=iv(h,a),s[15]=h,s[16]=a,s[17]=se):se=s[17],b=se,w=g||"—",j=H?rv(H.input,H.output,ln):"",s[2]=m,s[3]=p,s[4]=r,s[5]=h,s[6]=g,s[7]=a,s[8]=w,s[9]=b,s[10]=j,s[11]=y}else w=s[8],b=s[9],j=s[10],y=s[11];const E=j,A=f||"unknown",R=g?`${A}: ${g}`:A;let _;s[18]!==o||s[19]!==r.info||s[20]!==r.parts?(_=o?JSON.stringify({info:r.info,parts:r.parts},null,2):"",s[18]=o,s[19]=r.info,s[20]=r.parts,s[21]=_):_=s[21];const L=_;let v;s[22]!==r.info.id||s[23]!==d?(v=()=>d(r.info.id),s[22]=r.info.id,s[23]=d,s[24]=v):v=s[24];const C=m?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content";let S;s[25]!==C?(S={gridTemplateColumns:C},s[25]=C,s[26]=S):S=s[26];let k;s[27]!==w||s[28]!==E||s[29]!==m||s[30]!==p||s[31]!==R||s[32]!==y?(k=p?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",y]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:m?w:R}),m&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:E})]}),s[27]=w,s[28]=E,s[29]=m,s[30]=p,s[31]=R,s[32]=y,s[33]=k):k=s[33];let N;s[34]!==b?(N=n.jsx("span",{className:"text-end text-muted-foreground",children:b}),s[34]=b,s[35]=N):N=s[35];let $;s[36]!==S||s[37]!==k||s[38]!==N?($=n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:S,children:[k,N]}),s[36]=S,s[37]=k,s[38]=N,s[39]=$):$=s[39];let B;s[40]!==o||s[41]!==v||s[42]!==$?(B=n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":o,onClick:v,children:$}),s[40]=o,s[41]=v,s[42]=$,s[43]=B):B=s[43];let D;s[44]!==i||s[45]!==o||s[46]!==L||s[47]!==r.info.id||s[48]!==u||s[49]!==l?(D=o&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs(as,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[n.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:H=>{H.stopPropagation(),u(r.info.id,L)},"aria-label":l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),children:i?n.jsx(ce,{name:"check",className:"size-3.5"}):n.jsx(ce,{name:"file-copy",className:"size-3.5"})})}),n.jsx(jt,{sideOffset:6,children:l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson")})]})}),n.jsx(Hh,{language:"json",code:L,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})}),s[44]=i,s[45]=o,s[46]=L,s[47]=r.info.id,s[48]=u,s[49]=l,s[50]=D):D=s[50];let W;return s[51]!==B||s[52]!==D?(W=n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[B,D]}),s[51]=B,s[52]=D,s[53]=W):W=s[53],W}),gv=()=>{const t=Ue.c(216),{t:e}=lt(),s=Kh(),r=K(bv);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=c.useState(o),[d,u]=c.useState(null),l=c.useRef(null),f=nt(wv),m=nt(yv),p=qh(m??void 0),h=Gh(f??"",m??void 0),x=Bt(vv);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),a(Sv),u(null)},t[1]=g):g=t[1];let w;t[2]!==m||t[3]!==f?(w=[m,f],t[2]=m,t[3]=f,t[4]=w):w=t[4],c.useEffect(g,w);let b,j;t[5]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},j=[],t[5]=b,t[6]=j):(b=t[5],j=t[6]),c.useEffect(b,j);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=Ye=>{a(ft=>({...ft,[Ye]:ft[Ye]!==!0}))},t[7]=y):y=t[7];const E=y;let A;t[8]===Symbol.for("react.memo_cache_sentinel")?(A=async(Ye,ft)=>{(await io(ft)).ok?(u(Ye),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{u(ht=>ht===Ye?null:ht),l.current=null},2e3)):u(null)},t[8]=A):A=t[8];const R=A;let _,L,v,C,S,k,N,$,B,D,W,H,U,se;if(t[9]!==f||t[10]!==x||t[11]!==h||t[12]!==p||t[13]!==e){S=f?p.find(Kt=>Kt.id===f)??null:null,_=h.filter(kv);let Ye;t[28]!==h?(Ye=h.filter(jv),t[28]=h,t[29]=Ye):Ye=t[29],se=Ye;let ft;t[30]!==h?(ft=Nc(h.map(Cv)),t[30]=h,t[31]=ft):ft=t[31];const Nt=ft,ht=Nt?h[Nt.index]??null:null,Ct=Nt?.state==="compacted";W=ht?Od(ht):hi,v=Zh({input:W.input,cache:{read:W.cacheRead,write:W.cacheWrite}}),H=Number.isFinite(S?.cost)?Os(S?.cost):_.reduce(Tv,0);const pt=ht?.info??null,It=x,Ht=pt?.providerID||"",dt=pt?.modelID||"";let ct;t[32]!==It||t[33]!==Ht||t[34]!==dt?(ct=mv(It,Ht,dt),t[32]=It,t[33]=Ht,t[34]=dt,t[35]=ct):ct=t[35],$=ct,C=$.contextLimit,U=Ct?null:C&&C>0?Math.min(999,W.total/C*100):0;const Mt=[...h].reverse().find(Nv),Wt=Mt?.info.role==="system"?Mt.info.text:"",Zt=fv(h,Wt);L=av(Zt,{windowTokens:W.total,compacted:Ct}),k=h[0]?.info?.time?.created,N=h.length>0?h[h.length-1]?.info?.time?.created:null,B=S?.title||e("contextSidebar.session.untitled"),D=Xh(S),t[9]=f,t[10]=x,t[11]=h,t[12]=p,t[13]=e,t[14]=_,t[15]=L,t[16]=v,t[17]=C,t[18]=S,t[19]=k,t[20]=N,t[21]=$,t[22]=B,t[23]=D,t[24]=W,t[25]=H,t[26]=U,t[27]=se}else _=t[14],L=t[15],v=t[16],C=t[17],S=t[18],k=t[19],N=t[20],$=t[21],B=t[22],D=t[23],W=t[24],H=t[25],U=t[26],se=t[27];const z=S?.time?.created??k??null,Q=N??S?.time?.created??null;let ie;t[36]!==_.length||t[37]!==L||t[38]!==v||t[39]!==C||t[40]!==$||t[41]!==h.length||t[42]!==Q||t[43]!==B||t[44]!==D||t[45]!==z||t[46]!==W||t[47]!==H||t[48]!==U||t[49]!==se.length?(ie={sessionTitle:B,sessionTotals:D,messagesCount:h.length,userMessagesCount:se.length,assistantMessagesCount:_.length,createdAt:z,lastActivityAt:Q,providerModel:$,tokenBreakdown:W,usagePercent:U,cacheHitRate:v,totalAssistantCost:H,contextLimit:C,breakdown:L,breakdownTotal:L.total},t[36]=_.length,t[37]=L,t[38]=v,t[39]=C,t[40]=$,t[41]=h.length,t[42]=Q,t[43]=B,t[44]=D,t[45]=z,t[46]=W,t[47]=H,t[48]=U,t[49]=se.length,t[50]=ie):ie=t[50];const O=ie;if(!f){let Ye;t[51]!==e?(Ye=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Ye):Ye=t[52];let ft;return t[53]!==Ye?(ft=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ye}),t[53]=Ye,t[54]=ft):ft=t[54],ft}let ne;t[55]!==e?(ne=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=ne):ne=t[56];let V;t[57]!==ne||t[58]!==O.breakdown.user?(V={key:"user",label:ne,value:O.breakdown.user,color:"var(--status-success)"},t[57]=ne,t[58]=O.breakdown.user,t[59]=V):V=t[59];let J;t[60]!==e?(J=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=J):J=t[61];let F;t[62]!==J||t[63]!==O.breakdown.assistant?(F={key:"assistant",label:J,value:O.breakdown.assistant,color:"var(--primary-base)"},t[62]=J,t[63]=O.breakdown.assistant,t[64]=F):F=t[64];let re;t[65]!==e?(re=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=re):re=t[66];let q;t[67]!==re||t[68]!==O.breakdown.tool?(q={key:"tool",label:re,value:O.breakdown.tool,color:"var(--status-warning)"},t[67]=re,t[68]=O.breakdown.tool,t[69]=q):q=t[69];let ge;t[70]!==e?(ge=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=ge):ge=t[71];let Z;t[72]!==ge||t[73]!==O.breakdown.other?(Z={key:"other",label:ge,value:O.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=ge,t[73]=O.breakdown.other,t[74]=Z):Z=t[74];let de;t[75]!==V||t[76]!==F||t[77]!==q||t[78]!==Z?(de=[V,F,q,Z],t[75]=V,t[76]=F,t[77]=q,t[78]=Z,t[79]=de):de=t[79];const Se=de;let ue;t[80]!==s||t[81]!==O.sessionTitle?(ue=s?n.jsx(zc,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:O.sessionTitle,children:O.sessionTitle})})}):null,t[80]=s,t[81]=O.sessionTitle,t[82]=ue):ue=t[82];let ke;t[83]!==s||t[84]!==O.sessionTitle?(ke=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:O.sessionTitle}),t[83]=s,t[84]=O.sessionTitle,t[85]=ke):ke=t[85];const Me=!s&&"mt-1";let We;t[86]!==Me?(We=Ze(Me,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[86]=Me,t[87]=We):We=t[87];let Le;t[88]!==O.providerModel.modelName||t[89]!==O.providerModel.providerName?(Le=n.jsxs("span",{children:[O.providerModel.providerName," / ",O.providerModel.modelName]}),t[88]=O.providerModel.modelName,t[89]=O.providerModel.providerName,t[90]=Le):Le=t[90];let Ve;t[91]!==r||t[92]!==O.createdAt?(Ve=O.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:pv(O.createdAt,r)})]}),t[91]=r,t[92]=O.createdAt,t[93]=Ve):Ve=t[93];let Ne;t[94]!==We||t[95]!==Le||t[96]!==Ve?(Ne=n.jsxs("div",{className:We,children:[Le,Ve]}),t[94]=We,t[95]=Le,t[96]=Ve,t[97]=Ne):Ne=t[97];let me;t[98]!==ke||t[99]!==Ne?(me=n.jsxs("div",{className:"mb-6",children:[ke,Ne]}),t[98]=ke,t[99]=Ne,t[100]=me):me=t[100];let ye;t[101]!==e?(ye=e("contextSidebar.section.context"),t[101]=e,t[102]=ye):ye=t[102];let je;t[103]!==ye?(je=n.jsx("span",{className:"typography-micro text-muted-foreground",children:ye}),t[103]=ye,t[104]=je):je=t[104];let Be;t[105]!==O.tokenBreakdown.total||t[106]!==O.usagePercent?(Be=O.usagePercent===null?"—":ln(O.tokenBreakdown.total),t[105]=O.tokenBreakdown.total,t[106]=O.usagePercent,t[107]=Be):Be=t[107];let _e;t[108]!==O.contextLimit?(_e=O.contextLimit?` / ${ln(O.contextLimit)}`:"",t[108]=O.contextLimit,t[109]=_e):_e=t[109];let Ie;t[110]!==Be||t[111]!==_e?(Ie=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Be,_e]}),t[110]=Be,t[111]=_e,t[112]=Ie):Ie=t[112];let tt;t[113]!==je||t[114]!==Ie?(tt=n.jsxs("div",{className:"flex items-baseline justify-between",children:[je,Ie]}),t[113]=je,t[114]=Ie,t[115]=tt):tt=t[115];let Ke;t[116]!==O.usagePercent?(Ke=O.usagePercent!==null&&O.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,O.usagePercent)}%`,backgroundColor:O.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=O.usagePercent,t[117]=Ke):Ke=t[117];let ze;t[118]!==Ke?(ze=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Ke}),t[118]=Ke,t[119]=ze):ze=t[119];let rt;t[120]!==e||t[121]!==O.usagePercent?(rt=O.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:O.usagePercent.toFixed(1)}),t[120]=e,t[121]=O.usagePercent,t[122]=rt):rt=t[122];let ve;t[123]!==rt?(ve=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:rt}),t[123]=rt,t[124]=ve):ve=t[124];let M;t[125]!==tt||t[126]!==ze||t[127]!==ve?(M=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[tt,ze,ve]}),t[125]=tt,t[126]=ze,t[127]=ve,t[128]=M):M=t[128];let Ce;t[129]!==e?(Ce=e("contextSidebar.stats.messages"),t[129]=e,t[130]=Ce):Ce=t[130];let He;t[131]!==O.messagesCount?(He=ln(O.messagesCount),t[131]=O.messagesCount,t[132]=He):He=t[132];let Xe;t[133]!==Ce||t[134]!==He?(Xe={label:Ce,value:He},t[133]=Ce,t[134]=He,t[135]=Xe):Xe=t[135];let G;t[136]!==e?(G=e("contextSidebar.stats.user"),t[136]=e,t[137]=G):G=t[137];let Ee;t[138]!==O.userMessagesCount?(Ee=ln(O.userMessagesCount),t[138]=O.userMessagesCount,t[139]=Ee):Ee=t[139];let Pe;t[140]!==G||t[141]!==Ee?(Pe={label:G,value:Ee},t[140]=G,t[141]=Ee,t[142]=Pe):Pe=t[142];let Fe;t[143]!==e?(Fe=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Fe):Fe=t[144];let Te;t[145]!==O.assistantMessagesCount?(Te=ln(O.assistantMessagesCount),t[145]=O.assistantMessagesCount,t[146]=Te):Te=t[146];let Ae;t[147]!==Fe||t[148]!==Te?(Ae={label:Fe,value:Te},t[147]=Fe,t[148]=Te,t[149]=Ae):Ae=t[149];let qe;t[150]!==e?(qe=e("contextSidebar.stats.cost"),t[150]=e,t[151]=qe):qe=t[151];let Ge;t[152]!==O.totalAssistantCost?(Ge=dd(O.totalAssistantCost),t[152]=O.totalAssistantCost,t[153]=Ge):Ge=t[153];let Je;t[154]!==qe||t[155]!==Ge?(Je={label:qe,value:Ge},t[154]=qe,t[155]=Ge,t[156]=Je):Je=t[156];let st;t[157]!==Xe||t[158]!==Pe||t[159]!==Ae||t[160]!==Je?(st=[Xe,Pe,Ae,Je],t[157]=Xe,t[158]=Pe,t[159]=Ae,t[160]=Je,t[161]=st):st=t[161];const mt=st;let Y;t[162]!==mt?(Y=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:mt.map(Ev)}),t[162]=mt,t[163]=Y):Y=t[163];let fe;t[164]!==e?(fe=e("contextSidebar.section.sessionTotals"),t[164]=e,t[165]=fe):fe=t[165];let Re;t[166]!==fe||t[167]!==O.sessionTotals?(Re=n.jsx(ll,{title:fe,figures:O.sessionTotals}),t[166]=fe,t[167]=O.sessionTotals,t[168]=Re):Re=t[168];let T;t[169]!==e?(T=e("contextSidebar.section.lastAssistantMessage"),t[169]=e,t[170]=T):T=t[170];const ae=O.tokenBreakdown.input+O.tokenBreakdown.cacheRead+O.tokenBreakdown.cacheWrite,pe=O.cacheHitRate.hasInput?O.cacheHitRate.percent:null;let oe;t[171]!==ae||t[172]!==pe||t[173]!==O.tokenBreakdown?(oe={...O.tokenBreakdown,prompt:ae,cacheHitPercent:pe},t[171]=ae,t[172]=pe,t[173]=O.tokenBreakdown,t[174]=oe):oe=t[174];let be;t[175]!==T||t[176]!==oe?(be=n.jsx(ll,{title:T,figures:oe}),t[175]=T,t[176]=oe,t[177]=be):be=t[177];let $e;t[178]!==Se||t[179]!==O.breakdownTotal?($e=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Se.map(Ye=>Ye.value<=0||O.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${Ye.value/O.breakdownTotal*100}%`,backgroundColor:Ye.color}},Ye.key))}),t[178]=Se,t[179]=O.breakdownTotal,t[180]=$e):$e=t[180];let De;t[181]!==Se||t[182]!==O.breakdownTotal?(De=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Se.map(Ye=>{const ft=O.breakdownTotal>0?Ye.value/O.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ye.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground",children:[Ye.label," ",n.jsxs("span",{className:"tabular-nums",children:[ft.toFixed(0),"%"]})]})]},Ye.key)})}),t[181]=Se,t[182]=O.breakdownTotal,t[183]=De):De=t[183];let ee;t[184]!==$e||t[185]!==De?(ee=n.jsxs("div",{className:"mb-6",children:[$e,De]}),t[184]=$e,t[185]=De,t[186]=ee):ee=t[186];let le;t[187]!==e?(le=e("contextSidebar.section.rawMessages"),t[187]=e,t[188]=le):le=t[188];let et;t[189]!==le?(et=n.jsx("div",{className:"typography-micro text-muted-foreground",children:le}),t[189]=le,t[190]=et):et=t[190];let xe;if(t[191]!==d||t[192]!==i||t[193]!==h||t[194]!==r){let Ye;t[196]!==d||t[197]!==i||t[198]!==r?(Ye=ft=>n.jsx(hv,{message:ft,isExpanded:i[ft.info.id]===!0,isCopied:d===ft.info.id,timeFormatPreference:r,onToggle:E,onCopy:R},ft.info.id),t[196]=d,t[197]=i,t[198]=r,t[199]=Ye):Ye=t[199],xe=[...h].reverse().map(Ye),t[191]=d,t[192]=i,t[193]=h,t[194]=r,t[195]=xe}else xe=t[195];let bt;t[200]!==xe?(bt=n.jsx("div",{className:"mt-2.5 space-y-1",children:xe}),t[200]=xe,t[201]=bt):bt=t[201];let Tt;t[202]!==et||t[203]!==bt?(Tt=n.jsxs("div",{children:[et,bt]}),t[202]=et,t[203]=bt,t[204]=Tt):Tt=t[204];let vt;t[205]!==me||t[206]!==M||t[207]!==Y||t[208]!==Re||t[209]!==be||t[210]!==ee||t[211]!==Tt?(vt=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[me,M,Y,Re,be,ee,Tt]}),t[205]=me,t[206]=M,t[207]=Y,t[208]=Re,t[209]=be,t[210]=ee,t[211]=Tt,t[212]=vt):vt=t[212];let Rt;return t[213]!==ue||t[214]!==vt?(Rt=n.jsxs(as,{outerClassName:"h-full",className:"bg-background",children:[ue,vt]}),t[213]=ue,t[214]=vt,t[215]=Rt):Rt=t[215],Rt};function xv(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value===null?"—":t.format==="percent"?`${t.value.toFixed(1)}%`:ln(t.value)})]},t.label)}function bv(t){return t.timeFormatPreference}function wv(t){return t.currentSessionId}function yv(t){return t.currentSessionDirectory}function vv(t){return t.providers}function Sv(t){return Object.keys(t).length>0?{}:t}function kv(t){return t.info.role==="assistant"}function jv(t){return t.info.role==="user"}function Cv(t){return t.info}function Tv(t,e){const s=Os(e.info.cost);return t+s}function Nv(t){return t.info.role==="system"}function Ev(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}const Ar=(t,e)=>{const[s,r]=c.useState(null),o=t?.id??null;return e&&s!==o&&r(o),e||s===null||s===o?t:null},Pv=280,Iv=.28,Rv=240,Dv=.35,_v=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=s?s.top:i-Math.min(Rv,e.height*Dv),d=Math.min(Pv,t.width*Iv,e.width/4),u=e.left-t.left>=1,l=r-o>=1,f=Math.max(0,a-t.top),m=u?e.left:t.left+d,p=l?o:r-d;return{left:{left:t.left,top:t.top,width:m-t.left,height:u?t.height:f},right:{left:p,top:t.top,width:r-p,height:l?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},Vo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,Av=(t,e)=>Vo(t.bottom,e)?"bottom":Vo(t.left,e)?"left":Vo(t.right,e)?"right":null,Vs=go(()=>({drag:null,hovered:null})),Or=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},Ho=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),Ko=t=>Or(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Fd=t=>{const e=Or(document.querySelector("[data-workspace-row]")),s=Or(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=_v(e,s,Or(r)),i={left:Ko("left")??Ho(o.left),right:Ko("right")??Ho(o.right),bottom:Ko("bottom")??Ho(o.bottom)};return Vs.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Ld=t=>{const{drag:e,hovered:s}=Vs.getState();if(!e)return;const r=Av(e.targets,t);r!==s&&Vs.setState({hovered:r})},gi=()=>{Vs.getState().drag&&Vs.setState({drag:null,hovered:null})},Bd=t=>{const{drag:e,hovered:s}=Vs.getState();if(Vs.setState({drag:null,hovered:null}),!e||!s)return!1;const r=K.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?rs(t):"";if(o){const i=K.getState();Ei(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},ta=(t,e)=>{let s=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(s||(s=Fd(t)),s&&Ld(a)):s&&(gi(),s=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),s?(Bd(i),!0):!1),cancel:()=>{o(),s&&gi()}}},cl={left:null,right:null,bottom:null},dr=go(()=>({body:cl,headerSlot:cl})),$d=(t,e,s)=>{const r=dr.getState()[t];r[e]!==s&&dr.setState({[t]:{...r,[e]:s}})},Ov=(t,e)=>$d("body",t,e),Mv=(t,e)=>$d("headerSlot",t,e),Xn=t=>{const e=c.useRef(t);e.current=t;const[s,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{Fi(o)},[t,o]),c.useEffect(()=>()=>Vc(o),[o]),s},qo=t=>{const e=Xn(t);return t||e},Fv=mr(()=>Ft(()=>import("./GitView-2p131yFW.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,207,208,209,210,211,212])).then(t=>({default:t.GitView}))),sa=320,zd=320,Lv=24,Bv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},dl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(sa,Math.round(t))):Ii,$v=t=>t===null?Number.POSITIVE_INFINITY:Math.max(sa,t-zd),ul=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},Mr=(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"):Pn(t)?tr.getState().guests.find(r=>r.id===zr(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),zv=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},Wv=(t,e,s)=>{if(t.mode==="chat"){const r=bo(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?ro(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?zv(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):Mr(t.mode,s)},Uv=t=>{const e=Ue.c(8),{mode:s}=t,r=qi();let o;if(e[0]!==s||e[1]!==r){let l;e[3]!==s?(l=f=>f.mode===s,e[3]=s,e[4]=l):l=e[4],o=r.find(l),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??og,d=i?.iconSrc;let u;return e[5]!==a||e[6]!==d?(u=n.jsx(Gi,{icon:a,iconSrc:d,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u},Vv=t=>{const e=Ue.c(2),{sessionId:s}=t,r=kc(s);let o;return e[0]!==r?(o=r?n.jsx(Cc,{state:r,className:"h-3.5 w-3.5"}):n.jsx(ce,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},Hv=[],Kv=(t,e,s)=>{const r=s(t);if(r)return ig(r.provider,r.identifier);const o=e.match(t);return o?ag(o.kind,o):null},qv=t=>{switch(t?.type){case"pull":return t.state?_o({kind:"pull",state:t.state.state,draft:t.state.draft},t.state):null;case"issue":return t.state?_o({kind:"issue",state:t.state.state},null):null;case"discussion":return t.state?_o({kind:"discussion",state:t.state.state,answered:t.state.answered},null):null;case"work-item":return t.state?lg(t.state.state.category):null;default:return null}},Gv=t=>{const e=Ue.c(23),{url:s,active:r,visible:o}=t,i=po(),a=Bc();let d;e[0]!==a||e[1]!==s||e[2]!==i?(d=s?Kv(s,i,a):null,e[0]=a,e[1]=s,e[2]=i,e[3]=d):d=e[3];const u=d;let l;e[4]!==u?(l=u?[u]:[],e[4]=u,e[5]=l):l=e[5];const f=l;uo(o?f:Hv);const m=sg(f)[0]??null;let p;e[6]!==m?(p=qv(m),e[6]=m,e[7]=p):p=e[7];const h=p;let x,g;if(e[8]!==r||e[9]!==h||e[10]!==a||e[11]!==s||e[12]!==i){g=Symbol.for("react.early_return_sentinel");e:{const j=s?$c(s,i,a):null;if(j&&h){let y;e[15]!==r||e[16]!==h.color?(y=r?void 0:{color:h.color},e[15]=r,e[16]=h.color,e[17]=y):y=e[17];let E;e[18]!==h.icon||e[19]!==y?(E=n.jsx(ce,{name:h.icon,className:"h-3.5 w-3.5",style:y}),e[18]=h.icon,e[19]=y,e[20]=E):E=e[20],g=E;break e}x=j?j.source==="tracker"?rg(j.provider).icon:ng[j.kind]:"git-branch"}e[8]=r,e[9]=h,e[10]=a,e[11]=s,e[12]=i,e[13]=x,e[14]=g}else x=e[13],g=e[14];if(g!==Symbol.for("react.early_return_sentinel"))return g;const w=x;let b;return e[21]!==w?(b=n.jsx(ce,{name:w,className:"h-3.5 w-3.5"}),e[21]=w,e[22]=b):b=e[22],b},fl=(t,e={},s=!0,r=!0)=>{if(t.mode==="file")return t.targetPath?n.jsx(mo,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(sp,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(ce,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(ce,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(Gv,{url:t.targetPath,active:s,visible:r});if(t.mode==="notes")return n.jsx(ce,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(ce,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(ce,{name:"pie-chart",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return n.jsx(ce,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const o=bo(t.dedupeKey);return o?n.jsx(Vv,{sessionId:o}):n.jsx(ce,{name:"chat-4",className:"h-3.5 w-3.5"})}if(Pn(t.mode))return n.jsx(Uv,{mode:t.mode});if(t.mode==="browser"){const o=Zv(t.targetPath??"",e);return o?n.jsx("img",{src:o,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(ce,{name:"global",className:"h-3.5 w-3.5"})}},Zv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Xv=t=>{const e=Kc(),s=c.useRef(qr),r=c.useRef(t);r.current=t;const o=t.length>0;return c.useSyncExternalStore(c.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),c.useCallback(()=>{const i=Array.from(e.children.values(),d=>d.getState()),a=dy(i,r.current);return ly(s.current,a)?s.current:(s.current=a,a)},[e]),()=>qr)},Yv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Jv=8,Qv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',e0=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Wd=320,na=160,xi=200,t0={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"}},pl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(na,Math.round(t))):Wd,s0=t=>t===null?Number.POSITIVE_INFINITY:Math.max(na,t-xi),Go=({zone:t="right"})=>{const e=t0[t],s=lo(),r=e.axis==="y",{t:o,direction:i}=lt(),a=i==="rtl",d=Hs()??"",u=Ql(Jh(d||null)),l=c.useCallback((te,Qe)=>o(Ls(te,u),Qe),[u,o]),f=c.useMemo(()=>Bv(d),[d]),m=K(te=>f?te.contextPanelByDirectory[f]:void 0),p=K(te=>te.contextSurfaceZones),h=K(te=>te.shortcutOverrides),x=K(te=>te.closeContextZone),g=K(te=>te.closeContextPanelTab),w=K(te=>te.pinContextPanelTab),b=K(te=>te.toggleContextPanelExpanded),j=K(te=>te.setContextZoneSize),y=K(te=>te.setContextZoneExpandedChatSize),E=K(te=>te.setActiveContextPanelTab),A=K(te=>te.reorderContextPanelTabs),R=K(te=>te.contextEditorTreeVisible),_=K(te=>te.contextEditorTreeWidth),L=K(te=>te.setContextEditorTreeWidth),v=K(te=>te.toggleContextEditorTree),C=K(te=>te.contextEditorVisible),S=K(te=>te.toggleContextEditor),k=K(te=>te.fileTreeSide),N=K(te=>te.openNewContextBrowserTab),$=Ad(te=>te.byOrigin),[B,D]=c.useState(null),W=c.useCallback(te=>{D(te),Mv(t,te)},[t]),H=c.useCallback(te=>{Ov(t,te)},[t]),U=c.useMemo(()=>m?.tabs??[],[m?.tabs]),se=m?$r(m,p,t):null,z=m?er(m,t):zu,Q=_r(te=>te.workStatusReserved),ie=_r(te=>te.workStatusBesidePanel),O=_r(te=>te.chatCovered),ne=t==="bottom"&&O,V=!!(z.isOpen&&se)&&!ne,J=Ar(se,V),F=c.useMemo(()=>U.some(te=>te.mode==="file"&&te.targetPath),[U]),re=F&&(C||!R),q=!r&&J?.mode==="file"&&!re,ge=!!(V&&z.expanded&&!q),Z=K(te=>te.contextZoneSizes[t]),de=q?_:r?pl(Z??Wd,Number.POSITIVE_INFINITY):dl(Z??Ii,Number.POSITIVE_INFINITY),Se=c.useCallback((te,Qe)=>r?pl(te,s0(Qe)):dl(te,$v(Qe)),[r]),ue=r?xi:zd,ke=K(te=>r?0:te.sidebarWidth),Me=K(te=>te.contextZoneExpandedChatSizes[t]),We=Math.max(ue,Me??(r?xi:ke)),Le=t==="right"?"left":t==="left"?"right":null,Ve=K(te=>{if(!Le||!f)return 0;const Qe=te.contextPanelByDirectory[f],gt=Qe&&Kn(Qe,te.contextSurfaceZones,Le)?$r(Qe,te.contextSurfaceZones,Le):null;return Qe&>?Wu(Qe,gt,Le,te):0}),Ne=Le==="right"&&Q&&!O&&Ve===0?yn:Ve,me=t==="right"&&Q&&!O,ye=me&&ie&&!ge,[je,Be]=c.useState(null),_e=c.useRef(null),Ie=c.useRef(Ne);Ie.current=Ne;const tt=c.useRef(V);tt.current=V;const Ke=c.useRef(()=>!1);Ke.current=te=>ge||!q&&te-Ie.current-ue<de;const ze=c.useCallback(()=>{let te=_e.current;if(te!==null&&!r&&tt.current){const Qe=document.querySelector("[data-left-sidebar]");Qe&&(te+=Math.round(Qe.getBoundingClientRect().width-(Number.parseFloat(Qe.style.width)||0)))}Be(te!==null&&Ke.current(te)?te:null)},[r]),rt=je!==null?je-Ne:null,ve=q?de:ge&&rt!==null?Math.max(r?na:sa,rt-We):Se(de,rt),M=V&&J?.mode==="chat",Ce=c.useMemo(()=>{const te=[];if(!M)return te;for(const Qe of U){if(Qe.mode!=="chat")continue;const gt=bo(Qe.dedupeKey);gt&&!te.includes(gt)&&te.push(gt)}return te},[M,U]),He=Xv(Ce),[Xe,G]=c.useState(!1),Ee=c.useRef(0),Pe=c.useRef(ve),Fe=c.useRef(null),Te=c.useRef(null),Ae=c.useRef(null),qe=c.useRef(null),Ge=c.useRef(!1);c.useLayoutEffect(()=>{const te=r?Ae.current?.parentElement:Ae.current?.closest("[data-workspace-row]");if(!te||typeof ResizeObserver>"u")return;const Qe=new ResizeObserver(gt=>{const wt=gt[gt.length-1]?.contentRect,At=r?wt?.height:wt?.width;_e.current=At?Math.round(At):null,Fi(ze)});return Qe.observe(te),_e.current=(r?te.clientHeight:te.clientWidth)||null,ze(),()=>{Qe.disconnect(),Vc(ze)}},[ze,r]);const Je=!r&&V&&(ge||je!==null),st=K(te=>Je&&te.isSidebarOpen);c.useLayoutEffect(()=>{ze()},[ze,de,ge,V,Ne,st]),c.useEffect(()=>{if(!V||Ge.current){Ge.current=V;return}const te=window.requestAnimationFrame(()=>{qe.current?.focus({preventScroll:!0})});return Ge.current=!0,()=>window.cancelAnimationFrame(te)},[V]);const mt=c.useRef(null),Y=c.useRef(null),fe=c.useRef(null),Re=c.useRef(null),T=c.useRef(!1),ae=c.useRef(null),pe=c.useRef(!1),oe=c.useCallback(te=>{const Qe=Ae.current,gt=ae.current;if(!Qe||!gt)return;const wt=r?"height":"width";Qe.style[wt]=pe.current?`${te+yn}px`:`min(${te}px, 100%)`,gt.style[wt]=`calc(${te}px - ${e.gutterSize})`},[e.gutterSize,r]),be=c.useCallback(()=>{Y.current=null;const te=Fe.current;te!==null&&oe(te)},[oe]);c.useEffect(()=>()=>{Y.current!==null&&cancelAnimationFrame(Y.current),fe.current?.(),fe.current=null,Re.current?.remove(),Re.current=null},[]);const $e=c.useCallback(te=>{const Qe=mt.current,gt=q?ei(te):Se(te,Qe);return Qe===null?gt:Math.min(gt,Math.max(1,Qe))},[Se,q]),De=c.useCallback(te=>{if(!V||!f)return;Te.current=te.pointerId,G(!0),Ee.current=r?te.clientY:te.clientX,Pe.current=ve,Fe.current=ve;const Qe=r?Ae.current?.parentElement?.clientHeight:(Ae.current?.closest("[data-workspace-row]")?.clientWidth??0)-Ie.current-(ye?yn:0);mt.current=Qe&&Qe>0?Qe:null,Re.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),Re.current=gt,fe.current?.(),fe.current=Rc(r?"height":"width"),te.preventDefault()},[ye,f,V,r,ve]),ee=c.useCallback(()=>{const te=$e(Fe.current??ve),Qe=mt.current;Y.current!==null&&(cancelAnimationFrame(Y.current),Y.current=null);const gt=Ae.current,wt=ae.current;if(gt&&wt){const At=r?"height":"width";gt.style.setProperty(e.sizeVariable,`${te}px`),gt.style[At]=xt.current,wt.style[At]=_t.current}Fe.current=null,mt.current=null,T.current=!0,Re.current?.remove(),Re.current=null,q?L(te):ge?Qe!==null&&y(t,Qe-te):j(t,te),G(!1),Te.current=null,fe.current?.(),fe.current=null},[$e,e.sizeVariable,ge,q,r,L,y,j,ve,t]);c.useEffect(()=>{if(!Xe)return;const te=wt=>{if(Te.current!==wt.pointerId)return;const At=r?wt.clientY:wt.clientX,Vt=t==="left"?At-Ee.current:Ee.current-At,ys=!r&&a?-Vt:Vt,os=$e(Pe.current+ys);Fe.current!==os&&(Fe.current=os,Y.current===null&&(Y.current=requestAnimationFrame(be)))},Qe=wt=>{Te.current===wt.pointerId&&ee()},gt=()=>{ee()};return window.addEventListener("pointermove",te),window.addEventListener("pointerup",Qe),window.addEventListener("pointercancel",Qe),window.addEventListener("blur",gt),()=>{window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",Qe),window.removeEventListener("pointercancel",Qe),window.removeEventListener("blur",gt)}},[be,$e,ee,Xe,a,r,t]),c.useEffect(()=>{Xe||(Fe.current=null,Re.current?.remove(),Re.current=null)},[Xe]);const le=c.useCallback(()=>{f&&x(f,t)},[x,f,t]),et=c.useCallback(()=>{f&&b(f,t)},[f,b,t]),xe=J?.mode==="file"||J?.mode==="chat"||J?.mode==="browser"||J?.mode==="pr",bt=c.useMemo(()=>{if(!J)return[];const te=U.filter(Qe=>Qe.mode===J.mode);return J.mode==="pr"?[...te.filter(jr),...te.filter(Qe=>!jr(Qe))]:te},[J,U]),Tt=fo(J?.mode==="pr"&&f?f:null)?.current??null,vt=J?.id,Rt=c.useMemo(()=>{const te=Qh(bt.filter(Qe=>Qe.mode==="file").map(Qe=>ul(Qe.targetPath,d)));return bt.map(Qe=>{const gt=jr(Qe),wt=gt?Tt||o("contextPanel.tracker.branchTab"):Wv(Qe,He,l),At=Yv(wt,Lv),Vt=ul(Qe.targetPath,d);return{id:Qe.id,label:At,labelFolder:Qe.mode==="file"?te.get(Vt):void 0,icon:fl(Qe,$,Qe.id===vt,V),title:Vt?`${wt}: ${Vt}`:wt,closeLabel:o("contextPanel.tab.closeTabAria",{label:At}),closeShortcut:Qe.id===vt&&Ps()?ws("mod+w",""):void 0,closable:!gt,preview:Qe.preview}})},[bt,vt,d,$,V,He,o,l,Tt]),Ye=J?.mode==="context"?n.jsx(cn,{value:B,children:n.jsx(gv,{})}):J?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(cn,{value:B,children:n.jsx(Fv,{isActive:V})})}):J?.mode==="pr"?J.targetPath?n.jsx(Yw,{url:J.targetPath,directory:J.targetDirectory??d,panelDirectory:d,tabId:J.id,foreign:!!J.targetDirectory,visible:V},J.id):n.jsx(zw,{}):J?.mode==="notes"?n.jsx(cn,{value:B,children:n.jsx(tp,{visible:V})}):J?.mode==="workflows"?n.jsx(cn,{value:B,children:n.jsx(Vy,{directory:d||null})}):null,ft=J?.mode==="file",Nt=ft&&!!J?.targetPath&&re,ht=V&&J&&xe&&!Nt&&!jr(J)?J.id:null;c.useEffect(()=>{if(!(!f||!ht))return _i(()=>g(f,ht),Ae)},[g,f,ht]);const Ct=K(te=>te.closeContextPanelTabs),pt=c.useCallback(te=>{if(!f)return null;const{id:Qe,index:gt,allIds:wt,close:At}=te,Vt=()=>Ct(f,wt.filter(Ks=>Ks!==Qe)),ys=wt.slice(0,gt),os=wt.slice(gt+1),Cs=()=>Ct(f,a?os:ys),Ts=()=>Ct(f,a?ys:os),ds=()=>Ct(f,wt),ss=wt.length>1,ps=a?gt===wt.length-1:gt===0,Qs=a?gt===0:gt===wt.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(vs,{onClick:At,children:[n.jsx(ce,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(Cn,{}),n.jsxs(vs,{onClick:Vt,disabled:!ss,children:[n.jsx(ce,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs(vs,{onClick:Cs,disabled:ps,children:[n.jsx(ce,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(vs,{onClick:Ts,disabled:Qs,children:[n.jsx(ce,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(Cn,{}),n.jsxs(vs,{onClick:ds,disabled:!ss,children:[n.jsx(ce,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),J?n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsx(bc,{mode:J.mode})]}):null]})},[J,Ct,f,a,o]),It=c.useCallback((te,Qe)=>{const gt=U.find(At=>At.id===te);if(!gt)return null;const wt=ta({mode:gt.mode,label:Mr(gt.mode,l),from:t},Qe);return{finish:()=>wt.finish(f),cancel:wt.cancel}},[f,l,U,t]),[Ht,dt]=c.useState(null),ct=c.useCallback(te=>{if(!J||te.button!==0||te.pointerType==="touch"||te.target instanceof Element&&te.target.closest(Qv))return;const Qe=J.mode,gt=Mr(Qe,l),wt={x:te.clientX,y:te.clientY};let At=!1;const Vt=Ts=>{const ds={x:Ts.clientX,y:Ts.clientY};!At&&(Math.hypot(ds.x-wt.x,ds.y-wt.y)<Jv||(At=Fd({mode:Qe,label:gt,from:t}),!At))||Ld(ds)},ys=()=>{window.removeEventListener("pointermove",Vt),window.removeEventListener("pointerup",os),window.removeEventListener("pointercancel",Cs),window.removeEventListener("blur",Cs)},os=()=>{ys(),At&&Bd(f)},Cs=()=>{ys(),At&&gi()};window.addEventListener("pointermove",Vt),window.addEventListener("pointerup",os),window.addEventListener("pointercancel",Cs),window.addEventListener("blur",Cs)},[J,f,l,t]);c.useEffect(()=>{if(Ht)return Ht.addEventListener("pointerdown",ct),()=>Ht.removeEventListener("pointerdown",ct)},[ct,Ht]);const Mt=n.jsxs("header",{ref:dt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[xe?n.jsx(eg,{items:Rt,activeId:J?.id??null,onSelect:te=>{f&&E(f,te)},onClose:te=>{f&&g(f,te)},onReorder:(te,Qe)=>{f&&A(f,te,Qe)},onDoubleClickTab:te=>{f&&w(f,te)},layoutMode:"scrollable",variant:"default",tabContextMenu:pt,onTabDragOut:It}):n.jsxs(n.Fragment,{children:[n.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:[J?fl(J,$):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:J?Mr(J.mode,l):null})]}),n.jsx("div",{ref:W,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[J?.mode==="browser"?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&N(f)},className:"h-7 w-7 p-0","aria-label":o("contextPanel.browser.newTab"),children:n.jsx(ce,{name:"add",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.browser.newTab")})]}):null,ft?["left","right"].map(te=>{const Qe=te===k;if(!Qe&&!F)return null;const gt=o(Qe?"contextRail.editorTree.toggle":"contextRail.editor.toggle"),wt=Qe?R:re,At=o(Qe?wt?"contextTooltips.panel.hideFileTree":"contextTooltips.panel.showFileTree":wt?"contextTooltips.panel.hideFileEditor":"contextTooltips.panel.showFileEditor");return n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:Qe?v:S,className:"h-7 w-7 p-0","aria-label":gt,"aria-pressed":wt,children:n.jsx(ce,{name:te==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:At})]},te)}):null,q?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:et,className:"h-7 w-7 p-0","aria-label":o(ge?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:ge?n.jsx(ce,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(ce,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:o(ge?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:ws(Ws("toggle_context_panel_expanded",h),"")})})]}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:le,className:"h-7 w-7 p-0","aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(ce,{name:"close",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.actions.closePanel")})]})]})]}),Wt=V?ye?`calc(var(${e.sizeVariable}) + ${yn}px)`:`min(var(${e.sizeVariable}), 100%)`:me?`${yn}px`:"0px",Zt=ye?`${yn}px`:"0px";pe.current=ye;const Kt=t==="bottom"&&Kn(m,p,"left"),ls=t==="bottom"&&(Q&&!O||Kn(m,p,"right")),Ut=`${V}|${ge}|${me}|${V&&ye}|${V?de:""}`,Qt=c.useRef(Ut),cs=c.useRef(O),js=cs.current!==O;c.useLayoutEffect(()=>{cs.current=O},[O]),c.useLayoutEffect(()=>{if(Qt.current===Ut)return;Qt.current=Ut;const te=T.current;!js&&!te&&Ic(s)},[Ut,js,s]),c.useLayoutEffect(()=>{T.current=!1});const Rs=!Ir(V,Xn(V),J?.mode),X={[e.sizeVariable]:`${ve}px`,...r?{height:Wt,maxHeight:"100%"}:{width:Wt,maxWidth:"100%"},transitionDuration:js||Xe?"0ms":`${s}ms`,transitionTimingFunction:In},ot=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,xt=c.useRef(Wt);xt.current=Wt;const _t=c.useRef(ot);return _t.current=ot,n.jsxs("aside",{ref:Ae,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":V?"true":"false",tabIndex:-1,className:Ze("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:X,children:[n.jsx("div",{ref:qe,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?n.jsx("div",{ref:tg,className:Ze("absolute inset-y-0 z-0 flex",ye?"inset-s-0":"inset-e-0",O&&"invisible")}):null,V&&n.jsx("div",{className:e.handle,style:{marginInlineStart:Zt},onPointerDown:De,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{ref:ae,"data-zone-card":"",className:Ze("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Kt?"ms-0":"ms-2"),t==="bottom"&&(ls?"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]",!V&&"opacity-0",Rs&&"pointer-events-none select-none"),style:{...r?{height:ot,width:`calc(100% - ${(Kt?0:.5)+(ls?0:.375)}rem)`}:{width:ot},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Zt})`}:null,transitionDuration:Xe?"0ms":`${s}ms`,transitionTimingFunction:In},inert:Rs||void 0,children:n.jsxs(Hc.Provider,{value:!0,children:[Mt,n.jsx("div",{ref:H,className:"relative min-h-0 flex-1 overflow-hidden",children:J&&e0(J.mode)?Ye:null})]})})]})},n0=Js({port:xo().int().positive(),url:Ss().min(1),command:Ss(),directory:Ss().min(1).optional()}),r0=t=>{const e=Js({servers:yd(xx())}).safeParse(t);return e.success?e.data.servers.flatMap(s=>{const r=n0.safeParse(s);return r.success?[r.data]:[]}):null},o0=async(t,e)=>{try{const s=await zs("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=r0(await s.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},i0=async t=>{try{const e=await zs("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},a0=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},l0=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=a0(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.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):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},c0=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),ml=(t,e)=>{if(!e)return null;let s=null;for(const r of t)c0(r.path,e)&&(!s||r.path.length>s.path.length)&&(s=r);return s},d0=t=>t.slice(t.lastIndexOf("/")+1)||t,u0=({candidates:t,folders:e,directory:s})=>{const r=e.flatMap(u=>{const l=Jt(u.path),f=Jt(u.projectPath);return l&&f?[{path:l,projectPath:f}]:[]}),o=Jt(s),i=o?{path:o,projectPath:ml(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(u=>{const l=Jt(u.directory),f=ml(a,l),m=u.announced?0:f&&i&&f.path===i.path?1:f&&i&&f.projectPath===i.projectPath?2:3;return{server:{...u,folderName:f?d0(f.path):null,outsideWork:l!==null&&f===null&&!u.announced},rank:m}}).sort((u,l)=>u.rank-l.rank||u.server.port-l.server.port).map(u=>u.server)},f0=t=>({sessionId:t.sessionId,directory:t.directory?rs(t.directory):null}),p0=2e3,m0=Js({title:Ss(),settled:cr()}),h0=4e4,g0=50,Yn=400,is=new Map,Is=new Map;let bi=null,wi=null;const ur=new Map;let Ms=null,Xs=null,Jn=null;const Fs=async t=>{try{const e=await zs("/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}},x0=async(t,e)=>{try{const s=await zs("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},Ud=async(t,e=p0)=>{const s=Date.now()+e;for(;!is.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,g0));return is.get(t)??null},Zr=t=>is.has(t)||Is.has(t),An=t=>is.get(t)??Is.get(t)??null,yi=()=>[...is.values(),...[...Is.values()].filter(t=>!is.has(t.tabId))],ra=t=>{const e=wi?An(wi):null,s=e?.directory===bi?e:null;if(!t.sessionId){if(s)return s.tabId;const i=yi().filter(u=>u.directory===bi),a=i.filter(u=>is.has(u.tabId)),d=a.length>0?a:i;return d.length>0?d[d.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=ur.get(t.sessionId);if(r&&An(r)?.ownerSessionId===t.sessionId)return r;const o=yi().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},b0=t=>{const e=ra(t);return e&&An(e)?.ownerSessionId===t.sessionId?e:null},w0=(t,e)=>{t.sessionId&&An(e)?.ownerSessionId===t.sessionId&&ur.set(t.sessionId,e)},Vd=async t=>{const e=is.get(t);if(e)return e;const s=Is.get(t);return s?(s.wake(),Ud(t)):null},Hd=t=>{const e=ra(t);return yi().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},Kd=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,qd=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.`,y0=t=>{const e=Hd(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 n.jsxs("div",{className:Ze("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[n.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),n.jsx("dd",{className:"min-w-0 typography-meta",children:n.jsx(wo,{node:s})})]},e)}function hy(t,e){return n.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:n.jsx(wo,{node:t})},e)}function gy(t,e){return n.jsx("li",{className:"typography-meta",children:n.jsx(wo,{node:t})},e)}function xy(t){return!t}const _d=t=>t.slice(t.indexOf("/")+1),Qi=t=>{const e=Ue.c(7),{start:s,end:r,className:o}=t,i=Dh(s!==void 0&&r===void 0);if(s===void 0)return null;let a;e[0]!==o?(a=Ze("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const d=(r??i)-s;let u;e[2]!==d?(u=_h(d),e[2]=d,e[3]=u):u=e[3];let l;return e[4]!==a||e[5]!==u?(l=n.jsx("span",{className:a,dir:"auto",children:u}),e[4]=a,e[5]=u,e[6]=l):l=e[6],l},by=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 s=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:s?void 0:Math.max(...r,...e)}},wy=t=>{const e=Ue.c(18),{run:s,groups:r}=t,{t:o}=lt();let i,a,d,u,l,f;if(e[0]!==r||e[1]!==s||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=r.filter(Cy);if(p.length===0){f=null;break e}i=as,a="overlay-scrollbar-wrapper--no-gutter",d=!1,u="flex gap-1.5 pb-1";let h;e[9]!==s||e[10]!==o?(h=x=>{const g=x.agents.length,w=by(x.agents),b=s.state==="running"&&s.currentPhase===x.title;return n.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[n.jsx("div",{className:Ze("truncate typography-meta",b?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?n.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):n.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?n.jsx(Qi,{start:w.start,end:w.end,className:"ms-auto"}):null]}),n.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?n.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]=s,e[10]=o,e[11]=h):h=e[11],l=p.map(h)}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=d,e[6]=u,e[7]=l,e[8]=f}else i=e[3],a=e[4],d=e[5],u=e[6],l=e[7],f=e[8];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[12]!==i||e[13]!==a||e[14]!==d||e[15]!==u||e[16]!==l?(m=n.jsx(i,{outerClassName:a,fillContainer:d,className:u,children:l}),e[12]=i,e[13]=a,e[14]=d,e[15]=u,e[16]=l,e[17]=m):m=e[17],m},yy=t=>{const e=Ue.c(30),{run:s,agent:r,onOpenSession:o}=t,{t:i}=lt(),[a,d]=c.useState(null),[u,l]=c.useState(!1),[f,m]=c.useState(!1);let p;e[0]!==r.key||e[1]!==s.id?(p=()=>{let E=!0;return l(!1),Ah(s.id,r.key).then(A=>{E&&d(A)}).catch(()=>{E&&l(!0)}),()=>{E=!1}},e[0]=r.key,e[1]=s.id,e[2]=p):p=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==s.id?(h=[r.key,r.state,s.id],e[3]=r.key,e[4]=r.state,e[5]=s.id,e[6]=h):h=e[6],c.useEffect(p,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?n.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]!==u||e[11]!==i?(g=u?n.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.loadFailed")}):null,e[10]=u,e[11]=i,e[12]=g):g=e[12];let w;e[13]!==a||e[14]!==u||e[15]!==i?(w=!a&&!u?n.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),n.jsx(Hi,{})]}):null,e[13]=a,e[14]=u,e[15]=i,e[16]=w):w=e[16];let b;e[17]!==a||e[18]!==f||e[19]!==i?(b=a?n.jsxs(n.Fragment,{children:[n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),n.jsx("div",{className:"mt-1",children:a.result===void 0?n.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):n.jsx(Dd,{answer:a.result})})]}),n.jsxs("section",{children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:()=>m(Ty),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[n.jsx(ce,{name:"arrow-right-s",className:Ze("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]})}),n.jsx(jt,{sideOffset:6,children:i(f?"contextTooltips.workspace.workflow.promptHide":"contextTooltips.workspace.workflow.promptShow")})]}),f?n.jsx(as,{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]=b):b=e[20];let j;e[21]!==o||e[22]!==i?(j=o?n.jsx("div",{children:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[n.jsx(ce,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}),n.jsx(jt,{sideOffset:6,children:i("contextTooltips.workspace.workflow.agentSession")})]})}):null,e[21]=o,e[22]=i,e[23]=j):j=e[23];let y;return e[24]!==x||e[25]!==g||e[26]!==w||e[27]!==b||e[28]!==j?(y=n.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,w,b,j]}),e[24]=x,e[25]=g,e[26]=w,e[27]=b,e[28]=j,e[29]=y):y=e[29],y},vy=t=>{const e=Ue.c(57),{run:s,agent:r,showModel:o,columns:i,open:a,onToggle:d,onOpenSession:u}=t,{t:l}=lt();let f,m,p,h,x,g,w,b,j,y,E;if(e[0]!==r||e[1]!==i.tokens||e[2]!==d||e[3]!==a||e[4]!==o||e[5]!==l){const v=Ih(r.state),C=Rh(r);f="button",h=d,x=a,g=r.label,w="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 S=v.icon,k=v.color?{color:v.color}:void 0,N=l(v.labelKey);e[17]!==v||e[18]!==k||e[19]!==N?(b=n.jsx(ce,{name:S,className:"size-3.5 shrink-0",style:k,"aria-label":N}),e[17]=v,e[18]=k,e[19]=N,e[20]=b):b=e[20],e[21]!==r.label?(j=n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:r.label}),e[21]=r.label,e[22]=j):j=e[22],e[23]!==r.replayed||e[24]!==l?(y=r.replayed?n.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:l("chat.workflow.agent.reused")}):null,e[23]=r.replayed,e[24]=l,e[25]=y):y=e[25],e[26]!==r.model||e[27]!==o?(E=o&&r.model?n.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:_d(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=E):E=e[28];const $=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==$?(m=n.jsx(Qi,{start:$,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=$,e[31]=m):m=e[31],p=i.tokens?n.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:C===null||r.replayed?"":Ui(C)}):null,e[0]=r,e[1]=i.tokens,e[2]=d,e[3]=a,e[4]=o,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=w,e[13]=b,e[14]=j,e[15]=y,e[16]=E}else f=e[6],m=e[7],p=e[8],h=e[9],x=e[10],g=e[11],w=e[12],b=e[13],j=e[14],y=e[15],E=e[16];let A;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(A=i.cost?n.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?Vi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=A):A=e[35];let R;e[36]!==f||e[37]!==m||e[38]!==p||e[39]!==A||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==w||e[44]!==b||e[45]!==j||e[46]!==y||e[47]!==E?(R=n.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:w,children:[b,j,y,E,m,p,A]}),e[36]=f,e[37]=m,e[38]=p,e[39]=A,e[40]=h,e[41]=x,e[42]=g,e[43]=w,e[44]=b,e[45]=j,e[46]=y,e[47]=E,e[48]=R):R=e[48];let _;e[49]!==r||e[50]!==u||e[51]!==a||e[52]!==s?(_=a?n.jsx(yy,{run:s,agent:r,onOpenSession:u}):null,e[49]=r,e[50]=u,e[51]=a,e[52]=s,e[53]=_):_=e[53];let L;return e[54]!==R||e[55]!==_?(L=n.jsxs(n.Fragment,{children:[R,_]}),e[54]=R,e[55]=_,e[56]=L):L=e[56],L},Sy=(t,e)=>{const s=Ph(t);if(s.measured===0)return null;const r=[];return e.tokens&&r.push(Ui(s.tokens)),e.cost&&s.cost>0&&r.push(Vi(s.cost)),r.length>0?r.join(" · "):null},ky=t=>{const e=new Set(t.map(r=>r.model??null)),[s]=e;return e.size===1&&s?_d(s):null},jy=t=>{const e=Ue.c(51),{run:s,directory:r}=t,{t:o}=lt();let i;e[0]!==s?(i=Th(s),e[0]=s,e[1]=i):i=e[1];const a=i,d=Nh(r),[u,l]=c.useState(Ny),[f,m]=c.useState(Ey);let p,h,x,g,w,b;if(e[2]!==a||e[3]!==u||e[4]!==d||e[5]!==s||e[6]!==o||e[7]!==f){const E=Eh(s),A=E.measured>0,R=E.cost>0;let _,L,v;if(e[14]!==a||e[15]!==u||e[16]!==d||e[17]!==s||e[18]!==o||e[19]!==A||e[20]!==R||e[21]!==f){const C={tokens:A,cost:R},S=s.agents.filter(Py).length,k=Iy;w="flex h-full min-h-0 flex-col";let N;e[28]!==a||e[29]!==s?(N=n.jsx(wy,{run:s,groups:a}),e[28]=a,e[29]=s,e[30]=N):N=e[30];const $=a.map(B=>{if(B.agents.length===0)return null;const D=B.title??"",W=B.done+B.failed===B.agents.length,U=(s.state==="running"&&W)===f.has(D),se=ky(B.agents),z=Sy(B.agents,C);return n.jsxs("section",{className:"mt-3",children:[n.jsxs("button",{type:"button",onClick:()=>k(m,D),"aria-expanded":U,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:[n.jsx(ce,{name:"arrow-right-s",className:Ze("size-3.5 shrink-0 transition-transform",U&&"rotate-90 rtl:-rotate-90")}),n.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:B.title??o("chat.workflow.phase.unphased")}),se?n.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${se}`}):null,z?n.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:z}):null,n.jsx("span",{className:Ze("shrink-0 tabular-nums font-normal",!z&&"ms-auto"),dir:"auto",children:z?`· ${B.done}/${B.agents.length}`:`${B.done}/${B.agents.length}`})]}),U?B.agents.map(Q=>{const ie=Q.sessionId;return n.jsx(vy,{run:s,agent:Q,showModel:se===null,columns:C,open:u.has(Q.key),onToggle:()=>k(l,Q.key),onOpenSession:ie?()=>d(ie,Q.label):null},Q.key)}):null]},D)});e[31]!==N||e[32]!==$?(b=n.jsxs(as,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[N,$]}),e[31]=N,e[32]=$,e[33]=b):b=e[33],p="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",L="auto",v=o("workflows.panel.summary.agents",{done:S,total:s.agents.length}),e[14]=a,e[15]=u,e[16]=d,e[17]=s,e[18]=o,e[19]=A,e[20]=R,e[21]=f,e[22]=_,e[23]=L,e[24]=v,e[25]=p,e[26]=w,e[27]=b}else _=e[22],L=e[23],v=e[24],p=e[25],w=e[26],b=e[27];e[34]!==_||e[35]!==L||e[36]!==v?(h=n.jsx("span",{className:_,dir:L,children:v}),e[34]=_,e[35]=L,e[36]=v,e[37]=h):h=e[37],e[38]!==s.endedAt||e[39]!==s.startedAt||e[40]!==s.state?(x=s.startedAt!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx(Qi,{start:s.startedAt,end:s.state==="running"?void 0:s.endedAt??s.startedAt})]}):null,e[38]=s.endedAt,e[39]=s.startedAt,e[40]=s.state,e[41]=x):x=e[41],g=E.measured>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:Ui(E.tokens)})}),E.cost>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("span",{className:"tabular-nums",dir:"ltr",children:Vi(E.cost)})]}):null]}):null,e[2]=a,e[3]=u,e[4]=d,e[5]=s,e[6]=o,e[7]=f,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=w,e[13]=b}else p=e[8],h=e[9],x=e[10],g=e[11],w=e[12],b=e[13];let j;e[42]!==p||e[43]!==h||e[44]!==x||e[45]!==g?(j=n.jsxs("div",{className:p,children:[h,x,g]}),e[42]=p,e[43]=h,e[44]=x,e[45]=g,e[46]=j):j=e[46];let y;return e[47]!==w||e[48]!==b||e[49]!==j?(y=n.jsxs("div",{className:w,children:[b,j]}),e[47]=w,e[48]=b,e[49]=j,e[50]=y):y=e[50],y};function Cy(t){return t.title!==null}function Ty(t){return!t}function Ny(){return new Set}function Ey(){return new Set}function Py(t){return t.state==="completed"}function Iy(t,e){return t(s=>{const r=new Set(s);return r.has(e)?r.delete(e):r.add(e),r})}const Ry={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},Dy=[{id:"agents",icon:"flow-chart",labelKey:"workflows.panel.view.agents",tooltipKey:"contextTooltips.workspace.workflow.view.agents"},{id:"log",icon:"file-list-2",labelKey:"workflows.panel.view.log",tooltipKey:"contextTooltips.workspace.workflow.view.log"},{id:"result",icon:"checkbox-circle",labelKey:"workflows.panel.view.result",tooltipKey:"contextTooltips.workspace.workflow.view.result"},{id:"script",icon:"code-sslash",labelKey:"workflows.panel.view.script",tooltipKey:"contextTooltips.workspace.workflow.view.script"}],_y=1500,Ay=(t,e)=>{const s=Ue.c(11),[r,o]=c.useState(null),[i,a]=c.useState(null),d=c.useRef(null),u=e!=="agents",l=e==="log"&&t.state==="running"?t.logs.at(-1)?.at??0:0;let f;s[0]!==t.id||s[1]!==u?(f=()=>{if(!u)return;let g=!0;const w=d.current?.runId===t.id?d.current.at:0,b=Math.max(0,w+_y-Date.now()),j=setTimeout(()=>{d.current={runId:t.id,at:Date.now()},Vh(t.id).then(y=>{g&&(o(y),a(null))}).catch(()=>{g&&a(t.id)})},b);return()=>{g=!1,clearTimeout(j)}},s[0]=t.id,s[1]=u,s[2]=f):f=s[2];let m;s[3]!==l||s[4]!==t.id||s[5]!==t.state||s[6]!==u?(m=[l,t.id,t.state,u],s[3]=l,s[4]=t.id,s[5]=t.state,s[6]=u,s[7]=m):m=s[7],c.useEffect(f,m);const p=r?.runId===t.id?r:null,h=i===t.id;let x;return s[8]!==p||s[9]!==h?(x={detail:p,failed:h},s[8]=p,s[9]=h,s[10]=x):x=s[10],x},Oy=t=>new Intl.DateTimeFormat(Uc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),My=t=>{const e=Ue.c(8),{run:s,detail:r}=t,{t:o}=lt(),i=r?.logs??s.logs;if(i.length===0){let u;e[0]!==o?(u=o("workflows.panel.log.empty"),e[0]=o,e[1]=u):u=e[1];let l;return e[2]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[2]=u,e[3]=l):l=e[3],l}let a;e[4]!==i?(a=i.map(Ky),e[4]=i,e[5]=a):a=e[5];let d;return e[6]!==a?(d=n.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=d):d=e[7],d},Fy=t=>{const e=Ue.c(24),{run:s,detail:r,failed:o}=t,{t:i}=lt();if(s.error&&(s.state==="failed"||s.state==="stopped")){const u=s.state==="failed"?"var(--status-error)":void 0;let l;e[0]!==u?(l={color:u},e[0]=u,e[1]=l):l=e[1];let f;return e[2]!==s.error||e[3]!==l?(f=n.jsx("p",{dir:"auto",className:"px-4 py-6 typography-meta",style:l,children:s.error}),e[2]=s.error,e[3]=l,e[4]=f):f=e[4],f}if(s.state==="awaiting-approval"||s.state==="running"||s.state==="declined"){let u;e[5]!==i?(u=i("workflows.panel.result.pending"),e[5]=i,e[6]=u):u=e[6];let l;return e[7]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[7]=u,e[8]=l):l=e[8],l}if(o&&!r){let u;e[9]!==i?(u=i("workflows.panel.detail.loadFailed"),e[9]=i,e[10]=u):u=e[10];let l;return e[11]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[11]=u,e[12]=l):l=e[12],l}if(!r){let u;e[13]!==i?(u=i("workflows.panel.agent.loading"),e[13]=i,e[14]=u):u=e[14];let l;e[15]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Hi,{}),e[15]=l):l=e[15];let f;return e[16]!==u?(f=n.jsxs("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:[u,l]}),e[16]=u,e[17]=f):f=e[17],f}const{result:a}=r;if(!a||a.kind==="json"&&a.value===null){let u;e[18]!==i?(u=i("workflows.panel.result.none"),e[18]=i,e[19]=u):u=e[19];let l;return e[20]!==u?(l=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=l):l=e[21],l}let d;return e[22]!==a?(d=n.jsx("div",{className:"px-4 py-3",children:n.jsx(Dd,{answer:a})}),e[22]=a,e[23]=d):d=e[23],d},Ly=t=>{const e=Ue.c(16),{detail:s,failed:r}=t,{t:o}=lt();if(!s){let m;e[0]!==r||e[1]!==o?(m=r?o("workflows.panel.detail.loadFailed"):n.jsxs(n.Fragment,{children:[o("workflows.panel.agent.loading"),n.jsx(Hi,{})]}),e[0]=r,e[1]=o,e[2]=m):m=e[2];let p;return e[3]!==m?(p=n.jsx("p",{className:"px-4 py-6 typography-meta text-muted-foreground",children:m}),e[3]=m,e[4]=p):p=e[4],p}const i=s.args;let a;e[5]!==i?(a=i!=null&&JSON.stringify(i)!=="{}",e[5]=i,e[6]=a):a=e[6];const d=a;let u;e[7]!==i||e[8]!==d||e[9]!==o?(u=d?n.jsxs("section",{children:[n.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),n.jsx(as,{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]=d,e[9]=o,e[10]=u):u=e[10];let l;e[11]!==s.script?(l=n.jsx(as,{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:s.script}),e[11]=s.script,e[12]=l):l=e[12];let f;return e[13]!==u||e[14]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3",children:[u,l]}),e[13]=u,e[14]=l,e[15]=f):f=e[15],f},By=t=>{const e=Ue.c(83),{run:s}=t,{t:r}=lt(),{pending:o,act:i}=Uh(),a=o===s.id;if(s.state==="awaiting-approval"){let d;e[0]!==r?(d=r("contextTooltips.workspace.workflow.approve"),e[0]=r,e[1]=d):d=e[1];let u;e[2]!==i||e[3]!==s.id?(u=()=>i(s.id,"approve"),e[2]=i,e[3]=s.id,e[4]=u):u=e[4];let l;e[5]!==r?(l=r("chat.workflow.action.run"),e[5]=r,e[6]=l):l=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ce,{name:"play",className:"size-3.5"}),e[7]=f):f=e[7];let m;e[8]!==r?(m=r("chat.workflow.action.run"),e[8]=r,e[9]=m):m=e[9];let p;e[10]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[10]=m,e[11]=p):p=e[11];let h;e[12]!==a||e[13]!==u||e[14]!==l||e[15]!==p?(h=n.jsxs(ut,{type:"button",size:"sm",disabled:a,onClick:u,"aria-label":l,children:[f,p]}),e[12]=a,e[13]=u,e[14]=l,e[15]=p,e[16]=h):h=e[16];let x;e[17]!==d||e[18]!==h?(x=n.jsx(ns,{label:d,side:"bottom",className:"shrink-0",children:h}),e[17]=d,e[18]=h,e[19]=x):x=e[19];let g;e[20]!==r?(g=r("contextTooltips.workspace.workflow.decline"),e[20]=r,e[21]=g):g=e[21];let w;e[22]!==i||e[23]!==s.id?(w=()=>i(s.id,"decline"),e[22]=i,e[23]=s.id,e[24]=w):w=e[24];let b;e[25]!==r?(b=r("chat.workflow.action.decline"),e[25]=r,e[26]=b):b=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(ce,{name:"close",className:"size-3.5"}),e[27]=j):j=e[27];let y;e[28]!==r?(y=r("chat.workflow.action.decline"),e[28]=r,e[29]=y):y=e[29];let E;e[30]!==y?(E=n.jsx("span",{className:"workflows-header__action-label",children:y}),e[30]=y,e[31]=E):E=e[31];let A;e[32]!==a||e[33]!==w||e[34]!==b||e[35]!==E?(A=n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:w,"aria-label":b,children:[j,E]}),e[32]=a,e[33]=w,e[34]=b,e[35]=E,e[36]=A):A=e[36];let R;e[37]!==A||e[38]!==g?(R=n.jsx(ns,{label:g,side:"bottom",className:"shrink-0",children:A}),e[37]=A,e[38]=g,e[39]=R):R=e[39];let _;return e[40]!==R||e[41]!==x?(_=n.jsxs(n.Fragment,{children:[x,R]}),e[40]=R,e[41]=x,e[42]=_):_=e[42],_}if(s.state==="running"){let d;e[43]!==r?(d=r("contextTooltips.workspace.workflow.stop"),e[43]=r,e[44]=d):d=e[44];let u;e[45]!==i||e[46]!==s.id?(u=()=>i(s.id,"stop"),e[45]=i,e[46]=s.id,e[47]=u):u=e[47];let l;e[48]!==r?(l=r("chat.workflow.action.stop"),e[48]=r,e[49]=l):l=e[49];let f;e[50]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ce,{name:"stop",className:"size-3.5"}),e[50]=f):f=e[50];let m;e[51]!==r?(m=r("chat.workflow.action.stop"),e[51]=r,e[52]=m):m=e[52];let p;e[53]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[53]=m,e[54]=p):p=e[54];let h;e[55]!==a||e[56]!==u||e[57]!==l||e[58]!==p?(h=n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":l,children:[f,p]}),e[55]=a,e[56]=u,e[57]=l,e[58]=p,e[59]=h):h=e[59];let x;return e[60]!==d||e[61]!==h?(x=n.jsx(ns,{label:d,side:"bottom",className:"shrink-0",children:h}),e[60]=d,e[61]=h,e[62]=x):x=e[62],x}if(s.state==="failed"||s.state==="stopped"){let d;e[63]!==r?(d=r("contextTooltips.workspace.workflow.resume"),e[63]=r,e[64]=d):d=e[64];let u;e[65]!==i||e[66]!==s.id?(u=()=>i(s.id,"resume"),e[65]=i,e[66]=s.id,e[67]=u):u=e[67];let l;e[68]!==r?(l=r("chat.workflow.action.resume"),e[68]=r,e[69]=l):l=e[69];let f;e[70]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(ce,{name:"restart",className:"size-3.5"}),e[70]=f):f=e[70];let m;e[71]!==r?(m=r("chat.workflow.action.resume"),e[71]=r,e[72]=m):m=e[72];let p;e[73]!==m?(p=n.jsx("span",{className:"workflows-header__action-label",children:m}),e[73]=m,e[74]=p):p=e[74];let h;e[75]!==a||e[76]!==u||e[77]!==l||e[78]!==p?(h=n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:u,"aria-label":l,children:[f,p]}),e[75]=a,e[76]=u,e[77]=l,e[78]=p,e[79]=h):h=e[79];let x;return e[80]!==d||e[81]!==h?(x=n.jsx(ns,{label:d,side:"bottom",className:"shrink-0",children:h}),e[80]=d,e[81]=h,e[82]=x):x=e[82],x}return null},$y=()=>{const t=Ue.c(2),e=ts(qy);let s;return t[0]!==e?(s={get:r=>e.get(r)?.title},t[0]=e,t[1]=s):s=t[1],s},ol=t=>{const e=Ue.c(31),{run:s,selected:r,caption:o,onSelect:i}=t,{t:a}=lt();let d,u,l,f,m,p,h;if(e[0]!==i||e[1]!==s.state||e[2]!==a){const E=Wc(s.state);u=$s,h=i,d=ce,l=E.icon,f="size-3.5 shrink-0",m=E.color?{color:E.color}:void 0,p=a(E.labelKey),e[0]=i,e[1]=s.state,e[2]=a,e[3]=d,e[4]=u,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h}else d=e[3],u=e[4],l=e[5],f=e[6],m=e[7],p=e[8],h=e[9];let x;e[10]!==d||e[11]!==l||e[12]!==f||e[13]!==m||e[14]!==p?(x=n.jsx(d,{name:l,className:f,style:m,"aria-label":p}),e[10]=d,e[11]=l,e[12]=f,e[13]=m,e[14]=p,e[15]=x):x=e[15];let g;e[16]!==s.name?(g=n.jsx("span",{className:"truncate",dir:"auto",children:s.name}),e[16]=s.name,e[17]=g):g=e[17];let w;e[18]!==o?(w=o?n.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=w):w=e[19];let b;e[20]!==g||e[21]!==w?(b=n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,w]}),e[20]=g,e[21]=w,e[22]=b):b=e[22];let j;e[23]!==r?(j=r?n.jsx(ce,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=j):j=e[24];let y;return e[25]!==u||e[26]!==j||e[27]!==h||e[28]!==x||e[29]!==b?(y=n.jsxs(u,{onSelect:h,children:[x,b,j]}),e[25]=u,e[26]=j,e[27]=h,e[28]=x,e[29]=b,e[30]=y):y=e[30],y},zy=t=>{const e=Ue.c(63),{runs:s,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:d,onRunSaved:u,onDelete:l}=t,{t:f}=lt();let m;e[0]!==r.state?(m=Wc(r.state),e[0]=r.state,e[1]=m):m=e[1];const p=m;let h,x,g,w,b,j,y;if(e[2]!==p.color||e[3]!==p.icon||e[4]!==d||e[5]!==s||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const L=s.slice().reverse();let v;e[18]!==o?(v=Q=>Q.parentSessionId===o,e[18]=o,e[19]=v):v=e[19];const C=L.filter(v);let S;e[20]!==o?(S=Q=>Q.parentSessionId!==o,e[20]=o,e[21]=S):S=e[21];const k=L.filter(S);x=fn;let N;e[22]!==f?(N=f("workflows.panel.runPicker"),e[22]=f,e[23]=N):N=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=Ze(Wh(),"max-w-[14rem] shrink-0"),e[24]=$):$=e[24];let B;e[25]!==p.color?(B=p.color?{color:p.color}:void 0,e[25]=p.color,e[26]=B):B=e[26];let D;e[27]!==p.icon||e[28]!==B?(D=n.jsx(ce,{name:p.icon,className:"size-3.5",style:B}),e[27]=p.icon,e[28]=B,e[29]=D):D=e[29];let W;e[30]!==r.name?(W=n.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=W):W=e[31];let H;e[32]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(ce,{name:"arrow-down-s",className:"size-4"}),e[32]=H):H=e[32];let U;e[33]!==D||e[34]!==W||e[35]!==N?(U=n.jsx(St,{asChild:!0,children:n.jsx(pn,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":N,className:$,children:[D,W,H]})})}),e[33]=D,e[34]=W,e[35]=N,e[36]=U):U=e[36];let se;e[37]!==f?(se=f("contextTooltips.workspace.workflow.pickRun"),e[37]=f,e[38]=se):se=e[38];let z;e[39]!==se?(z=n.jsx(jt,{side:"bottom",sideOffset:6,children:se}),e[39]=se,e[40]=z):z=e[40],e[41]!==U||e[42]!==z?(y=n.jsxs(kt,{children:[U,z]}),e[41]=U,e[42]=z,e[43]=y):y=e[43],h=mn,g="start",w="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",b=C.length>0?n.jsxs(n.Fragment,{children:[n.jsx(Dr,{children:f("workflows.panel.picker.thisSession")}),C.map(Q=>n.jsx(ol,{run:Q,selected:Q.id===r.id,onSelect:()=>d(Q.id)},Q.id))]}):null,j=k.length>0?n.jsxs(n.Fragment,{children:[C.length>0?n.jsx(qn,{}):null,n.jsx(Dr,{children:f("workflows.panel.picker.otherSessions")}),k.map(Q=>n.jsx(ol,{run:Q,selected:Q.id===r.id,caption:i.get(Q.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>d(Q.id)},Q.id))]}):null,e[2]=p.color,e[3]=p.icon,e[4]=d,e[5]=s,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]=w,e[15]=b,e[16]=j,e[17]=y}else h=e[11],x=e[12],g=e[13],w=e[14],b=e[15],j=e[16],y=e[17];let E;e[44]!==u||e[45]!==a||e[46]!==f?(E=a.length>0?n.jsxs(n.Fragment,{children:[n.jsx(qn,{}),n.jsx(Dr,{children:f("workflows.panel.picker.saved")}),a.map(L=>n.jsxs($s,{disabled:!!L.error,onSelect:()=>u(L.name),title:L.error??L.description,children:[n.jsx(ce,{name:"play",className:"size-3.5 shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:L.name})]},L.name))]}):null,e[44]=u,e[45]=a,e[46]=f,e[47]=E):E=e[47];let A;e[48]!==l||e[49]!==f?(A=l?n.jsxs(n.Fragment,{children:[n.jsx(qn,{}),n.jsxs($s,{variant:"destructive",onSelect:l,children:[n.jsx(ce,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[48]=l,e[49]=f,e[50]=A):A=e[50];let R;e[51]!==h||e[52]!==g||e[53]!==w||e[54]!==b||e[55]!==j||e[56]!==E||e[57]!==A?(R=n.jsxs(h,{align:g,className:w,children:[b,j,E,A]}),e[51]=h,e[52]=g,e[53]=w,e[54]=b,e[55]=j,e[56]=E,e[57]=A,e[58]=R):R=e[58];let _;return e[59]!==x||e[60]!==y||e[61]!==R?(_=n.jsxs(x,{children:[y,R]}),e[59]=x,e[60]=y,e[61]=R,e[62]=_):_=e[62],_},Wy=(t,e,s,r)=>{const o=Ue.c(11),{t:i}=lt(),{confirm:a,dialog:d}=Wi(),u=Ki(Gy);let l;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==u||o[4]!==r||o[5]!==s||o[6]!==i?(l=async p=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:p}),message:i(s?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const x=await Lh({directory:t,scriptDirectory:e,sessionId:s,name:p});s?u(r,x.runId):(u(x.sessionId,x.runId),nt.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;Oe.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]=u,o[4]=r,o[5]=s,o[6]=i,o[7]=l):l=o[7];const f=l;let m;return o[8]!==d||o[9]!==f?(m={run:f,dialog:d},o[8]=d,o[9]=f,o[10]=m):m=o[10],m},Uy=t=>{const e=Ue.c(23),{saved:s,onRunSaved:r}=t,{t:o}=lt();if(s.length===0){let m;e[0]!==o?(m=o("workflows.panel.emptyProject"),e[0]=o,e[1]=m):m=e[1];let p;return e[2]!==m?(p=n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-meta text-muted-foreground",children:m}),e[2]=m,e[3]=p):p=e[3],p}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=n.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[6]=i,e[7]=a):a=e[7];let d;e[8]!==o?(d=o("workflows.panel.picker.saved"),e[8]=o,e[9]=d):d=e[9];let u;e[10]!==d?(u=n.jsx("h4",{className:"mt-2 typography-micro font-medium text-muted-foreground",children:d}),e[10]=d,e[11]=u):u=e[11];let l;if(e[12]!==r||e[13]!==s||e[14]!==o){let m;e[16]!==r||e[17]!==o?(m=p=>n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:p.name}),p.description||p.error?n.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:p.error??p.description,children:p.error??p.description}):null]}),n.jsx(ns,{label:o("workflows.panel.saved.runAria",{name:p.name}),className:"shrink-0",children:n.jsxs(ut,{type:"button",size:"sm",variant:"outline",disabled:!!p.error,onClick:()=>r(p.name),"aria-label":o("workflows.panel.saved.runAria",{name:p.name}),children:[n.jsx(ce,{name:"play",className:"size-3.5"}),o("workflows.panel.saved.confirmAction")]})})]},p.name),e[16]=r,e[17]=o,e[18]=m):m=e[18],l=s.map(m),e[12]=r,e[13]=s,e[14]=o,e[15]=l}else l=e[15];let f;return e[19]!==a||e[20]!==u||e[21]!==l?(f=n.jsxs("div",{className:"flex flex-col gap-1 px-3 py-3",children:[a,u,l]}),e[19]=a,e[20]=u,e[21]=l,e[22]=f):f=e[22],f},Vy=t=>{const e=Ue.c(17),{directory:s}=t,r=nt(Zy),o=Oh(s),i=Mh(o),a=Fh(o?.savedDirectory??null),d=r??`directory:${s??""}`;let u;e[0]!==d?(u=w=>w.selectedBySession[d],e[0]=d,e[1]=u):u=e[1];const l=Ki(u),{run:f,dialog:m}=Wy(s,o?.savedDirectory??null,r,d);let p;e[2]!==i||e[3]!==l||e[4]!==r?(p=i.find(w=>w.id===l)??i.filter(w=>w.parentSessionId===r).at(-1)??i.at(-1)??null,e[2]=i,e[3]=l,e[4]=r,e[5]=p):p=e[5];const h=p;let x;e[6]!==s||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==d||e[12]!==r?(x=h?n.jsx(Hy,{sessionId:r,selectionKey:d,runs:i,saved:a,run:h,directory:s,onRunSaved:w=>{f(w)}}):n.jsx(Uy,{saved:a,onRunSaved:w=>{f(w)}}),e[6]=s,e[7]=h,e[8]=f,e[9]=i,e[10]=a,e[11]=d,e[12]=r,e[13]=x):x=e[13];let g;return e[14]!==m||e[15]!==x?(g=n.jsxs(n.Fragment,{children:[m,x]}),e[14]=m,e[15]=x,e[16]=g):g=e[16],g},Hy=t=>{const e=Ue.c(58),{sessionId:s,selectionKey:r,runs:o,saved:i,run:a,directory:d,onRunSaved:u}=t,{t:l}=lt(),f=Ki(Xy),m=$y(),[p,h]=c.useState("agents"),{detail:x,failed:g}=Ay(a,p),w=c.useRef(null);Bh(w,Ry);const{confirm:b,dialog:j}=Wi(),y=a.state==="running"||a.state==="awaiting-approval",E=a.parentSessionId!==s;let A;e[0]!==b||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==l?(A=async()=>{if(await b({title:l("workflows.panel.delete.title",{name:a.name}),message:l("workflows.panel.delete.message"),action:l("workflows.panel.delete.confirm"),destructive:!0}))try{await $h(a.id),zh.getState().remove(a.parentSessionId,a.id)}catch(Q){const ie=Q;Oe.error(l("workflows.panel.delete.failed"),{description:ie instanceof Error?ie.message:void 0})}},e[0]=b,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=l,e[5]=A):A=e[5];const R=A;let _;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(_=()=>{f(a.parentSessionId,a.id),nt.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 L=_;let v;e[11]!==f||e[12]!==r?(v=z=>f(r,z),e[11]=f,e[12]=r,e[13]=v):v=e[13];let C;e[14]!==R||e[15]!==y?(C=y?null:()=>{R()},e[14]=R,e[15]=y,e[16]=C):C=e[16];let S;e[17]!==u||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==s||e[22]!==m||e[23]!==v||e[24]!==C?(S=n.jsx(zy,{runs:o,selected:a,sessionId:s,sessionTitles:m,saved:i,onSelect:v,onRunSaved:u,onDelete:C}),e[17]=u,e[18]=a,e[19]=o,e[20]=i,e[21]=s,e[22]=m,e[23]=v,e[24]=C,e[25]=S):S=e[25];let k;e[26]!==l?(k=l("workflows.panel.view.label"),e[26]=l,e[27]=k):k=e[27];let N;e[28]!==l||e[29]!==p?(N=Dy.map(z=>{const Q=z.id===p;return n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:()=>h(z.id),"aria-current":Q?"page":void 0,"aria-label":l(z.labelKey),className:Ze("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",Q?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[n.jsx(ce,{name:z.icon,className:"size-3.5 shrink-0"}),n.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:l(z.labelKey)})]})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:l(z.tooltipKey)})]},z.id)}),e[28]=l,e[29]=p,e[30]=N):N=e[30];let $;e[31]!==k||e[32]!==N?($=n.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":k,children:N}),e[31]=k,e[32]=N,e[33]=$):$=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=B):B=e[34];let D;e[35]!==E||e[36]!==L||e[37]!==a.parentSessionId||e[38]!==m||e[39]!==l?(D=E?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{type:"button",size:"sm",variant:"ghost",onClick:L,"aria-label":l("workflows.panel.agent.openSession"),children:[n.jsx(ce,{name:"chat-4",className:"size-3.5"}),n.jsx("span",{className:"workflows-header__action-label",children:l("workflows.panel.agent.openSession")})]})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:m.get(a.parentSessionId)||l("workflows.panel.picker.untitledSession")})]}):null,e[35]=E,e[36]=L,e[37]=a.parentSessionId,e[38]=m,e[39]=l,e[40]=D):D=e[40];let W;e[41]!==a?(W=n.jsx(By,{run:a}),e[41]=a,e[42]=W):W=e[42];let H;e[43]!==D||e[44]!==W||e[45]!==S||e[46]!==$?(H=n.jsx(zc,{children:n.jsxs("div",{ref:w,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[S,$,B,D,W]})}),e[43]=D,e[44]=W,e[45]=S,e[46]=$,e[47]=H):H=e[47];let U;e[48]!==x||e[49]!==d||e[50]!==g||e[51]!==a||e[52]!==p?(U=p==="agents"?n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(jy,{run:a,directory:d},a.id)}):n.jsxs(as,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[p==="log"?n.jsx(My,{run:a,detail:x}):null,p==="result"?n.jsx(Fy,{run:a,detail:x,failed:g}):null,p==="script"?n.jsx(Ly,{detail:x,failed:g}):null]}),e[48]=x,e[49]=d,e[50]=g,e[51]=a,e[52]=p,e[53]=U):U=e[53];let se;return e[54]!==j||e[55]!==H||e[56]!==U?(se=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,H,U]}),e[54]=j,e[55]=H,e[56]=U,e[57]=se):se=e[57],se};function Ky(t,e){return n.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[n.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:Oy(t.at)}),n.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function qy(t){return t.entityById}function Gy(t){return t.select}function Zy(t){return t.currentSessionId}function Xy(t){return t.select}const il=60,Yy=t=>{try{return new URL(t).origin}catch{return""}},Uo=new Set,Ad=go()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=Yy(s);!i||!r||e().byOrigin[i]||Uo.has(i)||(Uo.add(i),Sn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const d=typeof a?.dataUrl=="string"?a.dataUrl:"";d&&t(u=>{const l={...u.byOrigin,[i]:d},f=Object.keys(l);if(f.length<=il)return{byOrigin:l};for(const m of f.slice(0,f.length-il))delete l[m];return{byOrigin:l}})}).catch(()=>{}).finally(()=>{Uo.delete(i)}))}})),ea=t=>t,mi=t=>{const e=ea(t).type;return typeof e=="string"?e:""},Jy=t=>{const e=ea(t).tool;return typeof e=="string"?e:""},Qy=t=>{const e=ea(t).text;return typeof e=="string"?e:""},ev=t=>{const e=mi(t);return e==="tool"?Jy(t).trim().toLowerCase()||"tool":e||"unknown"},tv=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=ev(s);e.includes(r)||e.push(r)}return e.join(" + ")},sv=t=>t.replace(/\s+/g," ").trim(),nv=t=>{for(const s of t)if(mi(s)==="text"){const r=sv(Qy(s));if(r.length===0)continue;return r}const e=t.filter(s=>mi(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},rv=(t,e,s)=>`${s(t)} / ${s(e)}`,ov=t=>{if(t==="12h")return!0;if(t==="24h")return!1},iv=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=ov(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},av=(t,{windowTokens:e,compacted:s=!1})=>{const r=s?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}},hi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Gr={user:0,assistant:0,tool:0,other:0},Os=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Od=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...hi,total:Os(s)};if(!s||typeof s!="object")return hi;const r=s,o=Os(r.input),i=Os(r.output),a=Os(r.reasoning),d=Os(r.cache?.read),u=Os(r.cache?.write),l=Os(r.total);return{input:o,output:i,reasoning:a,cacheRead:d,cacheWrite:u,total:l>0?l:o+i+a+d+u}},lv=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},fs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+fs(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+fs(s),0):0,cv=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...Gr,assistant:fs(s.text)+fs(s.content)};const o=lv(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:fs(s.input)+fs(s.output)+fs(s.error)+fs(s.call?.input)+fs(s.call?.output)+fs(s.call?.error)+fs(s.raw)+Math.round(fs(s.metadata)*.25)+Math.round(fs(s.state)*.1)+Math.round(($u(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}},Md=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),dv=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",al=new WeakMap,uv=t=>{const e=al.get(t);if(e)return e;const s=dv(t);let r={...Gr};for(const o of t.parts)r=Md(r,cv(o,s));return al.set(t,r),r},fv=(t,e)=>{if(t.length===0)return{...Gr};const s=t.reduce((r,o)=>Md(r,uv(o)),{...Gr});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},ln=t=>t.toLocaleString(Uc()),pv=(t,e)=>!t||!Number.isFinite(t)?"-":Yh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),mv=(t,e,s)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},ll=t=>{const e=Ue.c(21),{title:s,figures:r}=t,{t:o}=lt();let i,a,d,u;if(e[0]!==r?.cacheHitPercent||e[1]!==r?.cacheRead||e[2]!==r?.cacheWrite||e[3]!==r?.output||e[4]!==r?.prompt||e[5]!==r?.reasoning||e[6]!==o||e[7]!==s){const m=[{label:o("contextSidebar.tokens.input"),value:r?.prompt??null,format:"count"},{label:o("contextSidebar.tokens.output"),value:r?.output??null,format:"count"},{label:o("contextSidebar.tokens.reasoning"),value:r?.reasoning??null,format:"count"},{label:o("contextSidebar.tokens.cacheRead"),value:r?.cacheRead??null,format:"count"},{label:o("contextSidebar.tokens.cacheWrite"),value:r?.cacheWrite??null,format:"count"},{label:o("contextSidebar.tokens.cacheHit"),value:r?.cacheHitPercent??null,format:"percent"}];d="mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",e[12]!==s?(u=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:s}),e[12]=s,e[13]=u):u=e[13],i="grid grid-cols-3 gap-x-4 gap-y-2.5",a=m.map(xv),e[0]=r?.cacheHitPercent,e[1]=r?.cacheRead,e[2]=r?.cacheWrite,e[3]=r?.output,e[4]=r?.prompt,e[5]=r?.reasoning,e[6]=o,e[7]=s,e[8]=i,e[9]=a,e[10]=d,e[11]=u}else i=e[8],a=e[9],d=e[10],u=e[11];let l;e[14]!==i||e[15]!==a?(l=n.jsx("div",{className:i,children:a}),e[14]=i,e[15]=a,e[16]=l):l=e[16];let f;return e[17]!==d||e[18]!==u||e[19]!==l?(f=n.jsxs("div",{className:d,children:[u,l]}),e[17]=d,e[18]=u,e[19]=l,e[20]=f):f=e[20],f},hv=c.memo(function(e){const s=Ue.c(54),{message:r,isExpanded:o,isCopied:i,timeFormatPreference:a,onToggle:d,onCopy:u}=e,{t:l}=lt(),f=r.info.role,m=f==="assistant",p=f==="user",h=r.info.time?.created??null;let x;s[0]!==r.parts?(x=tv(r.parts),s[0]=r.parts,s[1]=x):x=s[1];const g=x;let w,b,j,y;if(s[2]!==m||s[3]!==p||s[4]!==r||s[5]!==h||s[6]!==g||s[7]!==a){const H=m?Od(r):null;let U;s[12]!==p||s[13]!==r.parts?(U=p?nv(r.parts):"",s[12]=p,s[13]=r.parts,s[14]=U):U=s[14],y=U;let se;s[15]!==h||s[16]!==a?(se=iv(h,a),s[15]=h,s[16]=a,s[17]=se):se=s[17],b=se,w=g||"—",j=H?rv(H.input,H.output,ln):"",s[2]=m,s[3]=p,s[4]=r,s[5]=h,s[6]=g,s[7]=a,s[8]=w,s[9]=b,s[10]=j,s[11]=y}else w=s[8],b=s[9],j=s[10],y=s[11];const E=j,A=f||"unknown",R=g?`${A}: ${g}`:A;let _;s[18]!==o||s[19]!==r.info||s[20]!==r.parts?(_=o?JSON.stringify({info:r.info,parts:r.parts},null,2):"",s[18]=o,s[19]=r.info,s[20]=r.parts,s[21]=_):_=s[21];const L=_;let v;s[22]!==r.info.id||s[23]!==d?(v=()=>d(r.info.id),s[22]=r.info.id,s[23]=d,s[24]=v):v=s[24];const C=m?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content";let S;s[25]!==C?(S={gridTemplateColumns:C},s[25]=C,s[26]=S):S=s[26];let k;s[27]!==w||s[28]!==E||s[29]!==m||s[30]!==p||s[31]!==R||s[32]!==y?(k=p?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",y]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:m?w:R}),m&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:E})]}),s[27]=w,s[28]=E,s[29]=m,s[30]=p,s[31]=R,s[32]=y,s[33]=k):k=s[33];let N;s[34]!==b?(N=n.jsx("span",{className:"text-end text-muted-foreground",children:b}),s[34]=b,s[35]=N):N=s[35];let $;s[36]!==S||s[37]!==k||s[38]!==N?($=n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:S,children:[k,N]}),s[36]=S,s[37]=k,s[38]=N,s[39]=$):$=s[39];let B;s[40]!==o||s[41]!==v||s[42]!==$?(B=n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":o,onClick:v,children:$}),s[40]=o,s[41]=v,s[42]=$,s[43]=B):B=s[43];let D;s[44]!==i||s[45]!==o||s[46]!==L||s[47]!==r.info.id||s[48]!==u||s[49]!==l?(D=o&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs(as,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[n.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:H=>{H.stopPropagation(),u(r.info.id,L)},"aria-label":l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),children:i?n.jsx(ce,{name:"check",className:"size-3.5"}):n.jsx(ce,{name:"file-copy",className:"size-3.5"})})}),n.jsx(jt,{sideOffset:6,children:l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson")})]})}),n.jsx(Hh,{language:"json",code:L,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})}),s[44]=i,s[45]=o,s[46]=L,s[47]=r.info.id,s[48]=u,s[49]=l,s[50]=D):D=s[50];let W;return s[51]!==B||s[52]!==D?(W=n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[B,D]}),s[51]=B,s[52]=D,s[53]=W):W=s[53],W}),gv=()=>{const t=Ue.c(216),{t:e}=lt(),s=Kh(),r=K(bv);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=c.useState(o),[d,u]=c.useState(null),l=c.useRef(null),f=nt(wv),m=nt(yv),p=qh(m??void 0),h=Gh(f??"",m??void 0),x=Bt(vv);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),a(Sv),u(null)},t[1]=g):g=t[1];let w;t[2]!==m||t[3]!==f?(w=[m,f],t[2]=m,t[3]=f,t[4]=w):w=t[4],c.useEffect(g,w);let b,j;t[5]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},j=[],t[5]=b,t[6]=j):(b=t[5],j=t[6]),c.useEffect(b,j);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=Ye=>{a(ft=>({...ft,[Ye]:ft[Ye]!==!0}))},t[7]=y):y=t[7];const E=y;let A;t[8]===Symbol.for("react.memo_cache_sentinel")?(A=async(Ye,ft)=>{(await io(ft)).ok?(u(Ye),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{u(ht=>ht===Ye?null:ht),l.current=null},2e3)):u(null)},t[8]=A):A=t[8];const R=A;let _,L,v,C,S,k,N,$,B,D,W,H,U,se;if(t[9]!==f||t[10]!==x||t[11]!==h||t[12]!==p||t[13]!==e){S=f?p.find(Kt=>Kt.id===f)??null:null,_=h.filter(kv);let Ye;t[28]!==h?(Ye=h.filter(jv),t[28]=h,t[29]=Ye):Ye=t[29],se=Ye;let ft;t[30]!==h?(ft=Nc(h.map(Cv)),t[30]=h,t[31]=ft):ft=t[31];const Nt=ft,ht=Nt?h[Nt.index]??null:null,Ct=Nt?.state==="compacted";W=ht?Od(ht):hi,v=Zh({input:W.input,cache:{read:W.cacheRead,write:W.cacheWrite}}),H=Number.isFinite(S?.cost)?Os(S?.cost):_.reduce(Tv,0);const pt=ht?.info??null,It=x,Ht=pt?.providerID||"",dt=pt?.modelID||"";let ct;t[32]!==It||t[33]!==Ht||t[34]!==dt?(ct=mv(It,Ht,dt),t[32]=It,t[33]=Ht,t[34]=dt,t[35]=ct):ct=t[35],$=ct,C=$.contextLimit,U=Ct?null:C&&C>0?Math.min(999,W.total/C*100):0;const Mt=[...h].reverse().find(Nv),Wt=Mt?.info.role==="system"?Mt.info.text:"",Zt=fv(h,Wt);L=av(Zt,{windowTokens:W.total,compacted:Ct}),k=h[0]?.info?.time?.created,N=h.length>0?h[h.length-1]?.info?.time?.created:null,B=S?.title||e("contextSidebar.session.untitled"),D=Xh(S),t[9]=f,t[10]=x,t[11]=h,t[12]=p,t[13]=e,t[14]=_,t[15]=L,t[16]=v,t[17]=C,t[18]=S,t[19]=k,t[20]=N,t[21]=$,t[22]=B,t[23]=D,t[24]=W,t[25]=H,t[26]=U,t[27]=se}else _=t[14],L=t[15],v=t[16],C=t[17],S=t[18],k=t[19],N=t[20],$=t[21],B=t[22],D=t[23],W=t[24],H=t[25],U=t[26],se=t[27];const z=S?.time?.created??k??null,Q=N??S?.time?.created??null;let ie;t[36]!==_.length||t[37]!==L||t[38]!==v||t[39]!==C||t[40]!==$||t[41]!==h.length||t[42]!==Q||t[43]!==B||t[44]!==D||t[45]!==z||t[46]!==W||t[47]!==H||t[48]!==U||t[49]!==se.length?(ie={sessionTitle:B,sessionTotals:D,messagesCount:h.length,userMessagesCount:se.length,assistantMessagesCount:_.length,createdAt:z,lastActivityAt:Q,providerModel:$,tokenBreakdown:W,usagePercent:U,cacheHitRate:v,totalAssistantCost:H,contextLimit:C,breakdown:L,breakdownTotal:L.total},t[36]=_.length,t[37]=L,t[38]=v,t[39]=C,t[40]=$,t[41]=h.length,t[42]=Q,t[43]=B,t[44]=D,t[45]=z,t[46]=W,t[47]=H,t[48]=U,t[49]=se.length,t[50]=ie):ie=t[50];const O=ie;if(!f){let Ye;t[51]!==e?(Ye=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Ye):Ye=t[52];let ft;return t[53]!==Ye?(ft=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ye}),t[53]=Ye,t[54]=ft):ft=t[54],ft}let ne;t[55]!==e?(ne=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=ne):ne=t[56];let V;t[57]!==ne||t[58]!==O.breakdown.user?(V={key:"user",label:ne,value:O.breakdown.user,color:"var(--status-success)"},t[57]=ne,t[58]=O.breakdown.user,t[59]=V):V=t[59];let J;t[60]!==e?(J=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=J):J=t[61];let F;t[62]!==J||t[63]!==O.breakdown.assistant?(F={key:"assistant",label:J,value:O.breakdown.assistant,color:"var(--primary-base)"},t[62]=J,t[63]=O.breakdown.assistant,t[64]=F):F=t[64];let re;t[65]!==e?(re=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=re):re=t[66];let q;t[67]!==re||t[68]!==O.breakdown.tool?(q={key:"tool",label:re,value:O.breakdown.tool,color:"var(--status-warning)"},t[67]=re,t[68]=O.breakdown.tool,t[69]=q):q=t[69];let ge;t[70]!==e?(ge=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=ge):ge=t[71];let Z;t[72]!==ge||t[73]!==O.breakdown.other?(Z={key:"other",label:ge,value:O.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=ge,t[73]=O.breakdown.other,t[74]=Z):Z=t[74];let de;t[75]!==V||t[76]!==F||t[77]!==q||t[78]!==Z?(de=[V,F,q,Z],t[75]=V,t[76]=F,t[77]=q,t[78]=Z,t[79]=de):de=t[79];const Se=de;let ue;t[80]!==s||t[81]!==O.sessionTitle?(ue=s?n.jsx(zc,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:O.sessionTitle,children:O.sessionTitle})})}):null,t[80]=s,t[81]=O.sessionTitle,t[82]=ue):ue=t[82];let ke;t[83]!==s||t[84]!==O.sessionTitle?(ke=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:O.sessionTitle}),t[83]=s,t[84]=O.sessionTitle,t[85]=ke):ke=t[85];const Me=!s&&"mt-1";let We;t[86]!==Me?(We=Ze(Me,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[86]=Me,t[87]=We):We=t[87];let Le;t[88]!==O.providerModel.modelName||t[89]!==O.providerModel.providerName?(Le=n.jsxs("span",{children:[O.providerModel.providerName," / ",O.providerModel.modelName]}),t[88]=O.providerModel.modelName,t[89]=O.providerModel.providerName,t[90]=Le):Le=t[90];let Ve;t[91]!==r||t[92]!==O.createdAt?(Ve=O.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:pv(O.createdAt,r)})]}),t[91]=r,t[92]=O.createdAt,t[93]=Ve):Ve=t[93];let Ne;t[94]!==We||t[95]!==Le||t[96]!==Ve?(Ne=n.jsxs("div",{className:We,children:[Le,Ve]}),t[94]=We,t[95]=Le,t[96]=Ve,t[97]=Ne):Ne=t[97];let me;t[98]!==ke||t[99]!==Ne?(me=n.jsxs("div",{className:"mb-6",children:[ke,Ne]}),t[98]=ke,t[99]=Ne,t[100]=me):me=t[100];let ye;t[101]!==e?(ye=e("contextSidebar.section.context"),t[101]=e,t[102]=ye):ye=t[102];let je;t[103]!==ye?(je=n.jsx("span",{className:"typography-micro text-muted-foreground",children:ye}),t[103]=ye,t[104]=je):je=t[104];let Be;t[105]!==O.tokenBreakdown.total||t[106]!==O.usagePercent?(Be=O.usagePercent===null?"—":ln(O.tokenBreakdown.total),t[105]=O.tokenBreakdown.total,t[106]=O.usagePercent,t[107]=Be):Be=t[107];let _e;t[108]!==O.contextLimit?(_e=O.contextLimit?` / ${ln(O.contextLimit)}`:"",t[108]=O.contextLimit,t[109]=_e):_e=t[109];let Ie;t[110]!==Be||t[111]!==_e?(Ie=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Be,_e]}),t[110]=Be,t[111]=_e,t[112]=Ie):Ie=t[112];let tt;t[113]!==je||t[114]!==Ie?(tt=n.jsxs("div",{className:"flex items-baseline justify-between",children:[je,Ie]}),t[113]=je,t[114]=Ie,t[115]=tt):tt=t[115];let Ke;t[116]!==O.usagePercent?(Ke=O.usagePercent!==null&&O.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,O.usagePercent)}%`,backgroundColor:O.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=O.usagePercent,t[117]=Ke):Ke=t[117];let ze;t[118]!==Ke?(ze=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Ke}),t[118]=Ke,t[119]=ze):ze=t[119];let rt;t[120]!==e||t[121]!==O.usagePercent?(rt=O.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:O.usagePercent.toFixed(1)}),t[120]=e,t[121]=O.usagePercent,t[122]=rt):rt=t[122];let ve;t[123]!==rt?(ve=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:rt}),t[123]=rt,t[124]=ve):ve=t[124];let M;t[125]!==tt||t[126]!==ze||t[127]!==ve?(M=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[tt,ze,ve]}),t[125]=tt,t[126]=ze,t[127]=ve,t[128]=M):M=t[128];let Ce;t[129]!==e?(Ce=e("contextSidebar.stats.messages"),t[129]=e,t[130]=Ce):Ce=t[130];let He;t[131]!==O.messagesCount?(He=ln(O.messagesCount),t[131]=O.messagesCount,t[132]=He):He=t[132];let Xe;t[133]!==Ce||t[134]!==He?(Xe={label:Ce,value:He},t[133]=Ce,t[134]=He,t[135]=Xe):Xe=t[135];let G;t[136]!==e?(G=e("contextSidebar.stats.user"),t[136]=e,t[137]=G):G=t[137];let Ee;t[138]!==O.userMessagesCount?(Ee=ln(O.userMessagesCount),t[138]=O.userMessagesCount,t[139]=Ee):Ee=t[139];let Pe;t[140]!==G||t[141]!==Ee?(Pe={label:G,value:Ee},t[140]=G,t[141]=Ee,t[142]=Pe):Pe=t[142];let Fe;t[143]!==e?(Fe=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Fe):Fe=t[144];let Te;t[145]!==O.assistantMessagesCount?(Te=ln(O.assistantMessagesCount),t[145]=O.assistantMessagesCount,t[146]=Te):Te=t[146];let Ae;t[147]!==Fe||t[148]!==Te?(Ae={label:Fe,value:Te},t[147]=Fe,t[148]=Te,t[149]=Ae):Ae=t[149];let qe;t[150]!==e?(qe=e("contextSidebar.stats.cost"),t[150]=e,t[151]=qe):qe=t[151];let Ge;t[152]!==O.totalAssistantCost?(Ge=dd(O.totalAssistantCost),t[152]=O.totalAssistantCost,t[153]=Ge):Ge=t[153];let Je;t[154]!==qe||t[155]!==Ge?(Je={label:qe,value:Ge},t[154]=qe,t[155]=Ge,t[156]=Je):Je=t[156];let st;t[157]!==Xe||t[158]!==Pe||t[159]!==Ae||t[160]!==Je?(st=[Xe,Pe,Ae,Je],t[157]=Xe,t[158]=Pe,t[159]=Ae,t[160]=Je,t[161]=st):st=t[161];const mt=st;let Y;t[162]!==mt?(Y=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:mt.map(Ev)}),t[162]=mt,t[163]=Y):Y=t[163];let fe;t[164]!==e?(fe=e("contextSidebar.section.sessionTotals"),t[164]=e,t[165]=fe):fe=t[165];let Re;t[166]!==fe||t[167]!==O.sessionTotals?(Re=n.jsx(ll,{title:fe,figures:O.sessionTotals}),t[166]=fe,t[167]=O.sessionTotals,t[168]=Re):Re=t[168];let T;t[169]!==e?(T=e("contextSidebar.section.lastAssistantMessage"),t[169]=e,t[170]=T):T=t[170];const ae=O.tokenBreakdown.input+O.tokenBreakdown.cacheRead+O.tokenBreakdown.cacheWrite,pe=O.cacheHitRate.hasInput?O.cacheHitRate.percent:null;let oe;t[171]!==ae||t[172]!==pe||t[173]!==O.tokenBreakdown?(oe={...O.tokenBreakdown,prompt:ae,cacheHitPercent:pe},t[171]=ae,t[172]=pe,t[173]=O.tokenBreakdown,t[174]=oe):oe=t[174];let be;t[175]!==T||t[176]!==oe?(be=n.jsx(ll,{title:T,figures:oe}),t[175]=T,t[176]=oe,t[177]=be):be=t[177];let $e;t[178]!==Se||t[179]!==O.breakdownTotal?($e=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Se.map(Ye=>Ye.value<=0||O.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${Ye.value/O.breakdownTotal*100}%`,backgroundColor:Ye.color}},Ye.key))}),t[178]=Se,t[179]=O.breakdownTotal,t[180]=$e):$e=t[180];let De;t[181]!==Se||t[182]!==O.breakdownTotal?(De=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Se.map(Ye=>{const ft=O.breakdownTotal>0?Ye.value/O.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ye.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground",children:[Ye.label," ",n.jsxs("span",{className:"tabular-nums",children:[ft.toFixed(0),"%"]})]})]},Ye.key)})}),t[181]=Se,t[182]=O.breakdownTotal,t[183]=De):De=t[183];let ee;t[184]!==$e||t[185]!==De?(ee=n.jsxs("div",{className:"mb-6",children:[$e,De]}),t[184]=$e,t[185]=De,t[186]=ee):ee=t[186];let le;t[187]!==e?(le=e("contextSidebar.section.rawMessages"),t[187]=e,t[188]=le):le=t[188];let et;t[189]!==le?(et=n.jsx("div",{className:"typography-micro text-muted-foreground",children:le}),t[189]=le,t[190]=et):et=t[190];let xe;if(t[191]!==d||t[192]!==i||t[193]!==h||t[194]!==r){let Ye;t[196]!==d||t[197]!==i||t[198]!==r?(Ye=ft=>n.jsx(hv,{message:ft,isExpanded:i[ft.info.id]===!0,isCopied:d===ft.info.id,timeFormatPreference:r,onToggle:E,onCopy:R},ft.info.id),t[196]=d,t[197]=i,t[198]=r,t[199]=Ye):Ye=t[199],xe=[...h].reverse().map(Ye),t[191]=d,t[192]=i,t[193]=h,t[194]=r,t[195]=xe}else xe=t[195];let bt;t[200]!==xe?(bt=n.jsx("div",{className:"mt-2.5 space-y-1",children:xe}),t[200]=xe,t[201]=bt):bt=t[201];let Tt;t[202]!==et||t[203]!==bt?(Tt=n.jsxs("div",{children:[et,bt]}),t[202]=et,t[203]=bt,t[204]=Tt):Tt=t[204];let vt;t[205]!==me||t[206]!==M||t[207]!==Y||t[208]!==Re||t[209]!==be||t[210]!==ee||t[211]!==Tt?(vt=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[me,M,Y,Re,be,ee,Tt]}),t[205]=me,t[206]=M,t[207]=Y,t[208]=Re,t[209]=be,t[210]=ee,t[211]=Tt,t[212]=vt):vt=t[212];let Rt;return t[213]!==ue||t[214]!==vt?(Rt=n.jsxs(as,{outerClassName:"h-full",className:"bg-background",children:[ue,vt]}),t[213]=ue,t[214]=vt,t[215]=Rt):Rt=t[215],Rt};function xv(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value===null?"—":t.format==="percent"?`${t.value.toFixed(1)}%`:ln(t.value)})]},t.label)}function bv(t){return t.timeFormatPreference}function wv(t){return t.currentSessionId}function yv(t){return t.currentSessionDirectory}function vv(t){return t.providers}function Sv(t){return Object.keys(t).length>0?{}:t}function kv(t){return t.info.role==="assistant"}function jv(t){return t.info.role==="user"}function Cv(t){return t.info}function Tv(t,e){const s=Os(e.info.cost);return t+s}function Nv(t){return t.info.role==="system"}function Ev(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}const Ar=(t,e)=>{const[s,r]=c.useState(null),o=t?.id??null;return e&&s!==o&&r(o),e||s===null||s===o?t:null},Pv=280,Iv=.28,Rv=240,Dv=.35,_v=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=s?s.top:i-Math.min(Rv,e.height*Dv),d=Math.min(Pv,t.width*Iv,e.width/4),u=e.left-t.left>=1,l=r-o>=1,f=Math.max(0,a-t.top),m=u?e.left:t.left+d,p=l?o:r-d;return{left:{left:t.left,top:t.top,width:m-t.left,height:u?t.height:f},right:{left:p,top:t.top,width:r-p,height:l?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},Vo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,Av=(t,e)=>Vo(t.bottom,e)?"bottom":Vo(t.left,e)?"left":Vo(t.right,e)?"right":null,Vs=go(()=>({drag:null,hovered:null})),Or=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},Ho=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),Ko=t=>Or(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Fd=t=>{const e=Or(document.querySelector("[data-workspace-row]")),s=Or(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=_v(e,s,Or(r)),i={left:Ko("left")??Ho(o.left),right:Ko("right")??Ho(o.right),bottom:Ko("bottom")??Ho(o.bottom)};return Vs.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Ld=t=>{const{drag:e,hovered:s}=Vs.getState();if(!e)return;const r=Av(e.targets,t);r!==s&&Vs.setState({hovered:r})},gi=()=>{Vs.getState().drag&&Vs.setState({drag:null,hovered:null})},Bd=t=>{const{drag:e,hovered:s}=Vs.getState();if(Vs.setState({drag:null,hovered:null}),!e||!s)return!1;const r=K.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?rs(t):"";if(o){const i=K.getState();Ei(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},ta=(t,e)=>{let s=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(s||(s=Fd(t)),s&&Ld(a)):s&&(gi(),s=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),s?(Bd(i),!0):!1),cancel:()=>{o(),s&&gi()}}},cl={left:null,right:null,bottom:null},dr=go(()=>({body:cl,headerSlot:cl})),$d=(t,e,s)=>{const r=dr.getState()[t];r[e]!==s&&dr.setState({[t]:{...r,[e]:s}})},Ov=(t,e)=>$d("body",t,e),Mv=(t,e)=>$d("headerSlot",t,e),Xn=t=>{const e=c.useRef(t);e.current=t;const[s,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{Fi(o)},[t,o]),c.useEffect(()=>()=>Vc(o),[o]),s},qo=t=>{const e=Xn(t);return t||e},Fv=mr(()=>Ft(()=>import("./GitView-C5sudp8H.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,207,208,209,210,211,212])).then(t=>({default:t.GitView}))),sa=320,zd=320,Lv=24,Bv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},dl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(sa,Math.round(t))):Ii,$v=t=>t===null?Number.POSITIVE_INFINITY:Math.max(sa,t-zd),ul=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},Mr=(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"):Pn(t)?tr.getState().guests.find(r=>r.id===zr(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),zv=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},Wv=(t,e,s)=>{if(t.mode==="chat"){const r=bo(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?ro(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?zv(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):Mr(t.mode,s)},Uv=t=>{const e=Ue.c(8),{mode:s}=t,r=qi();let o;if(e[0]!==s||e[1]!==r){let l;e[3]!==s?(l=f=>f.mode===s,e[3]=s,e[4]=l):l=e[4],o=r.find(l),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??og,d=i?.iconSrc;let u;return e[5]!==a||e[6]!==d?(u=n.jsx(Gi,{icon:a,iconSrc:d,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u},Vv=t=>{const e=Ue.c(2),{sessionId:s}=t,r=kc(s);let o;return e[0]!==r?(o=r?n.jsx(Cc,{state:r,className:"h-3.5 w-3.5"}):n.jsx(ce,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},Hv=[],Kv=(t,e,s)=>{const r=s(t);if(r)return ig(r.provider,r.identifier);const o=e.match(t);return o?ag(o.kind,o):null},qv=t=>{switch(t?.type){case"pull":return t.state?_o({kind:"pull",state:t.state.state,draft:t.state.draft},t.state):null;case"issue":return t.state?_o({kind:"issue",state:t.state.state},null):null;case"discussion":return t.state?_o({kind:"discussion",state:t.state.state,answered:t.state.answered},null):null;case"work-item":return t.state?lg(t.state.state.category):null;default:return null}},Gv=t=>{const e=Ue.c(23),{url:s,active:r,visible:o}=t,i=po(),a=Bc();let d;e[0]!==a||e[1]!==s||e[2]!==i?(d=s?Kv(s,i,a):null,e[0]=a,e[1]=s,e[2]=i,e[3]=d):d=e[3];const u=d;let l;e[4]!==u?(l=u?[u]:[],e[4]=u,e[5]=l):l=e[5];const f=l;uo(o?f:Hv);const m=sg(f)[0]??null;let p;e[6]!==m?(p=qv(m),e[6]=m,e[7]=p):p=e[7];const h=p;let x,g;if(e[8]!==r||e[9]!==h||e[10]!==a||e[11]!==s||e[12]!==i){g=Symbol.for("react.early_return_sentinel");e:{const j=s?$c(s,i,a):null;if(j&&h){let y;e[15]!==r||e[16]!==h.color?(y=r?void 0:{color:h.color},e[15]=r,e[16]=h.color,e[17]=y):y=e[17];let E;e[18]!==h.icon||e[19]!==y?(E=n.jsx(ce,{name:h.icon,className:"h-3.5 w-3.5",style:y}),e[18]=h.icon,e[19]=y,e[20]=E):E=e[20],g=E;break e}x=j?j.source==="tracker"?rg(j.provider).icon:ng[j.kind]:"git-branch"}e[8]=r,e[9]=h,e[10]=a,e[11]=s,e[12]=i,e[13]=x,e[14]=g}else x=e[13],g=e[14];if(g!==Symbol.for("react.early_return_sentinel"))return g;const w=x;let b;return e[21]!==w?(b=n.jsx(ce,{name:w,className:"h-3.5 w-3.5"}),e[21]=w,e[22]=b):b=e[22],b},fl=(t,e={},s=!0,r=!0)=>{if(t.mode==="file")return t.targetPath?n.jsx(mo,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(sp,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(ce,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(ce,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(Gv,{url:t.targetPath,active:s,visible:r});if(t.mode==="notes")return n.jsx(ce,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(ce,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(ce,{name:"pie-chart",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return n.jsx(ce,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const o=bo(t.dedupeKey);return o?n.jsx(Vv,{sessionId:o}):n.jsx(ce,{name:"chat-4",className:"h-3.5 w-3.5"})}if(Pn(t.mode))return n.jsx(Uv,{mode:t.mode});if(t.mode==="browser"){const o=Zv(t.targetPath??"",e);return o?n.jsx("img",{src:o,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(ce,{name:"global",className:"h-3.5 w-3.5"})}},Zv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Xv=t=>{const e=Kc(),s=c.useRef(qr),r=c.useRef(t);r.current=t;const o=t.length>0;return c.useSyncExternalStore(c.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),c.useCallback(()=>{const i=Array.from(e.children.values(),d=>d.getState()),a=dy(i,r.current);return ly(s.current,a)?s.current:(s.current=a,a)},[e]),()=>qr)},Yv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Jv=8,Qv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',e0=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Wd=320,na=160,xi=200,t0={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"}},pl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(na,Math.round(t))):Wd,s0=t=>t===null?Number.POSITIVE_INFINITY:Math.max(na,t-xi),Go=({zone:t="right"})=>{const e=t0[t],s=lo(),r=e.axis==="y",{t:o,direction:i}=lt(),a=i==="rtl",d=Hs()??"",u=Ql(Jh(d||null)),l=c.useCallback((te,Qe)=>o(Ls(te,u),Qe),[u,o]),f=c.useMemo(()=>Bv(d),[d]),m=K(te=>f?te.contextPanelByDirectory[f]:void 0),p=K(te=>te.contextSurfaceZones),h=K(te=>te.shortcutOverrides),x=K(te=>te.closeContextZone),g=K(te=>te.closeContextPanelTab),w=K(te=>te.pinContextPanelTab),b=K(te=>te.toggleContextPanelExpanded),j=K(te=>te.setContextZoneSize),y=K(te=>te.setContextZoneExpandedChatSize),E=K(te=>te.setActiveContextPanelTab),A=K(te=>te.reorderContextPanelTabs),R=K(te=>te.contextEditorTreeVisible),_=K(te=>te.contextEditorTreeWidth),L=K(te=>te.setContextEditorTreeWidth),v=K(te=>te.toggleContextEditorTree),C=K(te=>te.contextEditorVisible),S=K(te=>te.toggleContextEditor),k=K(te=>te.fileTreeSide),N=K(te=>te.openNewContextBrowserTab),$=Ad(te=>te.byOrigin),[B,D]=c.useState(null),W=c.useCallback(te=>{D(te),Mv(t,te)},[t]),H=c.useCallback(te=>{Ov(t,te)},[t]),U=c.useMemo(()=>m?.tabs??[],[m?.tabs]),se=m?$r(m,p,t):null,z=m?er(m,t):zu,Q=_r(te=>te.workStatusReserved),ie=_r(te=>te.workStatusBesidePanel),O=_r(te=>te.chatCovered),ne=t==="bottom"&&O,V=!!(z.isOpen&&se)&&!ne,J=Ar(se,V),F=c.useMemo(()=>U.some(te=>te.mode==="file"&&te.targetPath),[U]),re=F&&(C||!R),q=!r&&J?.mode==="file"&&!re,ge=!!(V&&z.expanded&&!q),Z=K(te=>te.contextZoneSizes[t]),de=q?_:r?pl(Z??Wd,Number.POSITIVE_INFINITY):dl(Z??Ii,Number.POSITIVE_INFINITY),Se=c.useCallback((te,Qe)=>r?pl(te,s0(Qe)):dl(te,$v(Qe)),[r]),ue=r?xi:zd,ke=K(te=>r?0:te.sidebarWidth),Me=K(te=>te.contextZoneExpandedChatSizes[t]),We=Math.max(ue,Me??(r?xi:ke)),Le=t==="right"?"left":t==="left"?"right":null,Ve=K(te=>{if(!Le||!f)return 0;const Qe=te.contextPanelByDirectory[f],gt=Qe&&Kn(Qe,te.contextSurfaceZones,Le)?$r(Qe,te.contextSurfaceZones,Le):null;return Qe&>?Wu(Qe,gt,Le,te):0}),Ne=Le==="right"&&Q&&!O&&Ve===0?yn:Ve,me=t==="right"&&Q&&!O,ye=me&&ie&&!ge,[je,Be]=c.useState(null),_e=c.useRef(null),Ie=c.useRef(Ne);Ie.current=Ne;const tt=c.useRef(V);tt.current=V;const Ke=c.useRef(()=>!1);Ke.current=te=>ge||!q&&te-Ie.current-ue<de;const ze=c.useCallback(()=>{let te=_e.current;if(te!==null&&!r&&tt.current){const Qe=document.querySelector("[data-left-sidebar]");Qe&&(te+=Math.round(Qe.getBoundingClientRect().width-(Number.parseFloat(Qe.style.width)||0)))}Be(te!==null&&Ke.current(te)?te:null)},[r]),rt=je!==null?je-Ne:null,ve=q?de:ge&&rt!==null?Math.max(r?na:sa,rt-We):Se(de,rt),M=V&&J?.mode==="chat",Ce=c.useMemo(()=>{const te=[];if(!M)return te;for(const Qe of U){if(Qe.mode!=="chat")continue;const gt=bo(Qe.dedupeKey);gt&&!te.includes(gt)&&te.push(gt)}return te},[M,U]),He=Xv(Ce),[Xe,G]=c.useState(!1),Ee=c.useRef(0),Pe=c.useRef(ve),Fe=c.useRef(null),Te=c.useRef(null),Ae=c.useRef(null),qe=c.useRef(null),Ge=c.useRef(!1);c.useLayoutEffect(()=>{const te=r?Ae.current?.parentElement:Ae.current?.closest("[data-workspace-row]");if(!te||typeof ResizeObserver>"u")return;const Qe=new ResizeObserver(gt=>{const wt=gt[gt.length-1]?.contentRect,At=r?wt?.height:wt?.width;_e.current=At?Math.round(At):null,Fi(ze)});return Qe.observe(te),_e.current=(r?te.clientHeight:te.clientWidth)||null,ze(),()=>{Qe.disconnect(),Vc(ze)}},[ze,r]);const Je=!r&&V&&(ge||je!==null),st=K(te=>Je&&te.isSidebarOpen);c.useLayoutEffect(()=>{ze()},[ze,de,ge,V,Ne,st]),c.useEffect(()=>{if(!V||Ge.current){Ge.current=V;return}const te=window.requestAnimationFrame(()=>{qe.current?.focus({preventScroll:!0})});return Ge.current=!0,()=>window.cancelAnimationFrame(te)},[V]);const mt=c.useRef(null),Y=c.useRef(null),fe=c.useRef(null),Re=c.useRef(null),T=c.useRef(!1),ae=c.useRef(null),pe=c.useRef(!1),oe=c.useCallback(te=>{const Qe=Ae.current,gt=ae.current;if(!Qe||!gt)return;const wt=r?"height":"width";Qe.style[wt]=pe.current?`${te+yn}px`:`min(${te}px, 100%)`,gt.style[wt]=`calc(${te}px - ${e.gutterSize})`},[e.gutterSize,r]),be=c.useCallback(()=>{Y.current=null;const te=Fe.current;te!==null&&oe(te)},[oe]);c.useEffect(()=>()=>{Y.current!==null&&cancelAnimationFrame(Y.current),fe.current?.(),fe.current=null,Re.current?.remove(),Re.current=null},[]);const $e=c.useCallback(te=>{const Qe=mt.current,gt=q?ei(te):Se(te,Qe);return Qe===null?gt:Math.min(gt,Math.max(1,Qe))},[Se,q]),De=c.useCallback(te=>{if(!V||!f)return;Te.current=te.pointerId,G(!0),Ee.current=r?te.clientY:te.clientX,Pe.current=ve,Fe.current=ve;const Qe=r?Ae.current?.parentElement?.clientHeight:(Ae.current?.closest("[data-workspace-row]")?.clientWidth??0)-Ie.current-(ye?yn:0);mt.current=Qe&&Qe>0?Qe:null,Re.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),Re.current=gt,fe.current?.(),fe.current=Rc(r?"height":"width"),te.preventDefault()},[ye,f,V,r,ve]),ee=c.useCallback(()=>{const te=$e(Fe.current??ve),Qe=mt.current;Y.current!==null&&(cancelAnimationFrame(Y.current),Y.current=null);const gt=Ae.current,wt=ae.current;if(gt&&wt){const At=r?"height":"width";gt.style.setProperty(e.sizeVariable,`${te}px`),gt.style[At]=xt.current,wt.style[At]=_t.current}Fe.current=null,mt.current=null,T.current=!0,Re.current?.remove(),Re.current=null,q?L(te):ge?Qe!==null&&y(t,Qe-te):j(t,te),G(!1),Te.current=null,fe.current?.(),fe.current=null},[$e,e.sizeVariable,ge,q,r,L,y,j,ve,t]);c.useEffect(()=>{if(!Xe)return;const te=wt=>{if(Te.current!==wt.pointerId)return;const At=r?wt.clientY:wt.clientX,Vt=t==="left"?At-Ee.current:Ee.current-At,ys=!r&&a?-Vt:Vt,os=$e(Pe.current+ys);Fe.current!==os&&(Fe.current=os,Y.current===null&&(Y.current=requestAnimationFrame(be)))},Qe=wt=>{Te.current===wt.pointerId&&ee()},gt=()=>{ee()};return window.addEventListener("pointermove",te),window.addEventListener("pointerup",Qe),window.addEventListener("pointercancel",Qe),window.addEventListener("blur",gt),()=>{window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",Qe),window.removeEventListener("pointercancel",Qe),window.removeEventListener("blur",gt)}},[be,$e,ee,Xe,a,r,t]),c.useEffect(()=>{Xe||(Fe.current=null,Re.current?.remove(),Re.current=null)},[Xe]);const le=c.useCallback(()=>{f&&x(f,t)},[x,f,t]),et=c.useCallback(()=>{f&&b(f,t)},[f,b,t]),xe=J?.mode==="file"||J?.mode==="chat"||J?.mode==="browser"||J?.mode==="pr",bt=c.useMemo(()=>{if(!J)return[];const te=U.filter(Qe=>Qe.mode===J.mode);return J.mode==="pr"?[...te.filter(jr),...te.filter(Qe=>!jr(Qe))]:te},[J,U]),Tt=fo(J?.mode==="pr"&&f?f:null)?.current??null,vt=J?.id,Rt=c.useMemo(()=>{const te=Qh(bt.filter(Qe=>Qe.mode==="file").map(Qe=>ul(Qe.targetPath,d)));return bt.map(Qe=>{const gt=jr(Qe),wt=gt?Tt||o("contextPanel.tracker.branchTab"):Wv(Qe,He,l),At=Yv(wt,Lv),Vt=ul(Qe.targetPath,d);return{id:Qe.id,label:At,labelFolder:Qe.mode==="file"?te.get(Vt):void 0,icon:fl(Qe,$,Qe.id===vt,V),title:Vt?`${wt}: ${Vt}`:wt,closeLabel:o("contextPanel.tab.closeTabAria",{label:At}),closeShortcut:Qe.id===vt&&Ps()?ws("mod+w",""):void 0,closable:!gt,preview:Qe.preview}})},[bt,vt,d,$,V,He,o,l,Tt]),Ye=J?.mode==="context"?n.jsx(cn,{value:B,children:n.jsx(gv,{})}):J?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(cn,{value:B,children:n.jsx(Fv,{isActive:V})})}):J?.mode==="pr"?J.targetPath?n.jsx(Yw,{url:J.targetPath,directory:J.targetDirectory??d,panelDirectory:d,tabId:J.id,foreign:!!J.targetDirectory,visible:V},J.id):n.jsx(zw,{}):J?.mode==="notes"?n.jsx(cn,{value:B,children:n.jsx(tp,{visible:V})}):J?.mode==="workflows"?n.jsx(cn,{value:B,children:n.jsx(Vy,{directory:d||null})}):null,ft=J?.mode==="file",Nt=ft&&!!J?.targetPath&&re,ht=V&&J&&xe&&!Nt&&!jr(J)?J.id:null;c.useEffect(()=>{if(!(!f||!ht))return _i(()=>g(f,ht),Ae)},[g,f,ht]);const Ct=K(te=>te.closeContextPanelTabs),pt=c.useCallback(te=>{if(!f)return null;const{id:Qe,index:gt,allIds:wt,close:At}=te,Vt=()=>Ct(f,wt.filter(Ks=>Ks!==Qe)),ys=wt.slice(0,gt),os=wt.slice(gt+1),Cs=()=>Ct(f,a?os:ys),Ts=()=>Ct(f,a?ys:os),ds=()=>Ct(f,wt),ss=wt.length>1,ps=a?gt===wt.length-1:gt===0,Qs=a?gt===0:gt===wt.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(vs,{onClick:At,children:[n.jsx(ce,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(Cn,{}),n.jsxs(vs,{onClick:Vt,disabled:!ss,children:[n.jsx(ce,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs(vs,{onClick:Cs,disabled:ps,children:[n.jsx(ce,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(vs,{onClick:Ts,disabled:Qs,children:[n.jsx(ce,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(Cn,{}),n.jsxs(vs,{onClick:ds,disabled:!ss,children:[n.jsx(ce,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),J?n.jsxs(n.Fragment,{children:[n.jsx(Cn,{}),n.jsx(bc,{mode:J.mode})]}):null]})},[J,Ct,f,a,o]),It=c.useCallback((te,Qe)=>{const gt=U.find(At=>At.id===te);if(!gt)return null;const wt=ta({mode:gt.mode,label:Mr(gt.mode,l),from:t},Qe);return{finish:()=>wt.finish(f),cancel:wt.cancel}},[f,l,U,t]),[Ht,dt]=c.useState(null),ct=c.useCallback(te=>{if(!J||te.button!==0||te.pointerType==="touch"||te.target instanceof Element&&te.target.closest(Qv))return;const Qe=J.mode,gt=Mr(Qe,l),wt={x:te.clientX,y:te.clientY};let At=!1;const Vt=Ts=>{const ds={x:Ts.clientX,y:Ts.clientY};!At&&(Math.hypot(ds.x-wt.x,ds.y-wt.y)<Jv||(At=Fd({mode:Qe,label:gt,from:t}),!At))||Ld(ds)},ys=()=>{window.removeEventListener("pointermove",Vt),window.removeEventListener("pointerup",os),window.removeEventListener("pointercancel",Cs),window.removeEventListener("blur",Cs)},os=()=>{ys(),At&&Bd(f)},Cs=()=>{ys(),At&&gi()};window.addEventListener("pointermove",Vt),window.addEventListener("pointerup",os),window.addEventListener("pointercancel",Cs),window.addEventListener("blur",Cs)},[J,f,l,t]);c.useEffect(()=>{if(Ht)return Ht.addEventListener("pointerdown",ct),()=>Ht.removeEventListener("pointerdown",ct)},[ct,Ht]);const Mt=n.jsxs("header",{ref:dt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[xe?n.jsx(eg,{items:Rt,activeId:J?.id??null,onSelect:te=>{f&&E(f,te)},onClose:te=>{f&&g(f,te)},onReorder:(te,Qe)=>{f&&A(f,te,Qe)},onDoubleClickTab:te=>{f&&w(f,te)},layoutMode:"scrollable",variant:"default",tabContextMenu:pt,onTabDragOut:It}):n.jsxs(n.Fragment,{children:[n.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:[J?fl(J,$):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:J?Mr(J.mode,l):null})]}),n.jsx("div",{ref:W,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[J?.mode==="browser"?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&N(f)},className:"h-7 w-7 p-0","aria-label":o("contextPanel.browser.newTab"),children:n.jsx(ce,{name:"add",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.browser.newTab")})]}):null,ft?["left","right"].map(te=>{const Qe=te===k;if(!Qe&&!F)return null;const gt=o(Qe?"contextRail.editorTree.toggle":"contextRail.editor.toggle"),wt=Qe?R:re,At=o(Qe?wt?"contextTooltips.panel.hideFileTree":"contextTooltips.panel.showFileTree":wt?"contextTooltips.panel.hideFileEditor":"contextTooltips.panel.showFileEditor");return n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:Qe?v:S,className:"h-7 w-7 p-0","aria-label":gt,"aria-pressed":wt,children:n.jsx(ce,{name:te==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:At})]},te)}):null,q?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:et,className:"h-7 w-7 p-0","aria-label":o(ge?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:ge?n.jsx(ce,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(ce,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:n.jsx(Us,{label:o(ge?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:ws(Ws("toggle_context_panel_expanded",h),"")})})]}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:le,className:"h-7 w-7 p-0","aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(ce,{name:"close",className:"h-3.5 w-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.actions.closePanel")})]})]})]}),Wt=V?ye?`calc(var(${e.sizeVariable}) + ${yn}px)`:`min(var(${e.sizeVariable}), 100%)`:me?`${yn}px`:"0px",Zt=ye?`${yn}px`:"0px";pe.current=ye;const Kt=t==="bottom"&&Kn(m,p,"left"),ls=t==="bottom"&&(Q&&!O||Kn(m,p,"right")),Ut=`${V}|${ge}|${me}|${V&&ye}|${V?de:""}`,Qt=c.useRef(Ut),cs=c.useRef(O),js=cs.current!==O;c.useLayoutEffect(()=>{cs.current=O},[O]),c.useLayoutEffect(()=>{if(Qt.current===Ut)return;Qt.current=Ut;const te=T.current;!js&&!te&&Ic(s)},[Ut,js,s]),c.useLayoutEffect(()=>{T.current=!1});const Rs=!Ir(V,Xn(V),J?.mode),X={[e.sizeVariable]:`${ve}px`,...r?{height:Wt,maxHeight:"100%"}:{width:Wt,maxWidth:"100%"},transitionDuration:js||Xe?"0ms":`${s}ms`,transitionTimingFunction:In},ot=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,xt=c.useRef(Wt);xt.current=Wt;const _t=c.useRef(ot);return _t.current=ot,n.jsxs("aside",{ref:Ae,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":V?"true":"false",tabIndex:-1,className:Ze("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:X,children:[n.jsx("div",{ref:qe,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?n.jsx("div",{ref:tg,className:Ze("absolute inset-y-0 z-0 flex",ye?"inset-s-0":"inset-e-0",O&&"invisible")}):null,V&&n.jsx("div",{className:e.handle,style:{marginInlineStart:Zt},onPointerDown:De,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{ref:ae,"data-zone-card":"",className:Ze("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Kt?"ms-0":"ms-2"),t==="bottom"&&(ls?"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]",!V&&"opacity-0",Rs&&"pointer-events-none select-none"),style:{...r?{height:ot,width:`calc(100% - ${(Kt?0:.5)+(ls?0:.375)}rem)`}:{width:ot},...t==="right"?{marginInlineStart:`calc(0.5rem + ${Zt})`}:null,transitionDuration:Xe?"0ms":`${s}ms`,transitionTimingFunction:In},inert:Rs||void 0,children:n.jsxs(Hc.Provider,{value:!0,children:[Mt,n.jsx("div",{ref:H,className:"relative min-h-0 flex-1 overflow-hidden",children:J&&e0(J.mode)?Ye:null})]})})]})},n0=Js({port:xo().int().positive(),url:Ss().min(1),command:Ss(),directory:Ss().min(1).optional()}),r0=t=>{const e=Js({servers:yd(xx())}).safeParse(t);return e.success?e.data.servers.flatMap(s=>{const r=n0.safeParse(s);return r.success?[r.data]:[]}):null},o0=async(t,e)=>{try{const s=await zs("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=r0(await s.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},i0=async t=>{try{const e=await zs("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},a0=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},l0=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=a0(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.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):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},c0=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),ml=(t,e)=>{if(!e)return null;let s=null;for(const r of t)c0(r.path,e)&&(!s||r.path.length>s.path.length)&&(s=r);return s},d0=t=>t.slice(t.lastIndexOf("/")+1)||t,u0=({candidates:t,folders:e,directory:s})=>{const r=e.flatMap(u=>{const l=Jt(u.path),f=Jt(u.projectPath);return l&&f?[{path:l,projectPath:f}]:[]}),o=Jt(s),i=o?{path:o,projectPath:ml(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(u=>{const l=Jt(u.directory),f=ml(a,l),m=u.announced?0:f&&i&&f.path===i.path?1:f&&i&&f.projectPath===i.projectPath?2:3;return{server:{...u,folderName:f?d0(f.path):null,outsideWork:l!==null&&f===null&&!u.announced},rank:m}}).sort((u,l)=>u.rank-l.rank||u.server.port-l.server.port).map(u=>u.server)},f0=t=>({sessionId:t.sessionId,directory:t.directory?rs(t.directory):null}),p0=2e3,m0=Js({title:Ss(),settled:cr()}),h0=4e4,g0=50,Yn=400,is=new Map,Is=new Map;let bi=null,wi=null;const ur=new Map;let Ms=null,Xs=null,Jn=null;const Fs=async t=>{try{const e=await zs("/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}},x0=async(t,e)=>{try{const s=await zs("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},Ud=async(t,e=p0)=>{const s=Date.now()+e;for(;!is.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,g0));return is.get(t)??null},Zr=t=>is.has(t)||Is.has(t),An=t=>is.get(t)??Is.get(t)??null,yi=()=>[...is.values(),...[...Is.values()].filter(t=>!is.has(t.tabId))],ra=t=>{const e=wi?An(wi):null,s=e?.directory===bi?e:null;if(!t.sessionId){if(s)return s.tabId;const i=yi().filter(u=>u.directory===bi),a=i.filter(u=>is.has(u.tabId)),d=a.length>0?a:i;return d.length>0?d[d.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=ur.get(t.sessionId);if(r&&An(r)?.ownerSessionId===t.sessionId)return r;const o=yi().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},b0=t=>{const e=ra(t);return e&&An(e)?.ownerSessionId===t.sessionId?e:null},w0=(t,e)=>{t.sessionId&&An(e)?.ownerSessionId===t.sessionId&&ur.set(t.sessionId,e)},Vd=async t=>{const e=is.get(t);if(e)return e;const s=Is.get(t);return s?(s.wake(),Ud(t)):null},Hd=t=>{const e=ra(t);return yi().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},Kd=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,qd=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.`,y0=t=>{const e=Hd(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
|
`)}`:"")},v0=()=>"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.",S0=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.`,k0=()=>"This browser.close did not come from a session, so there is no tab it opened to close. Nothing was closed.",Yt=(t,e)=>x0(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:qc()})}:e),j0=async(t,e,s)=>{if(!e.sessionId){if(!await Fs(t.requestId))return;await Yt(t,{ok:!1,error:k0()});return}const r=s??b0(e);if(r===null){if(await new Promise(a=>setTimeout(a,Yn)),!await Fs(t.requestId))return;await Yt(t,{ok:!1,error:v0()});return}if(!Zr(r)){if(is.size===0&&Is.size===0&&!Xs)return;if(await new Promise(a=>setTimeout(a,Yn)),!Zr(r)){if(!await Fs(t.requestId))return;await Yt(t,{ok:!1,error:qd(r)});return}}const o=An(r);if(!o||o.ownerSessionId!==e.sessionId){if(!await Fs(t.requestId))return;await Yt(t,{ok:!1,error:S0(r)});return}if(!await Fs(t.requestId))return;if(!(Xs?Xs(o.directory,r):!1)){await Yt(t,{ok:!1,error:Xs?`The browser tab ${r} could not be closed.`:"There is no browser here to close a tab in."});return}e.sessionId&&ur.get(e.sessionId)===r&&ur.delete(e.sessionId),await Yt(t,{ok:!0,data:{closed:!0,tabId:r}})},C0=async t=>{const e=t.action==="browser.open",s=t.action==="browser.close",r=f0(t.context),{tabId:o,...i}=t.parameters,a=o===void 0?null:String(o);if(s){await j0(t,r,a);return}if(a!==null){if(!Zr(a)){if(is.size===0&&Is.size===0&&!Ms)return;if(await new Promise(l=>setTimeout(l,Yn)),Zr(a)){await hl(t,r,a,i);return}if(!await Fs(t.requestId))return;await Yt(t,{ok:!1,error:qd(a)});return}await hl(t,r,a,i);return}const d=ra(r);if(!d&&!(e&&Ms)){if(!r.sessionId||(await new Promise(l=>setTimeout(l,Yn)),!await Fs(t.requestId)))return;await Yt(t,{ok:!1,error:y0(r)});return}if(!(e&&Ms!==null)&&r.sessionId&&An(d)?.ownerSessionId!==r.sessionId&&await new Promise(l=>setTimeout(l,Yn)),!!await Fs(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await Yt(t,{ok:!1,error:"url is required"});return}const f=Date.now(),m=e&&Ms?Ms(l,t.context):null;if(e&&!m&&!d){await Yt(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(m){r.sessionId&&ur.set(r.sessionId,m);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"",x=!!h&&h!=="fill",g=qc();if(!x&&!g){await Yt(t,{ok:!0,data:{url:l,opened:!0,tabId:m}});return}const w=await Ud(m);if(!w&&!x){await Yt(t,{ok:!0,data:{url:l,opened:!0,tabId:m,settled:!1}});return}if(!w){await Yt(t,{ok:!0,data:{url:l,opened:!0,tabId:m,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 b=x?await w.run("browser.resize",{viewport:h}):null,j=b&&typeof b=="object"?b.viewport??null:null,y=g?m0.safeParse(await w.run("browser.settle",{budgetMs:Math.max(0,h0-(Date.now()-f))}).catch(()=>null)):null;await Yt(t,{ok:!0,data:Object.assign({url:l,opened:!0,tabId:m},x?{viewportApplied:!0,viewport:j}:{},y?y.success?y.data:{settled:!1}:{})});return}const p=await Vd(d);await Yt(t,p?await Gd(p,r,t.action,i):{ok:!1,error:Kd(d)})}catch(l){await Yt(t,{ok:!1,error:l instanceof Error?l.message:String(l)})}},hl=async(t,e,s,r)=>{if(!await Fs(t.requestId))return;w0(e,s);const o=await Vd(s);await Yt(t,o?await Gd(o,e,t.action,r):{ok:!1,error:Kd(s)})},Gd=async(t,e,s,r)=>{try{const o=await t.run(s,r);return s==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:Hd(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},yo=()=>{Jn||(Jn=_n(t=>{t.type==="browser-control-request"&&C0({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},vo=()=>{is.size>0||Is.size>0||Ms||Xs||!Jn||(Jn(),Jn=null)},T0=t=>(is.set(t.tabId,t),yo(),()=>{is.get(t.tabId)===t&&is.delete(t.tabId),vo()}),N0=t=>(Is.set(t.tabId,t),yo(),()=>{Is.get(t.tabId)===t&&Is.delete(t.tabId),vo()}),E0=(t,e)=>{bi=t,e&&(wi=e)},P0=t=>(Ms=t,yo(),()=>{Ms===t&&(Ms=null),vo()}),I0=t=>(Xs=t,yo(),()=>{Xs===t&&(Xs=null),vo()}),R0=50,D0=6,_0=2048,A0=200,Zd=t=>{const e=jn(String(t??"").trim());if(!e||e.length>_0)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},O0=(t,e)=>{const s=Zd(e.url);if(!s)return t;const r=t.find(a=>a.url===s),o=String(e.title??"").trim().slice(0,A0)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(a=>a.url!==s)].slice(0,R0)},M0=(t,e)=>{const s=Zd(e);return t.filter(r=>r.url!==s)},F0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Xd=(t,e,s=D0)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((a,d)=>d.lastVisitedAt-a.lastVisitedAt);if(!r)return o.slice(0,s);const i=r.replace(/^https?:\/\//,"");return o.filter(a=>{const d=F0(a);return a.url===r||d===i?!1:d.includes(i)}).slice(0,s)},gl=20,Fr=t=>{const e=Jt((t||"").trim());return e?JSON.stringify([qt(),e]):""},L0=t=>{const e=Object.keys(t);if(e.length<=gl)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,gl);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},Tn=go()(gx(t=>({byProject:{},recordVisit:(e,s)=>{const r=Fr(e);r&&t(o=>{const i=o.byProject[r]??[],a=O0(i,{...s,at:Date.now()});return a===i?o:{byProject:L0({...o.byProject,[r]:a})}})},forget:(e,s)=>{const r=Fr(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:M0(i,s)}}:o})},clear:e=>{const s=Fr(e);s&&t(r=>{if(!(s in r.byProject))return r;const o={...r.byProject};return delete o[s],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Uu(),partialize:t=>({byProject:t.byProject})})),B0=[],Yd=t=>e=>{const s=Fr(t);return(s?e.byProject[s]:void 0)??B0},oa=t=>{const e=Ue.c(10),{t:s}=lt();let r;e[0]!==t?(r=bs(t),e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=l=>o?l.journey?.get(o):void 0,e[2]=o,e[3]=i):i=e[3];const a=dn(i);if(o===null)return null;if(!a){let l;return e[4]!==s?(l=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=l):l=e[5],l}let d;e[6]!==a.machine||e[7]!==a.placeId||e[8]!==s?(d=a.machine??(a.placeId==="docker"?s("spaces.create.place.localDocker"):a.placeId),e[6]=a.machine,e[7]=a.placeId,e[8]=s,e[9]=d):d=e[9];const u=d;return`${a.name} · ${u}`},xl=6e3,$0=120,z0=80,W0=32,U0=100,V0=`
|
|
8
8
|
var MAX_ELEMENTS = ${$0};
|
|
@@ -495,4 +495,4 @@ ${t}
|
|
|
495
495
|
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
496
496
|
styles: styles
|
|
497
497
|
};
|
|
498
|
-
`),Q0=t=>{const e=Ue.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:d}=lt();if(s.length===0)return null;let u;e[0]!==d?(u=d("contextPanel.browser.history.label"),e[0]=d,e[1]=u):u=e[1];let l;if(e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==d){let m;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==d?(m=(p,h)=>n.jsxs("div",{role:"option","aria-selected":h===r,className:Ze("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(p.url)},onPointerEnter:()=>a(h),children:[n.jsx(ce,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||ro(p.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:Ze("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":d("contextPanel.browser.history.forget"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),i(p.url)},children:n.jsx(ce,{name:"close",className:"size-3","aria-hidden":"true"})})}),n.jsx(jt,{sideOffset:6,children:d("contextPanel.browser.history.forget")})]})]},p.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=d,e[14]=m):m=e[14],l=s.map(m),e[2]=r,e[3]=s,e[4]=i,e[5]=a,e[6]=o,e[7]=d,e[8]=l}else l=e[8];let f;return e[15]!==u||e[16]!==l?(f=n.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":u,children:l}),e[15]=u,e[16]=l,e[17]=f):f=e[17],f},gs=t=>{const e=Ue.c(17),{icon:s,label:r,onClick:o,disabled:i,pressed:a}=t,d=a?"secondary":"ghost",u=a&&"text-foreground";let l;e[0]!==u?(l=Ze("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=l):l=e[1];let f;e[2]!==s?(f=n.jsx(ce,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let m;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==d||e[9]!==l||e[10]!==f?(m=n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex shrink-0",children:n.jsx(ut,{type:"button",variant:d,size:"xs",className:l,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]=d,e[9]=l,e[10]=f,e[11]=m):m=e[11];let p;e[12]!==r?(p=n.jsx(jt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let h;return e[14]!==m||e[15]!==p?(h=n.jsxs(kt,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=h):h=e[16],h},Jd=t=>{const e=Ue.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:d,onBack:u,onForward:l,onReload:f,onOpenExternal:m,canOpenExternal:p,canGoBack:h,canGoForward:x,isLoading:g,onAnnotate:w,onOpenDevTools:b,isAnnotating:j,onHardReload:y,onZoomIn:E,onZoomOut:A,onZoomReset:R,zoomPercent:_,onClearCookies:L,onClearCache:v,onToggleDeviceBar:C,isDeviceBarOpen:S}=t;let k;e[0]!==o?(k=o===void 0?[]:o,e[0]=o,e[1]=k):k=e[1];const N=k,$=p===void 0?!0:p,B=_===void 0?100:_,{t:D}=lt(),[W,H]=c.useState(!1),[U,se]=c.useState(-1);let z;e[2]!==W||e[3]!==N?(z=W?N:[],e[2]=W,e[3]=N,e[4]=z):z=e[4];const Q=z;let ie;e[5]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>{se(-1)},e[5]=ie):ie=e[5];let O;e[6]!==s||e[7]!==W?(O=[s,W],e[6]=s,e[7]=W,e[8]=O):O=e[8],c.useEffect(ie,O);let ne;e[9]!==d?(ne=Te=>{H(!1),se(-1),d(Te)},e[9]=d,e[10]=ne):ne=e[10];const V=ne;let J;e[11]!==U||e[12]!==V||e[13]!==Q?(J=Te=>{if(Q.length!==0){if(Te.key==="ArrowDown"||Te.key==="ArrowUp"){Te.preventDefault();const Ae=Te.key==="ArrowDown"?1:-1,qe=Q.length;se(Ge=>{const Je=Ge+Ae;return Je<-1?qe-1:Je>=qe?-1:Je});return}if(Te.key==="Escape"&&U>=0){Te.preventDefault(),se(-1);return}if(Te.key==="Enter"&&U>=0){Te.preventDefault();const Ae=Q[U];Ae&&V(Ae.url)}}},e[11]=U,e[12]=V,e[13]=Q,e[14]=J):J=e[14];const F=J;let re;e[15]!==D?(re=D("contextPanel.browser.back"),e[15]=D,e[16]=re):re=e[16];const q=!h;let ge;e[17]!==u||e[18]!==re||e[19]!==q?(ge=n.jsx(gs,{icon:"arrow-left",label:re,onClick:u,disabled:q}),e[17]=u,e[18]=re,e[19]=q,e[20]=ge):ge=e[20];let Z;e[21]!==D?(Z=D("contextPanel.browser.forward"),e[21]=D,e[22]=Z):Z=e[22];const de=!x;let Se;e[23]!==l||e[24]!==Z||e[25]!==de?(Se=n.jsx(gs,{icon:"arrow-right",label:Z,onClick:l,disabled:de}),e[23]=l,e[24]=Z,e[25]=de,e[26]=Se):Se=e[26];let ue;e[27]!==g||e[28]!==D?(ue=D(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=D,e[29]=ue):ue=e[29];let ke;e[30]!==f||e[31]!==ue?(ke=n.jsx(gs,{icon:"refresh",label:ue,onClick:f}),e[30]=f,e[31]=ue,e[32]=ke):ke=e[32];let Me;e[33]!==y||e[34]!==D?(Me=y?n.jsx(gs,{icon:"restart",label:D("contextPanel.browser.hardReload"),onClick:y}):null,e[33]=y,e[34]=D,e[35]=Me):Me=e[35];let We;e[36]!==s||e[37]!==V?(We=Te=>{Te.preventDefault(),V(s)},e[36]=s,e[37]=V,e[38]=We):We=e[38];let Le;e[39]!==r?(Le=r?n.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:n.jsx(ce,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=Le):Le=e[40];let Ve;e[41]!==a?(Ve=Te=>a(Te.target.value),e[41]=a,e[42]=Ve):Ve=e[42];let Ne,me;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>H(!0),me=()=>H(!1),e[43]=Ne,e[44]=me):(Ne=e[43],me=e[44]);const ye=Q.length>0,je=r&&"ps-8";let Be;e[45]!==je?(Be=Ze("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",je,"typography-micro text-foreground outline-none"),e[45]=je,e[46]=Be):Be=e[46];let _e;e[47]!==D?(_e=D("contextPanel.browser.addressAria"),e[47]=D,e[48]=_e):_e=e[48];let Ie;e[49]!==s||e[50]!==F||e[51]!==Ve||e[52]!==ye||e[53]!==Be||e[54]!==_e?(Ie=n.jsx("input",{value:s,onChange:Ve,onFocus:Ne,onBlur:me,onKeyDown:F,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":ye,"aria-controls":"openchamber-browser-address-suggestions",className:Be,"aria-label":_e}),e[49]=s,e[50]=F,e[51]=Ve,e[52]=ye,e[53]=Be,e[54]=_e,e[55]=Ie):Ie=e[55];let tt;e[56]!==i?(tt=Te=>i?.(Te),e[56]=i,e[57]=tt):tt=e[57];let Ke;e[58]!==U||e[59]!==V||e[60]!==tt||e[61]!==Q?(Ke=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(Q0,{entries:Q,activeIndex:U,onSelect:V,onForget:tt,onHighlight:se})}),e[58]=U,e[59]=V,e[60]=tt,e[61]=Q,e[62]=Ke):Ke=e[62];let ze;e[63]!==We||e[64]!==Le||e[65]!==Ie||e[66]!==Ke?(ze=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:We,children:[Le,Ie,Ke]}),e[63]=We,e[64]=Le,e[65]=Ie,e[66]=Ke,e[67]=ze):ze=e[67];let rt;e[68]!==E||e[69]!==A||e[70]!==R||e[71]!==D||e[72]!==B?(rt=A&&E?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(gs,{icon:"subtract",label:D("contextPanel.browser.zoomOut"),onClick:A}),B!==100&&R?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{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":D("contextPanel.browser.zoomReset"),children:[B,"%"]})}),n.jsx(jt,{sideOffset:6,children:D("contextPanel.browser.zoomReset")})]}):null,n.jsx(gs,{icon:"add",label:D("contextPanel.browser.zoomIn"),onClick:E})]}):null,e[68]=E,e[69]=A,e[70]=R,e[71]=D,e[72]=B,e[73]=rt):rt=e[73];let ve;e[74]!==L||e[75]!==D?(ve=L?n.jsx(gs,{icon:"delete-bin",label:D("contextPanel.browser.clearCookies"),onClick:L}):null,e[74]=L,e[75]=D,e[76]=ve):ve=e[76];let M;e[77]!==v||e[78]!==D?(M=v?n.jsx(gs,{icon:"database-2",label:D("contextPanel.browser.clearCache"),onClick:v}):null,e[77]=v,e[78]=D,e[79]=M):M=e[79];let Ce;e[80]!==S||e[81]!==C||e[82]!==D?(Ce=C?n.jsx(gs,{icon:"smartphone",label:D("contextPanel.browser.deviceToolbar"),onClick:C,pressed:S}):null,e[80]=S,e[81]=C,e[82]=D,e[83]=Ce):Ce=e[83];let He;e[84]!==j||e[85]!==w||e[86]!==D?(He=w?n.jsx(gs,{icon:"markup",label:D("contextPanel.browser.annotate.toggle"),onClick:w,pressed:j}):null,e[84]=j,e[85]=w,e[86]=D,e[87]=He):He=e[87];let Xe;e[88]!==b||e[89]!==D?(Xe=b?n.jsx(gs,{icon:"terminal-box",label:D("contextPanel.browser.devTools"),onClick:b}):null,e[88]=b,e[89]=D,e[90]=Xe):Xe=e[90];let G;e[91]!==D?(G=D("contextPanel.browser.openExternal"),e[91]=D,e[92]=G):G=e[92];const Ee=!$;let Pe;e[93]!==m||e[94]!==G||e[95]!==Ee?(Pe=n.jsx(gs,{icon:"external-link",label:G,onClick:m,disabled:Ee}),e[93]=m,e[94]=G,e[95]=Ee,e[96]=Pe):Pe=e[96];let Fe;return e[97]!==ge||e[98]!==Se||e[99]!==ke||e[100]!==Me||e[101]!==ze||e[102]!==rt||e[103]!==ve||e[104]!==M||e[105]!==Ce||e[106]!==He||e[107]!==Xe||e[108]!==Pe?(Fe=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ge,Se,ke,Me,ze,rt,ve,M,Ce,He,Xe,Pe]}),e[97]=ge,e[98]=Se,e[99]=ke,e[100]=Me,e[101]=ze,e[102]=rt,e[103]=ve,e[104]=M,e[105]=Ce,e[106]=He,e[107]=Xe,e[108]=Pe,e[109]=Fe):Fe=e[109],Fe},Xr={kind:"fill"},bl=240,eS=3840,Qd=[{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}],wl=t=>Number.isFinite(t)?Math.round(Math.min(eS,Math.max(bl,t))):bl,Yr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},eu=t=>{const e=Qd.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},tS=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},sS=(t,e)=>{const s=Yr(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:i}},nS=["mobile","tablet","desktop","fill"],rS={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},yl=t=>typeof t=="string"&&nS.includes(t),vi=t=>t==="fill"?Xr:eu(rS[t])??Xr,Cr=t=>{const e=Yr(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=vi(s),o=Yr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},oS=t=>{const e=Ue.c(77),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:d}=lt();let u;e[0]!==s?(u=Yr(s),e[0]=s,e[1]=u):u=e[1];const l=u,f=s.kind==="preset"?s.id:"";let m;e[2]!==r||e[3]!==l?(m=(q,ge)=>{const Z=Number.parseInt(ge,10);if(!Number.isFinite(Z))return;const de=l??{width:1280,height:800};r({kind:"custom",width:wl(q==="width"?Z:de.width),height:wl(q==="height"?Z:de.height)})},e[2]=r,e[3]=l,e[4]=m):m=e[4];const p=m;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Ze("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=q=>{const ge=eu(q.target.value);r(ge??Xr)},e[6]=r,e[7]=g):g=e[7];let w;e[8]!==d?(w=d("contextPanel.browser.device.preset"),e[8]=d,e[9]=w):w=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=Ze("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=b):b=e[10];let j;e[11]!==d?(j=d("contextPanel.browser.device.responsive"),e[11]=d,e[12]=j):j=e[12];let y;e[13]!==j?(y=n.jsx("option",{value:"",children:j}),e[13]=j,e[14]=y):y=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=Qd.map(iS),e[15]=E):E=e[15];let A;e[16]!==f||e[17]!==g||e[18]!==w||e[19]!==y?(A=n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex shrink-0",children:n.jsxs("select",{value:f,onChange:g,"aria-label":w,className:b,children:[y,E]})})}),e[16]=f,e[17]=g,e[18]=w,e[19]=y,e[20]=A):A=e[20];let R;e[21]!==d?(R=d("contextPanel.browser.device.preset"),e[21]=d,e[22]=R):R=e[22];let _;e[23]!==R?(_=n.jsx(jt,{sideOffset:6,children:R}),e[23]=R,e[24]=_):_=e[24];let L;e[25]!==A||e[26]!==_?(L=n.jsxs(kt,{children:[A,_]}),e[25]=A,e[26]=_,e[27]=L):L=e[27];const v=l?String(l.width):"";let C;e[28]!==p?(C=q=>p("width",q.target.value),e[28]=p,e[29]=C):C=e[29];let S;e[30]!==d?(S=d("contextPanel.browser.device.width"),e[30]=d,e[31]=S):S=e[31];let k;e[32]!==v||e[33]!==C||e[34]!==S?(k=n.jsx("input",{value:v,onChange:C,placeholder:"—",inputMode:"numeric","aria-label":S,className:x}),e[32]=v,e[33]=C,e[34]=S,e[35]=k):k=e[35];let N;e[36]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[36]=N):N=e[36];const $=l?String(l.height):"";let B;e[37]!==p?(B=q=>p("height",q.target.value),e[37]=p,e[38]=B):B=e[38];let D;e[39]!==d?(D=d("contextPanel.browser.device.height"),e[39]=d,e[40]=D):D=e[40];let W;e[41]!==$||e[42]!==B||e[43]!==D?(W=n.jsx("input",{value:$,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":D,className:x}),e[41]=$,e[42]=B,e[43]=D,e[44]=W):W=e[44];let H;e[45]!==r||e[46]!==s?(H=()=>r(tS(s)),e[45]=r,e[46]=s,e[47]=H):H=e[47];const U=!l;let se;e[48]!==d?(se=d("contextPanel.browser.device.rotate"),e[48]=d,e[49]=se):se=e[49];let z;e[50]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(ce,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[50]=z):z=e[50];let Q;e[51]!==H||e[52]!==U||e[53]!==se?(Q=n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex shrink-0",children:n.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:H,disabled:U,"aria-label":se,children:z})})}),e[51]=H,e[52]=U,e[53]=se,e[54]=Q):Q=e[54];let ie;e[55]!==d?(ie=d("contextPanel.browser.device.rotate"),e[55]=d,e[56]=ie):ie=e[56];let O;e[57]!==ie?(O=n.jsx(jt,{sideOffset:6,children:ie}),e[57]=ie,e[58]=O):O=e[58];let ne;e[59]!==Q||e[60]!==O?(ne=n.jsxs(kt,{children:[Q,O]}),e[59]=Q,e[60]=O,e[61]=ne):ne=e[61];let V;e[62]!==a||e[63]!==l?(V=l&&a<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[62]=a,e[63]=l,e[64]=V):V=e[64];let J;e[65]===Symbol.for("react.memo_cache_sentinel")?(J=["system","light","dark"],e[65]=J):J=e[65];let F;e[66]!==o||e[67]!==i||e[68]!==d?(F=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:J.map(q=>n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:o===q?"secondary":"ghost",size:"xs",className:Ze("shrink-0 rounded-full px-2.5 typography-micro",o===q?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(q),"aria-pressed":o===q,children:d(q==="system"?"contextPanel.browser.device.schemeSystem":q==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")})}),n.jsx(jt,{sideOffset:6,children:d(q==="system"?"contextTooltips.terminalBrowser.device.schemeSystem":q==="light"?"contextTooltips.terminalBrowser.device.schemeLight":"contextTooltips.terminalBrowser.device.schemeDark")})]},q))}),e[66]=o,e[67]=i,e[68]=d,e[69]=F):F=e[69];let re;return e[70]!==L||e[71]!==k||e[72]!==W||e[73]!==ne||e[74]!==V||e[75]!==F?(re=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[L,k,N,W,ne,V,F]}),e[70]=L,e[71]=k,e[72]=W,e[73]=ne,e[74]=V,e[75]=F,e[76]=re):re=e[76],re};function iS(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const Jr=new Map,Si=new Set,tu=()=>{for(const t of Si)t()},Zo=(t,e)=>{const s=t.trim();s&&(e.length===0?Jr.delete(s):Jr.set(s,[...e]),tu())},aS=t=>{Jr.delete(t.trim())&&tu()},su=[],lS=t=>Jr.get(t.trim())??su,cS=t=>(Si.add(t),()=>{Si.delete(t)}),dS=t=>{const e=Ue.c(2);let s;return e[0]!==t?(s=()=>lS(t),e[0]=t,e[1]=s):s=e[1],c.useSyncExternalStore(cS,s,uS)};function uS(){return su}const nu="oc.browser.hiddenDevServerPorts.v1",fS=di(Ss(),yd(xo().int().positive())),ki=new Set,ru=[];let Tr=null;const ia=()=>{const t=hr().getItem(nu);if(Tr&&Tr.raw===t)return Tr.value;let e={};if(t!==null)try{const s=fS.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return Tr={raw:t,value:e},e},ou=t=>{hr().setItem(nu,JSON.stringify(t));for(const e of ki)e()},pS=(t=qt())=>ia()[t]??ru,mS=t=>{const e=qt(),s=ia(),r=s[e]??[];r.includes(t)||ou({...s,[e]:[...r,t].sort((o,i)=>o-i)})},hS=()=>{const t=qt(),e=ia();if(!e[t])return;const s={...e};delete s[t],ou(s)},gS=t=>(ki.add(t),()=>{ki.delete(t)}),xS=()=>c.useSyncExternalStore(gS,bS,wS);function bS(){return pS()}function wS(){return ru}const yS=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},vS=2e3,SS=t=>wc("http://localhost",t),iu=t=>{const e=Ue.c(62),{onOpen:s,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=lt();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={kind:"loading"},e[0]=d):d=e[0];const[u,l]=c.useState(d),f=dS(i);let m;e[1]!==i?(m=()=>SS(i),e[1]=i,e[2]=m):m=e[2];const[p]=c.useState(m);let h;e[3]!==i?(h=()=>np(i),e[3]=i,e[4]=h):h=e[4];const[x]=c.useState(h);let g;e[5]!==i?(g=ec(i),e[5]=i,e[6]=g):g=e[6];const w=g,b=oa(i),j=Vu(i);let y,E;e[7]!==i||e[8]!==j||e[9]!==o?(y=()=>{if(j){l({kind:"ready",servers:[]});return}if(!o)return;let V=!0,J=null;const F=new AbortController,re=()=>{o0(F.signal,i).then(q=>{V&&(l(q),J=setTimeout(re,vS))})};return re(),()=>{V=!1,J&&clearTimeout(J),F.abort()}},E=[i,j,o],e[7]=i,e[8]=j,e[9]=o,e[10]=y,e[11]=E):(y=e[10],E=e[11]),c.useEffect(y,E);const A=Gt(kS),R=nt(jS);let _;if(e[12]!==A||e[13]!==R){const V=A.map(CS);let J;e[15]!==R?(J=[...R].flatMap(TS),e[15]=R,e[16]=J):J=e[16],_=[...V,...J],e[12]=A,e[13]=R,e[14]=_}else _=e[14];const L=_;let v;e[17]!==f||e[18]!==i||e[19]!==u.kind||e[20]!==u.servers||e[21]!==L?(v=u0({candidates:l0({announced:f,discovered:u.kind==="ready"?u.servers:null}),folders:L,directory:i}),e[17]=f,e[18]=i,e[19]=u.kind,e[20]=u.servers,e[21]=L,e[22]=v):v=e[22];const C=v,S=xS(),[k,N]=c.useState(!1);let $;if(e[23]!==C||e[24]!==S||e[25]!==k){let V;e[27]!==S||e[28]!==k?(V=J=>J.announced||!S.includes(J.port)&&(k||!J.outsideWork),e[27]=S,e[28]=k,e[29]=V):V=e[29],$=C.filter(V),e[23]=C,e[24]=S,e[25]=k,e[26]=$}else $=e[26];const B=$,D=C.length-B.length;let W;e[30]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(cg,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=W):W=e[30];let H;e[31]!==a?(H=a("contextPanel.browser.empty"),e[31]=a,e[32]=H):H=e[32];let U;e[33]!==H?(U=n.jsx("span",{className:"typography-ui-header text-foreground",children:H}),e[33]=H,e[34]=U):U=e[34];let se;e[35]!==a?(se=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=se):se=e[36];let z;e[37]!==se?(z=n.jsx("span",{className:"typography-micro text-muted-foreground",children:se}),e[37]=se,e[38]=z):z=e[38];let Q;e[39]!==U||e[40]!==z?(Q=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[U,z]}),e[39]=U,e[40]=z,e[41]=Q):Q=e[41];let ie;e[42]!==f||e[43]!==C.length||e[44]!==i||e[45]!==D||e[46]!==w||e[47]!==s||e[48]!==p||e[49]!==b||e[50]!==x||e[51]!==a||e[52]!==B?(ie=C.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.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")}),p&&!x?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx(as,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:B.map(V=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(ut,{type:"button",variant:"outline",size:"sm",className:Ze("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(aS(i),s(V.url))},children:[w?n.jsx("span",{className:"shrink-0",role:"img","aria-label":b??a("contextPanel.browser.spaceAddress"),title:b??a("contextPanel.browser.spaceAddress"),children:n.jsx(ce,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):n.jsx(ce,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsxs("span",{className:"truncate",children:[ro(V.url)||V.url,n.jsx("span",{className:"typography-micro text-muted-foreground",children:yS(V.url)})]}),x?n.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:n.jsx(ce,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):V.folderName?n.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:V.directory,children:[n.jsx(ce,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",dir:"auto",children:V.folderName})]}):null]}),V.announced?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{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:()=>mS(V.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:V.port}),children:n.jsx(ce,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})}),n.jsx(jt,{sideOffset:6,children:a("contextPanel.browser.devServers.hide",{port:V.port})})]})]},V.port))}),D>0?n.jsx(ut,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{hS(),N(!0)},children:D===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:D}):a("contextPanel.browser.devServers.showHiddenPlural",{count:D})}):null]}):null,e[42]=f,e[43]=C.length,e[44]=i,e[45]=D,e[46]=w,e[47]=s,e[48]=p,e[49]=b,e[50]=x,e[51]=a,e[52]=B,e[53]=ie):ie=e[53];let O;e[54]!==C.length||e[55]!==u.kind||e[56]!==a?(O=C.length===0&&u.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=C.length,e[55]=u.kind,e[56]=a,e[57]=O):O=e[57];let ne;return e[58]!==Q||e[59]!==ie||e[60]!==O?(ne=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[W,Q,ie,O]}),e[58]=Q,e[59]=ie,e[60]=O,e[61]=ne):ne=e[61],ne};function kS(t){return t.projects}function jS(t){return t.availableWorktreesByProject}function CS(t){return{path:t.path,projectPath:t.path}}function TS(t){const[e,s]=t;return s.map(r=>({path:r.path,projectPath:e}))}const NS=3e4,ES=3,PS=250,IS={attempts:0,windowStartedAt:null},RS=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=NS,r=s?0:t.attempts;return r>=ES?null:{delayMs:PS*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},DS=-3,Nr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",kn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},_S=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:dg),[i,a]=c.useState(e),[d,u]=c.useState(""),[l,f]=c.useState(!1),[m,p]=c.useState(!1),h=c.useRef(s);h.current=s;const x=c.useRef(IS);return c.useEffect(()=>{if(!t)return;const g=()=>{try{const C=t.getURL();return Nr(C)?C:""}catch{return""}},w=()=>{try{f(t.canGoBack()),p(t.canGoForward())}catch{}},b=C=>{Nr(C)&&(a(C),h.current(C))},j=()=>{const C=g();o({kind:"loading",url:C})},y=()=>{const C=g();let S="";try{S=t.getTitle()||""}catch{S=""}u(S),b(C),w(),o(k=>k.kind==="failed"?k:{kind:"ready",url:C,title:S})},E=C=>{const S=kn(C);Nr(S.url)&&(b(S.url),w())},A=C=>{const S=kn(C),k=Array.isArray(S.favicons)?S.favicons.find(Boolean):"",N=g();if(!k||!N)return;let $=-1;try{$=t.getWebContentsId()}catch{return}!Number.isFinite($)||$<0||Ad.getState().resolve(N,k,$)},R=C=>{const S=kn(C);typeof S.title=="string"&&u(S.title)},_=C=>{const S=kn(C);if(S.isMainFrame===!1)return;const k=typeof S.errorCode=="number"?S.errorCode:0;k!==DS&&o({kind:"failed",url:Nr(S.validatedURL)?S.validatedURL:g(),code:k,description:typeof S.errorDescription=="string"?S.errorDescription:""})};let L=null;const v=()=>{const C=g(),S=RS(x.current,Date.now());if(!S){o({kind:"failed",url:C,code:0,description:"",crashed:!0});return}x.current=S.state,o({kind:"loading",url:C}),L=setTimeout(()=>{L=null;try{t.reload()}catch{o({kind:"failed",url:C,code:0,description:"",crashed:!0})}},S.delayMs)};t.addEventListener("did-start-loading",j),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",E),t.addEventListener("did-navigate-in-page",E),t.addEventListener("page-title-updated",R),t.addEventListener("page-favicon-updated",A),t.addEventListener("did-fail-load",_),t.addEventListener("render-process-gone",v),t.addEventListener("crashed",v);try{!t.isLoading()&&g()&&y()}catch{}return()=>{L!==null&&clearTimeout(L),t.removeEventListener("render-process-gone",v),t.removeEventListener("crashed",v),t.removeEventListener("did-start-loading",j),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",E),t.removeEventListener("did-navigate-in-page",E),t.removeEventListener("page-title-updated",R),t.removeEventListener("page-favicon-updated",A),t.removeEventListener("did-fail-load",_)}},[t]),{status:r,url:i,title:d,canGoBack:l,canGoForward:m}},vl=1e3,au=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},AS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},OS=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},MS=(t,e)=>{const s=c.useRef(0),r=c.useRef(0),o=c.useRef(0),i=c.useRef(null),a=c.useCallback(()=>{if(!t||document.activeElement!==t)return;const d=i.current;d&&d.isConnected&&d!==document.body?d.focus({preventScroll:!0}):t.blur()},[t]);return c.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=OS());const d=u=>{if(document.activeElement!==t){i.current=AS(u);return}const l=e.current,f=s.current>r.current||Date.now()<o.current;l&&au(l)&&!f||r.current>0||a()};return document.addEventListener("focusin",d,!0),()=>document.removeEventListener("focusin",d,!0)},[a,e,t]),c.useCallback(async d=>{const u=t!==null&&document.activeElement===t;let l=!1;const f=()=>{l&&(l=!1,r.current-=1,o.current=Date.now()+vl,!u&&r.current===0&&a())},m=()=>(l||(l=!0,r.current+=1),f);s.current+=1;try{return await d(m)}finally{s.current-=1,o.current=Date.now()+vl,f()}},[a,t])},FS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),LS=()=>document.visibilityState==="visible",BS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Er=.5,$S=-3,zS=4,WS="persist:openchamber-browser",lu=(t,e,s)=>bs(t)!==null&&sc(e)?{icon:"instance",label:s}:void 0,Sl=t=>{const e=bs(t);return e?`openchamber-space-preview:${e}`:WS},kl="openchamber:browser-panel-open-tab",US=Js({webContentsId:xo(),url:Ss().min(1),background:cr()}),jl=20,VS=600,HS=2e4,KS=15e3,Cl=500,Tl=5e3,qS=3e4,GS=3e3,Nl=1e3,ZS=250,XS=Js({quiet:cr()}),YS=()=>new Promise(t=>{let e=0,s=0,r=0,o;const i=l=>{clearTimeout(o),t(l)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},d=()=>{s=e,r=performance.now()+Nl,o=setTimeout(u,Nl)},u=()=>{e>s||performance.now()-r>ZS?d():i(!1)};requestAnimationFrame(a),d()}),JS=t=>{if(!t||au(t))return()=>{};const e=t.getBoundingClientRect(),s=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=s}},QS=({initialUrl:t,directory:e,siteDirectory:s,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=lt(),{currentTheme:d}=oo(),u=c.useRef(null),[l,f]=c.useState(null),m=c.useCallback(Y=>{u.current=Y,f(Y)},[]),p=K(Y=>Y.setContextPanelTabTargetPath),h=c.useRef(jn(t)),x=h.current!==Zs?h.current:"",[g,w]=c.useState(x?null:Zs),b=oa(s),[j,y]=c.useState(x),[E,A]=c.useState(!1),[R,_]=c.useState(!1),[L,v]=c.useState(0),C=c.useRef(0),[S,k]=c.useState(!1),[N,$]=c.useState(Xr),B=c.useRef(N);B.current=N;const D=c.useRef([]),[W,H]=c.useState("system"),[U,se]=c.useState({width:0,height:0}),z=c.useRef(null),Q=c.useRef(null),ie=rs(e),O=c.useRef(!!x&&!Hu(ie,r)),ne=c.useRef(null);c.useEffect(()=>{tc(ie,r)},[ie,r]);const V=c.useRef(!1),J=c.useRef(Date.now()),F=c.useCallback(Y=>{!Y||Y===Zs||!e||!r||p(e,r,Y)},[e,r,p]),re=_S(l,{initialUrl:x,onUrlChange:c.useCallback(Y=>{const fe=bn(Y);y(fe),F(fe)},[F])}),[q,ge]=c.useState(null),[Z,de]=c.useState(bs(s)===null);c.useEffect(()=>{const Y=bs(s);if(Y===null){de(!0);return}let fe=!0;return de(!1),Sn("desktop_space_preview_prepare",{spaceId:Y}).then(()=>{fe&&de(!0)}).catch(()=>{fe&&ge(x||"http://localhost/")}),()=>{fe=!1}},[s,x]);const Se=ug(e),ue=fg(),ke=re.status.kind==="loading",Me=Tn(Yd(s)),We=Tn(Y=>Y.recordVisit),Le=Tn(Y=>Y.forget);c.useEffect(()=>{re.status.kind==="ready"&&We(s,{url:bn(re.status.url),title:re.status.title})},[s,re.status,We]);const Ve=c.useMemo(()=>Xd(Me,j),[Me,j]),Ne=c.useCallback(Y=>{const fe=jn(Y);fe!==Zs&&(O.current=!1,y(fe),ge(null),Sa(fe,s).then(Re=>{const T=u.current;if(!T){w(Re);return}try{T.loadURL(Re)}catch{w(Re)}}).catch(Re=>{Re instanceof ka&&ge(fe)}))},[s]);c.useEffect(()=>{if(!x)return;let Y=!0;return Sa(x,s).then(fe=>{Y&&w(fe)}).catch(fe=>{if(Y){if(fe instanceof ka){ge(x),O.current=!1,w(Zs);return}w(x)}}),()=>{Y=!1}},[]);const me=c.useMemo(()=>({executeJavaScript:async(Y,fe)=>{const Re=u.current;if(!Re)throw new Error("Browser view is not available");return Re.executeJavaScript(Y,fe)},capturePage:async()=>{const Y=u.current;if(!Y)return null;const fe=Y.getWebContentsId();return Number.isFinite(fe)?await Sn("desktop_browser_capture_page",{webContentsId:fe}):null}}),[]),ye=c.useCallback(()=>{if(E){A(!1),Ao(me);return}if(!re.url){Oe.error(a("contextPanel.browser.annotate.noPage"));return}const Y=pg(d.metadata.variant==="light"?"light":"dark");A(!0),mg({host:me,theme:Y,labels:ue}).then(async fe=>{A(!1),fe&&await Se(fe)}).catch(()=>{A(!1),Oe.error(a("contextPanel.browser.annotate.failed"))})},[me,Se,d,E,re.url,ue,a]);c.useEffect(()=>{if(!E)return;const Y=fe=>{Dc(fe)||fe.key!=="Escape"||(fe.preventDefault(),fe.stopImmediatePropagation(),A(!1),Ao(me))};return window.addEventListener("keydown",Y,!0),()=>window.removeEventListener("keydown",Y,!0)},[me,E]);const je=c.useRef(!1);c.useEffect(()=>{if(!l)return;const Y=()=>{je.current=!0};return l.addEventListener("dom-ready",Y),l.addEventListener("did-fail-load",Y),()=>{l.removeEventListener("dom-ready",Y),l.removeEventListener("did-fail-load",Y)}},[l]);const Be=c.useCallback(async()=>{const Y=Date.now()+KS;for(;!(u.current&&je.current)&&Date.now()<Y;)await new Promise(fe=>setTimeout(fe,100));return u.current},[]),_e=c.useCallback(async(Y=8e3)=>{const fe=Date.now();for(;;){const Re=u.current;if(!Re)return!1;let T=!1;try{T=Re.isLoading()}catch{return!1}if(!T)return!0;if(Date.now()-fe>Y)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),Ie=c.useCallback(async(Y,fe)=>{const Re=X0({quietMs:Cl,maxMs:fe});let T;const ae=new Promise(pe=>{T=setTimeout(()=>pe(null),fe+1e3)});try{const pe=XS.safeParse(await Promise.race([Y.executeJavaScript(Re,!1),ae]));return pe.success&&pe.data.quiet}catch{return!1}finally{clearTimeout(T)}},[]),tt=c.useCallback(async(Y,fe=qS)=>{const Re=Date.now(),T=await _e(Math.min(25e3,Math.max(0,fe-Tl))),ae=fe-(Date.now()-Re),pe=T&&ae>Cl&&await Ie(Y,Math.min(Tl,ae));let oe="";try{oe=Y.getTitle()||""}catch{oe=""}return{title:oe,settled:pe}},[_e,Ie]),Ke=c.useCallback(async(Y,fe,Re)=>{const T=await Be();if(!T)throw new Error("The browser panel is not ready");const ae=()=>{yl(fe.viewport)&&($(vi(fe.viewport)),k(!0))};if(Y==="browser.back"||Y==="browser.forward"){const le=Y==="browser.back";if(!(le?T.canGoBack():T.canGoForward()))throw new Error(le?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");le?T.goBack():T.goForward(),await new Promise(bt=>setTimeout(bt,150)),await _e();let xe="";try{xe=T.getTitle()||""}catch{xe=""}return{url:bn(T.getURL()),title:xe}}if(Y==="browser.capture"){const le=JS(z.current);try{if(!await YS())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 _e()&&await Ie(T,GS);const et=await me.capturePage();if(!et)throw new Error("The page could not be captured");let xe="";try{xe=T.getTitle()||""}catch{xe=""}return{...et,url:bn(T.getURL()),title:xe,viewport:Cr(B.current)}}finally{le()}}if(Y==="browser.resize"){if(!yl(fe.viewport))throw new Error("viewport is required");return ae(),await new Promise(le=>setTimeout(le,200)),await _e(),{viewport:Cr(vi(fe.viewport))}}if(Y==="browser.open"){const le=typeof fe.url=="string"?fe.url:"";if(!le)throw new Error("url is required");return ae(),Ne(le),await new Promise(et=>setTimeout(et,150)),{url:jn(le),...await tt(T),opened:!0,viewport:Cr(B.current)}}if(Y==="browser.settle"){const le=xo().safeParse(fe.budgetMs);return tt(T,le.success?le.data:void 0)}await _e();const pe=le=>typeof le=="string"&&le?le:void 0,be=(()=>{switch(Y){case"browser.snapshot":return H0({selector:pe(fe.selector)});case"browser.click":return K0({selector:pe(fe.selector),text:pe(fe.text)});case"browser.type":return q0({selector:String(fe.selector??""),value:String(fe.value??""),submit:fe.submit===!0});case"browser.select":return G0({selector:String(fe.selector??""),label:typeof fe.label=="string"?fe.label:void 0,value:typeof fe.value=="string"?fe.value:void 0});case"browser.inspect":return J0({selector:String(fe.selector??"")});case"browser.scroll":return Z0({selector:pe(fe.selector),direction:pe(fe.direction)});default:return null}})();if(!be)throw new Error(`Unsupported browser action: ${Y}`);let $e=()=>{};(Y==="browser.click"||Y==="browser.type")&&(await Sn("desktop_browser_keep_page_focused",{webContentsId:T.getWebContentsId()}).then(et=>et.focused===!0).catch(()=>!1)||($e=Re(),T.focus({preventScroll:!0})));let De;try{De=await T.executeJavaScript(be,!0)}finally{$e()}if(!De||typeof De!="object")throw new Error("The page returned no result");const ee=De;if(ee.ok!==!0)throw new Error(typeof ee.error=="string"&&ee.error?ee.error:"Browser action failed");if(Y==="browser.snapshot"){const le=D.current;return{...ee,viewport:Cr(B.current),...le.length>0?{consoleProblems:[...le]}:{}}}return(Y==="browser.click"||Y==="browser.select"||Y==="browser.type"&&fe.submit===!0)&&(await new Promise(le=>setTimeout(le,150)),await _e()),De},[me,Ne,tt,_e,Ie,Be]),ze=MS(l,z),[rt,ve]=c.useState(!1),M=c.useCallback((Y,fe)=>(ve(!0),ze(Re=>Ke(Y,fe,Re))),[ze,Ke]),Ce=c.useCallback(()=>{const Y=u.current;if(!Y)return{title:"",url:""};let fe="",Re="";try{fe=Y.getTitle()||""}catch{fe=""}try{Re=bn(Y.getURL())}catch{Re=""}return{title:fe,url:Re}},[]);c.useEffect(()=>T0({tabId:r,directory:ie,ownerSessionId:o,describe:Ce,run:M}),[Ce,o,M,ie,r]),c.useEffect(()=>{const Y=me;return()=>{Ao(Y)}},[me]),c.useEffect(()=>{if(!l)return;const Y=Re=>{const T=Re;if(typeof T.level!="number"||T.level<2)return;const ae=T.sourceId?`${T.sourceId}${T.line?`:${T.line}`:""}`:"";D.current.push({level:T.level>=3?"error":"warning",message:String(T.message??"").slice(0,400),source:ae}),D.current.length>jl&&D.current.splice(0,D.current.length-jl)},fe=()=>{D.current=[]};return l.addEventListener("console-message",Y),l.addEventListener("did-start-loading",fe),()=>{l.removeEventListener("console-message",Y),l.removeEventListener("did-start-loading",fe)}},[l]);const He=c.useRef(new Set),Xe=c.useCallback(Y=>{He.current.clear(),Ne(Y)},[Ne]),G=c.useRef(re.status);G.current=re.status;const Ee=c.useRef(!1);re.status.kind==="ready"&&re.status.url&&(Ee.current=!0),c.useEffect(()=>Ku(ie,r,Y=>{Gu(G.current,Ee.current)&&Xe(Y)}),[Xe,ie,r]),c.useEffect(()=>{if(!l)return;const Y=Re=>{const T=kn(Re),ae=typeof T.url=="string"?T.url:"";!ae||!ja(ae,s)||(Re.preventDefault(),Ne(ae))},fe=Re=>{const T=kn(Re);if(T.isMainFrame===!1||T.errorCode===-3)return;const ae=typeof T.validatedURL=="string"?T.validatedURL:"";!ae||!ja(ae,s)||He.current.has(ae)||(He.current.add(ae),Ne(ae))};return l.addEventListener("will-navigate",Y),l.addEventListener("did-fail-load",fe),()=>{l.removeEventListener("will-navigate",Y),l.removeEventListener("did-fail-load",fe)}},[s,Ne,l]),c.useEffect(()=>{if(!l)return;const Y=fe=>{if(!(fe instanceof CustomEvent))return;const Re=US.safeParse(fe.detail);if(!Re.success)return;let T=-1;try{T=l.getWebContentsId()}catch{return}Re.data.webContentsId===T&&K.getState().openContextBrowser(ie,Re.data.url,{reveal:!Re.data.background})};return window.addEventListener(kl,Y),()=>window.removeEventListener(kl,Y)},[ie,l]);const Pe=c.useCallback(Y=>{const fe=Math.min(zS,Math.max($S,Y));C.current=fe,v(fe);try{u.current?.setZoomLevel(fe)}catch{}},[]);c.useEffect(()=>{const Y=fe=>{if(!(fe instanceof CustomEvent))return;const Re=fe.detail,T=u.current;!T||document.activeElement!==T||(Re==="zoom-in"?Pe(C.current+Er):Re==="zoom-out"?Pe(C.current-Er):Re==="zoom-reset"&&Pe(0))};return window.addEventListener("openchamber:zoom",Y),()=>window.removeEventListener("openchamber:zoom",Y)},[Pe]);const Fe=c.useCallback(Y=>{Sn("desktop_browser_clear_data",{partition:Sl(s),cookies:Y==="cookies",cache:Y==="cache"}).then(()=>{Oe.success(a(Y==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{u.current?.reloadIgnoringCache()}catch{}}).catch(()=>Oe.error(a("contextPanel.browser.clearFailed")))},[s,a]);c.useEffect(()=>{const Y=z.current;if(!Y||typeof ResizeObserver>"u")return;const fe=new ResizeObserver(Re=>{const T=Re[0]?.contentRect;T&&se({width:T.width,height:T.height})});return fe.observe(Y),()=>fe.disconnect()},[]);const Te=c.useCallback(Y=>{H(Y);const fe=u.current;if(!fe)return;let Re=-1;try{Re=fe.getWebContentsId()}catch{return}Sn("desktop_browser_set_color_scheme",{webContentsId:Re,scheme:Y}).catch(T=>{H("system"),Oe.error(T instanceof Error?T.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),Ae=c.useCallback(()=>{try{ke?u.current?.stop():u.current?.reload()}catch{}},[ke]),qe=re.status,Ge=c.useSyncExternalStore(FS,LS),Je=i&&Ge||o!==null||rt;c.useEffect(()=>{const Y=pe=>{_(!0);const oe=setTimeout(()=>{try{u.current?.reload()}catch{}},pe);return()=>clearTimeout(oe)};if(qe.kind==="loading")return;const fe=O.current||ne.current===qe;if(O.current&&(qe.kind==="failed"||qe.kind==="ready"&&qe.url)&&(O.current=!1,ne.current=qe),qe.kind==="failed"){const pe=qu(qe,{run:Q.current,restored:fe,watched:Je,now:Date.now()});if(Q.current=pe.run,pe.next==="retry")return Y(pe.delayMs);_(pe.next==="pause");return}if(Q.current=null,qe.kind!=="ready"||!qe.url||!sc(qe.url)){V.current=!0,_(!1);return}if(fe||V.current||Date.now()-J.current>HS){V.current=!0,_(!1);return}let Re=!1,T=null;return(bs(s)?Promise.resolve(null):i0(bn(qe.url))).then(pe=>{if(!Re){if(pe===null||pe<500){V.current=!0,_(!1);return}T=Y(VS)}}),()=>{Re=!0,T?.()}},[s,qe,Je]);const st=re.status.kind==="failed"&&!R?re.status:null,mt=sS(N,U);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(Jd,{address:j,onAddressChange:y,onSubmit:Xe,suggestions:Ve,onForgetSuggestion:Y=>Le(s,Y),onBack:()=>{try{u.current?.goBack()}catch{}},onForward:()=>{try{u.current?.goForward()}catch{}},onReload:Ae,onOpenExternal:()=>{On(re.url||j)},addressMark:lu(s,j,b??a("contextPanel.browser.spaceAddress")),canOpenExternal:bs(s)===null,canGoBack:re.canGoBack,canGoForward:re.canGoForward,isLoading:ke,onAnnotate:ye,isAnnotating:E,onOpenDevTools:()=>{try{u.current?.openDevTools()}catch{}},onHardReload:()=>{try{u.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Pe(L+Er),onZoomOut:()=>Pe(L-Er),onZoomReset:()=>Pe(0),zoomPercent:Math.round(Math.pow(1.2,L)*100),onClearCookies:()=>Fe("cookies"),onClearCache:()=>Fe("cache"),onToggleDeviceBar:()=>k(Y=>!Y),isDeviceBarOpen:S}),S?n.jsx(oS,{viewport:N,onViewportChange:$,colorScheme:W,onColorSchemeChange:Te,scale:mt?.scale??1}):null,n.jsxs("div",{ref:z,className:Ze("relative min-h-0 flex-1 bg-background",mt&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&Z?n.jsx("webview",{ref:m,src:g,partition:Sl(s),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:mt?{width:`${mt.width}px`,height:`${mt.height}px`,transform:`scale(${mt.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!x&&!re.url&&!ke?n.jsx(iu,{onOpen:Xe,directory:s,visible:i}):null,R?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,q?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[bs(s)!==null?n.jsx(ce,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a(bs(s)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:q})})]}):null,st&&!q?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:st.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:st.crashed?a("contextPanel.browser.crashedHint"):st.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,ke?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},e2=t=>{const e=Ue.c(75),{initialUrl:s,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:d}=lt(),u=K(s2);let l;e[0]!==s?(l=jn(s),e[0]=s,e[1]=l):l=e[1];const f=l,m=f!==Zs?f:"",[p,h]=c.useState(m);let x;e[2]!==o||e[3]!==m?(x=Io(m,o),e[2]=o,e[3]=m,e[4]=x):x=e[4];const[g,w]=c.useState(x);let b;e[5]!==o||e[6]!==m?(b=wc(m,o)?m:"",e[5]=o,e[6]=m,e[7]=b):b=e[7];const[j,y]=c.useState(b);let E;e[8]!==o?(E=bs(o),e[8]=o,e[9]=E):E=e[9];const A=E!==null,R=oa(o);let _;e[10]!==m?(_=m?[m]:[],e[10]=m,e[11]=_):_=e[11];const[L,v]=c.useState(_),[C,S]=c.useState(m?0:-1),[k,N]=c.useReducer(n2,0);let $,B;e[12]!==i||e[13]!==r?($=()=>{tc(rs(r),i)},B=[r,i],e[12]=i,e[13]=r,e[14]=$,e[15]=B):($=e[14],B=e[15]),c.useEffect($,B);let D;e[16]!==u||e[17]!==i||e[18]!==r?(D=Ve=>{!Ve||Ve===Zs||!r||!i||u(r,i,Ve)},e[16]=u,e[17]=i,e[18]=r,e[19]=D):D=e[19];const W=D;let H;e[20]!==o?(H=Yd(o),e[20]=o,e[21]=H):H=e[21];const U=Tn(H),se=Tn(r2),z=Tn(o2);let Q;e[22]!==p||e[23]!==U?(Q=Xd(U,p),e[22]=p,e[23]=U,e[24]=Q):Q=e[24];const ie=Q;let O;e[25]!==o||e[26]!==C||e[27]!==W||e[28]!==se?(O=Ve=>{const Ne=jn(Ve);if(Ne===Zs)return;h(Ne);const me=Io(Ne,o);w(me),y(me?"":Ne),W(Ne),se(o,{url:Ne}),v(ye=>{const je=C>=0?ye.slice(0,C+1):[];return je[je.length-1]===Ne?(S(je.length-1),je):(S(je.length),[...je,Ne])})},e[25]=o,e[26]=C,e[27]=W,e[28]=se,e[29]=O):O=e[29];const ne=O;let V;e[30]!==o||e[31]!==L||e[32]!==W?(V=Ve=>{const Ne=L[Ve];if(!Ne)return;S(Ve),h(Ne);const me=Io(Ne,o);w(me),y(me?"":Ne),W(Ne)},e[30]=o,e[31]=L,e[32]=W,e[33]=V):V=e[33];const J=V;let F;e[34]!==o||e[35]!==z?(F=Ve=>z(o,Ve),e[34]=o,e[35]=z,e[36]=F):F=e[36];let re,q;e[37]!==J||e[38]!==C?(re=()=>J(C-1),q=()=>J(C+1),e[37]=J,e[38]=C,e[39]=re,e[40]=q):(re=e[39],q=e[40]);let ge;e[41]!==p||e[42]!==g?(ge=()=>{On(g||p)},e[41]=p,e[42]=g,e[43]=ge):ge=e[43];let Z;e[44]!==R||e[45]!==d?(Z=R??d("contextPanel.browser.spaceAddress"),e[44]=R,e[45]=d,e[46]=Z):Z=e[46];let de;e[47]!==p||e[48]!==o||e[49]!==Z?(de=lu(o,p,Z),e[47]=p,e[48]=o,e[49]=Z,e[50]=de):de=e[50];const Se=!j,ue=C>0,ke=C>=0&&C<L.length-1;let Me;e[51]!==p||e[52]!==ne||e[53]!==ie||e[54]!==F||e[55]!==re||e[56]!==q||e[57]!==ge||e[58]!==de||e[59]!==Se||e[60]!==ue||e[61]!==ke?(Me=n.jsx(Jd,{address:p,onAddressChange:h,onSubmit:ne,suggestions:ie,onForgetSuggestion:F,onBack:re,onForward:q,onReload:N,onOpenExternal:ge,addressMark:de,canOpenExternal:Se,canGoBack:ue,canGoForward:ke,isLoading:!1}),e[51]=p,e[52]=ne,e[53]=ie,e[54]=F,e[55]=re,e[56]=q,e[57]=ge,e[58]=de,e[59]=Se,e[60]=ue,e[61]=ke,e[62]=Me):Me=e[62];let We;e[63]!==o||e[64]!==A||e[65]!==g||e[66]!==ne||e[67]!==k||e[68]!==d||e[69]!==j||e[70]!==a?(We=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:j?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[A?n.jsx(ce,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:d(A?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:ro(j)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:d("contextPanel.browser.remoteLoopback.hint")})]}):g?n.jsx("iframe",{src:g,title:d("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${k}`):n.jsx(iu,{onOpen:ne,directory:o,visible:a})}),e[63]=o,e[64]=A,e[65]=g,e[66]=ne,e[67]=k,e[68]=d,e[69]=j,e[70]=a,e[71]=We):We=e[71];let Le;return e[72]!==Me||e[73]!==We?(Le=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Me,We]}),e[72]=Me,e[73]=We,e[74]=Le):Le=e[74],Le},t2=t=>{const e=Ue.c(3),[s]=c.useState(BS);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(QS,{...t}):n.jsx(e2,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function s2(t){return t.setContextPanelTabTargetPath}function n2(t){return t+1}function r2(t){return t.recordVisit}function o2(t){return t.forget}const i2=t=>{const e=Ue.c(13),{zone:s,children:r}=t,[o]=c.useState(a2);let i;e[0]!==s?(i=p=>p.body[s],e[0]=s,e[1]=i):i=e[1];const a=dr(i);let d,u;e[2]!==a||e[3]!==o||e[4]!==s?(d=()=>{const p=a??dr.getState().body[s];if(!p){o.remove();return}if(o.parentElement===p)return;const h=document.activeElement;p.moveBefore&&o.isConnected?p.moveBefore(o,null):p.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:!0})},u=[a,o,s],e[2]=a,e[3]=o,e[4]=s,e[5]=d,e[6]=u):(d=e[5],u=e[6]),c.useLayoutEffect(d,u);let l,f;e[7]!==o?(l=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=l,e[9]=f):(l=e[8],f=e[9]),c.useLayoutEffect(l,f);let m;return e[10]!==r||e[11]!==o?(m=Gl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=m):m=e[12],m};function a2(){const t=document.createElement("div");return t.style.display="contents",t}const l2=200,cu=t=>`${t.path}:${t.line}:${t.column}`,El={status:"idle"},c2=t=>{const e=Ue.c(9),{searchContents:s,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:d,active:u}=t,[l,f]=c.useState(El);let m,p;return e[0]!==u||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==d||e[6]!==s?(m=()=>{if(!u||!s||!r||!o.trim()){f(El);return}const h=new AbortController;let x=!1;return f({status:"searching"}),s({directory:r,query:o,regex:i,limit:l2,includeHidden:a,respectGitignore:d,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()}},p=[u,r,a,o,i,d,s],e[0]=u,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=d,e[6]=s,e[7]=m,e[8]=p):(m=e[7],p=e[8]),c.useEffect(m,p),l},on=t=>{const e=Ue.c(5),{className:s,children:r}=t;let o;e[0]!==s?(o=Ze("px-2 py-1 typography-meta text-muted-foreground",s),e[0]=s,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=n.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},d2=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},u2=t=>{const e=Ue.c(44),{state:s,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:d}=lt();switch(s.status){case"idle":return null;case"searching":{let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ce,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=m):m=e[0];let p;e[1]!==d?(p=d("sidebarFilesTree.state.searching"),e[1]=d,e[2]=p):p=e[2];let h;return e[3]!==p?(h=n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[m,p]}),e[3]=p,e[4]=h):h=e[4],h}case"unavailable":{let m;e[5]!==d?(m=d("sidebarFilesTree.contentSearch.unavailable"),e[5]=d,e[6]=m):m=e[6];let p;return e[7]!==m?(p=n.jsx(on,{children:m}),e[7]=m,e[8]=p):p=e[8],p}case"invalid-pattern":{let m;e[9]!==d?(m=d("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=d,e[10]=m):m=e[10];let p;e[11]!==m?(p=n.jsx("span",{className:"text-[var(--status-error)]",children:m}),e[11]=m,e[12]=p):p=e[12];let h;e[13]!==s.message?(h=n.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:s.message}),e[13]=s.message,e[14]=h):h=e[14];let x;return e[15]!==p||e[16]!==h?(x=n.jsxs(on,{className:"flex flex-col gap-0.5",children:[p,h]}),e[15]=p,e[16]=h,e[17]=x):x=e[17],x}case"failed":{let m;e[18]!==s.message||e[19]!==d?(m=d("sidebarFilesTree.contentSearch.failed",{message:s.message}),e[18]=s.message,e[19]=d,e[20]=m):m=e[20];let p;return e[21]!==m?(p=n.jsx(on,{className:"text-[var(--status-error)]",children:m}),e[21]=m,e[22]=p):p=e[22],p}}if(s.matches.length===0){let m;return e[23]!==s.stopped||e[24]!==d?(m=s.stopped==="deadline"?n.jsx(on,{children:d("sidebarFilesTree.contentSearch.deadline")}):n.jsx(on,{children:d("sidebarFilesTree.contentSearch.empty")}),e[23]=s.stopped,e[24]=d,e[25]=m):m=e[25],m}let u;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==s.matches){let m;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(m=p=>{const{name:h,directory:x}=d2(p.relativePath),g=cu(p),w=r===g;return n.jsx("li",{"data-file-tree-path":p.path,children:n.jsxs("button",{type:"button",onClick:()=>o(p),onDoubleClick:()=>o(p,{pin:!0}),draggable:!!i,onDragStart:i?b=>i(b,p):void 0,onDragEnd:a?b=>a(b,p):void 0,className:Ze("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",Zi(w)),title:`${p.relativePath}:${p.line}`,children:[n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[n.jsx(mo,{filePath:p.path,className:"size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`${x}`}):n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:p.line})]}),n.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[p.cutStart?"…":null,n.jsx(rp,{segments:op(p.text,p.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=m):m=e[36],u=s.matches.map(m),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=s.matches,e[31]=u}else u=e[31];let l;e[37]!==s.matches.length||e[38]!==s.stopped||e[39]!==d?(l=s.stopped==="limit"?n.jsx(on,{children:d("sidebarFilesTree.contentSearch.limit",{count:s.matches.length})}):s.stopped==="deadline"?n.jsx(on,{children:d("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=s.matches.length,e[38]=s.stopped,e[39]=d,e[40]=l):l=e[40];let f;return e[41]!==u||e[42]!==l?(f=n.jsxs(n.Fragment,{children:[u,l]}),e[41]=u,e[42]=l,e[43]=f):f=e[43],f},Pl=8;let fr=null;const du=(t,e)=>Math.abs(e.clientX-t.x)<=Pl&&Math.abs(e.clientY-t.y)<=Pl,ji=t=>{fr={x:t.clientX,y:t.clientY}},Ci=t=>{const e=fr;return fr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:du(e,t)},uu=t=>fr!==null&&du(fr,t);let fu=null;const Xo=t=>{fu=t},pu=()=>fu,Il=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},mu=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:Il(e.path);return!r||Il(t.path)===r||t.type==="directory"&&Zu(r,t.path,t.path)!==null?null:r},f2=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},p2=({root:t,childrenByDir:e,expandedPaths:s,loadErrorsByDir:r})=>{const o=[],i=(a,d)=>{for(const u of e[a]??[]){const l=u.type==="directory"&&s.has(u.path);if(o.push({kind:"node",key:u.path,node:u,depth:d,isExpanded:l}),!l)continue;const f=r[u.path];f&&o.push({kind:"error",key:`error:${u.path}`,directory:u.path,depth:d+1,message:f}),i(u.path,d+1)}};return i(t,0),o},m2=(t,e,s)=>{const r=e.filter(o=>o>=0&&o<s&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},h2=28,Nn=t=>Array.from(t.types).includes("Files"),Qn=t=>Array.from(t.types).includes(ar)?pu():null,hu=(t,e,s)=>t.getData(ar)===So(e,s.path),g2=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},x2=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),Lt=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},So=(t,e)=>{const s=Lt(e),r=Lt(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},zn=(t,e)=>{const s=So(t,e);if(s!==".")return s;const r=Lt(t);return r.split("/").filter(Boolean).pop()??r},Lr=t=>{const e=Lt(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},b2=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),w2=new Set(["node_modules"]),y2=t=>w2.has(t),v2=t=>{const e=Lt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},S2=8,Es=new Map,aa=t=>JSON.stringify([qt(),t]),k2=t=>{const e=aa(t),s=Es.get(e);return s?(s.touchedAt=Date.now(),Es.delete(e),Es.set(e,s),s):null},Yo=t=>{const e=aa(t),s=Es.get(e);if(s)return s.touchedAt=Date.now(),s;if(Es.size>=S2){const o=Es.keys().next().value;o!==void 0&&Es.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Es.set(e,r),r},j2=t=>{const e=Ue.c(159),{guestActions:s,node:r,root:o,isExpanded:i,isActive:a,isBrowserClient:d,depth:u,isOpen:l,status:f,badge:m,isDropTarget:p,isDragSource:h,canUpload:x,canMove:g,permissions:w,downloadFile:b,onSelect:j,onToggle:y,onRevealPath:E,onOpenDialog:A,onSetDropTarget:R,onDropFiles:_,onPickFiles:L,onMoveDragChange:v,onSetMoveDropTarget:C,onMoveDrop:S}=t,{t:k}=lt(),N=r.type==="directory";let $;e[0]!==N||e[1]!==r.path?($=N?r.path:Lr(r.path),e[0]=N,e[1]=r.path,e[2]=$):$=e[2];const B=$,{canRename:D,canCreateFile:W,canCreateFolder:H,canDelete:U,canReveal:se}=w,z=!N&&!!b,Q=se&&!d,ie=N&&x,O=D||W||H||ie||U||z||Q,[ne,V]=c.useState(!1),[J,F]=c.useState(!1);let re;e[3]!==O?(re=_e=>{O&&(_e?.preventDefault(),F(!0))},e[3]=O,e[4]=re):re=e[4];const q=re;let ge;e[5]!==N||e[6]!==r||e[7]!==j||e[8]!==y?(ge=()=>{N?y(r.path):j(r)},e[5]=N,e[6]=r,e[7]=j,e[8]=y,e[9]=ge):ge=e[9];const Z=ge;let de;e[10]!==N||e[11]!==r||e[12]!==j?(de=()=>{N||j(r,{pin:!0})},e[10]=N,e[11]=r,e[12]=j,e[13]=de):de=e[13];const Se=de;let ue;e[14]===Symbol.for("react.memo_cache_sentinel")?(ue=_e=>{_e.stopPropagation(),F(!1),V(!0)},e[14]=ue):ue=e[14];const ke=ue;let Me,We,Le,Ve,Ne,me,ye;if(e[15]!==m||e[16]!==W||e[17]!==H||e[18]!==U||e[19]!==g||e[20]!==D||e[21]!==Q||e[22]!==x||e[23]!==ie||e[24]!==ne||e[25]!==u||e[26]!==b||e[27]!==s||e[28]!==q||e[29]!==Se||e[30]!==Z||e[31]!==O||e[32]!==a||e[33]!==d||e[34]!==N||e[35]!==h||e[36]!==p||e[37]!==i||e[38]!==l||e[39]!==r||e[40]!==_||e[41]!==v||e[42]!==S||e[43]!==A||e[44]!==L||e[45]!==E||e[46]!==R||e[47]!==C||e[48]!==J||e[49]!==o||e[50]!==f||e[51]!==k||e[52]!==B){const _e=hg(s,"file"),Ie=ee=>{const{Item:le,Separator:et}=ee;return n.jsxs(n.Fragment,{children:[D&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("rename",r)},children:[n.jsx(ce,{name:"edit",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.rename")]}),n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),io(r.path).then(bt=>{if(bt.ok){Oe.success(k("sidebarFilesTree.toast.pathCopied"));return}Oe.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(ce,{name:"link",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.copyPath")]}),!N&&b&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),b(r.path).catch(bt=>{console.error("Download failed:",bt),Oe.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ce,{name:"download",className:"me-2 h-4 w-4"})," ",k(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Q&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),E(r.path)},children:[n.jsx(ce,{name:"folder-received",className:"me-2 h-4 w-4"})," ",k(bg())]}),!N&&Q&&no()&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),Xl(r.path).then(bt=>{bt||Oe.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ce,{name:"external-link",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.openInDefaultApp")]}),_e.length>0&&n.jsx(et,{}),_e.map(xe=>n.jsxs(le,{onClick:bt=>{bt.stopPropagation(),wg(xe,{kind:"file",action:xe.action.id,directory:o||null,path:r.path,isDirectory:N},k)},children:[n.jsx(Gi,{icon:xe.icon,iconSrc:xe.iconSrc,className:"me-2 h-4 w-4"})," ",xe.action.label]},`${xe.guest.id}:${xe.action.id}`)),N&&(W||H||ie)&&n.jsxs(n.Fragment,{children:[n.jsx(et,{}),W&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("createFile",r)},children:[n.jsx(ce,{name:"file-add",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.newFile")]}),H&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("createFolder",r)},children:[n.jsx(ce,{name:"folder-add",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.newFolder")]}),ie&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),L(r.path)},children:[n.jsx(ce,{name:"upload-2",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.uploadFiles")]})]}),U&&n.jsxs(n.Fragment,{children:[n.jsx(et,{}),n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(ce,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.delete")]})]})]})};let tt;e[60]!==g||e[61]!==r.path||e[62]!==r.type||e[63]!==v||e[64]!==o?(tt=ee=>{ji(ee);const le=So(o,r.path);!le||le==="."||(ee.dataTransfer.setData(ar,le),ee.dataTransfer.effectAllowed=g?"copyMove":"copy",g&&v({path:r.path,type:r.type}))},e[60]=g,e[61]=r.path,e[62]=r.type,e[63]=v,e[64]=o,e[65]=tt):tt=e[65];const Ke=tt;let ze;e[66]!==g||e[67]!==Z||e[68]!==v?(ze=ee=>{g&&v(null),Ci(ee)&&Z()},e[66]=g,e[67]=Z,e[68]=v,e[69]=ze):ze=e[69];const rt=ze;let ve;e[70]!==x||e[71]!==R||e[72]!==B?(ve=ee=>{!x||!B||!Nn(ee.dataTransfer)||(ee.preventDefault(),ee.stopPropagation(),ee.dataTransfer.dropEffect="copy",R(B))},e[70]=x,e[71]=R,e[72]=B,e[73]=ve):ve=e[73];const M=ve;let Ce;e[74]!==x||e[75]!==R||e[76]!==B?(Ce=ee=>{!x||!B||!Nn(ee.dataTransfer)||ee.relatedTarget instanceof Node&&ee.currentTarget.contains(ee.relatedTarget)||(ee.stopPropagation(),R(null))},e[74]=x,e[75]=R,e[76]=B,e[77]=Ce):Ce=e[77];const He=Ce;let Xe;e[78]!==x||e[79]!==_||e[80]!==B?(Xe=ee=>{!x||!B||!Nn(ee.dataTransfer)||(ee.preventDefault(),ee.stopPropagation(),_(B,ee.dataTransfer))},e[78]=x,e[79]=_,e[80]=B,e[81]=Xe):Xe=e[81];const G=Xe;let Ee;e[82]!==r.path||e[83]!==r.type||e[84]!==o?(Ee=(ee,le)=>uu(ee)?null:mu(le,{path:r.path,type:r.type},o),e[82]=r.path,e[83]=r.type,e[84]=o,e[85]=Ee):Ee=e[85];const Pe=Ee;let Fe;e[86]!==g||e[87]!==Pe||e[88]!==M||e[89]!==C?(Fe=ee=>{const le=g?Qn(ee.dataTransfer):null;if(!le){M(ee);return}ee.stopPropagation();const et=Pe(ee,le);C(et),et&&(ee.preventDefault(),ee.dataTransfer.dropEffect="move")},e[86]=g,e[87]=Pe,e[88]=M,e[89]=C,e[90]=Fe):Fe=e[90];const Te=Fe;let Ae;e[91]!==g||e[92]!==Pe||e[93]!==G||e[94]!==S||e[95]!==C||e[96]!==o?(Ae=ee=>{const le=g?Qn(ee.dataTransfer):null;if(!le){G(ee);return}ee.stopPropagation(),ee.preventDefault(),C(null);const et=Pe(ee,le);et&&hu(ee.dataTransfer,o,le)&&S(le,et)},e[91]=g,e[92]=Pe,e[93]=G,e[94]=S,e[95]=C,e[96]=o,e[97]=Ae):Ae=e[97];const qe=Ae;We=xr,me=J,ye=F;let Ge;e[98]===Symbol.for("react.memo_cache_sentinel")?(Ge={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[98]=Ge):Ge=e[98];let Je;e[99]!==q||e[100]!==He||e[101]!==Te||e[102]!==qe?(Je=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ge,onContextMenu:q,onDragEnter:Te,onDragOver:Te,onDragLeave:He,onDrop:qe}),e[99]=q,e[100]=He,e[101]=Te,e[102]=qe,e[103]=Je):Je=e[103];let st;e[104]!==u?(st=n.jsx(Gc,{depth:u}),e[104]=u,e[105]=st):st=e[105];let mt;e[106]!==a||e[107]!==h||e[108]!==p?(mt=Ze("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(a),h&&"opacity-50"),e[106]=a,e[107]=h,e[108]=p,e[109]=mt):mt=e[109];let Y;e[110]!==u?(Y=Zc(u),e[110]=u,e[111]=Y):Y=e[111];let fe;e[112]!==Y?(fe={paddingInlineStart:Y},e[112]=Y,e[113]=fe):fe=e[113];let Re;e[114]!==N||e[115]!==i||e[116]!==r.extension||e[117]!==r.path?(Re=N?n.jsx(gg,{expanded:i}):n.jsx(mo,{filePath:r.path,extension:r.extension,className:"ms-0.5 size-3.5"}),e[114]=N,e[115]=i,e[116]=r.extension,e[117]=r.path,e[118]=Re):Re=e[118];let T;e[119]!==r.name||e[120]!==r.path?(T=n.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:r.path,children:r.name}),e[119]=r.name,e[120]=r.path,e[121]=T):T=e[121];let ae;e[122]!==N||e[123]!==l||e[124]!==f?(ae=!N&&n.jsx(yg,{isOpen:l,status:f}),e[122]=N,e[123]=l,e[124]=f,e[125]=ae):ae=e[125];let pe;e[126]!==m||e[127]!==N?(pe=N&&m&&n.jsx(vg,{badge:m}),e[126]=m,e[127]=N,e[128]=pe):pe=e[128];let oe;e[129]!==ae||e[130]!==pe?(oe=n.jsxs(Sg,{className:"pe-2",children:[ae,pe]}),e[129]=ae,e[130]=pe,e[131]=oe):oe=e[131];let be;e[132]!==q||e[133]!==Se||e[134]!==rt||e[135]!==Ke||e[136]!==Z||e[137]!==mt||e[138]!==fe||e[139]!==Re||e[140]!==T||e[141]!==oe?(be=n.jsxs("button",{type:"button",onClick:Z,onDoubleClick:Se,onContextMenu:q,draggable:!0,onDragStart:Ke,onDragEnd:rt,className:mt,style:fe,children:[Re,T,oe]}),e[132]=q,e[133]=Se,e[134]=rt,e[135]=Ke,e[136]=Z,e[137]=mt,e[138]=fe,e[139]=Re,e[140]=T,e[141]=oe,e[142]=be):be=e[142];const $e=O&&n.jsx("div",{className:Ze("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 pointer-fine:hidden",xg(a||p)),children:n.jsxs(fn,{open:ne,onOpenChange:V,children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(pn,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ke,"aria-label":k("diffView.actions.moreActions"),children:n.jsx(ce,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:k("diffView.actions.moreActions")})]}),n.jsx(mn,{align:"end",side:"bottom",onCloseAutoFocus:()=>V(!1),children:Ie({Item:$s,Separator:qn})})]})});e[143]!==Je||e[144]!==st||e[145]!==be||e[146]!==$e?(Le=n.jsxs(ao,{render:Je,children:[st,be,$e]}),e[143]=Je,e[144]=st,e[145]=be,e[146]=$e,e[147]=Le):Le=e[147],Me=br,Ve="min-w-[180px]";let De;e[148]===Symbol.for("react.memo_cache_sentinel")?(De={Item:vs,Separator:Cn},e[148]=De):De=e[148],Ne=Ie(De),e[15]=m,e[16]=W,e[17]=H,e[18]=U,e[19]=g,e[20]=D,e[21]=Q,e[22]=x,e[23]=ie,e[24]=ne,e[25]=u,e[26]=b,e[27]=s,e[28]=q,e[29]=Se,e[30]=Z,e[31]=O,e[32]=a,e[33]=d,e[34]=N,e[35]=h,e[36]=p,e[37]=i,e[38]=l,e[39]=r,e[40]=_,e[41]=v,e[42]=S,e[43]=A,e[44]=L,e[45]=E,e[46]=R,e[47]=C,e[48]=J,e[49]=o,e[50]=f,e[51]=k,e[52]=B,e[53]=Me,e[54]=We,e[55]=Le,e[56]=Ve,e[57]=Ne,e[58]=me,e[59]=ye}else Me=e[53],We=e[54],Le=e[55],Ve=e[56],Ne=e[57],me=e[58],ye=e[59];let je;e[149]!==Me||e[150]!==Ve||e[151]!==Ne?(je=n.jsx(Me,{className:Ve,children:Ne}),e[149]=Me,e[150]=Ve,e[151]=Ne,e[152]=je):je=e[152];let Be;return e[153]!==We||e[154]!==Le||e[155]!==je||e[156]!==me||e[157]!==ye?(Be=n.jsxs(We,{open:me,onOpenChange:ye,children:[Le,je]}),e[153]=We,e[154]=Le,e[155]=je,e[156]=me,e[157]=ye,e[158]=Be):Be=e[158],Be},C2=(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&&t.guestActions===e.guestActions,T2=c.memo(j2,C2),N2=t=>{const e=Ue.c(14),{visible:s}=t,r=s===void 0?!0:s,o=Dn(P2),i=Hs()??"",a=wr();let d,u,l,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(u=co(a,i)??"",a?.kind==="preparing"){let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Rr,{}),e[7]=p):p=e[7],f=p;break e}d=E2,l=JSON.stringify([o,u])}e[0]=a,e[1]=i,e[2]=o,e[3]=d,e[4]=u,e[5]=l,e[6]=f}else d=e[3],u=e[4],l=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[8]!==d||e[9]!==u||e[10]!==i||e[11]!==l||e[12]!==r?(m=n.jsx(d,{visible:r,currentDirectory:u,panelDirectory:i},l),e[8]=d,e[9]=u,e[10]=i,e[11]=l,e[12]=r,e[13]=m):m=e[13],m},E2=({visible:t,currentDirectory:e,panelDirectory:s})=>{const r=c.useRef(t);r.current=t;const{t:o}=lt(),{files:i,runtime:a}=ks(),d=kg(),u=Xu(a.platform),l=Lt(e.trim()),f=Lt(s.trim()),m=aa(l),p=Yu(),h=Ju(),x=Qu(I=>I.searchFiles),g=K(I=>I.openContextFile),w=fo(t?e:null),[b,j]=c.useState(""),y=jg(b,200),E=c.useRef(null),[A,R]=c.useState([]),[_,L]=c.useState(!1),v=!!i.searchContents,[C,S]=c.useState("names"),[k,N]=c.useState(!1),$=v&&C==="contents",B=c2({searchContents:i.searchContents,directory:e,query:y,regex:k,includeHidden:p,respectGitignore:!h,active:t&&$}),D=K(I=>I.openContextFileAtLine),[W,H]=c.useState(null),[U,se]=c.useState(null),[z,Q]=c.useState(null),[ie,O]=c.useState(null),[ne,V]=c.useState(null),{hasTouchOnlyPointer:J}=hn(),F=!!(i.rename&&l)&&!J,re=K(I=>I.confirmFileTreeMove),q=K(I=>I.setConfirmFileTreeMove),[ge,Z]=c.useState({}),[de,Se]=c.useState({}),ue=c.useRef(new Set),ke=c.useRef(new Map),Me=c.useMemo(()=>new px,[]);c.useEffect(()=>()=>Me.clear(),[Me]);const We=c.useRef(null);c.useEffect(()=>{if(se(null),O(null),V(null),!l){Z({}),Se({}),ue.current=new Set;return}const I=k2(l);I?(Z({...I.childrenByDir}),Se({...I.loadErrorsByDir}),ue.current=new Set(I.loadedDirs)):(Z({}),Se({}),ue.current=new Set)},[l]),c.useEffect(()=>{if(!l)return;const I=Yo(l);I.childrenByDir=ge},[l,ge]),c.useEffect(()=>{if(!l)return;const I=Yo(l);I.loadErrorsByDir=de},[l,de]),c.useEffect(()=>{if(!l)return;const I=Yo(l);I.loadedDirs=new Set(ue.current)},[l,ge,de]),c.useEffect(()=>()=>{if(!l)return;const I=Es.get(m);I&&I.loadedDirs.size===0&&Object.keys(I.childrenByDir).length===0&&Es.delete(m)},[m,l]);const Le=c.useMemo(()=>[],[]),Ve=c.useMemo(()=>[],[]),Ne=us(I=>l?I.byRoot[l]?.expandedPaths??Le:Le),me=c.useMemo(()=>new Set(Ne),[Ne]),ye=us(I=>l?I.byRoot[l]?.selectedPath??null:null),je=us(I=>I.setSelectedPath),Be=c.useRef(null);c.useEffect(()=>{Be.current=ye},[ye]);const _e=us(I=>I.addOpenPath),Ie=us(I=>I.removeOpenPathsByPrefix),tt=us(I=>I.toggleExpandedPath),Ke=us(I=>I.expandPath),ze=us(I=>I.collapseAllExpandedPaths),rt=K(I=>f?I.contextPanelByDirectory[f]?.tabs??Ve:Ve),ve=c.useMemo(()=>new Set(rt.map(I=>I.mode==="file"?I.targetPath:null).filter(I=>typeof I=="string"&&I.length>0).map(I=>Lt(I))),[rt]),[M,Ce]=c.useState(null),[He,Xe]=c.useState(null),[G,Ee]=c.useState(""),[Pe,Fe]=c.useState(!1),Te=!!i.writeFile,Ae=!!i.createDirectory,qe=!!i.rename,Ge=!!i.delete,Je=!!i.revealPath,st=c.useMemo(()=>({canRename:qe,canCreateFile:Te,canCreateFolder:Ae,canDelete:Ge,canReveal:Je}),[qe,Te,Ae,Ge,Je]),mt=c.useCallback(I=>{i.revealPath&&i.revealPath(I).catch(()=>{Oe.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),Y=c.useCallback((I,P)=>{Ce(I),Xe(P),Ee(I==="rename"&&P.name||""),Fe(!1)},[]),fe=c.useCallback((I,P)=>{const we=P.filter(he=>he&&typeof he.name=="string"&&he.name.length>0).filter(he=>p||!he.name.startsWith(".")).filter(he=>h||!y2(he.name)).map(he=>{const at=he.name,it=Lt(he.path||""),Et=it?b2(it)?it:Lt(`${I}/${it}`):Lt(`${I}/${at}`),Dt=he.isDirectory?"directory":"file",Pt=Dt==="file"&&at.includes(".")?at.split(".").pop()?.toLowerCase():void 0;return{name:at,path:Et,type:Dt,extension:Pt}});return x2(we)},[h,p]),Re=c.useCallback(async(I,P,we=!1)=>{if(!r.current||P?.())return;const he=Lt(I.trim());if(!he||!we&&ue.current.has(he))return;const at=qt();return Me.run(he,async it=>{const Et=()=>!it()||qt()!==at;try{const Dt=!h,Pt=i.listDirectory?(await i.listDirectory(he,{respectGitignore:Dt})).entries:await ti.listLocalDirectory(he,{respectGitignore:Dt});if(Et())return;ke.current.set(he,Pt.length);const Ot=fe(he,Pt);ue.current=new Set(ue.current),ue.current.add(he),Se(ms=>{if(!ms[he])return ms;const en={...ms};return delete en[he],en}),Z(ms=>ms[he]&&mx(ms[he],Ot)?ms:{...ms,[he]:Ot})}catch(Dt){if(Et())return;const Pt=Dt instanceof Error?Dt.message:String(Dt??"");console.error("Failed to load sidebar directory:",Dt),Se(Ot=>({...Ot,[he]:Pt}))}},we)},[Me,i,fe,h]),T=c.useCallback(async()=>{if(!l)return;We.current?.abort();const I=new AbortController;We.current=I,Me.clear();try{const we=(us.getState().byRoot[l]?.expandedPaths??[]).map(it=>Lt(it)).filter(it=>!!it&&it!==l&&it.startsWith(`${l}/`)),he=[l,...we];ue.current=new Set(ue.current);for(const it of he)ue.current.delete(it);Se(it=>{if(Object.keys(it).length===0)return it;const Et={...it};let Dt=!1;for(const Pt of he)Pt in Et&&(delete Et[Pt],Dt=!0);return Dt?Et:it});const at=()=>I.signal.aborted;await Re(l,at);for(let it=0;it<we.length&&!I.signal.aborted;it+=3){const Et=we.slice(it,it+3);await Promise.all(Et.map(Dt=>Re(Dt,at)))}}catch(P){if(I.signal.aborted)return;console.error("Failed to refresh sidebar tree:",P)}finally{We.current===I&&(We.current=null)}},[Me,Re,l]),ae=c.useCallback(async I=>{if(!I){await T();return}const P=Lt(I);ue.current=new Set(ue.current),ue.current.delete(P),await Re(P,void 0,!0)},[Re,T]);c.useEffect(()=>{l&&(We.current?.abort(),ue.current=new Set,Me.clear(),Se({}),Z(I=>Object.keys(I).length===0?I:{}),Re(l))},[Me,Re,l,p,h]),c.useEffect(()=>{if(!t||!l||Ne.length===0)return;const I=Ne.map(he=>Lt(he)).filter(he=>!!he&&he!==l&&he.startsWith(`${l}/`)&&!ue.current.has(he)&&!Me.has(he)).sort((he,at)=>he.split("/").length-at.split("/").length);if(I.length===0)return;let P=!1;const we=()=>P;return(async()=>{for(let he=0;he<I.length&&!P;he+=3){const at=I.slice(he,he+3);await Promise.all(at.map(it=>Re(it,we)))}})(),()=>{P=!0}},[Me,Ne,Re,l,t]);const pe=c.useRef(t);c.useEffect(()=>{const I=t&&!pe.current;pe.current=t,I&&T()},[T,t]);const oe=c.useCallback(({directories:I})=>{if(!l)return;const P=new Set((us.getState().byRoot[l]?.expandedPaths??[]).map(Pt=>Lt(Pt))),we=l==="/"?"/":`${l}/`,he=Pt=>{for(let Ot=Pt;Ot!==l;Ot=Lr(Ot))if(!Ot.startsWith(we)||!P.has(Ot))return!1;return!0},at=Pt=>{for(let Ot=Pt;Ot===l||Ot.startsWith(we);Ot=Lr(Ot)){if(ue.current.has(Ot))return Ot;if(Ot===l)break}return null},it=new Set,Et=new Set;for(const Pt of I??ue.current){const Ot=at(Lt(Pt));Ot&&(he(Ot)?it:Et).add(Ot)}Et.size>0&&(ue.current=new Set([...ue.current].filter(Pt=>!Et.has(Pt))));const Dt=[...it].filter(Pt=>(ke.current.get(Pt)??0)<=ip);(async()=>{for(let Pt=0;Pt<Dt.length;Pt+=3)await Promise.all(Dt.slice(Pt,Pt+3).map(Ot=>Re(Ot,void 0,!0)))})()},[Re,l]);ap({root:l,active:t,whileInactive:"drop",onChanges:oe}),c.useEffect(()=>{if(!t)return;if(!e||$){R([]),L(!1);return}const I=y.trim();if(!I){R([]),L(!1);return}let P=!1;return L(!0),x(e,I,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(we=>{if(P)return;const at=we.filter(it=>h||!v2(it.path)).map(it=>({name:it.name,path:Lt(it.path),type:"file",extension:it.extension,relativePath:it.relativePath}));R(at)}).catch(()=>{P||R([])}).finally(()=>{P||L(!1)}),()=>{P=!0}},[$,e,y,x,p,h,t]);const be=c.useMemo(()=>{const I=new Map;if(!w?.files)return I;for(const P of w.files)P.index==="A"||P.working_dir==="?"?I.set(P.path,"git-added"):P.index==="D"?I.set(P.path,"git-deleted"):(P.index==="M"||P.working_dir==="M")&&I.set(P.path,"git-modified");return I},[w]),$e=c.useMemo(()=>{const I=new Map;if(!w?.files||!l)return I;for(const P of w.files){const we=P.index==="M"||P.working_dir==="M",he=P.index==="A"||P.working_dir==="?";if(!we&&!he)continue;const at=P.path.split("/");if(at.length<=1)continue;let it=l;for(let Et=0;Et<at.length-1;Et++){it=`${it}/${at[Et]}`;let Dt=I.get(it);Dt||(Dt={modified:0,added:0},I.set(it,Dt)),we&&Dt.modified++,he&&Dt.added++}}return I},[w,l]),De=c.useCallback(I=>{if(be.size===0)return null;const P=I.startsWith(l+"/")?I.slice(l.length+1):I;return be.get(P)??null},[be,l]),ee=c.useCallback(I=>{if($e.size===0)return null;const P=$e.get(I);return P&&P.modified+P.added>0?P:null},[$e]),le=c.useCallback(async(I,P)=>{if(!l)return;const we=await Va(i,I.path,{directory:l});if(!we.ok){Ha(I.path,we);return}je(l,I.path),_e(l,I.path),g(f,I.path,{preview:!P?.pin&&!K.getState().isMobile})},[_e,i,g,f,l,je]),et=c.useCallback(async(I,P)=>{if(!l)return;const we=await Va(i,I.path,{directory:l});if(!we.ok){Ha(I.path,we);return}je(l,I.path),_e(l,I.path),H({path:I.path,key:cu(I)}),D(f,I.path,I.line,I.column,{preview:!P?.pin&&!K.getState().isMobile})},[_e,i,D,f,l,je]),xe=c.useCallback((I,P)=>{ji(I),Xo(null),I.dataTransfer.setData(ar,P.relativePath),I.dataTransfer.effectAllowed="copy"},[]),bt=c.useCallback((I,P)=>{Ci(I)&&et(P)},[et]),[Tt,vt]=c.useState(null),Rt=c.useCallback(()=>vt(null),[]),Ye=c.useRef(null),ft=hx(Ye,{onSettled:Rt}),Nt=c.useCallback(async I=>{const P=Lt(I);if(!l)return;const we=us.getState().byRoot[l]?.expandedPaths.includes(P)??!1;ft(I,we,()=>{const he=Array.from(Ye.current?.querySelectorAll("[data-tree-disclosure-path]")??[],at=>at.dataset.treeDisclosurePath??"");vt(we?null:he.slice(he.indexOf(I)+1)),tt(l,P)}),ue.current.has(P)||await Re(P)},[Re,l,tt,ft]),{canUpload:ht,uploadingDirectory:Ct,uploadFiles:pt,pickFiles:It,uploadElements:Ht}=lp({root:l,refreshDirectory:ae}),dt=Ct!==null,ct=Ct??U,Mt=c.useCallback((I,P)=>{const we=g2(P);we.length!==0&&(se(null),pt(I,we))},[pt]),Wt=c.useCallback(I=>{if(Xo(I),!I){Q(null),O(null);return}requestAnimationFrame(()=>{pu()?.path===I.path&&Q(I.path)})},[]),Zt=c.useCallback(async(I,P)=>{const we=f2(I,P),he=await Ua(i,{tabs:f,files:l},I.path,we);if(he==="conflict"){Oe.error(o("sidebarFilesTree.toast.nameTaken",{name:we.slice(we.lastIndexOf("/")+1),folder:zn(l,P)}));return}if(he==="failed"){Oe.error(o("sidebarFilesTree.toast.operationFailed"));return}P!==l&&Ke(l,P),await Promise.all([ae(Lr(I.path)),ae(P)]).catch(()=>{})},[Ke,i,f,ae,l,o]),Kt=c.useCallback((I,P)=>{if(K.getState().confirmFileTreeMove){V({source:I,targetDirectory:P});return}Zt(I,P)},[Zt]),ls=c.useCallback(()=>{ne&&(V(null),Zt(ne.source,ne.targetDirectory))},[Zt,ne]),Ut=c.useCallback((I,P)=>!F||uu(I)?null:mu(P,null,l),[F,l]),Qt=c.useCallback(I=>{const P=Qn(I.dataTransfer);if(P){const we=Ut(I,P);if(O(we),!we)return;I.preventDefault(),I.dataTransfer.dropEffect="move";return}!ht||dt||!l||!Nn(I.dataTransfer)||(I.preventDefault(),I.dataTransfer.dropEffect="copy",se(l))},[ht,Ut,dt,l]),cs=c.useCallback(I=>{if(!(I.relatedTarget instanceof Node&&I.currentTarget.contains(I.relatedTarget))){if(Qn(I.dataTransfer)){O(null);return}Nn(I.dataTransfer)&&se(null)}},[]),js=c.useCallback(I=>{const P=Qn(I.dataTransfer);if(P){I.preventDefault(),O(null);const we=Ut(I,P);we&&hu(I.dataTransfer,l,P)&&Kt(P,we);return}!ht||dt||!l||!Nn(I.dataTransfer)||(I.preventDefault(),Mt(l,I.dataTransfer))},[ht,Ut,Mt,Kt,dt,l]),Rs=c.useCallback(async I=>{if(I?.preventDefault(),!He||!M)return;Fe(!0);const P=()=>Fe(!1),we=()=>Ce(null);if(M==="createFile"){if(!G.trim()){Oe.error(o("sidebarFilesTree.toast.filenameRequired")),P();return}if(!i.writeFile){Oe.error(o("sidebarFilesTree.toast.writeNotSupported")),P();return}const he=He.path,at=he?`${he}/`:"",it=Lt(`${at}${G.trim()}`);await i.writeFile(it,"").then(async Et=>{Et.success&&(Oe.success(o("sidebarFilesTree.toast.fileCreated")),await ae(he)),we()}).catch(()=>Oe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(P);return}if(M==="createFolder"){if(!G.trim()){Oe.error(o("sidebarFilesTree.toast.folderNameRequired")),P();return}const he=He.path,at=he?`${he}/`:"",it=Lt(`${at}${G.trim()}`);await i.createDirectory(it).then(async Et=>{Et.success&&(Oe.success(o("sidebarFilesTree.toast.folderCreated")),await ae(he)),we()}).catch(()=>Oe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(P);return}if(M==="rename"){if(!G.trim()){Oe.error(o("sidebarFilesTree.toast.nameRequired")),P();return}if(!i.rename){Oe.error(o("sidebarFilesTree.toast.renameNotSupported")),P();return}const he=He.path,at=he.split("/").slice(0,-1).join("/"),it=at?`${at}/`:"",Et=G.trim(),Dt=Lt(`${it}${Et}`);try{const Pt=await Ua(i,{tabs:f,files:l},he,Dt);Pt==="moved"?(Oe.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await ae(at),we()):Pt==="conflict"?Oe.error(o("sidebarFilesTree.toast.nameTaken",{name:Et,folder:zn(l,at)})):Oe.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Oe.error(o("sidebarFilesTree.toast.operationFailed"))}finally{P()}return}if(M==="delete"){if(!i.delete){Oe.error(o("sidebarFilesTree.toast.deleteNotSupported")),P();return}const he=He.path,at=he.split("/").slice(0,-1).join("/");await i.delete(he).then(async it=>{it.success&&(Oe.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await ae(at),l&&Ie(l,he),(ye===he||ye&&ye.startsWith(he+"/"))&&je(l,null)),we()}).catch(()=>Oe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(P);return}P()},[M,He,G,i,f,ae,Ie,l,ye,je,o]),X=c.useMemo(()=>l?p2({root:l,childrenByDir:ge,expandedPaths:me,loadErrorsByDir:de}):[],[ge,me,de,l]),ot=c.useMemo(()=>new Map(X.flatMap((I,P)=>I.kind==="node"?[[I.node.path,P]]:[])),[X]),[xt,_t]=c.useState(null),[te,Qe]=c.useState(null),gt=c.useCallback(I=>{Ye.current=I,Qe(I)},[]),[wt,At]=c.useState(null),Vt=c.useMemo(()=>[z,wt,...Tt??[]].flatMap(I=>I?[ot.get(I)??-1]:[]),[wt,z,Tt,ot]),ys=c.useCallback(I=>m2(wx(I),Vt,X.length),[Vt,X.length]),[os,Cs]=c.useState(0);c.useLayoutEffect(()=>{if(!xt||!te)return;const I=te.getBoundingClientRect().top-xt.getBoundingClientRect().top+xt.scrollTop;Cs(Math.max(0,Math.round(I)))},[te,xt]);const Ts=c.useRef(null),ds=c.useRef(new Map),ss=c.useRef(null),ps=c.useCallback(I=>{const P=Math.max(0,...ds.current.values());I.style.setProperty("--oc-file-tree-width",`${P}px`)},[]),Qs=c.useCallback((I,P)=>{const we=I.dataset.treeRowPath,he=Ye.current;!we||!he||P<=he.clientWidth+.5||ds.current.get(we)!==P&&(ds.current.set(we,P),ss.current===null&&(ss.current=requestAnimationFrame(()=>{ss.current=null,Ye.current&&ps(Ye.current)})))},[ps]);c.useEffect(()=>()=>{ss.current!==null&&cancelAnimationFrame(ss.current)},[]),c.useLayoutEffect(()=>{if(!te)return;const I=ds.current;for(const he of I.keys())ot.has(he)||I.delete(he);const P=xt?.scrollLeft??0;te.style.removeProperty("--oc-file-tree-width");const we=te.clientWidth;for(const he of te.children){const at=he instanceof HTMLElement?he.dataset.treeRowPath:void 0;if(!at)continue;const it=he.getBoundingClientRect().width;it>we+.5?I.set(at,it):I.delete(at)}ps(te),xt&&(xt.scrollLeft=P)},[te,ot,xt,ps]);const Ks=bx({count:X.length,enabled:xt!==null,getScrollElement:()=>xt,estimateSize:I=>(X[I]?.kind==="node"?Ts.current:null)??h2,measureElement:(I,P,we)=>{const he=yx(I,P,we);return I.dataset.treeRowPath&&(Ts.current=he),P&&Qs(I,P.borderBoxSize?.[0]?.inlineSize??I.getBoundingClientRect().width),he},getItemKey:I=>X[I]?.key??I,overscan:12,scrollMargin:os,rangeExtractor:ys}),xn=I=>{if(I.kind==="error")return n.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:Zc(I.depth)},children:[n.jsx(Gc,{depth:I.depth}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:I.message,children:I.message}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{ae(I.directory)},children:[n.jsx(ce,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFolder")})]})]});const{node:P,depth:we,isExpanded:he}=I,at=P.type==="directory";return n.jsx(T2,{node:P,root:l,isExpanded:he,isActive:ye===P.path,isBrowserClient:u,depth:we,isOpen:!at&&ve.has(P.path),status:at?void 0:De(P.path),badge:at?ee(P.path):void 0,isDropTarget:at&&(ct===P.path||ie===P.path),isDragSource:z===P.path,canUpload:ht&&!dt,canMove:F,permissions:st,downloadFile:i.downloadFile,onSelect:le,onToggle:Nt,onRevealPath:mt,onOpenDialog:Y,onSetDropTarget:se,onDropFiles:Mt,onPickFiles:It,onMoveDragChange:Wt,onSetMoveDropTarget:O,onMoveDrop:Kt,guestActions:d})},ko=c.useCallback(I=>{const P=I.target instanceof Element?I.target.closest("[data-tree-row-path]"):null;At(P?.dataset.treeRowPath??null)},[]),jo=c.useCallback(I=>{I.relatedTarget instanceof Node&&I.currentTarget.contains(I.relatedTarget)||At(null)},[]);c.useEffect(()=>{const I=Be.current;if(!I||!xt||!te)return;const P=ot.get(I);P===void 0||xt.offsetParent===null||(Be.current=null,Ks.scrollToIndex(P,{align:"auto"}))});const vr=!!(l&&ge[l]),Mn=l?de[l]:null,Fn=y.trim().length>0,Co=!_&&!Fn&&A.length===0&&!Mn&&vr&&!!l,Ln=ct?zn(l,ct):"",Sr=ie?zn(l,ie):"",To=ne?ne.source.path.slice(ne.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-t border-edge-muted px-2",children:[n.jsxs("div",{className:"relative min-w-0 flex-1",children:[v?n.jsxs(fn,{children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"absolute inset-s-0.5 top-1/2 inline-flex -translate-y-1/2",children:n.jsx(pn,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"sm",className:"relative size-6 p-0 text-muted-foreground hover:text-foreground","aria-label":o("sidebarFilesTree.search.mode.aria"),children:n.jsx(ce,{name:$?"file-search":"search",className:"size-3.5"})})})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.mode.aria")})]}),n.jsx(mn,{align:"start",side:"bottom",children:n.jsxs(Lc,{value:C,onValueChange:I=>S(I==="contents"?"contents":"names"),children:[n.jsxs(Hr,{value:"names",closeOnClick:!0,className:"items-center",children:[n.jsx(ce,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),n.jsxs(Hr,{value:"contents",closeOnClick:!0,className:"items-center",children:[n.jsx(ce,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):n.jsx(ce,{name:"search",className:"pointer-events-none absolute inset-s-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx(Rn,{ref:E,inputSize:"compact",value:b,onChange:I=>j(I.target.value),placeholder:o($?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Ze("ps-7",$?"pe-14":b.trim().length>0?"pe-7":"pe-2")}),$?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{variant:"chip",size:"xs","aria-pressed":k,onClick:()=>{N(I=>!I),E.current?.focus()},"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-1 top-1/2 h-5 min-w-0 -translate-y-1/2 px-1 font-mono typography-micro",children:".*"})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o(k?"contextTooltips.files.searchPlainText":"sidebarFilesTree.search.regexTitle")})]}):null,b.trim().length>0?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Ze("absolute top-1/2 inline-flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground hover:text-foreground",$?"inset-e-8":"inset-e-2"),onClick:()=>{j(""),E.current?.focus()},children:n.jsx(ce,{name:"close",className:"size-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.clearAria")})]}):null]}),n.jsx(Cg,{className:"shrink-0 gap-0.5",groups:[[(Te||Ae||ht)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:dt?"loader-4":"add",iconClassName:dt?"animate-spin":void 0,menu:n.jsxs(n.Fragment,{children:[Te?n.jsxs($s,{onClick:()=>Y("createFile",{path:e,type:"directory"}),children:[n.jsx(ce,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,Ae?n.jsxs($s,{onClick:()=>Y("createFolder",{path:e,type:"directory"}),children:[n.jsx(ce,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,ht?n.jsxs($s,{disabled:!l||dt,onClick:()=>It(l),children:[n.jsx(ce,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})}]],menuOnly:[{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:h,onSelect:()=>ef(!h)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{T()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{l&&ze(l)}}]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsxs(as,{ref:_t,outerClassName:"h-full min-h-0",className:Ze("@container px-1.5 py-1.5 [overflow-anchor:none]",(ct===l||ie===l)&&"bg-interactive-selection/10"),onDragEnter:Qt,onDragOver:Qt,onDragLeave:cs,onDrop:js,children:[n.jsx("ul",{className:"flex flex-col",children:$&&B.status!=="idle"?n.jsx(u2,{state:B,activeMatchKey:W&&W.path===ye?W.key:null,onOpen:et,onDragStart:xe,onDragEnd:bt}):_?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(ce,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Fn&&A.length===0?n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):A.length>0?A.map(I=>{const P=ye===I.path;return n.jsx("li",{"data-file-tree-path":I.path,children:n.jsxs("button",{type:"button",onClick:()=>le(I),onDoubleClick:()=>le(I,{pin:!0}),draggable:!0,onDragStart:we=>{ji(we),Xo(null);const he=I.relativePath||So(l??"",I.path);!he||he==="."||(we.dataTransfer.setData(ar,he),we.dataTransfer.effectAllowed="copy")},onDragEnd:we=>{Ci(we)&&le(I)},className:Ze("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Zi(P)),title:I.path,children:[n.jsx(mo,{filePath:I.path,extension:I.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`${I.relativePath??I.path}`})]})},I.path)}):Mn?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:Mn}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{T()},children:[n.jsx(ce,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFileList")})]})]}):vr&&l?null:n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),Co?n.jsx("ul",{ref:gt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Ks.getTotalSize()},onFocus:ko,onBlur:jo,children:Ks.getVirtualItems().map(I=>{const P=X[I.index];if(!P)return null;const we=P.kind==="node"?P.node.path:void 0;return n.jsx("li",{ref:Ks.measureElement,"data-index":I.index,"data-tree-row-path":we,"data-tree-disclosure-path":P.kind==="node"?we:`${P.directory}/`,"data-file-tree-path":P.kind==="node"&&P.node.type==="file"?we:void 0,className:Ze("absolute inset-x-0 top-0",P.kind==="node"&&"min-w-max"),style:{transform:`translateY(${I.start-os}px)`},children:xn(P)},I.key)})}):null]}),ct?n.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:[n.jsx(ce,{name:dt?"loader-4":"folder-received",className:Ze("size-4 flex-shrink-0",dt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Ln,children:o(dt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Ln})})]}):ie?n.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:[n.jsx(ce,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Sr,children:o("sidebarFilesTree.drop.moveTarget",{path:Sr})})]}):null]}),Ht,n.jsx(sr,{open:!!M,onOpenChange:I=>!I&&Ce(null),children:n.jsxs(nr,{children:[n.jsxs(rr,{children:[n.jsxs(or,{children:[M==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),M==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),M==="rename"&&o("sidebarFilesTree.dialog.rename.title"),M==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(ir,{children:[M==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:He?.path??o("sidebarFilesTree.dialog.rootFallback")}),M==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:He?.path??o("sidebarFilesTree.dialog.rootFallback")}),M==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:He?.name??""}),M==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:He?.name??""})]})]}),M!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Rn,{value:G,onChange:I=>Ee(I.target.value),placeholder:o(M==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:I=>{I.key==="Enter"&&Rs()},autoFocus:!0})}),n.jsxs(Ur,{children:[n.jsx(ut,{variant:"outline",onClick:()=>Ce(null),disabled:Pe,children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(ut,{variant:M==="delete"?"destructive":"default",onClick:()=>{Rs()},disabled:Pe||M!=="delete"&&!G.trim(),children:Pe?n.jsx(ce,{name:"loader-4",className:"size-4 animate-spin"}):o(M==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(sr,{open:ne!==null,onOpenChange:I=>{I||V(null)},children:n.jsxs(nr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(rr,{children:[n.jsx(or,{children:o("sidebarFilesTree.dialog.move.title")}),n.jsx(ir,{children:ne?o("sidebarFilesTree.dialog.move.description",{name:To,folder:zn(l,ne.targetDirectory)}):null})]}),n.jsxs(Ur,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>q(!re),children:[n.jsx(ni,{checked:!re,onChange:I=>q(!I),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{variant:"ghost",onClick:()=>V(null),children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(ut,{onClick:ls,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function P2(t){return t.runtimeKey}const I2=mr(()=>Ft(()=>import("./WalkthroughView-CYr8y2pi.js"),__vite__mapDeps([213,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,214,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,204,215,216,217,218])).then(t=>({default:t.WalkthroughView}))),R2=mr(()=>Ft(()=>import("./DiffView-B9-zXR21.js"),__vite__mapDeps([219,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,214,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,220,185,196,197,198,199,200,201,202,203,204,205,206,207,208,210,211,215,218])).then(t=>({default:t.DiffView}))),D2=mr(()=>Ft(()=>import("./FilesView-CTKhKCjC.js").then(t=>t.F),__vite__mapDeps([221,5,1,2,3,4,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,222,223,224,225,204,181,182,183,226,227,200,228,186,187,188,189,190,191,192,193,194,195,229,197,230,231,232,201,202,199,211,233,234,210,207,218,203,235])).then(t=>({default:t.FilesView}))),_2=c.lazy(()=>Ft(()=>import("./GuestPanelContent-BY7I-Y-o.js"),__vite__mapDeps([236,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])).then(t=>({default:t.GuestPanelContent}))),vn=(t,e)=>`${t}\0${e}`,A2=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:o}=lt(),i=K(y=>y.contextEditorTreeWidth),a=K(y=>y.setContextEditorTreeWidth),[d,u]=c.useState(!1),l=c.useRef(0),f=c.useRef(i),m=c.useRef(null),p=c.useRef(null),h=c.useRef(null),x=c.useCallback(y=>{const E=h.current;E&&(E.style.width=`${y}px`,E.style.setProperty("--oc-editor-tree-width",`${y}px`))},[]),g=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}p.current=y.pointerId,u(!0),l.current=y.clientX,f.current=i,m.current=i,y.preventDefault()}},w=y=>{if(!d||p.current!==y.pointerId)return;const E=r==="left"?y.clientX-l.current:l.current-y.clientX,A=to(y.currentTarget)?-E:E,R=ei(f.current+A);m.current!==R&&(m.current=R,x(R))},b=y=>{if(p.current!==y.pointerId)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const E=ei(m.current??i);p.current=null,m.current=null,u(!1),a(E)},j=t?i:0;return n.jsxs("div",{ref:h,className:Ze("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${d?m.current??j:j}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${d?m.current??i:i}px`,overflowX:"clip",transitionProperty:d?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:Ze("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:Ze("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",d&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:w,onPointerUp:b,onPointerCancel:b,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:Ze("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(N2,{visible:t&&e})})]})},an=t=>{const e=Ue.c(12),{zone:s,isOpen:r,interactive:o,hidden:i,className:a,children:d}=t,u=!r||i;let l;e[0]!==d||e[1]!==u?(l=n.jsx(Xc,{paused:u,children:d}),e[0]=d,e[1]=u,e[2]=l):l=e[2];let f;e[3]!==o||e[4]!==l?(f=n.jsx(Hc.Provider,{value:!0,children:n.jsx(up.Provider,{value:o,children:l})}),e[3]=o,e[4]=l,e[5]=f):f=e[5];let m;e[6]!==a||e[7]!==f?(m=n.jsx("div",{className:a,children:f}),e[6]=a,e[7]=f,e[8]=m):m=e[8];let p;return e[9]!==m||e[10]!==s?(p=n.jsx(i2,{zone:s,children:m}),e[9]=m,e[10]=s,e[11]=p):p=e[11],p},O2=()=>{const{t}=lt(),e=Hs()??"",s=c.useMemo(()=>e?rs(e):"",[e]),r=K(M=>s?M.contextPanelByDirectory[s]:void 0),o=wr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,d=co(o,e)??"",u=K(M=>M.contextSurfaceZones),l=K(M=>M.contextPanelByDirectory),f=K(M=>M.closeContextPanelTab),m=K(M=>M.closeContextFile),p=K(M=>M.openContextPanelTab),h=K(M=>M.openAgentBrowserTab),x=K(M=>M.openContextFile),g=K(M=>M.contextEditorTreeVisible),w=K(M=>M.contextEditorVisible),b=K(M=>M.fileTreeSide),j=us(M=>M.setSelectedPath),y=dr(M=>M.headerSlot),E=c.useMemo(()=>r?.tabs??[],[r?.tabs]),A=_r(M=>M.chatCovered),R=c.useMemo(()=>{const M=Ce=>{const He=r?$r(r,u,Ce):null,Xe=Ce==="bottom"&&A;return{activeTab:He,isOpen:!!(r&&er(r,Ce).isOpen&&He)&&!Xe}};return{left:M("left"),right:M("right"),bottom:M("bottom")}},[A,r,u]),_={left:{...R.left,activeTab:Ar(R.left.activeTab,R.left.isOpen)},right:{...R.right,activeTab:Ar(R.right.activeTab,R.right.isOpen)},bottom:{...R.bottom,activeTab:Ar(R.bottom.activeTab,R.bottom.isOpen)}},L={left:qo(_.left.isOpen),right:qo(_.right.isOpen),bottom:qo(_.bottom.isOpen)},v=M=>!L[M],C={left:Xn(_.left.isOpen),right:Xn(_.right.isOpen),bottom:Xn(_.bottom.isOpen)},S={left:Ir(_.left.isOpen,C.left,_.left.activeTab?.mode),right:Ir(_.right.isOpen,C.right,_.right.activeTab?.mode),bottom:Ir(_.bottom.isOpen,C.bottom,_.bottom.activeTab?.mode)},k=M=>{const Ce=si(u,M);return{zone:Ce,..._[Ce]}},N=k("file"),$=k("chat"),B=k("browser"),D=k("diff"),W=k("terminal"),H=k("walkthrough"),[U,se]=c.useState([]),z=c.useCallback((M,Ce)=>{se(He=>tf(He,vn(M,Ce)))},[]),Q=K(M=>M.liveBrowserTabLimit);c.useEffect(()=>P0((M,Ce)=>{const He=Ce.directory?rs(Ce.directory):s;if(!He)return null;const Xe=h(He,M,Ce.sessionId);return Xe&&z(He,Xe),Xe}),[s,h,z]),c.useEffect(()=>I0((M,Ce)=>K.getState().contextPanelByDirectory[M]?.tabs?.some(Xe=>Xe.id===Ce&&Xe.mode==="browser")?(f(M,Ce),!0):!1),[f]),c.useEffect(()=>_n(M=>{if(M.type!=="file-open-request")return;const Ce=M.directory??e;Ce&&x(Ce,M.path)}),[e,x]),c.useEffect(()=>_n(M=>{if(M.type!=="plan-open-request")return;const Ce=M.directory??e,He=Tg(Ce,M.projectId);!Ce||!He||K.getState().openProjectKnowledgePlan(Ce,Ng(He),M.planId)}),[e]);const ie=R[B.zone].activeTab,O=ie?.mode==="browser"?ie.id:null;c.useEffect(()=>{E0(s,O)},[s,O]);const ne=R[N.zone].activeTab;c.useEffect(()=>{if(!d||ne?.mode!=="file"||!ne.targetPath)return;const M=bs(ne.targetPath)===bs(d);j(rs(d),ne.targetPath,{allowOutsideRoot:!o&&M})},[d,o,ne,j]);const V=c.useMemo(()=>E.some(M=>M.mode==="file"&&M.targetPath),[E]),J=c.useMemo(()=>E.some(M=>M.mode==="file"),[E]),F=V&&(w||!g),re=N.activeTab?.mode==="file",q=c.useCallback(M=>{s&&m(s,M)},[m,s]),ge=$.isOpen&&$.activeTab?.mode==="chat"?$.activeTab:null,Z=ge?bo(ge.dedupeKey):null,de=c.useMemo(()=>(ge?.targetDirectory?rs(ge.targetDirectory):"")||s||null,[ge?.targetDirectory,s]),Se=c.useMemo(()=>Z?{sessionId:Z,directory:de}:null,[Z,de]);c.useEffect(()=>{if(!de||!Z||typeof window>"u")return;const M=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Oo(de,Z,!1);return}Yc(Z),Oo(de,Z,!0)};M();const Ce=window.setInterval(M,1e4);return window.addEventListener("focus",M),window.addEventListener("blur",M),document.addEventListener("visibilitychange",M),()=>{window.clearInterval(Ce),window.removeEventListener("focus",M),window.removeEventListener("blur",M),document.removeEventListener("visibilitychange",M),Oo(de,Z,!1)}},[de,Z]);const ue=D.activeTab,ke=c.useCallback(M=>{!s||ue?.mode!=="diff"||p(s,{mode:"diff",targetPath:ue.targetPath,targetDirectory:ue.targetDirectory,stagedDiff:M==="staged",diffScope:M})},[ue,s,p]),Me=B.isOpen&&B.activeTab?.mode==="browser"?B.activeTab.id:null;c.useEffect(()=>{Me&&s&&z(s,Me)},[s,Me,z]);const{loadedBrowserTabs:We,sleepingBrowserTabs:Le}=c.useMemo(()=>{const M=new Set(U),Ce=new Set;for(const[Ee,Pe]of Object.entries(l))for(const Fe of Pe.tabs)Fe.mode==="browser"&&Fe.ownerSessionId===null&&Ce.add(vn(Ee,Fe.id));const He=sf(U,Ce,Q),Xe=[],G=[];for(const[Ee,Pe]of Object.entries(l)){const Fe=Ee===s;for(const Te of Pe.tabs){if(Te.mode!=="browser")continue;const Ae=vn(Ee,Te.id),qe=Te.ownerSessionId===null,Ge=Fe&&Te.id===Me||(qe?He.has(Ae):M.has(Ae));if(!Ge&&!Fe&&qe)continue;const Je={directory:Ee,id:Te.id,targetPath:Te.targetPath,ownerSessionId:Te.ownerSessionId};(Ge?Xe:G).push(Je)}}return Xe.sort((Ee,Pe)=>vn(Ee.directory,Ee.id)<vn(Pe.directory,Pe.id)?-1:1),{loadedBrowserTabs:Xe,sleepingBrowserTabs:G}},[l,s,Q,U,Me]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const M=Le.map(Ce=>N0({tabId:Ce.id,directory:Ce.directory,ownerSessionId:Ce.ownerSessionId,describe:()=>({title:"",url:Ce.targetPath??""}),wake:()=>z(Ce.directory,Ce.id)}));return()=>M.forEach(Ce=>Ce())},[Le,z]);const Ve=c.useMemo(()=>E.filter(M=>M.mode==="diff"),[E]),Ne=c.useMemo(()=>E.find(M=>M.mode==="terminal")??null,[E]),me=c.useMemo(()=>E.find(M=>M.mode==="walkthrough")??null,[E]),ye=c.useMemo(()=>E.filter(M=>Pn(M.mode)),[E]),je=tr(M=>M.guests),Be=c.useMemo(()=>new Set(je.filter(Eg).map(M=>M.id)),[je]),_e=c.useMemo(()=>{const M=new Map;for(const Ce of je){const He=Pg(Ce);He&&M.set(Ce.id,He)}return M},[je]),Ie=W.zone,tt=c.useCallback(M=>{const Ce=ta({mode:"terminal",label:t("layout.mainTab.terminal"),from:Ie},M);return{finish:()=>Ce.finish(s),cancel:Ce.cancel}},[s,t,Ie]),Ke=(M,Ce)=>Ce?y[M]:null,[ze,rt]=c.useState(()=>new Set),ve=ye.filter(M=>{if(ze.has(M.id))return!1;const Ce=k(M.mode);return Ce.isOpen&&Ce.activeTab?.id===M.id});return ve.length>0&&rt(new Set([...ze,...ve.map(M=>M.id)])),n.jsxs(n.Fragment,{children:[J?n.jsxs(an,{zone:N.zone,interactive:S[N.zone],isOpen:N.isOpen,hidden:v(N.zone),className:Ze("absolute inset-0 flex",b==="left"&&"flex-row-reverse",re?"flex":"hidden"),children:[i?n.jsx("div",{className:"h-full min-w-0 flex-1",children:n.jsx(Rr,{})}):V||!g?n.jsx("div",{className:Ze("h-full min-w-0 flex-1",V&&!F&&"hidden"),children:V?n.jsx(c.Suspense,{fallback:null,children:n.jsx(D2,{mode:"editor-only",visible:!v(N.zone)&&re&&F,onCloseFile:q})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(ce,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,i?null:n.jsx(A2,{visible:g,active:N.isOpen&&re,fill:!F,side:b})]}):null,ge&&Z&&Se?n.jsx(an,{zone:$.zone,interactive:S[$.zone],isOpen:$.isOpen,hidden:v($.zone),className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:Z}),className:"h-full",children:n.jsx(yc,{pinnedSession:Se,readOnly:ge.readOnly})})},ge.id):null,We.map(M=>{const Ce=M.directory===s&&B.activeTab?.id===M.id,He=M.directory===s?a??M.directory:M.directory;return n.jsx(an,{zone:B.zone,interactive:S[B.zone],isOpen:B.isOpen,hidden:v(B.zone),className:Ze("absolute inset-0",!Ce&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!Ce||void 0,children:n.jsx(Xc,{paused:!Ce,children:M.directory===s&&i?n.jsx(Rr,{}):n.jsx(t2,{initialUrl:M.targetPath??"",directory:M.directory,siteDirectory:He,tabID:M.id,ownerSessionId:M.ownerSessionId,visible:Ce&&B.isOpen},He)})})},vn(M.directory,M.id))}),Ve.map(M=>{const Ce=D.activeTab?.id===M.id;return n.jsx(an,{zone:D.zone,interactive:S[D.zone],isOpen:D.isOpen,hidden:v(D.zone),className:Ze("absolute inset-0",!Ce&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(cn,{value:Ke(D.zone,Ce),children:i&&!M.targetDirectory?n.jsx(Rr,{}):n.jsx(R2,{directory:M.targetDirectory??a,visible:D.isOpen&&Ce,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:M.diffScope??(M.stagedDiff?"staged":null),onDiffScopeChange:ke,targetFilePath:M.targetPath,flushContent:!0})})})},M.id)}),Ne?n.jsx(an,{zone:W.zone,interactive:S[W.zone],isOpen:W.isOpen,hidden:v(W.zone),className:Ze("absolute inset-0",W.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(cn,{value:Ke(W.zone,W.activeTab?.mode==="terminal"),children:n.jsx(cp.Provider,{value:tt,children:n.jsx(dp,{visible:W.isOpen&&W.activeTab?.mode==="terminal",directory:Ne.targetDirectory,onLastTabClosed:()=>{s&&f(s,Ne.id)}})})})}):null,me?n.jsx(an,{zone:H.zone,interactive:S[H.zone],isOpen:H.isOpen,hidden:v(H.zone),className:Ze("absolute inset-0",H.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(cn,{value:Ke(H.zone,H.activeTab?.mode==="walkthrough"),children:n.jsx(I2,{directory:me.targetDirectory??e,visible:H.isOpen&&H.activeTab?.mode==="walkthrough"})})})}):null,ye.map(M=>{if(!Pn(M.mode))return null;const Ce=k(M.mode);if(!ze.has(M.id))return null;const He=zr(M.mode),Xe=Be.has(He),G=_e.get(He),Ee=Ce.activeTab?.id===M.id,Pe=Ee&&Ce.isOpen;return Xe&&!G&&!Pe?null:n.jsx(an,{zone:Ce.zone,interactive:S[Ce.zone],isOpen:Ce.isOpen,hidden:v(Ce.zone),className:Ze("absolute inset-0",Ee?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(_2,{mode:M.mode,sharedSurface:Xe,docking:G??null,surfaceMounted:Pe})})},M.id)})]})},M2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},F2=()=>{const t=Ue.c(20),{t:e}=lt(),s=Vs(L2),r=Vs(B2),o=c.useRef(null),[i,a]=c.useState(!1);let d,u;t[0]!==s?(d=()=>{if(!s){a(!1);return}const b=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(b)},u=[s],t[0]=s,t[1]=d,t[2]=u):(d=t[1],u=t[2]),c.useEffect(d,u);let l,f;if(t[3]!==s?(l=()=>{if(!s)return;const b=j=>{const y=o.current;y&&(y.style.transform=`translate(${j.clientX+12}px, ${j.clientY+12}px)`)};return window.addEventListener("pointermove",b),()=>window.removeEventListener("pointermove",b)},f=[s],t[3]=s,t[4]=l,t[5]=f):(l=t[4],f=t[5]),c.useEffect(l,f),!s)return null;const m=i?"opacity-100":"opacity-0";let p;t[6]!==m?(p=Ze("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",m),t[6]=m,t[7]=p):p=t[7];let h;t[8]!==p?(h=n.jsx("div",{className:p}),t[8]=p,t[9]=h):h=t[9];let x;t[10]!==s.frames||t[11]!==r||t[12]!==e?(x=Ri.map(b=>{const j=s.frames[b];if(j.width<=0||j.height<=0)return null;const y=r===b;return n.jsx("div",{className:Ze("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:j.left,top:j.top,width:j.width,height:j.height},children:n.jsx("span",{className:"typography-ui-label",children:e(M2[b])})},b)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==s.label?(g=n.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:s.label}),t[14]=s.label,t[15]=g):g=t[15];let w;return t[16]!==h||t[17]!==x||t[18]!==g?(w=Gl.createPortal(n.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]=w):w=t[19],w};function L2(t){return t.drag}function B2(t){return t.hovered}const Rl=320,$2=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let i=t-e-s;if(i>=Rl)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Rl)return{collapseSidebar:a,displace:null};const d=o==="left"?"right":"left";return{collapseSidebar:a,displace:(d==="left"?e:s)>0?d:null}},z2=({directoryKey:t,folded:e,readRowWidth:s})=>{const r=w=>{const b=w.contextPanelByDirectory[t];return{left:Kn(b,w.contextSurfaceZones,"left"),right:Kn(b,w.contextSurfaceZones,"right")}},o=(w,b,j)=>{const y=w.contextPanelByDirectory[t];return(j&&y?$r(y,w.contextSurfaceZones,b):null)?w.contextZoneSizes[b]??Ii:0},i=w=>{const b=w.contextPanelByDirectory[t];return b?Ri.some(j=>er(b,j).expanded&&nf(b,w,j)):!1};let a=null,d=!1,u=r(K.getState()),l=i(K.getState());const f=w=>{e.current=w,K.getState().setSidebarFoldedForExpandedZone(w==="expanded")},m=w=>{d=!0,K.getState().setSidebarOpen(w),d=!1},p=()=>{f(null),K.getState().isSidebarOpen||m(!0)};!e.current&&K.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?l:u[h])&&p(),!e.current&&l&&K.getState().isSidebarOpen&&(f("expanded"),m(!1));const x=(w,b,j)=>{const y=s();if(!y)return;const E=e.current==="expanded",A=$2({rowWidth:E?y-w.sidebarWidth:y,leftWidth:o(w,"left",j.left),rightWidth:o(w,"right",j.right),sidebarWidth:w.isSidebarOpen||E?w.sidebarWidth:null,opening:b});if(A.displace){const R=er(w.contextPanelByDirectory[t],A.displace).activeTabId;R&&(a={side:A.displace,by:b,tabId:R})}A.collapseSidebar&&(f(b),w.isSidebarOpen&&m(!1)),A.displace&&w.closeContextZone(t,A.displace)},g=w=>{if(a?.side===w){e.current===w&&f(a.by);return}const b=a?.by===w?a:null;b&&(a=null),e.current===w&&(b?f(b.side):p()),b&&K.getState().setActiveContextPanelTab(t,b.tabId)};return K.subscribe((w,b)=>{w.isSidebarOpen!==b.isSidebarOpen&&!d&&f(null);const j=r(w),y=i(w),E=u,A=l;u=j,l=y;const R=["left","right"],_=R.filter(v=>j[v]&&!E[v]),L=R.filter(v=>!j[v]&&E[v]);for(const v of L){const C=v==="left"?"right":"left";_.includes(C)&&(e.current===v&&f(C),a?.by===v&&(a=null))}for(const v of L)g(v);for(const v of _)x(w,v,j);y&&!A&&w.isSidebarOpen?(f("expanded"),m(!1)):!y&&A&&e.current==="expanded"&&p()})},W2=()=>{const t=Ue.c(5),e=Hs();let s;t[0]!==e?(s=e?rs(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=c.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return z2({directoryKey:r,folded:o,readRowWidth:U2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),c.useEffect(i,a),null};function U2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const V2=t=>{const e=Ue.c(54),{open:s,onOpenChange:r}=t,{t:o}=lt(),i=K(H2),a=K(K2),d=K(q2),u=K(G2),l=K(Z2),f=qi(),m=K(Ig);let p;if(e[0]!==i||e[1]!==f||e[2]!==m){let U;e[4]!==m?(U=se=>m||se.id!=="workflows",e[4]=m,e[5]=U):U=e[5],p=ri(i,f).filter(U),e[0]=i,e[1]=f,e[2]=m,e[3]=p}else p=e[3];const h=p,x=d.length===0;let g;if(e[6]!==d||e[7]!==h){let U;e[9]!==d?(U=se=>d.includes(se.id),e[9]=d,e[10]=U):U=e[10],g=h.every(U),e[6]=d,e[7]=h,e[8]=g}else g=e[8];const w=g,b=c.useRef(!1);let j;e[11]!==d||e[12]!==h||e[13]!==o?(j=h.map((U,se)=>({id:U.id,label:U.label??o(U.labelKey),visible:!d.includes(U.id),groupStart:se>0&&Gs(h[se-1])!==Gs(U)})),e[11]=d,e[12]=h,e[13]=o,e[14]=j):j=e[14];const y=j;let E;e[15]!==i||e[16]!==f||e[17]!==a?(E=U=>{const se=ri(U,f).map(X2).filter(Q=>U.includes(Q)),z=new Set(se);a([...se,...i.filter(Q=>!z.has(Q))])},e[15]=i,e[16]=f,e[17]=a,e[18]=E):E=e[18];const A=E;let R;e[19]!==r?(R=(U,se)=>{if(!U&&se.reason==="escape-key"&&b.current){se.cancel(),se.allowPropagation();return}b.current=!1,r(U)},e[19]=r,e[20]=R):R=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=U=>{b.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(U.key)&&U.preventBaseUIHandler()},e[21]=_):_=e[21];let L;e[22]!==o?(L=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=L):L=e[23];let v;e[24]!==L?(v=n.jsx(or,{children:L}),e[24]=L,e[25]=v):v=e[25];let C;e[26]!==o?(C=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=C):C=e[27];let S;e[28]!==C?(S=n.jsx(ir,{children:C}),e[28]=C,e[29]=S):S=e[29];let k;e[30]!==S||e[31]!==v?(k=n.jsxs(rr,{children:[v,S]}),e[30]=S,e[31]=v,e[32]=k):k=e[32];let N;e[33]!==o?(N=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=N):N=e[34];let $;e[35]===Symbol.for("react.memo_cache_sentinel")?($=U=>{b.current=U},e[35]=$):$=e[35];let B;e[36]!==A||e[37]!==y||e[38]!==u||e[39]!==N?(B=n.jsx(fp,{items:y,onVisibleChange:u,onReorder:A,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:N,onDraggingChange:$}),e[36]=A,e[37]=y,e[38]=u,e[39]=N,e[40]=B):B=e[40];let D;e[41]!==x||e[42]!==w||e[43]!==l||e[44]!==o?(D=x?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[w?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(ut,{variant:"link",size:"xs",onClick:()=>l([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=w,e[43]=l,e[44]=o,e[45]=D):D=e[45];let W;e[46]!==k||e[47]!==B||e[48]!==D?(W=n.jsxs(nr,{className:"max-w-md",onKeyDown:_,children:[k,B,D]}),e[46]=k,e[47]=B,e[48]=D,e[49]=W):W=e[49];let H;return e[50]!==s||e[51]!==W||e[52]!==R?(H=n.jsx(sr,{open:s,onOpenChange:R,children:W}),e[50]=s,e[51]=W,e[52]=R,e[53]=H):H=e[53],H};function H2(t){return t.contextRailOrder}function K2(t){return t.setContextRailOrder}function q2(t){return t.contextRailHiddenSurfaces}function G2(t){return t.setContextRailSurfaceVisible}function Z2(t){return t.setContextRailHiddenSurfaces}function X2(t){return t.id}const gu=150,Y2=500,J2=[],Q2=t=>{const e=Ue.c(69),{surface:s,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:d,badgeAriaLabel:u,badgeDescription:l,orderNumber:f,showOrderNumber:m,onSelect:p}=t,h=K(sk);let x;e[0]!==h?(x=Oi("switch_context_surface",h),e[0]=h,e[1]=x):x=e[1];const g=x;let w;e[2]!==f||e[3]!==g?(w=g&&g!==Sc&&f!=null&&f<=10?ws(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=w):w=e[4];const b=w;let j;e[5]!==s.id?(j={id:s.id},e[5]=s.id,e[6]=j):j=e[6];const{attributes:y,listeners:E,setNodeRef:A,transform:R,transition:_,isDragging:L}=xd(j),v=d!=null&&d>0;let C;e[7]!==R?(C=wd.Translate.toString(R),e[7]=R,e[8]=C):C=e[8];let S;e[9]!==C||e[10]!==_?(S={transform:C,transition:_},e[9]=C,e[10]=_,e[11]=S):S=e[11];const k=L&&"z-10 opacity-70";let N;e[12]!==k?(N=Ze("relative",k),e[12]=k,e[13]=N):N=e[13];let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("div",{}),e[14]=$):$=e[14];let B;e[15]!==p||e[16]!==s?(B=()=>p(s),e[15]=p,e[16]=s,e[17]=B):B=e[17];const D=u??i,W=s.id,H=r?"oc-selected text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground";let U;e[18]!==H?(U=Ze("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",H),e[18]=H,e[19]=U):U=e[19];let se;e[20]!==s.icon||e[21]!==s.iconSrc?(se=n.jsx(Gi,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=s.icon,e[21]=s.iconSrc,e[22]=se):se=e[22];let z;e[23]!==v||e[24]!==f||e[25]!==o||e[26]!==m?(z=m&&f!=null?n.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}):v?n.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?n.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[23]=v,e[24]=f,e[25]=o,e[26]=m,e[27]=z):z=e[27];let Q;e[28]!==y||e[29]!==r||e[30]!==E||e[31]!==s.id||e[32]!==D||e[33]!==U||e[34]!==se||e[35]!==z||e[36]!==B?(Q=n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",...y,...E,onClick:B,"aria-label":D,"aria-pressed":r,"data-context-surface":W,className:U,children:[se,z]})}),e[28]=y,e[29]=r,e[30]=E,e[31]=s.id,e[32]=D,e[33]=U,e[34]=se,e[35]=z,e[36]=B,e[37]=Q):Q=e[37];let ie;e[38]!==h||e[39]!==s.id||e[40]!==b?(ie=s.id==="terminal"?ws(Ws("toggle_terminal",h),""):b,e[38]=h,e[39]=s.id,e[40]=b,e[41]=ie):ie=e[41];let O;e[42]!==i||e[43]!==ie?(O=n.jsx(Us,{label:i,shortcut:ie}),e[42]=i,e[43]=ie,e[44]=O):O=e[44];let ne;e[45]!==a?(ne=n.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[45]=a,e[46]=ne):ne=e[46];let V;e[47]!==l?(V=l?n.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null,e[47]=l,e[48]=V):V=e[48];let J;e[49]!==s.id?(J=s.id==="context"?n.jsx(Sd,{}):null,e[49]=s.id,e[50]=J):J=e[50];let F;e[51]!==O||e[52]!==ne||e[53]!==V||e[54]!==J?(F=n.jsx(jt,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[O,ne,V,J]})}),e[51]=O,e[52]=ne,e[53]=V,e[54]=J,e[55]=F):F=e[55];let re;e[56]!==Q||e[57]!==F?(re=n.jsx(ao,{render:$,children:n.jsxs(kt,{delayDuration:gu,children:[Q,F]})}),e[56]=Q,e[57]=F,e[58]=re):re=e[58];let q;e[59]!==s.mode?(q=n.jsx(br,{children:n.jsx(bc,{mode:s.mode})}),e[59]=s.mode,e[60]=q):q=e[60];let ge;e[61]!==re||e[62]!==q?(ge=n.jsxs(xr,{children:[re,q]}),e[61]=re,e[62]=q,e[63]=ge):ge=e[63];let Z;return e[64]!==A||e[65]!==ge||e[66]!==S||e[67]!==N?(Z=n.jsx("div",{ref:A,style:S,className:N,children:ge}),e[64]=A,e[65]=ge,e[66]=S,e[67]=N,e[68]=Z):Z=e[68],Z},ek=t=>{if(!t)return{icon:"ticket-2"};const e=Og(t,"line");return e?{icon:e}:{icon:Mg,iconSrc:Fg(t)}},tk=()=>{const t=Ue.c(122),{t:e}=lt(),s=Hs();let r;t[0]!==s?(r=s?rs(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=De=>o?De.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=K(i),d=K(nk),u=K(rk),l=K(ok),f=K(ik),m=K(ak),p=K(lk),h=K(ck),x=K(dk),g=rf();let w;t[4]!==g?(w=De=>g.some(ee=>ee.instances.defaultInstance!==null&&De.entries[Un({provider:ee.id,instance:ee.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=w):w=t[5];const b=un(w),j=un(fk),y=Rg(o||null),E=Pi(y==="none"?null:y??g[0]?.id),A=y==="none"?"pullRequest":E.terminology.changeRequest,{screenWidth:R}=hn(),_=wr(),L=s??null;let v;t[6]!==_||t[7]!==L?(v=co(_,L),t[6]=_,t[7]=L,t[8]=v):v=t[8];const C=v,S=Dg(C),k=fo(S),{git:N}=ks(),$=Dn(pk),B=Dn(mk);let D,W;t[9]!==$||t[10]!==B||t[11]!==N||t[12]!==S||t[13]!==C?(D=()=>{if(!N||!C||!S||S===C)return;da(()=>$(S,N));const De=Jt(C),ee=Jt(S);return lr.onGitRefreshHint(le=>{const et=Jt(le.directory);et!==De&&et!==ee||da(()=>B(S,N,{silent:!0}))})},W=[$,B,N,S,C],t[9]=$,t[10]=B,t[11]=N,t[12]=S,t[13]=C,t[14]=D,t[15]=W):(D=t[14],W=t[15]),c.useEffect(D,W);let H;t[16]!==x?(H=Oi("switch_context_surface",x),t[16]=x,t[17]=H):H=t[17];const U=H,[se,z]=c.useState(!1);let Q,ie;t[18]!==U?(ie=()=>{const De=new Set;let ee=null,le=!1;const et=hk,xe=()=>{Aa(U,De)?!le&&ee===null&&(ee=setTimeout(()=>z(!0),Y2)):(le=!1,ee!==null&&(clearTimeout(ee),ee=null),z(!1))},bt=Rt=>{if(De.add(Rt.key.toLowerCase()),et(Rt.key)&&Aa(U,De)){le=!0,ee!==null&&(clearTimeout(ee),ee=null),z(!1);return}xe()},Tt=Rt=>{De.delete(Rt.key.toLowerCase()),xe()},vt=()=>{De.clear(),le=!1,ee!==null&&(clearTimeout(ee),ee=null),z(!1)};return window.addEventListener("keydown",bt,!0),window.addEventListener("keyup",Tt,!0),window.addEventListener("blur",vt),()=>{window.removeEventListener("keydown",bt,!0),window.removeEventListener("keyup",Tt,!0),window.removeEventListener("blur",vt),ee!==null&&clearTimeout(ee)}},Q=[U],t[18]=U,t[19]=Q,t[20]=ie):(Q=t[19],ie=t[20]),c.useEffect(ie,Q);let O;t[21]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{distance:8}},t[21]=O):O=t[21];let ne;t[22]===Symbol.for("react.memo_cache_sentinel")?(ne={activationConstraint:{delay:200,tolerance:6}},t[22]=ne):ne=t[22];const V=pd(Kr(hd,O),Kr(md,ne)),J=qi(),F=_a(gk),re=_a(xk),q=a?.tabs??J2,ge=_g(q,s||null);let Z;t[23]!==h||t[24]!==a?(Z=Ei(a,h),t[23]=h,t[24]=a,t[25]=Z):Z=t[25];const de=Z,Se=k?.files.length??0;let ue;if(t[26]!==l||t[27]!==u||t[28]!==J||t[29]!==y||t[30]!==R||t[31]!==j||t[32]!==q||t[33]!==E||t[34]!==ge){let De;t[36]!==y||t[37]!==E?(De=ee=>ee.id==="pr"?{...ee,...ek(y==="none"?null:E)}:ee,t[36]=y,t[37]=E,t[38]=De):De=t[38],ue=Ag({railOrder:u,hiddenSurfaces:l,isVSCode:pr(),screenWidth:R,tabs:q,sourceControlConnected:j,workflowsShown:ge,extras:J}).map(De),t[26]=l,t[27]=u,t[28]=J,t[29]=y,t[30]=R,t[31]=j,t[32]=q,t[33]=E,t[34]=ge,t[35]=ue}else ue=t[35];const ke=ue;let Me;t[39]!==q?(Me=q.some(bk),t[39]=q,t[40]=Me):Me=t[40];const We=Me;let Le,Ve;t[41]!==p||t[42]!==h||t[43]!==b||t[44]!==o||t[45]!==We||t[46]!==de||t[47]!==j?(Le=()=>{!o||!b||j||We||!de.has("pr")||p(o,si(h,"pr"))},Ve=[p,h,o,b,We,de,j],t[41]=p,t[42]=h,t[43]=b,t[44]=o,t[45]=We,t[46]=de,t[47]=j,t[48]=Le,t[49]=Ve):(Le=t[48],Ve=t[49]),c.useEffect(Le,Ve);const[Ne,me]=c.useState(!1),ye=c.useRef(null),je=c.useRef(null);let Be;t[50]!==A||t[51]!==ke||t[52]!==e?(Be=De=>{const ee=ke.find(et=>et.id===De.active.id),le=ye.current?.getBoundingClientRect().left;!ee||le===void 0||(je.current?.cancel(),je.current=ta({mode:ee.mode,label:ee.label??e(Ls(ee.labelKey,A)),from:si(K.getState().contextSurfaceZones,ee.mode)},et=>et.x<le-16))},t[50]=A,t[51]=ke,t[52]=e,t[53]=Be):Be=t[53];const _e=Be;let Ie;t[54]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>{je.current?.cancel(),je.current=null},t[54]=Ie):Ie=t[54];const tt=Ie;let Ke,ze;t[55]===Symbol.for("react.memo_cache_sentinel")?(Ke=()=>()=>je.current?.cancel(),ze=[],t[55]=Ke,t[56]=ze):(Ke=t[55],ze=t[56]),c.useEffect(Ke,ze);let rt;t[57]!==o||t[58]!==J||t[59]!==f?(rt=De=>{const ee=je.current;if(je.current=null,ee?.finish(o))return;const{active:le,over:et}=De;if(!et||le.id===et.id)return;const xe=ri(K.getState().contextRailOrder,J),bt=Ye=>{const ft=xe.find(Nt=>Nt.id===Ye);return ft?Gs(ft):null};if(bt(le.id)!==bt(et.id))return;const Tt=xe.map(wk),vt=Tt.indexOf(le.id),Rt=Tt.indexOf(et.id);vt===-1||Rt===-1||f(cx(Tt,vt,Rt))},t[57]=o,t[58]=J,t[59]=f,t[60]=rt):rt=t[60];const ve=rt;let M;if(t[61]!==ke){M=[];for(const De of ke){const ee=M.at(-1);ee&&Gs(ee[0])===Gs(De)?ee.push(De):M.push([De])}t[61]=ke,t[62]=M}else M=t[62];const Ce=M;let He;t[63]!==ke?(He=De=>{const ee=ke.find(et=>et.id===De.active.id);if(!ee)return li(De);const le=Gs(ee);return li({...De,droppableContainers:De.droppableContainers.filter(et=>{const xe=ke.find(bt=>bt.id===et.id);return xe!==void 0&&Gs(xe)===le})})},t[63]=ke,t[64]=He):He=t[64];const Xe=He;if(!o)return null;let G,Ee,Pe,Fe,Te,Ae,qe,Ge,Je,st;if(t[65]!==A||t[66]!==Se||t[67]!==re||t[68]!==Xe||t[69]!==o||t[70]!==Ce||t[71]!==F||t[72]!==ve||t[73]!==_e||t[74]!==m||t[75]!==se||t[76]!==V||t[77]!==de||t[78]!==e||t[79]!==d){let De=0;Ge=ye,t[90]!==e?(Je=e("contextRail.aria.rail"),t[90]=e,t[91]=Je):Je=t[91],st="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",G=gd,Ee=V,Pe=Xe,Fe=_e,Te=tt,Ae=ve,qe=Ce.map((ee,le)=>n.jsxs(c.Fragment,{children:[le>0?n.jsx("div",{"aria-hidden":"true",className:"h-1.5 shrink-0"}):null,n.jsx(bd,{items:ee.map(yk),strategy:lx,children:ee.map(et=>{De=De+1;const xe=et.label??e(Ls(et.labelKey,A)),bt=et.id==="git"&&!d?Se:0,Tt=Pn(et.mode)&&!de.has(et.mode)?F[zr(et.mode)]??0:0,vt=bt>0?bt:Tt>0?Tt:null,Rt=vt!==null&&bt===0;return n.jsx(Q2,{surface:et,isActive:de.has(et.mode),showActivityDot:!1,label:xe,description:e(Ls(et.descriptionKey,A)),badgeCount:vt,badgeAriaLabel:vt!==null?e(Rt?vt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":vt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:xe,count:vt}):null,badgeDescription:vt!==null?e(Rt?vt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":vt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:vt}):null,orderNumber:De,showOrderNumber:se,onSelect:Ye=>{Pn(Ye.mode)&&re(zr(Ye.mode)),m(o,Ye.mode)}},et.id)})})]},Gs(ee[0]))),t[65]=A,t[66]=Se,t[67]=re,t[68]=Xe,t[69]=o,t[70]=Ce,t[71]=F,t[72]=ve,t[73]=_e,t[74]=m,t[75]=se,t[76]=V,t[77]=de,t[78]=e,t[79]=d,t[80]=G,t[81]=Ee,t[82]=Pe,t[83]=Fe,t[84]=Te,t[85]=Ae,t[86]=qe,t[87]=Ge,t[88]=Je,t[89]=st}else G=t[80],Ee=t[81],Pe=t[82],Fe=t[83],Te=t[84],Ae=t[85],qe=t[86],Ge=t[87],Je=t[88],st=t[89];let mt;t[92]!==G||t[93]!==Ee||t[94]!==Pe||t[95]!==Fe||t[96]!==Te||t[97]!==Ae||t[98]!==qe?(mt=n.jsx(G,{sensors:Ee,collisionDetection:Pe,onDragStart:Fe,onDragCancel:Te,onDragEnd:Ae,children:qe}),t[92]=G,t[93]=Ee,t[94]=Pe,t[95]=Fe,t[96]=Te,t[97]=Ae,t[98]=qe,t[99]=mt):mt=t[99];let Y;t[100]!==e?(Y=e("contextRail.configure.open"),t[100]=e,t[101]=Y):Y=t[101];let fe;t[102]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>me(!0),t[102]=fe):fe=t[102];let Re;t[103]===Symbol.for("react.memo_cache_sentinel")?(Re=n.jsx(ce,{name:"list-settings",className:"h-[17px] w-[17px]"}),t[103]=Re):Re=t[103];let T;t[104]!==Y?(T=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":Y,onClick:fe,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:Re})}),t[104]=Y,t[105]=T):T=t[105];let ae;t[106]!==e?(ae=e("contextRail.configure.open"),t[106]=e,t[107]=ae):ae=t[107];let pe;t[108]!==ae?(pe=n.jsx(jt,{side:"left",sideOffset:8,children:ae}),t[108]=ae,t[109]=pe):pe=t[109];let oe;t[110]!==T||t[111]!==pe?(oe=n.jsxs(kt,{delayDuration:gu,children:[T,pe]}),t[110]=T,t[111]=pe,t[112]=oe):oe=t[112];let be;t[113]!==Ne?(be=n.jsx(V2,{open:Ne,onOpenChange:me}),t[113]=Ne,t[114]=be):be=t[114];let $e;return t[115]!==Ge||t[116]!==Je||t[117]!==st||t[118]!==mt||t[119]!==oe||t[120]!==be?($e=n.jsxs("nav",{ref:Ge,"aria-label":Je,className:st,children:[mt,oe,be]}),t[115]=Ge,t[116]=Je,t[117]=st,t[118]=mt,t[119]=oe,t[120]=be,t[121]=$e):$e=t[121],$e};function sk(t){return t.shortcutOverrides}function nk(t){return t.workStatusPanelVisible}function rk(t){return t.contextRailOrder}function ok(t){return t.contextRailHiddenSurfaces}function ik(t){return t.setContextRailOrder}function ak(t){return t.openContextSurface}function lk(t){return t.closeContextZone}function ck(t){return t.contextSurfaceZones}function dk(t){return t.shortcutOverrides}function uk(t){return t.status?.status==="connected"}function fk(t){return Object.values(t.entries).some(uk)}function pk(t){return t.ensureStatus}function mk(t){return t.fetchStatus}function hk(t){return t.length===1&&t>="0"&&t<="9"}function gk(t){return t.countByGuest}function xk(t){return t.clearBadge}function bk(t){return t.mode==="pr"&&t.targetPath}function wk(t){return t.id}function yk(t){return t.id}const Ns=t=>t?n.jsx("span",{className:"oc-title-rest",children:t}):void 0,xs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},vk=()=>{const{t}=lt(),{git:e,sourceControl:s}=ks(),{childStores:r}=Lg(),[o,i]=c.useState(!1),[a,d]=c.useState(null),[u,l]=c.useState([]),[f,m]=c.useState(!1),[p,h]=c.useState(!1),[x,g]=c.useState(!1),[w,b]=c.useState(!1),[j,y]=c.useState(!1),[E,A]=c.useState(new Set),R=nt(G=>G.getWorktreeMetadata),_=nt(G=>G.setNewSessionDraftTarget),L=nt(G=>G.setDraftBootstrapPendingDirectory),v=zg,C=Hg,S=nt(G=>G.deleteSessions),k=nt(G=>G.archiveSessions),N=nt(G=>G.unarchiveSessions),$=K(G=>G.showDeletionDialog),B=K(G=>G.setShowDeletionDialog),D=zt(G=>G.currentDirectory),W=zt(G=>G.homeDirectory),H=Gt(G=>G.projects),U=Gt(G=>G.activeProjectId),{isMobile:se,isTablet:z,hasTouchInput:Q}=hn(),ie=se||z||Q,O=c.useMemo(()=>{const Ee=(U?H.find(Pe=>Pe.id===U)??null:null)?.path??D;return xs(Ee)},[U,D,H]),ne=c.useCallback(G=>{const Pe=xs(G.projectDirectory)||O;return{id:(H.find(Te=>xs(Te.path)===Pe)??null)?.id??`path:${Pe}`,path:Pe}},[O,H]),V=j&&E.size>0,[J,F]=c.useState(!1),re=a?.mode==="worktree"?a.worktree??u[0]?.metadata??null:null,q=re?.path,ge=re?.branch,Z=re?ne(re).path:null;c.useEffect(()=>{if(F(!1),!q||!Z)return;let G=!1;return Bg(Z,{path:q,branch:ge??""}).then(Ee=>{G||F(Ee)}),()=>{G=!0}},[ge,q,Z]);const de=c.useMemo(()=>{if(!J)return!1;const G=a?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!!G.status?.upstream?.split("/")[0]?.trim():u.length>0&&u.every(({metadata:Ee})=>typeof Ee.branch=="string"&&Ee.branch.trim().length>0&&!!Ee.status?.upstream?.split("/")[0]?.trim())},[J,a?.worktree,u]),Se=a?.mode==="worktree",ue=w||!Se||!de,ke=w||!Se,Me=Se?q:void 0,We=c.useCallback(G=>Me?$g(r,G):()=>{},[r,Me]),Le=c.useSyncExternalStore(We,()=>Me?Oa(r,Me).length:0),Ve=x&&Le>0,Ne=c.useCallback(G=>{d({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),me=c.useCallback(()=>{d(null),l([]),m(!1),h(!1),g(!1),b(!1),y(!1),A(new Set)},[]),ye=c.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const Te=G.sessions[0];await v(Te.id)?Oe.success(t("sessions.sidebar.session.delete.success")):Oe.error(t("sessions.sidebar.session.delete.error"));return}const Ee=G.sessions.map(Te=>Te.id),{deletedIds:Pe,failedIds:Fe}=await S(Ee);if(Pe.length>0){const Te=Fe.length>0?Fe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Fe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Fe.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.dateLabel}):void 0;Oe.success(Pe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Pe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Pe.length}),{description:Ns(Te)})}Fe.length>0&&Oe.error(Fe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Fe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Fe.length}),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[v,S,t]);c.useEffect(()=>lr.onDirectoryRequest(()=>{i(!0)}),[]),c.useEffect(()=>{if(!a){l([]),m(!1),h(!1),g(!1),y(!1),A(new Set);return}const G=a.sessions.map(Fe=>{const Te=R(Fe.id);return Te?{session:Fe,metadata:Te}:null}).filter(Fe=>!!Fe);l(G),m(!1),y(!1),A(new Set);const Ee=new Map;if(a.worktree?.path&&Ee.set(xs(a.worktree.path),a.worktree),G.forEach(({metadata:Fe})=>{Fe.path&&Ee.set(xs(Fe.path),Fe)}),Ee.size===0){y(!0);return}let Pe=!1;return(async()=>{const Fe=new Map,Te=new Set;await Promise.all(Array.from(Ee.entries()).map(async([Ae,qe])=>{try{const Ge=await Ma(qe.path);Fe.set(Ae,Ge),Ge?.isDirty&&Te.add(Ae)}catch{qe.status&&(Fe.set(Ae,qe.status),qe.status.isDirty&&Te.add(Ae))}})).catch(Ae=>{console.warn("Failed to inspect worktree status before deletion:",Ae)}),!Pe&&(A(Te),y(!0),d(Ae=>{if(!Ae?.worktree?.path)return Ae;const qe=xs(Ae.worktree.path),Ge=Fe.get(qe);if(!Ge)return Ae;const Je=Ae.worktree.status;return Je?.isDirty===Ge.isDirty&&Je?.ahead===Ge.ahead&&Je?.behind===Ge.behind&&Je?.upstream===Ge.upstream?Ae:{...Ae,worktree:{...Ae.worktree,status:Ge}}}),l(Ae=>Ae.map(qe=>{const Ge=xs(qe.metadata.path),Je=Fe.get(Ge);return Je?{session:qe.session,metadata:{...qe.metadata,status:Je}}:qe})))})(),()=>{Pe=!0}},[a,R]),c.useEffect(()=>{de||m(!1)},[de]);const je=c.useCallback(async(G,Ee,Pe,Fe)=>{const Te=f&&de,Ae=ne(G),qe=xs(G.path),Ge=xs(Ae.path);try{await Wg(Ae,G,{deleteRemoteBranch:Te,deleteLocalBranch:Ee,remoteName:G.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s},skipTeardown:Fe});const Je=Y=>!!(qe&&Y&&Ug(qe,Y)),st=nt.getState().newSessionDraft,mt=xs(st?.directoryOverride);return st?.open&&Je(mt)&&Ge&&(L(null),_({projectId:Ae.id,directoryOverride:Ge},{force:!0})),Je(xs(zt.getState().currentDirectory))&&Ge&&zt.getState().setDirectory(Ge,{showOverlay:!1}),!0}catch(Je){if(Je instanceof Error&&Vg(Je))throw Je;return Oe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Pe,description:Ns(Je instanceof Error?Je.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[de,f,ne,e,L,_,s,t]),Be=c.useCallback((G,Ee,Pe,Fe)=>{const Te=f&&de,Ae=async(qe,Ge)=>{const Je=Oe.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Mo(G)}));Xg(G.path);try{if(Fe){const Y=()=>Oa(r,G.path),fe=Y().map(T=>T.id);if(!(await Yg({worktreePath:G.path,projectDirectory:ne(G).path,readSessions:Y,removeWorktree:()=>je(G,Pe,Je,qe)})).removed)return;Fa(fe,{projectId:ne(G).id}),Oe.success(t(Te?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Je,description:Ns(Mo(G))});return}const st=await Jg({sessionIds:Ge,removeWorktree:()=>je(G,Pe,Je,qe),restoreSessions:Y=>N(Y,{undo:!0}),archiveSessions:async Y=>Y.length===1?await C(Y[0])?{archivedIds:Y,failedIds:[]}:{archivedIds:[],failedIds:Y}:k(Y)});if(!st.removed)return;Fa(Ge,{projectId:ne(G).id}),Oe.success(t(Te?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Je,description:Ns(Mo(G))});const{failedIds:mt}=st.archive;mt.length>0&&Oe.error(mt.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:mt.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:mt.length}),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(st){Oe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Je,description:Ns(st instanceof Error?t1(st,t)??st.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain")),...st instanceof Error?Qg(st,t("sessions.sidebar.sessionDialogs.worktree.deleteWithoutTeardown"),()=>{Ae(!0,e1(Ge,G.path))}):void 0})}finally{s1(G.path)}};return Ae(!1,Ee)},[C,k,de,r,f,ne,je,t,N]),_e=c.useRef(new Set),Ie=c.useCallback(async(G,Ee)=>{const Pe=xs(G.path);if(!_e.current.has(Pe)){_e.current.add(Pe);try{const Fe=await Ma(G.path).catch(()=>{});if(!Kg(Fe)){Ne({sessions:Ee,mode:"worktree",worktree:G});return}await Be(G,Ee.map(Te=>Te.id),!0,!1)}finally{_e.current.delete(Pe)}}},[Ne,Be]);c.useEffect(()=>lr.onDeleteRequest(G=>{if(!$&&(G.mode??"session")==="session"){ye(G);return}if(G.mode==="worktree"&&G.skipDialogIfSafe&&G.worktree){Ie(G.worktree,G.sessions);return}Ne(G)}),[Ne,$,ye,Ie]);const tt=c.useCallback(async()=>{if(a){b(!0);try{if(Se){const G=a.worktree??u[0]?.metadata;if(!G){Oe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}Be(G,a.sessions.map(Ee=>Ee.id),p&&J,Ve),me();return}if(a.sessions.length===1){const G=a.sessions[0];if(!await v(G.id)){Oe.error(t("sessions.sidebar.session.delete.error")),b(!1);return}Oe.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const G=a.sessions.map(Fe=>Fe.id),{deletedIds:Ee,failedIds:Pe}=await S(G);if(Ee.length>0){const Fe=Pe.length>0?Pe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Pe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Pe.length}):a.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:a.dateLabel}):void 0;Oe.success(Ee.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ee.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ee.length}),{description:Ns(Fe),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(Pe.length>0&&(Oe.error(Pe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Pe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Pe.length}),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Ee.length===0)){b(!1);return}}me()}finally{b(!1)}}},[J,a,u,p,v,S,me,Se,Ve,Be,t]),Ke=a?.worktree??u[0]?.metadata??null;let ze="";if(a?.mode==="worktree"){const G=a.sessions.length;Ve?ze=Le===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinkedKept",{count:Le}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinkedKept",{count:Le}):G===0?ze=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):G===1?ze=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:G}):ze=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:G})}else if(a){const G=a.sessions.length;G===1?ze=a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):ze=a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:G,dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:G})}const rt=a?n.jsxs("div",{className:Ze(Se?"space-y-3":"space-y-2"),children:[a.sessions.length>0&&n.jsxs("div",{className:Ze(Se?"oc-tile rounded-lg p-3":"oc-tile space-y-1.5 rounded-lg p-3"),children:[Se&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:a.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a.sessions.length})]}),n.jsxs("ul",{className:Ze(Se?"mt-2 space-y-1":"space-y-0.5"),children:[a.sessions.slice(0,5).map(G=>n.jsxs("li",{className:Ze(Se?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[n.jsx("span",{className:Ze(!Se&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),a.sessions.length>5&&n.jsx("li",{className:Ze(Se?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:a.sessions.length-5})})]})]}),Se?n.jsxs("div",{className:"oc-tile space-y-2 rounded-lg p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ce,{name:"worktree",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),Ke?.label?n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ke.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Ke?qg(Ke.path,W):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),V&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"oc-tile rounded-lg p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,ve=Se&&J?de?n.jsxs("button",{type:"button",onClick:()=>{ue||m(G=>!G)},disabled:ue,"aria-pressed":f,className:Ze("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ue?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ce,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,M=Se&&J?n.jsxs("button",{type:"button",onClick:()=>{ke||h(G=>!G)},disabled:ke,"aria-pressed":p,className:Ze("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ke?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ce,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ce=Se&&Le>0?n.jsxs("button",{type:"button",onClick:()=>{w||g(G=>!G)},disabled:w,"aria-pressed":x,className:Ze("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",w?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[x?n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ce,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.keepSessions")]}):null,He=Se?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Ce,M,ve]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{variant:"ghost",onClick:me,disabled:w,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ut,{variant:"destructive",onClick:tt,disabled:w,children:t(w?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>B(!$),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":!$,children:[$?n.jsx(ce,{name:"checkbox-blank",className:"size-4"}):n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{variant:"ghost",onClick:me,disabled:w,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ut,{variant:"destructive",onClick:tt,disabled:w,children:w?t("sessions.sidebar.sessionDialogs.actions.deleting"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Xe=Se?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[ie?n.jsx(Gg,{open:!!a,onClose:()=>{w||me()},title:Xe,footer:n.jsx("div",{className:"flex justify-end gap-2",children:He}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[ze&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:ze}),rt]})}):n.jsx(sr,{open:!!a,onOpenChange:G=>{if(!G){if(w)return;me()}},children:n.jsxs(nr,{className:Ze(Se?"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:[n.jsxs(rr,{children:[n.jsxs(or,{className:Ze(Se&&"flex items-center gap-2"),children:[Se&&n.jsx(ce,{name:"delete-bin",className:"h-5 w-5"}),Xe]}),ze&&n.jsx(ir,{children:ze})]}),Se?n.jsx(as,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:rt}):n.jsx("div",{children:rt}),n.jsx(Ur,{className:"mt-2 gap-2 pt-1 pb-1",children:He})]})}),n.jsx(Zg,{open:o,onOpenChange:i})]})},xu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Sk=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,kk=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,jk=t=>xu.some(({pattern:e})=>e.test(t));async function Ck(t,e,s){if(!t)return null;const r=Ek(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=Pk(s);if(o){const i=await Ik(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 Tk(t)){const o=await Nk(),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 Tk(t){const e=`${t}/index.html`,s=await Qr(e,t);return typeof s=="string"&&s.trim().length>0}async function Nk(){try{const t=await zs("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function Ek(t){for(const e of t){const s=kk.exec(e.command.trim())?.[1];if(s&&jk(s)||e.source!=="shared"&&Sk.test(e.name.trim()))return e}return null}function Pk(t){for(const{pattern:e}of xu)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function Ik(t){const e=await Qr(`${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 s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const i=await Qr(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Qr(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await zs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=nc()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await zs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Rk(t){try{const e=await Qr(`${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 Dk=/\{(worktree|branch)\}/g,Jo=63,_k=new Set(["main","master"]),bu=t=>/\{(worktree|branch)\}/.test(t??""),Ak=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},wu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Jo)return e;const s=await Ak(e);return s?`${e.slice(0,Jo-7).replace(/-+$/,"")}-${s}`:e.slice(0,Jo).replace(/-+$/,"")},Ok=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},Mk=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.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:Ok(i.current),linkedWorktree:o}},Fk=async t=>!t.linkedWorktree||!t.branch||_k.has(t.branch)?"":wu(t.branch.split("/").pop()??""),Lk=t=>{const e=t.lastIndexOf("@"),s=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):"",d=i.split(".").map(u=>u.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${d.join(".")}${a}`},Bk=async(t,e)=>{const s={worktree:await Fk(e),branch:e.branch?await wu(e.branch):""},r=t.replace(Dk,(u,l)=>s[l]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",d=""]=o;return`${i}${Lk(a)}${d}`},$k=async(t,e,s)=>bu(e)?Bk(e,await Mk(t,s,e)):e,yu="oc.projectActions.selectedAction.v1",zk=di(Ss(),di(Ss(),Ss())),vu=()=>{const t=hr().getItem(yu);if(t===null)return{};try{const e=zk.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},Dl=(t,e=qt())=>vu()[e]?.[t]??null,Wk=(t,e,s=qt())=>{const r=vu();r[s]?.[t]!==e&&hr().setItem(yu,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},Uk=15e3,Vk=3e3,Hk=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Kk=({projectRef:t,directory:e,allowMobile:s=!1})=>{const{t:r}=lt(),{currentTheme:o}=oo(),{terminal:i,runtime:a,git:d}=ks(),u=Hs(),{isMobile:l}=hn(),f=c.useMemo(()=>Ps(),[]),m=Ca(T=>T.instances),p=Ca(T=>T.load),h=K(T=>T.terminalShell),x=K(T=>T.terminalLoginShells.includes(T.terminalShell)),g=K(T=>T.setSettingsPage),w=K(T=>T.setSettingsDialogOpen),b=K(T=>T.setSettingsProjectsSelectedId),j=K(T=>T.openContextPreview),y=yt(T=>T.ensureDirectory),E=yt(T=>T.reconcileServerSessions),A=yt(T=>T.setTabLabel),R=yt(T=>T.setTabIconKey),_=yt(T=>T.setActiveTab),L=yt(T=>T.setConnecting),v=yt(T=>T.setTabSessionId),C=yt(T=>T.setTabPurpose),S=yt(T=>T.allocateActionExecution),k=yt(T=>T.setTabLifecycle),N=yt(T=>T.setTabPreviewUrl),$=yt(T=>T.matchesActionExecution),B=yt(T=>T.captureStartedActionMutationRevisions),[D,W]=c.useState([]),H=c.useRef(null),[U,se]=c.useState(()=>t?.id?Dl(t.id):null),[z,Q]=c.useState(!1),ie=c.useRef({}),O=c.useRef({}),ne=c.useRef({}),V=c.useRef(new Set),J=c.useRef(0),[F,re]=c.useState({}),q=t?.id??null,ge=t?.path??"";c.useEffect(()=>{se(q?Dl(q):null)},[q]);const Z=c.useMemo(()=>q?{id:q,path:ge}:null,[q,ge]);c.useEffect(()=>{f&&p().catch(()=>{})},[f,p]);const de=c.useCallback(async T=>{await On(T)},[]),Se=c.useCallback(async()=>{if(!Z)return;const T=J.current+1;J.current=T,Q(!0);try{const ae=await Fo(Z);if(J.current!==T)return;H.current=ae;const pe=ae.projectActions;W(pe)}catch{if(J.current!==T)return}finally{J.current===T&&Q(!1)}},[Z]),ue=c.useMemo(()=>Ro(e||Z?.path||""),[e,Z?.path]),ke=c.useMemo(()=>Ro(Z?.path||""),[Z?.path]),Me=c.useMemo(()=>Ro(u||"")||ue,[u,ue]),We=c.useRef(Me);c.useEffect(()=>{We.current=Me},[Me]);const Le=yt(T=>ue?T.getDirectoryState(ue):void 0),Ve=yt(T=>ke&&ke!==ue?T.getDirectoryState(ke):void 0),Ne=c.useMemo(()=>{const T=ue?[{directory:ue,state:Le}]:[];return ke&&ke!==ue&&T.push({directory:ke,state:Ve}),T},[Le,ue,ke,Ve]),me=c.useMemo(()=>{const T=ue?[ue]:[];return ke&&ke!==ue&&T.push(ke),T},[ue,ke]),ye=c.useCallback(T=>T.id!==sn&&T.runIn==="parent"&&ke||ue,[ue,ke]),je=c.useCallback((T,ae,pe)=>`${T}::${ae}::${pe}`,[]),Be=c.useCallback((T,ae,pe=yt.getState())=>T?pe.getDirectoryState(T)?.tabs.find(oe=>oe.purpose.type==="project-action"&&oe.purpose.actionId===ae)??null:null,[]),_e=c.useMemo(()=>{const T={};for(const{directory:ae,state:pe}of Ne)for(const oe of pe?.tabs??[]){if(oe.purpose.type!=="project-action"||!oe.purpose.executionId||!oe.terminalSessionId||oe.lifecycle==="idle"||oe.lifecycle==="exited")continue;const be=wn(ae,oe.purpose.actionId),$e=je(ae,oe.purpose.actionId,oe.purpose.executionId);T[be]={directory:ae,actionId:oe.purpose.actionId,tabId:oe.id,sessionId:oe.terminalSessionId,executionId:oe.purpose.executionId,status:oe.lifecycle==="stopping"?"stopping":F[$e]?"waiting-for-preview":"running"}}return T},[je,F,Ne]),Ie=c.useCallback((T,ae,pe)=>{const oe=wn(T,ae),be=je(T,ae,pe),De=ie.current[oe]?.executionId===pe,ee=globalThis.window,le=et=>{ee?.clearTimeout(ne.current[et]),delete ne.current[et]};De&&(delete ie.current[oe],le(oe)),O.current[be]?.(),delete O.current[be],le(be),re(et=>{if(!et[be])return et;const xe={...et};return delete xe[be],xe})},[je]),tt=c.useCallback(T=>{O.current[T]?.(),delete O.current[T]},[]),Ke=c.useCallback(T=>{window.clearTimeout(ne.current[T]),delete ne.current[T]},[]);c.useEffect(()=>{const T=O.current,ae=ne.current;return()=>{for(const pe of Object.keys(T))tt(pe);for(const pe of Object.keys(ae))Ke(pe)}},[Ke,tt]),c.useEffect(()=>{const T=new Set(me);for(const ae of Object.values(ie.current))T.has(ae.directory)||Ie(ae.directory,ae.actionId,ae.executionId);for(const ae of Object.keys(O.current)){const pe=ae.split("::",1)[0]??"";T.has(pe)||tt(ae)}},[Ie,tt,me]);const ze=c.useCallback((T,ae)=>{K.getState().openContextPanelTab(T,{mode:"terminal",targetDirectory:ae===T?null:ae})},[]),rt=c.useMemo(()=>({id:sn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),ve=!l,M=c.useMemo(()=>ve?[...D,rt]:D,[D,rt,ve]),Ce=c.useMemo(()=>U?M.find(T=>T.id===U)??null:null,[M,U]);c.useEffect(()=>{Se()},[Se]);const[He,Xe]=c.useState(0),G=c.useCallback(()=>(Xe(T=>T+1),()=>Xe(T=>T-1)),[]),Ee=He>0;c.useEffect(()=>{if(!Ee)return;const T=me.map(ae=>pp(i,ae,B,pe=>E(ae,pe.sessions,{startedActionMutationRevisions:pe.startedActionMutationRevisions})));return()=>{for(const ae of T)ae()}},[B,Ee,E,i,me]),c.useEffect(()=>{for(const{directory:T,state:ae}of Ne)if(T)for(const pe of ae?.tabs??[]){if(pe.purpose.type!=="project-action")continue;const oe=pe.purpose.actionId,be=M.find(ee=>ee.id===oe),$e=be?.name??oe,De=be?.icon||"play";pe.label!==$e&&A(T,pe.id,$e),pe.iconKey!==De&&R(T,pe.id,De)}},[M,R,A,Ne]),c.useEffect(()=>{const T=globalThis.window;if(!T)return;const ae=pe=>{const oe=pe.detail;q&&(oe?.projectId&&oe.projectId!==q||Se())};return T.addEventListener(Ta,ae),()=>{T.removeEventListener(Ta,ae)}},[Se,q]),c.useEffect(()=>{const T=pe=>{delete ne.current[pe];const oe=ie.current[pe];if(!oe||oe.openedUrl)return;const be=je(oe.directory,oe.actionId,oe.executionId),$e=oe.announced;if($e.length!==0){if(window.clearTimeout(ne.current[be]),delete ne.current[be],oe.openedUrl=!0,re(De=>{if(!De[be])return De;const ee={...De};return delete ee[be],ee}),$e.length===1){Zo(oe.directory,[]),N(oe.directory,oe.tabId,$e[0],{locked:!1,autoOpened:!0}),j(oe.directory,$e[0]);return}oe.offering=!0,Zo(oe.directory,$e),K.getState().openContextSurface(oe.directory,"browser"),Oe.info(r("projectActions.toast.multipleServers"))}},ae=()=>{const pe=yt.getState(),oe=pe.sessions,be=_e;for(const[$e,De]of Object.entries(be)){const le=oe.get(De.directory)?.tabs.find(ht=>ht.id===De.tabId);if(!le||le.terminalSessionId!==De.sessionId){Ie(De.directory,De.actionId,De.executionId);continue}const et=ie.current[$e],xe=et?.executionId===De.executionId?et:{hostDirectory:We.current||De.directory,directory:De.directory,tabId:De.tabId,actionId:De.actionId,executionId:De.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};ie.current[$e]=xe;const bt=M.find(ht=>ht.id===De.actionId),Tt=pe.getBuffer(De.directory,De.tabId).chunks;if(!bt||Tt.length===0)continue;const vt=Tt.filter(ht=>xe.lastSeenChunkId===null||ht.id>xe.lastSeenChunkId);if(vt.length===0)continue;const Rt=vt.map(ht=>ht.data).join(""),Ye=`${xe.tail}${Rt}`;for(const ht of wp(Ye))xe.proxiedPorts.includes(ht)||xe.proxiedPorts.push(ht);if(xe.openInPreview&&(!xe.openedUrl||xe.offering)){const ht=yp(Ye,{proxiedPorts:xe.proxiedPorts,namedAddressesReachable:!Na()}),Ct=xe.announced.length;for(const It of ht)xe.announced.includes(It)||xe.announced.push(It);const pt=xe.announced.length-Ct;xe.offering&&pt>0?Zo(De.directory,xe.announced):!xe.openedUrl&&Ct===0&&xe.announced.length>0&&(window.clearTimeout(ne.current[$e]),ne.current[$e]=window.setTimeout(()=>T($e),Vk))}const ft=!xe.openedUrl&&bt.autoOpenUrl===!0&&!xe.openInPreview?vp(Ye,{proxiedPorts:xe.proxiedPorts,namedAddressesReachable:!Na()}):null,Nt=vt[vt.length-1]?.id??xe.lastSeenChunkId;if(xe.lastSeenChunkId=Nt,xe.tail=Ye.slice(-512),ft)if(xe.openedUrl=!0,xe.openInPreview){const ht=be[$e];ht&&(N(ht.directory,ht.tabId,ft,{locked:!1,autoOpened:!1,expectedExecutionId:ht.executionId}),ht.status==="waiting-for-preview"&&re(Ct=>{const pt=je(ht.directory,ht.actionId,ht.executionId);if(!Ct[pt])return Ct;const It={...Ct};return delete It[pt],It}),window.clearTimeout(ne.current[$e]),delete ne.current[$e],j(ht.directory,ft))}else de(ft),Oe.success(r("projectActions.toast.openedUrlFromOutput"));ie.current[$e]=xe}for(const $e of Object.keys(ie.current))if(!be[$e]){const De=ie.current[$e],ee=De?oe.get(De.directory)?.tabs.find(et=>et.id===De.tabId):void 0;if(ee?.purpose.type==="project-action"&&ee.purpose.executionId===De?.executionId&&!!ee.terminalSessionId&&ee.lifecycle!=="idle"&&ee.lifecycle!=="exited")continue;delete ie.current[$e],window.clearTimeout(ne.current[$e]),delete ne.current[$e]}};return ae(),yt.subscribe((pe,oe)=>{(pe.sessions!==oe.sessions||pe.buffers!==oe.buffers)&&ae()})},[Ie,We,M,je,j,de,_e,N,r]),c.useEffect(()=>{for(const{directory:T,state:ae}of Ne)for(const pe of ae?.tabs??[]){if(pe.purpose.type!=="project-action"||!pe.purpose.executionId||!pe.terminalSessionId||pe.lifecycle!=="running")continue;const oe=pe.purpose.actionId,be=pe.purpose.executionId,$e=je(T,oe,be);if(O.current[$e])continue;const De=i.connect(pe.terminalSessionId,{onEvent:ee=>{if(!$(T,pe.id,be))return;ee.type==="snapshot"&&(yt.getState().replaceBuffer(T,pe.id,ee.data??"",ee.sequence??0,ua(ee)),ee.status==="running"&&yt.getState().setTabLifecycle(T,pe.id,"running",{expectedExecutionId:be}),ee.status==="exited"&&(yt.getState().setTabLifecycle(T,pe.id,"exited",{expectedExecutionId:be}),yt.getState().setTabPurpose(T,pe.id,{type:"project-action",actionId:oe,executionId:null}),Ie(T,oe,be)));const le=ee.type==="data"?ee.data??"":"";le&&yt.getState().appendToBuffer(T,pe.id,le,ee.sequence,ee.replayData),ee.type==="exit"&&(yt.getState().setTabLifecycle(T,pe.id,"exited",{expectedExecutionId:be}),yt.getState().setTabPurpose(T,pe.id,{type:"project-action",actionId:oe,executionId:null}),Ie(T,oe,be))},onError:(ee,le)=>{!le||!$(T,pe.id,be)||(yt.getState().setTabLifecycle(T,pe.id,"exited",{expectedExecutionId:be}),yt.getState().setTabSessionId(T,pe.id,null,{expectedExecutionId:be}),yt.getState().setTabPurpose(T,pe.id,{type:"project-action",actionId:oe,executionId:null}),Ie(T,oe,be))}},T);O.current[$e]=De.close}},[Ie,je,$,i,Ne]);const Pe=c.useCallback(async T=>{const ae=ye(T);if(!ae)throw new Error(r("projectActions.error.noActiveDirectory"));const pe=wn(ae,T.id);y(ae);const oe=yt.getState(),be=Be(ae,T.id,oe),$e=be?.id??oe.createTab(ae);A(ae,$e,T.name),R(ae,$e,T.icon||"play"),be||C(ae,$e,{type:"project-action",actionId:T.id,executionId:null}),_(ae,$e);const ee=yt.getState().getDirectoryState(ae)?.tabs.find(le=>le.id===$e);return{executionDirectory:ae,key:pe,tabId:$e,sessionId:ee?.terminalSessionId??null,executionId:ee?.purpose.type==="project-action"?ee.purpose.executionId:null}},[y,ye,Be,_,R,A,C,r]),Fe=c.useCallback(async T=>{if(a.isVSCode||!s&&l)return;if(!ue){Oe.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ae=wn(ye(T),T.id),pe=_e[ae];if(pe&&pe.status==="running"||V.current.has(ae))return;V.current.add(ae);let oe=null;try{const be=T.id===sn?await(async()=>{const dt=Z??{id:"",path:ue},[ct,Mt]=await Promise.all([Fo(dt),Rk(ue)]),Wt=await Ck(ue,ct.projectActions,Mt);if(!Wt)throw new Error(r("contextPanel.preview.noDevServer"));return ct.projectActions.find(Kt=>Kt.id===Wt.actionId)?.source==="shared"&&!await La(dt,ct)?null:{id:sn,name:r("projectActions.actions.autoDiscover"),command:Wt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Wt.previewUrlHint||""}})():T;if(!be)return;const $e=be.autoOpenUrl===!0&&(be.openUrl||"").trim().length>0,De=!$e&&T.id!==sn,ee=We.current||ue,{executionDirectory:le,key:et,tabId:xe}=await Pe(be),bt=mp(be.command);if(!bt)throw new Error(r("projectActions.error.failedToRunAction"));const Tt=be.autoOpenUrl===!0&&f&&(be.desktopOpenSshForward||"").trim().length>0,vt=be.autoOpenUrl&&be.openUrl||"";let Rt=!1;const Ye=bu(vt)?await $k(d,vt,le).catch(()=>(Rt=!0,"")):vt,ft=be.autoOpenUrl?Hk(Ye):null,Nt=be.autoOpenUrl&&f?hp(be.desktopOpenSshForward,m):null;if(i.listSessions){const dt=Be(le,be.id);if(dt?.purpose.type==="project-action"&&dt.purpose.executionId===null){const ct=await gp(i,le,{captureStartedActionMutationRevisions:B});ct&&E(le,ct.sessions,{startedActionMutationRevisions:ct.startedActionMutationRevisions})}}const ht=Be(le,be.id);let Ct,pt;if(ht?.lifecycle==="running"&&ht.terminalSessionId&&ht.purpose.type==="project-action"&&ht.purpose.executionId)Ct=ht.terminalSessionId,pt=ht.purpose.executionId;else{const dt=ht?.purpose.type==="project-action"?ht.purpose.executionId:null;dt&&Ie(le,be.id,dt);const ct=S(le,xe,be.id);if(!ct)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));oe={directory:le,tabId:xe,id:ct},L(le,xe,!0,{expectedExecutionId:ct});const Mt=await xp({terminal:i,createOptions:{cwd:le,shell:h,loginShell:x,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:bt,isRunStillExpected:()=>$(le,xe,ct),purpose:{type:"project-action",actionId:be.id,executionId:ct}});if(!$(le,xe,ct)){Mt.sessionId===ct&&await i.close(Mt.sessionId).catch(()=>{});return}pt=Mt.purpose?.type==="project-action"?Mt.purpose.executionId:ct,Ct=Mt.sessionId,C(le,xe,{type:"project-action",actionId:be.id,executionId:pt}),v(le,xe,Ct,{expectedExecutionId:pt}),L(le,xe,!1,{expectedExecutionId:pt})}De&&ee&&ze(ee,le),ie.current[et]={hostDirectory:ee,directory:le,tabId:xe,actionId:be.id,executionId:pt,lastSeenChunkId:null,openedUrl:!!Nt||!!ft||$e,tail:"",openInPreview:be.id===sn,announced:[],offering:!1,proxiedPorts:[]};const It=je(le,be.id,pt);L(le,xe,!0,{expectedExecutionId:pt});const Ht=i.connect(Ct,{onEvent:dt=>{if(!$(le,xe,pt)||dt.purpose?.type==="project-action"&&dt.purpose.executionId!==pt)return;dt.type==="snapshot"&&(yt.getState().replaceBuffer(le,xe,dt.data??"",dt.sequence??0,ua(dt)),yt.getState().setConnecting(le,xe,!1,{expectedExecutionId:pt}),dt.purpose?.type==="project-action"&&yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:dt.purpose.actionId,executionId:dt.purpose.executionId}),dt.status==="running"&&yt.getState().setTabLifecycle(le,xe,"running",{expectedExecutionId:pt}),dt.status==="exited"&&(yt.getState().setTabLifecycle(le,xe,"exited",{expectedExecutionId:pt}),yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:be.id,executionId:null}),Ie(le,be.id,pt)));const ct=dt.type==="data"?dt.data??"":"";ct&&yt.getState().appendToBuffer(le,xe,ct,dt.sequence,dt.replayData),dt.type==="exit"&&(yt.getState().setTabLifecycle(le,xe,"exited",{expectedExecutionId:pt}),yt.getState().setConnecting(le,xe,!1,{expectedExecutionId:pt}),yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:be.id,executionId:null}),Ie(le,be.id,pt))},onError:(dt,ct)=>{$(le,xe,pt)&&(yt.getState().setConnecting(le,xe,!1,{expectedExecutionId:pt}),ct&&(yt.getState().setTabLifecycle(le,xe,"exited",{expectedExecutionId:pt}),yt.getState().setTabSessionId(le,xe,null,{expectedExecutionId:pt}),yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:be.id,executionId:null}),Ie(le,be.id,pt)))}},le);if(!$(le,xe,pt)){Ht.close();return}O.current[It]?.(),O.current[It]=Ht.close,window.clearTimeout(ne.current[It]),delete ne.current[It],be.id===sn&&!ft&&(re(dt=>({...dt,[It]:!0})),ne.current[It]=window.setTimeout(()=>{delete ne.current[It];const dt=ie.current[et];!dt||dt.executionId!==pt||dt.openedUrl||dt.offering||$(le,xe,pt)&&(re(ct=>{if(!ct[It])return ct;const Mt={...ct};return delete Mt[It],Mt}),yt.getState().setActiveTab(le,xe),ze(dt.hostDirectory,le))},Uk)),Nt?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),de(Nt),Oe.success(r("projectActions.toast.openedForwardedUrl"))):ft?(N(le,xe,ft,{locked:!0,autoOpened:!0,expectedExecutionId:pt}),j(ee,ft),Oe.success(r("projectActions.toast.openedActionUrl"))):Rt?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),Oe.error(r("projectActions.error.openUrlTemplateUnresolved"))):$e?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),Oe.error(r("projectActions.error.invalidCustomUrlFormat"))):Tt?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),Oe.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):N(le,xe,null,{locked:!1,autoOpened:!1,expectedExecutionId:pt})}catch(be){if(oe&&$(oe.directory,oe.tabId,oe.id)){const{directory:$e,tabId:De,id:ee}=oe;Ie($e,T.id,ee),k($e,De,"exited",{expectedExecutionId:ee}),C($e,De,{type:"project-action",actionId:T.id,executionId:null})}if(be instanceof Error&&be.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(be instanceof Error&&(be.message==="COMMAND_MODE_UNSUPPORTED"||be.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Oe.error(r("projectActions.error.failedToCreateTerminalSession"));return}Oe.error(be instanceof Error?be.message:r("projectActions.error.failedToRunAction"))}finally{V.current.delete(ae)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,We,m,Pe,d,s,l,f,ue,x,h,de,j,_e,ze,a.isVSCode,ye,$,Ie,je,Be,E,S,B,L,k,C,N,v,Z,r,i]),Te=c.useCallback(async T=>{const ae=wn(ye(T),T.id),pe=_e[ae];pe&&await bp({terminal:i,sessionId:pe.sessionId,isExecutionStillCurrent:()=>$(pe.directory,pe.tabId,pe.executionId),markStopping:()=>{k(pe.directory,pe.tabId,"stopping",{expectedExecutionId:pe.executionId})},restoreRunning:()=>{k(pe.directory,pe.tabId,"running",{expectedExecutionId:pe.executionId})},clearSession:()=>{v(pe.directory,pe.tabId,null,{expectedExecutionId:pe.executionId})},finalizeExit:()=>{k(pe.directory,pe.tabId,"exited",{expectedExecutionId:pe.executionId}),C(pe.directory,pe.tabId,{type:"project-action",actionId:pe.actionId,executionId:null}),Ie(pe.directory,pe.actionId,pe.executionId)}})},[Ie,ye,$,_e,k,C,v,i]),Ae=c.useCallback(async T=>{if(T.source==="shared"&&Z){const ae=H.current?.trust.trusted?H.current:await Fo(Z);if(H.current=ae,!await La(Z,ae))return;H.current={...ae,trust:{...ae.trust,trusted:!0}}}await Fe(T)},[Fe,Z]),qe=c.useCallback(T=>_e[wn(ye(T),T.id)]??null,[ye,_e]),Ge=(Ce&&qe(Ce)?Ce:null)??M.find(T=>qe(T)!==null)??Ce??M[0]??null,Je=c.useCallback(T=>{const ae=qe(T);if(ae?.status!=="stopping"){if(ae){Te(T);return}Ae(T)}},[Ae,qe,Te]),st=c.useCallback(T=>{Ae(T)},[Ae]),mt=c.useCallback(T=>{Te(T)},[Te]),Y=c.useCallback(T=>{se(T.id),q&&Wk(q,T.id)},[q]),fe=c.useCallback(()=>{Z?.id&&(b(Z.id),g("projects"),w(!0))},[w,g,b,Z?.id]),Re=!a.isVSCode&&(s||!l)&&!!Z&&!!ue;return c.useMemo(()=>({available:Re,actions:Re?M:[],shown:Re?Ge:null,isLoading:z,observe:G,runOf:qe,select:Y,run:st,stop:mt,toggle:Je,openSettings:fe}),[Re,M,z,G,fe,st,qe,Y,Ge,mt,Je])},qk=t=>{const e=Ue.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=Kk(r);let i;return e[3]!==s||e[4]!==o?(i=n.jsx(kd.Provider,{value:o,children:s}),e[3]=s,e[4]=o,e[5]=i):i=e[5],i},Gk=t=>{const e=Ue.c(4),{children:s}=t,r=Cd(),o=wr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let d;return e[0]!==s||e[1]!==a||e[2]!==i?(d=n.jsx(qk,{projectRef:i,directory:a,children:s}),e[0]=s,e[1]=a,e[2]=i,e[3]=d):d=e[3],d},Zk=2e4,Xk=14400*1e3,Yk=t=>Object.entries(t).map(([e,s])=>`${e}@${s.version}`).sort().join(","),Jk="openchamber.guests.announcedUpdates",Qk=()=>{const{t}=lt(),e=c.useRef(t);e.current=t,c.useEffect(()=>{let s=!1;const r=async()=>{const a=qt();await n1();const d=await Sp(!1);if(s||!d.ok||qt()!==a)return;const u=tr.getState();u.applyUpdates(d.updates,u.runtimeKey);const l=tr.getState().guests.filter(g=>d.updates[g.id]),f=Yk(d.updates),m=hr(),p=`${Jk}:${a}`;if(l.length===0||m.getItem(p)===f)return;m.setItem(p,f);const h=e.current,[x]=l;Oe.info(l.length===1&&x?h("settings.extensions.updates.notice.one",{name:x.name}):h("settings.extensions.updates.notice.many",{count:l.length}),{action:{label:h("settings.extensions.updates.notice.open"),onClick:()=>{const g=K.getState();g.setSettingsPage("extensions"),g.setSettingsDialogOpen(!0)}}})};let o;const i=window.setTimeout(()=>{r(),o=window.setInterval(()=>{r()},Xk)},Zk);return()=>{s=!0,window.clearTimeout(i),window.clearInterval(o)}},[])},ej=()=>{lr.requestDirectoryDialog()},tj=()=>{K.getState().setNewWorktreeDialogOpen(!0)},sj=()=>{const t=zt.getState().currentDirectory;if(!t)return!1;K.getState().openContextOverview(t)},nj=()=>{Jc()},rj=()=>{if(!K.getState().overviewFeatureAvailable)return!1;K.getState().setOverviewOpen(!0)},oj=()=>{window.location.reload()},ij=()=>{const t=K.getState();t.setSessionSwitcherOpen(!1),t.setArchivePageOpen(!0)},Su=t=>{const e=zt.getState().currentDirectory;if(!e)return!1;const s=K.getState();return s.setProjectContextTab(t),s.openContextSurface(e,"notes"),!0},aj=()=>Su("notes"),lj=()=>Su("todos"),cj=t=>()=>{kp(t)},dj=t=>()=>{const e=nt.getState().currentSessionId,s=zt.getState().currentDirectory;if(!e||!s)return!1;const r=Xi(yr.getState().ids,s,e)?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";jp({directory:s,sessionId:e}).catch(()=>Oe.error(t(r)))},uj=t=>()=>{const e=nt.getState().currentSessionId;if(!e)return!1;io(e).then(s=>{if(s.ok){Oe.success(t("sessions.sidebar.session.copyId.success"));return}Oe.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Oe.error(t("sessions.sidebar.session.copyId.error")))},fj=t=>()=>{if(!K.getState().sessionWorkEnabled)return!1;const e=nt.getState().currentSessionId;if(!e)return!1;const s=ts.getState().activeSessions.find(i=>i.id===e);if(!s||s.parentID)return!1;const r=Bs(s)??zt.getState().currentDirectory;if(!r||so(r)||Xi(yr.getState().ids,r,e)||nt.getState().worktreeMetadata.get(e)?.pinnedAt!==void 0)return!1;const o=Mi(s)?"done":"open";r1(e,r,o).catch(()=>Oe.error(t("sessions.sidebar.session.work.updateFailed")))},pj=()=>{K.getState().setSessionSwitcherOpen(!1),o1()};function mj(){const t=Ue.c(13),{t:e}=lt();let s;t[0]!==e?(s=cj(e),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=dj(e),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=uj(e),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=fj(e),t[6]=e,t[7]=i):i=t[7];let a;t[8]!==s||t[9]!==r||t[10]!==o||t[11]!==i?(a={open_new_worktree_dialog:tj,add_project:ej,show_context_usage:sj,show_opencode_status:nj,open_overview:rj,reload_ui:oj,open_archive:ij,open_notes:aj,open_todos:lj,restart_opencode:s,pin_current_session:r,copy_current_session_id:o,toggle_work_current_session:i,open_multi_run:pj},t[8]=s,t[9]=r,t[10]=o,t[11]=i,t[12]=a):a=t[12],Pc(a)}function hj(t){const e=[],s=(r,o)=>{const i=Jt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const gj=new Map,xj=[],bj=t=>{const e=Ue.c(20),{isVSCode:s}=t,r=Kc(),o=Gt(wj),i=zt(yj),a=nt(vj);let d;e[0]!==s?(d=_=>s?gj:_.availableWorktreesByProject,e[0]=s,e[1]=d):d=e[1];const u=nt(d),l=!s;let f;e[2]!==u||e[3]!==o||e[4]!==l?(f=Cp(o,u,{includeWorktrees:l}),e[2]=u,e[3]=o,e[4]=l,e[5]=f):f=e[5];const m=f,p=ts(Sj),h=`session-list-sync:${c.useId()}`;let x,g;e[6]!==h||e[7]!==r||e[8]!==i||e[9]!==a?(x=()=>(r.setBootstrapDemand(h,hj({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(h)),g=[h,r,i,a],e[6]=h,e[7]=r,e[8]=i,e[9]=a,e[10]=x,e[11]=g):(x=e[10],g=e[11]),c.useEffect(x,g);const w=c.useRef(null);let b,j;e[12]!==s||e[13]!==m?(b=()=>{const _=new Set(m),L=w.current;w.current=_;const v=L?[..._].filter(C=>!L.has(C)):s?[..._]:[];v.length&&Qc(v,oi())},j=[s,m],e[12]=s,e[13]=m,e[14]=b,e[15]=j):(b=e[14],j=e[15]),c.useEffect(b,j);let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[16]=y):y=e[16],c.useEffect(kj,y);const E=p!=null,A=p??xj;let R;e[17]!==A||e[18]!==E?(R={enabled:!0,hasAuthoritativeGlobalSessions:E,sessions:A},e[17]=A,e[18]=E,e[19]=R):R=e[19],Tp(R)};function wj(t){return t.projects}function yj(t){return t.currentDirectory}function vj(t){return t.currentSessionDirectory}function Sj(t){return t.authoritativeSessions}function kj(){let t=null,e=!1;const s=new Set,r=_n(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),i1(oi());return}const i=[...s];s.clear(),i.length&&Qc(i,oi())},500)});return()=>{t&&clearTimeout(t),r()}}const jj=()=>Ft(()=>import("./SettingsWindow-RJIA1rl5.js"),__vite__mapDeps([237,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,238,239,240,222,223,224,225,204,232,201,188,189,202,241,242,212,231,217,243,244,245])).then(t=>t.SettingsWindow),Cj=()=>Ft(()=>import("./CommandPalette-D1G7W43z.js"),__vite__mapDeps([246,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,245,211,181,182,183,209,210,212])).then(t=>t.CommandPalette),Tj=()=>Ft(()=>import("./HelpDialog-BfDxlsKj.js"),__vite__mapDeps([247,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),Nj=()=>Ft(()=>import("./ProjectActionsDialog-Bt6OXdLD.js"),__vite__mapDeps([248,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,209,210,211,212])).then(t=>t.ProjectActionsDialog),Ej=()=>Ft(()=>import("./OpenCodeStatusDialog-BZzdMaVU.js"),__vite__mapDeps([249,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),Pj=()=>Ft(()=>import("./RunOverview-CvD2Q7KM.js"),__vite__mapDeps([250,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),Ij=()=>Ft(()=>import("./ScheduledTasksDialog-Dtdb6owf.js"),__vite__mapDeps([251,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,235,252,253,254])).then(t=>t.ScheduledTasksDialog),Rj=()=>Ft(()=>import("./ArchiveView-DIg8Bq5r.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,181,182,183,256])).then(t=>t.ArchiveView),Dj=()=>Ft(()=>import("./IntegrationsCatalogView-DX9AlNKS.js"),__vite__mapDeps([257,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,239])).then(t=>t.IntegrationsCatalogView),_j=()=>Ft(()=>import("./UsageStatsView-Cgo61IDa.js"),__vite__mapDeps([258,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),Aj=()=>Ft(()=>import("./SourceBoardView-BuYJw-Sp.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,181,182,183])).then(t=>t.SourceBoardView),Oj=()=>Ft(()=>import("./OverviewView-CQ82APO2.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,181,182,183])).then(t=>t.OverviewView),Mj=()=>Ft(()=>import("./WorktreesView-Duwvqggr.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,256])).then(t=>t.WorktreesView),Fj=()=>Ft(()=>import("./SpacesView-BSt0xE6N.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,243,181,182,183])).then(t=>t.SpacesView),Lj=()=>Ft(()=>import("./SpaceAccessDialog-B4-bPo9e.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,264])).then(t=>t.SpaceAccessDialog),Bj=()=>Ft(()=>import("./SpaceApplyDialog-DjTQ5PZT.js"),__vite__mapDeps([265,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),$j=()=>Ft(()=>import("./SpaceSetupOutput-DRDEgMzx.js"),__vite__mapDeps([266,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,264])).then(t=>t.SpaceSetupOutputDialog),_s=()=>K.getState().closeMainSurfaces(),es=t=>{const e=Ue.c(2),{needed:s,load:r,onFailure:o}=t,i=ho(s,r,o);let a;return e[0]!==i?(a=i?n.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},ku=c.memo(t=>{const e=Ue.c(12),{isMobile:s}=t,r=K(Wj),o=!r&&!s,i=lo();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 d=qb(a),[u,l]=c.useState(null);let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(zb,{actionsSlotRef:l}),e[3]=f):f=e[3];const m=r||d.state!==!1;let p;e[4]!==u||e[5]!==m?(p=n.jsx(Np,{isVisible:m,listControlsSlot:u}),e[4]=u,e[5]=m,e[6]=p):p=e[6];let h;return e[7]!==s||e[8]!==r||e[9]!==d||e[10]!==p?(h=n.jsx($b,{isOpen:r,isMobile:s,className:"border-border",topBar:f,peek:d,children:p}),e[7]=s,e[8]=r,e[9]=d,e[10]=p,e[11]=h):h=e[11],h});ku.displayName="LeftSidebar";const zj=()=>{const t=Ue.c(114);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],bj(e),mj(),Ep();const s=K(Uj),r=K(Vj),o=K(Hj),i=K(Kj);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const d=ho(o,jj,a),u=K(qj),l=K(Gj),f=K(Zj),m=K(Xj),p=K(Yj),h=K(Jj),x=K(Qj),g=K(e3),w=K(t3),b=K(s3),j=K(n3),y=K(r3),E=K(o3),A=dn(i3),R=dn(a3),_=dn(l3),L=K(c3),v=a1();let C;if(t[3]!==v||t[4]!==L){let fe;t[6]!==L?(fe=Re=>Re.id===L,t[6]=L,t[7]=fe):fe=t[7],C=v.find(fe),t[3]=v,t[4]=L,t[5]=C}else C=t[5];const S=C;let k,N;t[8]!==S||t[9]!==L?(k=()=>{L&&!S&&K.getState().setOpenGuestPage(null)},N=[L,S],t[8]=S,t[9]=L,t[10]=k,t[11]=N):(k=t[10],N=t[11]),c.useEffect(k,N);let $;t[12]===Symbol.for("react.memo_cache_sentinel")?($=[],t[12]=$):$=t[12],c.useEffect(u3,$);let B;t[13]===Symbol.for("react.memo_cache_sentinel")?(B=[],t[13]=B):B=t[13],c.useEffect(f3,B);const D=l||f||m||p||h||x||!!g||w||u||!!S,W=c.useRef(null);let H,U;t[14]!==D?(H=()=>{if(D)return _i(p3,W,1)},U=[D],t[14]=D,t[15]=H,t[16]=U):(H=t[15],U=t[16]),c.useEffect(H,U);let se,z;t[17]!==D?(z=()=>{ed(D)},se=[D],t[17]=D,t[18]=se,t[19]=z):(se=t[18],z=t[19]),c.useLayoutEffect(z,se);let Q;t[20]===Symbol.for("react.memo_cache_sentinel")?(Q=[],t[20]=Q):Q=t[20],c.useEffect(h3,Q);let ie;t[21]===Symbol.for("react.memo_cache_sentinel")?(ie=[],t[21]=ie):ie=t[21],c.useEffect(x3,ie);const{isMobile:O}=hn();Pp(),Qk();let ne,V;t[22]!==O||t[23]!==r?(ne=()=>{K.getState().isMobile!==O&&r(O)},V=[O,r],t[22]=O,t[23]=r,t[24]=ne,t[25]=V):(ne=t[24],V=t[25]),c.useEffect(ne,V);let J;t[26]!==b?(J=n.jsx(es,{needed:b,load:Cj,onFailure:b3}),t[26]=b,t[27]=J):J=t[27];let F;t[28]!==j?(F=n.jsx(es,{needed:j,load:Tj,onFailure:w3}),t[28]=j,t[29]=F):F=t[29];let re;t[30]!==y?(re=n.jsx(es,{needed:y,load:Nj,onFailure:y3}),t[30]=y,t[31]=re):re=t[31];let q;t[32]!==E?(q=n.jsx(es,{needed:E,load:Ej,onFailure:v3}),t[32]=E,t[33]=q):q=t[33];let ge,Z;t[34]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsx(Rp,{}),Z=n.jsx(vk,{}),t[34]=ge,t[35]=Z):(ge=t[34],Z=t[35]);let de;t[36]!==A||t[37]!==R||t[38]!==_||t[39]!==s?(de=s?n.jsxs(n.Fragment,{children:[n.jsx(es,{needed:A,load:Lj,onFailure:S3}),n.jsx(Dp,{}),n.jsx(es,{needed:R,load:Bj,onFailure:k3}),n.jsx(_p,{}),n.jsx(es,{needed:_,load:$j,onFailure:j3})]}):null,t[36]=A,t[37]=R,t[38]=_,t[39]=s,t[40]=de):de=t[40];let Se;t[41]===Symbol.for("react.memo_cache_sentinel")?(Se=n.jsx(Gb,{}),t[41]=Se):Se=t[41];let ue;t[42]!==O?(ue=n.jsx(ku,{isMobile:O}),t[42]=O,t[43]=ue):ue=t[43];let ke;t[44]===Symbol.for("react.memo_cache_sentinel")?(ke=n.jsx(Bb,{}),t[44]=ke):ke=t[44];let Me;t[45]===Symbol.for("react.memo_cache_sentinel")?(Me=n.jsx(Go,{zone:"left"}),t[45]=Me):Me=t[45];const We=D&&"invisible";let Le;t[46]!==We?(Le=Ze("absolute inset-0",We),t[46]=We,t[47]=Le):Le=t[47];const Ve=!o&&!D;let Ne;t[48]!==Ve?(Ne=n.jsx(Xt,{children:n.jsx(yc,{active:Ve})}),t[48]=Ve,t[49]=Ne):Ne=t[49];let me;t[50]!==Le||t[51]!==Ne?(me=n.jsx("div",{className:Le,children:Ne}),t[50]=Le,t[51]=Ne,t[52]=me):me=t[52];let ye;t[53]!==u?(ye=n.jsx(Xt,{children:n.jsx(es,{needed:u,load:Pj,onFailure:_s})}),t[53]=u,t[54]=ye):ye=t[54];let je;t[55]!==l?(je=n.jsx(Xt,{children:n.jsx(es,{needed:l,load:Ij,onFailure:_s})}),t[55]=l,t[56]=je):je=t[56];let Be;t[57]!==f?(Be=n.jsx(Xt,{children:n.jsx(es,{needed:f,load:Rj,onFailure:_s})}),t[57]=f,t[58]=Be):Be=t[58];let _e;t[59]!==m?(_e=n.jsx(Xt,{children:n.jsx(es,{needed:m,load:Dj,onFailure:_s})}),t[59]=m,t[60]=_e):_e=t[60];let Ie;t[61]!==p?(Ie=p&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Xt,{children:n.jsx(es,{needed:!0,load:_j,onFailure:_s})})}),t[61]=p,t[62]=Ie):Ie=t[62];let tt;t[63]!==h?(tt=n.jsx(es,{needed:h,load:Aj,onFailure:_s}),t[63]=h,t[64]=tt):tt=t[64];let Ke;t[65]!==x?(Ke=n.jsx(Xt,{children:n.jsx(es,{needed:x,load:Oj,onFailure:_s})}),t[65]=x,t[66]=Ke):Ke=t[66];const ze=!!g;let rt;t[67]!==ze?(rt=n.jsx(Xt,{children:n.jsx(es,{needed:ze,load:Mj,onFailure:_s})}),t[67]=ze,t[68]=rt):rt=t[68];let ve;t[69]!==w?(ve=w?n.jsx(Xt,{children:n.jsx(es,{needed:!0,load:Fj,onFailure:_s})}):null,t[69]=w,t[70]=ve):ve=t[70];let M;t[71]!==S?(M=S&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Xt,{children:n.jsx(l1,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:C3})})}),t[71]=S,t[72]=M):M=t[72];let Ce;t[73]!==me||t[74]!==ye||t[75]!==je||t[76]!==Be||t[77]!==_e||t[78]!==Ie||t[79]!==tt||t[80]!==Ke||t[81]!==rt||t[82]!==ve||t[83]!==M?(Ce=n.jsxs("main",{ref:W,className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[me,ye,je,Be,_e,Ie,tt,Ke,rt,ve,M]}),t[73]=me,t[74]=ye,t[75]=je,t[76]=Be,t[77]=_e,t[78]=Ie,t[79]=tt,t[80]=Ke,t[81]=rt,t[82]=ve,t[83]=M,t[84]=Ce):Ce=t[84];let He;t[85]===Symbol.for("react.memo_cache_sentinel")?(He=n.jsx(Go,{zone:"bottom"}),t[85]=He):He=t[85];let Xe;t[86]!==Ce?(Xe=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[Ce,He]}),t[86]=Ce,t[87]=Xe):Xe=t[87];let G,Ee,Pe,Fe;t[88]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Go,{zone:"right"}),Ee=n.jsx(O2,{}),Pe=n.jsx(F2,{}),Fe=n.jsx(W2,{}),t[88]=G,t[89]=Ee,t[90]=Pe,t[91]=Fe):(G=t[88],Ee=t[89],Pe=t[90],Fe=t[91]);let Te;t[92]!==Xe?(Te=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Me,n.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:[Xe,G,Ee,Pe,Fe]})]})}),t[92]=Xe,t[93]=Te):Te=t[93];let Ae;t[94]===Symbol.for("react.memo_cache_sentinel")?(Ae=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(Xt,{children:n.jsx(tk,{})})}),t[94]=Ae):Ae=t[94];let qe;t[95]===Symbol.for("react.memo_cache_sentinel")?(qe=n.jsx(Xt,{children:n.jsx(d1,{})}),t[95]=qe):qe=t[95];let Ge;t[96]!==Te?(Ge=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ke,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Te,Ae,qe]})]}),t[96]=Te,t[97]=Ge):Ge=t[97];let Je;t[98]!==ue||t[99]!==Ge?(Je=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[ue,Ge]}),t[98]=ue,t[99]=Ge,t[100]=Je):Je=t[100];let st;t[101]!==d||t[102]!==o||t[103]!==i?(st=d?n.jsx(d,{open:o,onOpenChange:i}):null,t[101]=d,t[102]=o,t[103]=i,t[104]=st):st=t[104];let mt;t[105]===Symbol.for("react.memo_cache_sentinel")?(mt=null,t[105]=mt):mt=t[105];let Y;return t[106]!==J||t[107]!==F||t[108]!==re||t[109]!==q||t[110]!==de||t[111]!==Je||t[112]!==st?(Y=n.jsx(c1.Provider,{value:!0,children:n.jsx(Ip,{children:n.jsx(Gk,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[J,F,re,q,ge,Z,de,Se,Je,st,mt]})})})}),t[106]=J,t[107]=F,t[108]=re,t[109]=q,t[110]=de,t[111]=Je,t[112]=st,t[113]=Y):Y=t[113],Y};function Wj(t){return t.isSidebarOpen}function Uj(t){return t.isolatedSpacesEnabled}function Vj(t){return t.setIsMobile}function Hj(t){return t.isSettingsDialogOpen}function Kj(t){return t.setSettingsDialogOpen}function qj(t){return t.runOverviewKey!==null}function Gj(t){return t.isScheduledTasksDialogOpen}function Zj(t){return t.isArchivePageOpen}function Xj(t){return t.isIntegrationsCatalogOpen}function Yj(t){return t.isUsageStatsPageOpen}function Jj(t){return t.isSourceBoardOpen}function Qj(t){return t.isOverviewOpen}function e3(t){return t.worktreesPageProjectId}function t3(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function s3(t){return t.isCommandPaletteOpen}function n3(t){return t.isHelpDialogOpen}function r3(t){return t.isProjectActionsDialogOpen}function o3(t){return t.isOpenCodeStatusDialogOpen}function i3(t){return t.accessDialog!==null}function a3(t){return t.applyDialog!==null}function l3(t){return t.setupOutputDialog!==null}function c3(t){return t.openGuestPageId}function d3(){return K.getState().setOpenGuestPage(null)}function u3(){return rc(d3)}function f3(){return nx()}function p3(){return K.getState().closeMainSurfaces()}function m3(){return ed(!1)}function h3(){return m3}function g3(){return K.getState().closeMainSurfaces()}function x3(){const t=g3,e=nt.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,i=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function b3(){return K.getState().setCommandPaletteOpen(!1)}function w3(){return K.getState().setHelpDialogOpen(!1)}function y3(){return K.getState().setProjectActionsDialogOpen(!1)}function v3(){return K.getState().setOpenCodeStatusDialogOpen(!1)}function S3(){return dn.getState().closeAccessDialog()}function k3(){return dn.getState().closeApplyDialog()}function j3(){return dn.getState().closeSetupOutputDialog()}function C3(){return K.getState().setOpenGuestPage(null)}const Ti="openchamber_requests_in_flight",ju=1e3,T3=300*1e3,eo=Math.ceil(T3/ju),N3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ti)==="1"}catch{return!1}},Cu=()=>({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 E3=1;const P3=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},I3=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Tu=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,o)=>r-o),s},En=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},R3=()=>{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 s=async(r,o)=>{const i=E3++;P3(i,Date.now());try{return await e(r,o)}finally{I3(i)}};window.fetch=s},_l=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Wn=t=>{t.length>eo&&t.splice(0,t.length-eo)},D3=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Tu(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(En(e,50)),t.p90Samples.push(En(e,90)),t.p99Samples.push(En(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,Wn(t.samples),Wn(t.p50Samples),Wn(t.p90Samples),Wn(t.p99Samples),Wn(t.maxSamples),t.lastSampleAt=Date.now()},_3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(D3,ju))},Al=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Ol=t=>{if(!(typeof window>"u"))try{if(t){Al(),_l(),window.localStorage.setItem(Ti,"1"),window.__openchamberRequestsInFlight__=Cu(),R3(),_3();return}window.localStorage.removeItem(Ti),Al(),_l(),delete window.__openchamberRequestsInFlight__}catch{}},v5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Cu();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},S5=()=>{if(typeof window>"u")return Ml();const t=window.__openchamberRequestsInFlight__;if(!N3()||!t)return Ml();const e=Tu(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:En(e,50),ageP90:En(e,90),ageP99:En(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:eo}},Ml=()=>({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:eo}),A3=(t,e,s)=>u1(t.filter(r=>!td(r)&&!r.parentID),e,s),O3=()=>A3(ts.getState().activeSessions,yr.getState().ids,Yi.getState().rankById??f1),M3=(t,e,s)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=s>0?0:t.length-1;return r>=0&&(o=(r+s+t.length)%t.length),t[o]},F3=()=>{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()??"":""},L3=async()=>{const t=F3()||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")},Fl="openchamber:menu-action",Ll="openchamber:check-for-updates",B3=t=>{const e=Ue.c(24),{t:s}=lt(),r=nt($3),o=K(z3),i=K(W3),a=K(U3),d=K(V3),u=K(H3),l=K(K3),f=K(q3),m=vc(G3),{setThemeMode:p}=oo(),h=c.useRef(!1),x=K(Z3);let g,w;e[0]!==x?(g=()=>{Br()&&Ys("desktop_set_menu_shortcuts",{shortcuts:p1(x)}).catch(X3)},w=[x],e[0]=x,e[1]=g,e[2]=w):(g=e[1],w=e[2]),c.useEffect(g,w);let b;e[3]!==m?(b=()=>{h.current||(h.current=!0,m().then(Y3).finally(()=>{h.current=!1}))},e[3]=m,e[4]=b):b=e[4];const j=b,y=J3;let E;e[5]!==u?(E=S=>{const k=nt.getState().currentSessionId,N=M3(O3(),k,S);N&&(u(!1),nt.getState().setCurrentSession(N.id,Bs(N)))},e[5]=u,e[6]=E):E=e[6];const A=E,R=Q3;let _;e[7]!==A||e[8]!==t||e[9]!==r||e[10]!==f||e[11]!==i||e[12]!==u||e[13]!==l||e[14]!==p||e[15]!==s||e[16]!==o||e[17]!==a||e[18]!==d?(_=S=>{e:switch(S){case"about":{f(!0);break e}case"settings":{l(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{u(!1);const k=nt.getState(),N=zt.getState().currentDirectory;r(k.currentSessionId&&N?{directoryOverride:N}:void 0);break e}case"new-worktree-session":{u(!1),g1();break e}case"change-workspace":{y();break e}case"toggle-right-sidebar":{const k=zt.getState().currentDirectory;if(!k)break e;const N=K.getState(),$=rs(k),B=N.contextPanelByDirectory[$],D=B?of(B.tabs,N.contextSurfaceZones,"right",er(B,"right").activeTabId):null;B?.isOpen?N.closeContextPanel($):D?N.setActiveContextPanelTab($,D):N.openContextSurface($,"git");break e}case"open-right-sidebar-git":{const k=zt.getState().currentDirectory;if(!k)break e;K.getState().openContextSurface(rs(k),"git");break e}case"open-right-sidebar-files":{const k=zt.getState().currentDirectory;if(!k)break e;K.getState().openContextSurface(rs(k),"file");break e}case"toggle-terminal":{const k=zt.getState().currentDirectory;if(!k)break e;K.getState().openContextSurface(rs(k),"terminal");break e}case"toggle-context-panel-expanded":{h1(zt.getState().currentDirectory);break e}case"copy":{const k=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(k)||L3();break e}case"theme-light":{p("light");break e}case"theme-dark":{p("dark");break e}case"theme-system":{p("system");break e}case"add-selection-to-chat":{m1();break e}case"toggle-sidebar":{d();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{Ba(-1);break e}case"go-forward":{Ba(1);break e}case"previous-session":{A(-1);break e}case"next-session":{A(1);break e}case"previous-project":{R(-1);break e}case"next-project":{R(1);break e}case"help-dialog":{a();break e}case"download-logs":Jc().catch(()=>{Oe.error(s("openCodeStatusDialog.toast.collectFailed"))})}},e[7]=A,e[8]=t,e[9]=r,e[10]=f,e[11]=i,e[12]=u,e[13]=l,e[14]=p,e[15]=s,e[16]=o,e[17]=a,e[18]=d,e[19]=_):_=e[19];const L=_;let v,C;e[20]!==L||e[21]!==j?(v=()=>{const S=N=>{const $=N.detail;$&&L($)},k=()=>{j()};return window.addEventListener(Fl,S),window.addEventListener(Ll,k),()=>{window.removeEventListener(Fl,S),window.removeEventListener(Ll,k)}},C=[L,j],e[20]=L,e[21]=j,e[22]=v,e[23]=C):(v=e[22],C=e[23]),c.useEffect(v,C)};function $3(t){return t.openNewSessionDraft}function z3(t){return t.toggleCommandPalette}function W3(t){return t.setCommandPaletteOpen}function U3(t){return t.toggleHelpDialog}function V3(t){return t.toggleSidebar}function H3(t){return t.setSessionSwitcherOpen}function K3(t){return t.setSettingsDialogOpen}function q3(t){return t.setAboutDialogOpen}function G3(t){return t.checkForUpdates}function Z3(t){return t.shortcutOverrides}function X3(t){console.warn("[menu-actions] failed to update menu shortcuts",t)}function Y3(){const{available:t,error:e}=vc.getState();if(e){Oe.error("Failed to check for updates",{description:e});return}t||Oe.success("You are on the latest version")}function J3(){lr.requestDirectoryDialog()}function Q3(t){const{activeProjectId:e,projects:s,setActiveProject:r}=Gt.getState();if(s.length===0)return;const o=s.findIndex(d=>d.id===e);let i=t>0?0:s.length-1;o>=0&&(i=(o+t+s.length)%s.length);const a=s[i];a&&r(a.id)}const Bl="openchamber:install-extension",Nu=t=>vx({source:t,confirmed:!1}),e4=()=>{const t=Ue.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(n4,e)};function t4(t){const{url:e}=t.detail??{};typeof e=="string"&&e&&Nu(e)}function s4(t){return t.forEach(Nu)}function n4(){const t=t4;return window.addEventListener(Bl,t),af().then(s4),()=>window.removeEventListener(Bl,t)}const $l=(t,{isAdmitted:e,isPlaced:s,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||td(t)?!1:s||o.pinned&&r||o.work&&Mi(t),r4="openchamber:tray-action",o4=5e3,i4=500,a4=20,zl=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Wl=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Eu=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},Pu=t=>t.title.trim()||"Question",l4=new Set,c4=(t,e)=>j1(t,e,l4,Yi.getState().rankById),d4=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},u4=(t,e,s,r,o)=>{if(!t)return"";const i=gr(s,r,t),a=e.project?.name,d=i?.label?.trim()||a?.trim()||d4(t),u=Vr(t);let l=u&&o.get(u)||"";if(!l){for(const[f,m]of Dn.getState().directories)if(Vr(f)===u){l=m.status?.current??"";break}}if(!l)for(const f of r.values()){const m=u?Wr(f,u):void 0;if(m?.branch){l=m.branch;break}}return l?`${d} · ${l}`:d},f4=()=>{const{dictionary:t}=uf.getState(),e=(l,f)=>ff(t,l,f),{results:s,dropdownProviderIds:r,displayMode:o,extensionProviders:i}=ld.getState(),a=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:a,groups:[]};const d=new Map(s.map(l=>[l.providerId,l])),u=[];for(const l of C1(i)){if(!r.includes(l.id))continue;const f=d.get(l.id);if(!f||f.configured!==!0)continue;const m=[];for(const[h,x]of Object.entries(f.usage?.windows??{})){const g=a==="remaining"?x.remainingPercent:x.usedPercent;m.push({label:N1(h),value:T1(x,g,e)})}const p=!f.ok&&f.error?f.error:m.length===0?"No rate limits reported":null;u.push({provider:l.name,rows:m,status:p})}return{mode:a,groups:u}},p4=async()=>{try{if(no())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=lf();if(e&&fa(e,t))return"Local OpenChamber";const r=(await Di()).hosts.find(o=>e?fa(e,ic(o)):!1);return r?.label?.trim()?cf(r.label.trim()):"Instance"}catch{return""}},m4=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=ai()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[i,a]of o.children.entries()){const d=a.getState();d.vcs?.branch&&e.set(Vr(i)??i,d.vcs.branch);for(const u of d.session)u?.id&&r.set(u.id,u.title);for(const[u,l]of Object.entries(d.session_status??{})){const f=l?.type,m=f==="busy"?"busy":f==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,m)}for(const[u,l]of Object.entries(d.permission??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||u;s.push({kind:"permission",id:f.id,sessionId:m,sessionTitle:"",label:Eu(f),directory:i,canSave:cd(f.save)})}for(const[u,l]of Object.entries(d.form??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||u;s.push({kind:"form",id:f.id,sessionId:m,sessionTitle:"",label:Pu(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},h4=(t,e)=>{const s=ts.getState().activeSessions,r=y1(s),o=v=>r.descendantsOf(v,"active").map(C=>C.id),i=Gt.getState().projects,a=nt.getState().availableWorktreesByProject,d=yr.getState().ids,u=(v,C)=>{const S=Bs(v),k=$a(S,i,a);return so(S)||v.projectID===df?$l(v,{isAdmitted:k,isPlaced:C.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):$l(v,{isAdmitted:k,isPlaced:ec(S)||gr(i,a,S)!==null,isPinned:Xi(d,v.directory,v.id),zones:C})},l=oc.getState(),f={chats:l.showChatsSection,pinned:l.showPinnedSection,work:K.getState().sessionWorkEnabled&&l.showWorkSection},m={chats:!0,pinned:!0,work:!0},p=v1(ii.getState().activeSessionIds,[sd.getState().runningSessionIds,nd.getState().sessionIds,rd.getState().sessionIds,od.getState().bySession.keys(),id.getState().bySession.keys()]),h=v=>k1(v)&&!p.has(v.id),x=K.getState().dockBadgeEnabled?s.filter(v=>h(v)&&u(v,f)):[],g=x.length,w=x.sort((v,C)=>(C.time.idle??C.time.updated)-(v.time.idle??v.time.updated)||v.id.localeCompare(C.id)).slice(0,10).map(v=>({id:v.id,title:v.title,directory:Bs(v)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:w};const b=m4(),j=new Map(b.titleById);for(const v of s)v?.id&&v.title&&j.set(v.id,v.title);const y=ii.getState().statusById,E=v=>{const C=b.statusById.get(v);return C&&C!=="idle"?C:y.get(v)?.status.type??C??"idle"},A=v=>{const C=v.map(S=>E(S));return C.includes("busy")?"busy":C.includes("retry")?"retry":"idle"},R=s.filter(v=>v?.id&&!v.parentID).filter(v=>u(v,m)).slice().sort(c4).slice(0,a4).map(v=>{const C=[v.id,...o(v.id)],S=Bs(v)??"";return{id:v.id,title:v.title||"Untitled session",status:A(C),branch:S?b.branchByDirectory.get(S)??"":"",unseen:h(v)?1:0,hasError:h(v)&&S1(v),directory:S,subtitle:u4(S,v,i,a,b.branchByDirectory)}}),_=b.approvals.map(v=>({...v,sessionTitle:j.get(v.sessionId)||""})),L=new Set(_.map(v=>v.id));for(const[v,C]of ad.getState().bySession){const S=j.get(v)||"";for(const k of C.permissions)L.has(k.id)||(L.add(k.id),_.push({kind:"permission",id:k.id,sessionId:v,sessionTitle:S,label:Eu(k),directory:C.directory,canSave:cd(k.save)}));for(const k of[...C.forms,...C.pages])L.has(k.id)||(L.add(k.id),_.push({kind:"form",id:k.id,sessionId:v,sessionTitle:S,label:Pu(k),directory:C.directory,canSave:!1}))}return{sessions:R,approvals:_.filter(v=>$a(v.directory,i,a)),instanceName:t,usage:f4(),dockBadgeCount:g,dockUnreadSessions:w}},g4=()=>{c.useEffect(()=>{if(!zl()||!Br())return;const t=Wl();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const N=h4(o,t),$=JSON.stringify(N);$!==s&&(s=$,Ys("desktop_tray_update",N))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},i4))},d=ts.subscribe(()=>a()),u=ii.subscribe(()=>a()),l=sd.subscribe(()=>a()),f=nd.subscribe(()=>a()),m=rd.subscribe(()=>a()),p=od.subscribe(()=>a()),h=id.subscribe(()=>a()),x=K.subscribe((N,$)=>{(N.dockBadgeEnabled!==$.dockBadgeEnabled||N.sessionWorkEnabled!==$.sessionWorkEnabled)&&a()}),g=Gt.subscribe(()=>a()),w=nt.subscribe(()=>a()),b=yr.subscribe(()=>a()),j=oc.subscribe((N,$)=>{(N.showChatsSection!==$.showChatsSection||N.showPinnedSection!==$.showPinnedSection||N.showWorkSection!==$.showWorkSection)&&a()}),y=()=>{e=!0,r!==null&&window.clearTimeout(r),d(),u(),l(),f(),m(),p(),h(),x(),g(),w(),b(),j()};if(!t)return i(),y;p4().then(N=>{e||(o=N,i())});const E=new Map,A=()=>{if(e)return;let N;try{N=ai()}catch{return}const $=new Set;for(const[B,D]of N.children.entries())$.add(B),E.has(B)||E.set(B,D.subscribe(()=>a()));for(const[B,D]of E)$.has(B)||(D(),E.delete(B))};let R=null;try{R=ai().subscribeRegistry(()=>{A(),a()})}catch{}A();const _=Dn.subscribe(()=>a()),L=ad.subscribe(()=>a()),v=Yi.subscribe(()=>a()),C=ld.subscribe(()=>a()),S=Bt.subscribe((N,$)=>{N.isInitialized&&!$.isInitialized&&Lo(!0)});Lo(!0);const k=window.setInterval(()=>{A(),i()},o4);return i(),()=>{y(),window.clearInterval(k),_(),L(),v(),C(),S(),R?.();for(const N of E.values())N();E.clear()}},[]),c.useEffect(()=>{if(!zl()||!Br())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=i=>{switch(i.type){case"mark-all-read":b1().then(()=>w1()).catch(()=>{});break;case"menu-opened":Wl()&&Lo();break;case"respond-permission":x1(i.sessionId,i.id,i.response).catch(()=>{Oe.error("Failed to respond to permission request")});break}};let r=null,o=!1;return e(r4,i=>{const a=i?.payload;!a||typeof a!="object"||typeof a.type!="string"||s(a)}).then(i=>{if(o){i();return}r=i,Ys("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=!0;try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},x4=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,b4=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,w4=t=>{t.kind!=="plugin"||!t.title||Oe.info(t.title,{id:b4(t.kind,t.title,t.body,t.tag),description:t.body})},y4=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,v4=t=>{const e=Ue.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(Ps()||!ac()||!globalThis.window))return _n(S4)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function S4(t){if(t.type!=="notification")return;const e=K.getState();if(!e.nativeNotificationsEnabled)return;const s=x4();if(y4(t.payload,s)){w4(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;nc()?.notifications?.notifyAgentCompletion(t.payload)}const k4=()=>{const t=Ue.c(3),{t:e}=lt();let s,r;t[0]!==e?(s=()=>_n(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=Bt.getState().providers,d=u=>a.find(l=>l.id===u);if(i.kind==="account"){const u=d(i.providerId)?.name||i.providerId;Oe.info(i.fromAccount?e("chat.limitFailover.toast.account",{provider:u,from:i.fromAccount,to:i.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:u,to:i.toAccount}));return}Oe.info(e("chat.limitFailover.toast.model",{model:za(d(i.providerId),i.modelId),fallback:za(d(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)},Ul="relay-limit-reached",j4=()=>{const t=Ue.c(3),{t:e}=lt();let s,r;t[0]!==e?(s=()=>{const o=()=>{Oe.error(e("relayConnection.limitReached.title"),{id:Ul,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:C4}})};return pa(lc()?.getStatus())&&o(),pf(a=>{pa(a)?o():(a.state==="connected"||a.state==="idle")&&Oe.dismiss(Ul)})},r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)};function C4(){return lc()?.retry()}const Vl=()=>{mf()||(E1(),P1(Ap.map(t=>t.id)))},T4=(t,e)=>{const s=Ue.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(Vl,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(Vl,3e3);return()=>clearTimeout(i)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],c.useEffect(r,o)},Hl="pwa-install-toast-shown",Kl="pwa-install-toast-dismissed",N4=()=>{const t=Ue.c(6),{browserTab:e}=Op(),{t:s}=lt(),r=c.useRef(s);let o,i;t[0]!==s?(o=()=>{r.current=s},i=[s],t[0]=s,t[1]=o,t[2]=i):(o=t[1],i=t[2]),c.useEffect(o,i);let a,d;t[3]!==e?(a=()=>{if(typeof window>"u"||!ac()||!e)return;let u=null,l=null;const f=()=>{l!==null&&(Oe.dismiss(l),l=null)},m=async()=>{if(!u)return;const x=u;u=null,f(),await x.prompt();const{outcome:g}=await x.userChoice;g==="accepted"&&Oe.success(r.current("pwa.installPrompt.started"))},p=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),u=g;const w=ma(),b=hf();Mp({dismissed:w.getItem(Kl),sessionShown:b.getItem(Hl),hasActiveToast:l!==null})&&(b.setItem(Hl,"true"),l=Oe.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{ma().setItem(Kl,"true"),f()}}}))},h=()=>{u=null,f(),Oe.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",h)}},d=[e],t[3]=e,t[4]=a,t[5]=d):(a=t[4],d=t[5]),c.useEffect(a,d)},Iu=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,E4=()=>{us.setState({byRoot:{},runtimeSnapshots:{}});const t=K.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const s of Ri)t.closeContextZone(e,s)},P4=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Ru=async(t,e)=>{const s=(await Di()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await wf(s.id,e);return}const r=yf(ic(s));if(!r)throw new Error("host-not-found");vf({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:Sf(s),sshForwarded:s.sshForwarded===!0})},I4=async t=>{const e=await Di(),s=await xf(t,e.hosts);await bf({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await Ru(s.hostId,{reconnectActive:!0})},R4=async t=>{const e=await gf();for(const s of e)try{s.type==="pairing"?await I4(s.link):await Ru(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(P4(o))}},Ni="project-config-invalid",D4=()=>{const t=Ue.c(9),{t:e}=lt(),s=Bt(_4);let r;t[0]!==s?(r=p=>p.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=Bt(r),[i,a]=$t.useState(!1);let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const p=Bt.getState(),h=p.activeDirectoryKey;a(!0),Promise.all([p.loadProviders({directory:h,source:"projectConfigError:retry"}),p.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=d):d=t[2];const u=d;let l,f;t[3]!==o||t[4]!==i||t[5]!==e?(l=()=>{if(!o){Oe.dismiss(Ni);return}Oe.error(e("projectConfigError.toast.title"),{id:Ni,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx(as,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),i||u()}}})},f=[o,i,u,e],t[3]=o,t[4]=i,t[5]=e,t[6]=l,t[7]=f):(l=t[6],f=t[7]),$t.useEffect(l,f);let m;return t[8]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[8]=m):m=t[8],$t.useEffect(O4,m),null};function _4(t){return t.activeDirectoryKey}function A4(){Oe.dismiss(Ni)}function O4(){return A4}const M4="\x1B",F4=new RegExp(`${M4}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Pr=Ss().transform(t=>t.replace(F4,"").trim()).nullish(),L4=Js({isOpenCodeReady:cr().optional(),openCodeRunning:cr().optional(),lastOpenCodeError:Pr,opencodeBinaryResolved:Pr,lastOpenCodeLaunchDiagnostics:Js({sourceBinary:Pr,binary:Pr}).nullish()}),B4=async(t,e=zs)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=L4.parse(await s.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}},$4=(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"}},z4=Js({openchamberVersion:Ss()}),W4=async(t,e=zs)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=z4.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},U4=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function V4({version:t}){const{t:e}=lt(),[s,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const d=await Lp();r(d.available&&!d.installBlocked?{kind:"available",info:d}:{kind:"manual",info:d,error:null})}catch(d){r({kind:"manual",info:null,error:d instanceof Error?d.message:null})}},i=s.kind==="manual"?s:null,a=i?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(ut,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(ce,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&n.jsx("p",{dir:"auto",className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="opencode-version"?n.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:e("updateDialog.openCodeTooOld",{version:i.info.version||"",required:i.info.requiredOpenCodeVersion||"",current:i.info.openCodeVersion||""})}):i.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{dir:"ltr",className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),n.jsx(Fp,{open:s.kind==="available",onOpenChange:d=>{d||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const ql=mr(()=>Ft(()=>import("./OnboardingScreen-Dlbi5e0G.js"),__vite__mapDeps([267,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}))),H4=()=>Ft(()=>import("./AboutDialog-Byc63m0u.js"),__vite__mapDeps([268,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,244])).then(t=>t.AboutDialog),K4=()=>Ft(()=>import("./MemoryDebugPanel-MrH6vI6i.js"),__vite__mapDeps([269,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,209,210,211,212])).then(t=>t.MemoryDebugPanel),q4=()=>{const t=Ue.c(6),e=K(J4),s=K(Q4);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const o=ho(e,H4,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==s?(i=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=i):i=t[5],i},G4=t=>{const e=Ue.c(3),{onClose:s}=t,r=ho(!0,K4,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},Z4=t=>{const e=Ue.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=lt(),[i,a]=c.useState(null);let d,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const v=new AbortController,C=qt(),S=setTimeout(()=>v.abort(),5e3);return B4(v.signal).then(k=>{!v.signal.aborted&&qt()===C&&a(k)}).catch(e5).finally(()=>clearTimeout(S)),()=>{v.abort(),clearTimeout(S)}},u=[],e[0]=d,e[1]=u):(d=e[0],u=e[1]),c.useEffect(d,u);const[l,f]=c.useState(null);let m,p;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const v=new AbortController,C=qt(),S=setTimeout(()=>v.abort(),5e3);return W4(v.signal).then(k=>{v.signal.aborted||qt()!==C||f(k&&U4(k)?k:null)}).catch(t5).finally(()=>clearTimeout(S)),()=>{v.abort(),clearTimeout(S)}},p=[],e[2]=m,e[3]=p):(m=e[2],p=e[3]),c.useEffect(m,p);const h=Bt(s5),x=i?null:h?.message??null;if(l){let v;e[4]!==l?(v=n.jsx(V4,{version:l}),e[4]=l,e[5]=v):v=e[5];let C;e[6]!==r||e[7]!==o?(C=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=C):C=e[8];let S;e[9]!==r||e[10]!==s||e[11]!==C?(S=n.jsx(ut,{type:"button",variant:"outline",onClick:s,disabled:r,children:C}),e[9]=r,e[10]=s,e[11]=C,e[12]=S):S=e[12];let k;return e[13]!==v||e[14]!==S?(k=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[v,S]})}),e[13]=v,e[14]=S,e[15]=k):k=e[15],k}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let w;e[18]!==g?(w=n.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=w):w=e[19];let b;e[20]!==i||e[21]!==h||e[22]!==o?(b=o($4(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=b):b=e[23];let j;e[24]!==b?(j=n.jsx("p",{className:"typography-markdown text-muted-foreground",children:b}),e[24]=b,e[25]=j):j=e[25];let y;e[26]!==w||e[27]!==j?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[w,j]}),e[26]=w,e[27]=j,e[28]=y):y=e[28];let E;e[29]!==x||e[30]!==o?(E=x&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),n.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]=E):E=e[31];let A;e[32]!==i||e[33]!==o?(A=i&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),n.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]=A):A=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]!==s||e[40]!==R?(_=n.jsx(ut,{type:"button",onClick:s,disabled:r,children:R}),e[38]=r,e[39]=s,e[40]=R,e[41]=_):_=e[41];let L;return e[42]!==E||e[43]!==A||e[44]!==_||e[45]!==y?(L=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[y,E,A,_]})}),e[42]=E,e[43]=A,e[44]=_,e[45]=y,e[46]=L):L=e[46],L};function X4({apis:t}){e4(),c.useEffect(()=>I1(),[]),c.useEffect(()=>{kf("App:mounted"),jf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Bt(F=>F.initializeApp),s=Bt(F=>F.isInitialized),r=Bt(F=>F.isConnected),o=Bt(F=>F.providersLoaded),i=Bt(F=>F.agentsLoaded),a=Bt(F=>F.loadProviders),d=Bt(F=>F.loadAgents),u=nt(F=>F.error),l=nt(F=>F.clearError),f=zt(F=>F.currentDirectory),m=zt(F=>F.isSwitchingDirectory),[p,h]=c.useState(!1),x=un(F=>F.refreshAll),g=Jl(F=>F.refresh),[w,b]=c.useState(()=>t.runtime.isVSCode),[j,y]=c.useState(!1),[E,A]=c.useState(0),[R,_]=c.useState(0),[L,v]=c.useState(!1),C=K(F=>F.wideChatLayoutEnabled),S=K(F=>F.mobileKeyboardMode),k=c.useMemo(()=>Ps(),[]),[N,$]=c.useState(()=>ha()),[B,D]=c.useState(()=>{const F=Po();return F!==null?ga({isDesktopShell:!0,bootOutcome:F}):null}),W=c.useRef(!1),{t:H}=lt(),U=c.useRef(!1);c.useEffect(()=>{if(!s||N!=="valid"||U.current)return;const F=Po();F?.target!=="local"||F.status!=="ok"||!F.sshStartupFallbackHostId||(U.current=!0,Oe.error(H("desktopHostSwitcher.startup.title"),{description:H("desktopHostSwitcher.startup.fellBackToLocal")}))},[N,s,H]);const se=c.useRef(!1);c.useEffect(()=>{!s||!Iu()||se.current||(se.current=!0,Oe.info(H("desktopSafeStart.title"),{description:H("desktopSafeStart.description"),duration:1/0}))},[s,H]),c.useEffect(()=>(xa(p),Ol(p),()=>{xa(!1),Ol(!1)}),[p]),c.useEffect(()=>{Cf(S)},[S]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>rc(F=>{$p(F)&&zp(F),_(re=>re+1),y(!1),A(re=>re+1)}),[]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",C),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[C]),c.useEffect(()=>(ba(t),()=>ba(null)),[t]),c.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:!0}),R1(t.trackers))},[t.sourceControl,t.trackers,r,x,g,R]),D1();const z=N==="valid",Q=B?.screen==="main";c.useEffect(()=>{if(!Tf({isDesktopShell:k,bootOutcomeKnown:z}))return;_1();const F=setTimeout(()=>{const re=document.getElementById("initial-loading");re&&(re.classList.add("fade-out"),setTimeout(()=>{re.remove()},300))},150);return()=>clearTimeout(F)},[k,z]),c.useEffect(()=>{if(!k||N!=="malformed")return;const F=document.getElementById("initial-loading");F&&(F.textContent="Desktop startup failed — please restart the app.")},[k,N]),c.useEffect(()=>{w||e()},[e,w]),c.useEffect(()=>{if(w||s)return;let F=!0,re,q=0;const ge=10,Z=1e3,de=async()=>{if(!F)return;if(q>=ge){y(!0);return}const Se=Bt.getState();if(Se.isInitialized){y(!1);return}q+=1,await Se.initializeApp();const ue=Bt.getState();if(!F)return;if(ue.isInitialized){y(!1);return}if(q>=ge){y(!0);return}const ke=Math.min(Z*Math.pow(2,q-1),4e3);re=setTimeout(de,ke)};return re=setTimeout(de,Z),()=>{F=!1,re&&clearTimeout(re)}},[E,s,w]),c.useEffect(()=>{s&&y(!1)},[s]),c.useEffect(()=>{if(!j)return;const F=document.getElementById("initial-loading");F&&(F.classList.add("fade-out"),setTimeout(()=>{F.remove()},300))},[j]),c.useEffect(()=>{if(w||!r||o&&i)return;let F=!0,re=0;const q=15,ge=async()=>{const de=Bt.getState();if(!(de.providersLoaded&&de.agentsLoaded))try{de.providersLoaded||await a({source:"startupRecovery"}),Bt.getState().agentsLoaded||await d({source:"startupRecovery"})}catch{}};ge();const Z=setInterval(()=>{if(F){if(++re>=q){clearInterval(Z);return}ge()}},2e3);return()=>{F=!1,clearInterval(Z)}},[r,w,d,a,o,i]),c.useEffect(()=>{m||w||r&&ti.setDirectory(f)},[f,m,r,w]),c.useEffect(()=>{if(typeof window>"u")return;const F=re=>{const q=re.detail,ge=typeof q?.sessionId=="string"?q.sessionId.trim():"";if(!ge)return;const Z=typeof q?.directory=="string"&&q.directory.trim().length>0?q.directory.trim():null,de=typeof q?.messageId=="string"&&q.messageId.trim()||null;wa(ge,String(q?.runtimeKey??"").trim(),de)||Wa(ge,{directory:Z,messageId:de,requireKnownSession:q?.requireKnownSession===!0})};return window.addEventListener("openchamber:open-session",F),Nf().then(re=>{for(const q of re)wa(q.sessionId,q.runtimeKey,q.messageId)||(q.requireKnownSession?Wa(q.sessionId,{messageId:q.messageId,requireKnownSession:!0}):A1(q.sessionId,q.messageId))}),()=>window.removeEventListener("openchamber:open-session",F)},[]),c.useEffect(()=>{if(!Ps())return;const F=()=>{R4(re=>{Oe.error(H(re==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":re==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",F),F(),()=>window.removeEventListener("openchamber:host-actions-ready",F)},[H]);const ie=c.useRef({attempt:null,running:!1,done:!1});c.useLayoutEffect(()=>{const F=ie.current;F.attempt||(F.attempt=Wp({selectNow:!Up().sessionId}))},[]),c.useEffect(()=>{const F=ie.current,re=()=>{const q=F.attempt;if(!q||F.running||F.done)return;const ge=Bt.getState().isInitialized;F.running=!0,q().then(Z=>{if(F.running=!1,Z!=="failed"||ge){F.done=!0;return}Bt.getState().isInitialized&&re()})};re()},[s]),c.useEffect(()=>{if(typeof window>"u")return;const F=()=>{Ys("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Qo()})};return window.addEventListener("openchamber:open-mini-chat",F),()=>window.removeEventListener("openchamber:open-mini-chat",F)},[]),c.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const re=nt.getState().currentSessionId;re&&Yc(re)};return window.addEventListener("focus",F),()=>window.removeEventListener("focus",F)},[]),c.useEffect(()=>{if(typeof window>"u")return;const F=re=>{const q=re.detail,ge=typeof q?.directory=="string"&&q.directory.trim().length>0?q.directory.trim():null,Z=typeof q?.projectId=="string"&&q.projectId.trim().length>0?q.projectId.trim():null,de=!!(ge||Z);K.getState().setSessionSwitcherOpen(!1),nt.getState().openNewSessionDraft({target:de?"project":"chat",selectedProjectId:de?Z:null,directoryOverride:de?ge:null,preserveDirectoryOverride:!!ge})};return window.addEventListener("openchamber:open-draft-session",F),()=>window.removeEventListener("openchamber:open-draft-session",F)},[]),c.useEffect(()=>{typeof window>"u"||!s||m||W.current||(W.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,m]),O1(),v4(),Vp(f||null),Hp(),Kp(t.sourceControl),qp(t.trackers),Gp(),Zp(),Xp(),k4(),M1(),Yp(),j4(),T4(s&&r,R),N4(),F1(),rx(),Jp();const O=c.useCallback(()=>{h(F=>!F)},[]);B3(O),g4(),ox(!0),c.useEffect(()=>{const F=()=>h(re=>!re);return window.addEventListener("openchamber:memory-debug-toggle",F),()=>window.removeEventListener("openchamber:memory-debug-toggle",F)},[]),c.useEffect(()=>{u&&setTimeout(()=>l(),5e3)},[l,u]),c.useEffect(()=>{if(!k||N!=="not-injected")return;let F=!1,re=0;const q=200,ge=2e3,Z=50,de=()=>{if(F)return;re++;const Se=ha();if(Se!=="not-injected"){if(F=!0,$(Se),Se==="valid"){const ke=Po();ke&&D(ga({isDesktopShell:!0,bootOutcome:ke}))}return}const ue=Math.min(q*Math.pow(1.1,re),ge);if(re>=Z){const ke=document.getElementById("initial-loading");ke&&!ke.textContent?.includes("taking longer")&&(ke.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(de,ue)};return window.setTimeout(de,q),()=>{F=!0}},[k,N]);const ne=c.useCallback(async()=>{if(Ef({isDesktopShell:Ps(),isDesktopLocalOriginActive:no()})){await Pf();return}window.location.reload()},[]),V=c.useCallback(async()=>{if(!L){y(!1),v(!0);try{await Bt.getState().initializeApp()}finally{v(!1)}Bt.getState().isInitialized||A(F=>F+1)}},[L]),J=F=>{if(F.screen==="recovery")return F.variant};if(k&&B&&B.screen!=="main"){if(B.screen==="chooser")return n.jsx(Xt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(ql,{mode:"first-launch",localAvailable:B.localAvailable!==!1,onCliAvailable:ne,onChooseRemote:()=>{}})})})});const F=J(B),re=B.screen==="recovery"&&"url"in B?B.url:void 0,q=B.screen==="recovery"&&"hostId"in B?B.hostId:void 0;return n.jsx(Xt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(ql,{mode:"recovery",recoveryVariant:F,recoveryHostUrl:re,recoveryHostLabel:void 0,recoveryHostId:q,localAvailable:B.localAvailable!==!1,onCliAvailable:ne})})})})}return j&&!s&&!w?n.jsx(Xt,{children:n.jsx(Z4,{onRetry:()=>{V()},isRetrying:L},R)}):n.jsx(Xt,{children:n.jsx(L1,{sdk:ti.getSdkClient(),directory:f||"",children:n.jsx(B1,{apis:t,children:n.jsx(Qp,{children:n.jsx($1,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:k?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(z1,{backgroundWorkEnabled:!0}),n.jsx(em,{}),n.jsx(D4,{}),n.jsx(zj,{}),k?n.jsx(tm,{ready:z&&Q}):null,n.jsx(W1,{}),n.jsx(U1,{}),n.jsx(V1,{}),n.jsx(H1,{}),n.jsx(K1,{}),n.jsx(sm,{}),n.jsx(q4,{}),p&&n.jsx(G4,{onClose:()=>h(!1)})]})})})})},R)})}function Y4(t){const e=Ue.c(2);let s;return e[0]!==t?(s=n.jsx(Bp,{children:n.jsx(X4,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function J4(t){return t.isAboutDialogOpen}function Q4(t){return t.setAboutDialogOpen}function e5(){}function t5(){}function s5(t){return t.lastInitFailure}const n5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();If();Iu()&&E4();nm();rm();Rf().then(()=>{q1().catch(t=>{console.error("[main] settings init failed:",t)}),G1(),Z1(),X1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Du=document.getElementById("root");if(!Du)throw new Error("Root element not found");Y1();_u.createRoot(Du).render(n.jsx($t.StrictMode,{children:n.jsx(J1,{children:n.jsx(Q1,{children:n.jsx(ex,{children:n.jsx(tx,{children:n.jsx(Y4,{apis:n5})})})})})}));const k5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Za as P,yb as a,ej as b,nj as c,rj as d,oj as e,uj as f,S5 as g,pj as h,ij as i,aj as j,lj as k,cj as l,A3 as m,tw as n,tj as o,dj as p,k5 as q,v5 as r,sj as s,jd as u};
|
|
498
|
+
`),Q0=t=>{const e=Ue.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:d}=lt();if(s.length===0)return null;let u;e[0]!==d?(u=d("contextPanel.browser.history.label"),e[0]=d,e[1]=u):u=e[1];let l;if(e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==d){let m;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==d?(m=(p,h)=>n.jsxs("div",{role:"option","aria-selected":h===r,className:Ze("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(p.url)},onPointerEnter:()=>a(h),children:[n.jsx(ce,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||ro(p.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button",className:Ze("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":d("contextPanel.browser.history.forget"),onPointerDown:x=>{x.preventDefault(),x.stopPropagation(),i(p.url)},children:n.jsx(ce,{name:"close",className:"size-3","aria-hidden":"true"})})}),n.jsx(jt,{sideOffset:6,children:d("contextPanel.browser.history.forget")})]})]},p.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=d,e[14]=m):m=e[14],l=s.map(m),e[2]=r,e[3]=s,e[4]=i,e[5]=a,e[6]=o,e[7]=d,e[8]=l}else l=e[8];let f;return e[15]!==u||e[16]!==l?(f=n.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":u,children:l}),e[15]=u,e[16]=l,e[17]=f):f=e[17],f},gs=t=>{const e=Ue.c(17),{icon:s,label:r,onClick:o,disabled:i,pressed:a}=t,d=a?"secondary":"ghost",u=a&&"text-foreground";let l;e[0]!==u?(l=Ze("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",u),e[0]=u,e[1]=l):l=e[1];let f;e[2]!==s?(f=n.jsx(ce,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let m;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==d||e[9]!==l||e[10]!==f?(m=n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex shrink-0",children:n.jsx(ut,{type:"button",variant:d,size:"xs",className:l,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]=d,e[9]=l,e[10]=f,e[11]=m):m=e[11];let p;e[12]!==r?(p=n.jsx(jt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let h;return e[14]!==m||e[15]!==p?(h=n.jsxs(kt,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=h):h=e[16],h},Jd=t=>{const e=Ue.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:d,onBack:u,onForward:l,onReload:f,onOpenExternal:m,canOpenExternal:p,canGoBack:h,canGoForward:x,isLoading:g,onAnnotate:w,onOpenDevTools:b,isAnnotating:j,onHardReload:y,onZoomIn:E,onZoomOut:A,onZoomReset:R,zoomPercent:_,onClearCookies:L,onClearCache:v,onToggleDeviceBar:C,isDeviceBarOpen:S}=t;let k;e[0]!==o?(k=o===void 0?[]:o,e[0]=o,e[1]=k):k=e[1];const N=k,$=p===void 0?!0:p,B=_===void 0?100:_,{t:D}=lt(),[W,H]=c.useState(!1),[U,se]=c.useState(-1);let z;e[2]!==W||e[3]!==N?(z=W?N:[],e[2]=W,e[3]=N,e[4]=z):z=e[4];const Q=z;let ie;e[5]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>{se(-1)},e[5]=ie):ie=e[5];let O;e[6]!==s||e[7]!==W?(O=[s,W],e[6]=s,e[7]=W,e[8]=O):O=e[8],c.useEffect(ie,O);let ne;e[9]!==d?(ne=Te=>{H(!1),se(-1),d(Te)},e[9]=d,e[10]=ne):ne=e[10];const V=ne;let J;e[11]!==U||e[12]!==V||e[13]!==Q?(J=Te=>{if(Q.length!==0){if(Te.key==="ArrowDown"||Te.key==="ArrowUp"){Te.preventDefault();const Ae=Te.key==="ArrowDown"?1:-1,qe=Q.length;se(Ge=>{const Je=Ge+Ae;return Je<-1?qe-1:Je>=qe?-1:Je});return}if(Te.key==="Escape"&&U>=0){Te.preventDefault(),se(-1);return}if(Te.key==="Enter"&&U>=0){Te.preventDefault();const Ae=Q[U];Ae&&V(Ae.url)}}},e[11]=U,e[12]=V,e[13]=Q,e[14]=J):J=e[14];const F=J;let re;e[15]!==D?(re=D("contextPanel.browser.back"),e[15]=D,e[16]=re):re=e[16];const q=!h;let ge;e[17]!==u||e[18]!==re||e[19]!==q?(ge=n.jsx(gs,{icon:"arrow-left",label:re,onClick:u,disabled:q}),e[17]=u,e[18]=re,e[19]=q,e[20]=ge):ge=e[20];let Z;e[21]!==D?(Z=D("contextPanel.browser.forward"),e[21]=D,e[22]=Z):Z=e[22];const de=!x;let Se;e[23]!==l||e[24]!==Z||e[25]!==de?(Se=n.jsx(gs,{icon:"arrow-right",label:Z,onClick:l,disabled:de}),e[23]=l,e[24]=Z,e[25]=de,e[26]=Se):Se=e[26];let ue;e[27]!==g||e[28]!==D?(ue=D(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=D,e[29]=ue):ue=e[29];let ke;e[30]!==f||e[31]!==ue?(ke=n.jsx(gs,{icon:"refresh",label:ue,onClick:f}),e[30]=f,e[31]=ue,e[32]=ke):ke=e[32];let Me;e[33]!==y||e[34]!==D?(Me=y?n.jsx(gs,{icon:"restart",label:D("contextPanel.browser.hardReload"),onClick:y}):null,e[33]=y,e[34]=D,e[35]=Me):Me=e[35];let We;e[36]!==s||e[37]!==V?(We=Te=>{Te.preventDefault(),V(s)},e[36]=s,e[37]=V,e[38]=We):We=e[38];let Le;e[39]!==r?(Le=r?n.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:n.jsx(ce,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=Le):Le=e[40];let Ve;e[41]!==a?(Ve=Te=>a(Te.target.value),e[41]=a,e[42]=Ve):Ve=e[42];let Ne,me;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>H(!0),me=()=>H(!1),e[43]=Ne,e[44]=me):(Ne=e[43],me=e[44]);const ye=Q.length>0,je=r&&"ps-8";let Be;e[45]!==je?(Be=Ze("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",je,"typography-micro text-foreground outline-none"),e[45]=je,e[46]=Be):Be=e[46];let _e;e[47]!==D?(_e=D("contextPanel.browser.addressAria"),e[47]=D,e[48]=_e):_e=e[48];let Ie;e[49]!==s||e[50]!==F||e[51]!==Ve||e[52]!==ye||e[53]!==Be||e[54]!==_e?(Ie=n.jsx("input",{value:s,onChange:Ve,onFocus:Ne,onBlur:me,onKeyDown:F,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":ye,"aria-controls":"openchamber-browser-address-suggestions",className:Be,"aria-label":_e}),e[49]=s,e[50]=F,e[51]=Ve,e[52]=ye,e[53]=Be,e[54]=_e,e[55]=Ie):Ie=e[55];let tt;e[56]!==i?(tt=Te=>i?.(Te),e[56]=i,e[57]=tt):tt=e[57];let Ke;e[58]!==U||e[59]!==V||e[60]!==tt||e[61]!==Q?(Ke=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(Q0,{entries:Q,activeIndex:U,onSelect:V,onForget:tt,onHighlight:se})}),e[58]=U,e[59]=V,e[60]=tt,e[61]=Q,e[62]=Ke):Ke=e[62];let ze;e[63]!==We||e[64]!==Le||e[65]!==Ie||e[66]!==Ke?(ze=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:We,children:[Le,Ie,Ke]}),e[63]=We,e[64]=Le,e[65]=Ie,e[66]=Ke,e[67]=ze):ze=e[67];let rt;e[68]!==E||e[69]!==A||e[70]!==R||e[71]!==D||e[72]!==B?(rt=A&&E?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(gs,{icon:"subtract",label:D("contextPanel.browser.zoomOut"),onClick:A}),B!==100&&R?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{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":D("contextPanel.browser.zoomReset"),children:[B,"%"]})}),n.jsx(jt,{sideOffset:6,children:D("contextPanel.browser.zoomReset")})]}):null,n.jsx(gs,{icon:"add",label:D("contextPanel.browser.zoomIn"),onClick:E})]}):null,e[68]=E,e[69]=A,e[70]=R,e[71]=D,e[72]=B,e[73]=rt):rt=e[73];let ve;e[74]!==L||e[75]!==D?(ve=L?n.jsx(gs,{icon:"delete-bin",label:D("contextPanel.browser.clearCookies"),onClick:L}):null,e[74]=L,e[75]=D,e[76]=ve):ve=e[76];let M;e[77]!==v||e[78]!==D?(M=v?n.jsx(gs,{icon:"database-2",label:D("contextPanel.browser.clearCache"),onClick:v}):null,e[77]=v,e[78]=D,e[79]=M):M=e[79];let Ce;e[80]!==S||e[81]!==C||e[82]!==D?(Ce=C?n.jsx(gs,{icon:"smartphone",label:D("contextPanel.browser.deviceToolbar"),onClick:C,pressed:S}):null,e[80]=S,e[81]=C,e[82]=D,e[83]=Ce):Ce=e[83];let He;e[84]!==j||e[85]!==w||e[86]!==D?(He=w?n.jsx(gs,{icon:"markup",label:D("contextPanel.browser.annotate.toggle"),onClick:w,pressed:j}):null,e[84]=j,e[85]=w,e[86]=D,e[87]=He):He=e[87];let Xe;e[88]!==b||e[89]!==D?(Xe=b?n.jsx(gs,{icon:"terminal-box",label:D("contextPanel.browser.devTools"),onClick:b}):null,e[88]=b,e[89]=D,e[90]=Xe):Xe=e[90];let G;e[91]!==D?(G=D("contextPanel.browser.openExternal"),e[91]=D,e[92]=G):G=e[92];const Ee=!$;let Pe;e[93]!==m||e[94]!==G||e[95]!==Ee?(Pe=n.jsx(gs,{icon:"external-link",label:G,onClick:m,disabled:Ee}),e[93]=m,e[94]=G,e[95]=Ee,e[96]=Pe):Pe=e[96];let Fe;return e[97]!==ge||e[98]!==Se||e[99]!==ke||e[100]!==Me||e[101]!==ze||e[102]!==rt||e[103]!==ve||e[104]!==M||e[105]!==Ce||e[106]!==He||e[107]!==Xe||e[108]!==Pe?(Fe=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ge,Se,ke,Me,ze,rt,ve,M,Ce,He,Xe,Pe]}),e[97]=ge,e[98]=Se,e[99]=ke,e[100]=Me,e[101]=ze,e[102]=rt,e[103]=ve,e[104]=M,e[105]=Ce,e[106]=He,e[107]=Xe,e[108]=Pe,e[109]=Fe):Fe=e[109],Fe},Xr={kind:"fill"},bl=240,eS=3840,Qd=[{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}],wl=t=>Number.isFinite(t)?Math.round(Math.min(eS,Math.max(bl,t))):bl,Yr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},eu=t=>{const e=Qd.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},tS=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},sS=(t,e)=>{const s=Yr(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:i}},nS=["mobile","tablet","desktop","fill"],rS={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},yl=t=>typeof t=="string"&&nS.includes(t),vi=t=>t==="fill"?Xr:eu(rS[t])??Xr,Cr=t=>{const e=Yr(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=vi(s),o=Yr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},oS=t=>{const e=Ue.c(77),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:d}=lt();let u;e[0]!==s?(u=Yr(s),e[0]=s,e[1]=u):u=e[1];const l=u,f=s.kind==="preset"?s.id:"";let m;e[2]!==r||e[3]!==l?(m=(q,ge)=>{const Z=Number.parseInt(ge,10);if(!Number.isFinite(Z))return;const de=l??{width:1280,height:800};r({kind:"custom",width:wl(q==="width"?Z:de.width),height:wl(q==="height"?Z:de.height)})},e[2]=r,e[3]=l,e[4]=m):m=e[4];const p=m;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Ze("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=q=>{const ge=eu(q.target.value);r(ge??Xr)},e[6]=r,e[7]=g):g=e[7];let w;e[8]!==d?(w=d("contextPanel.browser.device.preset"),e[8]=d,e[9]=w):w=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=Ze("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=b):b=e[10];let j;e[11]!==d?(j=d("contextPanel.browser.device.responsive"),e[11]=d,e[12]=j):j=e[12];let y;e[13]!==j?(y=n.jsx("option",{value:"",children:j}),e[13]=j,e[14]=y):y=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=Qd.map(iS),e[15]=E):E=e[15];let A;e[16]!==f||e[17]!==g||e[18]!==w||e[19]!==y?(A=n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex shrink-0",children:n.jsxs("select",{value:f,onChange:g,"aria-label":w,className:b,children:[y,E]})})}),e[16]=f,e[17]=g,e[18]=w,e[19]=y,e[20]=A):A=e[20];let R;e[21]!==d?(R=d("contextPanel.browser.device.preset"),e[21]=d,e[22]=R):R=e[22];let _;e[23]!==R?(_=n.jsx(jt,{sideOffset:6,children:R}),e[23]=R,e[24]=_):_=e[24];let L;e[25]!==A||e[26]!==_?(L=n.jsxs(kt,{children:[A,_]}),e[25]=A,e[26]=_,e[27]=L):L=e[27];const v=l?String(l.width):"";let C;e[28]!==p?(C=q=>p("width",q.target.value),e[28]=p,e[29]=C):C=e[29];let S;e[30]!==d?(S=d("contextPanel.browser.device.width"),e[30]=d,e[31]=S):S=e[31];let k;e[32]!==v||e[33]!==C||e[34]!==S?(k=n.jsx("input",{value:v,onChange:C,placeholder:"—",inputMode:"numeric","aria-label":S,className:x}),e[32]=v,e[33]=C,e[34]=S,e[35]=k):k=e[35];let N;e[36]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[36]=N):N=e[36];const $=l?String(l.height):"";let B;e[37]!==p?(B=q=>p("height",q.target.value),e[37]=p,e[38]=B):B=e[38];let D;e[39]!==d?(D=d("contextPanel.browser.device.height"),e[39]=d,e[40]=D):D=e[40];let W;e[41]!==$||e[42]!==B||e[43]!==D?(W=n.jsx("input",{value:$,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":D,className:x}),e[41]=$,e[42]=B,e[43]=D,e[44]=W):W=e[44];let H;e[45]!==r||e[46]!==s?(H=()=>r(tS(s)),e[45]=r,e[46]=s,e[47]=H):H=e[47];const U=!l;let se;e[48]!==d?(se=d("contextPanel.browser.device.rotate"),e[48]=d,e[49]=se):se=e[49];let z;e[50]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(ce,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[50]=z):z=e[50];let Q;e[51]!==H||e[52]!==U||e[53]!==se?(Q=n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex shrink-0",children:n.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:H,disabled:U,"aria-label":se,children:z})})}),e[51]=H,e[52]=U,e[53]=se,e[54]=Q):Q=e[54];let ie;e[55]!==d?(ie=d("contextPanel.browser.device.rotate"),e[55]=d,e[56]=ie):ie=e[56];let O;e[57]!==ie?(O=n.jsx(jt,{sideOffset:6,children:ie}),e[57]=ie,e[58]=O):O=e[58];let ne;e[59]!==Q||e[60]!==O?(ne=n.jsxs(kt,{children:[Q,O]}),e[59]=Q,e[60]=O,e[61]=ne):ne=e[61];let V;e[62]!==a||e[63]!==l?(V=l&&a<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[62]=a,e[63]=l,e[64]=V):V=e[64];let J;e[65]===Symbol.for("react.memo_cache_sentinel")?(J=["system","light","dark"],e[65]=J):J=e[65];let F;e[66]!==o||e[67]!==i||e[68]!==d?(F=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:J.map(q=>n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{type:"button",variant:o===q?"secondary":"ghost",size:"xs",className:Ze("shrink-0 rounded-full px-2.5 typography-micro",o===q?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(q),"aria-pressed":o===q,children:d(q==="system"?"contextPanel.browser.device.schemeSystem":q==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")})}),n.jsx(jt,{sideOffset:6,children:d(q==="system"?"contextTooltips.terminalBrowser.device.schemeSystem":q==="light"?"contextTooltips.terminalBrowser.device.schemeLight":"contextTooltips.terminalBrowser.device.schemeDark")})]},q))}),e[66]=o,e[67]=i,e[68]=d,e[69]=F):F=e[69];let re;return e[70]!==L||e[71]!==k||e[72]!==W||e[73]!==ne||e[74]!==V||e[75]!==F?(re=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[L,k,N,W,ne,V,F]}),e[70]=L,e[71]=k,e[72]=W,e[73]=ne,e[74]=V,e[75]=F,e[76]=re):re=e[76],re};function iS(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const Jr=new Map,Si=new Set,tu=()=>{for(const t of Si)t()},Zo=(t,e)=>{const s=t.trim();s&&(e.length===0?Jr.delete(s):Jr.set(s,[...e]),tu())},aS=t=>{Jr.delete(t.trim())&&tu()},su=[],lS=t=>Jr.get(t.trim())??su,cS=t=>(Si.add(t),()=>{Si.delete(t)}),dS=t=>{const e=Ue.c(2);let s;return e[0]!==t?(s=()=>lS(t),e[0]=t,e[1]=s):s=e[1],c.useSyncExternalStore(cS,s,uS)};function uS(){return su}const nu="oc.browser.hiddenDevServerPorts.v1",fS=di(Ss(),yd(xo().int().positive())),ki=new Set,ru=[];let Tr=null;const ia=()=>{const t=hr().getItem(nu);if(Tr&&Tr.raw===t)return Tr.value;let e={};if(t!==null)try{const s=fS.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return Tr={raw:t,value:e},e},ou=t=>{hr().setItem(nu,JSON.stringify(t));for(const e of ki)e()},pS=(t=qt())=>ia()[t]??ru,mS=t=>{const e=qt(),s=ia(),r=s[e]??[];r.includes(t)||ou({...s,[e]:[...r,t].sort((o,i)=>o-i)})},hS=()=>{const t=qt(),e=ia();if(!e[t])return;const s={...e};delete s[t],ou(s)},gS=t=>(ki.add(t),()=>{ki.delete(t)}),xS=()=>c.useSyncExternalStore(gS,bS,wS);function bS(){return pS()}function wS(){return ru}const yS=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},vS=2e3,SS=t=>wc("http://localhost",t),iu=t=>{const e=Ue.c(62),{onOpen:s,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=lt();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={kind:"loading"},e[0]=d):d=e[0];const[u,l]=c.useState(d),f=dS(i);let m;e[1]!==i?(m=()=>SS(i),e[1]=i,e[2]=m):m=e[2];const[p]=c.useState(m);let h;e[3]!==i?(h=()=>np(i),e[3]=i,e[4]=h):h=e[4];const[x]=c.useState(h);let g;e[5]!==i?(g=ec(i),e[5]=i,e[6]=g):g=e[6];const w=g,b=oa(i),j=Vu(i);let y,E;e[7]!==i||e[8]!==j||e[9]!==o?(y=()=>{if(j){l({kind:"ready",servers:[]});return}if(!o)return;let V=!0,J=null;const F=new AbortController,re=()=>{o0(F.signal,i).then(q=>{V&&(l(q),J=setTimeout(re,vS))})};return re(),()=>{V=!1,J&&clearTimeout(J),F.abort()}},E=[i,j,o],e[7]=i,e[8]=j,e[9]=o,e[10]=y,e[11]=E):(y=e[10],E=e[11]),c.useEffect(y,E);const A=Gt(kS),R=nt(jS);let _;if(e[12]!==A||e[13]!==R){const V=A.map(CS);let J;e[15]!==R?(J=[...R].flatMap(TS),e[15]=R,e[16]=J):J=e[16],_=[...V,...J],e[12]=A,e[13]=R,e[14]=_}else _=e[14];const L=_;let v;e[17]!==f||e[18]!==i||e[19]!==u.kind||e[20]!==u.servers||e[21]!==L?(v=u0({candidates:l0({announced:f,discovered:u.kind==="ready"?u.servers:null}),folders:L,directory:i}),e[17]=f,e[18]=i,e[19]=u.kind,e[20]=u.servers,e[21]=L,e[22]=v):v=e[22];const C=v,S=xS(),[k,N]=c.useState(!1);let $;if(e[23]!==C||e[24]!==S||e[25]!==k){let V;e[27]!==S||e[28]!==k?(V=J=>J.announced||!S.includes(J.port)&&(k||!J.outsideWork),e[27]=S,e[28]=k,e[29]=V):V=e[29],$=C.filter(V),e[23]=C,e[24]=S,e[25]=k,e[26]=$}else $=e[26];const B=$,D=C.length-B.length;let W;e[30]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(cg,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=W):W=e[30];let H;e[31]!==a?(H=a("contextPanel.browser.empty"),e[31]=a,e[32]=H):H=e[32];let U;e[33]!==H?(U=n.jsx("span",{className:"typography-ui-header text-foreground",children:H}),e[33]=H,e[34]=U):U=e[34];let se;e[35]!==a?(se=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=se):se=e[36];let z;e[37]!==se?(z=n.jsx("span",{className:"typography-micro text-muted-foreground",children:se}),e[37]=se,e[38]=z):z=e[38];let Q;e[39]!==U||e[40]!==z?(Q=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[U,z]}),e[39]=U,e[40]=z,e[41]=Q):Q=e[41];let ie;e[42]!==f||e[43]!==C.length||e[44]!==i||e[45]!==D||e[46]!==w||e[47]!==s||e[48]!==p||e[49]!==b||e[50]!==x||e[51]!==a||e[52]!==B?(ie=C.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.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")}),p&&!x?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx(as,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:B.map(V=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(ut,{type:"button",variant:"outline",size:"sm",className:Ze("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(aS(i),s(V.url))},children:[w?n.jsx("span",{className:"shrink-0",role:"img","aria-label":b??a("contextPanel.browser.spaceAddress"),title:b??a("contextPanel.browser.spaceAddress"),children:n.jsx(ce,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):n.jsx(ce,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsxs("span",{className:"truncate",children:[ro(V.url)||V.url,n.jsx("span",{className:"typography-micro text-muted-foreground",children:yS(V.url)})]}),x?n.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:n.jsx(ce,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):V.folderName?n.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:V.directory,children:[n.jsx(ce,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",dir:"auto",children:V.folderName})]}):null]}),V.announced?null:n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{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:()=>mS(V.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:V.port}),children:n.jsx(ce,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})}),n.jsx(jt,{sideOffset:6,children:a("contextPanel.browser.devServers.hide",{port:V.port})})]})]},V.port))}),D>0?n.jsx(ut,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{hS(),N(!0)},children:D===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:D}):a("contextPanel.browser.devServers.showHiddenPlural",{count:D})}):null]}):null,e[42]=f,e[43]=C.length,e[44]=i,e[45]=D,e[46]=w,e[47]=s,e[48]=p,e[49]=b,e[50]=x,e[51]=a,e[52]=B,e[53]=ie):ie=e[53];let O;e[54]!==C.length||e[55]!==u.kind||e[56]!==a?(O=C.length===0&&u.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=C.length,e[55]=u.kind,e[56]=a,e[57]=O):O=e[57];let ne;return e[58]!==Q||e[59]!==ie||e[60]!==O?(ne=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[W,Q,ie,O]}),e[58]=Q,e[59]=ie,e[60]=O,e[61]=ne):ne=e[61],ne};function kS(t){return t.projects}function jS(t){return t.availableWorktreesByProject}function CS(t){return{path:t.path,projectPath:t.path}}function TS(t){const[e,s]=t;return s.map(r=>({path:r.path,projectPath:e}))}const NS=3e4,ES=3,PS=250,IS={attempts:0,windowStartedAt:null},RS=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=NS,r=s?0:t.attempts;return r>=ES?null:{delayMs:PS*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},DS=-3,Nr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",kn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},_S=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:dg),[i,a]=c.useState(e),[d,u]=c.useState(""),[l,f]=c.useState(!1),[m,p]=c.useState(!1),h=c.useRef(s);h.current=s;const x=c.useRef(IS);return c.useEffect(()=>{if(!t)return;const g=()=>{try{const C=t.getURL();return Nr(C)?C:""}catch{return""}},w=()=>{try{f(t.canGoBack()),p(t.canGoForward())}catch{}},b=C=>{Nr(C)&&(a(C),h.current(C))},j=()=>{const C=g();o({kind:"loading",url:C})},y=()=>{const C=g();let S="";try{S=t.getTitle()||""}catch{S=""}u(S),b(C),w(),o(k=>k.kind==="failed"?k:{kind:"ready",url:C,title:S})},E=C=>{const S=kn(C);Nr(S.url)&&(b(S.url),w())},A=C=>{const S=kn(C),k=Array.isArray(S.favicons)?S.favicons.find(Boolean):"",N=g();if(!k||!N)return;let $=-1;try{$=t.getWebContentsId()}catch{return}!Number.isFinite($)||$<0||Ad.getState().resolve(N,k,$)},R=C=>{const S=kn(C);typeof S.title=="string"&&u(S.title)},_=C=>{const S=kn(C);if(S.isMainFrame===!1)return;const k=typeof S.errorCode=="number"?S.errorCode:0;k!==DS&&o({kind:"failed",url:Nr(S.validatedURL)?S.validatedURL:g(),code:k,description:typeof S.errorDescription=="string"?S.errorDescription:""})};let L=null;const v=()=>{const C=g(),S=RS(x.current,Date.now());if(!S){o({kind:"failed",url:C,code:0,description:"",crashed:!0});return}x.current=S.state,o({kind:"loading",url:C}),L=setTimeout(()=>{L=null;try{t.reload()}catch{o({kind:"failed",url:C,code:0,description:"",crashed:!0})}},S.delayMs)};t.addEventListener("did-start-loading",j),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",E),t.addEventListener("did-navigate-in-page",E),t.addEventListener("page-title-updated",R),t.addEventListener("page-favicon-updated",A),t.addEventListener("did-fail-load",_),t.addEventListener("render-process-gone",v),t.addEventListener("crashed",v);try{!t.isLoading()&&g()&&y()}catch{}return()=>{L!==null&&clearTimeout(L),t.removeEventListener("render-process-gone",v),t.removeEventListener("crashed",v),t.removeEventListener("did-start-loading",j),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",E),t.removeEventListener("did-navigate-in-page",E),t.removeEventListener("page-title-updated",R),t.removeEventListener("page-favicon-updated",A),t.removeEventListener("did-fail-load",_)}},[t]),{status:r,url:i,title:d,canGoBack:l,canGoForward:m}},vl=1e3,au=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},AS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},OS=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},MS=(t,e)=>{const s=c.useRef(0),r=c.useRef(0),o=c.useRef(0),i=c.useRef(null),a=c.useCallback(()=>{if(!t||document.activeElement!==t)return;const d=i.current;d&&d.isConnected&&d!==document.body?d.focus({preventScroll:!0}):t.blur()},[t]);return c.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=OS());const d=u=>{if(document.activeElement!==t){i.current=AS(u);return}const l=e.current,f=s.current>r.current||Date.now()<o.current;l&&au(l)&&!f||r.current>0||a()};return document.addEventListener("focusin",d,!0),()=>document.removeEventListener("focusin",d,!0)},[a,e,t]),c.useCallback(async d=>{const u=t!==null&&document.activeElement===t;let l=!1;const f=()=>{l&&(l=!1,r.current-=1,o.current=Date.now()+vl,!u&&r.current===0&&a())},m=()=>(l||(l=!0,r.current+=1),f);s.current+=1;try{return await d(m)}finally{s.current-=1,o.current=Date.now()+vl,f()}},[a,t])},FS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),LS=()=>document.visibilityState==="visible",BS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Er=.5,$S=-3,zS=4,WS="persist:openchamber-browser",lu=(t,e,s)=>bs(t)!==null&&sc(e)?{icon:"instance",label:s}:void 0,Sl=t=>{const e=bs(t);return e?`openchamber-space-preview:${e}`:WS},kl="openchamber:browser-panel-open-tab",US=Js({webContentsId:xo(),url:Ss().min(1),background:cr()}),jl=20,VS=600,HS=2e4,KS=15e3,Cl=500,Tl=5e3,qS=3e4,GS=3e3,Nl=1e3,ZS=250,XS=Js({quiet:cr()}),YS=()=>new Promise(t=>{let e=0,s=0,r=0,o;const i=l=>{clearTimeout(o),t(l)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},d=()=>{s=e,r=performance.now()+Nl,o=setTimeout(u,Nl)},u=()=>{e>s||performance.now()-r>ZS?d():i(!1)};requestAnimationFrame(a),d()}),JS=t=>{if(!t||au(t))return()=>{};const e=t.getBoundingClientRect(),s=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=s}},QS=({initialUrl:t,directory:e,siteDirectory:s,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=lt(),{currentTheme:d}=oo(),u=c.useRef(null),[l,f]=c.useState(null),m=c.useCallback(Y=>{u.current=Y,f(Y)},[]),p=K(Y=>Y.setContextPanelTabTargetPath),h=c.useRef(jn(t)),x=h.current!==Zs?h.current:"",[g,w]=c.useState(x?null:Zs),b=oa(s),[j,y]=c.useState(x),[E,A]=c.useState(!1),[R,_]=c.useState(!1),[L,v]=c.useState(0),C=c.useRef(0),[S,k]=c.useState(!1),[N,$]=c.useState(Xr),B=c.useRef(N);B.current=N;const D=c.useRef([]),[W,H]=c.useState("system"),[U,se]=c.useState({width:0,height:0}),z=c.useRef(null),Q=c.useRef(null),ie=rs(e),O=c.useRef(!!x&&!Hu(ie,r)),ne=c.useRef(null);c.useEffect(()=>{tc(ie,r)},[ie,r]);const V=c.useRef(!1),J=c.useRef(Date.now()),F=c.useCallback(Y=>{!Y||Y===Zs||!e||!r||p(e,r,Y)},[e,r,p]),re=_S(l,{initialUrl:x,onUrlChange:c.useCallback(Y=>{const fe=bn(Y);y(fe),F(fe)},[F])}),[q,ge]=c.useState(null),[Z,de]=c.useState(bs(s)===null);c.useEffect(()=>{const Y=bs(s);if(Y===null){de(!0);return}let fe=!0;return de(!1),Sn("desktop_space_preview_prepare",{spaceId:Y}).then(()=>{fe&&de(!0)}).catch(()=>{fe&&ge(x||"http://localhost/")}),()=>{fe=!1}},[s,x]);const Se=ug(e),ue=fg(),ke=re.status.kind==="loading",Me=Tn(Yd(s)),We=Tn(Y=>Y.recordVisit),Le=Tn(Y=>Y.forget);c.useEffect(()=>{re.status.kind==="ready"&&We(s,{url:bn(re.status.url),title:re.status.title})},[s,re.status,We]);const Ve=c.useMemo(()=>Xd(Me,j),[Me,j]),Ne=c.useCallback(Y=>{const fe=jn(Y);fe!==Zs&&(O.current=!1,y(fe),ge(null),Sa(fe,s).then(Re=>{const T=u.current;if(!T){w(Re);return}try{T.loadURL(Re)}catch{w(Re)}}).catch(Re=>{Re instanceof ka&&ge(fe)}))},[s]);c.useEffect(()=>{if(!x)return;let Y=!0;return Sa(x,s).then(fe=>{Y&&w(fe)}).catch(fe=>{if(Y){if(fe instanceof ka){ge(x),O.current=!1,w(Zs);return}w(x)}}),()=>{Y=!1}},[]);const me=c.useMemo(()=>({executeJavaScript:async(Y,fe)=>{const Re=u.current;if(!Re)throw new Error("Browser view is not available");return Re.executeJavaScript(Y,fe)},capturePage:async()=>{const Y=u.current;if(!Y)return null;const fe=Y.getWebContentsId();return Number.isFinite(fe)?await Sn("desktop_browser_capture_page",{webContentsId:fe}):null}}),[]),ye=c.useCallback(()=>{if(E){A(!1),Ao(me);return}if(!re.url){Oe.error(a("contextPanel.browser.annotate.noPage"));return}const Y=pg(d.metadata.variant==="light"?"light":"dark");A(!0),mg({host:me,theme:Y,labels:ue}).then(async fe=>{A(!1),fe&&await Se(fe)}).catch(()=>{A(!1),Oe.error(a("contextPanel.browser.annotate.failed"))})},[me,Se,d,E,re.url,ue,a]);c.useEffect(()=>{if(!E)return;const Y=fe=>{Dc(fe)||fe.key!=="Escape"||(fe.preventDefault(),fe.stopImmediatePropagation(),A(!1),Ao(me))};return window.addEventListener("keydown",Y,!0),()=>window.removeEventListener("keydown",Y,!0)},[me,E]);const je=c.useRef(!1);c.useEffect(()=>{if(!l)return;const Y=()=>{je.current=!0};return l.addEventListener("dom-ready",Y),l.addEventListener("did-fail-load",Y),()=>{l.removeEventListener("dom-ready",Y),l.removeEventListener("did-fail-load",Y)}},[l]);const Be=c.useCallback(async()=>{const Y=Date.now()+KS;for(;!(u.current&&je.current)&&Date.now()<Y;)await new Promise(fe=>setTimeout(fe,100));return u.current},[]),_e=c.useCallback(async(Y=8e3)=>{const fe=Date.now();for(;;){const Re=u.current;if(!Re)return!1;let T=!1;try{T=Re.isLoading()}catch{return!1}if(!T)return!0;if(Date.now()-fe>Y)return!1;await new Promise(ae=>setTimeout(ae,120))}},[]),Ie=c.useCallback(async(Y,fe)=>{const Re=X0({quietMs:Cl,maxMs:fe});let T;const ae=new Promise(pe=>{T=setTimeout(()=>pe(null),fe+1e3)});try{const pe=XS.safeParse(await Promise.race([Y.executeJavaScript(Re,!1),ae]));return pe.success&&pe.data.quiet}catch{return!1}finally{clearTimeout(T)}},[]),tt=c.useCallback(async(Y,fe=qS)=>{const Re=Date.now(),T=await _e(Math.min(25e3,Math.max(0,fe-Tl))),ae=fe-(Date.now()-Re),pe=T&&ae>Cl&&await Ie(Y,Math.min(Tl,ae));let oe="";try{oe=Y.getTitle()||""}catch{oe=""}return{title:oe,settled:pe}},[_e,Ie]),Ke=c.useCallback(async(Y,fe,Re)=>{const T=await Be();if(!T)throw new Error("The browser panel is not ready");const ae=()=>{yl(fe.viewport)&&($(vi(fe.viewport)),k(!0))};if(Y==="browser.back"||Y==="browser.forward"){const le=Y==="browser.back";if(!(le?T.canGoBack():T.canGoForward()))throw new Error(le?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");le?T.goBack():T.goForward(),await new Promise(bt=>setTimeout(bt,150)),await _e();let xe="";try{xe=T.getTitle()||""}catch{xe=""}return{url:bn(T.getURL()),title:xe}}if(Y==="browser.capture"){const le=JS(z.current);try{if(!await YS())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 _e()&&await Ie(T,GS);const et=await me.capturePage();if(!et)throw new Error("The page could not be captured");let xe="";try{xe=T.getTitle()||""}catch{xe=""}return{...et,url:bn(T.getURL()),title:xe,viewport:Cr(B.current)}}finally{le()}}if(Y==="browser.resize"){if(!yl(fe.viewport))throw new Error("viewport is required");return ae(),await new Promise(le=>setTimeout(le,200)),await _e(),{viewport:Cr(vi(fe.viewport))}}if(Y==="browser.open"){const le=typeof fe.url=="string"?fe.url:"";if(!le)throw new Error("url is required");return ae(),Ne(le),await new Promise(et=>setTimeout(et,150)),{url:jn(le),...await tt(T),opened:!0,viewport:Cr(B.current)}}if(Y==="browser.settle"){const le=xo().safeParse(fe.budgetMs);return tt(T,le.success?le.data:void 0)}await _e();const pe=le=>typeof le=="string"&&le?le:void 0,be=(()=>{switch(Y){case"browser.snapshot":return H0({selector:pe(fe.selector)});case"browser.click":return K0({selector:pe(fe.selector),text:pe(fe.text)});case"browser.type":return q0({selector:String(fe.selector??""),value:String(fe.value??""),submit:fe.submit===!0});case"browser.select":return G0({selector:String(fe.selector??""),label:typeof fe.label=="string"?fe.label:void 0,value:typeof fe.value=="string"?fe.value:void 0});case"browser.inspect":return J0({selector:String(fe.selector??"")});case"browser.scroll":return Z0({selector:pe(fe.selector),direction:pe(fe.direction)});default:return null}})();if(!be)throw new Error(`Unsupported browser action: ${Y}`);let $e=()=>{};(Y==="browser.click"||Y==="browser.type")&&(await Sn("desktop_browser_keep_page_focused",{webContentsId:T.getWebContentsId()}).then(et=>et.focused===!0).catch(()=>!1)||($e=Re(),T.focus({preventScroll:!0})));let De;try{De=await T.executeJavaScript(be,!0)}finally{$e()}if(!De||typeof De!="object")throw new Error("The page returned no result");const ee=De;if(ee.ok!==!0)throw new Error(typeof ee.error=="string"&&ee.error?ee.error:"Browser action failed");if(Y==="browser.snapshot"){const le=D.current;return{...ee,viewport:Cr(B.current),...le.length>0?{consoleProblems:[...le]}:{}}}return(Y==="browser.click"||Y==="browser.select"||Y==="browser.type"&&fe.submit===!0)&&(await new Promise(le=>setTimeout(le,150)),await _e()),De},[me,Ne,tt,_e,Ie,Be]),ze=MS(l,z),[rt,ve]=c.useState(!1),M=c.useCallback((Y,fe)=>(ve(!0),ze(Re=>Ke(Y,fe,Re))),[ze,Ke]),Ce=c.useCallback(()=>{const Y=u.current;if(!Y)return{title:"",url:""};let fe="",Re="";try{fe=Y.getTitle()||""}catch{fe=""}try{Re=bn(Y.getURL())}catch{Re=""}return{title:fe,url:Re}},[]);c.useEffect(()=>T0({tabId:r,directory:ie,ownerSessionId:o,describe:Ce,run:M}),[Ce,o,M,ie,r]),c.useEffect(()=>{const Y=me;return()=>{Ao(Y)}},[me]),c.useEffect(()=>{if(!l)return;const Y=Re=>{const T=Re;if(typeof T.level!="number"||T.level<2)return;const ae=T.sourceId?`${T.sourceId}${T.line?`:${T.line}`:""}`:"";D.current.push({level:T.level>=3?"error":"warning",message:String(T.message??"").slice(0,400),source:ae}),D.current.length>jl&&D.current.splice(0,D.current.length-jl)},fe=()=>{D.current=[]};return l.addEventListener("console-message",Y),l.addEventListener("did-start-loading",fe),()=>{l.removeEventListener("console-message",Y),l.removeEventListener("did-start-loading",fe)}},[l]);const He=c.useRef(new Set),Xe=c.useCallback(Y=>{He.current.clear(),Ne(Y)},[Ne]),G=c.useRef(re.status);G.current=re.status;const Ee=c.useRef(!1);re.status.kind==="ready"&&re.status.url&&(Ee.current=!0),c.useEffect(()=>Ku(ie,r,Y=>{Gu(G.current,Ee.current)&&Xe(Y)}),[Xe,ie,r]),c.useEffect(()=>{if(!l)return;const Y=Re=>{const T=kn(Re),ae=typeof T.url=="string"?T.url:"";!ae||!ja(ae,s)||(Re.preventDefault(),Ne(ae))},fe=Re=>{const T=kn(Re);if(T.isMainFrame===!1||T.errorCode===-3)return;const ae=typeof T.validatedURL=="string"?T.validatedURL:"";!ae||!ja(ae,s)||He.current.has(ae)||(He.current.add(ae),Ne(ae))};return l.addEventListener("will-navigate",Y),l.addEventListener("did-fail-load",fe),()=>{l.removeEventListener("will-navigate",Y),l.removeEventListener("did-fail-load",fe)}},[s,Ne,l]),c.useEffect(()=>{if(!l)return;const Y=fe=>{if(!(fe instanceof CustomEvent))return;const Re=US.safeParse(fe.detail);if(!Re.success)return;let T=-1;try{T=l.getWebContentsId()}catch{return}Re.data.webContentsId===T&&K.getState().openContextBrowser(ie,Re.data.url,{reveal:!Re.data.background})};return window.addEventListener(kl,Y),()=>window.removeEventListener(kl,Y)},[ie,l]);const Pe=c.useCallback(Y=>{const fe=Math.min(zS,Math.max($S,Y));C.current=fe,v(fe);try{u.current?.setZoomLevel(fe)}catch{}},[]);c.useEffect(()=>{const Y=fe=>{if(!(fe instanceof CustomEvent))return;const Re=fe.detail,T=u.current;!T||document.activeElement!==T||(Re==="zoom-in"?Pe(C.current+Er):Re==="zoom-out"?Pe(C.current-Er):Re==="zoom-reset"&&Pe(0))};return window.addEventListener("openchamber:zoom",Y),()=>window.removeEventListener("openchamber:zoom",Y)},[Pe]);const Fe=c.useCallback(Y=>{Sn("desktop_browser_clear_data",{partition:Sl(s),cookies:Y==="cookies",cache:Y==="cache"}).then(()=>{Oe.success(a(Y==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{u.current?.reloadIgnoringCache()}catch{}}).catch(()=>Oe.error(a("contextPanel.browser.clearFailed")))},[s,a]);c.useEffect(()=>{const Y=z.current;if(!Y||typeof ResizeObserver>"u")return;const fe=new ResizeObserver(Re=>{const T=Re[0]?.contentRect;T&&se({width:T.width,height:T.height})});return fe.observe(Y),()=>fe.disconnect()},[]);const Te=c.useCallback(Y=>{H(Y);const fe=u.current;if(!fe)return;let Re=-1;try{Re=fe.getWebContentsId()}catch{return}Sn("desktop_browser_set_color_scheme",{webContentsId:Re,scheme:Y}).catch(T=>{H("system"),Oe.error(T instanceof Error?T.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),Ae=c.useCallback(()=>{try{ke?u.current?.stop():u.current?.reload()}catch{}},[ke]),qe=re.status,Ge=c.useSyncExternalStore(FS,LS),Je=i&&Ge||o!==null||rt;c.useEffect(()=>{const Y=pe=>{_(!0);const oe=setTimeout(()=>{try{u.current?.reload()}catch{}},pe);return()=>clearTimeout(oe)};if(qe.kind==="loading")return;const fe=O.current||ne.current===qe;if(O.current&&(qe.kind==="failed"||qe.kind==="ready"&&qe.url)&&(O.current=!1,ne.current=qe),qe.kind==="failed"){const pe=qu(qe,{run:Q.current,restored:fe,watched:Je,now:Date.now()});if(Q.current=pe.run,pe.next==="retry")return Y(pe.delayMs);_(pe.next==="pause");return}if(Q.current=null,qe.kind!=="ready"||!qe.url||!sc(qe.url)){V.current=!0,_(!1);return}if(fe||V.current||Date.now()-J.current>HS){V.current=!0,_(!1);return}let Re=!1,T=null;return(bs(s)?Promise.resolve(null):i0(bn(qe.url))).then(pe=>{if(!Re){if(pe===null||pe<500){V.current=!0,_(!1);return}T=Y(VS)}}),()=>{Re=!0,T?.()}},[s,qe,Je]);const st=re.status.kind==="failed"&&!R?re.status:null,mt=sS(N,U);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(Jd,{address:j,onAddressChange:y,onSubmit:Xe,suggestions:Ve,onForgetSuggestion:Y=>Le(s,Y),onBack:()=>{try{u.current?.goBack()}catch{}},onForward:()=>{try{u.current?.goForward()}catch{}},onReload:Ae,onOpenExternal:()=>{On(re.url||j)},addressMark:lu(s,j,b??a("contextPanel.browser.spaceAddress")),canOpenExternal:bs(s)===null,canGoBack:re.canGoBack,canGoForward:re.canGoForward,isLoading:ke,onAnnotate:ye,isAnnotating:E,onOpenDevTools:()=>{try{u.current?.openDevTools()}catch{}},onHardReload:()=>{try{u.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Pe(L+Er),onZoomOut:()=>Pe(L-Er),onZoomReset:()=>Pe(0),zoomPercent:Math.round(Math.pow(1.2,L)*100),onClearCookies:()=>Fe("cookies"),onClearCache:()=>Fe("cache"),onToggleDeviceBar:()=>k(Y=>!Y),isDeviceBarOpen:S}),S?n.jsx(oS,{viewport:N,onViewportChange:$,colorScheme:W,onColorSchemeChange:Te,scale:mt?.scale??1}):null,n.jsxs("div",{ref:z,className:Ze("relative min-h-0 flex-1 bg-background",mt&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&Z?n.jsx("webview",{ref:m,src:g,partition:Sl(s),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:mt?{width:`${mt.width}px`,height:`${mt.height}px`,transform:`scale(${mt.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!x&&!re.url&&!ke?n.jsx(iu,{onOpen:Xe,directory:s,visible:i}):null,R?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,q?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[bs(s)!==null?n.jsx(ce,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a(bs(s)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:q})})]}):null,st&&!q?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:st.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:st.crashed?a("contextPanel.browser.crashedHint"):st.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,ke?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},e2=t=>{const e=Ue.c(75),{initialUrl:s,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:d}=lt(),u=K(s2);let l;e[0]!==s?(l=jn(s),e[0]=s,e[1]=l):l=e[1];const f=l,m=f!==Zs?f:"",[p,h]=c.useState(m);let x;e[2]!==o||e[3]!==m?(x=Io(m,o),e[2]=o,e[3]=m,e[4]=x):x=e[4];const[g,w]=c.useState(x);let b;e[5]!==o||e[6]!==m?(b=wc(m,o)?m:"",e[5]=o,e[6]=m,e[7]=b):b=e[7];const[j,y]=c.useState(b);let E;e[8]!==o?(E=bs(o),e[8]=o,e[9]=E):E=e[9];const A=E!==null,R=oa(o);let _;e[10]!==m?(_=m?[m]:[],e[10]=m,e[11]=_):_=e[11];const[L,v]=c.useState(_),[C,S]=c.useState(m?0:-1),[k,N]=c.useReducer(n2,0);let $,B;e[12]!==i||e[13]!==r?($=()=>{tc(rs(r),i)},B=[r,i],e[12]=i,e[13]=r,e[14]=$,e[15]=B):($=e[14],B=e[15]),c.useEffect($,B);let D;e[16]!==u||e[17]!==i||e[18]!==r?(D=Ve=>{!Ve||Ve===Zs||!r||!i||u(r,i,Ve)},e[16]=u,e[17]=i,e[18]=r,e[19]=D):D=e[19];const W=D;let H;e[20]!==o?(H=Yd(o),e[20]=o,e[21]=H):H=e[21];const U=Tn(H),se=Tn(r2),z=Tn(o2);let Q;e[22]!==p||e[23]!==U?(Q=Xd(U,p),e[22]=p,e[23]=U,e[24]=Q):Q=e[24];const ie=Q;let O;e[25]!==o||e[26]!==C||e[27]!==W||e[28]!==se?(O=Ve=>{const Ne=jn(Ve);if(Ne===Zs)return;h(Ne);const me=Io(Ne,o);w(me),y(me?"":Ne),W(Ne),se(o,{url:Ne}),v(ye=>{const je=C>=0?ye.slice(0,C+1):[];return je[je.length-1]===Ne?(S(je.length-1),je):(S(je.length),[...je,Ne])})},e[25]=o,e[26]=C,e[27]=W,e[28]=se,e[29]=O):O=e[29];const ne=O;let V;e[30]!==o||e[31]!==L||e[32]!==W?(V=Ve=>{const Ne=L[Ve];if(!Ne)return;S(Ve),h(Ne);const me=Io(Ne,o);w(me),y(me?"":Ne),W(Ne)},e[30]=o,e[31]=L,e[32]=W,e[33]=V):V=e[33];const J=V;let F;e[34]!==o||e[35]!==z?(F=Ve=>z(o,Ve),e[34]=o,e[35]=z,e[36]=F):F=e[36];let re,q;e[37]!==J||e[38]!==C?(re=()=>J(C-1),q=()=>J(C+1),e[37]=J,e[38]=C,e[39]=re,e[40]=q):(re=e[39],q=e[40]);let ge;e[41]!==p||e[42]!==g?(ge=()=>{On(g||p)},e[41]=p,e[42]=g,e[43]=ge):ge=e[43];let Z;e[44]!==R||e[45]!==d?(Z=R??d("contextPanel.browser.spaceAddress"),e[44]=R,e[45]=d,e[46]=Z):Z=e[46];let de;e[47]!==p||e[48]!==o||e[49]!==Z?(de=lu(o,p,Z),e[47]=p,e[48]=o,e[49]=Z,e[50]=de):de=e[50];const Se=!j,ue=C>0,ke=C>=0&&C<L.length-1;let Me;e[51]!==p||e[52]!==ne||e[53]!==ie||e[54]!==F||e[55]!==re||e[56]!==q||e[57]!==ge||e[58]!==de||e[59]!==Se||e[60]!==ue||e[61]!==ke?(Me=n.jsx(Jd,{address:p,onAddressChange:h,onSubmit:ne,suggestions:ie,onForgetSuggestion:F,onBack:re,onForward:q,onReload:N,onOpenExternal:ge,addressMark:de,canOpenExternal:Se,canGoBack:ue,canGoForward:ke,isLoading:!1}),e[51]=p,e[52]=ne,e[53]=ie,e[54]=F,e[55]=re,e[56]=q,e[57]=ge,e[58]=de,e[59]=Se,e[60]=ue,e[61]=ke,e[62]=Me):Me=e[62];let We;e[63]!==o||e[64]!==A||e[65]!==g||e[66]!==ne||e[67]!==k||e[68]!==d||e[69]!==j||e[70]!==a?(We=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:j?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[A?n.jsx(ce,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:d(A?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:ro(j)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:d("contextPanel.browser.remoteLoopback.hint")})]}):g?n.jsx("iframe",{src:g,title:d("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${k}`):n.jsx(iu,{onOpen:ne,directory:o,visible:a})}),e[63]=o,e[64]=A,e[65]=g,e[66]=ne,e[67]=k,e[68]=d,e[69]=j,e[70]=a,e[71]=We):We=e[71];let Le;return e[72]!==Me||e[73]!==We?(Le=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Me,We]}),e[72]=Me,e[73]=We,e[74]=Le):Le=e[74],Le},t2=t=>{const e=Ue.c(3),[s]=c.useState(BS);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(QS,{...t}):n.jsx(e2,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function s2(t){return t.setContextPanelTabTargetPath}function n2(t){return t+1}function r2(t){return t.recordVisit}function o2(t){return t.forget}const i2=t=>{const e=Ue.c(13),{zone:s,children:r}=t,[o]=c.useState(a2);let i;e[0]!==s?(i=p=>p.body[s],e[0]=s,e[1]=i):i=e[1];const a=dr(i);let d,u;e[2]!==a||e[3]!==o||e[4]!==s?(d=()=>{const p=a??dr.getState().body[s];if(!p){o.remove();return}if(o.parentElement===p)return;const h=document.activeElement;p.moveBefore&&o.isConnected?p.moveBefore(o,null):p.append(o),h instanceof HTMLElement&&o.contains(h)&&document.activeElement!==h&&h.focus({preventScroll:!0})},u=[a,o,s],e[2]=a,e[3]=o,e[4]=s,e[5]=d,e[6]=u):(d=e[5],u=e[6]),c.useLayoutEffect(d,u);let l,f;e[7]!==o?(l=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=l,e[9]=f):(l=e[8],f=e[9]),c.useLayoutEffect(l,f);let m;return e[10]!==r||e[11]!==o?(m=Gl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=m):m=e[12],m};function a2(){const t=document.createElement("div");return t.style.display="contents",t}const l2=200,cu=t=>`${t.path}:${t.line}:${t.column}`,El={status:"idle"},c2=t=>{const e=Ue.c(9),{searchContents:s,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:d,active:u}=t,[l,f]=c.useState(El);let m,p;return e[0]!==u||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==d||e[6]!==s?(m=()=>{if(!u||!s||!r||!o.trim()){f(El);return}const h=new AbortController;let x=!1;return f({status:"searching"}),s({directory:r,query:o,regex:i,limit:l2,includeHidden:a,respectGitignore:d,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()}},p=[u,r,a,o,i,d,s],e[0]=u,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=d,e[6]=s,e[7]=m,e[8]=p):(m=e[7],p=e[8]),c.useEffect(m,p),l},on=t=>{const e=Ue.c(5),{className:s,children:r}=t;let o;e[0]!==s?(o=Ze("px-2 py-1 typography-meta text-muted-foreground",s),e[0]=s,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=n.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},d2=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},u2=t=>{const e=Ue.c(44),{state:s,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:d}=lt();switch(s.status){case"idle":return null;case"searching":{let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(ce,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=m):m=e[0];let p;e[1]!==d?(p=d("sidebarFilesTree.state.searching"),e[1]=d,e[2]=p):p=e[2];let h;return e[3]!==p?(h=n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[m,p]}),e[3]=p,e[4]=h):h=e[4],h}case"unavailable":{let m;e[5]!==d?(m=d("sidebarFilesTree.contentSearch.unavailable"),e[5]=d,e[6]=m):m=e[6];let p;return e[7]!==m?(p=n.jsx(on,{children:m}),e[7]=m,e[8]=p):p=e[8],p}case"invalid-pattern":{let m;e[9]!==d?(m=d("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=d,e[10]=m):m=e[10];let p;e[11]!==m?(p=n.jsx("span",{className:"text-[var(--status-error)]",children:m}),e[11]=m,e[12]=p):p=e[12];let h;e[13]!==s.message?(h=n.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:s.message}),e[13]=s.message,e[14]=h):h=e[14];let x;return e[15]!==p||e[16]!==h?(x=n.jsxs(on,{className:"flex flex-col gap-0.5",children:[p,h]}),e[15]=p,e[16]=h,e[17]=x):x=e[17],x}case"failed":{let m;e[18]!==s.message||e[19]!==d?(m=d("sidebarFilesTree.contentSearch.failed",{message:s.message}),e[18]=s.message,e[19]=d,e[20]=m):m=e[20];let p;return e[21]!==m?(p=n.jsx(on,{className:"text-[var(--status-error)]",children:m}),e[21]=m,e[22]=p):p=e[22],p}}if(s.matches.length===0){let m;return e[23]!==s.stopped||e[24]!==d?(m=s.stopped==="deadline"?n.jsx(on,{children:d("sidebarFilesTree.contentSearch.deadline")}):n.jsx(on,{children:d("sidebarFilesTree.contentSearch.empty")}),e[23]=s.stopped,e[24]=d,e[25]=m):m=e[25],m}let u;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==s.matches){let m;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(m=p=>{const{name:h,directory:x}=d2(p.relativePath),g=cu(p),w=r===g;return n.jsx("li",{"data-file-tree-path":p.path,children:n.jsxs("button",{type:"button",onClick:()=>o(p),onDoubleClick:()=>o(p,{pin:!0}),draggable:!!i,onDragStart:i?b=>i(b,p):void 0,onDragEnd:a?b=>a(b,p):void 0,className:Ze("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",Zi(w)),title:`${p.relativePath}:${p.line}`,children:[n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[n.jsx(mo,{filePath:p.path,className:"size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`${x}`}):n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:p.line})]}),n.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[p.cutStart?"…":null,n.jsx(rp,{segments:op(p.text,p.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=m):m=e[36],u=s.matches.map(m),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=s.matches,e[31]=u}else u=e[31];let l;e[37]!==s.matches.length||e[38]!==s.stopped||e[39]!==d?(l=s.stopped==="limit"?n.jsx(on,{children:d("sidebarFilesTree.contentSearch.limit",{count:s.matches.length})}):s.stopped==="deadline"?n.jsx(on,{children:d("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=s.matches.length,e[38]=s.stopped,e[39]=d,e[40]=l):l=e[40];let f;return e[41]!==u||e[42]!==l?(f=n.jsxs(n.Fragment,{children:[u,l]}),e[41]=u,e[42]=l,e[43]=f):f=e[43],f},Pl=8;let fr=null;const du=(t,e)=>Math.abs(e.clientX-t.x)<=Pl&&Math.abs(e.clientY-t.y)<=Pl,ji=t=>{fr={x:t.clientX,y:t.clientY}},Ci=t=>{const e=fr;return fr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:du(e,t)},uu=t=>fr!==null&&du(fr,t);let fu=null;const Xo=t=>{fu=t},pu=()=>fu,Il=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},mu=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:Il(e.path);return!r||Il(t.path)===r||t.type==="directory"&&Zu(r,t.path,t.path)!==null?null:r},f2=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},p2=({root:t,childrenByDir:e,expandedPaths:s,loadErrorsByDir:r})=>{const o=[],i=(a,d)=>{for(const u of e[a]??[]){const l=u.type==="directory"&&s.has(u.path);if(o.push({kind:"node",key:u.path,node:u,depth:d,isExpanded:l}),!l)continue;const f=r[u.path];f&&o.push({kind:"error",key:`error:${u.path}`,directory:u.path,depth:d+1,message:f}),i(u.path,d+1)}};return i(t,0),o},m2=(t,e,s)=>{const r=e.filter(o=>o>=0&&o<s&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},h2=28,Nn=t=>Array.from(t.types).includes("Files"),Qn=t=>Array.from(t.types).includes(ar)?pu():null,hu=(t,e,s)=>t.getData(ar)===So(e,s.path),g2=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},x2=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),Lt=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},So=(t,e)=>{const s=Lt(e),r=Lt(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},zn=(t,e)=>{const s=So(t,e);if(s!==".")return s;const r=Lt(t);return r.split("/").filter(Boolean).pop()??r},Lr=t=>{const e=Lt(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},b2=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),w2=new Set(["node_modules"]),y2=t=>w2.has(t),v2=t=>{const e=Lt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},S2=8,Es=new Map,aa=t=>JSON.stringify([qt(),t]),k2=t=>{const e=aa(t),s=Es.get(e);return s?(s.touchedAt=Date.now(),Es.delete(e),Es.set(e,s),s):null},Yo=t=>{const e=aa(t),s=Es.get(e);if(s)return s.touchedAt=Date.now(),s;if(Es.size>=S2){const o=Es.keys().next().value;o!==void 0&&Es.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Es.set(e,r),r},j2=t=>{const e=Ue.c(159),{guestActions:s,node:r,root:o,isExpanded:i,isActive:a,isBrowserClient:d,depth:u,isOpen:l,status:f,badge:m,isDropTarget:p,isDragSource:h,canUpload:x,canMove:g,permissions:w,downloadFile:b,onSelect:j,onToggle:y,onRevealPath:E,onOpenDialog:A,onSetDropTarget:R,onDropFiles:_,onPickFiles:L,onMoveDragChange:v,onSetMoveDropTarget:C,onMoveDrop:S}=t,{t:k}=lt(),N=r.type==="directory";let $;e[0]!==N||e[1]!==r.path?($=N?r.path:Lr(r.path),e[0]=N,e[1]=r.path,e[2]=$):$=e[2];const B=$,{canRename:D,canCreateFile:W,canCreateFolder:H,canDelete:U,canReveal:se}=w,z=!N&&!!b,Q=se&&!d,ie=N&&x,O=D||W||H||ie||U||z||Q,[ne,V]=c.useState(!1),[J,F]=c.useState(!1);let re;e[3]!==O?(re=_e=>{O&&(_e?.preventDefault(),F(!0))},e[3]=O,e[4]=re):re=e[4];const q=re;let ge;e[5]!==N||e[6]!==r||e[7]!==j||e[8]!==y?(ge=()=>{N?y(r.path):j(r)},e[5]=N,e[6]=r,e[7]=j,e[8]=y,e[9]=ge):ge=e[9];const Z=ge;let de;e[10]!==N||e[11]!==r||e[12]!==j?(de=()=>{N||j(r,{pin:!0})},e[10]=N,e[11]=r,e[12]=j,e[13]=de):de=e[13];const Se=de;let ue;e[14]===Symbol.for("react.memo_cache_sentinel")?(ue=_e=>{_e.stopPropagation(),F(!1),V(!0)},e[14]=ue):ue=e[14];const ke=ue;let Me,We,Le,Ve,Ne,me,ye;if(e[15]!==m||e[16]!==W||e[17]!==H||e[18]!==U||e[19]!==g||e[20]!==D||e[21]!==Q||e[22]!==x||e[23]!==ie||e[24]!==ne||e[25]!==u||e[26]!==b||e[27]!==s||e[28]!==q||e[29]!==Se||e[30]!==Z||e[31]!==O||e[32]!==a||e[33]!==d||e[34]!==N||e[35]!==h||e[36]!==p||e[37]!==i||e[38]!==l||e[39]!==r||e[40]!==_||e[41]!==v||e[42]!==S||e[43]!==A||e[44]!==L||e[45]!==E||e[46]!==R||e[47]!==C||e[48]!==J||e[49]!==o||e[50]!==f||e[51]!==k||e[52]!==B){const _e=hg(s,"file"),Ie=ee=>{const{Item:le,Separator:et}=ee;return n.jsxs(n.Fragment,{children:[D&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("rename",r)},children:[n.jsx(ce,{name:"edit",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.rename")]}),n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),io(r.path).then(bt=>{if(bt.ok){Oe.success(k("sidebarFilesTree.toast.pathCopied"));return}Oe.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(ce,{name:"link",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.copyPath")]}),!N&&b&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),b(r.path).catch(bt=>{console.error("Download failed:",bt),Oe.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ce,{name:"download",className:"me-2 h-4 w-4"})," ",k(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Q&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),E(r.path)},children:[n.jsx(ce,{name:"folder-received",className:"me-2 h-4 w-4"})," ",k(bg())]}),!N&&Q&&no()&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),Xl(r.path).then(bt=>{bt||Oe.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(ce,{name:"external-link",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.openInDefaultApp")]}),_e.length>0&&n.jsx(et,{}),_e.map(xe=>n.jsxs(le,{onClick:bt=>{bt.stopPropagation(),wg(xe,{kind:"file",action:xe.action.id,directory:o||null,path:r.path,isDirectory:N},k)},children:[n.jsx(Gi,{icon:xe.icon,iconSrc:xe.iconSrc,className:"me-2 h-4 w-4"})," ",xe.action.label]},`${xe.guest.id}:${xe.action.id}`)),N&&(W||H||ie)&&n.jsxs(n.Fragment,{children:[n.jsx(et,{}),W&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("createFile",r)},children:[n.jsx(ce,{name:"file-add",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.newFile")]}),H&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("createFolder",r)},children:[n.jsx(ce,{name:"folder-add",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.newFolder")]}),ie&&n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),L(r.path)},children:[n.jsx(ce,{name:"upload-2",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.uploadFiles")]})]}),U&&n.jsxs(n.Fragment,{children:[n.jsx(et,{}),n.jsxs(le,{onClick:xe=>{xe.stopPropagation(),A("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(ce,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",k("sidebarFilesTree.menu.delete")]})]})]})};let tt;e[60]!==g||e[61]!==r.path||e[62]!==r.type||e[63]!==v||e[64]!==o?(tt=ee=>{ji(ee);const le=So(o,r.path);!le||le==="."||(ee.dataTransfer.setData(ar,le),ee.dataTransfer.effectAllowed=g?"copyMove":"copy",g&&v({path:r.path,type:r.type}))},e[60]=g,e[61]=r.path,e[62]=r.type,e[63]=v,e[64]=o,e[65]=tt):tt=e[65];const Ke=tt;let ze;e[66]!==g||e[67]!==Z||e[68]!==v?(ze=ee=>{g&&v(null),Ci(ee)&&Z()},e[66]=g,e[67]=Z,e[68]=v,e[69]=ze):ze=e[69];const rt=ze;let ve;e[70]!==x||e[71]!==R||e[72]!==B?(ve=ee=>{!x||!B||!Nn(ee.dataTransfer)||(ee.preventDefault(),ee.stopPropagation(),ee.dataTransfer.dropEffect="copy",R(B))},e[70]=x,e[71]=R,e[72]=B,e[73]=ve):ve=e[73];const M=ve;let Ce;e[74]!==x||e[75]!==R||e[76]!==B?(Ce=ee=>{!x||!B||!Nn(ee.dataTransfer)||ee.relatedTarget instanceof Node&&ee.currentTarget.contains(ee.relatedTarget)||(ee.stopPropagation(),R(null))},e[74]=x,e[75]=R,e[76]=B,e[77]=Ce):Ce=e[77];const He=Ce;let Xe;e[78]!==x||e[79]!==_||e[80]!==B?(Xe=ee=>{!x||!B||!Nn(ee.dataTransfer)||(ee.preventDefault(),ee.stopPropagation(),_(B,ee.dataTransfer))},e[78]=x,e[79]=_,e[80]=B,e[81]=Xe):Xe=e[81];const G=Xe;let Ee;e[82]!==r.path||e[83]!==r.type||e[84]!==o?(Ee=(ee,le)=>uu(ee)?null:mu(le,{path:r.path,type:r.type},o),e[82]=r.path,e[83]=r.type,e[84]=o,e[85]=Ee):Ee=e[85];const Pe=Ee;let Fe;e[86]!==g||e[87]!==Pe||e[88]!==M||e[89]!==C?(Fe=ee=>{const le=g?Qn(ee.dataTransfer):null;if(!le){M(ee);return}ee.stopPropagation();const et=Pe(ee,le);C(et),et&&(ee.preventDefault(),ee.dataTransfer.dropEffect="move")},e[86]=g,e[87]=Pe,e[88]=M,e[89]=C,e[90]=Fe):Fe=e[90];const Te=Fe;let Ae;e[91]!==g||e[92]!==Pe||e[93]!==G||e[94]!==S||e[95]!==C||e[96]!==o?(Ae=ee=>{const le=g?Qn(ee.dataTransfer):null;if(!le){G(ee);return}ee.stopPropagation(),ee.preventDefault(),C(null);const et=Pe(ee,le);et&&hu(ee.dataTransfer,o,le)&&S(le,et)},e[91]=g,e[92]=Pe,e[93]=G,e[94]=S,e[95]=C,e[96]=o,e[97]=Ae):Ae=e[97];const qe=Ae;We=xr,me=J,ye=F;let Ge;e[98]===Symbol.for("react.memo_cache_sentinel")?(Ge={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[98]=Ge):Ge=e[98];let Je;e[99]!==q||e[100]!==He||e[101]!==Te||e[102]!==qe?(Je=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ge,onContextMenu:q,onDragEnter:Te,onDragOver:Te,onDragLeave:He,onDrop:qe}),e[99]=q,e[100]=He,e[101]=Te,e[102]=qe,e[103]=Je):Je=e[103];let st;e[104]!==u?(st=n.jsx(Gc,{depth:u}),e[104]=u,e[105]=st):st=e[105];let mt;e[106]!==a||e[107]!==h||e[108]!==p?(mt=Ze("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(a),h&&"opacity-50"),e[106]=a,e[107]=h,e[108]=p,e[109]=mt):mt=e[109];let Y;e[110]!==u?(Y=Zc(u),e[110]=u,e[111]=Y):Y=e[111];let fe;e[112]!==Y?(fe={paddingInlineStart:Y},e[112]=Y,e[113]=fe):fe=e[113];let Re;e[114]!==N||e[115]!==i||e[116]!==r.extension||e[117]!==r.path?(Re=N?n.jsx(gg,{expanded:i}):n.jsx(mo,{filePath:r.path,extension:r.extension,className:"ms-0.5 size-3.5"}),e[114]=N,e[115]=i,e[116]=r.extension,e[117]=r.path,e[118]=Re):Re=e[118];let T;e[119]!==r.name||e[120]!==r.path?(T=n.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:r.path,children:r.name}),e[119]=r.name,e[120]=r.path,e[121]=T):T=e[121];let ae;e[122]!==N||e[123]!==l||e[124]!==f?(ae=!N&&n.jsx(yg,{isOpen:l,status:f}),e[122]=N,e[123]=l,e[124]=f,e[125]=ae):ae=e[125];let pe;e[126]!==m||e[127]!==N?(pe=N&&m&&n.jsx(vg,{badge:m}),e[126]=m,e[127]=N,e[128]=pe):pe=e[128];let oe;e[129]!==ae||e[130]!==pe?(oe=n.jsxs(Sg,{className:"pe-2",children:[ae,pe]}),e[129]=ae,e[130]=pe,e[131]=oe):oe=e[131];let be;e[132]!==q||e[133]!==Se||e[134]!==rt||e[135]!==Ke||e[136]!==Z||e[137]!==mt||e[138]!==fe||e[139]!==Re||e[140]!==T||e[141]!==oe?(be=n.jsxs("button",{type:"button",onClick:Z,onDoubleClick:Se,onContextMenu:q,draggable:!0,onDragStart:Ke,onDragEnd:rt,className:mt,style:fe,children:[Re,T,oe]}),e[132]=q,e[133]=Se,e[134]=rt,e[135]=Ke,e[136]=Z,e[137]=mt,e[138]=fe,e[139]=Re,e[140]=T,e[141]=oe,e[142]=be):be=e[142];const $e=O&&n.jsx("div",{className:Ze("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 pointer-fine:hidden",xg(a||p)),children:n.jsxs(fn,{open:ne,onOpenChange:V,children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(pn,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ke,"aria-label":k("diffView.actions.moreActions"),children:n.jsx(ce,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:k("diffView.actions.moreActions")})]}),n.jsx(mn,{align:"end",side:"bottom",onCloseAutoFocus:()=>V(!1),children:Ie({Item:$s,Separator:qn})})]})});e[143]!==Je||e[144]!==st||e[145]!==be||e[146]!==$e?(Le=n.jsxs(ao,{render:Je,children:[st,be,$e]}),e[143]=Je,e[144]=st,e[145]=be,e[146]=$e,e[147]=Le):Le=e[147],Me=br,Ve="min-w-[180px]";let De;e[148]===Symbol.for("react.memo_cache_sentinel")?(De={Item:vs,Separator:Cn},e[148]=De):De=e[148],Ne=Ie(De),e[15]=m,e[16]=W,e[17]=H,e[18]=U,e[19]=g,e[20]=D,e[21]=Q,e[22]=x,e[23]=ie,e[24]=ne,e[25]=u,e[26]=b,e[27]=s,e[28]=q,e[29]=Se,e[30]=Z,e[31]=O,e[32]=a,e[33]=d,e[34]=N,e[35]=h,e[36]=p,e[37]=i,e[38]=l,e[39]=r,e[40]=_,e[41]=v,e[42]=S,e[43]=A,e[44]=L,e[45]=E,e[46]=R,e[47]=C,e[48]=J,e[49]=o,e[50]=f,e[51]=k,e[52]=B,e[53]=Me,e[54]=We,e[55]=Le,e[56]=Ve,e[57]=Ne,e[58]=me,e[59]=ye}else Me=e[53],We=e[54],Le=e[55],Ve=e[56],Ne=e[57],me=e[58],ye=e[59];let je;e[149]!==Me||e[150]!==Ve||e[151]!==Ne?(je=n.jsx(Me,{className:Ve,children:Ne}),e[149]=Me,e[150]=Ve,e[151]=Ne,e[152]=je):je=e[152];let Be;return e[153]!==We||e[154]!==Le||e[155]!==je||e[156]!==me||e[157]!==ye?(Be=n.jsxs(We,{open:me,onOpenChange:ye,children:[Le,je]}),e[153]=We,e[154]=Le,e[155]=je,e[156]=me,e[157]=ye,e[158]=Be):Be=e[158],Be},C2=(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&&t.guestActions===e.guestActions,T2=c.memo(j2,C2),N2=t=>{const e=Ue.c(14),{visible:s}=t,r=s===void 0?!0:s,o=Dn(P2),i=Hs()??"",a=wr();let d,u,l,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(u=co(a,i)??"",a?.kind==="preparing"){let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Rr,{}),e[7]=p):p=e[7],f=p;break e}d=E2,l=JSON.stringify([o,u])}e[0]=a,e[1]=i,e[2]=o,e[3]=d,e[4]=u,e[5]=l,e[6]=f}else d=e[3],u=e[4],l=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;return e[8]!==d||e[9]!==u||e[10]!==i||e[11]!==l||e[12]!==r?(m=n.jsx(d,{visible:r,currentDirectory:u,panelDirectory:i},l),e[8]=d,e[9]=u,e[10]=i,e[11]=l,e[12]=r,e[13]=m):m=e[13],m},E2=({visible:t,currentDirectory:e,panelDirectory:s})=>{const r=c.useRef(t);r.current=t;const{t:o}=lt(),{files:i,runtime:a}=ks(),d=kg(),u=Xu(a.platform),l=Lt(e.trim()),f=Lt(s.trim()),m=aa(l),p=Yu(),h=Ju(),x=Qu(I=>I.searchFiles),g=K(I=>I.openContextFile),w=fo(t?e:null),[b,j]=c.useState(""),y=jg(b,200),E=c.useRef(null),[A,R]=c.useState([]),[_,L]=c.useState(!1),v=!!i.searchContents,[C,S]=c.useState("names"),[k,N]=c.useState(!1),$=v&&C==="contents",B=c2({searchContents:i.searchContents,directory:e,query:y,regex:k,includeHidden:p,respectGitignore:!h,active:t&&$}),D=K(I=>I.openContextFileAtLine),[W,H]=c.useState(null),[U,se]=c.useState(null),[z,Q]=c.useState(null),[ie,O]=c.useState(null),[ne,V]=c.useState(null),{hasTouchOnlyPointer:J}=hn(),F=!!(i.rename&&l)&&!J,re=K(I=>I.confirmFileTreeMove),q=K(I=>I.setConfirmFileTreeMove),[ge,Z]=c.useState({}),[de,Se]=c.useState({}),ue=c.useRef(new Set),ke=c.useRef(new Map),Me=c.useMemo(()=>new px,[]);c.useEffect(()=>()=>Me.clear(),[Me]);const We=c.useRef(null);c.useEffect(()=>{if(se(null),O(null),V(null),!l){Z({}),Se({}),ue.current=new Set;return}const I=k2(l);I?(Z({...I.childrenByDir}),Se({...I.loadErrorsByDir}),ue.current=new Set(I.loadedDirs)):(Z({}),Se({}),ue.current=new Set)},[l]),c.useEffect(()=>{if(!l)return;const I=Yo(l);I.childrenByDir=ge},[l,ge]),c.useEffect(()=>{if(!l)return;const I=Yo(l);I.loadErrorsByDir=de},[l,de]),c.useEffect(()=>{if(!l)return;const I=Yo(l);I.loadedDirs=new Set(ue.current)},[l,ge,de]),c.useEffect(()=>()=>{if(!l)return;const I=Es.get(m);I&&I.loadedDirs.size===0&&Object.keys(I.childrenByDir).length===0&&Es.delete(m)},[m,l]);const Le=c.useMemo(()=>[],[]),Ve=c.useMemo(()=>[],[]),Ne=us(I=>l?I.byRoot[l]?.expandedPaths??Le:Le),me=c.useMemo(()=>new Set(Ne),[Ne]),ye=us(I=>l?I.byRoot[l]?.selectedPath??null:null),je=us(I=>I.setSelectedPath),Be=c.useRef(null);c.useEffect(()=>{Be.current=ye},[ye]);const _e=us(I=>I.addOpenPath),Ie=us(I=>I.removeOpenPathsByPrefix),tt=us(I=>I.toggleExpandedPath),Ke=us(I=>I.expandPath),ze=us(I=>I.collapseAllExpandedPaths),rt=K(I=>f?I.contextPanelByDirectory[f]?.tabs??Ve:Ve),ve=c.useMemo(()=>new Set(rt.map(I=>I.mode==="file"?I.targetPath:null).filter(I=>typeof I=="string"&&I.length>0).map(I=>Lt(I))),[rt]),[M,Ce]=c.useState(null),[He,Xe]=c.useState(null),[G,Ee]=c.useState(""),[Pe,Fe]=c.useState(!1),Te=!!i.writeFile,Ae=!!i.createDirectory,qe=!!i.rename,Ge=!!i.delete,Je=!!i.revealPath,st=c.useMemo(()=>({canRename:qe,canCreateFile:Te,canCreateFolder:Ae,canDelete:Ge,canReveal:Je}),[qe,Te,Ae,Ge,Je]),mt=c.useCallback(I=>{i.revealPath&&i.revealPath(I).catch(()=>{Oe.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),Y=c.useCallback((I,P)=>{Ce(I),Xe(P),Ee(I==="rename"&&P.name||""),Fe(!1)},[]),fe=c.useCallback((I,P)=>{const we=P.filter(he=>he&&typeof he.name=="string"&&he.name.length>0).filter(he=>p||!he.name.startsWith(".")).filter(he=>h||!y2(he.name)).map(he=>{const at=he.name,it=Lt(he.path||""),Et=it?b2(it)?it:Lt(`${I}/${it}`):Lt(`${I}/${at}`),Dt=he.isDirectory?"directory":"file",Pt=Dt==="file"&&at.includes(".")?at.split(".").pop()?.toLowerCase():void 0;return{name:at,path:Et,type:Dt,extension:Pt}});return x2(we)},[h,p]),Re=c.useCallback(async(I,P,we=!1)=>{if(!r.current||P?.())return;const he=Lt(I.trim());if(!he||!we&&ue.current.has(he))return;const at=qt();return Me.run(he,async it=>{const Et=()=>!it()||qt()!==at;try{const Dt=!h,Pt=i.listDirectory?(await i.listDirectory(he,{respectGitignore:Dt})).entries:await ti.listLocalDirectory(he,{respectGitignore:Dt});if(Et())return;ke.current.set(he,Pt.length);const Ot=fe(he,Pt);ue.current=new Set(ue.current),ue.current.add(he),Se(ms=>{if(!ms[he])return ms;const en={...ms};return delete en[he],en}),Z(ms=>ms[he]&&mx(ms[he],Ot)?ms:{...ms,[he]:Ot})}catch(Dt){if(Et())return;const Pt=Dt instanceof Error?Dt.message:String(Dt??"");console.error("Failed to load sidebar directory:",Dt),Se(Ot=>({...Ot,[he]:Pt}))}},we)},[Me,i,fe,h]),T=c.useCallback(async()=>{if(!l)return;We.current?.abort();const I=new AbortController;We.current=I,Me.clear();try{const we=(us.getState().byRoot[l]?.expandedPaths??[]).map(it=>Lt(it)).filter(it=>!!it&&it!==l&&it.startsWith(`${l}/`)),he=[l,...we];ue.current=new Set(ue.current);for(const it of he)ue.current.delete(it);Se(it=>{if(Object.keys(it).length===0)return it;const Et={...it};let Dt=!1;for(const Pt of he)Pt in Et&&(delete Et[Pt],Dt=!0);return Dt?Et:it});const at=()=>I.signal.aborted;await Re(l,at);for(let it=0;it<we.length&&!I.signal.aborted;it+=3){const Et=we.slice(it,it+3);await Promise.all(Et.map(Dt=>Re(Dt,at)))}}catch(P){if(I.signal.aborted)return;console.error("Failed to refresh sidebar tree:",P)}finally{We.current===I&&(We.current=null)}},[Me,Re,l]),ae=c.useCallback(async I=>{if(!I){await T();return}const P=Lt(I);ue.current=new Set(ue.current),ue.current.delete(P),await Re(P,void 0,!0)},[Re,T]);c.useEffect(()=>{l&&(We.current?.abort(),ue.current=new Set,Me.clear(),Se({}),Z(I=>Object.keys(I).length===0?I:{}),Re(l))},[Me,Re,l,p,h]),c.useEffect(()=>{if(!t||!l||Ne.length===0)return;const I=Ne.map(he=>Lt(he)).filter(he=>!!he&&he!==l&&he.startsWith(`${l}/`)&&!ue.current.has(he)&&!Me.has(he)).sort((he,at)=>he.split("/").length-at.split("/").length);if(I.length===0)return;let P=!1;const we=()=>P;return(async()=>{for(let he=0;he<I.length&&!P;he+=3){const at=I.slice(he,he+3);await Promise.all(at.map(it=>Re(it,we)))}})(),()=>{P=!0}},[Me,Ne,Re,l,t]);const pe=c.useRef(t);c.useEffect(()=>{const I=t&&!pe.current;pe.current=t,I&&T()},[T,t]);const oe=c.useCallback(({directories:I})=>{if(!l)return;const P=new Set((us.getState().byRoot[l]?.expandedPaths??[]).map(Pt=>Lt(Pt))),we=l==="/"?"/":`${l}/`,he=Pt=>{for(let Ot=Pt;Ot!==l;Ot=Lr(Ot))if(!Ot.startsWith(we)||!P.has(Ot))return!1;return!0},at=Pt=>{for(let Ot=Pt;Ot===l||Ot.startsWith(we);Ot=Lr(Ot)){if(ue.current.has(Ot))return Ot;if(Ot===l)break}return null},it=new Set,Et=new Set;for(const Pt of I??ue.current){const Ot=at(Lt(Pt));Ot&&(he(Ot)?it:Et).add(Ot)}Et.size>0&&(ue.current=new Set([...ue.current].filter(Pt=>!Et.has(Pt))));const Dt=[...it].filter(Pt=>(ke.current.get(Pt)??0)<=ip);(async()=>{for(let Pt=0;Pt<Dt.length;Pt+=3)await Promise.all(Dt.slice(Pt,Pt+3).map(Ot=>Re(Ot,void 0,!0)))})()},[Re,l]);ap({root:l,active:t,whileInactive:"drop",onChanges:oe}),c.useEffect(()=>{if(!t)return;if(!e||$){R([]),L(!1);return}const I=y.trim();if(!I){R([]),L(!1);return}let P=!1;return L(!0),x(e,I,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(we=>{if(P)return;const at=we.filter(it=>h||!v2(it.path)).map(it=>({name:it.name,path:Lt(it.path),type:"file",extension:it.extension,relativePath:it.relativePath}));R(at)}).catch(()=>{P||R([])}).finally(()=>{P||L(!1)}),()=>{P=!0}},[$,e,y,x,p,h,t]);const be=c.useMemo(()=>{const I=new Map;if(!w?.files)return I;for(const P of w.files)P.index==="A"||P.working_dir==="?"?I.set(P.path,"git-added"):P.index==="D"?I.set(P.path,"git-deleted"):(P.index==="M"||P.working_dir==="M")&&I.set(P.path,"git-modified");return I},[w]),$e=c.useMemo(()=>{const I=new Map;if(!w?.files||!l)return I;for(const P of w.files){const we=P.index==="M"||P.working_dir==="M",he=P.index==="A"||P.working_dir==="?";if(!we&&!he)continue;const at=P.path.split("/");if(at.length<=1)continue;let it=l;for(let Et=0;Et<at.length-1;Et++){it=`${it}/${at[Et]}`;let Dt=I.get(it);Dt||(Dt={modified:0,added:0},I.set(it,Dt)),we&&Dt.modified++,he&&Dt.added++}}return I},[w,l]),De=c.useCallback(I=>{if(be.size===0)return null;const P=I.startsWith(l+"/")?I.slice(l.length+1):I;return be.get(P)??null},[be,l]),ee=c.useCallback(I=>{if($e.size===0)return null;const P=$e.get(I);return P&&P.modified+P.added>0?P:null},[$e]),le=c.useCallback(async(I,P)=>{if(!l)return;const we=await Va(i,I.path,{directory:l});if(!we.ok){Ha(I.path,we);return}je(l,I.path),_e(l,I.path),g(f,I.path,{preview:!P?.pin&&!K.getState().isMobile})},[_e,i,g,f,l,je]),et=c.useCallback(async(I,P)=>{if(!l)return;const we=await Va(i,I.path,{directory:l});if(!we.ok){Ha(I.path,we);return}je(l,I.path),_e(l,I.path),H({path:I.path,key:cu(I)}),D(f,I.path,I.line,I.column,{preview:!P?.pin&&!K.getState().isMobile})},[_e,i,D,f,l,je]),xe=c.useCallback((I,P)=>{ji(I),Xo(null),I.dataTransfer.setData(ar,P.relativePath),I.dataTransfer.effectAllowed="copy"},[]),bt=c.useCallback((I,P)=>{Ci(I)&&et(P)},[et]),[Tt,vt]=c.useState(null),Rt=c.useCallback(()=>vt(null),[]),Ye=c.useRef(null),ft=hx(Ye,{onSettled:Rt}),Nt=c.useCallback(async I=>{const P=Lt(I);if(!l)return;const we=us.getState().byRoot[l]?.expandedPaths.includes(P)??!1;ft(I,we,()=>{const he=Array.from(Ye.current?.querySelectorAll("[data-tree-disclosure-path]")??[],at=>at.dataset.treeDisclosurePath??"");vt(we?null:he.slice(he.indexOf(I)+1)),tt(l,P)}),ue.current.has(P)||await Re(P)},[Re,l,tt,ft]),{canUpload:ht,uploadingDirectory:Ct,uploadFiles:pt,pickFiles:It,uploadElements:Ht}=lp({root:l,refreshDirectory:ae}),dt=Ct!==null,ct=Ct??U,Mt=c.useCallback((I,P)=>{const we=g2(P);we.length!==0&&(se(null),pt(I,we))},[pt]),Wt=c.useCallback(I=>{if(Xo(I),!I){Q(null),O(null);return}requestAnimationFrame(()=>{pu()?.path===I.path&&Q(I.path)})},[]),Zt=c.useCallback(async(I,P)=>{const we=f2(I,P),he=await Ua(i,{tabs:f,files:l},I.path,we);if(he==="conflict"){Oe.error(o("sidebarFilesTree.toast.nameTaken",{name:we.slice(we.lastIndexOf("/")+1),folder:zn(l,P)}));return}if(he==="failed"){Oe.error(o("sidebarFilesTree.toast.operationFailed"));return}P!==l&&Ke(l,P),await Promise.all([ae(Lr(I.path)),ae(P)]).catch(()=>{})},[Ke,i,f,ae,l,o]),Kt=c.useCallback((I,P)=>{if(K.getState().confirmFileTreeMove){V({source:I,targetDirectory:P});return}Zt(I,P)},[Zt]),ls=c.useCallback(()=>{ne&&(V(null),Zt(ne.source,ne.targetDirectory))},[Zt,ne]),Ut=c.useCallback((I,P)=>!F||uu(I)?null:mu(P,null,l),[F,l]),Qt=c.useCallback(I=>{const P=Qn(I.dataTransfer);if(P){const we=Ut(I,P);if(O(we),!we)return;I.preventDefault(),I.dataTransfer.dropEffect="move";return}!ht||dt||!l||!Nn(I.dataTransfer)||(I.preventDefault(),I.dataTransfer.dropEffect="copy",se(l))},[ht,Ut,dt,l]),cs=c.useCallback(I=>{if(!(I.relatedTarget instanceof Node&&I.currentTarget.contains(I.relatedTarget))){if(Qn(I.dataTransfer)){O(null);return}Nn(I.dataTransfer)&&se(null)}},[]),js=c.useCallback(I=>{const P=Qn(I.dataTransfer);if(P){I.preventDefault(),O(null);const we=Ut(I,P);we&&hu(I.dataTransfer,l,P)&&Kt(P,we);return}!ht||dt||!l||!Nn(I.dataTransfer)||(I.preventDefault(),Mt(l,I.dataTransfer))},[ht,Ut,Mt,Kt,dt,l]),Rs=c.useCallback(async I=>{if(I?.preventDefault(),!He||!M)return;Fe(!0);const P=()=>Fe(!1),we=()=>Ce(null);if(M==="createFile"){if(!G.trim()){Oe.error(o("sidebarFilesTree.toast.filenameRequired")),P();return}if(!i.writeFile){Oe.error(o("sidebarFilesTree.toast.writeNotSupported")),P();return}const he=He.path,at=he?`${he}/`:"",it=Lt(`${at}${G.trim()}`);await i.writeFile(it,"").then(async Et=>{Et.success&&(Oe.success(o("sidebarFilesTree.toast.fileCreated")),await ae(he)),we()}).catch(()=>Oe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(P);return}if(M==="createFolder"){if(!G.trim()){Oe.error(o("sidebarFilesTree.toast.folderNameRequired")),P();return}const he=He.path,at=he?`${he}/`:"",it=Lt(`${at}${G.trim()}`);await i.createDirectory(it).then(async Et=>{Et.success&&(Oe.success(o("sidebarFilesTree.toast.folderCreated")),await ae(he)),we()}).catch(()=>Oe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(P);return}if(M==="rename"){if(!G.trim()){Oe.error(o("sidebarFilesTree.toast.nameRequired")),P();return}if(!i.rename){Oe.error(o("sidebarFilesTree.toast.renameNotSupported")),P();return}const he=He.path,at=he.split("/").slice(0,-1).join("/"),it=at?`${at}/`:"",Et=G.trim(),Dt=Lt(`${it}${Et}`);try{const Pt=await Ua(i,{tabs:f,files:l},he,Dt);Pt==="moved"?(Oe.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await ae(at),we()):Pt==="conflict"?Oe.error(o("sidebarFilesTree.toast.nameTaken",{name:Et,folder:zn(l,at)})):Oe.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Oe.error(o("sidebarFilesTree.toast.operationFailed"))}finally{P()}return}if(M==="delete"){if(!i.delete){Oe.error(o("sidebarFilesTree.toast.deleteNotSupported")),P();return}const he=He.path,at=he.split("/").slice(0,-1).join("/");await i.delete(he).then(async it=>{it.success&&(Oe.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await ae(at),l&&Ie(l,he),(ye===he||ye&&ye.startsWith(he+"/"))&&je(l,null)),we()}).catch(()=>Oe.error(o("sidebarFilesTree.toast.operationFailed"))).finally(P);return}P()},[M,He,G,i,f,ae,Ie,l,ye,je,o]),X=c.useMemo(()=>l?p2({root:l,childrenByDir:ge,expandedPaths:me,loadErrorsByDir:de}):[],[ge,me,de,l]),ot=c.useMemo(()=>new Map(X.flatMap((I,P)=>I.kind==="node"?[[I.node.path,P]]:[])),[X]),[xt,_t]=c.useState(null),[te,Qe]=c.useState(null),gt=c.useCallback(I=>{Ye.current=I,Qe(I)},[]),[wt,At]=c.useState(null),Vt=c.useMemo(()=>[z,wt,...Tt??[]].flatMap(I=>I?[ot.get(I)??-1]:[]),[wt,z,Tt,ot]),ys=c.useCallback(I=>m2(wx(I),Vt,X.length),[Vt,X.length]),[os,Cs]=c.useState(0);c.useLayoutEffect(()=>{if(!xt||!te)return;const I=te.getBoundingClientRect().top-xt.getBoundingClientRect().top+xt.scrollTop;Cs(Math.max(0,Math.round(I)))},[te,xt]);const Ts=c.useRef(null),ds=c.useRef(new Map),ss=c.useRef(null),ps=c.useCallback(I=>{const P=Math.max(0,...ds.current.values());I.style.setProperty("--oc-file-tree-width",`${P}px`)},[]),Qs=c.useCallback((I,P)=>{const we=I.dataset.treeRowPath,he=Ye.current;!we||!he||P<=he.clientWidth+.5||ds.current.get(we)!==P&&(ds.current.set(we,P),ss.current===null&&(ss.current=requestAnimationFrame(()=>{ss.current=null,Ye.current&&ps(Ye.current)})))},[ps]);c.useEffect(()=>()=>{ss.current!==null&&cancelAnimationFrame(ss.current)},[]),c.useLayoutEffect(()=>{if(!te)return;const I=ds.current;for(const he of I.keys())ot.has(he)||I.delete(he);const P=xt?.scrollLeft??0;te.style.removeProperty("--oc-file-tree-width");const we=te.clientWidth;for(const he of te.children){const at=he instanceof HTMLElement?he.dataset.treeRowPath:void 0;if(!at)continue;const it=he.getBoundingClientRect().width;it>we+.5?I.set(at,it):I.delete(at)}ps(te),xt&&(xt.scrollLeft=P)},[te,ot,xt,ps]);const Ks=bx({count:X.length,enabled:xt!==null,getScrollElement:()=>xt,estimateSize:I=>(X[I]?.kind==="node"?Ts.current:null)??h2,measureElement:(I,P,we)=>{const he=yx(I,P,we);return I.dataset.treeRowPath&&(Ts.current=he),P&&Qs(I,P.borderBoxSize?.[0]?.inlineSize??I.getBoundingClientRect().width),he},getItemKey:I=>X[I]?.key??I,overscan:12,scrollMargin:os,rangeExtractor:ys}),xn=I=>{if(I.kind==="error")return n.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:Zc(I.depth)},children:[n.jsx(Gc,{depth:I.depth}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:I.message,children:I.message}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{ae(I.directory)},children:[n.jsx(ce,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFolder")})]})]});const{node:P,depth:we,isExpanded:he}=I,at=P.type==="directory";return n.jsx(T2,{node:P,root:l,isExpanded:he,isActive:ye===P.path,isBrowserClient:u,depth:we,isOpen:!at&&ve.has(P.path),status:at?void 0:De(P.path),badge:at?ee(P.path):void 0,isDropTarget:at&&(ct===P.path||ie===P.path),isDragSource:z===P.path,canUpload:ht&&!dt,canMove:F,permissions:st,downloadFile:i.downloadFile,onSelect:le,onToggle:Nt,onRevealPath:mt,onOpenDialog:Y,onSetDropTarget:se,onDropFiles:Mt,onPickFiles:It,onMoveDragChange:Wt,onSetMoveDropTarget:O,onMoveDrop:Kt,guestActions:d})},ko=c.useCallback(I=>{const P=I.target instanceof Element?I.target.closest("[data-tree-row-path]"):null;At(P?.dataset.treeRowPath??null)},[]),jo=c.useCallback(I=>{I.relatedTarget instanceof Node&&I.currentTarget.contains(I.relatedTarget)||At(null)},[]);c.useEffect(()=>{const I=Be.current;if(!I||!xt||!te)return;const P=ot.get(I);P===void 0||xt.offsetParent===null||(Be.current=null,Ks.scrollToIndex(P,{align:"auto"}))});const vr=!!(l&&ge[l]),Mn=l?de[l]:null,Fn=y.trim().length>0,Co=!_&&!Fn&&A.length===0&&!Mn&&vr&&!!l,Ln=ct?zn(l,ct):"",Sr=ie?zn(l,ie):"",To=ne?ne.source.path.slice(ne.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-t border-edge-muted px-2",children:[n.jsxs("div",{className:"relative min-w-0 flex-1",children:[v?n.jsxs(fn,{children:[n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("span",{className:"absolute inset-s-0.5 top-1/2 inline-flex -translate-y-1/2",children:n.jsx(pn,{asChild:!0,children:n.jsx(ut,{variant:"ghost",size:"sm",className:"relative size-6 p-0 text-muted-foreground hover:text-foreground","aria-label":o("sidebarFilesTree.search.mode.aria"),children:n.jsx(ce,{name:$?"file-search":"search",className:"size-3.5"})})})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.mode.aria")})]}),n.jsx(mn,{align:"start",side:"bottom",children:n.jsxs(Lc,{value:C,onValueChange:I=>S(I==="contents"?"contents":"names"),children:[n.jsxs(Hr,{value:"names",closeOnClick:!0,className:"items-center",children:[n.jsx(ce,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),n.jsxs(Hr,{value:"contents",closeOnClick:!0,className:"items-center",children:[n.jsx(ce,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):n.jsx(ce,{name:"search",className:"pointer-events-none absolute inset-s-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),n.jsx(Rn,{ref:E,inputSize:"compact",value:b,onChange:I=>j(I.target.value),placeholder:o($?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Ze("ps-7",$?"pe-14":b.trim().length>0?"pe-7":"pe-2")}),$?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx(ut,{variant:"chip",size:"xs","aria-pressed":k,onClick:()=>{N(I=>!I),E.current?.focus()},"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-1 top-1/2 h-5 min-w-0 -translate-y-1/2 px-1 font-mono typography-micro",children:".*"})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o(k?"contextTooltips.files.searchPlainText":"sidebarFilesTree.search.regexTitle")})]}):null,b.trim().length>0?n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Ze("absolute top-1/2 inline-flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground hover:text-foreground",$?"inset-e-8":"inset-e-2"),onClick:()=>{j(""),E.current?.focus()},children:n.jsx(ce,{name:"close",className:"size-3.5"})})}),n.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.clearAria")})]}):null]}),n.jsx(Cg,{className:"shrink-0 gap-0.5",groups:[[(Te||Ae||ht)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:dt?"loader-4":"add",iconClassName:dt?"animate-spin":void 0,menu:n.jsxs(n.Fragment,{children:[Te?n.jsxs($s,{onClick:()=>Y("createFile",{path:e,type:"directory"}),children:[n.jsx(ce,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,Ae?n.jsxs($s,{onClick:()=>Y("createFolder",{path:e,type:"directory"}),children:[n.jsx(ce,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,ht?n.jsxs($s,{disabled:!l||dt,onClick:()=>It(l),children:[n.jsx(ce,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})}]],menuOnly:[{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:h,onSelect:()=>ef(!h)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{T()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{l&&ze(l)}}]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsxs(as,{ref:_t,outerClassName:"h-full min-h-0",className:Ze("@container px-1.5 py-1.5 [overflow-anchor:none]",(ct===l||ie===l)&&"bg-interactive-selection/10"),onDragEnter:Qt,onDragOver:Qt,onDragLeave:cs,onDrop:js,children:[n.jsx("ul",{className:"flex flex-col",children:$&&B.status!=="idle"?n.jsx(u2,{state:B,activeMatchKey:W&&W.path===ye?W.key:null,onOpen:et,onDragStart:xe,onDragEnd:bt}):_?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(ce,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Fn&&A.length===0?n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):A.length>0?A.map(I=>{const P=ye===I.path;return n.jsx("li",{"data-file-tree-path":I.path,children:n.jsxs("button",{type:"button",onClick:()=>le(I),onDoubleClick:()=>le(I,{pin:!0}),draggable:!0,onDragStart:we=>{ji(we),Xo(null);const he=I.relativePath||So(l??"",I.path);!he||he==="."||(we.dataTransfer.setData(ar,he),we.dataTransfer.effectAllowed="copy")},onDragEnd:we=>{Ci(we)&&le(I)},className:Ze("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Zi(P)),title:I.path,children:[n.jsx(mo,{filePath:I.path,extension:I.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`${I.relativePath??I.path}`})]})},I.path)}):Mn?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:Mn}),n.jsxs(kt,{children:[n.jsx(St,{asChild:!0,children:n.jsxs(ut,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{T()},children:[n.jsx(ce,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),n.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFileList")})]})]}):vr&&l?null:n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),Co?n.jsx("ul",{ref:gt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Ks.getTotalSize()},onFocus:ko,onBlur:jo,children:Ks.getVirtualItems().map(I=>{const P=X[I.index];if(!P)return null;const we=P.kind==="node"?P.node.path:void 0;return n.jsx("li",{ref:Ks.measureElement,"data-index":I.index,"data-tree-row-path":we,"data-tree-disclosure-path":P.kind==="node"?we:`${P.directory}/`,"data-file-tree-path":P.kind==="node"&&P.node.type==="file"?we:void 0,className:Ze("absolute inset-x-0 top-0",P.kind==="node"&&"min-w-max"),style:{transform:`translateY(${I.start-os}px)`},children:xn(P)},I.key)})}):null]}),ct?n.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:[n.jsx(ce,{name:dt?"loader-4":"folder-received",className:Ze("size-4 flex-shrink-0",dt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Ln,children:o(dt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Ln})})]}):ie?n.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:[n.jsx(ce,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Sr,children:o("sidebarFilesTree.drop.moveTarget",{path:Sr})})]}):null]}),Ht,n.jsx(sr,{open:!!M,onOpenChange:I=>!I&&Ce(null),children:n.jsxs(nr,{children:[n.jsxs(rr,{children:[n.jsxs(or,{children:[M==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),M==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),M==="rename"&&o("sidebarFilesTree.dialog.rename.title"),M==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(ir,{children:[M==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:He?.path??o("sidebarFilesTree.dialog.rootFallback")}),M==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:He?.path??o("sidebarFilesTree.dialog.rootFallback")}),M==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:He?.name??""}),M==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:He?.name??""})]})]}),M!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Rn,{value:G,onChange:I=>Ee(I.target.value),placeholder:o(M==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:I=>{I.key==="Enter"&&Rs()},autoFocus:!0})}),n.jsxs(Ur,{children:[n.jsx(ut,{variant:"outline",onClick:()=>Ce(null),disabled:Pe,children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(ut,{variant:M==="delete"?"destructive":"default",onClick:()=>{Rs()},disabled:Pe||M!=="delete"&&!G.trim(),children:Pe?n.jsx(ce,{name:"loader-4",className:"size-4 animate-spin"}):o(M==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(sr,{open:ne!==null,onOpenChange:I=>{I||V(null)},children:n.jsxs(nr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(rr,{children:[n.jsx(or,{children:o("sidebarFilesTree.dialog.move.title")}),n.jsx(ir,{children:ne?o("sidebarFilesTree.dialog.move.description",{name:To,folder:zn(l,ne.targetDirectory)}):null})]}),n.jsxs(Ur,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>q(!re),children:[n.jsx(ni,{checked:!re,onChange:I=>q(!I),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{variant:"ghost",onClick:()=>V(null),children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(ut,{onClick:ls,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function P2(t){return t.runtimeKey}const I2=mr(()=>Ft(()=>import("./WalkthroughView-B7KbSsAT.js"),__vite__mapDeps([213,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,214,186,187,188,189,190,191,192,193,194,195,181,182,183,185,196,197,198,199,200,201,202,203,204,215,216,217,218])).then(t=>({default:t.WalkthroughView}))),R2=mr(()=>Ft(()=>import("./DiffView-BZ72jtft.js"),__vite__mapDeps([219,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,214,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,220,185,196,197,198,199,200,201,202,203,204,205,206,207,208,210,211,215,218])).then(t=>({default:t.DiffView}))),D2=mr(()=>Ft(()=>import("./FilesView-C6unlf1o.js").then(t=>t.F),__vite__mapDeps([221,5,1,2,3,4,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,222,223,224,225,204,181,182,183,226,227,200,228,186,187,188,189,190,191,192,193,194,195,229,197,230,231,232,201,202,199,211,233,234,210,207,218,203,235])).then(t=>({default:t.FilesView}))),_2=c.lazy(()=>Ft(()=>import("./GuestPanelContent-VypuCChp.js"),__vite__mapDeps([236,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])).then(t=>({default:t.GuestPanelContent}))),vn=(t,e)=>`${t}\0${e}`,A2=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:o}=lt(),i=K(y=>y.contextEditorTreeWidth),a=K(y=>y.setContextEditorTreeWidth),[d,u]=c.useState(!1),l=c.useRef(0),f=c.useRef(i),m=c.useRef(null),p=c.useRef(null),h=c.useRef(null),x=c.useCallback(y=>{const E=h.current;E&&(E.style.width=`${y}px`,E.style.setProperty("--oc-editor-tree-width",`${y}px`))},[]),g=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}p.current=y.pointerId,u(!0),l.current=y.clientX,f.current=i,m.current=i,y.preventDefault()}},w=y=>{if(!d||p.current!==y.pointerId)return;const E=r==="left"?y.clientX-l.current:l.current-y.clientX,A=to(y.currentTarget)?-E:E,R=ei(f.current+A);m.current!==R&&(m.current=R,x(R))},b=y=>{if(p.current!==y.pointerId)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const E=ei(m.current??i);p.current=null,m.current=null,u(!1),a(E)},j=t?i:0;return n.jsxs("div",{ref:h,className:Ze("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${d?m.current??j:j}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${d?m.current??i:i}px`,overflowX:"clip",transitionProperty:d?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:Ze("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:Ze("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",d&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:w,onPointerUp:b,onPointerCancel:b,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:Ze("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(N2,{visible:t&&e})})]})},an=t=>{const e=Ue.c(12),{zone:s,isOpen:r,interactive:o,hidden:i,className:a,children:d}=t,u=!r||i;let l;e[0]!==d||e[1]!==u?(l=n.jsx(Xc,{paused:u,children:d}),e[0]=d,e[1]=u,e[2]=l):l=e[2];let f;e[3]!==o||e[4]!==l?(f=n.jsx(Hc.Provider,{value:!0,children:n.jsx(up.Provider,{value:o,children:l})}),e[3]=o,e[4]=l,e[5]=f):f=e[5];let m;e[6]!==a||e[7]!==f?(m=n.jsx("div",{className:a,children:f}),e[6]=a,e[7]=f,e[8]=m):m=e[8];let p;return e[9]!==m||e[10]!==s?(p=n.jsx(i2,{zone:s,children:m}),e[9]=m,e[10]=s,e[11]=p):p=e[11],p},O2=()=>{const{t}=lt(),e=Hs()??"",s=c.useMemo(()=>e?rs(e):"",[e]),r=K(M=>s?M.contextPanelByDirectory[s]:void 0),o=wr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,d=co(o,e)??"",u=K(M=>M.contextSurfaceZones),l=K(M=>M.contextPanelByDirectory),f=K(M=>M.closeContextPanelTab),m=K(M=>M.closeContextFile),p=K(M=>M.openContextPanelTab),h=K(M=>M.openAgentBrowserTab),x=K(M=>M.openContextFile),g=K(M=>M.contextEditorTreeVisible),w=K(M=>M.contextEditorVisible),b=K(M=>M.fileTreeSide),j=us(M=>M.setSelectedPath),y=dr(M=>M.headerSlot),E=c.useMemo(()=>r?.tabs??[],[r?.tabs]),A=_r(M=>M.chatCovered),R=c.useMemo(()=>{const M=Ce=>{const He=r?$r(r,u,Ce):null,Xe=Ce==="bottom"&&A;return{activeTab:He,isOpen:!!(r&&er(r,Ce).isOpen&&He)&&!Xe}};return{left:M("left"),right:M("right"),bottom:M("bottom")}},[A,r,u]),_={left:{...R.left,activeTab:Ar(R.left.activeTab,R.left.isOpen)},right:{...R.right,activeTab:Ar(R.right.activeTab,R.right.isOpen)},bottom:{...R.bottom,activeTab:Ar(R.bottom.activeTab,R.bottom.isOpen)}},L={left:qo(_.left.isOpen),right:qo(_.right.isOpen),bottom:qo(_.bottom.isOpen)},v=M=>!L[M],C={left:Xn(_.left.isOpen),right:Xn(_.right.isOpen),bottom:Xn(_.bottom.isOpen)},S={left:Ir(_.left.isOpen,C.left,_.left.activeTab?.mode),right:Ir(_.right.isOpen,C.right,_.right.activeTab?.mode),bottom:Ir(_.bottom.isOpen,C.bottom,_.bottom.activeTab?.mode)},k=M=>{const Ce=si(u,M);return{zone:Ce,..._[Ce]}},N=k("file"),$=k("chat"),B=k("browser"),D=k("diff"),W=k("terminal"),H=k("walkthrough"),[U,se]=c.useState([]),z=c.useCallback((M,Ce)=>{se(He=>tf(He,vn(M,Ce)))},[]),Q=K(M=>M.liveBrowserTabLimit);c.useEffect(()=>P0((M,Ce)=>{const He=Ce.directory?rs(Ce.directory):s;if(!He)return null;const Xe=h(He,M,Ce.sessionId);return Xe&&z(He,Xe),Xe}),[s,h,z]),c.useEffect(()=>I0((M,Ce)=>K.getState().contextPanelByDirectory[M]?.tabs?.some(Xe=>Xe.id===Ce&&Xe.mode==="browser")?(f(M,Ce),!0):!1),[f]),c.useEffect(()=>_n(M=>{if(M.type!=="file-open-request")return;const Ce=M.directory??e;Ce&&x(Ce,M.path)}),[e,x]),c.useEffect(()=>_n(M=>{if(M.type!=="plan-open-request")return;const Ce=M.directory??e,He=Tg(Ce,M.projectId);!Ce||!He||K.getState().openProjectKnowledgePlan(Ce,Ng(He),M.planId)}),[e]);const ie=R[B.zone].activeTab,O=ie?.mode==="browser"?ie.id:null;c.useEffect(()=>{E0(s,O)},[s,O]);const ne=R[N.zone].activeTab;c.useEffect(()=>{if(!d||ne?.mode!=="file"||!ne.targetPath)return;const M=bs(ne.targetPath)===bs(d);j(rs(d),ne.targetPath,{allowOutsideRoot:!o&&M})},[d,o,ne,j]);const V=c.useMemo(()=>E.some(M=>M.mode==="file"&&M.targetPath),[E]),J=c.useMemo(()=>E.some(M=>M.mode==="file"),[E]),F=V&&(w||!g),re=N.activeTab?.mode==="file",q=c.useCallback(M=>{s&&m(s,M)},[m,s]),ge=$.isOpen&&$.activeTab?.mode==="chat"?$.activeTab:null,Z=ge?bo(ge.dedupeKey):null,de=c.useMemo(()=>(ge?.targetDirectory?rs(ge.targetDirectory):"")||s||null,[ge?.targetDirectory,s]),Se=c.useMemo(()=>Z?{sessionId:Z,directory:de}:null,[Z,de]);c.useEffect(()=>{if(!de||!Z||typeof window>"u")return;const M=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Oo(de,Z,!1);return}Yc(Z),Oo(de,Z,!0)};M();const Ce=window.setInterval(M,1e4);return window.addEventListener("focus",M),window.addEventListener("blur",M),document.addEventListener("visibilitychange",M),()=>{window.clearInterval(Ce),window.removeEventListener("focus",M),window.removeEventListener("blur",M),document.removeEventListener("visibilitychange",M),Oo(de,Z,!1)}},[de,Z]);const ue=D.activeTab,ke=c.useCallback(M=>{!s||ue?.mode!=="diff"||p(s,{mode:"diff",targetPath:ue.targetPath,targetDirectory:ue.targetDirectory,stagedDiff:M==="staged",diffScope:M})},[ue,s,p]),Me=B.isOpen&&B.activeTab?.mode==="browser"?B.activeTab.id:null;c.useEffect(()=>{Me&&s&&z(s,Me)},[s,Me,z]);const{loadedBrowserTabs:We,sleepingBrowserTabs:Le}=c.useMemo(()=>{const M=new Set(U),Ce=new Set;for(const[Ee,Pe]of Object.entries(l))for(const Fe of Pe.tabs)Fe.mode==="browser"&&Fe.ownerSessionId===null&&Ce.add(vn(Ee,Fe.id));const He=sf(U,Ce,Q),Xe=[],G=[];for(const[Ee,Pe]of Object.entries(l)){const Fe=Ee===s;for(const Te of Pe.tabs){if(Te.mode!=="browser")continue;const Ae=vn(Ee,Te.id),qe=Te.ownerSessionId===null,Ge=Fe&&Te.id===Me||(qe?He.has(Ae):M.has(Ae));if(!Ge&&!Fe&&qe)continue;const Je={directory:Ee,id:Te.id,targetPath:Te.targetPath,ownerSessionId:Te.ownerSessionId};(Ge?Xe:G).push(Je)}}return Xe.sort((Ee,Pe)=>vn(Ee.directory,Ee.id)<vn(Pe.directory,Pe.id)?-1:1),{loadedBrowserTabs:Xe,sleepingBrowserTabs:G}},[l,s,Q,U,Me]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const M=Le.map(Ce=>N0({tabId:Ce.id,directory:Ce.directory,ownerSessionId:Ce.ownerSessionId,describe:()=>({title:"",url:Ce.targetPath??""}),wake:()=>z(Ce.directory,Ce.id)}));return()=>M.forEach(Ce=>Ce())},[Le,z]);const Ve=c.useMemo(()=>E.filter(M=>M.mode==="diff"),[E]),Ne=c.useMemo(()=>E.find(M=>M.mode==="terminal")??null,[E]),me=c.useMemo(()=>E.find(M=>M.mode==="walkthrough")??null,[E]),ye=c.useMemo(()=>E.filter(M=>Pn(M.mode)),[E]),je=tr(M=>M.guests),Be=c.useMemo(()=>new Set(je.filter(Eg).map(M=>M.id)),[je]),_e=c.useMemo(()=>{const M=new Map;for(const Ce of je){const He=Pg(Ce);He&&M.set(Ce.id,He)}return M},[je]),Ie=W.zone,tt=c.useCallback(M=>{const Ce=ta({mode:"terminal",label:t("layout.mainTab.terminal"),from:Ie},M);return{finish:()=>Ce.finish(s),cancel:Ce.cancel}},[s,t,Ie]),Ke=(M,Ce)=>Ce?y[M]:null,[ze,rt]=c.useState(()=>new Set),ve=ye.filter(M=>{if(ze.has(M.id))return!1;const Ce=k(M.mode);return Ce.isOpen&&Ce.activeTab?.id===M.id});return ve.length>0&&rt(new Set([...ze,...ve.map(M=>M.id)])),n.jsxs(n.Fragment,{children:[J?n.jsxs(an,{zone:N.zone,interactive:S[N.zone],isOpen:N.isOpen,hidden:v(N.zone),className:Ze("absolute inset-0 flex",b==="left"&&"flex-row-reverse",re?"flex":"hidden"),children:[i?n.jsx("div",{className:"h-full min-w-0 flex-1",children:n.jsx(Rr,{})}):V||!g?n.jsx("div",{className:Ze("h-full min-w-0 flex-1",V&&!F&&"hidden"),children:V?n.jsx(c.Suspense,{fallback:null,children:n.jsx(D2,{mode:"editor-only",visible:!v(N.zone)&&re&&F,onCloseFile:q})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(ce,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,i?null:n.jsx(A2,{visible:g,active:N.isOpen&&re,fill:!F,side:b})]}):null,ge&&Z&&Se?n.jsx(an,{zone:$.zone,interactive:S[$.zone],isOpen:$.isOpen,hidden:v($.zone),className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:Z}),className:"h-full",children:n.jsx(yc,{pinnedSession:Se,readOnly:ge.readOnly})})},ge.id):null,We.map(M=>{const Ce=M.directory===s&&B.activeTab?.id===M.id,He=M.directory===s?a??M.directory:M.directory;return n.jsx(an,{zone:B.zone,interactive:S[B.zone],isOpen:B.isOpen,hidden:v(B.zone),className:Ze("absolute inset-0",!Ce&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!Ce||void 0,children:n.jsx(Xc,{paused:!Ce,children:M.directory===s&&i?n.jsx(Rr,{}):n.jsx(t2,{initialUrl:M.targetPath??"",directory:M.directory,siteDirectory:He,tabID:M.id,ownerSessionId:M.ownerSessionId,visible:Ce&&B.isOpen},He)})})},vn(M.directory,M.id))}),Ve.map(M=>{const Ce=D.activeTab?.id===M.id;return n.jsx(an,{zone:D.zone,interactive:S[D.zone],isOpen:D.isOpen,hidden:v(D.zone),className:Ze("absolute inset-0",!Ce&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(cn,{value:Ke(D.zone,Ce),children:i&&!M.targetDirectory?n.jsx(Rr,{}):n.jsx(R2,{directory:M.targetDirectory??a,visible:D.isOpen&&Ce,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:M.diffScope??(M.stagedDiff?"staged":null),onDiffScopeChange:ke,targetFilePath:M.targetPath,flushContent:!0})})})},M.id)}),Ne?n.jsx(an,{zone:W.zone,interactive:S[W.zone],isOpen:W.isOpen,hidden:v(W.zone),className:Ze("absolute inset-0",W.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(cn,{value:Ke(W.zone,W.activeTab?.mode==="terminal"),children:n.jsx(cp.Provider,{value:tt,children:n.jsx(dp,{visible:W.isOpen&&W.activeTab?.mode==="terminal",directory:Ne.targetDirectory,onLastTabClosed:()=>{s&&f(s,Ne.id)}})})})}):null,me?n.jsx(an,{zone:H.zone,interactive:S[H.zone],isOpen:H.isOpen,hidden:v(H.zone),className:Ze("absolute inset-0",H.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(cn,{value:Ke(H.zone,H.activeTab?.mode==="walkthrough"),children:n.jsx(I2,{directory:me.targetDirectory??e,visible:H.isOpen&&H.activeTab?.mode==="walkthrough"})})})}):null,ye.map(M=>{if(!Pn(M.mode))return null;const Ce=k(M.mode);if(!ze.has(M.id))return null;const He=zr(M.mode),Xe=Be.has(He),G=_e.get(He),Ee=Ce.activeTab?.id===M.id,Pe=Ee&&Ce.isOpen;return Xe&&!G&&!Pe?null:n.jsx(an,{zone:Ce.zone,interactive:S[Ce.zone],isOpen:Ce.isOpen,hidden:v(Ce.zone),className:Ze("absolute inset-0",Ee?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(_2,{mode:M.mode,sharedSurface:Xe,docking:G??null,surfaceMounted:Pe})})},M.id)})]})},M2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},F2=()=>{const t=Ue.c(20),{t:e}=lt(),s=Vs(L2),r=Vs(B2),o=c.useRef(null),[i,a]=c.useState(!1);let d,u;t[0]!==s?(d=()=>{if(!s){a(!1);return}const b=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(b)},u=[s],t[0]=s,t[1]=d,t[2]=u):(d=t[1],u=t[2]),c.useEffect(d,u);let l,f;if(t[3]!==s?(l=()=>{if(!s)return;const b=j=>{const y=o.current;y&&(y.style.transform=`translate(${j.clientX+12}px, ${j.clientY+12}px)`)};return window.addEventListener("pointermove",b),()=>window.removeEventListener("pointermove",b)},f=[s],t[3]=s,t[4]=l,t[5]=f):(l=t[4],f=t[5]),c.useEffect(l,f),!s)return null;const m=i?"opacity-100":"opacity-0";let p;t[6]!==m?(p=Ze("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",m),t[6]=m,t[7]=p):p=t[7];let h;t[8]!==p?(h=n.jsx("div",{className:p}),t[8]=p,t[9]=h):h=t[9];let x;t[10]!==s.frames||t[11]!==r||t[12]!==e?(x=Ri.map(b=>{const j=s.frames[b];if(j.width<=0||j.height<=0)return null;const y=r===b;return n.jsx("div",{className:Ze("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:j.left,top:j.top,width:j.width,height:j.height},children:n.jsx("span",{className:"typography-ui-label",children:e(M2[b])})},b)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==s.label?(g=n.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:s.label}),t[14]=s.label,t[15]=g):g=t[15];let w;return t[16]!==h||t[17]!==x||t[18]!==g?(w=Gl.createPortal(n.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]=w):w=t[19],w};function L2(t){return t.drag}function B2(t){return t.hovered}const Rl=320,$2=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let i=t-e-s;if(i>=Rl)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Rl)return{collapseSidebar:a,displace:null};const d=o==="left"?"right":"left";return{collapseSidebar:a,displace:(d==="left"?e:s)>0?d:null}},z2=({directoryKey:t,folded:e,readRowWidth:s})=>{const r=w=>{const b=w.contextPanelByDirectory[t];return{left:Kn(b,w.contextSurfaceZones,"left"),right:Kn(b,w.contextSurfaceZones,"right")}},o=(w,b,j)=>{const y=w.contextPanelByDirectory[t];return(j&&y?$r(y,w.contextSurfaceZones,b):null)?w.contextZoneSizes[b]??Ii:0},i=w=>{const b=w.contextPanelByDirectory[t];return b?Ri.some(j=>er(b,j).expanded&&nf(b,w,j)):!1};let a=null,d=!1,u=r(K.getState()),l=i(K.getState());const f=w=>{e.current=w,K.getState().setSidebarFoldedForExpandedZone(w==="expanded")},m=w=>{d=!0,K.getState().setSidebarOpen(w),d=!1},p=()=>{f(null),K.getState().isSidebarOpen||m(!0)};!e.current&&K.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?l:u[h])&&p(),!e.current&&l&&K.getState().isSidebarOpen&&(f("expanded"),m(!1));const x=(w,b,j)=>{const y=s();if(!y)return;const E=e.current==="expanded",A=$2({rowWidth:E?y-w.sidebarWidth:y,leftWidth:o(w,"left",j.left),rightWidth:o(w,"right",j.right),sidebarWidth:w.isSidebarOpen||E?w.sidebarWidth:null,opening:b});if(A.displace){const R=er(w.contextPanelByDirectory[t],A.displace).activeTabId;R&&(a={side:A.displace,by:b,tabId:R})}A.collapseSidebar&&(f(b),w.isSidebarOpen&&m(!1)),A.displace&&w.closeContextZone(t,A.displace)},g=w=>{if(a?.side===w){e.current===w&&f(a.by);return}const b=a?.by===w?a:null;b&&(a=null),e.current===w&&(b?f(b.side):p()),b&&K.getState().setActiveContextPanelTab(t,b.tabId)};return K.subscribe((w,b)=>{w.isSidebarOpen!==b.isSidebarOpen&&!d&&f(null);const j=r(w),y=i(w),E=u,A=l;u=j,l=y;const R=["left","right"],_=R.filter(v=>j[v]&&!E[v]),L=R.filter(v=>!j[v]&&E[v]);for(const v of L){const C=v==="left"?"right":"left";_.includes(C)&&(e.current===v&&f(C),a?.by===v&&(a=null))}for(const v of L)g(v);for(const v of _)x(w,v,j);y&&!A&&w.isSidebarOpen?(f("expanded"),m(!1)):!y&&A&&e.current==="expanded"&&p()})},W2=()=>{const t=Ue.c(5),e=Hs();let s;t[0]!==e?(s=e?rs(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=c.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return z2({directoryKey:r,folded:o,readRowWidth:U2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),c.useEffect(i,a),null};function U2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const V2=t=>{const e=Ue.c(54),{open:s,onOpenChange:r}=t,{t:o}=lt(),i=K(H2),a=K(K2),d=K(q2),u=K(G2),l=K(Z2),f=qi(),m=K(Ig);let p;if(e[0]!==i||e[1]!==f||e[2]!==m){let U;e[4]!==m?(U=se=>m||se.id!=="workflows",e[4]=m,e[5]=U):U=e[5],p=ri(i,f).filter(U),e[0]=i,e[1]=f,e[2]=m,e[3]=p}else p=e[3];const h=p,x=d.length===0;let g;if(e[6]!==d||e[7]!==h){let U;e[9]!==d?(U=se=>d.includes(se.id),e[9]=d,e[10]=U):U=e[10],g=h.every(U),e[6]=d,e[7]=h,e[8]=g}else g=e[8];const w=g,b=c.useRef(!1);let j;e[11]!==d||e[12]!==h||e[13]!==o?(j=h.map((U,se)=>({id:U.id,label:U.label??o(U.labelKey),visible:!d.includes(U.id),groupStart:se>0&&Gs(h[se-1])!==Gs(U)})),e[11]=d,e[12]=h,e[13]=o,e[14]=j):j=e[14];const y=j;let E;e[15]!==i||e[16]!==f||e[17]!==a?(E=U=>{const se=ri(U,f).map(X2).filter(Q=>U.includes(Q)),z=new Set(se);a([...se,...i.filter(Q=>!z.has(Q))])},e[15]=i,e[16]=f,e[17]=a,e[18]=E):E=e[18];const A=E;let R;e[19]!==r?(R=(U,se)=>{if(!U&&se.reason==="escape-key"&&b.current){se.cancel(),se.allowPropagation();return}b.current=!1,r(U)},e[19]=r,e[20]=R):R=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=U=>{b.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(U.key)&&U.preventBaseUIHandler()},e[21]=_):_=e[21];let L;e[22]!==o?(L=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=L):L=e[23];let v;e[24]!==L?(v=n.jsx(or,{children:L}),e[24]=L,e[25]=v):v=e[25];let C;e[26]!==o?(C=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=C):C=e[27];let S;e[28]!==C?(S=n.jsx(ir,{children:C}),e[28]=C,e[29]=S):S=e[29];let k;e[30]!==S||e[31]!==v?(k=n.jsxs(rr,{children:[v,S]}),e[30]=S,e[31]=v,e[32]=k):k=e[32];let N;e[33]!==o?(N=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=N):N=e[34];let $;e[35]===Symbol.for("react.memo_cache_sentinel")?($=U=>{b.current=U},e[35]=$):$=e[35];let B;e[36]!==A||e[37]!==y||e[38]!==u||e[39]!==N?(B=n.jsx(fp,{items:y,onVisibleChange:u,onReorder:A,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:N,onDraggingChange:$}),e[36]=A,e[37]=y,e[38]=u,e[39]=N,e[40]=B):B=e[40];let D;e[41]!==x||e[42]!==w||e[43]!==l||e[44]!==o?(D=x?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[w?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(ut,{variant:"link",size:"xs",onClick:()=>l([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=w,e[43]=l,e[44]=o,e[45]=D):D=e[45];let W;e[46]!==k||e[47]!==B||e[48]!==D?(W=n.jsxs(nr,{className:"max-w-md",onKeyDown:_,children:[k,B,D]}),e[46]=k,e[47]=B,e[48]=D,e[49]=W):W=e[49];let H;return e[50]!==s||e[51]!==W||e[52]!==R?(H=n.jsx(sr,{open:s,onOpenChange:R,children:W}),e[50]=s,e[51]=W,e[52]=R,e[53]=H):H=e[53],H};function H2(t){return t.contextRailOrder}function K2(t){return t.setContextRailOrder}function q2(t){return t.contextRailHiddenSurfaces}function G2(t){return t.setContextRailSurfaceVisible}function Z2(t){return t.setContextRailHiddenSurfaces}function X2(t){return t.id}const gu=150,Y2=500,J2=[],Q2=t=>{const e=Ue.c(69),{surface:s,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:d,badgeAriaLabel:u,badgeDescription:l,orderNumber:f,showOrderNumber:m,onSelect:p}=t,h=K(sk);let x;e[0]!==h?(x=Oi("switch_context_surface",h),e[0]=h,e[1]=x):x=e[1];const g=x;let w;e[2]!==f||e[3]!==g?(w=g&&g!==Sc&&f!=null&&f<=10?ws(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=w):w=e[4];const b=w;let j;e[5]!==s.id?(j={id:s.id},e[5]=s.id,e[6]=j):j=e[6];const{attributes:y,listeners:E,setNodeRef:A,transform:R,transition:_,isDragging:L}=xd(j),v=d!=null&&d>0;let C;e[7]!==R?(C=wd.Translate.toString(R),e[7]=R,e[8]=C):C=e[8];let S;e[9]!==C||e[10]!==_?(S={transform:C,transition:_},e[9]=C,e[10]=_,e[11]=S):S=e[11];const k=L&&"z-10 opacity-70";let N;e[12]!==k?(N=Ze("relative",k),e[12]=k,e[13]=N):N=e[13];let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("div",{}),e[14]=$):$=e[14];let B;e[15]!==p||e[16]!==s?(B=()=>p(s),e[15]=p,e[16]=s,e[17]=B):B=e[17];const D=u??i,W=s.id,H=r?"oc-selected text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground";let U;e[18]!==H?(U=Ze("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",H),e[18]=H,e[19]=U):U=e[19];let se;e[20]!==s.icon||e[21]!==s.iconSrc?(se=n.jsx(Gi,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=s.icon,e[21]=s.iconSrc,e[22]=se):se=e[22];let z;e[23]!==v||e[24]!==f||e[25]!==o||e[26]!==m?(z=m&&f!=null?n.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}):v?n.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?n.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[23]=v,e[24]=f,e[25]=o,e[26]=m,e[27]=z):z=e[27];let Q;e[28]!==y||e[29]!==r||e[30]!==E||e[31]!==s.id||e[32]!==D||e[33]!==U||e[34]!==se||e[35]!==z||e[36]!==B?(Q=n.jsx(St,{asChild:!0,children:n.jsxs("button",{type:"button",...y,...E,onClick:B,"aria-label":D,"aria-pressed":r,"data-context-surface":W,className:U,children:[se,z]})}),e[28]=y,e[29]=r,e[30]=E,e[31]=s.id,e[32]=D,e[33]=U,e[34]=se,e[35]=z,e[36]=B,e[37]=Q):Q=e[37];let ie;e[38]!==h||e[39]!==s.id||e[40]!==b?(ie=s.id==="terminal"?ws(Ws("toggle_terminal",h),""):b,e[38]=h,e[39]=s.id,e[40]=b,e[41]=ie):ie=e[41];let O;e[42]!==i||e[43]!==ie?(O=n.jsx(Us,{label:i,shortcut:ie}),e[42]=i,e[43]=ie,e[44]=O):O=e[44];let ne;e[45]!==a?(ne=n.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[45]=a,e[46]=ne):ne=e[46];let V;e[47]!==l?(V=l?n.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null,e[47]=l,e[48]=V):V=e[48];let J;e[49]!==s.id?(J=s.id==="context"?n.jsx(Sd,{}):null,e[49]=s.id,e[50]=J):J=e[50];let F;e[51]!==O||e[52]!==ne||e[53]!==V||e[54]!==J?(F=n.jsx(jt,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[O,ne,V,J]})}),e[51]=O,e[52]=ne,e[53]=V,e[54]=J,e[55]=F):F=e[55];let re;e[56]!==Q||e[57]!==F?(re=n.jsx(ao,{render:$,children:n.jsxs(kt,{delayDuration:gu,children:[Q,F]})}),e[56]=Q,e[57]=F,e[58]=re):re=e[58];let q;e[59]!==s.mode?(q=n.jsx(br,{children:n.jsx(bc,{mode:s.mode})}),e[59]=s.mode,e[60]=q):q=e[60];let ge;e[61]!==re||e[62]!==q?(ge=n.jsxs(xr,{children:[re,q]}),e[61]=re,e[62]=q,e[63]=ge):ge=e[63];let Z;return e[64]!==A||e[65]!==ge||e[66]!==S||e[67]!==N?(Z=n.jsx("div",{ref:A,style:S,className:N,children:ge}),e[64]=A,e[65]=ge,e[66]=S,e[67]=N,e[68]=Z):Z=e[68],Z},ek=t=>{if(!t)return{icon:"ticket-2"};const e=Og(t,"line");return e?{icon:e}:{icon:Mg,iconSrc:Fg(t)}},tk=()=>{const t=Ue.c(122),{t:e}=lt(),s=Hs();let r;t[0]!==s?(r=s?rs(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=De=>o?De.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=K(i),d=K(nk),u=K(rk),l=K(ok),f=K(ik),m=K(ak),p=K(lk),h=K(ck),x=K(dk),g=rf();let w;t[4]!==g?(w=De=>g.some(ee=>ee.instances.defaultInstance!==null&&De.entries[Un({provider:ee.id,instance:ee.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=w):w=t[5];const b=un(w),j=un(fk),y=Rg(o||null),E=Pi(y==="none"?null:y??g[0]?.id),A=y==="none"?"pullRequest":E.terminology.changeRequest,{screenWidth:R}=hn(),_=wr(),L=s??null;let v;t[6]!==_||t[7]!==L?(v=co(_,L),t[6]=_,t[7]=L,t[8]=v):v=t[8];const C=v,S=Dg(C),k=fo(S),{git:N}=ks(),$=Dn(pk),B=Dn(mk);let D,W;t[9]!==$||t[10]!==B||t[11]!==N||t[12]!==S||t[13]!==C?(D=()=>{if(!N||!C||!S||S===C)return;da(()=>$(S,N));const De=Jt(C),ee=Jt(S);return lr.onGitRefreshHint(le=>{const et=Jt(le.directory);et!==De&&et!==ee||da(()=>B(S,N,{silent:!0}))})},W=[$,B,N,S,C],t[9]=$,t[10]=B,t[11]=N,t[12]=S,t[13]=C,t[14]=D,t[15]=W):(D=t[14],W=t[15]),c.useEffect(D,W);let H;t[16]!==x?(H=Oi("switch_context_surface",x),t[16]=x,t[17]=H):H=t[17];const U=H,[se,z]=c.useState(!1);let Q,ie;t[18]!==U?(ie=()=>{const De=new Set;let ee=null,le=!1;const et=hk,xe=()=>{Aa(U,De)?!le&&ee===null&&(ee=setTimeout(()=>z(!0),Y2)):(le=!1,ee!==null&&(clearTimeout(ee),ee=null),z(!1))},bt=Rt=>{if(De.add(Rt.key.toLowerCase()),et(Rt.key)&&Aa(U,De)){le=!0,ee!==null&&(clearTimeout(ee),ee=null),z(!1);return}xe()},Tt=Rt=>{De.delete(Rt.key.toLowerCase()),xe()},vt=()=>{De.clear(),le=!1,ee!==null&&(clearTimeout(ee),ee=null),z(!1)};return window.addEventListener("keydown",bt,!0),window.addEventListener("keyup",Tt,!0),window.addEventListener("blur",vt),()=>{window.removeEventListener("keydown",bt,!0),window.removeEventListener("keyup",Tt,!0),window.removeEventListener("blur",vt),ee!==null&&clearTimeout(ee)}},Q=[U],t[18]=U,t[19]=Q,t[20]=ie):(Q=t[19],ie=t[20]),c.useEffect(ie,Q);let O;t[21]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{distance:8}},t[21]=O):O=t[21];let ne;t[22]===Symbol.for("react.memo_cache_sentinel")?(ne={activationConstraint:{delay:200,tolerance:6}},t[22]=ne):ne=t[22];const V=pd(Kr(hd,O),Kr(md,ne)),J=qi(),F=_a(gk),re=_a(xk),q=a?.tabs??J2,ge=_g(q,s||null);let Z;t[23]!==h||t[24]!==a?(Z=Ei(a,h),t[23]=h,t[24]=a,t[25]=Z):Z=t[25];const de=Z,Se=k?.files.length??0;let ue;if(t[26]!==l||t[27]!==u||t[28]!==J||t[29]!==y||t[30]!==R||t[31]!==j||t[32]!==q||t[33]!==E||t[34]!==ge){let De;t[36]!==y||t[37]!==E?(De=ee=>ee.id==="pr"?{...ee,...ek(y==="none"?null:E)}:ee,t[36]=y,t[37]=E,t[38]=De):De=t[38],ue=Ag({railOrder:u,hiddenSurfaces:l,isVSCode:pr(),screenWidth:R,tabs:q,sourceControlConnected:j,workflowsShown:ge,extras:J}).map(De),t[26]=l,t[27]=u,t[28]=J,t[29]=y,t[30]=R,t[31]=j,t[32]=q,t[33]=E,t[34]=ge,t[35]=ue}else ue=t[35];const ke=ue;let Me;t[39]!==q?(Me=q.some(bk),t[39]=q,t[40]=Me):Me=t[40];const We=Me;let Le,Ve;t[41]!==p||t[42]!==h||t[43]!==b||t[44]!==o||t[45]!==We||t[46]!==de||t[47]!==j?(Le=()=>{!o||!b||j||We||!de.has("pr")||p(o,si(h,"pr"))},Ve=[p,h,o,b,We,de,j],t[41]=p,t[42]=h,t[43]=b,t[44]=o,t[45]=We,t[46]=de,t[47]=j,t[48]=Le,t[49]=Ve):(Le=t[48],Ve=t[49]),c.useEffect(Le,Ve);const[Ne,me]=c.useState(!1),ye=c.useRef(null),je=c.useRef(null);let Be;t[50]!==A||t[51]!==ke||t[52]!==e?(Be=De=>{const ee=ke.find(et=>et.id===De.active.id),le=ye.current?.getBoundingClientRect().left;!ee||le===void 0||(je.current?.cancel(),je.current=ta({mode:ee.mode,label:ee.label??e(Ls(ee.labelKey,A)),from:si(K.getState().contextSurfaceZones,ee.mode)},et=>et.x<le-16))},t[50]=A,t[51]=ke,t[52]=e,t[53]=Be):Be=t[53];const _e=Be;let Ie;t[54]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>{je.current?.cancel(),je.current=null},t[54]=Ie):Ie=t[54];const tt=Ie;let Ke,ze;t[55]===Symbol.for("react.memo_cache_sentinel")?(Ke=()=>()=>je.current?.cancel(),ze=[],t[55]=Ke,t[56]=ze):(Ke=t[55],ze=t[56]),c.useEffect(Ke,ze);let rt;t[57]!==o||t[58]!==J||t[59]!==f?(rt=De=>{const ee=je.current;if(je.current=null,ee?.finish(o))return;const{active:le,over:et}=De;if(!et||le.id===et.id)return;const xe=ri(K.getState().contextRailOrder,J),bt=Ye=>{const ft=xe.find(Nt=>Nt.id===Ye);return ft?Gs(ft):null};if(bt(le.id)!==bt(et.id))return;const Tt=xe.map(wk),vt=Tt.indexOf(le.id),Rt=Tt.indexOf(et.id);vt===-1||Rt===-1||f(cx(Tt,vt,Rt))},t[57]=o,t[58]=J,t[59]=f,t[60]=rt):rt=t[60];const ve=rt;let M;if(t[61]!==ke){M=[];for(const De of ke){const ee=M.at(-1);ee&&Gs(ee[0])===Gs(De)?ee.push(De):M.push([De])}t[61]=ke,t[62]=M}else M=t[62];const Ce=M;let He;t[63]!==ke?(He=De=>{const ee=ke.find(et=>et.id===De.active.id);if(!ee)return li(De);const le=Gs(ee);return li({...De,droppableContainers:De.droppableContainers.filter(et=>{const xe=ke.find(bt=>bt.id===et.id);return xe!==void 0&&Gs(xe)===le})})},t[63]=ke,t[64]=He):He=t[64];const Xe=He;if(!o)return null;let G,Ee,Pe,Fe,Te,Ae,qe,Ge,Je,st;if(t[65]!==A||t[66]!==Se||t[67]!==re||t[68]!==Xe||t[69]!==o||t[70]!==Ce||t[71]!==F||t[72]!==ve||t[73]!==_e||t[74]!==m||t[75]!==se||t[76]!==V||t[77]!==de||t[78]!==e||t[79]!==d){let De=0;Ge=ye,t[90]!==e?(Je=e("contextRail.aria.rail"),t[90]=e,t[91]=Je):Je=t[91],st="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",G=gd,Ee=V,Pe=Xe,Fe=_e,Te=tt,Ae=ve,qe=Ce.map((ee,le)=>n.jsxs(c.Fragment,{children:[le>0?n.jsx("div",{"aria-hidden":"true",className:"h-1.5 shrink-0"}):null,n.jsx(bd,{items:ee.map(yk),strategy:lx,children:ee.map(et=>{De=De+1;const xe=et.label??e(Ls(et.labelKey,A)),bt=et.id==="git"&&!d?Se:0,Tt=Pn(et.mode)&&!de.has(et.mode)?F[zr(et.mode)]??0:0,vt=bt>0?bt:Tt>0?Tt:null,Rt=vt!==null&&bt===0;return n.jsx(Q2,{surface:et,isActive:de.has(et.mode),showActivityDot:!1,label:xe,description:e(Ls(et.descriptionKey,A)),badgeCount:vt,badgeAriaLabel:vt!==null?e(Rt?vt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":vt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:xe,count:vt}):null,badgeDescription:vt!==null?e(Rt?vt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":vt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:vt}):null,orderNumber:De,showOrderNumber:se,onSelect:Ye=>{Pn(Ye.mode)&&re(zr(Ye.mode)),m(o,Ye.mode)}},et.id)})})]},Gs(ee[0]))),t[65]=A,t[66]=Se,t[67]=re,t[68]=Xe,t[69]=o,t[70]=Ce,t[71]=F,t[72]=ve,t[73]=_e,t[74]=m,t[75]=se,t[76]=V,t[77]=de,t[78]=e,t[79]=d,t[80]=G,t[81]=Ee,t[82]=Pe,t[83]=Fe,t[84]=Te,t[85]=Ae,t[86]=qe,t[87]=Ge,t[88]=Je,t[89]=st}else G=t[80],Ee=t[81],Pe=t[82],Fe=t[83],Te=t[84],Ae=t[85],qe=t[86],Ge=t[87],Je=t[88],st=t[89];let mt;t[92]!==G||t[93]!==Ee||t[94]!==Pe||t[95]!==Fe||t[96]!==Te||t[97]!==Ae||t[98]!==qe?(mt=n.jsx(G,{sensors:Ee,collisionDetection:Pe,onDragStart:Fe,onDragCancel:Te,onDragEnd:Ae,children:qe}),t[92]=G,t[93]=Ee,t[94]=Pe,t[95]=Fe,t[96]=Te,t[97]=Ae,t[98]=qe,t[99]=mt):mt=t[99];let Y;t[100]!==e?(Y=e("contextRail.configure.open"),t[100]=e,t[101]=Y):Y=t[101];let fe;t[102]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>me(!0),t[102]=fe):fe=t[102];let Re;t[103]===Symbol.for("react.memo_cache_sentinel")?(Re=n.jsx(ce,{name:"list-settings",className:"h-[17px] w-[17px]"}),t[103]=Re):Re=t[103];let T;t[104]!==Y?(T=n.jsx(St,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":Y,onClick:fe,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:Re})}),t[104]=Y,t[105]=T):T=t[105];let ae;t[106]!==e?(ae=e("contextRail.configure.open"),t[106]=e,t[107]=ae):ae=t[107];let pe;t[108]!==ae?(pe=n.jsx(jt,{side:"left",sideOffset:8,children:ae}),t[108]=ae,t[109]=pe):pe=t[109];let oe;t[110]!==T||t[111]!==pe?(oe=n.jsxs(kt,{delayDuration:gu,children:[T,pe]}),t[110]=T,t[111]=pe,t[112]=oe):oe=t[112];let be;t[113]!==Ne?(be=n.jsx(V2,{open:Ne,onOpenChange:me}),t[113]=Ne,t[114]=be):be=t[114];let $e;return t[115]!==Ge||t[116]!==Je||t[117]!==st||t[118]!==mt||t[119]!==oe||t[120]!==be?($e=n.jsxs("nav",{ref:Ge,"aria-label":Je,className:st,children:[mt,oe,be]}),t[115]=Ge,t[116]=Je,t[117]=st,t[118]=mt,t[119]=oe,t[120]=be,t[121]=$e):$e=t[121],$e};function sk(t){return t.shortcutOverrides}function nk(t){return t.workStatusPanelVisible}function rk(t){return t.contextRailOrder}function ok(t){return t.contextRailHiddenSurfaces}function ik(t){return t.setContextRailOrder}function ak(t){return t.openContextSurface}function lk(t){return t.closeContextZone}function ck(t){return t.contextSurfaceZones}function dk(t){return t.shortcutOverrides}function uk(t){return t.status?.status==="connected"}function fk(t){return Object.values(t.entries).some(uk)}function pk(t){return t.ensureStatus}function mk(t){return t.fetchStatus}function hk(t){return t.length===1&&t>="0"&&t<="9"}function gk(t){return t.countByGuest}function xk(t){return t.clearBadge}function bk(t){return t.mode==="pr"&&t.targetPath}function wk(t){return t.id}function yk(t){return t.id}const Ns=t=>t?n.jsx("span",{className:"oc-title-rest",children:t}):void 0,xs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},vk=()=>{const{t}=lt(),{git:e,sourceControl:s}=ks(),{childStores:r}=Lg(),[o,i]=c.useState(!1),[a,d]=c.useState(null),[u,l]=c.useState([]),[f,m]=c.useState(!1),[p,h]=c.useState(!1),[x,g]=c.useState(!1),[w,b]=c.useState(!1),[j,y]=c.useState(!1),[E,A]=c.useState(new Set),R=nt(G=>G.getWorktreeMetadata),_=nt(G=>G.setNewSessionDraftTarget),L=nt(G=>G.setDraftBootstrapPendingDirectory),v=zg,C=Hg,S=nt(G=>G.deleteSessions),k=nt(G=>G.archiveSessions),N=nt(G=>G.unarchiveSessions),$=K(G=>G.showDeletionDialog),B=K(G=>G.setShowDeletionDialog),D=zt(G=>G.currentDirectory),W=zt(G=>G.homeDirectory),H=Gt(G=>G.projects),U=Gt(G=>G.activeProjectId),{isMobile:se,isTablet:z,hasTouchInput:Q}=hn(),ie=se||z||Q,O=c.useMemo(()=>{const Ee=(U?H.find(Pe=>Pe.id===U)??null:null)?.path??D;return xs(Ee)},[U,D,H]),ne=c.useCallback(G=>{const Pe=xs(G.projectDirectory)||O;return{id:(H.find(Te=>xs(Te.path)===Pe)??null)?.id??`path:${Pe}`,path:Pe}},[O,H]),V=j&&E.size>0,[J,F]=c.useState(!1),re=a?.mode==="worktree"?a.worktree??u[0]?.metadata??null:null,q=re?.path,ge=re?.branch,Z=re?ne(re).path:null;c.useEffect(()=>{if(F(!1),!q||!Z)return;let G=!1;return Bg(Z,{path:q,branch:ge??""}).then(Ee=>{G||F(Ee)}),()=>{G=!0}},[ge,q,Z]);const de=c.useMemo(()=>{if(!J)return!1;const G=a?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!!G.status?.upstream?.split("/")[0]?.trim():u.length>0&&u.every(({metadata:Ee})=>typeof Ee.branch=="string"&&Ee.branch.trim().length>0&&!!Ee.status?.upstream?.split("/")[0]?.trim())},[J,a?.worktree,u]),Se=a?.mode==="worktree",ue=w||!Se||!de,ke=w||!Se,Me=Se?q:void 0,We=c.useCallback(G=>Me?$g(r,G):()=>{},[r,Me]),Le=c.useSyncExternalStore(We,()=>Me?Oa(r,Me).length:0),Ve=x&&Le>0,Ne=c.useCallback(G=>{d({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),me=c.useCallback(()=>{d(null),l([]),m(!1),h(!1),g(!1),b(!1),y(!1),A(new Set)},[]),ye=c.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const Te=G.sessions[0];await v(Te.id)?Oe.success(t("sessions.sidebar.session.delete.success")):Oe.error(t("sessions.sidebar.session.delete.error"));return}const Ee=G.sessions.map(Te=>Te.id),{deletedIds:Pe,failedIds:Fe}=await S(Ee);if(Pe.length>0){const Te=Fe.length>0?Fe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Fe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Fe.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.dateLabel}):void 0;Oe.success(Pe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Pe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Pe.length}),{description:Ns(Te)})}Fe.length>0&&Oe.error(Fe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Fe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Fe.length}),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[v,S,t]);c.useEffect(()=>lr.onDirectoryRequest(()=>{i(!0)}),[]),c.useEffect(()=>{if(!a){l([]),m(!1),h(!1),g(!1),y(!1),A(new Set);return}const G=a.sessions.map(Fe=>{const Te=R(Fe.id);return Te?{session:Fe,metadata:Te}:null}).filter(Fe=>!!Fe);l(G),m(!1),y(!1),A(new Set);const Ee=new Map;if(a.worktree?.path&&Ee.set(xs(a.worktree.path),a.worktree),G.forEach(({metadata:Fe})=>{Fe.path&&Ee.set(xs(Fe.path),Fe)}),Ee.size===0){y(!0);return}let Pe=!1;return(async()=>{const Fe=new Map,Te=new Set;await Promise.all(Array.from(Ee.entries()).map(async([Ae,qe])=>{try{const Ge=await Ma(qe.path);Fe.set(Ae,Ge),Ge?.isDirty&&Te.add(Ae)}catch{qe.status&&(Fe.set(Ae,qe.status),qe.status.isDirty&&Te.add(Ae))}})).catch(Ae=>{console.warn("Failed to inspect worktree status before deletion:",Ae)}),!Pe&&(A(Te),y(!0),d(Ae=>{if(!Ae?.worktree?.path)return Ae;const qe=xs(Ae.worktree.path),Ge=Fe.get(qe);if(!Ge)return Ae;const Je=Ae.worktree.status;return Je?.isDirty===Ge.isDirty&&Je?.ahead===Ge.ahead&&Je?.behind===Ge.behind&&Je?.upstream===Ge.upstream?Ae:{...Ae,worktree:{...Ae.worktree,status:Ge}}}),l(Ae=>Ae.map(qe=>{const Ge=xs(qe.metadata.path),Je=Fe.get(Ge);return Je?{session:qe.session,metadata:{...qe.metadata,status:Je}}:qe})))})(),()=>{Pe=!0}},[a,R]),c.useEffect(()=>{de||m(!1)},[de]);const je=c.useCallback(async(G,Ee,Pe,Fe)=>{const Te=f&&de,Ae=ne(G),qe=xs(G.path),Ge=xs(Ae.path);try{await Wg(Ae,G,{deleteRemoteBranch:Te,deleteLocalBranch:Ee,remoteName:G.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s},skipTeardown:Fe});const Je=Y=>!!(qe&&Y&&Ug(qe,Y)),st=nt.getState().newSessionDraft,mt=xs(st?.directoryOverride);return st?.open&&Je(mt)&&Ge&&(L(null),_({projectId:Ae.id,directoryOverride:Ge},{force:!0})),Je(xs(zt.getState().currentDirectory))&&Ge&&zt.getState().setDirectory(Ge,{showOverlay:!1}),!0}catch(Je){if(Je instanceof Error&&Vg(Je))throw Je;return Oe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Pe,description:Ns(Je instanceof Error?Je.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[de,f,ne,e,L,_,s,t]),Be=c.useCallback((G,Ee,Pe,Fe)=>{const Te=f&&de,Ae=async(qe,Ge)=>{const Je=Oe.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Mo(G)}));Xg(G.path);try{if(Fe){const Y=()=>Oa(r,G.path),fe=Y().map(T=>T.id);if(!(await Yg({worktreePath:G.path,projectDirectory:ne(G).path,readSessions:Y,removeWorktree:()=>je(G,Pe,Je,qe)})).removed)return;Fa(fe,{projectId:ne(G).id}),Oe.success(t(Te?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Je,description:Ns(Mo(G))});return}const st=await Jg({sessionIds:Ge,removeWorktree:()=>je(G,Pe,Je,qe),restoreSessions:Y=>N(Y,{undo:!0}),archiveSessions:async Y=>Y.length===1?await C(Y[0])?{archivedIds:Y,failedIds:[]}:{archivedIds:[],failedIds:Y}:k(Y)});if(!st.removed)return;Fa(Ge,{projectId:ne(G).id}),Oe.success(t(Te?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Je,description:Ns(Mo(G))});const{failedIds:mt}=st.archive;mt.length>0&&Oe.error(mt.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:mt.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:mt.length}),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(st){Oe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Je,description:Ns(st instanceof Error?t1(st,t)??st.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain")),...st instanceof Error?Qg(st,t("sessions.sidebar.sessionDialogs.worktree.deleteWithoutTeardown"),()=>{Ae(!0,e1(Ge,G.path))}):void 0})}finally{s1(G.path)}};return Ae(!1,Ee)},[C,k,de,r,f,ne,je,t,N]),_e=c.useRef(new Set),Ie=c.useCallback(async(G,Ee)=>{const Pe=xs(G.path);if(!_e.current.has(Pe)){_e.current.add(Pe);try{const Fe=await Ma(G.path).catch(()=>{});if(!Kg(Fe)){Ne({sessions:Ee,mode:"worktree",worktree:G});return}await Be(G,Ee.map(Te=>Te.id),!0,!1)}finally{_e.current.delete(Pe)}}},[Ne,Be]);c.useEffect(()=>lr.onDeleteRequest(G=>{if(!$&&(G.mode??"session")==="session"){ye(G);return}if(G.mode==="worktree"&&G.skipDialogIfSafe&&G.worktree){Ie(G.worktree,G.sessions);return}Ne(G)}),[Ne,$,ye,Ie]);const tt=c.useCallback(async()=>{if(a){b(!0);try{if(Se){const G=a.worktree??u[0]?.metadata;if(!G){Oe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}Be(G,a.sessions.map(Ee=>Ee.id),p&&J,Ve),me();return}if(a.sessions.length===1){const G=a.sessions[0];if(!await v(G.id)){Oe.error(t("sessions.sidebar.session.delete.error")),b(!1);return}Oe.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const G=a.sessions.map(Fe=>Fe.id),{deletedIds:Ee,failedIds:Pe}=await S(G);if(Ee.length>0){const Fe=Pe.length>0?Pe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:Pe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:Pe.length}):a.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:a.dateLabel}):void 0;Oe.success(Ee.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ee.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ee.length}),{description:Ns(Fe),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(Pe.length>0&&(Oe.error(Pe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Pe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:Pe.length}),{description:Ns(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Ee.length===0)){b(!1);return}}me()}finally{b(!1)}}},[J,a,u,p,v,S,me,Se,Ve,Be,t]),Ke=a?.worktree??u[0]?.metadata??null;let ze="";if(a?.mode==="worktree"){const G=a.sessions.length;Ve?ze=Le===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinkedKept",{count:Le}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinkedKept",{count:Le}):G===0?ze=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):G===1?ze=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:G}):ze=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:G})}else if(a){const G=a.sessions.length;G===1?ze=a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):ze=a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:G,dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:G})}const rt=a?n.jsxs("div",{className:Ze(Se?"space-y-3":"space-y-2"),children:[a.sessions.length>0&&n.jsxs("div",{className:Ze(Se?"oc-tile rounded-lg p-3":"oc-tile space-y-1.5 rounded-lg p-3"),children:[Se&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:a.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a.sessions.length})]}),n.jsxs("ul",{className:Ze(Se?"mt-2 space-y-1":"space-y-0.5"),children:[a.sessions.slice(0,5).map(G=>n.jsxs("li",{className:Ze(Se?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[n.jsx("span",{className:Ze(!Se&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),a.sessions.length>5&&n.jsx("li",{className:Ze(Se?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:a.sessions.length-5})})]})]}),Se?n.jsxs("div",{className:"oc-tile space-y-2 rounded-lg p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ce,{name:"worktree",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),Ke?.label?n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ke.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:Ke?qg(Ke.path,W):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),V&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"oc-tile rounded-lg p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,ve=Se&&J?de?n.jsxs("button",{type:"button",onClick:()=>{ue||m(G=>!G)},disabled:ue,"aria-pressed":f,className:Ze("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ue?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ce,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,M=Se&&J?n.jsxs("button",{type:"button",onClick:()=>{ke||h(G=>!G)},disabled:ke,"aria-pressed":p,className:Ze("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ke?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ce,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ce=Se&&Le>0?n.jsxs("button",{type:"button",onClick:()=>{w||g(G=>!G)},disabled:w,"aria-pressed":x,className:Ze("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",w?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[x?n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(ce,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.keepSessions")]}):null,He=Se?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Ce,M,ve]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{variant:"ghost",onClick:me,disabled:w,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ut,{variant:"destructive",onClick:tt,disabled:w,children:t(w?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>B(!$),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":!$,children:[$?n.jsx(ce,{name:"checkbox-blank",className:"size-4"}):n.jsx(ce,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ut,{variant:"ghost",onClick:me,disabled:w,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ut,{variant:"destructive",onClick:tt,disabled:w,children:w?t("sessions.sidebar.sessionDialogs.actions.deleting"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Xe=Se?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[ie?n.jsx(Gg,{open:!!a,onClose:()=>{w||me()},title:Xe,footer:n.jsx("div",{className:"flex justify-end gap-2",children:He}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[ze&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:ze}),rt]})}):n.jsx(sr,{open:!!a,onOpenChange:G=>{if(!G){if(w)return;me()}},children:n.jsxs(nr,{className:Ze(Se?"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:[n.jsxs(rr,{children:[n.jsxs(or,{className:Ze(Se&&"flex items-center gap-2"),children:[Se&&n.jsx(ce,{name:"delete-bin",className:"h-5 w-5"}),Xe]}),ze&&n.jsx(ir,{children:ze})]}),Se?n.jsx(as,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:rt}):n.jsx("div",{children:rt}),n.jsx(Ur,{className:"mt-2 gap-2 pt-1 pb-1",children:He})]})}),n.jsx(Zg,{open:o,onOpenChange:i})]})},xu=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Sk=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,kk=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,jk=t=>xu.some(({pattern:e})=>e.test(t));async function Ck(t,e,s){if(!t)return null;const r=Ek(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=Pk(s);if(o){const i=await Ik(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 Tk(t)){const o=await Nk(),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 Tk(t){const e=`${t}/index.html`,s=await Qr(e,t);return typeof s=="string"&&s.trim().length>0}async function Nk(){try{const t=await zs("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function Ek(t){for(const e of t){const s=kk.exec(e.command.trim())?.[1];if(s&&jk(s)||e.source!=="shared"&&Sk.test(e.name.trim()))return e}return null}function Pk(t){for(const{pattern:e}of xu)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function Ik(t){const e=await Qr(`${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 s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const i=await Qr(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Qr(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await zs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=nc()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await zs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Rk(t){try{const e=await Qr(`${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 Dk=/\{(worktree|branch)\}/g,Jo=63,_k=new Set(["main","master"]),bu=t=>/\{(worktree|branch)\}/.test(t??""),Ak=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},wu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Jo)return e;const s=await Ak(e);return s?`${e.slice(0,Jo-7).replace(/-+$/,"")}-${s}`:e.slice(0,Jo).replace(/-+$/,"")},Ok=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},Mk=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.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:Ok(i.current),linkedWorktree:o}},Fk=async t=>!t.linkedWorktree||!t.branch||_k.has(t.branch)?"":wu(t.branch.split("/").pop()??""),Lk=t=>{const e=t.lastIndexOf("@"),s=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):"",d=i.split(".").map(u=>u.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${d.join(".")}${a}`},Bk=async(t,e)=>{const s={worktree:await Fk(e),branch:e.branch?await wu(e.branch):""},r=t.replace(Dk,(u,l)=>s[l]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",d=""]=o;return`${i}${Lk(a)}${d}`},$k=async(t,e,s)=>bu(e)?Bk(e,await Mk(t,s,e)):e,yu="oc.projectActions.selectedAction.v1",zk=di(Ss(),di(Ss(),Ss())),vu=()=>{const t=hr().getItem(yu);if(t===null)return{};try{const e=zk.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},Dl=(t,e=qt())=>vu()[e]?.[t]??null,Wk=(t,e,s=qt())=>{const r=vu();r[s]?.[t]!==e&&hr().setItem(yu,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},Uk=15e3,Vk=3e3,Hk=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Kk=({projectRef:t,directory:e,allowMobile:s=!1})=>{const{t:r}=lt(),{currentTheme:o}=oo(),{terminal:i,runtime:a,git:d}=ks(),u=Hs(),{isMobile:l}=hn(),f=c.useMemo(()=>Ps(),[]),m=Ca(T=>T.instances),p=Ca(T=>T.load),h=K(T=>T.terminalShell),x=K(T=>T.terminalLoginShells.includes(T.terminalShell)),g=K(T=>T.setSettingsPage),w=K(T=>T.setSettingsDialogOpen),b=K(T=>T.setSettingsProjectsSelectedId),j=K(T=>T.openContextPreview),y=yt(T=>T.ensureDirectory),E=yt(T=>T.reconcileServerSessions),A=yt(T=>T.setTabLabel),R=yt(T=>T.setTabIconKey),_=yt(T=>T.setActiveTab),L=yt(T=>T.setConnecting),v=yt(T=>T.setTabSessionId),C=yt(T=>T.setTabPurpose),S=yt(T=>T.allocateActionExecution),k=yt(T=>T.setTabLifecycle),N=yt(T=>T.setTabPreviewUrl),$=yt(T=>T.matchesActionExecution),B=yt(T=>T.captureStartedActionMutationRevisions),[D,W]=c.useState([]),H=c.useRef(null),[U,se]=c.useState(()=>t?.id?Dl(t.id):null),[z,Q]=c.useState(!1),ie=c.useRef({}),O=c.useRef({}),ne=c.useRef({}),V=c.useRef(new Set),J=c.useRef(0),[F,re]=c.useState({}),q=t?.id??null,ge=t?.path??"";c.useEffect(()=>{se(q?Dl(q):null)},[q]);const Z=c.useMemo(()=>q?{id:q,path:ge}:null,[q,ge]);c.useEffect(()=>{f&&p().catch(()=>{})},[f,p]);const de=c.useCallback(async T=>{await On(T)},[]),Se=c.useCallback(async()=>{if(!Z)return;const T=J.current+1;J.current=T,Q(!0);try{const ae=await Fo(Z);if(J.current!==T)return;H.current=ae;const pe=ae.projectActions;W(pe)}catch{if(J.current!==T)return}finally{J.current===T&&Q(!1)}},[Z]),ue=c.useMemo(()=>Ro(e||Z?.path||""),[e,Z?.path]),ke=c.useMemo(()=>Ro(Z?.path||""),[Z?.path]),Me=c.useMemo(()=>Ro(u||"")||ue,[u,ue]),We=c.useRef(Me);c.useEffect(()=>{We.current=Me},[Me]);const Le=yt(T=>ue?T.getDirectoryState(ue):void 0),Ve=yt(T=>ke&&ke!==ue?T.getDirectoryState(ke):void 0),Ne=c.useMemo(()=>{const T=ue?[{directory:ue,state:Le}]:[];return ke&&ke!==ue&&T.push({directory:ke,state:Ve}),T},[Le,ue,ke,Ve]),me=c.useMemo(()=>{const T=ue?[ue]:[];return ke&&ke!==ue&&T.push(ke),T},[ue,ke]),ye=c.useCallback(T=>T.id!==sn&&T.runIn==="parent"&&ke||ue,[ue,ke]),je=c.useCallback((T,ae,pe)=>`${T}::${ae}::${pe}`,[]),Be=c.useCallback((T,ae,pe=yt.getState())=>T?pe.getDirectoryState(T)?.tabs.find(oe=>oe.purpose.type==="project-action"&&oe.purpose.actionId===ae)??null:null,[]),_e=c.useMemo(()=>{const T={};for(const{directory:ae,state:pe}of Ne)for(const oe of pe?.tabs??[]){if(oe.purpose.type!=="project-action"||!oe.purpose.executionId||!oe.terminalSessionId||oe.lifecycle==="idle"||oe.lifecycle==="exited")continue;const be=wn(ae,oe.purpose.actionId),$e=je(ae,oe.purpose.actionId,oe.purpose.executionId);T[be]={directory:ae,actionId:oe.purpose.actionId,tabId:oe.id,sessionId:oe.terminalSessionId,executionId:oe.purpose.executionId,status:oe.lifecycle==="stopping"?"stopping":F[$e]?"waiting-for-preview":"running"}}return T},[je,F,Ne]),Ie=c.useCallback((T,ae,pe)=>{const oe=wn(T,ae),be=je(T,ae,pe),De=ie.current[oe]?.executionId===pe,ee=globalThis.window,le=et=>{ee?.clearTimeout(ne.current[et]),delete ne.current[et]};De&&(delete ie.current[oe],le(oe)),O.current[be]?.(),delete O.current[be],le(be),re(et=>{if(!et[be])return et;const xe={...et};return delete xe[be],xe})},[je]),tt=c.useCallback(T=>{O.current[T]?.(),delete O.current[T]},[]),Ke=c.useCallback(T=>{window.clearTimeout(ne.current[T]),delete ne.current[T]},[]);c.useEffect(()=>{const T=O.current,ae=ne.current;return()=>{for(const pe of Object.keys(T))tt(pe);for(const pe of Object.keys(ae))Ke(pe)}},[Ke,tt]),c.useEffect(()=>{const T=new Set(me);for(const ae of Object.values(ie.current))T.has(ae.directory)||Ie(ae.directory,ae.actionId,ae.executionId);for(const ae of Object.keys(O.current)){const pe=ae.split("::",1)[0]??"";T.has(pe)||tt(ae)}},[Ie,tt,me]);const ze=c.useCallback((T,ae)=>{K.getState().openContextPanelTab(T,{mode:"terminal",targetDirectory:ae===T?null:ae})},[]),rt=c.useMemo(()=>({id:sn,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),ve=!l,M=c.useMemo(()=>ve?[...D,rt]:D,[D,rt,ve]),Ce=c.useMemo(()=>U?M.find(T=>T.id===U)??null:null,[M,U]);c.useEffect(()=>{Se()},[Se]);const[He,Xe]=c.useState(0),G=c.useCallback(()=>(Xe(T=>T+1),()=>Xe(T=>T-1)),[]),Ee=He>0;c.useEffect(()=>{if(!Ee)return;const T=me.map(ae=>pp(i,ae,B,pe=>E(ae,pe.sessions,{startedActionMutationRevisions:pe.startedActionMutationRevisions})));return()=>{for(const ae of T)ae()}},[B,Ee,E,i,me]),c.useEffect(()=>{for(const{directory:T,state:ae}of Ne)if(T)for(const pe of ae?.tabs??[]){if(pe.purpose.type!=="project-action")continue;const oe=pe.purpose.actionId,be=M.find(ee=>ee.id===oe),$e=be?.name??oe,De=be?.icon||"play";pe.label!==$e&&A(T,pe.id,$e),pe.iconKey!==De&&R(T,pe.id,De)}},[M,R,A,Ne]),c.useEffect(()=>{const T=globalThis.window;if(!T)return;const ae=pe=>{const oe=pe.detail;q&&(oe?.projectId&&oe.projectId!==q||Se())};return T.addEventListener(Ta,ae),()=>{T.removeEventListener(Ta,ae)}},[Se,q]),c.useEffect(()=>{const T=pe=>{delete ne.current[pe];const oe=ie.current[pe];if(!oe||oe.openedUrl)return;const be=je(oe.directory,oe.actionId,oe.executionId),$e=oe.announced;if($e.length!==0){if(window.clearTimeout(ne.current[be]),delete ne.current[be],oe.openedUrl=!0,re(De=>{if(!De[be])return De;const ee={...De};return delete ee[be],ee}),$e.length===1){Zo(oe.directory,[]),N(oe.directory,oe.tabId,$e[0],{locked:!1,autoOpened:!0}),j(oe.directory,$e[0]);return}oe.offering=!0,Zo(oe.directory,$e),K.getState().openContextSurface(oe.directory,"browser"),Oe.info(r("projectActions.toast.multipleServers"))}},ae=()=>{const pe=yt.getState(),oe=pe.sessions,be=_e;for(const[$e,De]of Object.entries(be)){const le=oe.get(De.directory)?.tabs.find(ht=>ht.id===De.tabId);if(!le||le.terminalSessionId!==De.sessionId){Ie(De.directory,De.actionId,De.executionId);continue}const et=ie.current[$e],xe=et?.executionId===De.executionId?et:{hostDirectory:We.current||De.directory,directory:De.directory,tabId:De.tabId,actionId:De.actionId,executionId:De.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};ie.current[$e]=xe;const bt=M.find(ht=>ht.id===De.actionId),Tt=pe.getBuffer(De.directory,De.tabId).chunks;if(!bt||Tt.length===0)continue;const vt=Tt.filter(ht=>xe.lastSeenChunkId===null||ht.id>xe.lastSeenChunkId);if(vt.length===0)continue;const Rt=vt.map(ht=>ht.data).join(""),Ye=`${xe.tail}${Rt}`;for(const ht of wp(Ye))xe.proxiedPorts.includes(ht)||xe.proxiedPorts.push(ht);if(xe.openInPreview&&(!xe.openedUrl||xe.offering)){const ht=yp(Ye,{proxiedPorts:xe.proxiedPorts,namedAddressesReachable:!Na()}),Ct=xe.announced.length;for(const It of ht)xe.announced.includes(It)||xe.announced.push(It);const pt=xe.announced.length-Ct;xe.offering&&pt>0?Zo(De.directory,xe.announced):!xe.openedUrl&&Ct===0&&xe.announced.length>0&&(window.clearTimeout(ne.current[$e]),ne.current[$e]=window.setTimeout(()=>T($e),Vk))}const ft=!xe.openedUrl&&bt.autoOpenUrl===!0&&!xe.openInPreview?vp(Ye,{proxiedPorts:xe.proxiedPorts,namedAddressesReachable:!Na()}):null,Nt=vt[vt.length-1]?.id??xe.lastSeenChunkId;if(xe.lastSeenChunkId=Nt,xe.tail=Ye.slice(-512),ft)if(xe.openedUrl=!0,xe.openInPreview){const ht=be[$e];ht&&(N(ht.directory,ht.tabId,ft,{locked:!1,autoOpened:!1,expectedExecutionId:ht.executionId}),ht.status==="waiting-for-preview"&&re(Ct=>{const pt=je(ht.directory,ht.actionId,ht.executionId);if(!Ct[pt])return Ct;const It={...Ct};return delete It[pt],It}),window.clearTimeout(ne.current[$e]),delete ne.current[$e],j(ht.directory,ft))}else de(ft),Oe.success(r("projectActions.toast.openedUrlFromOutput"));ie.current[$e]=xe}for(const $e of Object.keys(ie.current))if(!be[$e]){const De=ie.current[$e],ee=De?oe.get(De.directory)?.tabs.find(et=>et.id===De.tabId):void 0;if(ee?.purpose.type==="project-action"&&ee.purpose.executionId===De?.executionId&&!!ee.terminalSessionId&&ee.lifecycle!=="idle"&&ee.lifecycle!=="exited")continue;delete ie.current[$e],window.clearTimeout(ne.current[$e]),delete ne.current[$e]}};return ae(),yt.subscribe((pe,oe)=>{(pe.sessions!==oe.sessions||pe.buffers!==oe.buffers)&&ae()})},[Ie,We,M,je,j,de,_e,N,r]),c.useEffect(()=>{for(const{directory:T,state:ae}of Ne)for(const pe of ae?.tabs??[]){if(pe.purpose.type!=="project-action"||!pe.purpose.executionId||!pe.terminalSessionId||pe.lifecycle!=="running")continue;const oe=pe.purpose.actionId,be=pe.purpose.executionId,$e=je(T,oe,be);if(O.current[$e])continue;const De=i.connect(pe.terminalSessionId,{onEvent:ee=>{if(!$(T,pe.id,be))return;ee.type==="snapshot"&&(yt.getState().replaceBuffer(T,pe.id,ee.data??"",ee.sequence??0,ua(ee)),ee.status==="running"&&yt.getState().setTabLifecycle(T,pe.id,"running",{expectedExecutionId:be}),ee.status==="exited"&&(yt.getState().setTabLifecycle(T,pe.id,"exited",{expectedExecutionId:be}),yt.getState().setTabPurpose(T,pe.id,{type:"project-action",actionId:oe,executionId:null}),Ie(T,oe,be)));const le=ee.type==="data"?ee.data??"":"";le&&yt.getState().appendToBuffer(T,pe.id,le,ee.sequence,ee.replayData),ee.type==="exit"&&(yt.getState().setTabLifecycle(T,pe.id,"exited",{expectedExecutionId:be}),yt.getState().setTabPurpose(T,pe.id,{type:"project-action",actionId:oe,executionId:null}),Ie(T,oe,be))},onError:(ee,le)=>{!le||!$(T,pe.id,be)||(yt.getState().setTabLifecycle(T,pe.id,"exited",{expectedExecutionId:be}),yt.getState().setTabSessionId(T,pe.id,null,{expectedExecutionId:be}),yt.getState().setTabPurpose(T,pe.id,{type:"project-action",actionId:oe,executionId:null}),Ie(T,oe,be))}},T);O.current[$e]=De.close}},[Ie,je,$,i,Ne]);const Pe=c.useCallback(async T=>{const ae=ye(T);if(!ae)throw new Error(r("projectActions.error.noActiveDirectory"));const pe=wn(ae,T.id);y(ae);const oe=yt.getState(),be=Be(ae,T.id,oe),$e=be?.id??oe.createTab(ae);A(ae,$e,T.name),R(ae,$e,T.icon||"play"),be||C(ae,$e,{type:"project-action",actionId:T.id,executionId:null}),_(ae,$e);const ee=yt.getState().getDirectoryState(ae)?.tabs.find(le=>le.id===$e);return{executionDirectory:ae,key:pe,tabId:$e,sessionId:ee?.terminalSessionId??null,executionId:ee?.purpose.type==="project-action"?ee.purpose.executionId:null}},[y,ye,Be,_,R,A,C,r]),Fe=c.useCallback(async T=>{if(a.isVSCode||!s&&l)return;if(!ue){Oe.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ae=wn(ye(T),T.id),pe=_e[ae];if(pe&&pe.status==="running"||V.current.has(ae))return;V.current.add(ae);let oe=null;try{const be=T.id===sn?await(async()=>{const dt=Z??{id:"",path:ue},[ct,Mt]=await Promise.all([Fo(dt),Rk(ue)]),Wt=await Ck(ue,ct.projectActions,Mt);if(!Wt)throw new Error(r("contextPanel.preview.noDevServer"));return ct.projectActions.find(Kt=>Kt.id===Wt.actionId)?.source==="shared"&&!await La(dt,ct)?null:{id:sn,name:r("projectActions.actions.autoDiscover"),command:Wt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Wt.previewUrlHint||""}})():T;if(!be)return;const $e=be.autoOpenUrl===!0&&(be.openUrl||"").trim().length>0,De=!$e&&T.id!==sn,ee=We.current||ue,{executionDirectory:le,key:et,tabId:xe}=await Pe(be),bt=mp(be.command);if(!bt)throw new Error(r("projectActions.error.failedToRunAction"));const Tt=be.autoOpenUrl===!0&&f&&(be.desktopOpenSshForward||"").trim().length>0,vt=be.autoOpenUrl&&be.openUrl||"";let Rt=!1;const Ye=bu(vt)?await $k(d,vt,le).catch(()=>(Rt=!0,"")):vt,ft=be.autoOpenUrl?Hk(Ye):null,Nt=be.autoOpenUrl&&f?hp(be.desktopOpenSshForward,m):null;if(i.listSessions){const dt=Be(le,be.id);if(dt?.purpose.type==="project-action"&&dt.purpose.executionId===null){const ct=await gp(i,le,{captureStartedActionMutationRevisions:B});ct&&E(le,ct.sessions,{startedActionMutationRevisions:ct.startedActionMutationRevisions})}}const ht=Be(le,be.id);let Ct,pt;if(ht?.lifecycle==="running"&&ht.terminalSessionId&&ht.purpose.type==="project-action"&&ht.purpose.executionId)Ct=ht.terminalSessionId,pt=ht.purpose.executionId;else{const dt=ht?.purpose.type==="project-action"?ht.purpose.executionId:null;dt&&Ie(le,be.id,dt);const ct=S(le,xe,be.id);if(!ct)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));oe={directory:le,tabId:xe,id:ct},L(le,xe,!0,{expectedExecutionId:ct});const Mt=await xp({terminal:i,createOptions:{cwd:le,shell:h,loginShell:x,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:bt,isRunStillExpected:()=>$(le,xe,ct),purpose:{type:"project-action",actionId:be.id,executionId:ct}});if(!$(le,xe,ct)){Mt.sessionId===ct&&await i.close(Mt.sessionId).catch(()=>{});return}pt=Mt.purpose?.type==="project-action"?Mt.purpose.executionId:ct,Ct=Mt.sessionId,C(le,xe,{type:"project-action",actionId:be.id,executionId:pt}),v(le,xe,Ct,{expectedExecutionId:pt}),L(le,xe,!1,{expectedExecutionId:pt})}De&&ee&&ze(ee,le),ie.current[et]={hostDirectory:ee,directory:le,tabId:xe,actionId:be.id,executionId:pt,lastSeenChunkId:null,openedUrl:!!Nt||!!ft||$e,tail:"",openInPreview:be.id===sn,announced:[],offering:!1,proxiedPorts:[]};const It=je(le,be.id,pt);L(le,xe,!0,{expectedExecutionId:pt});const Ht=i.connect(Ct,{onEvent:dt=>{if(!$(le,xe,pt)||dt.purpose?.type==="project-action"&&dt.purpose.executionId!==pt)return;dt.type==="snapshot"&&(yt.getState().replaceBuffer(le,xe,dt.data??"",dt.sequence??0,ua(dt)),yt.getState().setConnecting(le,xe,!1,{expectedExecutionId:pt}),dt.purpose?.type==="project-action"&&yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:dt.purpose.actionId,executionId:dt.purpose.executionId}),dt.status==="running"&&yt.getState().setTabLifecycle(le,xe,"running",{expectedExecutionId:pt}),dt.status==="exited"&&(yt.getState().setTabLifecycle(le,xe,"exited",{expectedExecutionId:pt}),yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:be.id,executionId:null}),Ie(le,be.id,pt)));const ct=dt.type==="data"?dt.data??"":"";ct&&yt.getState().appendToBuffer(le,xe,ct,dt.sequence,dt.replayData),dt.type==="exit"&&(yt.getState().setTabLifecycle(le,xe,"exited",{expectedExecutionId:pt}),yt.getState().setConnecting(le,xe,!1,{expectedExecutionId:pt}),yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:be.id,executionId:null}),Ie(le,be.id,pt))},onError:(dt,ct)=>{$(le,xe,pt)&&(yt.getState().setConnecting(le,xe,!1,{expectedExecutionId:pt}),ct&&(yt.getState().setTabLifecycle(le,xe,"exited",{expectedExecutionId:pt}),yt.getState().setTabSessionId(le,xe,null,{expectedExecutionId:pt}),yt.getState().setTabPurpose(le,xe,{type:"project-action",actionId:be.id,executionId:null}),Ie(le,be.id,pt)))}},le);if(!$(le,xe,pt)){Ht.close();return}O.current[It]?.(),O.current[It]=Ht.close,window.clearTimeout(ne.current[It]),delete ne.current[It],be.id===sn&&!ft&&(re(dt=>({...dt,[It]:!0})),ne.current[It]=window.setTimeout(()=>{delete ne.current[It];const dt=ie.current[et];!dt||dt.executionId!==pt||dt.openedUrl||dt.offering||$(le,xe,pt)&&(re(ct=>{if(!ct[It])return ct;const Mt={...ct};return delete Mt[It],Mt}),yt.getState().setActiveTab(le,xe),ze(dt.hostDirectory,le))},Uk)),Nt?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),de(Nt),Oe.success(r("projectActions.toast.openedForwardedUrl"))):ft?(N(le,xe,ft,{locked:!0,autoOpened:!0,expectedExecutionId:pt}),j(ee,ft),Oe.success(r("projectActions.toast.openedActionUrl"))):Rt?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),Oe.error(r("projectActions.error.openUrlTemplateUnresolved"))):$e?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),Oe.error(r("projectActions.error.invalidCustomUrlFormat"))):Tt?(N(le,xe,null,{locked:!0,expectedExecutionId:pt}),Oe.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):N(le,xe,null,{locked:!1,autoOpened:!1,expectedExecutionId:pt})}catch(be){if(oe&&$(oe.directory,oe.tabId,oe.id)){const{directory:$e,tabId:De,id:ee}=oe;Ie($e,T.id,ee),k($e,De,"exited",{expectedExecutionId:ee}),C($e,De,{type:"project-action",actionId:T.id,executionId:null})}if(be instanceof Error&&be.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(be instanceof Error&&(be.message==="COMMAND_MODE_UNSUPPORTED"||be.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Oe.error(r("projectActions.error.failedToCreateTerminalSession"));return}Oe.error(be instanceof Error?be.message:r("projectActions.error.failedToRunAction"))}finally{V.current.delete(ae)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,We,m,Pe,d,s,l,f,ue,x,h,de,j,_e,ze,a.isVSCode,ye,$,Ie,je,Be,E,S,B,L,k,C,N,v,Z,r,i]),Te=c.useCallback(async T=>{const ae=wn(ye(T),T.id),pe=_e[ae];pe&&await bp({terminal:i,sessionId:pe.sessionId,isExecutionStillCurrent:()=>$(pe.directory,pe.tabId,pe.executionId),markStopping:()=>{k(pe.directory,pe.tabId,"stopping",{expectedExecutionId:pe.executionId})},restoreRunning:()=>{k(pe.directory,pe.tabId,"running",{expectedExecutionId:pe.executionId})},clearSession:()=>{v(pe.directory,pe.tabId,null,{expectedExecutionId:pe.executionId})},finalizeExit:()=>{k(pe.directory,pe.tabId,"exited",{expectedExecutionId:pe.executionId}),C(pe.directory,pe.tabId,{type:"project-action",actionId:pe.actionId,executionId:null}),Ie(pe.directory,pe.actionId,pe.executionId)}})},[Ie,ye,$,_e,k,C,v,i]),Ae=c.useCallback(async T=>{if(T.source==="shared"&&Z){const ae=H.current?.trust.trusted?H.current:await Fo(Z);if(H.current=ae,!await La(Z,ae))return;H.current={...ae,trust:{...ae.trust,trusted:!0}}}await Fe(T)},[Fe,Z]),qe=c.useCallback(T=>_e[wn(ye(T),T.id)]??null,[ye,_e]),Ge=(Ce&&qe(Ce)?Ce:null)??M.find(T=>qe(T)!==null)??Ce??M[0]??null,Je=c.useCallback(T=>{const ae=qe(T);if(ae?.status!=="stopping"){if(ae){Te(T);return}Ae(T)}},[Ae,qe,Te]),st=c.useCallback(T=>{Ae(T)},[Ae]),mt=c.useCallback(T=>{Te(T)},[Te]),Y=c.useCallback(T=>{se(T.id),q&&Wk(q,T.id)},[q]),fe=c.useCallback(()=>{Z?.id&&(b(Z.id),g("projects"),w(!0))},[w,g,b,Z?.id]),Re=!a.isVSCode&&(s||!l)&&!!Z&&!!ue;return c.useMemo(()=>({available:Re,actions:Re?M:[],shown:Re?Ge:null,isLoading:z,observe:G,runOf:qe,select:Y,run:st,stop:mt,toggle:Je,openSettings:fe}),[Re,M,z,G,fe,st,qe,Y,Ge,mt,Je])},qk=t=>{const e=Ue.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=Kk(r);let i;return e[3]!==s||e[4]!==o?(i=n.jsx(kd.Provider,{value:o,children:s}),e[3]=s,e[4]=o,e[5]=i):i=e[5],i},Gk=t=>{const e=Ue.c(4),{children:s}=t,r=Cd(),o=wr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let d;return e[0]!==s||e[1]!==a||e[2]!==i?(d=n.jsx(qk,{projectRef:i,directory:a,children:s}),e[0]=s,e[1]=a,e[2]=i,e[3]=d):d=e[3],d},Zk=2e4,Xk=14400*1e3,Yk=t=>Object.entries(t).map(([e,s])=>`${e}@${s.version}`).sort().join(","),Jk="openchamber.guests.announcedUpdates",Qk=()=>{const{t}=lt(),e=c.useRef(t);e.current=t,c.useEffect(()=>{let s=!1;const r=async()=>{const a=qt();await n1();const d=await Sp(!1);if(s||!d.ok||qt()!==a)return;const u=tr.getState();u.applyUpdates(d.updates,u.runtimeKey);const l=tr.getState().guests.filter(g=>d.updates[g.id]),f=Yk(d.updates),m=hr(),p=`${Jk}:${a}`;if(l.length===0||m.getItem(p)===f)return;m.setItem(p,f);const h=e.current,[x]=l;Oe.info(l.length===1&&x?h("settings.extensions.updates.notice.one",{name:x.name}):h("settings.extensions.updates.notice.many",{count:l.length}),{action:{label:h("settings.extensions.updates.notice.open"),onClick:()=>{const g=K.getState();g.setSettingsPage("extensions"),g.setSettingsDialogOpen(!0)}}})};let o;const i=window.setTimeout(()=>{r(),o=window.setInterval(()=>{r()},Xk)},Zk);return()=>{s=!0,window.clearTimeout(i),window.clearInterval(o)}},[])},ej=()=>{lr.requestDirectoryDialog()},tj=()=>{K.getState().setNewWorktreeDialogOpen(!0)},sj=()=>{const t=zt.getState().currentDirectory;if(!t)return!1;K.getState().openContextOverview(t)},nj=()=>{Jc()},rj=()=>{if(!K.getState().overviewFeatureAvailable)return!1;K.getState().setOverviewOpen(!0)},oj=()=>{window.location.reload()},ij=()=>{const t=K.getState();t.setSessionSwitcherOpen(!1),t.setArchivePageOpen(!0)},Su=t=>{const e=zt.getState().currentDirectory;if(!e)return!1;const s=K.getState();return s.setProjectContextTab(t),s.openContextSurface(e,"notes"),!0},aj=()=>Su("notes"),lj=()=>Su("todos"),cj=t=>()=>{kp(t)},dj=t=>()=>{const e=nt.getState().currentSessionId,s=zt.getState().currentDirectory;if(!e||!s)return!1;const r=Xi(yr.getState().ids,s,e)?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";jp({directory:s,sessionId:e}).catch(()=>Oe.error(t(r)))},uj=t=>()=>{const e=nt.getState().currentSessionId;if(!e)return!1;io(e).then(s=>{if(s.ok){Oe.success(t("sessions.sidebar.session.copyId.success"));return}Oe.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Oe.error(t("sessions.sidebar.session.copyId.error")))},fj=t=>()=>{if(!K.getState().sessionWorkEnabled)return!1;const e=nt.getState().currentSessionId;if(!e)return!1;const s=ts.getState().activeSessions.find(i=>i.id===e);if(!s||s.parentID)return!1;const r=Bs(s)??zt.getState().currentDirectory;if(!r||so(r)||Xi(yr.getState().ids,r,e)||nt.getState().worktreeMetadata.get(e)?.pinnedAt!==void 0)return!1;const o=Mi(s)?"done":"open";r1(e,r,o).catch(()=>Oe.error(t("sessions.sidebar.session.work.updateFailed")))},pj=()=>{K.getState().setSessionSwitcherOpen(!1),o1()};function mj(){const t=Ue.c(13),{t:e}=lt();let s;t[0]!==e?(s=cj(e),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=dj(e),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=uj(e),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=fj(e),t[6]=e,t[7]=i):i=t[7];let a;t[8]!==s||t[9]!==r||t[10]!==o||t[11]!==i?(a={open_new_worktree_dialog:tj,add_project:ej,show_context_usage:sj,show_opencode_status:nj,open_overview:rj,reload_ui:oj,open_archive:ij,open_notes:aj,open_todos:lj,restart_opencode:s,pin_current_session:r,copy_current_session_id:o,toggle_work_current_session:i,open_multi_run:pj},t[8]=s,t[9]=r,t[10]=o,t[11]=i,t[12]=a):a=t[12],Pc(a)}function hj(t){const e=[],s=(r,o)=>{const i=Jt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const gj=new Map,xj=[],bj=t=>{const e=Ue.c(20),{isVSCode:s}=t,r=Kc(),o=Gt(wj),i=zt(yj),a=nt(vj);let d;e[0]!==s?(d=_=>s?gj:_.availableWorktreesByProject,e[0]=s,e[1]=d):d=e[1];const u=nt(d),l=!s;let f;e[2]!==u||e[3]!==o||e[4]!==l?(f=Cp(o,u,{includeWorktrees:l}),e[2]=u,e[3]=o,e[4]=l,e[5]=f):f=e[5];const m=f,p=ts(Sj),h=`session-list-sync:${c.useId()}`;let x,g;e[6]!==h||e[7]!==r||e[8]!==i||e[9]!==a?(x=()=>(r.setBootstrapDemand(h,hj({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(h)),g=[h,r,i,a],e[6]=h,e[7]=r,e[8]=i,e[9]=a,e[10]=x,e[11]=g):(x=e[10],g=e[11]),c.useEffect(x,g);const w=c.useRef(null);let b,j;e[12]!==s||e[13]!==m?(b=()=>{const _=new Set(m),L=w.current;w.current=_;const v=L?[..._].filter(C=>!L.has(C)):s?[..._]:[];v.length&&Qc(v,oi())},j=[s,m],e[12]=s,e[13]=m,e[14]=b,e[15]=j):(b=e[14],j=e[15]),c.useEffect(b,j);let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[16]=y):y=e[16],c.useEffect(kj,y);const E=p!=null,A=p??xj;let R;e[17]!==A||e[18]!==E?(R={enabled:!0,hasAuthoritativeGlobalSessions:E,sessions:A},e[17]=A,e[18]=E,e[19]=R):R=e[19],Tp(R)};function wj(t){return t.projects}function yj(t){return t.currentDirectory}function vj(t){return t.currentSessionDirectory}function Sj(t){return t.authoritativeSessions}function kj(){let t=null,e=!1;const s=new Set,r=_n(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),i1(oi());return}const i=[...s];s.clear(),i.length&&Qc(i,oi())},500)});return()=>{t&&clearTimeout(t),r()}}const jj=()=>Ft(()=>import("./SettingsWindow-rjA8cpzb.js"),__vite__mapDeps([237,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,238,239,240,222,223,224,225,204,232,201,188,189,202,241,242,212,231,217,243,244,245])).then(t=>t.SettingsWindow),Cj=()=>Ft(()=>import("./CommandPalette-ynDRBNPC.js"),__vite__mapDeps([246,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,245,211,181,182,183,209,210,212])).then(t=>t.CommandPalette),Tj=()=>Ft(()=>import("./HelpDialog-BCLY1SdQ.js"),__vite__mapDeps([247,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),Nj=()=>Ft(()=>import("./ProjectActionsDialog-5SwtkdoL.js"),__vite__mapDeps([248,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,209,210,211,212])).then(t=>t.ProjectActionsDialog),Ej=()=>Ft(()=>import("./OpenCodeStatusDialog-riJvcyNM.js"),__vite__mapDeps([249,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),Pj=()=>Ft(()=>import("./RunOverview-Zx7ypz3K.js"),__vite__mapDeps([250,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),Ij=()=>Ft(()=>import("./ScheduledTasksDialog-BqkQPZwR.js"),__vite__mapDeps([251,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,235,252,253,254])).then(t=>t.ScheduledTasksDialog),Rj=()=>Ft(()=>import("./ArchiveView-BZJ26vYO.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,181,182,183,256])).then(t=>t.ArchiveView),Dj=()=>Ft(()=>import("./IntegrationsCatalogView-CCC5vFCc.js"),__vite__mapDeps([257,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,239])).then(t=>t.IntegrationsCatalogView),_j=()=>Ft(()=>import("./UsageStatsView-BqLNssJZ.js"),__vite__mapDeps([258,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),Aj=()=>Ft(()=>import("./SourceBoardView-ClskEpR_.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,181,182,183])).then(t=>t.SourceBoardView),Oj=()=>Ft(()=>import("./OverviewView-DrjJJdxp.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,181,182,183])).then(t=>t.OverviewView),Mj=()=>Ft(()=>import("./WorktreesView-C-AdzkFm.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,256])).then(t=>t.WorktreesView),Fj=()=>Ft(()=>import("./SpacesView-BBtBwQ17.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,243,181,182,183])).then(t=>t.SpacesView),Lj=()=>Ft(()=>import("./SpaceAccessDialog-VIsmK3Lq.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,264])).then(t=>t.SpaceAccessDialog),Bj=()=>Ft(()=>import("./SpaceApplyDialog-CE4GGYR-.js"),__vite__mapDeps([265,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),$j=()=>Ft(()=>import("./SpaceSetupOutput-CCkZT6Bi.js"),__vite__mapDeps([266,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,264])).then(t=>t.SpaceSetupOutputDialog),_s=()=>K.getState().closeMainSurfaces(),es=t=>{const e=Ue.c(2),{needed:s,load:r,onFailure:o}=t,i=ho(s,r,o);let a;return e[0]!==i?(a=i?n.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},ku=c.memo(t=>{const e=Ue.c(12),{isMobile:s}=t,r=K(Wj),o=!r&&!s,i=lo();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 d=qb(a),[u,l]=c.useState(null);let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(zb,{actionsSlotRef:l}),e[3]=f):f=e[3];const m=r||d.state!==!1;let p;e[4]!==u||e[5]!==m?(p=n.jsx(Np,{isVisible:m,listControlsSlot:u}),e[4]=u,e[5]=m,e[6]=p):p=e[6];let h;return e[7]!==s||e[8]!==r||e[9]!==d||e[10]!==p?(h=n.jsx($b,{isOpen:r,isMobile:s,className:"border-border",topBar:f,peek:d,children:p}),e[7]=s,e[8]=r,e[9]=d,e[10]=p,e[11]=h):h=e[11],h});ku.displayName="LeftSidebar";const zj=()=>{const t=Ue.c(114);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],bj(e),mj(),Ep();const s=K(Uj),r=K(Vj),o=K(Hj),i=K(Kj);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const d=ho(o,jj,a),u=K(qj),l=K(Gj),f=K(Zj),m=K(Xj),p=K(Yj),h=K(Jj),x=K(Qj),g=K(e3),w=K(t3),b=K(s3),j=K(n3),y=K(r3),E=K(o3),A=dn(i3),R=dn(a3),_=dn(l3),L=K(c3),v=a1();let C;if(t[3]!==v||t[4]!==L){let fe;t[6]!==L?(fe=Re=>Re.id===L,t[6]=L,t[7]=fe):fe=t[7],C=v.find(fe),t[3]=v,t[4]=L,t[5]=C}else C=t[5];const S=C;let k,N;t[8]!==S||t[9]!==L?(k=()=>{L&&!S&&K.getState().setOpenGuestPage(null)},N=[L,S],t[8]=S,t[9]=L,t[10]=k,t[11]=N):(k=t[10],N=t[11]),c.useEffect(k,N);let $;t[12]===Symbol.for("react.memo_cache_sentinel")?($=[],t[12]=$):$=t[12],c.useEffect(u3,$);let B;t[13]===Symbol.for("react.memo_cache_sentinel")?(B=[],t[13]=B):B=t[13],c.useEffect(f3,B);const D=l||f||m||p||h||x||!!g||w||u||!!S,W=c.useRef(null);let H,U;t[14]!==D?(H=()=>{if(D)return _i(p3,W,1)},U=[D],t[14]=D,t[15]=H,t[16]=U):(H=t[15],U=t[16]),c.useEffect(H,U);let se,z;t[17]!==D?(z=()=>{ed(D)},se=[D],t[17]=D,t[18]=se,t[19]=z):(se=t[18],z=t[19]),c.useLayoutEffect(z,se);let Q;t[20]===Symbol.for("react.memo_cache_sentinel")?(Q=[],t[20]=Q):Q=t[20],c.useEffect(h3,Q);let ie;t[21]===Symbol.for("react.memo_cache_sentinel")?(ie=[],t[21]=ie):ie=t[21],c.useEffect(x3,ie);const{isMobile:O}=hn();Pp(),Qk();let ne,V;t[22]!==O||t[23]!==r?(ne=()=>{K.getState().isMobile!==O&&r(O)},V=[O,r],t[22]=O,t[23]=r,t[24]=ne,t[25]=V):(ne=t[24],V=t[25]),c.useEffect(ne,V);let J;t[26]!==b?(J=n.jsx(es,{needed:b,load:Cj,onFailure:b3}),t[26]=b,t[27]=J):J=t[27];let F;t[28]!==j?(F=n.jsx(es,{needed:j,load:Tj,onFailure:w3}),t[28]=j,t[29]=F):F=t[29];let re;t[30]!==y?(re=n.jsx(es,{needed:y,load:Nj,onFailure:y3}),t[30]=y,t[31]=re):re=t[31];let q;t[32]!==E?(q=n.jsx(es,{needed:E,load:Ej,onFailure:v3}),t[32]=E,t[33]=q):q=t[33];let ge,Z;t[34]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsx(Rp,{}),Z=n.jsx(vk,{}),t[34]=ge,t[35]=Z):(ge=t[34],Z=t[35]);let de;t[36]!==A||t[37]!==R||t[38]!==_||t[39]!==s?(de=s?n.jsxs(n.Fragment,{children:[n.jsx(es,{needed:A,load:Lj,onFailure:S3}),n.jsx(Dp,{}),n.jsx(es,{needed:R,load:Bj,onFailure:k3}),n.jsx(_p,{}),n.jsx(es,{needed:_,load:$j,onFailure:j3})]}):null,t[36]=A,t[37]=R,t[38]=_,t[39]=s,t[40]=de):de=t[40];let Se;t[41]===Symbol.for("react.memo_cache_sentinel")?(Se=n.jsx(Gb,{}),t[41]=Se):Se=t[41];let ue;t[42]!==O?(ue=n.jsx(ku,{isMobile:O}),t[42]=O,t[43]=ue):ue=t[43];let ke;t[44]===Symbol.for("react.memo_cache_sentinel")?(ke=n.jsx(Bb,{}),t[44]=ke):ke=t[44];let Me;t[45]===Symbol.for("react.memo_cache_sentinel")?(Me=n.jsx(Go,{zone:"left"}),t[45]=Me):Me=t[45];const We=D&&"invisible";let Le;t[46]!==We?(Le=Ze("absolute inset-0",We),t[46]=We,t[47]=Le):Le=t[47];const Ve=!o&&!D;let Ne;t[48]!==Ve?(Ne=n.jsx(Xt,{children:n.jsx(yc,{active:Ve})}),t[48]=Ve,t[49]=Ne):Ne=t[49];let me;t[50]!==Le||t[51]!==Ne?(me=n.jsx("div",{className:Le,children:Ne}),t[50]=Le,t[51]=Ne,t[52]=me):me=t[52];let ye;t[53]!==u?(ye=n.jsx(Xt,{children:n.jsx(es,{needed:u,load:Pj,onFailure:_s})}),t[53]=u,t[54]=ye):ye=t[54];let je;t[55]!==l?(je=n.jsx(Xt,{children:n.jsx(es,{needed:l,load:Ij,onFailure:_s})}),t[55]=l,t[56]=je):je=t[56];let Be;t[57]!==f?(Be=n.jsx(Xt,{children:n.jsx(es,{needed:f,load:Rj,onFailure:_s})}),t[57]=f,t[58]=Be):Be=t[58];let _e;t[59]!==m?(_e=n.jsx(Xt,{children:n.jsx(es,{needed:m,load:Dj,onFailure:_s})}),t[59]=m,t[60]=_e):_e=t[60];let Ie;t[61]!==p?(Ie=p&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Xt,{children:n.jsx(es,{needed:!0,load:_j,onFailure:_s})})}),t[61]=p,t[62]=Ie):Ie=t[62];let tt;t[63]!==h?(tt=n.jsx(es,{needed:h,load:Aj,onFailure:_s}),t[63]=h,t[64]=tt):tt=t[64];let Ke;t[65]!==x?(Ke=n.jsx(Xt,{children:n.jsx(es,{needed:x,load:Oj,onFailure:_s})}),t[65]=x,t[66]=Ke):Ke=t[66];const ze=!!g;let rt;t[67]!==ze?(rt=n.jsx(Xt,{children:n.jsx(es,{needed:ze,load:Mj,onFailure:_s})}),t[67]=ze,t[68]=rt):rt=t[68];let ve;t[69]!==w?(ve=w?n.jsx(Xt,{children:n.jsx(es,{needed:!0,load:Fj,onFailure:_s})}):null,t[69]=w,t[70]=ve):ve=t[70];let M;t[71]!==S?(M=S&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Xt,{children:n.jsx(l1,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:C3})})}),t[71]=S,t[72]=M):M=t[72];let Ce;t[73]!==me||t[74]!==ye||t[75]!==je||t[76]!==Be||t[77]!==_e||t[78]!==Ie||t[79]!==tt||t[80]!==Ke||t[81]!==rt||t[82]!==ve||t[83]!==M?(Ce=n.jsxs("main",{ref:W,className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[me,ye,je,Be,_e,Ie,tt,Ke,rt,ve,M]}),t[73]=me,t[74]=ye,t[75]=je,t[76]=Be,t[77]=_e,t[78]=Ie,t[79]=tt,t[80]=Ke,t[81]=rt,t[82]=ve,t[83]=M,t[84]=Ce):Ce=t[84];let He;t[85]===Symbol.for("react.memo_cache_sentinel")?(He=n.jsx(Go,{zone:"bottom"}),t[85]=He):He=t[85];let Xe;t[86]!==Ce?(Xe=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[Ce,He]}),t[86]=Ce,t[87]=Xe):Xe=t[87];let G,Ee,Pe,Fe;t[88]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(Go,{zone:"right"}),Ee=n.jsx(O2,{}),Pe=n.jsx(F2,{}),Fe=n.jsx(W2,{}),t[88]=G,t[89]=Ee,t[90]=Pe,t[91]=Fe):(G=t[88],Ee=t[89],Pe=t[90],Fe=t[91]);let Te;t[92]!==Xe?(Te=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Me,n.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:[Xe,G,Ee,Pe,Fe]})]})}),t[92]=Xe,t[93]=Te):Te=t[93];let Ae;t[94]===Symbol.for("react.memo_cache_sentinel")?(Ae=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(Xt,{children:n.jsx(tk,{})})}),t[94]=Ae):Ae=t[94];let qe;t[95]===Symbol.for("react.memo_cache_sentinel")?(qe=n.jsx(Xt,{children:n.jsx(d1,{})}),t[95]=qe):qe=t[95];let Ge;t[96]!==Te?(Ge=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ke,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Te,Ae,qe]})]}),t[96]=Te,t[97]=Ge):Ge=t[97];let Je;t[98]!==ue||t[99]!==Ge?(Je=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[ue,Ge]}),t[98]=ue,t[99]=Ge,t[100]=Je):Je=t[100];let st;t[101]!==d||t[102]!==o||t[103]!==i?(st=d?n.jsx(d,{open:o,onOpenChange:i}):null,t[101]=d,t[102]=o,t[103]=i,t[104]=st):st=t[104];let mt;t[105]===Symbol.for("react.memo_cache_sentinel")?(mt=null,t[105]=mt):mt=t[105];let Y;return t[106]!==J||t[107]!==F||t[108]!==re||t[109]!==q||t[110]!==de||t[111]!==Je||t[112]!==st?(Y=n.jsx(c1.Provider,{value:!0,children:n.jsx(Ip,{children:n.jsx(Gk,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[J,F,re,q,ge,Z,de,Se,Je,st,mt]})})})}),t[106]=J,t[107]=F,t[108]=re,t[109]=q,t[110]=de,t[111]=Je,t[112]=st,t[113]=Y):Y=t[113],Y};function Wj(t){return t.isSidebarOpen}function Uj(t){return t.isolatedSpacesEnabled}function Vj(t){return t.setIsMobile}function Hj(t){return t.isSettingsDialogOpen}function Kj(t){return t.setSettingsDialogOpen}function qj(t){return t.runOverviewKey!==null}function Gj(t){return t.isScheduledTasksDialogOpen}function Zj(t){return t.isArchivePageOpen}function Xj(t){return t.isIntegrationsCatalogOpen}function Yj(t){return t.isUsageStatsPageOpen}function Jj(t){return t.isSourceBoardOpen}function Qj(t){return t.isOverviewOpen}function e3(t){return t.worktreesPageProjectId}function t3(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function s3(t){return t.isCommandPaletteOpen}function n3(t){return t.isHelpDialogOpen}function r3(t){return t.isProjectActionsDialogOpen}function o3(t){return t.isOpenCodeStatusDialogOpen}function i3(t){return t.accessDialog!==null}function a3(t){return t.applyDialog!==null}function l3(t){return t.setupOutputDialog!==null}function c3(t){return t.openGuestPageId}function d3(){return K.getState().setOpenGuestPage(null)}function u3(){return rc(d3)}function f3(){return nx()}function p3(){return K.getState().closeMainSurfaces()}function m3(){return ed(!1)}function h3(){return m3}function g3(){return K.getState().closeMainSurfaces()}function x3(){const t=g3,e=nt.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,i=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function b3(){return K.getState().setCommandPaletteOpen(!1)}function w3(){return K.getState().setHelpDialogOpen(!1)}function y3(){return K.getState().setProjectActionsDialogOpen(!1)}function v3(){return K.getState().setOpenCodeStatusDialogOpen(!1)}function S3(){return dn.getState().closeAccessDialog()}function k3(){return dn.getState().closeApplyDialog()}function j3(){return dn.getState().closeSetupOutputDialog()}function C3(){return K.getState().setOpenGuestPage(null)}const Ti="openchamber_requests_in_flight",ju=1e3,T3=300*1e3,eo=Math.ceil(T3/ju),N3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ti)==="1"}catch{return!1}},Cu=()=>({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 E3=1;const P3=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},I3=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Tu=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,o)=>r-o),s},En=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},R3=()=>{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 s=async(r,o)=>{const i=E3++;P3(i,Date.now());try{return await e(r,o)}finally{I3(i)}};window.fetch=s},_l=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Wn=t=>{t.length>eo&&t.splice(0,t.length-eo)},D3=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Tu(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(En(e,50)),t.p90Samples.push(En(e,90)),t.p99Samples.push(En(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,Wn(t.samples),Wn(t.p50Samples),Wn(t.p90Samples),Wn(t.p99Samples),Wn(t.maxSamples),t.lastSampleAt=Date.now()},_3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(D3,ju))},Al=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Ol=t=>{if(!(typeof window>"u"))try{if(t){Al(),_l(),window.localStorage.setItem(Ti,"1"),window.__openchamberRequestsInFlight__=Cu(),R3(),_3();return}window.localStorage.removeItem(Ti),Al(),_l(),delete window.__openchamberRequestsInFlight__}catch{}},v5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Cu();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},S5=()=>{if(typeof window>"u")return Ml();const t=window.__openchamberRequestsInFlight__;if(!N3()||!t)return Ml();const e=Tu(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:En(e,50),ageP90:En(e,90),ageP99:En(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:eo}},Ml=()=>({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:eo}),A3=(t,e,s)=>u1(t.filter(r=>!td(r)&&!r.parentID),e,s),O3=()=>A3(ts.getState().activeSessions,yr.getState().ids,Yi.getState().rankById??f1),M3=(t,e,s)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=s>0?0:t.length-1;return r>=0&&(o=(r+s+t.length)%t.length),t[o]},F3=()=>{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()??"":""},L3=async()=>{const t=F3()||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")},Fl="openchamber:menu-action",Ll="openchamber:check-for-updates",B3=t=>{const e=Ue.c(24),{t:s}=lt(),r=nt($3),o=K(z3),i=K(W3),a=K(U3),d=K(V3),u=K(H3),l=K(K3),f=K(q3),m=vc(G3),{setThemeMode:p}=oo(),h=c.useRef(!1),x=K(Z3);let g,w;e[0]!==x?(g=()=>{Br()&&Ys("desktop_set_menu_shortcuts",{shortcuts:p1(x)}).catch(X3)},w=[x],e[0]=x,e[1]=g,e[2]=w):(g=e[1],w=e[2]),c.useEffect(g,w);let b;e[3]!==m?(b=()=>{h.current||(h.current=!0,m().then(Y3).finally(()=>{h.current=!1}))},e[3]=m,e[4]=b):b=e[4];const j=b,y=J3;let E;e[5]!==u?(E=S=>{const k=nt.getState().currentSessionId,N=M3(O3(),k,S);N&&(u(!1),nt.getState().setCurrentSession(N.id,Bs(N)))},e[5]=u,e[6]=E):E=e[6];const A=E,R=Q3;let _;e[7]!==A||e[8]!==t||e[9]!==r||e[10]!==f||e[11]!==i||e[12]!==u||e[13]!==l||e[14]!==p||e[15]!==s||e[16]!==o||e[17]!==a||e[18]!==d?(_=S=>{e:switch(S){case"about":{f(!0);break e}case"settings":{l(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{u(!1);const k=nt.getState(),N=zt.getState().currentDirectory;r(k.currentSessionId&&N?{directoryOverride:N}:void 0);break e}case"new-worktree-session":{u(!1),g1();break e}case"change-workspace":{y();break e}case"toggle-right-sidebar":{const k=zt.getState().currentDirectory;if(!k)break e;const N=K.getState(),$=rs(k),B=N.contextPanelByDirectory[$],D=B?of(B.tabs,N.contextSurfaceZones,"right",er(B,"right").activeTabId):null;B?.isOpen?N.closeContextPanel($):D?N.setActiveContextPanelTab($,D):N.openContextSurface($,"git");break e}case"open-right-sidebar-git":{const k=zt.getState().currentDirectory;if(!k)break e;K.getState().openContextSurface(rs(k),"git");break e}case"open-right-sidebar-files":{const k=zt.getState().currentDirectory;if(!k)break e;K.getState().openContextSurface(rs(k),"file");break e}case"toggle-terminal":{const k=zt.getState().currentDirectory;if(!k)break e;K.getState().openContextSurface(rs(k),"terminal");break e}case"toggle-context-panel-expanded":{h1(zt.getState().currentDirectory);break e}case"copy":{const k=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(k)||L3();break e}case"theme-light":{p("light");break e}case"theme-dark":{p("dark");break e}case"theme-system":{p("system");break e}case"add-selection-to-chat":{m1();break e}case"toggle-sidebar":{d();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{Ba(-1);break e}case"go-forward":{Ba(1);break e}case"previous-session":{A(-1);break e}case"next-session":{A(1);break e}case"previous-project":{R(-1);break e}case"next-project":{R(1);break e}case"help-dialog":{a();break e}case"download-logs":Jc().catch(()=>{Oe.error(s("openCodeStatusDialog.toast.collectFailed"))})}},e[7]=A,e[8]=t,e[9]=r,e[10]=f,e[11]=i,e[12]=u,e[13]=l,e[14]=p,e[15]=s,e[16]=o,e[17]=a,e[18]=d,e[19]=_):_=e[19];const L=_;let v,C;e[20]!==L||e[21]!==j?(v=()=>{const S=N=>{const $=N.detail;$&&L($)},k=()=>{j()};return window.addEventListener(Fl,S),window.addEventListener(Ll,k),()=>{window.removeEventListener(Fl,S),window.removeEventListener(Ll,k)}},C=[L,j],e[20]=L,e[21]=j,e[22]=v,e[23]=C):(v=e[22],C=e[23]),c.useEffect(v,C)};function $3(t){return t.openNewSessionDraft}function z3(t){return t.toggleCommandPalette}function W3(t){return t.setCommandPaletteOpen}function U3(t){return t.toggleHelpDialog}function V3(t){return t.toggleSidebar}function H3(t){return t.setSessionSwitcherOpen}function K3(t){return t.setSettingsDialogOpen}function q3(t){return t.setAboutDialogOpen}function G3(t){return t.checkForUpdates}function Z3(t){return t.shortcutOverrides}function X3(t){console.warn("[menu-actions] failed to update menu shortcuts",t)}function Y3(){const{available:t,error:e}=vc.getState();if(e){Oe.error("Failed to check for updates",{description:e});return}t||Oe.success("You are on the latest version")}function J3(){lr.requestDirectoryDialog()}function Q3(t){const{activeProjectId:e,projects:s,setActiveProject:r}=Gt.getState();if(s.length===0)return;const o=s.findIndex(d=>d.id===e);let i=t>0?0:s.length-1;o>=0&&(i=(o+t+s.length)%s.length);const a=s[i];a&&r(a.id)}const Bl="openchamber:install-extension",Nu=t=>vx({source:t,confirmed:!1}),e4=()=>{const t=Ue.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(n4,e)};function t4(t){const{url:e}=t.detail??{};typeof e=="string"&&e&&Nu(e)}function s4(t){return t.forEach(Nu)}function n4(){const t=t4;return window.addEventListener(Bl,t),af().then(s4),()=>window.removeEventListener(Bl,t)}const $l=(t,{isAdmitted:e,isPlaced:s,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||td(t)?!1:s||o.pinned&&r||o.work&&Mi(t),r4="openchamber:tray-action",o4=5e3,i4=500,a4=20,zl=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Wl=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Eu=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},Pu=t=>t.title.trim()||"Question",l4=new Set,c4=(t,e)=>j1(t,e,l4,Yi.getState().rankById),d4=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},u4=(t,e,s,r,o)=>{if(!t)return"";const i=gr(s,r,t),a=e.project?.name,d=i?.label?.trim()||a?.trim()||d4(t),u=Vr(t);let l=u&&o.get(u)||"";if(!l){for(const[f,m]of Dn.getState().directories)if(Vr(f)===u){l=m.status?.current??"";break}}if(!l)for(const f of r.values()){const m=u?Wr(f,u):void 0;if(m?.branch){l=m.branch;break}}return l?`${d} · ${l}`:d},f4=()=>{const{dictionary:t}=uf.getState(),e=(l,f)=>ff(t,l,f),{results:s,dropdownProviderIds:r,displayMode:o,extensionProviders:i}=ld.getState(),a=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:a,groups:[]};const d=new Map(s.map(l=>[l.providerId,l])),u=[];for(const l of C1(i)){if(!r.includes(l.id))continue;const f=d.get(l.id);if(!f||f.configured!==!0)continue;const m=[];for(const[h,x]of Object.entries(f.usage?.windows??{})){const g=a==="remaining"?x.remainingPercent:x.usedPercent;m.push({label:N1(h),value:T1(x,g,e)})}const p=!f.ok&&f.error?f.error:m.length===0?"No rate limits reported":null;u.push({provider:l.name,rows:m,status:p})}return{mode:a,groups:u}},p4=async()=>{try{if(no())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=lf();if(e&&fa(e,t))return"Local OpenChamber";const r=(await Di()).hosts.find(o=>e?fa(e,ic(o)):!1);return r?.label?.trim()?cf(r.label.trim()):"Instance"}catch{return""}},m4=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=ai()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[i,a]of o.children.entries()){const d=a.getState();d.vcs?.branch&&e.set(Vr(i)??i,d.vcs.branch);for(const u of d.session)u?.id&&r.set(u.id,u.title);for(const[u,l]of Object.entries(d.session_status??{})){const f=l?.type,m=f==="busy"?"busy":f==="retry"?"retry":"idle",p=t.get(u);(!p||p==="idle")&&t.set(u,m)}for(const[u,l]of Object.entries(d.permission??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||u;s.push({kind:"permission",id:f.id,sessionId:m,sessionTitle:"",label:Eu(f),directory:i,canSave:cd(f.save)})}for(const[u,l]of Object.entries(d.form??{}))for(const f of l??[]){if(!f?.id)continue;const m=f.sessionID||u;s.push({kind:"form",id:f.id,sessionId:m,sessionTitle:"",label:Pu(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},h4=(t,e)=>{const s=ts.getState().activeSessions,r=y1(s),o=v=>r.descendantsOf(v,"active").map(C=>C.id),i=Gt.getState().projects,a=nt.getState().availableWorktreesByProject,d=yr.getState().ids,u=(v,C)=>{const S=Bs(v),k=$a(S,i,a);return so(S)||v.projectID===df?$l(v,{isAdmitted:k,isPlaced:C.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):$l(v,{isAdmitted:k,isPlaced:ec(S)||gr(i,a,S)!==null,isPinned:Xi(d,v.directory,v.id),zones:C})},l=oc.getState(),f={chats:l.showChatsSection,pinned:l.showPinnedSection,work:K.getState().sessionWorkEnabled&&l.showWorkSection},m={chats:!0,pinned:!0,work:!0},p=v1(ii.getState().activeSessionIds,[sd.getState().runningSessionIds,nd.getState().sessionIds,rd.getState().sessionIds,od.getState().bySession.keys(),id.getState().bySession.keys()]),h=v=>k1(v)&&!p.has(v.id),x=K.getState().dockBadgeEnabled?s.filter(v=>h(v)&&u(v,f)):[],g=x.length,w=x.sort((v,C)=>(C.time.idle??C.time.updated)-(v.time.idle??v.time.updated)||v.id.localeCompare(C.id)).slice(0,10).map(v=>({id:v.id,title:v.title,directory:Bs(v)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:w};const b=m4(),j=new Map(b.titleById);for(const v of s)v?.id&&v.title&&j.set(v.id,v.title);const y=ii.getState().statusById,E=v=>{const C=b.statusById.get(v);return C&&C!=="idle"?C:y.get(v)?.status.type??C??"idle"},A=v=>{const C=v.map(S=>E(S));return C.includes("busy")?"busy":C.includes("retry")?"retry":"idle"},R=s.filter(v=>v?.id&&!v.parentID).filter(v=>u(v,m)).slice().sort(c4).slice(0,a4).map(v=>{const C=[v.id,...o(v.id)],S=Bs(v)??"";return{id:v.id,title:v.title||"Untitled session",status:A(C),branch:S?b.branchByDirectory.get(S)??"":"",unseen:h(v)?1:0,hasError:h(v)&&S1(v),directory:S,subtitle:u4(S,v,i,a,b.branchByDirectory)}}),_=b.approvals.map(v=>({...v,sessionTitle:j.get(v.sessionId)||""})),L=new Set(_.map(v=>v.id));for(const[v,C]of ad.getState().bySession){const S=j.get(v)||"";for(const k of C.permissions)L.has(k.id)||(L.add(k.id),_.push({kind:"permission",id:k.id,sessionId:v,sessionTitle:S,label:Eu(k),directory:C.directory,canSave:cd(k.save)}));for(const k of[...C.forms,...C.pages])L.has(k.id)||(L.add(k.id),_.push({kind:"form",id:k.id,sessionId:v,sessionTitle:S,label:Pu(k),directory:C.directory,canSave:!1}))}return{sessions:R,approvals:_.filter(v=>$a(v.directory,i,a)),instanceName:t,usage:f4(),dockBadgeCount:g,dockUnreadSessions:w}},g4=()=>{c.useEffect(()=>{if(!zl()||!Br())return;const t=Wl();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const N=h4(o,t),$=JSON.stringify(N);$!==s&&(s=$,Ys("desktop_tray_update",N))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},i4))},d=ts.subscribe(()=>a()),u=ii.subscribe(()=>a()),l=sd.subscribe(()=>a()),f=nd.subscribe(()=>a()),m=rd.subscribe(()=>a()),p=od.subscribe(()=>a()),h=id.subscribe(()=>a()),x=K.subscribe((N,$)=>{(N.dockBadgeEnabled!==$.dockBadgeEnabled||N.sessionWorkEnabled!==$.sessionWorkEnabled)&&a()}),g=Gt.subscribe(()=>a()),w=nt.subscribe(()=>a()),b=yr.subscribe(()=>a()),j=oc.subscribe((N,$)=>{(N.showChatsSection!==$.showChatsSection||N.showPinnedSection!==$.showPinnedSection||N.showWorkSection!==$.showWorkSection)&&a()}),y=()=>{e=!0,r!==null&&window.clearTimeout(r),d(),u(),l(),f(),m(),p(),h(),x(),g(),w(),b(),j()};if(!t)return i(),y;p4().then(N=>{e||(o=N,i())});const E=new Map,A=()=>{if(e)return;let N;try{N=ai()}catch{return}const $=new Set;for(const[B,D]of N.children.entries())$.add(B),E.has(B)||E.set(B,D.subscribe(()=>a()));for(const[B,D]of E)$.has(B)||(D(),E.delete(B))};let R=null;try{R=ai().subscribeRegistry(()=>{A(),a()})}catch{}A();const _=Dn.subscribe(()=>a()),L=ad.subscribe(()=>a()),v=Yi.subscribe(()=>a()),C=ld.subscribe(()=>a()),S=Bt.subscribe((N,$)=>{N.isInitialized&&!$.isInitialized&&Lo(!0)});Lo(!0);const k=window.setInterval(()=>{A(),i()},o4);return i(),()=>{y(),window.clearInterval(k),_(),L(),v(),C(),S(),R?.();for(const N of E.values())N();E.clear()}},[]),c.useEffect(()=>{if(!zl()||!Br())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=i=>{switch(i.type){case"mark-all-read":b1().then(()=>w1()).catch(()=>{});break;case"menu-opened":Wl()&&Lo();break;case"respond-permission":x1(i.sessionId,i.id,i.response).catch(()=>{Oe.error("Failed to respond to permission request")});break}};let r=null,o=!1;return e(r4,i=>{const a=i?.payload;!a||typeof a!="object"||typeof a.type!="string"||s(a)}).then(i=>{if(o){i();return}r=i,Ys("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=!0;try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},x4=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,b4=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,w4=t=>{t.kind!=="plugin"||!t.title||Oe.info(t.title,{id:b4(t.kind,t.title,t.body,t.tag),description:t.body})},y4=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,v4=t=>{const e=Ue.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(Ps()||!ac()||!globalThis.window))return _n(S4)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function S4(t){if(t.type!=="notification")return;const e=K.getState();if(!e.nativeNotificationsEnabled)return;const s=x4();if(y4(t.payload,s)){w4(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;nc()?.notifications?.notifyAgentCompletion(t.payload)}const k4=()=>{const t=Ue.c(3),{t:e}=lt();let s,r;t[0]!==e?(s=()=>_n(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=Bt.getState().providers,d=u=>a.find(l=>l.id===u);if(i.kind==="account"){const u=d(i.providerId)?.name||i.providerId;Oe.info(i.fromAccount?e("chat.limitFailover.toast.account",{provider:u,from:i.fromAccount,to:i.toAccount}):e("chat.limitFailover.toast.accountUnknown",{provider:u,to:i.toAccount}));return}Oe.info(e("chat.limitFailover.toast.model",{model:za(d(i.providerId),i.modelId),fallback:za(d(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)},Ul="relay-limit-reached",j4=()=>{const t=Ue.c(3),{t:e}=lt();let s,r;t[0]!==e?(s=()=>{const o=()=>{Oe.error(e("relayConnection.limitReached.title"),{id:Ul,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:C4}})};return pa(lc()?.getStatus())&&o(),pf(a=>{pa(a)?o():(a.state==="connected"||a.state==="idle")&&Oe.dismiss(Ul)})},r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),c.useEffect(s,r)};function C4(){return lc()?.retry()}const Vl=()=>{mf()||(E1(),P1(Ap.map(t=>t.id)))},T4=(t,e)=>{const s=Ue.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(Vl,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(Vl,3e3);return()=>clearTimeout(i)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],c.useEffect(r,o)},Hl="pwa-install-toast-shown",Kl="pwa-install-toast-dismissed",N4=()=>{const t=Ue.c(6),{browserTab:e}=Op(),{t:s}=lt(),r=c.useRef(s);let o,i;t[0]!==s?(o=()=>{r.current=s},i=[s],t[0]=s,t[1]=o,t[2]=i):(o=t[1],i=t[2]),c.useEffect(o,i);let a,d;t[3]!==e?(a=()=>{if(typeof window>"u"||!ac()||!e)return;let u=null,l=null;const f=()=>{l!==null&&(Oe.dismiss(l),l=null)},m=async()=>{if(!u)return;const x=u;u=null,f(),await x.prompt();const{outcome:g}=await x.userChoice;g==="accepted"&&Oe.success(r.current("pwa.installPrompt.started"))},p=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),u=g;const w=ma(),b=hf();Mp({dismissed:w.getItem(Kl),sessionShown:b.getItem(Hl),hasActiveToast:l!==null})&&(b.setItem(Hl,"true"),l=Oe.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{ma().setItem(Kl,"true"),f()}}}))},h=()=>{u=null,f(),Oe.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",h),()=>{f(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",h)}},d=[e],t[3]=e,t[4]=a,t[5]=d):(a=t[4],d=t[5]),c.useEffect(a,d)},Iu=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,E4=()=>{us.setState({byRoot:{},runtimeSnapshots:{}});const t=K.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const s of Ri)t.closeContextZone(e,s)},P4=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Ru=async(t,e)=>{const s=(await Di()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await wf(s.id,e);return}const r=yf(ic(s));if(!r)throw new Error("host-not-found");vf({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:Sf(s),sshForwarded:s.sshForwarded===!0})},I4=async t=>{const e=await Di(),s=await xf(t,e.hosts);await bf({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await Ru(s.hostId,{reconnectActive:!0})},R4=async t=>{const e=await gf();for(const s of e)try{s.type==="pairing"?await I4(s.link):await Ru(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(P4(o))}},Ni="project-config-invalid",D4=()=>{const t=Ue.c(9),{t:e}=lt(),s=Bt(_4);let r;t[0]!==s?(r=p=>p.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=Bt(r),[i,a]=$t.useState(!1);let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const p=Bt.getState(),h=p.activeDirectoryKey;a(!0),Promise.all([p.loadProviders({directory:h,source:"projectConfigError:retry"}),p.loadAgents({directory:h,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=d):d=t[2];const u=d;let l,f;t[3]!==o||t[4]!==i||t[5]!==e?(l=()=>{if(!o){Oe.dismiss(Ni);return}Oe.error(e("projectConfigError.toast.title"),{id:Ni,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx(as,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),i||u()}}})},f=[o,i,u,e],t[3]=o,t[4]=i,t[5]=e,t[6]=l,t[7]=f):(l=t[6],f=t[7]),$t.useEffect(l,f);let m;return t[8]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[8]=m):m=t[8],$t.useEffect(O4,m),null};function _4(t){return t.activeDirectoryKey}function A4(){Oe.dismiss(Ni)}function O4(){return A4}const M4="\x1B",F4=new RegExp(`${M4}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Pr=Ss().transform(t=>t.replace(F4,"").trim()).nullish(),L4=Js({isOpenCodeReady:cr().optional(),openCodeRunning:cr().optional(),lastOpenCodeError:Pr,opencodeBinaryResolved:Pr,lastOpenCodeLaunchDiagnostics:Js({sourceBinary:Pr,binary:Pr}).nullish()}),B4=async(t,e=zs)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=L4.parse(await s.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}},$4=(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"}},z4=Js({openchamberVersion:Ss()}),W4=async(t,e=zs)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=z4.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},U4=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function V4({version:t}){const{t:e}=lt(),[s,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const d=await Lp();r(d.available&&!d.installBlocked?{kind:"available",info:d}:{kind:"manual",info:d,error:null})}catch(d){r({kind:"manual",info:null,error:d instanceof Error?d.message:null})}},i=s.kind==="manual"?s:null,a=i?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(ut,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(ce,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&n.jsx("p",{dir:"auto",className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="opencode-version"?n.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:e("updateDialog.openCodeTooOld",{version:i.info.version||"",required:i.info.requiredOpenCodeVersion||"",current:i.info.openCodeVersion||""})}):i.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{dir:"ltr",className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),n.jsx(Fp,{open:s.kind==="available",onOpenChange:d=>{d||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const ql=mr(()=>Ft(()=>import("./OnboardingScreen-BNELvFqK.js"),__vite__mapDeps([267,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}))),H4=()=>Ft(()=>import("./AboutDialog-DZBVspvU.js"),__vite__mapDeps([268,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,244])).then(t=>t.AboutDialog),K4=()=>Ft(()=>import("./MemoryDebugPanel-BiidelAZ.js"),__vite__mapDeps([269,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,209,210,211,212])).then(t=>t.MemoryDebugPanel),q4=()=>{const t=Ue.c(6),e=K(J4),s=K(Q4);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const o=ho(e,H4,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==s?(i=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=i):i=t[5],i},G4=t=>{const e=Ue.c(3),{onClose:s}=t,r=ho(!0,K4,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},Z4=t=>{const e=Ue.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=lt(),[i,a]=c.useState(null);let d,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const v=new AbortController,C=qt(),S=setTimeout(()=>v.abort(),5e3);return B4(v.signal).then(k=>{!v.signal.aborted&&qt()===C&&a(k)}).catch(e5).finally(()=>clearTimeout(S)),()=>{v.abort(),clearTimeout(S)}},u=[],e[0]=d,e[1]=u):(d=e[0],u=e[1]),c.useEffect(d,u);const[l,f]=c.useState(null);let m,p;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const v=new AbortController,C=qt(),S=setTimeout(()=>v.abort(),5e3);return W4(v.signal).then(k=>{v.signal.aborted||qt()!==C||f(k&&U4(k)?k:null)}).catch(t5).finally(()=>clearTimeout(S)),()=>{v.abort(),clearTimeout(S)}},p=[],e[2]=m,e[3]=p):(m=e[2],p=e[3]),c.useEffect(m,p);const h=Bt(s5),x=i?null:h?.message??null;if(l){let v;e[4]!==l?(v=n.jsx(V4,{version:l}),e[4]=l,e[5]=v):v=e[5];let C;e[6]!==r||e[7]!==o?(C=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=C):C=e[8];let S;e[9]!==r||e[10]!==s||e[11]!==C?(S=n.jsx(ut,{type:"button",variant:"outline",onClick:s,disabled:r,children:C}),e[9]=r,e[10]=s,e[11]=C,e[12]=S):S=e[12];let k;return e[13]!==v||e[14]!==S?(k=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[v,S]})}),e[13]=v,e[14]=S,e[15]=k):k=e[15],k}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let w;e[18]!==g?(w=n.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=w):w=e[19];let b;e[20]!==i||e[21]!==h||e[22]!==o?(b=o($4(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=b):b=e[23];let j;e[24]!==b?(j=n.jsx("p",{className:"typography-markdown text-muted-foreground",children:b}),e[24]=b,e[25]=j):j=e[25];let y;e[26]!==w||e[27]!==j?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[w,j]}),e[26]=w,e[27]=j,e[28]=y):y=e[28];let E;e[29]!==x||e[30]!==o?(E=x&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),n.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]=E):E=e[31];let A;e[32]!==i||e[33]!==o?(A=i&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),n.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]=A):A=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]!==s||e[40]!==R?(_=n.jsx(ut,{type:"button",onClick:s,disabled:r,children:R}),e[38]=r,e[39]=s,e[40]=R,e[41]=_):_=e[41];let L;return e[42]!==E||e[43]!==A||e[44]!==_||e[45]!==y?(L=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[y,E,A,_]})}),e[42]=E,e[43]=A,e[44]=_,e[45]=y,e[46]=L):L=e[46],L};function X4({apis:t}){e4(),c.useEffect(()=>I1(),[]),c.useEffect(()=>{kf("App:mounted"),jf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Bt(F=>F.initializeApp),s=Bt(F=>F.isInitialized),r=Bt(F=>F.isConnected),o=Bt(F=>F.providersLoaded),i=Bt(F=>F.agentsLoaded),a=Bt(F=>F.loadProviders),d=Bt(F=>F.loadAgents),u=nt(F=>F.error),l=nt(F=>F.clearError),f=zt(F=>F.currentDirectory),m=zt(F=>F.isSwitchingDirectory),[p,h]=c.useState(!1),x=un(F=>F.refreshAll),g=Jl(F=>F.refresh),[w,b]=c.useState(()=>t.runtime.isVSCode),[j,y]=c.useState(!1),[E,A]=c.useState(0),[R,_]=c.useState(0),[L,v]=c.useState(!1),C=K(F=>F.wideChatLayoutEnabled),S=K(F=>F.mobileKeyboardMode),k=c.useMemo(()=>Ps(),[]),[N,$]=c.useState(()=>ha()),[B,D]=c.useState(()=>{const F=Po();return F!==null?ga({isDesktopShell:!0,bootOutcome:F}):null}),W=c.useRef(!1),{t:H}=lt(),U=c.useRef(!1);c.useEffect(()=>{if(!s||N!=="valid"||U.current)return;const F=Po();F?.target!=="local"||F.status!=="ok"||!F.sshStartupFallbackHostId||(U.current=!0,Oe.error(H("desktopHostSwitcher.startup.title"),{description:H("desktopHostSwitcher.startup.fellBackToLocal")}))},[N,s,H]);const se=c.useRef(!1);c.useEffect(()=>{!s||!Iu()||se.current||(se.current=!0,Oe.info(H("desktopSafeStart.title"),{description:H("desktopSafeStart.description"),duration:1/0}))},[s,H]),c.useEffect(()=>(xa(p),Ol(p),()=>{xa(!1),Ol(!1)}),[p]),c.useEffect(()=>{Cf(S)},[S]),c.useEffect(()=>{b(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>rc(F=>{$p(F)&&zp(F),_(re=>re+1),y(!1),A(re=>re+1)}),[]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",C),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[C]),c.useEffect(()=>(ba(t),()=>ba(null)),[t]),c.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:!0}),R1(t.trackers))},[t.sourceControl,t.trackers,r,x,g,R]),D1();const z=N==="valid",Q=B?.screen==="main";c.useEffect(()=>{if(!Tf({isDesktopShell:k,bootOutcomeKnown:z}))return;_1();const F=setTimeout(()=>{const re=document.getElementById("initial-loading");re&&(re.classList.add("fade-out"),setTimeout(()=>{re.remove()},300))},150);return()=>clearTimeout(F)},[k,z]),c.useEffect(()=>{if(!k||N!=="malformed")return;const F=document.getElementById("initial-loading");F&&(F.textContent="Desktop startup failed — please restart the app.")},[k,N]),c.useEffect(()=>{w||e()},[e,w]),c.useEffect(()=>{if(w||s)return;let F=!0,re,q=0;const ge=10,Z=1e3,de=async()=>{if(!F)return;if(q>=ge){y(!0);return}const Se=Bt.getState();if(Se.isInitialized){y(!1);return}q+=1,await Se.initializeApp();const ue=Bt.getState();if(!F)return;if(ue.isInitialized){y(!1);return}if(q>=ge){y(!0);return}const ke=Math.min(Z*Math.pow(2,q-1),4e3);re=setTimeout(de,ke)};return re=setTimeout(de,Z),()=>{F=!1,re&&clearTimeout(re)}},[E,s,w]),c.useEffect(()=>{s&&y(!1)},[s]),c.useEffect(()=>{if(!j)return;const F=document.getElementById("initial-loading");F&&(F.classList.add("fade-out"),setTimeout(()=>{F.remove()},300))},[j]),c.useEffect(()=>{if(w||!r||o&&i)return;let F=!0,re=0;const q=15,ge=async()=>{const de=Bt.getState();if(!(de.providersLoaded&&de.agentsLoaded))try{de.providersLoaded||await a({source:"startupRecovery"}),Bt.getState().agentsLoaded||await d({source:"startupRecovery"})}catch{}};ge();const Z=setInterval(()=>{if(F){if(++re>=q){clearInterval(Z);return}ge()}},2e3);return()=>{F=!1,clearInterval(Z)}},[r,w,d,a,o,i]),c.useEffect(()=>{m||w||r&&ti.setDirectory(f)},[f,m,r,w]),c.useEffect(()=>{if(typeof window>"u")return;const F=re=>{const q=re.detail,ge=typeof q?.sessionId=="string"?q.sessionId.trim():"";if(!ge)return;const Z=typeof q?.directory=="string"&&q.directory.trim().length>0?q.directory.trim():null,de=typeof q?.messageId=="string"&&q.messageId.trim()||null;wa(ge,String(q?.runtimeKey??"").trim(),de)||Wa(ge,{directory:Z,messageId:de,requireKnownSession:q?.requireKnownSession===!0})};return window.addEventListener("openchamber:open-session",F),Nf().then(re=>{for(const q of re)wa(q.sessionId,q.runtimeKey,q.messageId)||(q.requireKnownSession?Wa(q.sessionId,{messageId:q.messageId,requireKnownSession:!0}):A1(q.sessionId,q.messageId))}),()=>window.removeEventListener("openchamber:open-session",F)},[]),c.useEffect(()=>{if(!Ps())return;const F=()=>{R4(re=>{Oe.error(H(re==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":re==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",F),F(),()=>window.removeEventListener("openchamber:host-actions-ready",F)},[H]);const ie=c.useRef({attempt:null,running:!1,done:!1});c.useLayoutEffect(()=>{const F=ie.current;F.attempt||(F.attempt=Wp({selectNow:!Up().sessionId}))},[]),c.useEffect(()=>{const F=ie.current,re=()=>{const q=F.attempt;if(!q||F.running||F.done)return;const ge=Bt.getState().isInitialized;F.running=!0,q().then(Z=>{if(F.running=!1,Z!=="failed"||ge){F.done=!0;return}Bt.getState().isInitialized&&re()})};re()},[s]),c.useEffect(()=>{if(typeof window>"u")return;const F=()=>{Ys("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Qo()})};return window.addEventListener("openchamber:open-mini-chat",F),()=>window.removeEventListener("openchamber:open-mini-chat",F)},[]),c.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const re=nt.getState().currentSessionId;re&&Yc(re)};return window.addEventListener("focus",F),()=>window.removeEventListener("focus",F)},[]),c.useEffect(()=>{if(typeof window>"u")return;const F=re=>{const q=re.detail,ge=typeof q?.directory=="string"&&q.directory.trim().length>0?q.directory.trim():null,Z=typeof q?.projectId=="string"&&q.projectId.trim().length>0?q.projectId.trim():null,de=!!(ge||Z);K.getState().setSessionSwitcherOpen(!1),nt.getState().openNewSessionDraft({target:de?"project":"chat",selectedProjectId:de?Z:null,directoryOverride:de?ge:null,preserveDirectoryOverride:!!ge})};return window.addEventListener("openchamber:open-draft-session",F),()=>window.removeEventListener("openchamber:open-draft-session",F)},[]),c.useEffect(()=>{typeof window>"u"||!s||m||W.current||(W.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,m]),O1(),v4(),Vp(f||null),Hp(),Kp(t.sourceControl),qp(t.trackers),Gp(),Zp(),Xp(),k4(),M1(),Yp(),j4(),T4(s&&r,R),N4(),F1(),rx(),Jp();const O=c.useCallback(()=>{h(F=>!F)},[]);B3(O),g4(),ox(!0),c.useEffect(()=>{const F=()=>h(re=>!re);return window.addEventListener("openchamber:memory-debug-toggle",F),()=>window.removeEventListener("openchamber:memory-debug-toggle",F)},[]),c.useEffect(()=>{u&&setTimeout(()=>l(),5e3)},[l,u]),c.useEffect(()=>{if(!k||N!=="not-injected")return;let F=!1,re=0;const q=200,ge=2e3,Z=50,de=()=>{if(F)return;re++;const Se=ha();if(Se!=="not-injected"){if(F=!0,$(Se),Se==="valid"){const ke=Po();ke&&D(ga({isDesktopShell:!0,bootOutcome:ke}))}return}const ue=Math.min(q*Math.pow(1.1,re),ge);if(re>=Z){const ke=document.getElementById("initial-loading");ke&&!ke.textContent?.includes("taking longer")&&(ke.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(de,ue)};return window.setTimeout(de,q),()=>{F=!0}},[k,N]);const ne=c.useCallback(async()=>{if(Ef({isDesktopShell:Ps(),isDesktopLocalOriginActive:no()})){await Pf();return}window.location.reload()},[]),V=c.useCallback(async()=>{if(!L){y(!1),v(!0);try{await Bt.getState().initializeApp()}finally{v(!1)}Bt.getState().isInitialized||A(F=>F+1)}},[L]),J=F=>{if(F.screen==="recovery")return F.variant};if(k&&B&&B.screen!=="main"){if(B.screen==="chooser")return n.jsx(Xt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(ql,{mode:"first-launch",localAvailable:B.localAvailable!==!1,onCliAvailable:ne,onChooseRemote:()=>{}})})})});const F=J(B),re=B.screen==="recovery"&&"url"in B?B.url:void 0,q=B.screen==="recovery"&&"hostId"in B?B.hostId:void 0;return n.jsx(Xt,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(ql,{mode:"recovery",recoveryVariant:F,recoveryHostUrl:re,recoveryHostLabel:void 0,recoveryHostId:q,localAvailable:B.localAvailable!==!1,onCliAvailable:ne})})})})}return j&&!s&&!w?n.jsx(Xt,{children:n.jsx(Z4,{onRetry:()=>{V()},isRetrying:L},R)}):n.jsx(Xt,{children:n.jsx(L1,{sdk:ti.getSdkClient(),directory:f||"",children:n.jsx(B1,{apis:t,children:n.jsx(Qp,{children:n.jsx($1,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:k?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(z1,{backgroundWorkEnabled:!0}),n.jsx(em,{}),n.jsx(D4,{}),n.jsx(zj,{}),k?n.jsx(tm,{ready:z&&Q}):null,n.jsx(W1,{}),n.jsx(U1,{}),n.jsx(V1,{}),n.jsx(H1,{}),n.jsx(K1,{}),n.jsx(sm,{}),n.jsx(q4,{}),p&&n.jsx(G4,{onClose:()=>h(!1)})]})})})})},R)})}function Y4(t){const e=Ue.c(2);let s;return e[0]!==t?(s=n.jsx(Bp,{children:n.jsx(X4,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function J4(t){return t.isAboutDialogOpen}function Q4(t){return t.setAboutDialogOpen}function e5(){}function t5(){}function s5(t){return t.lastInitFailure}const n5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();If();Iu()&&E4();nm();rm();Rf().then(()=>{q1().catch(t=>{console.error("[main] settings init failed:",t)}),G1(),Z1(),X1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Du=document.getElementById("root");if(!Du)throw new Error("Root element not found");Y1();_u.createRoot(Du).render(n.jsx($t.StrictMode,{children:n.jsx(J1,{children:n.jsx(Q1,{children:n.jsx(ex,{children:n.jsx(tx,{children:n.jsx(Y4,{apis:n5})})})})})}));const k5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Za as P,yb as a,ej as b,nj as c,rj as d,oj as e,uj as f,S5 as g,pj as h,ij as i,aj as j,lj as k,cj as l,A3 as m,tw as n,tj as o,dj as p,k5 as q,v5 as r,sj as s,jd as u};
|