@openchamber/web 2.7.0 → 2.7.1-canary.20261108.12
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-Bbu8cDW8.js → AboutDialog-uNKjHvzl.js} +1 -1
- package/dist/assets/{AboutLogo-sAyRFbrm.js → AboutLogo-BhyG0ENm.js} +1 -1
- package/dist/assets/{ArchiveView-DvLmQllR.js → ArchiveView-Jt6Qj8Ry.js} +1 -1
- package/dist/assets/{ChangeRequestDiffUnavailable-Ctc-P6zi.js → ChangeRequestDiffUnavailable-CNIWdYRx.js} +1 -1
- package/dist/assets/{ChangedPathLabel-CQOXgkIF.js → ChangedPathLabel-CCsE-8p4.js} +1 -1
- package/dist/assets/{CommandPalette-DHk0MqYi.js → CommandPalette-DrsFSbmk.js} +1 -1
- package/dist/assets/{DiffView-DPpu52DA.js → DiffView-DwaJOPUe.js} +1 -1
- package/dist/assets/{FilesView-CPrroDyU.js → FilesView-Hvxe_KqA.js} +4 -4
- package/dist/assets/{GitView-wWoZ95Yt.js → GitView-ZI_EafL9.js} +1 -1
- package/dist/assets/{GuestSurfacePane-BsMH8QjU.js → GuestSurfacePane-Ds8luSO0.js} +1 -1
- package/dist/assets/{HelpDialog-BZtzVj6Z.js → HelpDialog-DtZKoPZE.js} +1 -1
- package/dist/assets/{IntegrationsCatalogView-DJAOTlcc.js → IntegrationsCatalogView-DgdYlI3Z.js} +1 -1
- package/dist/assets/{JsonTreeView-BXv2HzlC.js → JsonTreeView-zAv-pn0X.js} +1 -1
- package/dist/assets/{MarkdownDiffPreview-CseaChSt.js → MarkdownDiffPreview-Bf9-WPy9.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CyXOMsMS.js → MarkdownRendererImpl-w7LnAwp_.js} +4 -4
- package/dist/assets/{MemoryDebugPanel-xYvjTjLG.js → MemoryDebugPanel-ylQytlyw.js} +1 -1
- package/dist/assets/{NoteEditor-Bbrtl8rq.js → NoteEditor-0HEW8KrY.js} +1 -1
- package/dist/assets/{OfficeDocumentDiff-DXsfJnFq.js → OfficeDocumentDiff-BFr4rAHy.js} +1 -1
- package/dist/assets/{OnboardingScreen-DuWvo16v.js → OnboardingScreen-Bpj6hpDe.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-9WRgjgWL.js → OpenCodeStatusDialog-CX3oxFSb.js} +1 -1
- package/dist/assets/{OverviewView-BzA9rGEs.js → OverviewView-UfIFJ3mf.js} +1 -1
- package/dist/assets/{PatchDiff-DVcyjZVm.js → PatchDiff-DC4ydsOW.js} +1 -1
- package/dist/assets/{PlanView-BGdba90K.js → PlanView-CgoTn3HJ.js} +1 -1
- package/dist/assets/{ProjectActionsDialog-ByPMdwFG.js → ProjectActionsDialog-B16N4lqs.js} +1 -1
- package/dist/assets/{ReplyCommand-pviKPDT8.js → ReplyCommand-CnDNvFmd.js} +1 -1
- package/dist/assets/{ReplyUiBlock-D7HPBgmq.js → ReplyUiBlock-BsOTgv8M.js} +1 -1
- package/dist/assets/{ReviewCards-CU1YHZkQ.js → ReviewCards-BkpTYy_a.js} +1 -1
- package/dist/assets/{RunOverview-uFEfusCK.js → RunOverview-DsffX3fI.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-J8i_b433.js → ScheduledTasksDialog-DgrAfpeX.js} +1 -1
- package/dist/assets/{SettingsView-CaUgulkI.js → SettingsView-B804XZvl.js} +1 -1
- package/dist/assets/{SettingsWindow-BVEVntuV.js → SettingsWindow-k5FSMAzV.js} +1 -1
- package/dist/assets/{SidebarSectionsManager-CIXOcE0-.js → SidebarSectionsManager-DH61-mRe.js} +1 -1
- package/dist/assets/{SourceBoardView-BW1OSOo1.js → SourceBoardView-BvGoSNer.js} +1 -1
- package/dist/assets/{SpaceAccessDialog-6GhzlMD8.js → SpaceAccessDialog-DHNqUzKD.js} +1 -1
- package/dist/assets/{SpaceApplyDialog-zB4jAExK.js → SpaceApplyDialog-DEOTeEjy.js} +1 -1
- package/dist/assets/{SpaceRow-C6QD41XF.js → SpaceRow-CBva6ofM.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-6GuKiRed.js → SpaceSetupOutput-C4NhRkjl.js} +1 -1
- package/dist/assets/{SpacesView-BgncMV45.js → SpacesView-BGevrpQp.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-BwVdGw0c.js → SubmoduleDiffSummary-Bebhaz7n.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CC9hcX2C.js → ToolOutputDialog-B1gU22Tz.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-D15Ja459.js → ToolPartDiffPreview-CVy_zn_m.js} +1 -1
- package/dist/assets/{UiBlock-pyLxOJr6.js → UiBlock-C11qZK5T.js} +2 -2
- package/dist/assets/{UsageStatsView-CMf29PeL.js → UsageStatsView-CNm8WPSk.js} +1 -1
- package/dist/assets/{WalkthroughView-DeuNxpZ7.js → WalkthroughView-Bbwyk6rg.js} +1 -1
- package/dist/assets/{WorktreesView-jHcQwWBH.js → WorktreesView-BGIfERNs.js} +1 -1
- package/dist/assets/{appThemeRegistry-BwyM6n38.js → appThemeRegistry-DYzVI9tX.js} +1 -1
- package/dist/assets/{ar-DnPStsLU.js → ar-CT3AuXVj.js} +1 -1
- package/dist/assets/{codeHighlight-C7ZRQ5-2.js → codeHighlight-BcDjh6yS.js} +1 -1
- package/dist/assets/{columnWidthMemory-Cbfh5HD5.js → columnWidthMemory-BA6h4J11.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DVynfSBh.js → computeVirtualFileMetrics-DVfKKHny.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-CKnYjgFC.js → contextFileOpenGuard-BC79wuu1.js} +1 -1
- package/dist/assets/{date-time-qS8d5iiz.js → date-time-DhfjtTnp.js} +1 -1
- package/dist/assets/{de-SUU4F7Nt.js → de-BdVTH897.js} +1 -1
- package/dist/assets/{documentClient-B0iRikhq.js → documentClient-JcxJ7vyh.js} +2 -2
- package/dist/assets/{documentExport-Cf0gMwM0.js → documentExport-C830mU4N.js} +1 -1
- package/dist/assets/{documentHost-cOykm7qf.js → documentHost-DKm0U_q_.js} +1 -1
- package/dist/assets/{es-BWlkhnKy.js → es-BFk4dosu.js} +1 -1
- package/dist/assets/{fileContentPoller-CKcqqhzG.js → fileContentPoller-BmcApnk-.js} +1 -1
- package/dist/assets/{flexokiTheme-deI9tWCZ.js → flexokiTheme-BMYGLHbL.js} +1 -1
- package/dist/assets/{fr-DN3Tx1EV.js → fr-CeExWqT9.js} +1 -1
- package/dist/assets/{he-B-7jIB_R.js → he-C_O5IfNH.js} +1 -1
- package/dist/assets/{highlights-B2Re-VTM.js → highlights-CIuWBj_n.js} +1 -1
- package/dist/assets/{index-D5Ed7hon.js → index-bD6u6GDm.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-D5FLPdpI.js → initializeSharedPreferences-BcnhlF3e.js} +1 -1
- package/dist/assets/{install-sOrZWWGd.js → install-CSoRI5iX.js} +1 -1
- package/dist/assets/{install-request-C-zhz88k.js → install-request-EHX4ORhb.js} +1 -1
- package/dist/assets/{isDiffPlainText-DpcjRlB-.js → isDiffPlainText-saKoOWJx.js} +1 -1
- package/dist/assets/{isFilePlainText-DJ_bXU7C.js → isFilePlainText-DOjSDWo3.js} +1 -1
- package/dist/assets/{ja-DE4Yf-rX.js → ja-BlUqUBMY.js} +1 -1
- package/dist/assets/{katex.min-g52ii4Gs.js → katex.min-Bs5OLoA1.js} +4 -4
- package/dist/assets/{ko-CETaCyB8.js → ko-CGv47dWq.js} +1 -1
- package/dist/assets/{main-QRYvDkRZ.js → main-064y5MQB.js} +4 -4
- package/dist/assets/{main-89VT8Kff.js → main-D8yzv2tL.js} +2 -2
- package/dist/assets/{miniChat-CgHPqY7Z.js → miniChat-X7g2IHQj.js} +2 -2
- package/dist/assets/{mobile-BQrjPA_e.js → mobile-B5efB3tI.js} +2 -2
- package/dist/assets/{moveWorkspacePath-C4_JgpNC.js → moveWorkspacePath-BaEfuU4S.js} +1 -1
- package/dist/assets/{nl-CL94_9kf.js → nl-CavtTtNf.js} +1 -1
- package/dist/assets/{officeDocument-COfYG-XF.js → officeDocument-CQScRmC1.js} +1 -1
- package/dist/assets/{parseDiffFromFile-CD1h9Yf5.js → parseDiffFromFile-By5H8w4y.js} +1 -1
- package/dist/assets/{pierreDiffTint-Cg024Eeg.js → pierreDiffTint-CVm_qZm-.js} +1 -1
- package/dist/assets/{pl-Bk1GuZBm.js → pl-BQZVI44N.js} +1 -1
- package/dist/assets/{pt-BR-Bfrsw-GS.js → pt-BR-iqkU-MRA.js} +1 -1
- package/dist/assets/{relocateRestoredSession-C79EVzC-.js → relocateRestoredSession-CsK2RUM_.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-lMVP5gEt.js → renderElectronMiniChatApp-DzVezwky.js} +2 -2
- package/dist/assets/{renderMarkdownForExport-DTutihQz.js → renderMarkdownForExport-BM19JOji.js} +1 -1
- package/dist/assets/{renderMobileApp-CmYW0oos.js → renderMobileApp-CiTrtu6R.js} +3 -3
- package/dist/assets/{resolveLanguages-lTTkQHer.js → resolveLanguages-DQXSOQcc.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BJm_77m2.js → runtimeEndpointReset-DiTyBUwe.js} +5 -5
- package/dist/assets/{scheduledTasksApi-CKPLiwD-.js → scheduledTasksApi-Z7dc8sXS.js} +1 -1
- package/dist/assets/{shiki-CQYsk6Az.js → shiki-DW-V1SDr.js} +1 -1
- package/dist/assets/{space-apply-BT-PjBF5.js → space-apply-8YUOtYvk.js} +1 -1
- package/dist/assets/{space-close-C1Qs6EK6.js → space-close-D7zK_obq.js} +1 -1
- package/dist/assets/{spaceNetwork-C14OnxrT.js → spaceNetwork-XStNVwJo.js} +1 -1
- package/dist/assets/{stream-tokenizer-xdyY_PEd.js → stream-tokenizer-BfPOSMyw.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-CRhUx8P-.js → textMateThemeFromAppTheme-CVOJt2hL.js} +1 -1
- package/dist/assets/{tr-Cgg3eQb7.js → tr-CYfLfxAg.js} +1 -1
- package/dist/assets/{uk-zPAKOL1d.js → uk-Bm__l5YX.js} +1 -1
- package/dist/assets/{useAppFontEffects-D9nf8G19.js → useAppFontEffects-3RimJo4B.js} +15 -15
- package/dist/assets/{useBranchPullRequestRequest-CaGsp4wW.js → useBranchPullRequestRequest-CMvepZei.js} +1 -1
- package/dist/assets/{useCallableModelProviders-B1YBs2FN.js → useCallableModelProviders-DpMos2Hl.js} +1 -1
- package/dist/assets/{useDiffFindSurface-DiINVOLu.js → useDiffFindSurface-Dy5ZvPrH.js} +1 -1
- package/dist/assets/{useGitCleanLine-BK-o3SG6.js → useGitCleanLine-COG7MPwc.js} +1 -1
- package/dist/assets/{useInlineCommentController-CzeMiLCm.js → useInlineCommentController-_L6_JHZ6.js} +1 -1
- package/dist/assets/{useMarkdownLocalAssets-wPn7MXUN.js → useMarkdownLocalAssets-CH5Ekvbl.js} +1 -1
- package/dist/assets/{useRootScrollLock-BvsNFl90.js → useRootScrollLock-DdknBCBa.js} +2 -2
- package/dist/assets/{useWalkthroughReview-CEo_4ZLc.js → useWalkthroughReview-Bi8eB9_G.js} +1 -1
- package/dist/assets/{useWholeFileComment-BexRzYws.js → useWholeFileComment-CqHAJ2YU.js} +1 -1
- package/dist/assets/{useWorktreeArchiveActions-DaRx6tMV.js → useWorktreeArchiveActions-D1kaQEP9.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-z3n6zAAT.js → vendor-codemirror-language-data-DRsX0PKK.js} +2 -2
- package/dist/assets/{zh-CN-BPcuR4-K.js → zh-CN-Db0Y0Ij-.js} +1 -1
- package/dist/assets/{zh-TW-CmPAjna9.js → zh-TW-CuzqmROB.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-wWoZ95Yt.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-D9nf8G19.js","assets/katex.min-g52ii4Gs.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod--raI7LhK.js","assets/vendor-opencode-client-CeybcDBQ.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-7f7Y525Q.css","assets/vendor-base-ui-CqKCZJyd.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-CqfECoM0.js","assets/vendor-tanstack-virtual-core-BdFnkr_2.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-z3n6zAAT.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-CEhBoV5L.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-BJm_77m2.js","assets/space-apply-BT-PjBF5.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-BK-o3SG6.js","assets/useBranchPullRequestRequest-CaGsp4wW.js","assets/parseDiffFromFile-CD1h9Yf5.js","assets/computeVirtualFileMetrics-DVynfSBh.js","assets/themeResolver-DXizngAV.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-DpcjRlB-.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-Cg024Eeg.js","assets/ReviewCards-CU1YHZkQ.js","assets/useInlineCommentController-CzeMiLCm.js","assets/appThemeRegistry-BwyM6n38.js","assets/textMateThemeFromAppTheme-CRhUx8P-.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/ChangedPathLabel-CQOXgkIF.js","assets/OfficeDocumentDiff-DXsfJnFq.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/documentClient-B0iRikhq.js","assets/useRootScrollLock-BvsNFl90.js","assets/moveWorkspacePath-C4_JgpNC.js","assets/contextFileOpenGuard-CKnYjgFC.js","assets/install-request-C-zhz88k.js","assets/WalkthroughView-DeuNxpZ7.js","assets/ChangeRequestDiffUnavailable-Ctc-P6zi.js","assets/useDiffFindSurface-DiINVOLu.js","assets/useWalkthroughReview-CEo_4ZLc.js","assets/useCallableModelProviders-B1YBs2FN.js","assets/useWholeFileComment-BexRzYws.js","assets/DiffView-DPpu52DA.js","assets/SubmoduleDiffSummary-BwVdGw0c.js","assets/FilesView-CPrroDyU.js","assets/flexokiTheme-deI9tWCZ.js","assets/vendor-codemirror-search-CWqbGraJ.js","assets/vendor-replit-codemirror-vim-DTiXsOdM.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-wPn7MXUN.js","assets/fileContentPoller-CKcqqhzG.js","assets/JsonTreeView-BXv2HzlC.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-DJ_bXU7C.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-C7ZRQ5-2.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/model-dyJJrKMm.js","assets/UiBlock-pyLxOJr6.js","assets/date-time-qS8d5iiz.js","assets/vendor-openuidev-lang-core-DF2LaCPS.js","assets/columnWidthMemory-Cbfh5HD5.js","assets/scheduledTasksApi-CKPLiwD-.js","assets/GuestSurfacePane-BsMH8QjU.js","assets/SettingsWindow-BVEVntuV.js","assets/SettingsView-CaUgulkI.js","assets/install-sOrZWWGd.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SpaceRow-C6QD41XF.js","assets/AboutLogo-sAyRFbrm.js","assets/pageTitle-BT3-HFbv.js","assets/mobileHeader-DaHAqQ0c.js","assets/CommandPalette-DHk0MqYi.js","assets/HelpDialog-BZtzVj6Z.js","assets/ProjectActionsDialog-ByPMdwFG.js","assets/OpenCodeStatusDialog-9WRgjgWL.js","assets/RunOverview-uFEfusCK.js","assets/ScheduledTasksDialog-J8i_b433.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-DvLmQllR.js","assets/useWorktreeArchiveActions-DaRx6tMV.js","assets/IntegrationsCatalogView-DJAOTlcc.js","assets/UsageStatsView-CMf29PeL.js","assets/SourceBoardView-BW1OSOo1.js","assets/OverviewView-BzA9rGEs.js","assets/WorktreesView-jHcQwWBH.js","assets/SpacesView-BgncMV45.js","assets/SpaceAccessDialog-6GhzlMD8.js","assets/spaceNetwork-C14OnxrT.js","assets/SpaceApplyDialog-zB4jAExK.js","assets/SpaceSetupOutput-6GuKiRed.js","assets/OnboardingScreen-DuWvo16v.js","assets/AboutDialog-Bbu8cDW8.js","assets/MemoryDebugPanel-xYvjTjLG.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as Le,j as s,R as c,r as Ut,a as Zl,h as Bu}from"./vendor-react--VO_rL_p.js";import{bB as mr,n as Yt,l as Ht,cH as zu,cI as Xl,u as G,bz as _s,aX as Jt,b0 as no,ch as fs,cJ as Ti,b2 as ro,cK as Wu,c8 as Yl,cL as yt,cM as Uu,bw as zr,m as Ni,bx as Us,by as Rr,bW as Vu,bC as Jl,cN as Ei,br as Ii,cO as Hu,cC as Ql,c3 as aa,b5 as ec,cP as qu,cQ as hr,cR as Wr,cS as tr,cT as Ku,cU as Gn,cV as Gu,cW as Jo,cX as jr,cY as Pi,cZ as oo,c_ as _n,bd as Ur,j as qs,c$ as En,d0 as Zu,d1 as ks,b as pn,d2 as gr,d3 as Xu,d4 as Qs,d5 as Yu,d6 as tc,d7 as Ju,d8 as Qu,d9 as sc,da as ef,ck as tf,c7 as sf,cc as nf,c9 as rf,bv as of,bs as xs,v as Qo,ca as af,db as lf,dc as cf,bN as ei,dd as Ri,de as df,bp as uf,be as la,cB as nc,df as ca,aZ as rc,dg as ff,dh as pf,w as oc,cb as mf,di as da,bP as Di,dj as ic,bY as hf,aY as gf,t as xf,q as bf,bA as ac,cp as ua,cq as lc,cF as wf,ci as yf,cm as fa,dk as vf,dl as Sf,bU as kf,bS as jf,dm as Cf,bZ as Tf,co as Nf,dn as Ef,dp as If,dq as Pf,dr as pa,ds as Ro,dt as ma,du as ha,dv as Rf,bE as ga,dw as Df,dx as _f,bF as xa,dy as Af,bT as Of,i as Mf,a as Ff}from"./katex.min-g52ii4Gs.js";import{_ as Lt}from"./vendor-vite-runtime-DD1OZmLC.js";import{bv as Lf,bw as cc,aD as dc,bx as ds,r as ba,by as $f,aF as Bf,bz as wa,aG as ya,V as uc,X as fc,Z as pc,W as mc,U as _i,a0 as hc,_ as gc,Y as xc,as as zf,at as Wf,ax as Uf,ay as Vf,az as Hf,al as qf,av as Kf,G as Gf,au as Zf,N as Xf,Q as Yf,a2 as Jf,a1 as Qf,b8 as ep,bA as bc,bB as Dr,bC as wc,bD as tp,bE as yc,bF as vn,bG as va,bH as Sa,bI as Do,bJ as ka,aw as _r,b5 as sp,b6 as np,aB as rp,br as op,bs as vc,bK as ip,b7 as ap,bL as lp,bM as cp,bN as ja,bO as _o,bP as on,bQ as Sn,bR as dp,bS as Ca,bT as up,bU as fp,bV as pp,bW as mp,bX as hp,bY as gp,bZ as xp,b_ as Ta,b$ as bp,c0 as wp,c1 as yp,c2 as vp,c3 as Sp,b9 as kp,b3 as jp,bq as Cp,ba as Tp,bt as Np,c4 as Ep,bm as Ip,bn as Pp,aE as Sc,c5 as Rp,c6 as Dp,c7 as _p,c8 as Ap,c9 as Op,bp as Mp,ca as Fp,bi as Lp,cb as $p,cc as Bp,bf as zp,bc as Wp,bd as Up,be as Vp,bb as Hp,bg as qp,bu as Kp,bl as Gp,bk as Zp,bo as Xp,cd as Yp,ce as Jp}from"./runtimeEndpointReset-BJm_77m2.js";import{gk as Na,aQ as io,Z as ts,a0 as st,cD as xr,Q as We,eQ as Qp,cE as em,I as oe,eR as tm,u as rt,la as an,Y as ps,lb as sm,ax as ms,aB as Ts,ay as Ai,lc as kc,bb as Hs,gj as jc,gi as nm,bs as rm,ld as Cc,le as om,lf as im,bh as br,ad as St,ac as kt,ae as jt,jP as Ks,cH as Tc,lg as am,lh as lm,b8 as cm,A as Te,cM as Oi,kh as Nc,li as Ec,bH as dm,lj as um,lk as fm,k1 as Ic,ll as pm,aO as Zs,fv as mm,aw as hm,bk as Cs,b6 as wr,bi as ao,jy as In,bj as lo,lm as gm,ln as co,lo as xm,lp as bm,aP as wn,lq as wm,fz as Pc,lr as ym,hX as yr,hY as uo,cy as Vr,fA as vm,ls as Sm,lt as km,lu as jm,lv as Cm,lw as Tm,cP as Rc,lx as Nm,cV as fo,ly as Em,lz as Im,lA as Pm,kk as Rm,lB as Dm,b_ as sr,fE as Dc,lC as _m,t as nr,q as rr,D as or,l as ir,F as ar,o as Hr,B as ft,lD as An,a4 as gn,a5 as xn,a6 as bn,a7 as Gt,af as mn,lE as _c,lF as Mi,n as gs,b2 as Qt,lG as Ac,lH as Am,cY as Oc,lI as Om,lJ as Mm,bR as Es,lK as Fm,cd as hn,lL as Ea,bX as Ar,lM as Lm,g4 as $m,cn as Fi,lN as Bm,lO as Mc,lP as Li,e3 as zm,dG as qr,ea as Fc,dZ as $i,d_ as Bi,lQ as Lc,ha as us,y as On,C as ti,hp as Wm,hV as Um,hA as Vm,id as Hm,lR as qm,h4 as $c,bT as Vs,K as zi,bO as Km,as as ys,bS as Bc,cf as Ia,ce as Hn,h5 as Gm,cg as Zm,cu as Wi,cp as Xm,h7 as Ao,lS as Ym,z as Jm,bt as Qm,bu as eh,bv as th,bw as sh,bx as nh,ed as Pa,bY as zc,bV as Kr,lT as rh,lU as oh,lV as ih,dW as Ln,bM as ah,bP as po,bQ as lh,bU as ch,aN as Mn,i2 as dh,bW as uh,hb as fh,co as mo,lW as Wc,lX as Uc,lY as ph,dS as mh,dO as hh,dR as gh,lZ as xh,d$ as bh,dP as Ra,l_ as wh,io as yh,l$ as vh,m0 as Sh,dQ as Da,e9 as kh,dU as jh,b3 as Ch,m1 as Th,m2 as Nh,m3 as Eh,m4 as Ui,m5 as Vi,m6 as Ih,m7 as Ph,m8 as Rh,m9 as Dh,ma as _h,kT as Hi,mb as Ah,mc as Oh,md as Mh,me as Fh,mf as qi,mg as Lh,bN as $h,mh as Bh,mi as zh,b0 as Vc,mj as Hc,br as Wh,mk as Uh,x as qc,ml as Vh,mm as Tn,ca as Hh,aM as qh,aq as Kh,mn as Gh,V as Wt,mo as Zh,mp as Xh,dp as Yh,mq as Kc,mr as Jh,ms as Or,mt as kn,jD as Qh,mu as fn,e6 as eg,mv as tg,mw as Gc,kr as Zc,fq as ho,e2 as sg,dw as ng,mx as Ki,my as rg,eS as tn,mz as Xc,bl as og,mA as ig,mB as ag,mC as lg,mD as Oo,mE as cg,mF as dg,fb as ug,fr as fg,gS as Gi,cO as pg,gP as mg,jQ as hg,jR as gg,cW as xg,mG as lr,gO as Yc,gN as Jc,jS as bg,jT as wg,gQ as yg,ff as vg,b1 as Sg,aR as kg,mH as Mo,mI as jg,mJ as Cg,mK as Qc,mL as ed,mM as Tg,mN as Ng,mO as si,mP as Js,dK as Eg,jN as Ig,mQ as _a,mR as Pg,mS as Rg,bg as cr,mT as Aa,mU as Dg,mV as _g,mW as Ag,k5 as Og,mX as Mg,k6 as Oa,k7 as Fg,dj as Lg,mY as $g,mZ as Bg,m_ as zg,bq as Wg,k as Ug,kv as Vg,cJ as Ma,k8 as Hg,k9 as qg,cN as Kg,kb as Gg,ka as Zg,m$ as Fo,n0 as Fa,l9 as td,kn as sd,fc as go,n1 as Xg,n2 as nd,eF as Yg,gp as ni,n3 as rd,j0 as xo,n4 as Jg,jr as Qg,n5 as e1,n6 as od,n7 as t1,n8 as id,fe as s1,fd as Zi,n9 as n1,na as La,nb as r1,nc as o1,fg as i1,G as ri,nd as ad,ci as ld,cj as cd,ck as dd,ne as oi,cl as ud,jZ as fd,nf as Lo,ng as a1,go as l1,ku as c1,a1 as d1,nh as u1,ni as f1,nj as pd,bc as $a,ey as p1,jU as m1,nk as h1,jX as g1,nl as x1,nm as b1,dq as Ba,nn as w1,j$ as y1,no as v1,kU as S1,fJ as k1,np as j1,fY as za,fo as C1,fK as T1,fM as N1,fL as E1,fU as I1,fT as P1,fN as R1,kV as D1,fS as _1,fO as A1,fP as O1,fQ as M1,fR as F1,a as L1,s as $1,b as B1,c as z1,l2 as W1,aj as U1,f$ as V1,g0 as H1,g1 as q1}from"./useAppFontEffects-D9nf8G19.js";import{f as md,u as hd,S as K1,W as gd,a as G1,G as Z1,b as X1,c as Y1}from"./useRootScrollLock-BvsNFl90.js";import{h as xd,i as Gr,T as bd,M as wd,D as yd,f as ii}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as J1,h as Q1,u as vd,S as Sd,v as ex,a as tx}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as kd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{S as sx,M as nx,C as rx,i as ox,j as ix,k as ax}from"./vendor-base-ui-CqKCZJyd.js";import{a as ln,O as lx,d as cx,D as dx,b as ux,u as fx,m as Wa}from"./moveWorkspacePath-C4_JgpNC.js";import{u as ai,c as bo,p as px}from"./vendor-zustand-C9tWdk0j.js";import{o as sn,s as Ns,n as wo,c as jd,f as mx,e as dr,a as li}from"./vendor-zod--raI7LhK.js";import{u as hx}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{v as Ua,t as Va}from"./contextFileOpenGuard-CKnYjgFC.js";import{d as gx,m as xx}from"./vendor-tanstack-virtual-core-BdFnkr_2.js";import{r as bx}from"./install-request-C-zhz88k.js";const Cd=t=>`${t}|chats`,wx=(t,e)=>{if(mr(e))return Cd(t);const n=Yt(e);return n?`${t}|${n}`:null},yx=(t,e,n)=>{const r=Yt(t);return!r||mr(r)?[]:n.some(o=>Yt(o)===r)?[]:e.filter(o=>!o.parentID&&!o.time?.archived&&Yt(o.directory??null)===r).sort((o,i)=>Na(i)-Na(o)).map(o=>o.id)};function vx(t){const e=Le.c(37),{directory:n,className:r}=t,{currentTheme:o}=io(),i=ts(jx),a=st(kx),d=Ht(Sx),u=zu(n);let l;e[0]!==n||e[1]!==d?(l=Xl(n,d),e[0]=n,e[1]=d,e[2]=l):l=e[2];const f=l;let m;e[3]!==n||e[4]!==f||e[5]!==i||e[6]!==u||e[7]!==a?(m=f||!n?null:xr(i,a,n,u),e[3]=n,e[4]=f,e[5]=i,e[6]=u,e[7]=a,e[8]=m):m=e[8];const p=m;if(f){let M;e[9]!==r?(M=We("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=M):M=e[10];let S;return e[11]!==M?(S=s.jsx(oe,{name:"chat-4",className:M}),e[11]=M,e[12]=S):S=e[12],S}if(!p)return null;const h=p.icon?Qp[p.icon]:null;let x;e[13]!==p.color?(x=em(p.color)??void 0,e[13]=p.color,e[14]=x):x=e[14];const g=x;let b;e[15]!==r||e[16]!==g||e[17]!==h?(b=h?s.jsx(oe,{name:h,className:We("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):s.jsx(oe,{name:"folder",className:We("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),style:g?{color:g}:void 0}),e[15]=r,e[16]=g,e[17]=h,e[18]=b):b=e[18];const w=b;if(!p.iconImage)return w;let j;e[19]!==r?(j=We("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 v;e[21]!==p.iconBackground?(v=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[21]=p.iconBackground,e[22]=v):v=e[22];let T;e[23]!==p.iconImage||e[24]!==p.id?(T={id:p.id,iconImage:p.iconImage},e[23]=p.iconImage,e[24]=p.id,e[25]=T):T=e[25];let F;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(F={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=F):F=e[28];let _;e[29]!==w||e[30]!==T||e[31]!==F?(_=s.jsx(tm,{project:T,options:F,className:"h-full w-full object-contain",fallback:w}),e[29]=w,e[30]=T,e[31]=F,e[32]=_):_=e[32];let A;return e[33]!==j||e[34]!==v||e[35]!==_?(A=s.jsx("span",{className:j,style:v,children:_}),e[33]=j,e[34]=v,e[35]=_,e[36]=A):A=e[36],A}function Sx(t){return t.homeDirectory}function kx(t){return t.availableWorktreesByProject}function jx(t){return t.projects}const qn=24,Cx=(t,e,n=qn)=>{const r=e.right-(t.right-n);if(r>0)return r;const o=e.left-(t.left+n);return o<0?o:0},Tx=({transform:t})=>({...t,y:0}),Nx=16,Ex=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*Nx:t.deltaY;t.currentTarget.scrollLeft+=no(t.currentTarget)?-e:e},Ix={Item:({className:t,...e})=>s.jsx(nx,{className:We(im,t),...e}),Separator:({className:t,...e})=>s.jsx(sx,{className:We(om,t),...e})},Px=t=>{const e=Le.c(127),{tab:n,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:d,onPin:u,onClose:l,renderMenu:f,closeOtherTabs:m,onMenuOpenChangeComplete:p,children:h}=t,{t:x}=rt(),g=G(Dx);let b;e[0]!==g?(b=Ai("switch_session_tab",g),e[0]=g,e[1]=b):b=e[1];const w=b;let j;e[2]!==r||e[3]!==w?(j=w&&w!==kc&&r<=9?ms(`${w}+${r}`):void 0,e[2]=r,e[3]=w,e[4]=j):j=e[4];const v=j,[T,F]=c.useState(!1);let _;e[5]!==n.id?(_={id:n.id},e[5]=n.id,e[6]=_):_=e[6];const{attributes:A,listeners:M,setNodeRef:S,transform:k,transition:C,isDragging:y}=vd(_);let E;e[7]!==x||e[8]!==n.session.title?(E=n.session.title?.trim()||x("sessions.sidebar.session.untitled"),e[7]=x,e[8]=n.session.title,e[9]=E):E=e[9];const B=E,$=n.id;let O;e[10]!==n.session?(O=Hs(n.session),e[10]=n.session,e[11]=O):O=e[11];const z=cc($,O),J=jc(n.id),K=J!==null,V=nm(n.id)&&!o&&!K,Y=K||V;let ae;e[12]!==d||e[13]!==n?(ae=()=>d(n),e[12]=d,e[13]=n,e[14]=ae):ae=e[14];let P;e[15]!==m||e[16]!==n.id?(P=()=>m(n.id),e[15]=m,e[16]=n.id,e[17]=P):P=e[17];let de,q,Q,L,ne,W,te,Z,me,Ie,fe,je,$e,Re,Fe,Ve,De,ge,xe,Se;if(e[18]!==A||e[19]!==h||e[20]!==T||e[21]!==o||e[22]!==z||e[23]!==y||e[24]!==i||e[25]!==M||e[26]!==l||e[27]!==p||e[28]!==u||e[29]!==d||e[30]!==f||e[31]!==S||e[32]!==g||e[33]!==Y||e[34]!==a||e[35]!==x||e[36]!==ae||e[37]!==P||e[38]!==n||e[39]!==v||e[40]!==B||e[41]!==k||e[42]!==C||e[43]!==J){const Ee={session:n.session,open:T,isActive:o,select:ae,closeOtherTabs:P,components:Ix};$e=S;let _e;e[64]!==k?(_e=kd.Translate.toString(k),e[64]=k,e[65]=_e):_e=e[65],e[66]!==_e||e[67]!==C?(Re={transform:_e,transition:C},e[66]=_e,e[67]=C,e[68]=Re):Re=e[68];const pe=y&&"z-10 opacity-60";e[69]!==pe?(Fe=We("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",pe),e[69]=pe,e[70]=Fe):Fe=e[70],Ve=o?"true":"false",e[71]!==o?(De=o?{"data-active-session-tab":!0}:{},e[71]=o,e[72]=De):De=e[72],ge=A,xe=M,L=br,me=T,Ie=F,e[73]!==p?(fe=Ce=>p?.(Ce),e[73]=p,e[74]=fe):fe=e[74];let R;e[75]!==h||e[76]!==o||e[77]!==z||e[78]!==i||e[79]!==l||e[80]!==u||e[81]!==d||e[82]!==g||e[83]!==Y||e[84]!==a||e[85]!==x||e[86]!==n||e[87]!==B||e[88]!==J?(R=s.jsx(St,{asChild:!0,children:s.jsx(rx,{render:Ce=>s.jsx("div",{...Ce,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:o?void 0:()=>d(n),onDoubleClick:i?()=>u(n.id):void 0,onKeyDown:o?void 0:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),d(n))},onAuxClick:Ne=>{Ne.button===1&&(Ne.preventDefault(),l(n.id))},className:We("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",o?"bg-interactive-selection text-interactive-selection-foreground":"cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx(vx,{directory:Hs(n.session),className:We(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":x("header.sessionTabs.closeTab"),onClick:Ne=>{Ne.stopPropagation(),l(n.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:s.jsx(oe,{name:"close",className:"size-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:x("header.sessionTabs.closeTab"),shortcut:o?ms(_s()?"mod+w":Ts("close_session_tab",g),""):void 0})})]})]}),s.jsx("div",{className:We("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:B})})}),z?s.jsx(oe,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":x("sessions.aiRename.generating")}):Y?s.jsx(Tc,{state:J??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[75]=h,e[76]=o,e[77]=z,e[78]=i,e[79]=l,e[80]=u,e[81]=d,e[82]=g,e[83]=Y,e[84]=a,e[85]=x,e[86]=n,e[87]=B,e[88]=J,e[89]=R):R=e[89];let ie;e[90]!==v||e[91]!==B?(ie=s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:B,shortcut:v})}),e[90]=v,e[91]=B,e[92]=ie):ie=e[92],e[93]!==R||e[94]!==ie?(je=s.jsxs(kt,{children:[R,ie]}),e[93]=R,e[94]=ie,e[95]=je):je=e[95],Q=ox,q=ix,Z="app-region-no-drag z-50",de=ax,Se="dropdown-menu-content",e[96]===Symbol.for("react.memo_cache_sentinel")?(ne={color:"var(--surface-elevated-foreground)"},W=We(rm,"min-w-[190px]"),e[96]=ne,e[97]=W):(ne=e[96],W=e[97]),te=f(Ee),e[18]=A,e[19]=h,e[20]=T,e[21]=o,e[22]=z,e[23]=y,e[24]=i,e[25]=M,e[26]=l,e[27]=p,e[28]=u,e[29]=d,e[30]=f,e[31]=S,e[32]=g,e[33]=Y,e[34]=a,e[35]=x,e[36]=ae,e[37]=P,e[38]=n,e[39]=v,e[40]=B,e[41]=k,e[42]=C,e[43]=J,e[44]=de,e[45]=q,e[46]=Q,e[47]=L,e[48]=ne,e[49]=W,e[50]=te,e[51]=Z,e[52]=me,e[53]=Ie,e[54]=fe,e[55]=je,e[56]=$e,e[57]=Re,e[58]=Fe,e[59]=Ve,e[60]=De,e[61]=ge,e[62]=xe,e[63]=Se}else de=e[44],q=e[45],Q=e[46],L=e[47],ne=e[48],W=e[49],te=e[50],Z=e[51],me=e[52],Ie=e[53],fe=e[54],je=e[55],$e=e[56],Re=e[57],Fe=e[58],Ve=e[59],De=e[60],ge=e[61],xe=e[62],Se=e[63];let Be;e[98]!==de||e[99]!==ne||e[100]!==W||e[101]!==te||e[102]!==Se?(Be=s.jsx(de,{"data-slot":Se,style:ne,className:W,children:te}),e[98]=de,e[99]=ne,e[100]=W,e[101]=te,e[102]=Se,e[103]=Be):Be=e[103];let Pe;e[104]!==q||e[105]!==Z||e[106]!==Be?(Pe=s.jsx(q,{className:Z,children:Be}),e[104]=q,e[105]=Z,e[106]=Be,e[107]=Pe):Pe=e[107];let Me;e[108]!==Q||e[109]!==Pe?(Me=s.jsx(Q,{children:Pe}),e[108]=Q,e[109]=Pe,e[110]=Me):Me=e[110];let Je;e[111]!==L||e[112]!==me||e[113]!==Ie||e[114]!==fe||e[115]!==je||e[116]!==Me?(Je=s.jsxs(L,{open:me,onOpenChange:Ie,onOpenChangeComplete:fe,children:[je,Me]}),e[111]=L,e[112]=me,e[113]=Ie,e[114]=fe,e[115]=je,e[116]=Me,e[117]=Je):Je=e[117];let X;return e[118]!==$e||e[119]!==Re||e[120]!==Fe||e[121]!==Ve||e[122]!==De||e[123]!==ge||e[124]!==xe||e[125]!==Je?(X=s.jsx("div",{ref:$e,style:Re,className:Fe,"data-active":Ve,...De,...ge,...xe,children:Je}),e[118]=$e,e[119]=Re,e[120]=Fe,e[121]=Ve,e[122]=De,e[123]=ge,e[124]=xe,e[125]=Je,e[126]=X):X=e[126],X},Rx=t=>{const e=Le.c(109),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:d,direction:u}=rt(),l=u==="rtl",f=an(Ax),m=an(Ox),p=an(Mx),h=an(Fx),x=an(Lx),g=an($x),b=st(Bx),w=st(zx),j=ps(Wx),v=G(Ux),T=an(Vx),F=ps(Hx),_=st(qx),A=st(Kx),M=st(Gx),S=st(Zx),k=st(Xx),C=st(Yx);let y;e[0]!==C?(y=U=>{const we=C??U.activeProjectId;return U.projects.find(ke=>ke.id===we)?.path??null},e[0]=C,e[1]=y):y=e[1];const E=ts(y),B=Lf(b);let $,O;e[2]!==B||e[3]!==_||e[4]!==b||e[5]!==k||e[6]!==S||e[7]!==A||e[8]!==E||e[9]!==p||e[10]!==T||e[11]!==v||e[12]!==F?($=()=>{if(!v)T(am,Jx);else{if(!F)return;const U=Jt(),we=!b&&A&&S,ke=b?_:A&&!S?k??E:null,Xe=we?Cd(U):wx(U,ke);if(!Xe)return;T(Xe,()=>yx(ke,ps.getState().activeSessions,ts.getState().projects.map(Qx)))}b&&p(b,B)},O=[B,_,b,k,S,A,E,p,T,v,F],e[2]=B,e[3]=_,e[4]=b,e[5]=k,e[6]=S,e[7]=A,e[8]=E,e[9]=p,e[10]=T,e[11]=v,e[12]=F,e[13]=$,e[14]=O):($=e[13],O=e[14]),c.useEffect($,O);let z;if(e[15]!==j){z=new Map;for(const U of j)z.set(U.id,U);e[15]=j,e[16]=z}else z=e[16];const J=z;let K;if(e[17]!==J||e[18]!==f){K=[];for(const U of f){const we=J.get(U);we&&K.push({id:U,session:we})}e[17]=J,e[18]=f,e[19]=K}else K=e[19];const ee=K;let V;e[20]!==w?(V=U=>{w(U.id,Hs(U.session))},e[20]=w,e[21]=V):V=e[21];const Y=V,ae=eb,P=!b&&A;let de;e[22]!==P||e[23]!==M?(de=U=>!P||!M?"":(U.drafts.find(ke=>ke.id===M)?.text??"").split(/\r?\n/).find(tb)?.trim()??"",e[22]=P,e[23]=M,e[24]=de):de=e[24];const q=sm(de),Q=G(sb),L=nb;let ne;e[25]!==b||e[26]!==P||e[27]!==ee?(ne=ee.some(U=>U.id===b)||P&&ee.length>0,e[25]=b,e[26]=P,e[27]=ee,e[28]=ne):ne=e[28];const W=ne;let te,Z;e[29]!==W?(te=()=>{if(W)return dc(rb,{current:document.body})},Z=[W],e[29]=W,e[30]=te,e[31]=Z):(te=e[30],Z=e[31]),c.useEffect(te,Z);let me;e[32]!==x||e[33]!==b||e[34]!==Y||e[35]!==ee?(me=U=>{if(x(U),b&&b!==U){const we=ee.find(ke=>ke.id===U);we&&Y(we)}},e[32]=x,e[33]=b,e[34]=Y,e[35]=ee,e[36]=me):me=e[36];const Ie=me;let fe;e[37]===Symbol.for("react.memo_cache_sentinel")?(fe={activationConstraint:{distance:8}},e[37]=fe):fe=e[37];let je;e[38]===Symbol.for("react.memo_cache_sentinel")?(je={activationConstraint:{delay:200,tolerance:6}},e[38]=je):je=e[38];const $e=xd(Gr(wd,fe),Gr(bd,je));let Re;e[39]!==g?(Re=U=>{const{active:we,over:ke}=U;ke&&we.id!==ke.id&&g(String(we.id),String(ke.id))},e[39]=g,e[40]=Re):Re=e[40];const Fe=Re,Ve=c.useRef(null);let De;e[41]===Symbol.for("react.memo_cache_sentinel")?(De={left:!1,right:!1},e[41]=De):De=e[41];const[ge,xe]=c.useState(De);let Se;e[42]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>{const U=Ve.current;if(!U)return;const we=U.scrollWidth-U.clientWidth,ke=no(U)?we+U.scrollLeft:U.scrollLeft,Xe=ke>2,Oe=ke<we-2;xe(se=>se.left===Xe&&se.right===Oe?se:{left:Xe,right:Oe})},e[42]=Se):Se=e[42];const Be=Se;let Pe;e[43]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>{Be();const U=Ve.current;if(!U||!globalThis.ResizeObserver)return;const we=new ResizeObserver(Be);return we.observe(U),()=>we.disconnect()},e[43]=Pe):Pe=e[43];let Me;e[44]!==ee.length?(Me=[Be,ee.length],e[44]=ee.length,e[45]=Me):Me=e[45],c.useEffect(Pe,Me);let Je;e[46]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>{const U=Ve.current,we=U?.querySelector("[data-active-session-tab]");if(!U||!we)return;const ke=Cx(U.getBoundingClientRect(),we.getBoundingClientRect());ke!==0&&(U.scrollLeft=U.scrollLeft+ke,Be())},e[46]=Je):Je=e[46];let X;e[47]!==b?(X=[b,Be],e[47]=b,e[48]=X):X=e[48],c.useEffect(Je,X);const Ee=ge.left&&ge.right?`linear-gradient(to right, transparent, black ${qn}px, black calc(100% - ${qn}px), transparent)`:ge.left?`linear-gradient(to right, transparent, black ${qn}px)`:ge.right?`linear-gradient(to right, black calc(100% - ${qn}px), transparent)`:void 0;let _e;e[49]!==ee?(_e=ee.map(ob),e[49]=ee,e[50]=_e):_e=e[50];const pe=_e;let R;e[51]!==b||e[52]!==ee?(R=!!b&&!ee.some(U=>U.id===b),e[51]=b,e[52]=ee,e[53]=R):R=e[53];const ie=R;let Ce;e[54]!==d?(Ce=d("header.sessionTabs.stripAria"),e[54]=d,e[55]=Ce):Ce=e[55];let Ne;e[56]!==Ee?(Ne=Ee?{maskImage:Ee,WebkitMaskImage:Ee}:void 0,e[56]=Ee,e[57]=Ne):Ne=e[57];let ze;e[58]===Symbol.for("react.memo_cache_sentinel")?(ze=[Tx],e[58]=ze):ze=e[58];const qe=l?J1:Q1;let Ue;e[59]!==i||e[60]!==b||e[61]!==Ie||e[62]!==Y||e[63]!==r||e[64]!==h||e[65]!==m||e[66]!==n||e[67]!==a||e[68]!==ee?(Ue=ee.map((U,we)=>s.jsx(Px,{tabNumber:we+1,tab:U,isActive:U.id===b,isPreview:U.id===m,suppressControls:U.id===b&&a,onSelect:Y,onPin:h,onClose:ae,renderMenu:n,closeOtherTabs:Ie,onMenuOpenChangeComplete:r,children:U.id===b?i:null},U.id)),e[59]=i,e[60]=b,e[61]=Ie,e[62]=Y,e[63]=r,e[64]=h,e[65]=m,e[66]=n,e[67]=a,e[68]=ee,e[69]=Ue):Ue=e[69];let tt;e[70]!==qe||e[71]!==Ue||e[72]!==pe?(tt=s.jsx(Sd,{items:pe,strategy:qe,children:Ue}),e[70]=qe,e[71]=Ue,e[72]=pe,e[73]=tt):tt=e[73];let He;e[74]!==Fe||e[75]!==$e||e[76]!==tt?(He=s.jsx(yd,{sensors:$e,collisionDetection:ii,modifiers:ze,onDragEnd:Fe,children:tt}),e[74]=Fe,e[75]=$e,e[76]=tt,e[77]=He):He=e[77];let Ze;e[78]!==q||e[79]!==P||e[80]!==d?(Ze=P?s.jsxs("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2 text-interactive-selection-foreground","data-active":"true","data-active-session-tab":!0,children:[s.jsx(oe,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),s.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:q||d("sessions.switcher.draftTitle")})})]}):null,e[78]=q,e[79]=P,e[80]=d,e[81]=Ze):Ze=e[81];let Qe;e[82]!==i||e[83]!==ie?(Qe=ie?s.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:i})}):null,e[82]=i,e[83]=ie,e[84]=Qe):Qe=e[84];let ot;e[85]!==Ne||e[86]!==He||e[87]!==Ze||e[88]!==Qe?(ot=s.jsxs("div",{ref:Ve,onScroll:Be,onWheel:Ex,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ne,children:[He,Ze,Qe]}),e[85]=Ne,e[86]=He,e[87]=Ze,e[88]=Qe,e[89]=ot):ot=e[89];let pt;e[90]!==d?(pt=d("sessions.sidebar.header.actions.newSession"),e[90]=d,e[91]=pt):pt=e[91];let at;e[92]===Symbol.for("react.memo_cache_sentinel")?(at=s.jsx(oe,{name:"add",className:"size-4"}),e[92]=at):at=e[92];let xt;e[93]!==pt?(xt=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:L,"aria-label":pt,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:at})}),e[93]=pt,e[94]=xt):xt=e[94];let le;e[95]!==d?(le=d("sessions.sidebar.header.actions.newSession"),e[95]=d,e[96]=le):le=e[96];let be;e[97]!==Q?(be=ms(Ts("new_chat",Q),""),e[97]=Q,e[98]=be):be=e[98];let Ae;e[99]!==le||e[100]!==be?(Ae=s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:le,shortcut:be})}),e[99]=le,e[100]=be,e[101]=Ae):Ae=e[101];let N;e[102]!==xt||e[103]!==Ae?(N=s.jsxs(kt,{children:[xt,Ae]}),e[102]=xt,e[103]=Ae,e[104]=N):N=e[104];let ce;return e[105]!==Ce||e[106]!==ot||e[107]!==N?(ce=s.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ce,children:[ot,N]}),e[105]=Ce,e[106]=ot,e[107]=N,e[108]=ce):ce=e[108],ce};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 $x(t){return t.reorderTabs}function Bx(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 qx(t){return t.currentSessionDirectory}function Kx(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){Cc(t)}function tb(t){return t.trim()}function sb(t){return t.shortcutOverrides}function nb(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:n}=st.getState(),r=t?Ht.getState().currentDirectory:e.directoryOverride;n(r?{directoryOverride:r}:void 0)}function rb(){const t=st.getState().currentSessionId;t?Cc(t):lm(-1)}function ob(t){return t.id}function Ha(t){const e=Le.c(37),{sessionId:n,onArchive:r,Item:o}=t,{t:i}=rt(),a=G(ab);let d;e[0]!==n?(d=y=>y.currentSessionId===n,e[0]=n,e[1]=d):d=e[1];const u=st(d);let l;e[2]!==a?(l=ms(Ts("archive_current_session",a),""),e[2]=a,e[3]=l):l=e[3];const f=l;let m;e[4]!==n?(m=y=>!!y.entityById.get(n)?.time.archived,e[4]=n,e[5]=m):m=e[5];const p=ps(m);let h;e[6]!==n?(h=y=>{const E=y.entityById.get(n);return!E||cm(E,y.entityById)},e[6]=n,e[7]=h):h=e[7];const x=ps(h),g=st(ib);let b;e[8]!==n||e[9]!==i||e[10]!==g?(b=async()=>{await g(n)?Te.success(i("sessions.sidebar.session.restore.success")):Te.error(i("sessions.sidebar.session.restore.error"))},e[8]=n,e[9]=i,e[10]=g,e[11]=b):b=e[11];const w=b;if(p&&!x)return null;const j=p?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let v;e[12]!==i||e[13]!==j?(v=i(j),e[12]=i,e[13]=j,e[14]=v):v=e[14];let T;e[15]!==p||e[16]!==r||e[17]!==w?(T=p?()=>{w()}:r,e[15]=p,e[16]=r,e[17]=w,e[18]=T):T=e[18];const F=p?"inbox-unarchive":"inbox-archive";let _;e[19]!==F?(_=s.jsx(oe,{name:F,className:"me-1 size-4"}),e[19]=F,e[20]=_):_=e[20];const A=p?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let M;e[21]!==i||e[22]!==A?(M=i(A),e[21]=i,e[22]=A,e[23]=M):M=e[23];let S;e[24]!==f||e[25]!==p||e[26]!==u?(S=!p&&u&&f?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:f}):null,e[24]=f,e[25]=p,e[26]=u,e[27]=S):S=e[27];let k;e[28]!==o||e[29]!==_||e[30]!==M||e[31]!==S||e[32]!==T?(k=s.jsxs(o,{onClick:T,children:[_,M,S]}),e[28]=o,e[29]=_,e[30]=M,e[31]=S,e[32]=T,e[33]=k):k=e[33];let C;return e[34]!==k||e[35]!==v?(C=s.jsx(ds,{hint:v,children:k}),e[34]=k,e[35]=v,e[36]=C):C=e[36],C}function ib(t){return t.unarchiveSession}function ab(t){return t.shortcutOverrides}function lb(t){const e=Le.c(17),{session:n,Item:r}=t,{t:o}=rt();if(!G(cb)||n.parentID||!Oi(n))return null;let a;e[0]!==n||e[1]!==o?(a=async()=>{try{await Nc(n.id,Hs(n),"done"),Ec([n.id])}catch{Te.error(o("sessions.sidebar.session.work.updateFailed"))}},e[0]=n,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==o?(u=o("sessions.sidebar.session.menuHint.markDone"),e[3]=o,e[4]=u):u=e[4];let l;e[5]!==d?(l=()=>{d()},e[5]=d,e[6]=l):l=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(oe,{name:"check",className:"me-1 size-4"}),e[7]=f):f=e[7];let m;e[8]!==o?(m=o("sessions.sidebar.session.work.markDone"),e[8]=o,e[9]=m):m=e[9];let p;e[10]!==r||e[11]!==l||e[12]!==m?(p=s.jsxs(r,{onClick:l,children:[f,m]}),e[10]=r,e[11]=l,e[12]=m,e[13]=p):p=e[13];let h;return e[14]!==u||e[15]!==p?(h=s.jsx(ds,{hint:u,children:p}),e[14]=u,e[15]=p,e[16]=h):h=e[16],h}function cb(t){return t.sessionWorkEnabled}const db=t=>{const e=Ic(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},ub=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,Td=()=>{const t=Le.c(4),e=st(fb),n=st(pb)??void 0,r=dm(e??"",n,db,ub),{context:o}=um(e,n),i=o>0?o:fm;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 fb(t){return t.currentSessionId}function pb(t){return t.currentSessionDirectory}const qa=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),$s=18,ci=2,di=($s-ci)/2,Ka=2*Math.PI*di,mb=t=>{const e=Le.c(9),{percent:n,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,n));let d;e[0]!==o?(d=We("shrink-0",o),e[0]=o,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("circle",{cx:$s/2,cy:$s/2,r:di,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ci}),e[2]=u):u=e[2];let l;e[3]!==i||e[4]!==a?(l=a>0?s.jsx("circle",{cx:$s/2,cy:$s/2,r:di,fill:"none",stroke:i,strokeWidth:ci,strokeLinecap:"round",strokeDasharray:Ka,strokeDashoffset:Ka*(1-a/100),transform:`rotate(-90 ${$s/2} ${$s/2})`}):null,e[3]=i,e[4]=a,e[5]=l):l=e[5];let f;return e[6]!==d||e[7]!==l?(f=s.jsxs("svg",{viewBox:`0 0 ${$s} ${$s}`,className:d,"aria-hidden":"true",children:[u,l]}),e[6]=d,e[7]=l,e[8]=f):f=e[8],f},Nd=()=>{const t=Le.c(16),{t:e}=rt(),{sessionId:n,fill:r,limit:o}=Td(),{totalCost:i}=pm(n);if(!n||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens: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:md(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=s.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(hb)}),t[14]=f,t[15]=m):m=t[15],m};function hb(t){return s.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const gb="—",xb={safe:"var(--status-success)",warn:"var(--status-warning)",critical:"var(--status-error)"},bb=t=>{const e=Le.c(35),{buttonClassName:n}=t,{t:r}=rt(),{sessionId:o,fill:i,limit:a}=Td(),d=Zs();let u;e[0]!==d?(u=d?fs(d):"",e[0]=d,e[1]=u):u=e[1];const l=u,f=G(yb);let m;e[2]!==l?(m=y=>l!==""&&Ti(y.contextPanelByDirectory[l],y.contextSurfaceZones).has("context"),e[2]=l,e[3]=m):m=e[3];const p=G(m);if(!o||!i)return null;const h=i.state==="measured"?i.totalTokens/a*100:null,x=h===null?void 0:xb[mm(Math.round(h))];let g;e[4]!==l||e[5]!==f?(g=l?()=>f(l,"context"):void 0,e[4]=l,e[5]=f,e[6]=g):g=e[6];let b;e[7]!==r?(b=r("contextUsage.aria.label"),e[7]=r,e[8]=b):b=e[8];const w=p&&"text-foreground";let j;e[9]!==n||e[10]!==w?(j=We(n,"w-auto gap-1.5 px-1 tabular-nums",w),e[9]=n,e[10]=w,e[11]=j):j=e[11];const v=h??0;let T;e[12]!==x||e[13]!==v?(T=s.jsx(mb,{percent:v,arcColor:x,className:"size-4"}),e[12]=x,e[13]=v,e[14]=T):T=e[14];let F;e[15]!==h?(F=h===null?gb:`${Math.min(h,999).toFixed(1)}%`,e[15]=h,e[16]=F):F=e[16];let _;e[17]!==F?(_=s.jsx("span",{dir:"ltr",className:"typography-meta",children:F}),e[17]=F,e[18]=_):_=e[18];let A;e[19]!==p||e[20]!==_||e[21]!==g||e[22]!==b||e[23]!==j||e[24]!==T?(A=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:g,"aria-label":b,"aria-pressed":p,className:j,children:[T,_]})}),e[19]=p,e[20]=_,e[21]=g,e[22]=b,e[23]=j,e[24]=T,e[25]=A):A=e[25];let M;e[26]!==p||e[27]!==r?(M=p?null:s.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=p,e[27]=r,e[28]=M):M=e[28];let S;e[29]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Nd,{}),e[29]=S):S=e[29];let k;e[30]!==M?(k=s.jsx(jt,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[M,S]})}),e[30]=M,e[31]=k):k=e[31];let C;return e[32]!==A||e[33]!==k?(C=s.jsxs(kt,{children:[A,k]}),e[32]=A,e[33]=k,e[34]=C):C=e[34],C},wb=c.memo(bb);function yb(t){return t.openContextSurface}const Ed=c.createContext(null),Id=()=>c.useContext(Ed),vb=t=>{const e=Le.c(4),n=Id()?.observe;let r,o;e[0]!==t||e[1]!==n?(r=()=>t&&n?n():void 0,o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),c.useEffect(r,o)},Ga=t=>{const e=Le.c(12),{run:n,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,d=o===void 0?!1:o;if(n?.status==="stopping"||n?.status==="waiting-for-preview"){let l;e[0]!==i?(l=We("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=s.jsx(oe,{name:"loader-4",className:l}),e[2]=l,e[3]=f):f=e[3],f}if(n){const l=d?"stop-large":"stop";let f;e[4]!==i?(f=We("size-4 shrink-0 text-[var(--status-warning)]",i),e[4]=i,e[5]=f):f=e[5];let m;return e[6]!==l||e[7]!==f?(m=s.jsx(oe,{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?s.jsx(oe,{name:"play",className:We("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=u):u=e[11],u},Sb=t=>{const e=Le.c(68),{directory:n,buttonClassName:r}=t,{t:o}=rt(),i=ln(jb),a=ln(Cb),d=ln(Tb),u=ln(Nb),l=hm(u),f=ln(Eb),m=ln(Ib),p=ln(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=_s()&&ro();let b;e[3]!==a||e[4]!==i?(b=a.find(Q=>Q.id===i)??a.find(Rb)??a[0]??lx[0],e[3]=a,e[4]=i,e[5]=b):b=e[5];const w=b;if(!g||!n||a.length===0)return null;let j;e[6]!==n?(j=async Q=>{await Wu(n,Q.id,Q.appName)||await Yl(n,Q.appName)},e[6]=n,e[7]=j):j=e[7];const v=j;let T;e[8]!==v||e[9]!==p?(T=async Q=>{await p(Q.id),await v(Q)},e[8]=v,e[9]=p,e[10]=T):T=e[10];const F=T;let _;e[11]!==n||e[12]!==o?(_=async()=>{(await wr(n)).ok&&Te.success(o("openInApp.toast.pathCopied"))},e[11]=n,e[12]=o,e[13]=_):_=e[13];const A=_;let M;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx("div",{className:"inline-flex"}),e[14]=M):M=e[14];let S;e[15]!==v||e[16]!==w?(S=()=>{v(w)},e[15]=v,e[16]=w,e[17]=S):S=e[17];let k;e[18]!==l||e[19]!==r?(k=We(r,l),e[18]=l,e[19]=r,e[20]=k):k=e[20];let C;e[21]!==w.label||e[22]!==o?(C=o("openInApp.actions.openInAria",{app:w.label}),e[21]=w.label,e[22]=o,e[23]=C):C=e[23];let y;e[24]!==w.icon?(y=s.jsx(oe,{name:w.icon,className:"size-4"}),e[24]=w.icon,e[25]=y):y=e[25];let E;e[26]!==C||e[27]!==y||e[28]!==S||e[29]!==k?(E=s.jsx(ao,{render:M,children:s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:S,className:k,"aria-label":C,children:y})})}),e[26]=C,e[27]=y,e[28]=S,e[29]=k,e[30]=E):E=e[30];let B;e[31]!==w.label||e[32]!==o?(B=o("openInApp.actions.openInAria",{app:w.label}),e[31]=w.label,e[32]=o,e[33]=B):B=e[33];let $;e[34]!==B?($=s.jsx(jt,{side:"bottom",children:B}),e[34]=B,e[35]=$):$=e[35];let O;e[36]!==E||e[37]!==$?(O=s.jsxs(kt,{children:[E,$]}),e[36]=E,e[37]=$,e[38]=O):O=e[38];let z;e[39]!==A?(z=()=>{A()},e[39]=A,e[40]=z):z=e[40];let J;e[41]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(oe,{name:"file-copy",className:"h-4 w-4"}),e[41]=J):J=e[41];let K;e[42]!==o?(K=o("openInApp.actions.copyPath"),e[42]=o,e[43]=K):K=e[43];let ee;e[44]!==K?(ee=s.jsx("span",{className:"typography-ui-label text-foreground",children:K}),e[44]=K,e[45]=ee):ee=e[45];let V;e[46]!==z||e[47]!==ee?(V=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:z,children:[J,ee]}),e[46]=z,e[47]=ee,e[48]=V):V=e[48];let Y;e[49]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(In,{}),e[49]=Y):Y=e[49];let ae;if(e[50]!==a||e[51]!==F||e[52]!==w.id){let Q;e[54]!==F||e[55]!==w.id?(Q=L=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{F(L)},children:[s.jsx(oe,{name:L.icon,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:L.label}),w.id===L.id?s.jsx(oe,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},L.id),e[54]=F,e[55]=w.id,e[56]=Q):Q=e[56],ae=a.map(Q),e[50]=a,e[51]=F,e[52]=w.id,e[53]=ae}else ae=e[53];let P;e[57]!==d||e[58]!==m||e[59]!==o?(P=d?s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(oe,{name:"refresh",className:"h-4 w-4"}),s.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]=P):P=e[60];let de;e[61]!==V||e[62]!==ae||e[63]!==P?(de=s.jsxs(lo,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[V,Y,ae,P]}),e[61]=V,e[62]=ae,e[63]=P,e[64]=de):de=e[64];let q;return e[65]!==O||e[66]!==de?(q=s.jsxs(br,{children:[O,de]}),e[65]=O,e[66]=de,e[67]=q):q=e[67],q},kb=c.memo(Sb);function jb(t){return t.selectedAppId}function Cb(t){return t.availableApps}function Tb(t){return t.isCacheStale}function Nb(t){return t.isScanning}function Eb(t){return t.initialize}function Ib(t){return t.loadInstalledApps}function Pb(t){return t.selectApp}function Rb(t){return t.id===cx}const Kn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Db=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const o=Kn(n??"");if(o){const i=xr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function Pd(){const t=ts(b=>b.projects),e=ts(b=>b.activeProjectId),n=st(b=>b.availableWorktreesByProject),r=st(b=>b.currentSessionId),o=gm(r??null),i=st(b=>r?b.worktreeMetadata.get(r)?.path??"":""),a=st(b=>b.newSessionDraft?.open?Kn(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),d=st(b=>b.newSessionDraft?.open?b.newSessionDraft.target==="chat":null),u=c.useMemo(()=>Kn(i||""),[i]),l=c.useMemo(()=>Kn(o||""),[o]),f=u||l||a,m=c.useMemo(()=>Db({projects:t,worktreesByProject:n,directory:f,activeProjectId:e}),[e,f,t,n]),p=c.useMemo(()=>Kn(f||m?.path||""),[f,m?.path]),h=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),x=d??mr(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 _b=t=>{const e=Le.c(67),{buttonClassName:n}=t,{t:r}=rt(),o=Id(),i=G(Fb),[a,d]=c.useState(!1),u=G(Lb);let l;e[0]!==u?(l=ms(Ts("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;vb(!0);let x;e[5]!==h?(x=de=>h?de.getDirectoryState(h.directory)?.tabs.find(q=>q.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 b;e[7]!==m.name||e[8]!==h||e[9]!==r?(b=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]=b):b=e[10];const w=b;let j;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(j=h&&g?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:n,"aria-label":r("projectActions.actions.openPreview"),children:s.jsx(oe,{name:"global",className:"size-4"})})}),s.jsx(jt,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=n,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=j):j=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx("div",{className:"inline-flex"}),e[17]=v):v=e[17];let T;e[18]!==o||e[19]!==m?(T=()=>o.toggle(m),e[18]=o,e[19]=m,e[20]=T):T=e[20];const F=o.isLoading||h?.status==="stopping",_=a&&"text-foreground";let A;e[21]!==n||e[22]!==_?(A=We(n,_),e[21]=n,e[22]=_,e[23]=A):A=e[23];let M;e[24]!==m||e[25]!==h?(M=h?s.jsx(Ga,{run:h,large:!0}):s.jsx(oe,{name:ba(m),className:"size-4"}),e[24]=m,e[25]=h,e[26]=M):M=e[26];let S;e[27]!==w||e[28]!==A||e[29]!==M||e[30]!==T||e[31]!==F?(S=s.jsx(ao,{render:v,children:s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:T,disabled:F,className:A,"aria-label":w,children:M})})}),e[27]=w,e[28]=A,e[29]=M,e[30]=T,e[31]=F,e[32]=S):S=e[32];let k;e[33]!==w?(k=s.jsx("span",{children:w}),e[33]=w,e[34]=k):k=e[34];let C;e[35]!==r?(C=r("projectActions.header.allActions"),e[35]=r,e[36]=C):C=e[36];let y;e[37]!==f||e[38]!==C?(y=s.jsx("span",{className:"typography-micro text-muted-foreground",children:s.jsx(Ks,{label:C,shortcut:f})}),e[37]=f,e[38]=C,e[39]=y):y=e[39];let E;e[40]!==k||e[41]!==y?(E=s.jsx(jt,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[k,y]})}),e[40]=k,e[41]=y,e[42]=E):E=e[42];let B;e[43]!==S||e[44]!==E?(B=s.jsxs(kt,{children:[S,E]}),e[43]=S,e[44]=E,e[45]=B):B=e[45];const $=o.openSettings;let O;e[46]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(oe,{name:"add",className:"h-4 w-4"}),e[46]=O):O=e[46];let z;e[47]!==r?(z=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=z):z=e[48];let J;e[49]!==z?(J=s.jsx("span",{className:"typography-ui-label text-foreground",children:z}),e[49]=z,e[50]=J):J=e[50];let K;e[51]!==o.openSettings||e[52]!==J?(K=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:$,children:[O,J]}),e[51]=o.openSettings,e[52]=J,e[53]=K):K=e[53];let ee;e[54]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(In,{}),e[54]=ee):ee=e[54];let V;e[55]!==o||e[56]!==r?(V=o.actions.map(de=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{o.select(de),o.toggle(de)},children:[s.jsx(oe,{name:ba(de),className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:de.name}),de.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:r("projectActions.menu.sharedBadge")}):null,s.jsx(Ga,{run:o.runOf(de),className:"ms-auto"})]},de.id)),e[55]=o,e[56]=r,e[57]=V):V=e[57];let Y;e[58]!==K||e[59]!==V?(Y=s.jsxs(lo,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[K,ee,V]}),e[58]=K,e[59]=V,e[60]=Y):Y=e[60];let ae;e[61]!==B||e[62]!==Y?(ae=s.jsxs(br,{onOpenChange:d,children:[B,Y]}),e[61]=B,e[62]=Y,e[63]=ae):ae=e[63];let P;return e[64]!==ae||e[65]!==j?(P=s.jsxs(s.Fragment,{children:[j,ae]}),e[64]=ae,e[65]=j,e[66]=P):P=e[66],P},Ab=c.memo(_b),Ob=t=>{const e=Le.c(8),{buttonClassName:n}=t,r=Pd();if(!r)return null;let o;e[0]!==n||e[1]!==r.directory?(o=s.jsx(kb,{directory:r.directory,buttonClassName:n}),e[0]=n,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==n?(i=s.jsx(Ab,{buttonClassName:n}),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=s.jsxs(s.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},Mb=c.memo(Ob);function Fb(t){return t.openContextPreview}function Lb(t){return t.shortcutOverrides}const $o="--oc-titlebar-controls-width",ui=new Set;let Zn=null;const Rd=t=>{Zn===null?t.style.removeProperty($o):t.style.getPropertyValue($o)!==Zn&&t.style.setProperty($o,Zn)},$b=t=>{const e=`${Math.round(t)}px`;e!==Zn&&(Zn=e,ui.forEach(Rd))},Dd=t=>{if(t)return ui.add(t),Rd(t),()=>{ui.delete(t)}},Wn="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",jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Za=t=>!t.parentId&&!t.archived&&!Ei(t.directory),Bb=()=>{Uu("ui.header.render");const{t,direction:e}=rt(),n=G(H=>H.isSidebarOpen),r=co(),o=G(H=>H.sessionTabsEnabled),i=st(H=>!!H.newSessionDraft?.open),a=st(H=>H.currentSessionId),d=xm(a??""),u=bm(a??""),l=ps(ai(c.useCallback(H=>{if(!a)return null;const Ge=[...H.activeSessions,...H.archivedSessions].find(It=>It.id===a);if(!Ge)return null;const mt=Ge;return{title:Ge.title??null,directory:mt.directory??null,created:Ge.time?.created??null,slug:mt.slug??null,parentId:Ge.parentID??null,archived:!!Ge.time?.archived}},[a]))),f=ts(ai(H=>{if(!H.activeProjectId)return null;const Ge=H.projects.find(mt=>mt.id===H.activeProjectId);return Ge?{id:Ge.id,path:Ge.path,label:Ge.label}:null})),m=c.useMemo(()=>{if(!f)return null;const H=f.label?.trim();if(H)return H;const Ge=f.path.split(/[\\/]/).filter(Boolean);return Ge[Ge.length-1]??null},[f]),{isMobile:p}=wn(),h=c.useRef(null),[x,g]=c.useState(()=>typeof window>"u"?!1:_s()),b=c.useMemo(()=>zr(),[]),w=wm(),[j,v]=c.useState(!1),T=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:F,side:_}=hd(),A=c.useMemo(()=>{if(typeof window>"u")return null;const H=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof H=="number"&&Number.isFinite(H)&&H>0)return H;if(typeof navigator>"u")return null;const Ge=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ge)return null;const mt=Number.parseInt(Ge[1],10),It=Number.parseInt(Ge[2],10);return Number.isNaN(mt)?null:mt===10?It:mt},[]);Ut.useEffect(()=>{typeof window>"u"||g(_s())},[]);const M=c.useMemo(()=>Ni(),[]),S=G(H=>H.shortcutOverrides),k=ms(Ts("rename_current_session",S),""),C=G(H=>H.workStatusPanelVisible),y=G(H=>H.workStatusPanelEnabled),E=G(H=>H.setWorkStatusPanelEnabled),B=G(H=>H.workStatusPanelFits),$=G(H=>H.workStatusOverlayOpen),O=G(H=>H.setWorkStatusOverlayOpen),J=y&&B||$,K=c.useCallback(()=>{if(y&&!B){O(!$);return}E(!y)},[O,E,$,y,B]),ee=a?l??null:null,V=c.useRef(null),[Y,ae]=c.useState(0);c.useEffect(()=>{if(!a){V.current&&(V.current=null,ae(It=>It+1));return}if(ee){V.current={sessionId:a,session:ee,expiresAt:Date.now()+2e3};return}const H=V.current;if(!H||H.sessionId!==a)return;const Ge=H.expiresAt-Date.now();if(Ge<=0){V.current=null,ae(It=>It+1);return}const mt=window.setTimeout(()=>{V.current?.sessionId===a&&(V.current=null),ae(It=>It+1)},Ge);return()=>{window.clearTimeout(mt)}},[a,ee]);const P=(()=>{if(ee)return ee;if(!a)return null;const H=V.current;return H&&H.sessionId===a&&H.expiresAt>Date.now()?H.session:null})(),de=st(H=>a?H.worktreeMetadata.get(a)?.path??"":""),q=st(H=>a?H.worktreeMetadata.get(a)?.branch?.trim()??null:null),Q=Pc(H=>a?H.getAttachment(a):void 0),L=c.useMemo(()=>Q?ym(Q,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Q]),ne=c.useMemo(()=>Q?Q.legacy?"legacy":Q.degraded?"degraded":Q.worktreeStatus==="pending"?"pending":Q.worktreeStatus==="missing"?"missing":Q.worktreeStatus==="invalid"?"invalid":Q.attentionReason?"attention":null:null,[Q]),W=c.useMemo(()=>jn(de||""),[de]),te=c.useMemo(()=>{const H=typeof P?.directory=="string"?P.directory:"";return jn(H||"")},[P?.directory]),Z=cc(a??"",te),me=st(H=>H.newSessionDraft?.open?jn(H.newSessionDraft.bootstrapPendingDirectory??H.newSessionDraft.directoryOverride??""):""),Ie=st(H=>H.newSessionDraft.target),fe=st(H=>H.newSessionDraft.selectedProjectId),je=st(H=>H.currentSessionDirectory),$e=Ht(H=>H.homeDirectory),Re=yr(),Fe=c.useMemo(()=>W||te||(uo(Re,me)??""),[me,Re,te,W]),Ve=st(H=>{const Ge=jn(W||te||"");if(!Ge)return null;for(const mt of H.availableWorktreesByProject.values()){const $t=Vr(mt,Ge)?.branch?.trim();if($t)return $t}return null}),ge=vm(Fe||null)||q||Ve,xe=i?Ie==="chat":Xl(te||je,$e),Se=!xe&&!C&&!!(m||ge||!i&&ne),Be=c.useMemo(()=>{if(!a)return m??"OpenChamber";const H=P?.title?.trim();return H&&H.length>0?H:"Untitled Session"},[m,P?.title,a]),Pe=Sm(),Me=st(H=>H.updateSessionTitle),Je=st(H=>H.archiveSessions),X=st(H=>H.deleteSessions),[Ee,_e]=c.useState(!1),[pe,R]=c.useState(!1),ie=c.useRef(null),[Ce,Ne]=c.useState(""),[ze,qe]=c.useState(!1),[Ue,tt]=c.useState(null),He=ps(H=>Ue&&H.entityById.get(Ue)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ze=c.useRef(null),Qe=c.useCallback(()=>{a&&(Ne(P?.title?.trim()||Be),_e(!0))},[P?.title,a,Be]),ot=c.useRef(Qe);ot.current=Qe;const pt=c.useCallback(H=>{H&&(H.focus(),H.select())},[]);c.useEffect(()=>{if(R(!1),tt(null),a&&ie.current===a){ie.current=null,ot.current();return}_e(!1),Ne("")},[a]);const at=c.useCallback(async()=>{if(!a)return;const H=Ce.trim();H&&H!==P?.title?.trim()&&await Me(a,H),_e(!1)},[P?.title,a,Ce,Me]);c.useEffect(()=>{if(!Ee)return;const H=Ge=>{const mt=Ge.target;(!mt||!Ze.current?.contains(mt))&&at()};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[Ee,at]);const xt=c.useCallback(H=>{H&&wr(H).then(Ge=>{Te[Ge.ok?"success":"error"](t(Ge.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Te.error(t("sessions.sidebar.session.copyId.error")))},[t]),le=c.useCallback(async()=>{if(!a||!Fe){Te.error(t("sessions.sidebar.session.export.nothingToExport"));return}const H=await Pe({sessionID:a,directory:Fe}).catch(()=>null);if(!H){Te.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(H.length===0){Te.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ge=km(H,P?.title??null),mt=jm(P?.title??null);await Cm(Ge,mt)||Tm(Ge,mt),Te.success(t("sessions.sidebar.session.export.success"))},[P?.title,a,Pe,Fe,t]),be=Rc(),Ae=c.useMemo(()=>Nm(be),[be]),N=c.useCallback(H=>{a&&$f({entry:H,t,session:{id:a,title:P?.title,directory:te??Fe},loadRecords:async()=>{if(!Fe)return null;try{return await Pe({sessionID:a,directory:Fe})}catch{return null}},onLoadFailed:()=>Te.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[P?.title,a,Pe,Fe,te,t]),ce=c.useCallback(H=>Ae.map(Ge=>s.jsxs(H,{onClick:()=>N(Ge),children:[s.jsx(fo,{icon:Ge.icon,iconSrc:Ge.iconSrc,className:"me-1 size-4"}),Ge.action.label]},`${Ge.guest.id}:${Ge.action.id}`)),[Ae,N]),U=d?.type==="busy"||d?.type==="retry",we=c.useCallback(()=>{if(!a||!te||U||u)return;const Ge=ps.getState().activeSessions.find(mt=>mt.id===a);Ge&&Em({kind:"quick",root:Ge,descendants:Pm(Ge,[]),sourceDirectory:te,messages:Im(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,U,u,te,t]),ke=c.useCallback(async(H,Ge)=>{const mt=[Ge,...Rm(Ge,[],H==="delete")],It=st.getState().currentSessionId===Ge?Ge:null;if(H==="delete"){const{failedIds:Ft}=await X(mt);Ft.length>0?Te.error(t("sessions.sidebar.session.delete.error")):Te.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:$t,failedIds:Bt}=await Je(mt);if(Bt.length>0){Te.error(t("sessions.sidebar.session.archive.error"));return}Te.success(t("sessions.sidebar.session.archive.success"),Dm($t,It,t))},[Je,X,t]),Xe=c.useCallback(async()=>{Ue&&(tt(null),await ke("delete",Ue))},[Ue,ke]),Oe=G(H=>H.openGuestPageId),se=sr(H=>H.guests.find(Ge=>Ge.id===Oe)),ue=G(H=>H.isScheduledTasksDialogOpen),et=G(H=>H.isArchivePageOpen),ye=G(H=>H.isIntegrationsCatalogOpen),bt=G(H=>H.isUsageStatsPageOpen),Tt=G(H=>H.isSourceBoardOpen),vt=G(H=>H.isOverviewOpen),Pt=G(H=>H.worktreesPageProjectId),Ke=G(H=>H.isolatedSpacesEnabled?H.spacesPageProjectId:null),ct=G(H=>H.runOverviewKey),Rt=Bf(ct),ht=Pt??Ke,Ct=ts(H=>{if(!ht)return null;const Ge=H.projects.find(mt=>mt.id===ht);return Ge?.label?.trim()||Ge?.path?.split("/").pop()||null}),lt=c.useMemo(()=>se?{title:se.pageTitle??se.name,subtitle:null}:ue?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:et?{title:t("sessions.archivePage.title"),subtitle:null}:ye?{title:t("integrationsCatalog.page.title"),subtitle:null}:bt?{title:t("usageStats.title"),subtitle:null}:Tt?{title:t("sourceBoard.title"),subtitle:null}:vt?{title:t("overview.title"),subtitle:null}:Pt?{title:t("sessions.worktreesPage.title",{project:Ct??""}),subtitle:null}:Ke?{title:t("spaces.page.title",{project:Ct??""}),subtitle:null}:ct?{title:Rt??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[se,et,ye,Rt,ct,ue,Tt,vt,bt,Ke,Ct,t,Pt]),Et=te||jn(je||"")||W,qt=c.useCallback(()=>{Us("desktop_open_draft_mini_chat_window",{directory:xe?"":me,projectId:xe?null:fe,...Rr()}).catch(H=>{console.warn("[header] failed to open draft mini chat window",H)})},[me,fe,xe]),dt=c.useCallback(()=>{if(i){qt();return}a&&Us("desktop_open_session_mini_chat_window",{sessionId:a,directory:te||jn(je||"")||W,...Rr()}).catch(H=>{console.warn("[header] failed to open session mini chat window",H)})},[a,qt,i,je,te,W]),ut=b&&(i||!!a),Ot=c.useCallback((H,Ge)=>{Us("desktop_open_session_mini_chat_window",{sessionId:H,directory:Ge,...Rr()}).catch(mt=>{console.warn("[header] failed to open session mini chat window",mt)})},[]),Zt=Wn,is=c.useMemo(()=>x&&T&&!j?"88px":w?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!x||F)&&!M?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[x,j,T,w,M,F]),as=(!x||F)&&!M?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",ss=e==="rtl",Xt=ss?as:is,ls=ss?is:as,ns=F&&_!==Jl(e);Ut.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",Xt)},[Xt]);const Is=n?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",Ps=n?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Ut.useEffect(()=>{if(!x||!T){v(!1);return}let H=!1;const Ge=async()=>{try{const It=await Us("desktop_is_window_fullscreen");H||v(It===!0)}catch{H||v(!1)}},mt=()=>{Ge()};return Ge(),window.addEventListener("openchamber:window-resized",mt),()=>{H=!0,window.removeEventListener("openchamber:window-resized",mt)}},[x,T]);const cs=c.useMemo(()=>!x||!T||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[x,T,A]),rs=c.useMemo(()=>x&&T&&!j?A!==null&&A<=15?"56px":"44px":"0px",[x,j,T,A]),Kt=c.useMemo(()=>{const Ge=`max(${x&&T?"2.75rem":"3rem"}, ${rs}, var(--oc-wco-titlebar-height, 0px))`,mt=x&&!F||M;if(mt&&rs==="0px")return{};const It={minHeight:Ge,height:Ge};return!ns&&(!mt||ss)&&(It.paddingInlineEnd=ls),It},[ns,x,T,ss,M,ls,rs,F]),Os=c.useRef(null),re=c.useCallback(H=>{!H||H===Os.current||(Os.current=H,document.documentElement.style.setProperty("--oc-header-height",`${H}px`))},[]),Ye=c.useCallback(()=>{typeof document>"u"||re(h.current?.getBoundingClientRect().height)},[re]);Ut.useEffect(()=>{if(typeof window>"u")return;Ye();const H=h.current;if(!H||typeof ResizeObserver>"u")return()=>{};let Ge=0;const mt=()=>{Ge||(Ge=requestAnimationFrame(()=>{Ge=0,Ye()}))},It=new ResizeObserver($t=>{const Bt=$t[$t.length-1];re(Bt?.borderBoxSize?.[0]?.blockSize??Bt?.target.getBoundingClientRect().height)});return It.observe(H),window.addEventListener("resize",mt),window.addEventListener("orientationchange",mt),()=>{Ge&&cancelAnimationFrame(Ge),It.disconnect(),window.removeEventListener("resize",mt),window.removeEventListener("orientationchange",mt)}},[re,Ye]),Ut.useEffect(()=>{Ye()},[Ye,p,cs]);const gt=c.useCallback(async H=>{const Ge=H.target;Ge.closest(".app-region-no-drag")||Ge.closest("button, a, input, select, textarea")||H.button===0&&x&&await Vu()},[x]);Dc({rename_current_session:()=>{if(!a||p)return!1;Qe()},archive_current_session:()=>{if(!a||p||ps.getState().entityById.get(a)?.time.archived)return!1;ke("archive",a)}});const wt=c.useCallback(({session:H,open:Ge,isActive:mt,select:It,closeOtherTabs:$t,components:Bt})=>{const{Item:Ft,Separator:js}=Bt,Rs=mt&&!M&&!xe&&P&&!P.parentId,Xs=mt&&!M&&P&&Za(P);return s.jsxs(s.Fragment,{children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Ft,{onClick:()=>{mt||It(),ie.current=H.id},children:[s.jsx(oe,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),mt&&k?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:k}):null]})}),s.jsx(wa,{sessionID:H.id,directory:H.directory,open:Ge,Item:Ft}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Ft,{onClick:()=>xt(H.id),children:[s.jsx(oe,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(js,{}),mt?s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Ft,{onClick:()=>{le()},children:[s.jsx(oe,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,b?s.jsxs(Ft,{onClick:()=>Ot(H.id,mt?Et:H.directory??""),children:[s.jsx(oe,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,mt?ce(Ft):null,Rs?s.jsx(ds,{hint:t(u?"sessions.sidebar.session.moveToWorktree.tooltipMoving":U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Ft,{disabled:!te||U||u,onClick:we,className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Xs?s.jsx(ds,{hint:t(U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Ft,{disabled:!te||U||u,onClick:()=>qe(!0),className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(js,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:s.jsxs(Ft,{onClick:$t,children:[s.jsx(oe,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),s.jsx(js,{}),s.jsx(lb,{session:H,Item:Ft}),s.jsx(Ha,{sessionId:H.id,Item:Ft,onArchive:()=>{ke("archive",H.id)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Ft,{className:"text-destructive focus:text-destructive",onClick:()=>tt(H.id),children:[s.jsx(oe,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[xt,P,Et,le,b,xe,U,u,M,we,Ot,ce,k,ke,te,t]),_t=()=>s.jsxs("div",{onMouseDown:gt,className:We("app-region-drag relative flex h-12 select-none items-center",ns?"pe-0":"pe-2.5",cs),style:Kt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Is,transitionDuration:`${r}ms`,transitionTimingFunction:An}}),s.jsx("div",{ref:Dd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Ps,transitionDuration:`${r}ms`,transitionTimingFunction:An}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[lt?s.jsxs(s.Fragment,{children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>G.getState().closeMainSurfaces(),children:s.jsx(oe,{name:"arrow-left",className:"size-4"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[s.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:lt.title}),lt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:lt.subtitle}):null]})]}):M||!o?s.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[Z?s.jsx(oe,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,n?null:s.jsxs(kt,{children:[s.jsx(K1,{align:"start",children:s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Zt,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(oe,{name:"history",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",children:s.jsx(Ks,{label:t("sessions.switcher.openAria"),shortcut:ms(Ts("open_session_list",S),"")})})]}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ee?s.jsxs("form",{ref:Ze,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:H=>H.stopPropagation(),onSubmit:H=>{H.preventDefault(),at()},children:[s.jsx("input",{ref:pt,value:Ce,onChange:H=>Ne(H.target.value),onKeyDown:H=>ya(H,()=>_e(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[0.875rem] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>_e(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"close",className:"size-4"})})]}):i?null:s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:Be}),Se?s.jsxs("span",{className:We("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:[m?s.jsx("span",{className:"truncate",children:m}):null,ge?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(oe,{name:"git-branch",className:We("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),s.jsx("span",{className:We("truncate",i&&"text-muted-foreground"),children:ge})]}):null,!i&&ne?s.jsxs("span",{className:We("inline-flex min-w-0 items-center gap-0.5",ne==="attention"||ne==="invalid"||ne==="missing"?"text-status-warning":"text-muted-foreground"),children:[s.jsx(oe,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:L})]}):null]}):null]}),s.jsx("div",{className:We("flex h-[1.125rem] shrink-0 items-center justify-center",Se?"self-start":"self-center"),children:a&&!i&&!Ee?s.jsxs(gn,{open:pe,onOpenChange:R,onOpenChangeComplete:H=>{!H&&ie.current&&ie.current===a&&(ie.current=null,Qe())},children:[s.jsx(xn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"h-[1.125rem] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(oe,{name:"more",className:"size-4"})})}),s.jsxs(bn,{align:"end",className:"min-w-[190px]",children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Gt,{onClick:()=>{ie.current=a},children:[s.jsx(oe,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),k?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:k}):null]})}),s.jsx(wa,{sessionID:a,directory:te,open:pe,Item:Gt}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Gt,{onClick:()=>a&&xt(a),children:[s.jsx(oe,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(mn,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Gt,{onClick:()=>{le()},children:[s.jsx(oe,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),b?s.jsxs(Gt,{onClick:()=>Ot(a,Et),children:[s.jsx(oe,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ce(Gt),!M&&!xe&&P&&!P.parentId?s.jsx(ds,{hint:t(u?"sessions.sidebar.session.moveToWorktree.tooltipMoving":U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!te||U||u,onClick:we,className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,!M&&P&&Za(P)?s.jsx(ds,{hint:t(U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!te||U||u,onClick:()=>qe(!0),className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(mn,{}),s.jsx(Ha,{sessionId:a,Item:Gt,onArchive:()=>{ke("archive",a)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Gt,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&tt(a)},children:[s.jsx(oe,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):s.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:s.jsx(Rx,{renderMenu:wt,suppressActiveTabControls:Ee,onMenuOpenChangeComplete:H=>{!H&&ie.current&&ie.current===a&&(ie.current=null,Qe())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ee?s.jsxs("form",{ref:Ze,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:H=>H.stopPropagation(),onSubmit:H=>{H.preventDefault(),at()},children:[s.jsx("input",{ref:pt,value:Ce,onChange:H=>Ne(H.target.value),onKeyDown:H=>ya(H,()=>_e(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[0.8125rem] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>_e(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"close",className:"size-4"})})]}):s.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):Be})})})}),lt||M||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!M&&!lt?s.jsxs(s.Fragment,{children:[s.jsx(wb,{buttonClassName:Wn}),s.jsx(Mb,{buttonClassName:Wn})]}):null,ut?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:dt,className:Wn,children:s.jsx(oe,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",children:s.jsx(Ks,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?ms(Ts("new_mini_chat",S),""):void 0})})]}):null,M?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":J,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:K,className:We(Wn,J&&"text-foreground"),children:s.jsx(oe,{name:"list-indefinite",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",children:t(y&&!B?$?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":y?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),s.jsx(gd,{visible:ns,position:_})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:_t()}),ze&&a&&te?s.jsx(_m,{open:!0,onOpenChange:qe,sessionId:a,sourceDirectory:te}):null,s.jsx(nr,{open:Ue!==null,onOpenChange:H=>{H||tt(null)},children:s.jsxs(rr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(or,{children:[s.jsx(ir,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),s.jsx(ar,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:He})})]}),s.jsxs(Hr,{children:[s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>tt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",size:"sm",onClick:()=>{Xe()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},Xa=280,Ya=264,Ja=500,zb=({isOpen:t,isMobile:e,children:n,className:r,topBar:o,peek:i})=>{const{t:a,direction:d}=rt(),u=G(V=>V.sidebarWidth),l=G(V=>V.setSidebarWidth),[f,m]=c.useState(!1),p=c.useRef(0),h=c.useRef(u||Xa),x=c.useRef(null),g=c.useRef(null),b=c.useRef(null),w=c.useRef(null),j=c.useRef(null),v=c.useCallback(V=>Math.min(Ja,Math.max(Ya,V)),[]),T=c.useCallback(()=>{const V=j.current;if(V?.isConnected)return V;const Y=document.querySelector("[data-titlebar-left-controls]");return j.current=Y,Y},[]),F=c.useCallback(V=>{const Y=w.current;if(!Y)return;Y.style.width=`${V}px`,Y.style.minWidth=`${V}px`,Y.style.maxWidth=`${V}px`,Y.style.setProperty("--oc-left-sidebar-width",`${V}px`);const ae=T();ae&&ae.style.setProperty("--oc-left-sidebar-width",`${V}px`)},[T]);c.useEffect(()=>{e&&f&&m(!1)},[e,f]),c.useEffect(()=>{f||(x.current=null,g.current=null,b.current?.(),b.current=null)},[f]),c.useEffect(()=>{!t&&f&&m(!1)},[t,f]),c.useEffect(()=>()=>{b.current?.(),b.current=null},[]);const _=Math.min(Ja,Math.max(Ya,u||Xa)),A=t?_:0,M=f?x.current??A:A,S=f?M:_;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${S}px`);const V=j.current;!f&&V&&V.style.removeProperty("--oc-left-sidebar-width")},[S,f]);const[k,C]=c.useState(!t);t&&k&&C(!1);const y=co(),E=c.useRef(t),B=c.useRef(t);if(c.useLayoutEffect(()=>{E.current=t,B.current!==t&&(B.current=t,_c(y),t||Mi(()=>{E.current||C(!0)}))},[t,y]),e)return null;const $=V=>{if(t){try{V.currentTarget.setPointerCapture(V.pointerId)}catch{}g.current=V.pointerId,m(!0),p.current=V.clientX,h.current=A,x.current=A,F(A),b.current?.(),b.current=Ac(),V.preventDefault()}},O=V=>{if(e||!f||g.current!==V.pointerId)return;const Y=(V.clientX-p.current)*(d==="rtl"?-1:1),ae=v(h.current+Y);x.current!==ae&&(x.current=ae,F(ae))},z=V=>{if(g.current!==V.pointerId||e)return;try{V.currentTarget.releasePointerCapture(V.pointerId)}catch{}const Y=v(x.current??A);g.current=null,x.current=null,m(!1),l(Y),b.current?.(),b.current=null},J=!t&&i?i.state:!1,K=J!==!1,ee=K&&i&&i.animationMs>0?`${J==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${An} forwards`:void 0;return s.jsxs("div",{ref:w,"data-left-sidebar":"",className:We("relative flex h-full",!K&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${M}px`,minWidth:`${M}px`,maxWidth:`${M}px`,"--oc-left-sidebar-width":`${S}px`,overflowX:K?void 0:"clip",transitionDuration:`${y}ms`,transitionTimingFunction:An},children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-0.5px_0_0_0_var(--oc-edge-strong)] rtl:shadow-[inset_0.5px_0_0_0_var(--oc-edge-strong)]","aria-hidden":"true"}),t&&s.jsx("div",{className:We("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:$,onPointerMove:O,onPointerUp:z,onPointerCancel:z,onLostPointerCapture:z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":K?J:void 0,className:We("flex h-full shrink-0 flex-col",K?"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&&!K&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${y}ms`,overflowX:"hidden",contentVisibility:k&&!K?"hidden":void 0,animation:ee,"--oc-peek-offset":d==="rtl"?"100%":"-100%"},inert:!t&&!K||void 0,onPointerEnter:K?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:K?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:K?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,s.jsx(gs,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Qt,{children:n})})]})]})},Wb=()=>{const t=Le.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{ref:Dd,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Ub=50,Vb=18,Hb=300,qb='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',_d=t=>!document.getElementById("root")?.contains(t),Kb=t=>{if((no(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Vb)return!1;const n=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=n},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(qb)).some(n=>_d(n)&&n.getClientRects().length>0)},Gb=({enabled:t,layoutAnimationMs:e})=>{const[n,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()},Hb)},[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(n!=="in")return;const x=w=>{const j=w.target;j instanceof Element&&(a.current?.contains(j)||_d(j)||f())},g=w=>{Oc(w)||w.key!=="Escape"||w.defaultPrevented||Qa(a.current)||f()},b=w=>{w.relatedTarget===null&&m()};return document.addEventListener("pointerdown",x,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",b)}},[f,m,n]),c.useEffect(()=>{if(!t||n!==!1)return;const x=()=>{d.current!==null&&clearTimeout(d.current),d.current=null},g=w=>{if(w.pointerType!=="mouse"||w.buttons!==0||!Kb(w)){x();return}d.current===null&&(d.current=setTimeout(()=>{d.current=null,r("in")},Ub))},b=w=>{w.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",b),x()}},[t,n]);const h=c.useMemo(()=>({onPointerEnter:()=>{p(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{n==="in"&&m()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?!1:g)}}),[p,m,n]);return{state:t?n:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},Cr="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",Zb=()=>{const t=Le.c(47),{t:e,locale:n,direction:r}=rt(),o=G(Xb),i=G(Yb),a=G(Jb),d=c.useRef(null),u=ms(Ts("toggle_sidebar",a)),l=Qb,f=G(ew),{usesFramelessChrome:m,side:p}=hd();let h;t[0]!==n?(h=Y=>{const ae=Y.currentTarget.getBoundingClientRect();Us("desktop_show_app_menu",{x:ae.left,y:ae.bottom,locale:n}).catch(tw)},t[0]=n,t[1]=h):h=t[1];const x=h;let g,b;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const Y=d.current;if(!Y)return;const ae=()=>{const de=Math.max(Y.getBoundingClientRect().width,Y.scrollWidth);$b(de)};if(ae(),typeof ResizeObserver>"u")return;const P=new ResizeObserver(ae);return P.observe(Y),()=>{P.disconnect()}},b=[],t[2]=g,t[3]=b):(g=t[2],b=t[3]),c.useEffect(g,b);const w="",j="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",v=i?"var(--oc-left-sidebar-width, 100%)":void 0;let T;t[4]!==v?(T={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:v},t[4]=v,t[5]=T):T=t[5];const F="flex min-w-0 items-center gap-2";let _;t[6]!==r||t[7]!==m||t[8]!==p?(_=m&&p===Jl(r)?s.jsx(gd,{visible:!0,position:p}):null,t[6]=r,t[7]=m,t[8]=p,t[9]=_):_=t[9];let A;t[10]!==x||t[11]!==e||t[12]!==m?(A=m?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:We(Cr,"shrink-0"),children:s.jsx(oe,{name:"menu-2",className:"h-4 w-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=m,t[13]=A):A=t[13];const M=kt;let S;t[14]!==e?(S=e("header.actions.openSessionsAria"),t[14]=e,t[15]=S):S=t[15];const k=i&&"text-foreground";let C;t[16]!==k?(C=We(Cr,"shrink-0",k),t[16]=k,t[17]=C):C=t[17];let y;t[18]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(oe,{name:"layout-left",className:"h-4 w-4"}),t[18]=y):y=t[18];let E;t[19]!==i||t[20]!==S||t[21]!==C||t[22]!==o?(E=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":S,"aria-pressed":i,className:C,children:y})}),t[19]=i,t[20]=S,t[21]=C,t[22]=o,t[23]=E):E=t[23];const B=jt,$=e("header.actions.openSessionsWithShortcut",{shortcut:u});let O;t[24]!==$?(O=s.jsx("p",{children:$}),t[24]=$,t[25]=O):O=t[25];let z;t[26]!==B||t[27]!==O?(z=s.jsx(B,{children:O}),t[26]=B,t[27]=O,t[28]=z):z=t[28];let J;t[29]!==M||t[30]!==E||t[31]!==z?(J=s.jsxs(M,{children:[E,z]}),t[29]=M,t[30]=E,t[31]=z,t[32]=J):J=t[32];let K;t[33]!==l||t[34]!==i||t[35]!==a||t[36]!==e||t[37]!==f?(K=f?null:i?s.jsxs("button",{type:"button",onClick:l,className:We(Cr,"-ms-1 w-auto min-w-0 ps-1 pe-1.5 font-normal"),children:[s.jsx(oe,{name:"chat-new",className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:We(Cr,"-ms-1 shrink-0"),children:s.jsx(oe,{name:"chat-new",className:"h-4 w-4"})})}),s.jsx(jt,{children:s.jsx(Ks,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:ms(Ts("new_chat",a),"")})})]}),t[33]=l,t[34]=i,t[35]=a,t[36]=e,t[37]=f,t[38]=K):K=t[38];let ee;t[39]!==J||t[40]!==K||t[41]!==_||t[42]!==A?(ee=s.jsxs("div",{ref:d,className:F,children:[_,A,J,K]}),t[39]=J,t[40]=K,t[41]=_,t[42]=A,t[43]=ee):ee=t[43];let V;return t[44]!==ee||t[45]!==T?(V=s.jsx("div",{"data-titlebar-left-controls":w,className:j,style:T,children:ee}),t[44]=ee,t[45]=T,t[46]=V):V=t[46],V};function Xb(t){return t.toggleSidebar}function Yb(t){return t.isSidebarOpen}function Jb(t){return t.shortcutOverrides}function Qb(){G.getState().closeMainSurfaces(),st.getState().openNewSessionDraft()}function ew(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 tw(t){console.warn("[titlebar] failed to open app menu",t)}function sw(t,e,n){const r=Le.c(5),[o,i]=c.useState();let a,d;return r[0]!==n||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let u=!1;return(async()=>{const[l,f]=await Promise.all([Om(t),Mm(t)]).catch(nw);if(u)return;const m=Yt(l),p=Yt(f);if(!m||!p||p===m)return;const h=n||"",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,n],r[0]=n,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 nw(){return["",""]}const rw=()=>{const t=Le.c(3),e=G(ow),n=G(iw);let r;return t[0]!==e||t[1]!==n?(r=()=>{n("integrations"),e(!0)},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function ow(t){return t.setSettingsDialogOpen}function iw(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",aw=({className:t,identity:e})=>{const{t:n}=rt(),{sourceControl:r}=Es(),o=Fm(e),i=Ii(e.provider),a=i.label,d=o?.status??null,u=hn(w=>w.setStatus),[l,f]=c.useState(!1),m=c.useCallback(async w=>{if(!(!w||l)){f(!0);try{u(e,await r.authActivate(e,w))}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?n("header.sourceControl.connectedWithLogin",{login:p,provider:a}):n("header.sourceControl.connected",{provider:a}),b=h?s.jsx("img",{src:h,alt:p?n("header.sourceControl.avatarWithLogin",{login:p}):n("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?s.jsx("div",{className:We(el,t),title:g,children:b}):s.jsxs(gn,{children:[s.jsx(xn,{asChild:!0,children:s.jsx("button",{type:"button",className:We(el,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:l,children:b})}),s.jsxs(bn,{align:"end",className:"w-64",children:[s.jsx(Ar,{className:"typography-ui-header font-semibold text-foreground",children:n("header.sourceControl.accountsTitle",{provider:a})}),s.jsx(mn,{}),x.map(w=>{const j=w.user,v=!!w.current,T=n(Lm(w.source??"oauth"));return s.jsxs(Gt,{className:"gap-2",disabled:l,onSelect:()=>{v||m(w.id)},children:[j?.avatarUrl?s.jsx("img",{src:j.avatarUrl,alt:j.username?n("header.sourceControl.avatarWithLogin",{login:j.username}):n("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-edge bg-muted",children:s.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:j?.name?.trim()||j.username||i.label}),j.username?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:j.username}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:T})]}):null]}),v?s.jsx(oe,{name:"check",className:"h-4 w-4 text-primary"}):null]},w.id)})]})]})},lw=t=>JSON.stringify($m(t)),cw=async(t,e)=>{const n=await t.projectUpstream(e);if(!n?.isFork||!n.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,n.upstream.owner,n.upstream.name);return{upstream:n.upstream,branches:r}},Ad=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function dw(t){if(!Ad(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function uw(t,e,n){const r=Le.c(18),{sourceControl:o}=Es(),i=Ii(t.provider).features.referenceSearch,[a,d]=Ut.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(fw),()=>{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]!==n||r[15]!==i||r[16]!==o?(m=[t,l,e,n,i,o],r[11]=t,r[12]=l,r[13]=e,r[14]=n,r[15]=i,r[16]=o,r[17]=m):m=r[17],Ut.useEffect(f,m),a?.key===l?a.pull:null}function fw(){}const pw=t=>{const e=Le.c(93),{directory:n,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:d}=Es(),u=Zs(),l=ts(mw),[f,m]=Ut.useState(0),[p,h]=Ut.useState(!1),x=Fi(),g=uw(r,o.number,f);let b;e[0]!==o?(b=Bm(o),e[0]=o,e[1]=b):b=e[1];const w=b;let j;e[2]!==g||e[3]!==w?(j=g?{...w,labels:g.labels,commentCount:g.commentCount}:w,e[2]=g,e[3]=w,e[4]=j):j=e[4];const v=j,[T,F]=Ut.useState(null),_=T?.number===o.number?T.sha:null,{detail:A,latest:M,refresh:S}=Mc(n,v,!0,_),k=M.status==="ready"?M.value.pull:null,C=uc(v);let y;e[5]!==i||e[6]!==S?(y=()=>{S(),m(hw),i()},e[5]=i,e[6]=S,e[7]=y):y=e[7];const E=y,B=fc(v,r,E);let $;e[8]!==r||e[9]!==i||e[10]!==v.number||e[11]!==v.sourceRepo.owner||e[12]!==v.sourceRepo.repo||e[13]!==S||e[14]!==d?($=async()=>{const pe={owner:v.sourceRepo.owner,repo:v.sourceRepo.repo,number:v.number};await d.refreshProviderReads(r,{item:pe}).catch(gw),Fc(pe),m(xw),await Promise.all([S(),i()])},e[8]=r,e[9]=i,e[10]=v.number,e[11]=v.sourceRepo.owner,e[12]=v.sourceRepo.repo,e[13]=S,e[14]=d,e[15]=$):$=e[15];const O=$;let z;e[16]!==v?(z={source:"repository",reference:v},e[16]=v,e[17]=z):z=e[17];const J=z,K=u??n;let ee;e[18]!==A||e[19]!==a?(ee=A.status==="ready"&&A.value.pull&&A.value.pull.stack===void 0&&a!==void 0?{status:"ready",value:{...A.value,pull:{...A.value.pull,stack:a}}}:A,e[18]=A,e[19]=a,e[20]=ee):ee=e[20];const V=ee,Y=V.status==="ready"?V.value.pull?.stack??null:a??null,ae=Li(),P=ts(bw),de=st(ww),q=xr(P,de,n),[Q,L]=Ut.useState(!1);let ne;e[21]===Symbol.for("react.memo_cache_sentinel")?(ne={status:"idle"},e[21]=ne):ne=e[21];const W=q?()=>L(!0):void 0,te=k?.submitRequirements,Z=M.status==="error",me=o.mergeable??null;let Ie;e[22]!==r||e[23]!==J||e[24]!==E||e[25]!==Y||e[26]!==Z||e[27]!==me||e[28]!==W||e[29]!==te?(Ie=s.jsx(_i,{item:J,project:null,context:r,onStartWorktree:vw,onChanged:E,worktreeAvailable:!1,stack:Y,onStartOnTop:W,submitRequirements:te,submitRequirementsUnreadable:Z,mergeable:me}),e[22]=r,e[23]=J,e[24]=E,e[25]=Y,e[26]=Z,e[27]=me,e[28]=W,e[29]=te,e[30]=Ie):Ie=e[30];let fe;e[31]!==o.number||e[32]!==k||e[33]!==_?(fe=k?.revisions?{revisions:k.revisions,selected:_,onSelect:pe=>F(pe?{number:o.number,sha:pe}:null)}:void 0,e[31]=o.number,e[32]=k,e[33]=_,e[34]=fe):fe=e[34];let je;e[35]!==n||e[36]!==ae?(je=pe=>{ae(pe.url,n)},e[35]=n,e[36]=ae,e[37]=je):je=e[37];let $e;e[38]===Symbol.for("react.memo_cache_sentinel")?($e=()=>h(!0),e[38]=$e):$e=e[38];let Re;e[39]!==C.attachComment||e[40]!==C.attachComments?(Re={onAttach:C.attachComment,onAttachAll:C.attachComments},e[39]=C.attachComment,e[40]=C.attachComments,e[41]=Re):Re=e[41];let Fe;e[42]!==r||e[43]!==v||e[44]!==E?(Fe=s.jsx(hc,{reference:v,context:r,onChanged:E}),e[42]=r,e[43]=v,e[44]=E,e[45]=Fe):Fe=e[45];let Ve;e[46]!==r||e[47]!==A||e[48]!==v||e[49]!==E?(Ve=s.jsx(gc,{pull:v,detail:A,context:r,onChanged:E}),e[46]=r,e[47]=A,e[48]=v,e[49]=E,e[50]=Ve):Ve=e[50];const De=k?.voteLabels;let ge;e[51]!==k?.revisions?(ge=k?.revisions?.at(-1)?.sha,e[51]=k?.revisions,e[52]=ge):ge=e[52];const xe=_===null;let Se;e[53]!==r||e[54]!==v||e[55]!==E||e[56]!==De||e[57]!==ge||e[58]!==xe?(Se=s.jsx(pc,{reference:v,context:r,onRefresh:E,voteLabels:De,latestRevision:ge,onLatestRevision:xe},v.number),e[53]=r,e[54]=v,e[55]=E,e[56]=De,e[57]=ge,e[58]=xe,e[59]=Se):Se=e[59];const Be=l??"";let Pe;e[60]!==K||e[61]!==Be?(Pe={id:Be,path:K},e[60]=K,e[61]=Be,e[62]=Pe):Pe=e[62];let Me;e[63]!==r||e[64]!==K||e[65]!==v||e[66]!==_||e[67]!==Pe?(Me=s.jsx(xc,{pull:v,project:Pe,repository:null,context:r,projectOwnsDirectory:Sw,currentDirectory:K,revision:_}),e[63]=r,e[64]=K,e[65]=v,e[66]=_,e[67]=Pe,e[68]=Me):Me=e[68];let Je;e[69]!==n||e[70]!==J||e[71]!==x||e[72]!==O||e[73]!==V||e[74]!==Ie||e[75]!==fe||e[76]!==je||e[77]!==Re||e[78]!==Fe||e[79]!==Ve||e[80]!==Se||e[81]!==Me||e[82]!==B?(Je=s.jsx($i,{item:J,directory:n,pullStatus:Bi,trackerDetail:ne,repositoryDetail:V,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:yw,now:x,footer:Ie,revisionChoice:fe,onOpenStackLayer:je,onOpenChecks:$e,onRefresh:O,commentAttachments:Re,threadActions:B,labelsControl:Fe,reviewersControl:Ve,reply:Se,pullLinks:Me}),e[69]=n,e[70]=J,e[71]=x,e[72]=O,e[73]=V,e[74]=Ie,e[75]=fe,e[76]=je,e[77]=Re,e[78]=Fe,e[79]=Ve,e[80]=Se,e[81]=Me,e[82]=B,e[83]=Je):Je=e[83];let X;e[84]!==C.attachFailedChecks||e[85]!==p||e[86]!==r||e[87]!==v?(X=s.jsx(mc,{pull:v,context:r,open:p,onOpenChange:h,onAttachFailed:C.attachFailedChecks}),e[84]=C.attachFailedChecks,e[85]=p,e[86]=r,e[87]=v,e[88]=X):X=e[88];const Ee=q?s.jsx(zm,{open:Q,onOpenChange:L,project:{id:q.id,path:qr(q.path)??q.path},initialSourceBranch:v.head,onWorktreeCreated:kw}):null;let _e;return e[89]!==Je||e[90]!==X||e[91]!==Ee?(_e=s.jsxs(s.Fragment,{children:[Je,X,Ee]}),e[89]=Je,e[90]=X,e[91]=Ee,e[92]=_e):_e=e[92],_e};function mw(t){return t.activeProjectId}function hw(t){return t+1}function gw(){}function xw(t){return t+1}function bw(t){return t.projects}function ww(t){return t.availableWorktreesByProject}function yw(){}function vw(){}function Sw(){return!0}function kw(t){st.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const jw=/^Change-Id:\s*I[0-9a-f]{40}$/,Cw=50,Tw=t=>(t.replace(/\r\n/g,`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-ZI_EafL9.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-3RimJo4B.js","assets/katex.min-Bs5OLoA1.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-C9tWdk0j.js","assets/vendor-zod--raI7LhK.js","assets/vendor-opencode-client-CeybcDBQ.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-7f7Y525Q.css","assets/vendor-base-ui-CqKCZJyd.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-CqfECoM0.js","assets/vendor-tanstack-virtual-core-BdFnkr_2.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-DRsX0PKK.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-CEhBoV5L.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeEndpointReset-DiTyBUwe.js","assets/space-apply-8YUOtYvk.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useGitCleanLine-COG7MPwc.js","assets/useBranchPullRequestRequest-CMvepZei.js","assets/parseDiffFromFile-By5H8w4y.js","assets/computeVirtualFileMetrics-DVfKKHny.js","assets/themeResolver-DXizngAV.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-saKoOWJx.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/pierreDiffTint-CVm_qZm-.js","assets/ReviewCards-BkpTYy_a.js","assets/useInlineCommentController-_L6_JHZ6.js","assets/appThemeRegistry-DYzVI9tX.js","assets/textMateThemeFromAppTheme-CVOJt2hL.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/ChangedPathLabel-CCsE-8p4.js","assets/OfficeDocumentDiff-BFr4rAHy.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/documentClient-JcxJ7vyh.js","assets/useRootScrollLock-DdknBCBa.js","assets/moveWorkspacePath-BaEfuU4S.js","assets/contextFileOpenGuard-BC79wuu1.js","assets/install-request-EHX4ORhb.js","assets/WalkthroughView-Bbwyk6rg.js","assets/ChangeRequestDiffUnavailable-CNIWdYRx.js","assets/useDiffFindSurface-Dy5ZvPrH.js","assets/useWalkthroughReview-Bi8eB9_G.js","assets/useCallableModelProviders-DpMos2Hl.js","assets/useWholeFileComment-CqHAJ2YU.js","assets/DiffView-DwaJOPUe.js","assets/SubmoduleDiffSummary-Bebhaz7n.js","assets/FilesView-Hvxe_KqA.js","assets/flexokiTheme-BMYGLHbL.js","assets/vendor-codemirror-search-CWqbGraJ.js","assets/vendor-replit-codemirror-vim-DTiXsOdM.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-CH5Ekvbl.js","assets/fileContentPoller-BmcApnk-.js","assets/JsonTreeView-zAv-pn0X.js","assets/useNextRenderData-CVFf78p9.js","assets/isFilePlainText-DOjSDWo3.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-BcDjh6yS.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/model-dyJJrKMm.js","assets/UiBlock-C11qZK5T.js","assets/date-time-DhfjtTnp.js","assets/vendor-openuidev-lang-core-DF2LaCPS.js","assets/columnWidthMemory-BA6h4J11.js","assets/scheduledTasksApi-Z7dc8sXS.js","assets/GuestSurfacePane-Ds8luSO0.js","assets/SettingsWindow-k5FSMAzV.js","assets/SettingsView-B804XZvl.js","assets/install-CSoRI5iX.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-Cl8OheHW.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SpaceRow-CBva6ofM.js","assets/AboutLogo-BhyG0ENm.js","assets/pageTitle-BT3-HFbv.js","assets/mobileHeader-DaHAqQ0c.js","assets/CommandPalette-DrsFSbmk.js","assets/HelpDialog-DtZKoPZE.js","assets/ProjectActionsDialog-B16N4lqs.js","assets/OpenCodeStatusDialog-CX3oxFSb.js","assets/RunOverview-DsffX3fI.js","assets/ScheduledTasksDialog-DgrAfpeX.js","assets/vendor-cron-parser-1X50-i0r.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-Jt6Qj8Ry.js","assets/useWorktreeArchiveActions-D1kaQEP9.js","assets/IntegrationsCatalogView-DgdYlI3Z.js","assets/UsageStatsView-CNm8WPSk.js","assets/SourceBoardView-BvGoSNer.js","assets/OverviewView-UfIFJ3mf.js","assets/WorktreesView-BGIfERNs.js","assets/SpacesView-BGevrpQp.js","assets/SpaceAccessDialog-DHNqUzKD.js","assets/spaceNetwork-XStNVwJo.js","assets/SpaceApplyDialog-DEOTeEjy.js","assets/SpaceSetupOutput-C4NhRkjl.js","assets/OnboardingScreen-Bpj6hpDe.js","assets/AboutDialog-uNKjHvzl.js","assets/MemoryDebugPanel-ylQytlyw.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as Le,j as s,R as c,r as Ut,a as Zl,h as Bu}from"./vendor-react--VO_rL_p.js";import{bB as mr,n as Yt,l as Ht,cH as zu,cI as Xl,u as G,bz as _s,aX as Jt,b0 as no,ch as fs,cJ as Ti,b2 as ro,cK as Wu,c8 as Yl,cL as yt,cM as Uu,bw as zr,m as Ni,bx as Us,by as Rr,bW as Vu,bC as Jl,cN as Ei,br as Ii,cO as Hu,cC as Ql,c3 as aa,b5 as ec,cP as qu,cQ as hr,cR as Wr,cS as tr,cT as Ku,cU as Gn,cV as Gu,cW as Jo,cX as jr,cY as Pi,cZ as oo,c_ as _n,bd as Ur,j as qs,c$ as En,d0 as Zu,d1 as ks,b as pn,d2 as gr,d3 as Xu,d4 as Qs,d5 as Yu,d6 as tc,d7 as Ju,d8 as Qu,d9 as sc,da as ef,ck as tf,c7 as sf,cc as nf,c9 as rf,bv as of,bs as xs,v as Qo,ca as af,db as lf,dc as cf,bN as ei,dd as Ri,de as df,bp as uf,be as la,cB as nc,df as ca,aZ as rc,dg as ff,dh as pf,w as oc,cb as mf,di as da,bP as Di,dj as ic,bY as hf,aY as gf,t as xf,q as bf,bA as ac,cp as ua,cq as lc,cF as wf,ci as yf,cm as fa,dk as vf,dl as Sf,bU as kf,bS as jf,dm as Cf,bZ as Tf,co as Nf,dn as Ef,dp as If,dq as Pf,dr as pa,ds as Ro,dt as ma,du as ha,dv as Rf,bE as ga,dw as Df,dx as _f,bF as xa,dy as Af,bT as Of,i as Mf,a as Ff}from"./katex.min-Bs5OLoA1.js";import{_ as Lt}from"./vendor-vite-runtime-DD1OZmLC.js";import{bv as Lf,bw as cc,aD as dc,bx as ds,r as ba,by as $f,aF as Bf,bz as wa,aG as ya,V as uc,X as fc,Z as pc,W as mc,U as _i,a0 as hc,_ as gc,Y as xc,as as zf,at as Wf,ax as Uf,ay as Vf,az as Hf,al as qf,av as Kf,G as Gf,au as Zf,N as Xf,Q as Yf,a2 as Jf,a1 as Qf,b8 as ep,bA as bc,bB as Dr,bC as wc,bD as tp,bE as yc,bF as vn,bG as va,bH as Sa,bI as Do,bJ as ka,aw as _r,b5 as sp,b6 as np,aB as rp,br as op,bs as vc,bK as ip,b7 as ap,bL as lp,bM as cp,bN as ja,bO as _o,bP as on,bQ as Sn,bR as dp,bS as Ca,bT as up,bU as fp,bV as pp,bW as mp,bX as hp,bY as gp,bZ as xp,b_ as Ta,b$ as bp,c0 as wp,c1 as yp,c2 as vp,c3 as Sp,b9 as kp,b3 as jp,bq as Cp,ba as Tp,bt as Np,c4 as Ep,bm as Ip,bn as Pp,aE as Sc,c5 as Rp,c6 as Dp,c7 as _p,c8 as Ap,c9 as Op,bp as Mp,ca as Fp,bi as Lp,cb as $p,cc as Bp,bf as zp,bc as Wp,bd as Up,be as Vp,bb as Hp,bg as qp,bu as Kp,bl as Gp,bk as Zp,bo as Xp,cd as Yp,ce as Jp}from"./runtimeEndpointReset-DiTyBUwe.js";import{gk as Na,aQ as io,Z as ts,a0 as st,cD as xr,Q as We,eQ as Qp,cE as em,I as oe,eR as tm,u as rt,la as an,Y as ps,lb as sm,ax as ms,aB as Ts,ay as Ai,lc as kc,bb as Hs,gj as jc,gi as nm,bs as rm,ld as Cc,le as om,lf as im,bh as br,ad as St,ac as kt,ae as jt,jP as Ks,cH as Tc,lg as am,lh as lm,b8 as cm,A as Te,cM as Oi,kh as Nc,li as Ec,bH as dm,lj as um,lk as fm,k1 as Ic,ll as pm,aO as Zs,fv as mm,aw as hm,bk as Cs,b6 as wr,bi as ao,jy as In,bj as lo,lm as gm,ln as co,lo as xm,lp as bm,aP as wn,lq as wm,fz as Pc,lr as ym,hX as yr,hY as uo,cy as Vr,fA as vm,ls as Sm,lt as km,lu as jm,lv as Cm,lw as Tm,cP as Rc,lx as Nm,cV as fo,ly as Em,lz as Im,lA as Pm,kk as Rm,lB as Dm,b_ as sr,fE as Dc,lC as _m,t as nr,q as rr,D as or,l as ir,F as ar,o as Hr,B as ft,lD as An,a4 as gn,a5 as xn,a6 as bn,a7 as Gt,af as mn,lE as _c,lF as Mi,n as gs,b2 as Qt,lG as Ac,lH as Am,cY as Oc,lI as Om,lJ as Mm,bR as Es,lK as Fm,cd as hn,lL as Ea,bX as Ar,lM as Lm,g4 as $m,cn as Fi,lN as Bm,lO as Mc,lP as Li,e3 as zm,dG as qr,ea as Fc,dZ as $i,d_ as Bi,lQ as Lc,ha as us,y as On,C as ti,hp as Wm,hV as Um,hA as Vm,id as Hm,lR as qm,h4 as $c,bT as Vs,K as zi,bO as Km,as as ys,bS as Bc,cf as Ia,ce as Hn,h5 as Gm,cg as Zm,cu as Wi,cp as Xm,h7 as Ao,lS as Ym,z as Jm,bt as Qm,bu as eh,bv as th,bw as sh,bx as nh,ed as Pa,bY as zc,bV as Kr,lT as rh,lU as oh,lV as ih,dW as Ln,bM as ah,bP as po,bQ as lh,bU as ch,aN as Mn,i2 as dh,bW as uh,hb as fh,co as mo,lW as Wc,lX as Uc,lY as ph,dS as mh,dO as hh,dR as gh,lZ as xh,d$ as bh,dP as Ra,l_ as wh,io as yh,l$ as vh,m0 as Sh,dQ as Da,e9 as kh,dU as jh,b3 as Ch,m1 as Th,m2 as Nh,m3 as Eh,m4 as Ui,m5 as Vi,m6 as Ih,m7 as Ph,m8 as Rh,m9 as Dh,ma as _h,kT as Hi,mb as Ah,mc as Oh,md as Mh,me as Fh,mf as qi,mg as Lh,bN as $h,mh as Bh,mi as zh,b0 as Vc,mj as Hc,br as Wh,mk as Uh,x as qc,ml as Vh,mm as Tn,ca as Hh,aM as qh,aq as Kh,mn as Gh,V as Wt,mo as Zh,mp as Xh,dp as Yh,mq as Kc,mr as Jh,ms as Or,mt as kn,jD as Qh,mu as fn,e6 as eg,mv as tg,mw as Gc,kr as Zc,fq as ho,e2 as sg,dw as ng,mx as Ki,my as rg,eS as tn,mz as Xc,bl as og,mA as ig,mB as ag,mC as lg,mD as Oo,mE as cg,mF as dg,fb as ug,fr as fg,gS as Gi,cO as pg,gP as mg,jQ as hg,jR as gg,cW as xg,mG as lr,gO as Yc,gN as Jc,jS as bg,jT as wg,gQ as yg,ff as vg,b1 as Sg,aR as kg,mH as Mo,mI as jg,mJ as Cg,mK as Qc,mL as ed,mM as Tg,mN as Ng,mO as si,mP as Js,dK as Eg,jN as Ig,mQ as _a,mR as Pg,mS as Rg,bg as cr,mT as Aa,mU as Dg,mV as _g,mW as Ag,k5 as Og,mX as Mg,k6 as Oa,k7 as Fg,dj as Lg,mY as $g,mZ as Bg,m_ as zg,bq as Wg,k as Ug,kv as Vg,cJ as Ma,k8 as Hg,k9 as qg,cN as Kg,kb as Gg,ka as Zg,m$ as Fo,n0 as Fa,l9 as td,kn as sd,fc as go,n1 as Xg,n2 as nd,eF as Yg,gp as ni,n3 as rd,j0 as xo,n4 as Jg,jr as Qg,n5 as e1,n6 as od,n7 as t1,n8 as id,fe as s1,fd as Zi,n9 as n1,na as La,nb as r1,nc as o1,fg as i1,G as ri,nd as ad,ci as ld,cj as cd,ck as dd,ne as oi,cl as ud,jZ as fd,nf as Lo,ng as a1,go as l1,ku as c1,a1 as d1,nh as u1,ni as f1,nj as pd,bc as $a,ey as p1,jU as m1,nk as h1,jX as g1,nl as x1,nm as b1,dq as Ba,nn as w1,j$ as y1,no as v1,kU as S1,fJ as k1,np as j1,fY as za,fo as C1,fK as T1,fM as N1,fL as E1,fU as I1,fT as P1,fN as R1,kV as D1,fS as _1,fO as A1,fP as O1,fQ as M1,fR as F1,a as L1,s as $1,b as B1,c as z1,l2 as W1,aj as U1,f$ as V1,g0 as H1,g1 as q1}from"./useAppFontEffects-3RimJo4B.js";import{f as md,u as hd,S as K1,W as gd,a as G1,G as Z1,b as X1,c as Y1}from"./useRootScrollLock-DdknBCBa.js";import{h as xd,i as Gr,T as bd,M as wd,D as yd,f as ii}from"./vendor-dnd-kit-core-Br1Cs7RV.js";import{r as J1,h as Q1,u as vd,S as Sd,v as ex,a as tx}from"./vendor-dnd-kit-sortable-DpfLEOLv.js";import{C as kd}from"./vendor-dnd-kit-utilities-DZ9KbT5S.js";import{S as sx,M as nx,C as rx,i as ox,j as ix,k as ax}from"./vendor-base-ui-CqKCZJyd.js";import{a as ln,O as lx,d as cx,D as dx,b as ux,u as fx,m as Wa}from"./moveWorkspacePath-BaEfuU4S.js";import{u as ai,c as bo,p as px}from"./vendor-zustand-C9tWdk0j.js";import{o as sn,s as Ns,n as wo,c as jd,f as mx,e as dr,a as li}from"./vendor-zod--raI7LhK.js";import{u as hx}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{v as Ua,t as Va}from"./contextFileOpenGuard-BC79wuu1.js";import{d as gx,m as xx}from"./vendor-tanstack-virtual-core-BdFnkr_2.js";import{r as bx}from"./install-request-EHX4ORhb.js";const Cd=t=>`${t}|chats`,wx=(t,e)=>{if(mr(e))return Cd(t);const n=Yt(e);return n?`${t}|${n}`:null},yx=(t,e,n)=>{const r=Yt(t);return!r||mr(r)?[]:n.some(o=>Yt(o)===r)?[]:e.filter(o=>!o.parentID&&!o.time?.archived&&Yt(o.directory??null)===r).sort((o,i)=>Na(i)-Na(o)).map(o=>o.id)};function vx(t){const e=Le.c(37),{directory:n,className:r}=t,{currentTheme:o}=io(),i=ts(jx),a=st(kx),d=Ht(Sx),u=zu(n);let l;e[0]!==n||e[1]!==d?(l=Xl(n,d),e[0]=n,e[1]=d,e[2]=l):l=e[2];const f=l;let m;e[3]!==n||e[4]!==f||e[5]!==i||e[6]!==u||e[7]!==a?(m=f||!n?null:xr(i,a,n,u),e[3]=n,e[4]=f,e[5]=i,e[6]=u,e[7]=a,e[8]=m):m=e[8];const p=m;if(f){let M;e[9]!==r?(M=We("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),e[9]=r,e[10]=M):M=e[10];let S;return e[11]!==M?(S=s.jsx(oe,{name:"chat-4",className:M}),e[11]=M,e[12]=S):S=e[12],S}if(!p)return null;const h=p.icon?Qp[p.icon]:null;let x;e[13]!==p.color?(x=em(p.color)??void 0,e[13]=p.color,e[14]=x):x=e[14];const g=x;let b;e[15]!==r||e[16]!==g||e[17]!==h?(b=h?s.jsx(oe,{name:h,className:We("h-3.5 w-3.5 shrink-0",r),style:g?{color:g}:void 0}):s.jsx(oe,{name:"folder",className:We("h-3.5 w-3.5 shrink-0 text-muted-foreground",r),style:g?{color:g}:void 0}),e[15]=r,e[16]=g,e[17]=h,e[18]=b):b=e[18];const w=b;if(!p.iconImage)return w;let j;e[19]!==r?(j=We("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 v;e[21]!==p.iconBackground?(v=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[21]=p.iconBackground,e[22]=v):v=e[22];let T;e[23]!==p.iconImage||e[24]!==p.id?(T={id:p.id,iconImage:p.iconImage},e[23]=p.iconImage,e[24]=p.id,e[25]=T):T=e[25];let F;e[26]!==o.colors.surface.foreground||e[27]!==o.metadata.variant?(F={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[26]=o.colors.surface.foreground,e[27]=o.metadata.variant,e[28]=F):F=e[28];let _;e[29]!==w||e[30]!==T||e[31]!==F?(_=s.jsx(tm,{project:T,options:F,className:"h-full w-full object-contain",fallback:w}),e[29]=w,e[30]=T,e[31]=F,e[32]=_):_=e[32];let A;return e[33]!==j||e[34]!==v||e[35]!==_?(A=s.jsx("span",{className:j,style:v,children:_}),e[33]=j,e[34]=v,e[35]=_,e[36]=A):A=e[36],A}function Sx(t){return t.homeDirectory}function kx(t){return t.availableWorktreesByProject}function jx(t){return t.projects}const qn=24,Cx=(t,e,n=qn)=>{const r=e.right-(t.right-n);if(r>0)return r;const o=e.left-(t.left+n);return o<0?o:0},Tx=({transform:t})=>({...t,y:0}),Nx=16,Ex=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*Nx:t.deltaY;t.currentTarget.scrollLeft+=no(t.currentTarget)?-e:e},Ix={Item:({className:t,...e})=>s.jsx(nx,{className:We(im,t),...e}),Separator:({className:t,...e})=>s.jsx(sx,{className:We(om,t),...e})},Px=t=>{const e=Le.c(127),{tab:n,tabNumber:r,isActive:o,isPreview:i,suppressControls:a,onSelect:d,onPin:u,onClose:l,renderMenu:f,closeOtherTabs:m,onMenuOpenChangeComplete:p,children:h}=t,{t:x}=rt(),g=G(Dx);let b;e[0]!==g?(b=Ai("switch_session_tab",g),e[0]=g,e[1]=b):b=e[1];const w=b;let j;e[2]!==r||e[3]!==w?(j=w&&w!==kc&&r<=9?ms(`${w}+${r}`):void 0,e[2]=r,e[3]=w,e[4]=j):j=e[4];const v=j,[T,F]=c.useState(!1);let _;e[5]!==n.id?(_={id:n.id},e[5]=n.id,e[6]=_):_=e[6];const{attributes:A,listeners:M,setNodeRef:S,transform:k,transition:C,isDragging:y}=vd(_);let E;e[7]!==x||e[8]!==n.session.title?(E=n.session.title?.trim()||x("sessions.sidebar.session.untitled"),e[7]=x,e[8]=n.session.title,e[9]=E):E=e[9];const B=E,$=n.id;let O;e[10]!==n.session?(O=Hs(n.session),e[10]=n.session,e[11]=O):O=e[11];const z=cc($,O),J=jc(n.id),K=J!==null,V=nm(n.id)&&!o&&!K,Y=K||V;let ae;e[12]!==d||e[13]!==n?(ae=()=>d(n),e[12]=d,e[13]=n,e[14]=ae):ae=e[14];let P;e[15]!==m||e[16]!==n.id?(P=()=>m(n.id),e[15]=m,e[16]=n.id,e[17]=P):P=e[17];let de,q,Q,L,ne,W,te,Z,me,Ie,fe,je,$e,Re,Fe,Ve,De,ge,xe,Se;if(e[18]!==A||e[19]!==h||e[20]!==T||e[21]!==o||e[22]!==z||e[23]!==y||e[24]!==i||e[25]!==M||e[26]!==l||e[27]!==p||e[28]!==u||e[29]!==d||e[30]!==f||e[31]!==S||e[32]!==g||e[33]!==Y||e[34]!==a||e[35]!==x||e[36]!==ae||e[37]!==P||e[38]!==n||e[39]!==v||e[40]!==B||e[41]!==k||e[42]!==C||e[43]!==J){const Ee={session:n.session,open:T,isActive:o,select:ae,closeOtherTabs:P,components:Ix};$e=S;let _e;e[64]!==k?(_e=kd.Translate.toString(k),e[64]=k,e[65]=_e):_e=e[65],e[66]!==_e||e[67]!==C?(Re={transform:_e,transition:C},e[66]=_e,e[67]=C,e[68]=Re):Re=e[68];const pe=y&&"z-10 opacity-60";e[69]!==pe?(Fe=We("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",pe),e[69]=pe,e[70]=Fe):Fe=e[70],Ve=o?"true":"false",e[71]!==o?(De=o?{"data-active-session-tab":!0}:{},e[71]=o,e[72]=De):De=e[72],ge=A,xe=M,L=br,me=T,Ie=F,e[73]!==p?(fe=Ce=>p?.(Ce),e[73]=p,e[74]=fe):fe=e[74];let R;e[75]!==h||e[76]!==o||e[77]!==z||e[78]!==i||e[79]!==l||e[80]!==u||e[81]!==d||e[82]!==g||e[83]!==Y||e[84]!==a||e[85]!==x||e[86]!==n||e[87]!==B||e[88]!==J?(R=s.jsx(St,{asChild:!0,children:s.jsx(rx,{render:Ce=>s.jsx("div",{...Ce,role:"tab","aria-selected":o,tabIndex:o?void 0:0,onClick:o?void 0:()=>d(n),onDoubleClick:i?()=>u(n.id):void 0,onKeyDown:o?void 0:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),d(n))},onAuxClick:Ne=>{Ne.button===1&&(Ne.preventDefault(),l(n.id))},className:We("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",o?"bg-interactive-selection text-interactive-selection-foreground":"cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsxs("span",{className:"relative me-1.5 inline-flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx(vx,{directory:Hs(n.session),className:We(!a&&"group-hover/session-tab:opacity-0 group-has-[:focus-visible]/session-tab:opacity-0")}),a?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":x("header.sessionTabs.closeTab"),onClick:Ne=>{Ne.stopPropagation(),l(n.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:s.jsx(oe,{name:"close",className:"size-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:x("header.sessionTabs.closeTab"),shortcut:o?ms(_s()?"mod+w":Ts("close_session_tab",g),""):void 0})})]})]}),s.jsx("div",{className:We("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!a&&"session-tab-title",i&&!a&&"italic"),children:o?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:B})})}),z?s.jsx(oe,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":x("sessions.aiRename.generating")}):Y?s.jsx(Tc,{state:J??"unread",className:"ms-1.5 shrink-0"}):null]})})})}),e[75]=h,e[76]=o,e[77]=z,e[78]=i,e[79]=l,e[80]=u,e[81]=d,e[82]=g,e[83]=Y,e[84]=a,e[85]=x,e[86]=n,e[87]=B,e[88]=J,e[89]=R):R=e[89];let ie;e[90]!==v||e[91]!==B?(ie=s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:B,shortcut:v})}),e[90]=v,e[91]=B,e[92]=ie):ie=e[92],e[93]!==R||e[94]!==ie?(je=s.jsxs(kt,{children:[R,ie]}),e[93]=R,e[94]=ie,e[95]=je):je=e[95],Q=ox,q=ix,Z="app-region-no-drag z-50",de=ax,Se="dropdown-menu-content",e[96]===Symbol.for("react.memo_cache_sentinel")?(ne={color:"var(--surface-elevated-foreground)"},W=We(rm,"min-w-[190px]"),e[96]=ne,e[97]=W):(ne=e[96],W=e[97]),te=f(Ee),e[18]=A,e[19]=h,e[20]=T,e[21]=o,e[22]=z,e[23]=y,e[24]=i,e[25]=M,e[26]=l,e[27]=p,e[28]=u,e[29]=d,e[30]=f,e[31]=S,e[32]=g,e[33]=Y,e[34]=a,e[35]=x,e[36]=ae,e[37]=P,e[38]=n,e[39]=v,e[40]=B,e[41]=k,e[42]=C,e[43]=J,e[44]=de,e[45]=q,e[46]=Q,e[47]=L,e[48]=ne,e[49]=W,e[50]=te,e[51]=Z,e[52]=me,e[53]=Ie,e[54]=fe,e[55]=je,e[56]=$e,e[57]=Re,e[58]=Fe,e[59]=Ve,e[60]=De,e[61]=ge,e[62]=xe,e[63]=Se}else de=e[44],q=e[45],Q=e[46],L=e[47],ne=e[48],W=e[49],te=e[50],Z=e[51],me=e[52],Ie=e[53],fe=e[54],je=e[55],$e=e[56],Re=e[57],Fe=e[58],Ve=e[59],De=e[60],ge=e[61],xe=e[62],Se=e[63];let Be;e[98]!==de||e[99]!==ne||e[100]!==W||e[101]!==te||e[102]!==Se?(Be=s.jsx(de,{"data-slot":Se,style:ne,className:W,children:te}),e[98]=de,e[99]=ne,e[100]=W,e[101]=te,e[102]=Se,e[103]=Be):Be=e[103];let Pe;e[104]!==q||e[105]!==Z||e[106]!==Be?(Pe=s.jsx(q,{className:Z,children:Be}),e[104]=q,e[105]=Z,e[106]=Be,e[107]=Pe):Pe=e[107];let Me;e[108]!==Q||e[109]!==Pe?(Me=s.jsx(Q,{children:Pe}),e[108]=Q,e[109]=Pe,e[110]=Me):Me=e[110];let Je;e[111]!==L||e[112]!==me||e[113]!==Ie||e[114]!==fe||e[115]!==je||e[116]!==Me?(Je=s.jsxs(L,{open:me,onOpenChange:Ie,onOpenChangeComplete:fe,children:[je,Me]}),e[111]=L,e[112]=me,e[113]=Ie,e[114]=fe,e[115]=je,e[116]=Me,e[117]=Je):Je=e[117];let X;return e[118]!==$e||e[119]!==Re||e[120]!==Fe||e[121]!==Ve||e[122]!==De||e[123]!==ge||e[124]!==xe||e[125]!==Je?(X=s.jsx("div",{ref:$e,style:Re,className:Fe,"data-active":Ve,...De,...ge,...xe,children:Je}),e[118]=$e,e[119]=Re,e[120]=Fe,e[121]=Ve,e[122]=De,e[123]=ge,e[124]=xe,e[125]=Je,e[126]=X):X=e[126],X},Rx=t=>{const e=Le.c(109),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:d,direction:u}=rt(),l=u==="rtl",f=an(Ax),m=an(Ox),p=an(Mx),h=an(Fx),x=an(Lx),g=an($x),b=st(Bx),w=st(zx),j=ps(Wx),v=G(Ux),T=an(Vx),F=ps(Hx),_=st(qx),A=st(Kx),M=st(Gx),S=st(Zx),k=st(Xx),C=st(Yx);let y;e[0]!==C?(y=U=>{const we=C??U.activeProjectId;return U.projects.find(ke=>ke.id===we)?.path??null},e[0]=C,e[1]=y):y=e[1];const E=ts(y),B=Lf(b);let $,O;e[2]!==B||e[3]!==_||e[4]!==b||e[5]!==k||e[6]!==S||e[7]!==A||e[8]!==E||e[9]!==p||e[10]!==T||e[11]!==v||e[12]!==F?($=()=>{if(!v)T(am,Jx);else{if(!F)return;const U=Jt(),we=!b&&A&&S,ke=b?_:A&&!S?k??E:null,Xe=we?Cd(U):wx(U,ke);if(!Xe)return;T(Xe,()=>yx(ke,ps.getState().activeSessions,ts.getState().projects.map(Qx)))}b&&p(b,B)},O=[B,_,b,k,S,A,E,p,T,v,F],e[2]=B,e[3]=_,e[4]=b,e[5]=k,e[6]=S,e[7]=A,e[8]=E,e[9]=p,e[10]=T,e[11]=v,e[12]=F,e[13]=$,e[14]=O):($=e[13],O=e[14]),c.useEffect($,O);let z;if(e[15]!==j){z=new Map;for(const U of j)z.set(U.id,U);e[15]=j,e[16]=z}else z=e[16];const J=z;let K;if(e[17]!==J||e[18]!==f){K=[];for(const U of f){const we=J.get(U);we&&K.push({id:U,session:we})}e[17]=J,e[18]=f,e[19]=K}else K=e[19];const ee=K;let V;e[20]!==w?(V=U=>{w(U.id,Hs(U.session))},e[20]=w,e[21]=V):V=e[21];const Y=V,ae=eb,P=!b&&A;let de;e[22]!==P||e[23]!==M?(de=U=>!P||!M?"":(U.drafts.find(ke=>ke.id===M)?.text??"").split(/\r?\n/).find(tb)?.trim()??"",e[22]=P,e[23]=M,e[24]=de):de=e[24];const q=sm(de),Q=G(sb),L=nb;let ne;e[25]!==b||e[26]!==P||e[27]!==ee?(ne=ee.some(U=>U.id===b)||P&&ee.length>0,e[25]=b,e[26]=P,e[27]=ee,e[28]=ne):ne=e[28];const W=ne;let te,Z;e[29]!==W?(te=()=>{if(W)return dc(rb,{current:document.body})},Z=[W],e[29]=W,e[30]=te,e[31]=Z):(te=e[30],Z=e[31]),c.useEffect(te,Z);let me;e[32]!==x||e[33]!==b||e[34]!==Y||e[35]!==ee?(me=U=>{if(x(U),b&&b!==U){const we=ee.find(ke=>ke.id===U);we&&Y(we)}},e[32]=x,e[33]=b,e[34]=Y,e[35]=ee,e[36]=me):me=e[36];const Ie=me;let fe;e[37]===Symbol.for("react.memo_cache_sentinel")?(fe={activationConstraint:{distance:8}},e[37]=fe):fe=e[37];let je;e[38]===Symbol.for("react.memo_cache_sentinel")?(je={activationConstraint:{delay:200,tolerance:6}},e[38]=je):je=e[38];const $e=xd(Gr(wd,fe),Gr(bd,je));let Re;e[39]!==g?(Re=U=>{const{active:we,over:ke}=U;ke&&we.id!==ke.id&&g(String(we.id),String(ke.id))},e[39]=g,e[40]=Re):Re=e[40];const Fe=Re,Ve=c.useRef(null);let De;e[41]===Symbol.for("react.memo_cache_sentinel")?(De={left:!1,right:!1},e[41]=De):De=e[41];const[ge,xe]=c.useState(De);let Se;e[42]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>{const U=Ve.current;if(!U)return;const we=U.scrollWidth-U.clientWidth,ke=no(U)?we+U.scrollLeft:U.scrollLeft,Xe=ke>2,Oe=ke<we-2;xe(se=>se.left===Xe&&se.right===Oe?se:{left:Xe,right:Oe})},e[42]=Se):Se=e[42];const Be=Se;let Pe;e[43]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>{Be();const U=Ve.current;if(!U||!globalThis.ResizeObserver)return;const we=new ResizeObserver(Be);return we.observe(U),()=>we.disconnect()},e[43]=Pe):Pe=e[43];let Me;e[44]!==ee.length?(Me=[Be,ee.length],e[44]=ee.length,e[45]=Me):Me=e[45],c.useEffect(Pe,Me);let Je;e[46]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>{const U=Ve.current,we=U?.querySelector("[data-active-session-tab]");if(!U||!we)return;const ke=Cx(U.getBoundingClientRect(),we.getBoundingClientRect());ke!==0&&(U.scrollLeft=U.scrollLeft+ke,Be())},e[46]=Je):Je=e[46];let X;e[47]!==b?(X=[b,Be],e[47]=b,e[48]=X):X=e[48],c.useEffect(Je,X);const Ee=ge.left&&ge.right?`linear-gradient(to right, transparent, black ${qn}px, black calc(100% - ${qn}px), transparent)`:ge.left?`linear-gradient(to right, transparent, black ${qn}px)`:ge.right?`linear-gradient(to right, black calc(100% - ${qn}px), transparent)`:void 0;let _e;e[49]!==ee?(_e=ee.map(ob),e[49]=ee,e[50]=_e):_e=e[50];const pe=_e;let R;e[51]!==b||e[52]!==ee?(R=!!b&&!ee.some(U=>U.id===b),e[51]=b,e[52]=ee,e[53]=R):R=e[53];const ie=R;let Ce;e[54]!==d?(Ce=d("header.sessionTabs.stripAria"),e[54]=d,e[55]=Ce):Ce=e[55];let Ne;e[56]!==Ee?(Ne=Ee?{maskImage:Ee,WebkitMaskImage:Ee}:void 0,e[56]=Ee,e[57]=Ne):Ne=e[57];let ze;e[58]===Symbol.for("react.memo_cache_sentinel")?(ze=[Tx],e[58]=ze):ze=e[58];const qe=l?J1:Q1;let Ue;e[59]!==i||e[60]!==b||e[61]!==Ie||e[62]!==Y||e[63]!==r||e[64]!==h||e[65]!==m||e[66]!==n||e[67]!==a||e[68]!==ee?(Ue=ee.map((U,we)=>s.jsx(Px,{tabNumber:we+1,tab:U,isActive:U.id===b,isPreview:U.id===m,suppressControls:U.id===b&&a,onSelect:Y,onPin:h,onClose:ae,renderMenu:n,closeOtherTabs:Ie,onMenuOpenChangeComplete:r,children:U.id===b?i:null},U.id)),e[59]=i,e[60]=b,e[61]=Ie,e[62]=Y,e[63]=r,e[64]=h,e[65]=m,e[66]=n,e[67]=a,e[68]=ee,e[69]=Ue):Ue=e[69];let tt;e[70]!==qe||e[71]!==Ue||e[72]!==pe?(tt=s.jsx(Sd,{items:pe,strategy:qe,children:Ue}),e[70]=qe,e[71]=Ue,e[72]=pe,e[73]=tt):tt=e[73];let He;e[74]!==Fe||e[75]!==$e||e[76]!==tt?(He=s.jsx(yd,{sensors:$e,collisionDetection:ii,modifiers:ze,onDragEnd:Fe,children:tt}),e[74]=Fe,e[75]=$e,e[76]=tt,e[77]=He):He=e[77];let Ze;e[78]!==q||e[79]!==P||e[80]!==d?(Ze=P?s.jsxs("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2 text-interactive-selection-foreground","data-active":"true","data-active-session-tab":!0,children:[s.jsx(oe,{name:"edit",className:"me-1.5 size-3.5 shrink-0"}),s.jsx("div",{className:"session-tab-title min-w-0 flex-1 overflow-hidden whitespace-nowrap italic",children:s.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4",children:q||d("sessions.switcher.draftTitle")})})]}):null,e[78]=q,e[79]=P,e[80]=d,e[81]=Ze):Ze=e[81];let Qe;e[82]!==i||e[83]!==ie?(Qe=ie?s.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:i})}):null,e[82]=i,e[83]=ie,e[84]=Qe):Qe=e[84];let ot;e[85]!==Ne||e[86]!==He||e[87]!==Ze||e[88]!==Qe?(ot=s.jsxs("div",{ref:Ve,onScroll:Be,onWheel:Ex,className:"session-tabs-scroll flex min-w-0 flex-initial items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ne,children:[He,Ze,Qe]}),e[85]=Ne,e[86]=He,e[87]=Ze,e[88]=Qe,e[89]=ot):ot=e[89];let pt;e[90]!==d?(pt=d("sessions.sidebar.header.actions.newSession"),e[90]=d,e[91]=pt):pt=e[91];let at;e[92]===Symbol.for("react.memo_cache_sentinel")?(at=s.jsx(oe,{name:"add",className:"size-4"}),e[92]=at):at=e[92];let xt;e[93]!==pt?(xt=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:L,"aria-label":pt,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:at})}),e[93]=pt,e[94]=xt):xt=e[94];let le;e[95]!==d?(le=d("sessions.sidebar.header.actions.newSession"),e[95]=d,e[96]=le):le=e[96];let be;e[97]!==Q?(be=ms(Ts("new_chat",Q),""),e[97]=Q,e[98]=be):be=e[98];let Ae;e[99]!==le||e[100]!==be?(Ae=s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:le,shortcut:be})}),e[99]=le,e[100]=be,e[101]=Ae):Ae=e[101];let N;e[102]!==xt||e[103]!==Ae?(N=s.jsxs(kt,{children:[xt,Ae]}),e[102]=xt,e[103]=Ae,e[104]=N):N=e[104];let ce;return e[105]!==Ce||e[106]!==ot||e[107]!==N?(ce=s.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ce,children:[ot,N]}),e[105]=Ce,e[106]=ot,e[107]=N,e[108]=ce):ce=e[108],ce};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 $x(t){return t.reorderTabs}function Bx(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 qx(t){return t.currentSessionDirectory}function Kx(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){Cc(t)}function tb(t){return t.trim()}function sb(t){return t.shortcutOverrides}function nb(){const{currentSessionId:t,newSessionDraft:e,openNewSessionDraft:n}=st.getState(),r=t?Ht.getState().currentDirectory:e.directoryOverride;n(r?{directoryOverride:r}:void 0)}function rb(){const t=st.getState().currentSessionId;t?Cc(t):lm(-1)}function ob(t){return t.id}function Ha(t){const e=Le.c(37),{sessionId:n,onArchive:r,Item:o}=t,{t:i}=rt(),a=G(ab);let d;e[0]!==n?(d=y=>y.currentSessionId===n,e[0]=n,e[1]=d):d=e[1];const u=st(d);let l;e[2]!==a?(l=ms(Ts("archive_current_session",a),""),e[2]=a,e[3]=l):l=e[3];const f=l;let m;e[4]!==n?(m=y=>!!y.entityById.get(n)?.time.archived,e[4]=n,e[5]=m):m=e[5];const p=ps(m);let h;e[6]!==n?(h=y=>{const E=y.entityById.get(n);return!E||cm(E,y.entityById)},e[6]=n,e[7]=h):h=e[7];const x=ps(h),g=st(ib);let b;e[8]!==n||e[9]!==i||e[10]!==g?(b=async()=>{await g(n)?Te.success(i("sessions.sidebar.session.restore.success")):Te.error(i("sessions.sidebar.session.restore.error"))},e[8]=n,e[9]=i,e[10]=g,e[11]=b):b=e[11];const w=b;if(p&&!x)return null;const j=p?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let v;e[12]!==i||e[13]!==j?(v=i(j),e[12]=i,e[13]=j,e[14]=v):v=e[14];let T;e[15]!==p||e[16]!==r||e[17]!==w?(T=p?()=>{w()}:r,e[15]=p,e[16]=r,e[17]=w,e[18]=T):T=e[18];const F=p?"inbox-unarchive":"inbox-archive";let _;e[19]!==F?(_=s.jsx(oe,{name:F,className:"me-1 size-4"}),e[19]=F,e[20]=_):_=e[20];const A=p?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let M;e[21]!==i||e[22]!==A?(M=i(A),e[21]=i,e[22]=A,e[23]=M):M=e[23];let S;e[24]!==f||e[25]!==p||e[26]!==u?(S=!p&&u&&f?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:f}):null,e[24]=f,e[25]=p,e[26]=u,e[27]=S):S=e[27];let k;e[28]!==o||e[29]!==_||e[30]!==M||e[31]!==S||e[32]!==T?(k=s.jsxs(o,{onClick:T,children:[_,M,S]}),e[28]=o,e[29]=_,e[30]=M,e[31]=S,e[32]=T,e[33]=k):k=e[33];let C;return e[34]!==k||e[35]!==v?(C=s.jsx(ds,{hint:v,children:k}),e[34]=k,e[35]=v,e[36]=C):C=e[36],C}function ib(t){return t.unarchiveSession}function ab(t){return t.shortcutOverrides}function lb(t){const e=Le.c(17),{session:n,Item:r}=t,{t:o}=rt();if(!G(cb)||n.parentID||!Oi(n))return null;let a;e[0]!==n||e[1]!==o?(a=async()=>{try{await Nc(n.id,Hs(n),"done"),Ec([n.id])}catch{Te.error(o("sessions.sidebar.session.work.updateFailed"))}},e[0]=n,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==o?(u=o("sessions.sidebar.session.menuHint.markDone"),e[3]=o,e[4]=u):u=e[4];let l;e[5]!==d?(l=()=>{d()},e[5]=d,e[6]=l):l=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(oe,{name:"check",className:"me-1 size-4"}),e[7]=f):f=e[7];let m;e[8]!==o?(m=o("sessions.sidebar.session.work.markDone"),e[8]=o,e[9]=m):m=e[9];let p;e[10]!==r||e[11]!==l||e[12]!==m?(p=s.jsxs(r,{onClick:l,children:[f,m]}),e[10]=r,e[11]=l,e[12]=m,e[13]=p):p=e[13];let h;return e[14]!==u||e[15]!==p?(h=s.jsx(ds,{hint:u,children:p}),e[14]=u,e[15]=p,e[16]=h):h=e[16],h}function cb(t){return t.sessionWorkEnabled}const db=t=>{const e=Ic(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},ub=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,Td=()=>{const t=Le.c(4),e=st(fb),n=st(pb)??void 0,r=dm(e??"",n,db,ub),{context:o}=um(e,n),i=o>0?o:fm;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 fb(t){return t.currentSessionId}function pb(t){return t.currentSessionDirectory}const qa=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),$s=18,ci=2,di=($s-ci)/2,Ka=2*Math.PI*di,mb=t=>{const e=Le.c(9),{percent:n,arcColor:r,className:o}=t,i=r===void 0?"currentColor":r,a=Math.min(100,Math.max(0,n));let d;e[0]!==o?(d=We("shrink-0",o),e[0]=o,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("circle",{cx:$s/2,cy:$s/2,r:di,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ci}),e[2]=u):u=e[2];let l;e[3]!==i||e[4]!==a?(l=a>0?s.jsx("circle",{cx:$s/2,cy:$s/2,r:di,fill:"none",stroke:i,strokeWidth:ci,strokeLinecap:"round",strokeDasharray:Ka,strokeDashoffset:Ka*(1-a/100),transform:`rotate(-90 ${$s/2} ${$s/2})`}):null,e[3]=i,e[4]=a,e[5]=l):l=e[5];let f;return e[6]!==d||e[7]!==l?(f=s.jsxs("svg",{viewBox:`0 0 ${$s} ${$s}`,className:d,"aria-hidden":"true",children:[u,l]}),e[6]=d,e[7]=l,e[8]=f):f=e[8],f},Nd=()=>{const t=Le.c(16),{t:e}=rt(),{sessionId:n,fill:r,limit:o}=Td(),{totalCost:i}=pm(n);if(!n||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens: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:md(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=s.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-edge pt-1 tabular-nums",children:f.map(hb)}),t[14]=f,t[15]=m):m=t[15],m};function hb(t){return s.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const gb="—",xb={safe:"var(--status-success)",warn:"var(--status-warning)",critical:"var(--status-error)"},bb=t=>{const e=Le.c(35),{buttonClassName:n}=t,{t:r}=rt(),{sessionId:o,fill:i,limit:a}=Td(),d=Zs();let u;e[0]!==d?(u=d?fs(d):"",e[0]=d,e[1]=u):u=e[1];const l=u,f=G(yb);let m;e[2]!==l?(m=y=>l!==""&&Ti(y.contextPanelByDirectory[l],y.contextSurfaceZones).has("context"),e[2]=l,e[3]=m):m=e[3];const p=G(m);if(!o||!i)return null;const h=i.state==="measured"?i.totalTokens/a*100:null,x=h===null?void 0:xb[mm(Math.round(h))];let g;e[4]!==l||e[5]!==f?(g=l?()=>f(l,"context"):void 0,e[4]=l,e[5]=f,e[6]=g):g=e[6];let b;e[7]!==r?(b=r("contextUsage.aria.label"),e[7]=r,e[8]=b):b=e[8];const w=p&&"text-foreground";let j;e[9]!==n||e[10]!==w?(j=We(n,"w-auto gap-1.5 px-1 tabular-nums",w),e[9]=n,e[10]=w,e[11]=j):j=e[11];const v=h??0;let T;e[12]!==x||e[13]!==v?(T=s.jsx(mb,{percent:v,arcColor:x,className:"size-4"}),e[12]=x,e[13]=v,e[14]=T):T=e[14];let F;e[15]!==h?(F=h===null?gb:`${Math.min(h,999).toFixed(1)}%`,e[15]=h,e[16]=F):F=e[16];let _;e[17]!==F?(_=s.jsx("span",{dir:"ltr",className:"typography-meta",children:F}),e[17]=F,e[18]=_):_=e[18];let A;e[19]!==p||e[20]!==_||e[21]!==g||e[22]!==b||e[23]!==j||e[24]!==T?(A=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:g,"aria-label":b,"aria-pressed":p,className:j,children:[T,_]})}),e[19]=p,e[20]=_,e[21]=g,e[22]=b,e[23]=j,e[24]=T,e[25]=A):A=e[25];let M;e[26]!==p||e[27]!==r?(M=p?null:s.jsx("span",{children:r("chat.workStatus.action.openContext")}),e[26]=p,e[27]=r,e[28]=M):M=e[28];let S;e[29]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Nd,{}),e[29]=S):S=e[29];let k;e[30]!==M?(k=s.jsx(jt,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[M,S]})}),e[30]=M,e[31]=k):k=e[31];let C;return e[32]!==A||e[33]!==k?(C=s.jsxs(kt,{children:[A,k]}),e[32]=A,e[33]=k,e[34]=C):C=e[34],C},wb=c.memo(bb);function yb(t){return t.openContextSurface}const Ed=c.createContext(null),Id=()=>c.useContext(Ed),vb=t=>{const e=Le.c(4),n=Id()?.observe;let r,o;e[0]!==t||e[1]!==n?(r=()=>t&&n?n():void 0,o=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=o):(r=e[2],o=e[3]),c.useEffect(r,o)},Ga=t=>{const e=Le.c(12),{run:n,showIdle:r,large:o,className:i}=t,a=r===void 0?!1:r,d=o===void 0?!1:o;if(n?.status==="stopping"||n?.status==="waiting-for-preview"){let l;e[0]!==i?(l=We("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=s.jsx(oe,{name:"loader-4",className:l}),e[2]=l,e[3]=f):f=e[3],f}if(n){const l=d?"stop-large":"stop";let f;e[4]!==i?(f=We("size-4 shrink-0 text-[var(--status-warning)]",i),e[4]=i,e[5]=f):f=e[5];let m;return e[6]!==l||e[7]!==f?(m=s.jsx(oe,{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?s.jsx(oe,{name:"play",className:We("size-4 shrink-0",i)}):null,e[9]=i,e[10]=a,e[11]=u):u=e[11],u},Sb=t=>{const e=Le.c(68),{directory:n,buttonClassName:r}=t,{t:o}=rt(),i=ln(jb),a=ln(Cb),d=ln(Tb),u=ln(Nb),l=hm(u),f=ln(Eb),m=ln(Ib),p=ln(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=_s()&&ro();let b;e[3]!==a||e[4]!==i?(b=a.find(Q=>Q.id===i)??a.find(Rb)??a[0]??lx[0],e[3]=a,e[4]=i,e[5]=b):b=e[5];const w=b;if(!g||!n||a.length===0)return null;let j;e[6]!==n?(j=async Q=>{await Wu(n,Q.id,Q.appName)||await Yl(n,Q.appName)},e[6]=n,e[7]=j):j=e[7];const v=j;let T;e[8]!==v||e[9]!==p?(T=async Q=>{await p(Q.id),await v(Q)},e[8]=v,e[9]=p,e[10]=T):T=e[10];const F=T;let _;e[11]!==n||e[12]!==o?(_=async()=>{(await wr(n)).ok&&Te.success(o("openInApp.toast.pathCopied"))},e[11]=n,e[12]=o,e[13]=_):_=e[13];const A=_;let M;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx("div",{className:"inline-flex"}),e[14]=M):M=e[14];let S;e[15]!==v||e[16]!==w?(S=()=>{v(w)},e[15]=v,e[16]=w,e[17]=S):S=e[17];let k;e[18]!==l||e[19]!==r?(k=We(r,l),e[18]=l,e[19]=r,e[20]=k):k=e[20];let C;e[21]!==w.label||e[22]!==o?(C=o("openInApp.actions.openInAria",{app:w.label}),e[21]=w.label,e[22]=o,e[23]=C):C=e[23];let y;e[24]!==w.icon?(y=s.jsx(oe,{name:w.icon,className:"size-4"}),e[24]=w.icon,e[25]=y):y=e[25];let E;e[26]!==C||e[27]!==y||e[28]!==S||e[29]!==k?(E=s.jsx(ao,{render:M,children:s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:S,className:k,"aria-label":C,children:y})})}),e[26]=C,e[27]=y,e[28]=S,e[29]=k,e[30]=E):E=e[30];let B;e[31]!==w.label||e[32]!==o?(B=o("openInApp.actions.openInAria",{app:w.label}),e[31]=w.label,e[32]=o,e[33]=B):B=e[33];let $;e[34]!==B?($=s.jsx(jt,{side:"bottom",children:B}),e[34]=B,e[35]=$):$=e[35];let O;e[36]!==E||e[37]!==$?(O=s.jsxs(kt,{children:[E,$]}),e[36]=E,e[37]=$,e[38]=O):O=e[38];let z;e[39]!==A?(z=()=>{A()},e[39]=A,e[40]=z):z=e[40];let J;e[41]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(oe,{name:"file-copy",className:"h-4 w-4"}),e[41]=J):J=e[41];let K;e[42]!==o?(K=o("openInApp.actions.copyPath"),e[42]=o,e[43]=K):K=e[43];let ee;e[44]!==K?(ee=s.jsx("span",{className:"typography-ui-label text-foreground",children:K}),e[44]=K,e[45]=ee):ee=e[45];let V;e[46]!==z||e[47]!==ee?(V=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:z,children:[J,ee]}),e[46]=z,e[47]=ee,e[48]=V):V=e[48];let Y;e[49]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(In,{}),e[49]=Y):Y=e[49];let ae;if(e[50]!==a||e[51]!==F||e[52]!==w.id){let Q;e[54]!==F||e[55]!==w.id?(Q=L=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{F(L)},children:[s.jsx(oe,{name:L.icon,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:L.label}),w.id===L.id?s.jsx(oe,{name:"check",className:"ms-auto h-4 w-4 text-primary"}):null]},L.id),e[54]=F,e[55]=w.id,e[56]=Q):Q=e[56],ae=a.map(Q),e[50]=a,e[51]=F,e[52]=w.id,e[53]=ae}else ae=e[53];let P;e[57]!==d||e[58]!==m||e[59]!==o?(P=d?s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(oe,{name:"refresh",className:"h-4 w-4"}),s.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]=P):P=e[60];let de;e[61]!==V||e[62]!==ae||e[63]!==P?(de=s.jsxs(lo,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[V,Y,ae,P]}),e[61]=V,e[62]=ae,e[63]=P,e[64]=de):de=e[64];let q;return e[65]!==O||e[66]!==de?(q=s.jsxs(br,{children:[O,de]}),e[65]=O,e[66]=de,e[67]=q):q=e[67],q},kb=c.memo(Sb);function jb(t){return t.selectedAppId}function Cb(t){return t.availableApps}function Tb(t){return t.isCacheStale}function Nb(t){return t.isScanning}function Eb(t){return t.initialize}function Ib(t){return t.loadInstalledApps}function Pb(t){return t.selectApp}function Rb(t){return t.id===cx}const Kn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Db=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const o=Kn(n??"");if(o){const i=xr(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function Pd(){const t=ts(b=>b.projects),e=ts(b=>b.activeProjectId),n=st(b=>b.availableWorktreesByProject),r=st(b=>b.currentSessionId),o=gm(r??null),i=st(b=>r?b.worktreeMetadata.get(r)?.path??"":""),a=st(b=>b.newSessionDraft?.open?Kn(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),d=st(b=>b.newSessionDraft?.open?b.newSessionDraft.target==="chat":null),u=c.useMemo(()=>Kn(i||""),[i]),l=c.useMemo(()=>Kn(o||""),[o]),f=u||l||a,m=c.useMemo(()=>Db({projects:t,worktreesByProject:n,directory:f,activeProjectId:e}),[e,f,t,n]),p=c.useMemo(()=>Kn(f||m?.path||""),[f,m?.path]),h=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),x=d??mr(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 _b=t=>{const e=Le.c(67),{buttonClassName:n}=t,{t:r}=rt(),o=Id(),i=G(Fb),[a,d]=c.useState(!1),u=G(Lb);let l;e[0]!==u?(l=ms(Ts("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;vb(!0);let x;e[5]!==h?(x=de=>h?de.getDirectoryState(h.directory)?.tabs.find(q=>q.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 b;e[7]!==m.name||e[8]!==h||e[9]!==r?(b=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]=b):b=e[10];const w=b;let j;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==h||e[15]!==r?(j=h&&g?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>i(h.directory,g),className:n,"aria-label":r("projectActions.actions.openPreview"),children:s.jsx(oe,{name:"global",className:"size-4"})})}),s.jsx(jt,{side:"bottom",children:r("projectActions.actions.openPreview")})]}):null,e[11]=n,e[12]=i,e[13]=g,e[14]=h,e[15]=r,e[16]=j):j=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx("div",{className:"inline-flex"}),e[17]=v):v=e[17];let T;e[18]!==o||e[19]!==m?(T=()=>o.toggle(m),e[18]=o,e[19]=m,e[20]=T):T=e[20];const F=o.isLoading||h?.status==="stopping",_=a&&"text-foreground";let A;e[21]!==n||e[22]!==_?(A=We(n,_),e[21]=n,e[22]=_,e[23]=A):A=e[23];let M;e[24]!==m||e[25]!==h?(M=h?s.jsx(Ga,{run:h,large:!0}):s.jsx(oe,{name:ba(m),className:"size-4"}),e[24]=m,e[25]=h,e[26]=M):M=e[26];let S;e[27]!==w||e[28]!==A||e[29]!==M||e[30]!==T||e[31]!==F?(S=s.jsx(ao,{render:v,children:s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:T,disabled:F,className:A,"aria-label":w,children:M})})}),e[27]=w,e[28]=A,e[29]=M,e[30]=T,e[31]=F,e[32]=S):S=e[32];let k;e[33]!==w?(k=s.jsx("span",{children:w}),e[33]=w,e[34]=k):k=e[34];let C;e[35]!==r?(C=r("projectActions.header.allActions"),e[35]=r,e[36]=C):C=e[36];let y;e[37]!==f||e[38]!==C?(y=s.jsx("span",{className:"typography-micro text-muted-foreground",children:s.jsx(Ks,{label:C,shortcut:f})}),e[37]=f,e[38]=C,e[39]=y):y=e[39];let E;e[40]!==k||e[41]!==y?(E=s.jsx(jt,{side:"bottom",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[k,y]})}),e[40]=k,e[41]=y,e[42]=E):E=e[42];let B;e[43]!==S||e[44]!==E?(B=s.jsxs(kt,{children:[S,E]}),e[43]=S,e[44]=E,e[45]=B):B=e[45];const $=o.openSettings;let O;e[46]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(oe,{name:"add",className:"h-4 w-4"}),e[46]=O):O=e[46];let z;e[47]!==r?(z=r("projectActions.actions.addNewAction"),e[47]=r,e[48]=z):z=e[48];let J;e[49]!==z?(J=s.jsx("span",{className:"typography-ui-label text-foreground",children:z}),e[49]=z,e[50]=J):J=e[50];let K;e[51]!==o.openSettings||e[52]!==J?(K=s.jsxs(Cs,{className:"flex items-center gap-2",onClick:$,children:[O,J]}),e[51]=o.openSettings,e[52]=J,e[53]=K):K=e[53];let ee;e[54]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(In,{}),e[54]=ee):ee=e[54];let V;e[55]!==o||e[56]!==r?(V=o.actions.map(de=>s.jsxs(Cs,{className:"flex items-center gap-2",onClick:()=>{o.select(de),o.toggle(de)},children:[s.jsx(oe,{name:ba(de),className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:de.name}),de.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:r("projectActions.menu.sharedBadge")}):null,s.jsx(Ga,{run:o.runOf(de),className:"ms-auto"})]},de.id)),e[55]=o,e[56]=r,e[57]=V):V=e[57];let Y;e[58]!==K||e[59]!==V?(Y=s.jsxs(lo,{className:"w-60 max-h-[70vh] overflow-y-auto",children:[K,ee,V]}),e[58]=K,e[59]=V,e[60]=Y):Y=e[60];let ae;e[61]!==B||e[62]!==Y?(ae=s.jsxs(br,{onOpenChange:d,children:[B,Y]}),e[61]=B,e[62]=Y,e[63]=ae):ae=e[63];let P;return e[64]!==ae||e[65]!==j?(P=s.jsxs(s.Fragment,{children:[j,ae]}),e[64]=ae,e[65]=j,e[66]=P):P=e[66],P},Ab=c.memo(_b),Ob=t=>{const e=Le.c(8),{buttonClassName:n}=t,r=Pd();if(!r)return null;let o;e[0]!==n||e[1]!==r.directory?(o=s.jsx(kb,{directory:r.directory,buttonClassName:n}),e[0]=n,e[1]=r.directory,e[2]=o):o=e[2];let i;e[3]!==n?(i=s.jsx(Ab,{buttonClassName:n}),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==o||e[6]!==i?(a=s.jsxs(s.Fragment,{children:[o,i]}),e[5]=o,e[6]=i,e[7]=a):a=e[7],a},Mb=c.memo(Ob);function Fb(t){return t.openContextPreview}function Lb(t){return t.shortcutOverrides}const $o="--oc-titlebar-controls-width",ui=new Set;let Zn=null;const Rd=t=>{Zn===null?t.style.removeProperty($o):t.style.getPropertyValue($o)!==Zn&&t.style.setProperty($o,Zn)},$b=t=>{const e=`${Math.round(t)}px`;e!==Zn&&(Zn=e,ui.forEach(Rd))},Dd=t=>{if(t)return ui.add(t),Rd(t),()=>{ui.delete(t)}},Wn="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",jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Za=t=>!t.parentId&&!t.archived&&!Ei(t.directory),Bb=()=>{Uu("ui.header.render");const{t,direction:e}=rt(),n=G(H=>H.isSidebarOpen),r=co(),o=G(H=>H.sessionTabsEnabled),i=st(H=>!!H.newSessionDraft?.open),a=st(H=>H.currentSessionId),d=xm(a??""),u=bm(a??""),l=ps(ai(c.useCallback(H=>{if(!a)return null;const Ge=[...H.activeSessions,...H.archivedSessions].find(It=>It.id===a);if(!Ge)return null;const mt=Ge;return{title:Ge.title??null,directory:mt.directory??null,created:Ge.time?.created??null,slug:mt.slug??null,parentId:Ge.parentID??null,archived:!!Ge.time?.archived}},[a]))),f=ts(ai(H=>{if(!H.activeProjectId)return null;const Ge=H.projects.find(mt=>mt.id===H.activeProjectId);return Ge?{id:Ge.id,path:Ge.path,label:Ge.label}:null})),m=c.useMemo(()=>{if(!f)return null;const H=f.label?.trim();if(H)return H;const Ge=f.path.split(/[\\/]/).filter(Boolean);return Ge[Ge.length-1]??null},[f]),{isMobile:p}=wn(),h=c.useRef(null),[x,g]=c.useState(()=>typeof window>"u"?!1:_s()),b=c.useMemo(()=>zr(),[]),w=wm(),[j,v]=c.useState(!1),T=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:F,side:_}=hd(),A=c.useMemo(()=>{if(typeof window>"u")return null;const H=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof H=="number"&&Number.isFinite(H)&&H>0)return H;if(typeof navigator>"u")return null;const Ge=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ge)return null;const mt=Number.parseInt(Ge[1],10),It=Number.parseInt(Ge[2],10);return Number.isNaN(mt)?null:mt===10?It:mt},[]);Ut.useEffect(()=>{typeof window>"u"||g(_s())},[]);const M=c.useMemo(()=>Ni(),[]),S=G(H=>H.shortcutOverrides),k=ms(Ts("rename_current_session",S),""),C=G(H=>H.workStatusPanelVisible),y=G(H=>H.workStatusPanelEnabled),E=G(H=>H.setWorkStatusPanelEnabled),B=G(H=>H.workStatusPanelFits),$=G(H=>H.workStatusOverlayOpen),O=G(H=>H.setWorkStatusOverlayOpen),J=y&&B||$,K=c.useCallback(()=>{if(y&&!B){O(!$);return}E(!y)},[O,E,$,y,B]),ee=a?l??null:null,V=c.useRef(null),[Y,ae]=c.useState(0);c.useEffect(()=>{if(!a){V.current&&(V.current=null,ae(It=>It+1));return}if(ee){V.current={sessionId:a,session:ee,expiresAt:Date.now()+2e3};return}const H=V.current;if(!H||H.sessionId!==a)return;const Ge=H.expiresAt-Date.now();if(Ge<=0){V.current=null,ae(It=>It+1);return}const mt=window.setTimeout(()=>{V.current?.sessionId===a&&(V.current=null),ae(It=>It+1)},Ge);return()=>{window.clearTimeout(mt)}},[a,ee]);const P=(()=>{if(ee)return ee;if(!a)return null;const H=V.current;return H&&H.sessionId===a&&H.expiresAt>Date.now()?H.session:null})(),de=st(H=>a?H.worktreeMetadata.get(a)?.path??"":""),q=st(H=>a?H.worktreeMetadata.get(a)?.branch?.trim()??null:null),Q=Pc(H=>a?H.getAttachment(a):void 0),L=c.useMemo(()=>Q?ym(Q,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Q]),ne=c.useMemo(()=>Q?Q.legacy?"legacy":Q.degraded?"degraded":Q.worktreeStatus==="pending"?"pending":Q.worktreeStatus==="missing"?"missing":Q.worktreeStatus==="invalid"?"invalid":Q.attentionReason?"attention":null:null,[Q]),W=c.useMemo(()=>jn(de||""),[de]),te=c.useMemo(()=>{const H=typeof P?.directory=="string"?P.directory:"";return jn(H||"")},[P?.directory]),Z=cc(a??"",te),me=st(H=>H.newSessionDraft?.open?jn(H.newSessionDraft.bootstrapPendingDirectory??H.newSessionDraft.directoryOverride??""):""),Ie=st(H=>H.newSessionDraft.target),fe=st(H=>H.newSessionDraft.selectedProjectId),je=st(H=>H.currentSessionDirectory),$e=Ht(H=>H.homeDirectory),Re=yr(),Fe=c.useMemo(()=>W||te||(uo(Re,me)??""),[me,Re,te,W]),Ve=st(H=>{const Ge=jn(W||te||"");if(!Ge)return null;for(const mt of H.availableWorktreesByProject.values()){const $t=Vr(mt,Ge)?.branch?.trim();if($t)return $t}return null}),ge=vm(Fe||null)||q||Ve,xe=i?Ie==="chat":Xl(te||je,$e),Se=!xe&&!C&&!!(m||ge||!i&&ne),Be=c.useMemo(()=>{if(!a)return m??"OpenChamber";const H=P?.title?.trim();return H&&H.length>0?H:"Untitled Session"},[m,P?.title,a]),Pe=Sm(),Me=st(H=>H.updateSessionTitle),Je=st(H=>H.archiveSessions),X=st(H=>H.deleteSessions),[Ee,_e]=c.useState(!1),[pe,R]=c.useState(!1),ie=c.useRef(null),[Ce,Ne]=c.useState(""),[ze,qe]=c.useState(!1),[Ue,tt]=c.useState(null),He=ps(H=>Ue&&H.entityById.get(Ue)?.title?.trim()||null)??t("sessions.sidebar.session.untitled"),Ze=c.useRef(null),Qe=c.useCallback(()=>{a&&(Ne(P?.title?.trim()||Be),_e(!0))},[P?.title,a,Be]),ot=c.useRef(Qe);ot.current=Qe;const pt=c.useCallback(H=>{H&&(H.focus(),H.select())},[]);c.useEffect(()=>{if(R(!1),tt(null),a&&ie.current===a){ie.current=null,ot.current();return}_e(!1),Ne("")},[a]);const at=c.useCallback(async()=>{if(!a)return;const H=Ce.trim();H&&H!==P?.title?.trim()&&await Me(a,H),_e(!1)},[P?.title,a,Ce,Me]);c.useEffect(()=>{if(!Ee)return;const H=Ge=>{const mt=Ge.target;(!mt||!Ze.current?.contains(mt))&&at()};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[Ee,at]);const xt=c.useCallback(H=>{H&&wr(H).then(Ge=>{Te[Ge.ok?"success":"error"](t(Ge.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Te.error(t("sessions.sidebar.session.copyId.error")))},[t]),le=c.useCallback(async()=>{if(!a||!Fe){Te.error(t("sessions.sidebar.session.export.nothingToExport"));return}const H=await Pe({sessionID:a,directory:Fe}).catch(()=>null);if(!H){Te.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(H.length===0){Te.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ge=km(H,P?.title??null),mt=jm(P?.title??null);await Cm(Ge,mt)||Tm(Ge,mt),Te.success(t("sessions.sidebar.session.export.success"))},[P?.title,a,Pe,Fe,t]),be=Rc(),Ae=c.useMemo(()=>Nm(be),[be]),N=c.useCallback(H=>{a&&$f({entry:H,t,session:{id:a,title:P?.title,directory:te??Fe},loadRecords:async()=>{if(!Fe)return null;try{return await Pe({sessionID:a,directory:Fe})}catch{return null}},onLoadFailed:()=>Te.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[P?.title,a,Pe,Fe,te,t]),ce=c.useCallback(H=>Ae.map(Ge=>s.jsxs(H,{onClick:()=>N(Ge),children:[s.jsx(fo,{icon:Ge.icon,iconSrc:Ge.iconSrc,className:"me-1 size-4"}),Ge.action.label]},`${Ge.guest.id}:${Ge.action.id}`)),[Ae,N]),U=d?.type==="busy"||d?.type==="retry",we=c.useCallback(()=>{if(!a||!te||U||u)return;const Ge=ps.getState().activeSessions.find(mt=>mt.id===a);Ge&&Em({kind:"quick",root:Ge,descendants:Pm(Ge,[]),sourceDirectory:te,messages:Im(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,U,u,te,t]),ke=c.useCallback(async(H,Ge)=>{const mt=[Ge,...Rm(Ge,[],H==="delete")],It=st.getState().currentSessionId===Ge?Ge:null;if(H==="delete"){const{failedIds:Ft}=await X(mt);Ft.length>0?Te.error(t("sessions.sidebar.session.delete.error")):Te.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:$t,failedIds:Bt}=await Je(mt);if(Bt.length>0){Te.error(t("sessions.sidebar.session.archive.error"));return}Te.success(t("sessions.sidebar.session.archive.success"),Dm($t,It,t))},[Je,X,t]),Xe=c.useCallback(async()=>{Ue&&(tt(null),await ke("delete",Ue))},[Ue,ke]),Oe=G(H=>H.openGuestPageId),se=sr(H=>H.guests.find(Ge=>Ge.id===Oe)),ue=G(H=>H.isScheduledTasksDialogOpen),et=G(H=>H.isArchivePageOpen),ye=G(H=>H.isIntegrationsCatalogOpen),bt=G(H=>H.isUsageStatsPageOpen),Tt=G(H=>H.isSourceBoardOpen),vt=G(H=>H.isOverviewOpen),Pt=G(H=>H.worktreesPageProjectId),Ke=G(H=>H.isolatedSpacesEnabled?H.spacesPageProjectId:null),ct=G(H=>H.runOverviewKey),Rt=Bf(ct),ht=Pt??Ke,Ct=ts(H=>{if(!ht)return null;const Ge=H.projects.find(mt=>mt.id===ht);return Ge?.label?.trim()||Ge?.path?.split("/").pop()||null}),lt=c.useMemo(()=>se?{title:se.pageTitle??se.name,subtitle:null}:ue?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:et?{title:t("sessions.archivePage.title"),subtitle:null}:ye?{title:t("integrationsCatalog.page.title"),subtitle:null}:bt?{title:t("usageStats.title"),subtitle:null}:Tt?{title:t("sourceBoard.title"),subtitle:null}:vt?{title:t("overview.title"),subtitle:null}:Pt?{title:t("sessions.worktreesPage.title",{project:Ct??""}),subtitle:null}:Ke?{title:t("spaces.page.title",{project:Ct??""}),subtitle:null}:ct?{title:Rt??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[se,et,ye,Rt,ct,ue,Tt,vt,bt,Ke,Ct,t,Pt]),Et=te||jn(je||"")||W,qt=c.useCallback(()=>{Us("desktop_open_draft_mini_chat_window",{directory:xe?"":me,projectId:xe?null:fe,...Rr()}).catch(H=>{console.warn("[header] failed to open draft mini chat window",H)})},[me,fe,xe]),dt=c.useCallback(()=>{if(i){qt();return}a&&Us("desktop_open_session_mini_chat_window",{sessionId:a,directory:te||jn(je||"")||W,...Rr()}).catch(H=>{console.warn("[header] failed to open session mini chat window",H)})},[a,qt,i,je,te,W]),ut=b&&(i||!!a),Ot=c.useCallback((H,Ge)=>{Us("desktop_open_session_mini_chat_window",{sessionId:H,directory:Ge,...Rr()}).catch(mt=>{console.warn("[header] failed to open session mini chat window",mt)})},[]),Zt=Wn,is=c.useMemo(()=>x&&T&&!j?"88px":w?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!x||F)&&!M?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[x,j,T,w,M,F]),as=(!x||F)&&!M?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",ss=e==="rtl",Xt=ss?as:is,ls=ss?is:as,ns=F&&_!==Jl(e);Ut.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",Xt)},[Xt]);const Is=n?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",Ps=n?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Ut.useEffect(()=>{if(!x||!T){v(!1);return}let H=!1;const Ge=async()=>{try{const It=await Us("desktop_is_window_fullscreen");H||v(It===!0)}catch{H||v(!1)}},mt=()=>{Ge()};return Ge(),window.addEventListener("openchamber:window-resized",mt),()=>{H=!0,window.removeEventListener("openchamber:window-resized",mt)}},[x,T]);const cs=c.useMemo(()=>!x||!T||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[x,T,A]),rs=c.useMemo(()=>x&&T&&!j?A!==null&&A<=15?"56px":"44px":"0px",[x,j,T,A]),Kt=c.useMemo(()=>{const Ge=`max(${x&&T?"2.75rem":"3rem"}, ${rs}, var(--oc-wco-titlebar-height, 0px))`,mt=x&&!F||M;if(mt&&rs==="0px")return{};const It={minHeight:Ge,height:Ge};return!ns&&(!mt||ss)&&(It.paddingInlineEnd=ls),It},[ns,x,T,ss,M,ls,rs,F]),Os=c.useRef(null),re=c.useCallback(H=>{!H||H===Os.current||(Os.current=H,document.documentElement.style.setProperty("--oc-header-height",`${H}px`))},[]),Ye=c.useCallback(()=>{typeof document>"u"||re(h.current?.getBoundingClientRect().height)},[re]);Ut.useEffect(()=>{if(typeof window>"u")return;Ye();const H=h.current;if(!H||typeof ResizeObserver>"u")return()=>{};let Ge=0;const mt=()=>{Ge||(Ge=requestAnimationFrame(()=>{Ge=0,Ye()}))},It=new ResizeObserver($t=>{const Bt=$t[$t.length-1];re(Bt?.borderBoxSize?.[0]?.blockSize??Bt?.target.getBoundingClientRect().height)});return It.observe(H),window.addEventListener("resize",mt),window.addEventListener("orientationchange",mt),()=>{Ge&&cancelAnimationFrame(Ge),It.disconnect(),window.removeEventListener("resize",mt),window.removeEventListener("orientationchange",mt)}},[re,Ye]),Ut.useEffect(()=>{Ye()},[Ye,p,cs]);const gt=c.useCallback(async H=>{const Ge=H.target;Ge.closest(".app-region-no-drag")||Ge.closest("button, a, input, select, textarea")||H.button===0&&x&&await Vu()},[x]);Dc({rename_current_session:()=>{if(!a||p)return!1;Qe()},archive_current_session:()=>{if(!a||p||ps.getState().entityById.get(a)?.time.archived)return!1;ke("archive",a)}});const wt=c.useCallback(({session:H,open:Ge,isActive:mt,select:It,closeOtherTabs:$t,components:Bt})=>{const{Item:Ft,Separator:js}=Bt,Rs=mt&&!M&&!xe&&P&&!P.parentId,Xs=mt&&!M&&P&&Za(P);return s.jsxs(s.Fragment,{children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Ft,{onClick:()=>{mt||It(),ie.current=H.id},children:[s.jsx(oe,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),mt&&k?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:k}):null]})}),s.jsx(wa,{sessionID:H.id,directory:H.directory,open:Ge,Item:Ft}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Ft,{onClick:()=>xt(H.id),children:[s.jsx(oe,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(js,{}),mt?s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Ft,{onClick:()=>{le()},children:[s.jsx(oe,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,b?s.jsxs(Ft,{onClick:()=>Ot(H.id,mt?Et:H.directory??""),children:[s.jsx(oe,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,mt?ce(Ft):null,Rs?s.jsx(ds,{hint:t(u?"sessions.sidebar.session.moveToWorktree.tooltipMoving":U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Ft,{disabled:!te||U||u,onClick:we,className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Xs?s.jsx(ds,{hint:t(U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Ft,{disabled:!te||U||u,onClick:()=>qe(!0),className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(js,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:s.jsxs(Ft,{onClick:$t,children:[s.jsx(oe,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),s.jsx(js,{}),s.jsx(lb,{session:H,Item:Ft}),s.jsx(Ha,{sessionId:H.id,Item:Ft,onArchive:()=>{ke("archive",H.id)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Ft,{className:"text-destructive focus:text-destructive",onClick:()=>tt(H.id),children:[s.jsx(oe,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[xt,P,Et,le,b,xe,U,u,M,we,Ot,ce,k,ke,te,t]),_t=()=>s.jsxs("div",{onMouseDown:gt,className:We("app-region-drag relative flex h-12 select-none items-center",ns?"pe-0":"pe-2.5",cs),style:Kt,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Is,transitionDuration:`${r}ms`,transitionTimingFunction:An}}),s.jsx("div",{ref:Dd,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:Ps,transitionDuration:`${r}ms`,transitionTimingFunction:An}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[lt?s.jsxs(s.Fragment,{children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>G.getState().closeMainSurfaces(),children:s.jsx(oe,{name:"arrow-left",className:"size-4"})})}),s.jsx(jt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[s.jsx("span",{className:"truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:lt.title}),lt.subtitle?s.jsx("span",{className:"truncate typography-micro text-[0.65625rem] font-normal leading-tight text-muted-foreground max-w-full",children:lt.subtitle}):null]})]}):M||!o?s.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[Z?s.jsx(oe,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,n?null:s.jsxs(kt,{children:[s.jsx(K1,{align:"start",children:s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Zt,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(oe,{name:"history",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",children:s.jsx(Ks,{label:t("sessions.switcher.openAria"),shortcut:ms(Ts("open_session_list",S),"")})})]}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ee?s.jsxs("form",{ref:Ze,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:H=>H.stopPropagation(),onSubmit:H=>{H.preventDefault(),at()},children:[s.jsx("input",{ref:pt,value:Ce,onChange:H=>Ne(H.target.value),onKeyDown:H=>ya(H,()=>_e(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[0.875rem] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>_e(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"close",className:"size-4"})})]}):i?null:s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[0.875rem] font-normal leading-tight text-foreground max-w-full",children:Be}),Se?s.jsxs("span",{className:We("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:[m?s.jsx("span",{className:"truncate",children:m}):null,ge?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(oe,{name:"git-branch",className:We("flex-shrink-0 text-muted-foreground",i?"h-3.5 w-3.5":"h-3 w-3")}),s.jsx("span",{className:We("truncate",i&&"text-muted-foreground"),children:ge})]}):null,!i&&ne?s.jsxs("span",{className:We("inline-flex min-w-0 items-center gap-0.5",ne==="attention"||ne==="invalid"||ne==="missing"?"text-status-warning":"text-muted-foreground"),children:[s.jsx(oe,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:L})]}):null]}):null]}),s.jsx("div",{className:We("flex h-[1.125rem] shrink-0 items-center justify-center",Se?"self-start":"self-center"),children:a&&!i&&!Ee?s.jsxs(gn,{open:pe,onOpenChange:R,onOpenChangeComplete:H=>{!H&&ie.current&&ie.current===a&&(ie.current=null,Qe())},children:[s.jsx(xn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"h-[1.125rem] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(oe,{name:"more",className:"size-4"})})}),s.jsxs(bn,{align:"end",className:"min-w-[190px]",children:[s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.rename"),children:s.jsxs(Gt,{onClick:()=>{ie.current=a},children:[s.jsx(oe,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename"),k?s.jsx("span",{className:"ms-auto ps-3 typography-meta text-muted-foreground",children:k}):null]})}),s.jsx(wa,{sessionID:a,directory:te,open:pe,Item:Gt}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:s.jsxs(Gt,{onClick:()=>a&&xt(a),children:[s.jsx(oe,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),s.jsx(mn,{}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:s.jsxs(Gt,{onClick:()=>{le()},children:[s.jsx(oe,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),b?s.jsxs(Gt,{onClick:()=>Ot(a,Et),children:[s.jsx(oe,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,ce(Gt),!M&&!xe&&P&&!P.parentId?s.jsx(ds,{hint:t(u?"sessions.sidebar.session.moveToWorktree.tooltipMoving":U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!te||U||u,onClick:we,className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,!M&&P&&Za(P)?s.jsx(ds,{hint:t(U?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveSession.hint"),children:s.jsx("span",{className:"block",children:s.jsxs(Gt,{disabled:!te||U||u,onClick:()=>qe(!0),className:"w-full",children:[s.jsx(oe,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveSession.menu")]})})}):null,s.jsx(mn,{}),s.jsx(Ha,{sessionId:a,Item:Gt,onArchive:()=>{ke("archive",a)}}),s.jsx(ds,{hint:t("sessions.sidebar.session.menuHint.delete"),children:s.jsxs(Gt,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&tt(a)},children:[s.jsx(oe,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):s.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:s.jsx(Rx,{renderMenu:wt,suppressActiveTabControls:Ee,onMenuOpenChangeComplete:H=>{!H&&ie.current&&ie.current===a&&(ie.current=null,Qe())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ee?s.jsxs("form",{ref:Ze,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:H=>H.stopPropagation(),onSubmit:H=>{H.preventDefault(),at()},children:[s.jsx("input",{ref:pt,value:Ce,onChange:H=>Ne(H.target.value),onKeyDown:H=>ya(H,()=>_e(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[0.8125rem] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>_e(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(oe,{name:"close",className:"size-4"})})]}):s.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[0.8125rem] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):Be})})})}),lt||M||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!M&&!lt?s.jsxs(s.Fragment,{children:[s.jsx(wb,{buttonClassName:Wn}),s.jsx(Mb,{buttonClassName:Wn})]}):null,ut?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:dt,className:Wn,children:s.jsx(oe,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",children:s.jsx(Ks,{label:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),shortcut:i?ms(Ts("new_mini_chat",S),""):void 0})})]}):null,M?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":J,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:K,className:We(Wn,J&&"text-foreground"),children:s.jsx(oe,{name:"list-indefinite",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",children:t(y&&!B?$?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":y?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),s.jsx(gd,{visible:ns,position:_})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:_t()}),ze&&a&&te?s.jsx(_m,{open:!0,onOpenChange:qe,sessionId:a,sourceDirectory:te}):null,s.jsx(nr,{open:Ue!==null,onOpenChange:H=>{H||tt(null)},children:s.jsxs(rr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(or,{children:[s.jsx(ir,{children:t("sessions.sidebar.dialogs.deleteSession.title")}),s.jsx(ar,{children:t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:He})})]}),s.jsxs(Hr,{children:[s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>tt(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",size:"sm",onClick:()=>{Xe()},children:t("sessions.sidebar.bulkActions.delete")})]})]})})]})},Xa=280,Ya=264,Ja=500,zb=({isOpen:t,isMobile:e,children:n,className:r,topBar:o,peek:i})=>{const{t:a,direction:d}=rt(),u=G(V=>V.sidebarWidth),l=G(V=>V.setSidebarWidth),[f,m]=c.useState(!1),p=c.useRef(0),h=c.useRef(u||Xa),x=c.useRef(null),g=c.useRef(null),b=c.useRef(null),w=c.useRef(null),j=c.useRef(null),v=c.useCallback(V=>Math.min(Ja,Math.max(Ya,V)),[]),T=c.useCallback(()=>{const V=j.current;if(V?.isConnected)return V;const Y=document.querySelector("[data-titlebar-left-controls]");return j.current=Y,Y},[]),F=c.useCallback(V=>{const Y=w.current;if(!Y)return;Y.style.width=`${V}px`,Y.style.minWidth=`${V}px`,Y.style.maxWidth=`${V}px`,Y.style.setProperty("--oc-left-sidebar-width",`${V}px`);const ae=T();ae&&ae.style.setProperty("--oc-left-sidebar-width",`${V}px`)},[T]);c.useEffect(()=>{e&&f&&m(!1)},[e,f]),c.useEffect(()=>{f||(x.current=null,g.current=null,b.current?.(),b.current=null)},[f]),c.useEffect(()=>{!t&&f&&m(!1)},[t,f]),c.useEffect(()=>()=>{b.current?.(),b.current=null},[]);const _=Math.min(Ja,Math.max(Ya,u||Xa)),A=t?_:0,M=f?x.current??A:A,S=f?M:_;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${S}px`);const V=j.current;!f&&V&&V.style.removeProperty("--oc-left-sidebar-width")},[S,f]);const[k,C]=c.useState(!t);t&&k&&C(!1);const y=co(),E=c.useRef(t),B=c.useRef(t);if(c.useLayoutEffect(()=>{E.current=t,B.current!==t&&(B.current=t,_c(y),t||Mi(()=>{E.current||C(!0)}))},[t,y]),e)return null;const $=V=>{if(t){try{V.currentTarget.setPointerCapture(V.pointerId)}catch{}g.current=V.pointerId,m(!0),p.current=V.clientX,h.current=A,x.current=A,F(A),b.current?.(),b.current=Ac(),V.preventDefault()}},O=V=>{if(e||!f||g.current!==V.pointerId)return;const Y=(V.clientX-p.current)*(d==="rtl"?-1:1),ae=v(h.current+Y);x.current!==ae&&(x.current=ae,F(ae))},z=V=>{if(g.current!==V.pointerId||e)return;try{V.currentTarget.releasePointerCapture(V.pointerId)}catch{}const Y=v(x.current??A);g.current=null,x.current=null,m(!1),l(Y),b.current?.(),b.current=null},J=!t&&i?i.state:!1,K=J!==!1,ee=K&&i&&i.animationMs>0?`${J==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${An} forwards`:void 0;return s.jsxs("div",{ref:w,"data-left-sidebar":"",className:We("relative flex h-full",!K&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",r),style:{width:`${M}px`,minWidth:`${M}px`,maxWidth:`${M}px`,"--oc-left-sidebar-width":`${S}px`,overflowX:K?void 0:"clip",transitionDuration:`${y}ms`,transitionTimingFunction:An},children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-0.5px_0_0_0_var(--oc-edge-strong)] rtl:shadow-[inset_0.5px_0_0_0_var(--oc-edge-strong)]","aria-hidden":"true"}),t&&s.jsx("div",{className:We("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:$,onPointerMove:O,onPointerUp:z,onPointerCancel:z,onLostPointerCapture:z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":K?J:void 0,className:We("flex h-full shrink-0 flex-col",K?"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&&!K&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${y}ms`,overflowX:"hidden",contentVisibility:k&&!K?"hidden":void 0,animation:ee,"--oc-peek-offset":d==="rtl"?"100%":"-100%"},inert:!t&&!K||void 0,onPointerEnter:K?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:K?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:K?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,s.jsx(gs,{outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(Qt,{children:n})})]})]})},Wb=()=>{const t=Le.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{ref:Dd,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Ub=50,Vb=18,Hb=300,qb='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',_d=t=>!document.getElementById("root")?.contains(t),Kb=t=>{if((no(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Vb)return!1;const n=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=n},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(qb)).some(n=>_d(n)&&n.getClientRects().length>0)},Gb=({enabled:t,layoutAnimationMs:e})=>{const[n,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()},Hb)},[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(n!=="in")return;const x=w=>{const j=w.target;j instanceof Element&&(a.current?.contains(j)||_d(j)||f())},g=w=>{Oc(w)||w.key!=="Escape"||w.defaultPrevented||Qa(a.current)||f()},b=w=>{w.relatedTarget===null&&m()};return document.addEventListener("pointerdown",x,!0),document.addEventListener("keydown",g),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("keydown",g),document.removeEventListener("pointerout",b)}},[f,m,n]),c.useEffect(()=>{if(!t||n!==!1)return;const x=()=>{d.current!==null&&clearTimeout(d.current),d.current=null},g=w=>{if(w.pointerType!=="mouse"||w.buttons!==0||!Kb(w)){x();return}d.current===null&&(d.current=setTimeout(()=>{d.current=null,r("in")},Ub))},b=w=>{w.relatedTarget===null&&x()};return document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerout",b),()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerout",b),x()}},[t,n]);const h=c.useMemo(()=>({onPointerEnter:()=>{p(),r(x=>x==="out"?"in":x)},onPointerLeave:()=>{n==="in"&&m()},onAnimationEnd:x=>{x.target===x.currentTarget&&r(g=>g==="out"?!1:g)}}),[p,m,n]);return{state:t?n:!1,animationMs:o,overlayRef:a,overlayHandlers:h}},Cr="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",Zb=()=>{const t=Le.c(47),{t:e,locale:n,direction:r}=rt(),o=G(Xb),i=G(Yb),a=G(Jb),d=c.useRef(null),u=ms(Ts("toggle_sidebar",a)),l=Qb,f=G(ew),{usesFramelessChrome:m,side:p}=hd();let h;t[0]!==n?(h=Y=>{const ae=Y.currentTarget.getBoundingClientRect();Us("desktop_show_app_menu",{x:ae.left,y:ae.bottom,locale:n}).catch(tw)},t[0]=n,t[1]=h):h=t[1];const x=h;let g,b;t[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{if(typeof document>"u")return;const Y=d.current;if(!Y)return;const ae=()=>{const de=Math.max(Y.getBoundingClientRect().width,Y.scrollWidth);$b(de)};if(ae(),typeof ResizeObserver>"u")return;const P=new ResizeObserver(ae);return P.observe(Y),()=>{P.disconnect()}},b=[],t[2]=g,t[3]=b):(g=t[2],b=t[3]),c.useEffect(g,b);const w="",j="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",v=i?"var(--oc-left-sidebar-width, 100%)":void 0;let T;t[4]!==v?(T={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:v},t[4]=v,t[5]=T):T=t[5];const F="flex min-w-0 items-center gap-2";let _;t[6]!==r||t[7]!==m||t[8]!==p?(_=m&&p===Jl(r)?s.jsx(gd,{visible:!0,position:p}):null,t[6]=r,t[7]=m,t[8]=p,t[9]=_):_=t[9];let A;t[10]!==x||t[11]!==e||t[12]!==m?(A=m?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:x,"aria-label":e("header.actions.openAppMenuAria"),className:We(Cr,"shrink-0"),children:s.jsx(oe,{name:"menu-2",className:"h-4 w-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=x,t[11]=e,t[12]=m,t[13]=A):A=t[13];const M=kt;let S;t[14]!==e?(S=e("header.actions.openSessionsAria"),t[14]=e,t[15]=S):S=t[15];const k=i&&"text-foreground";let C;t[16]!==k?(C=We(Cr,"shrink-0",k),t[16]=k,t[17]=C):C=t[17];let y;t[18]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(oe,{name:"layout-left",className:"h-4 w-4"}),t[18]=y):y=t[18];let E;t[19]!==i||t[20]!==S||t[21]!==C||t[22]!==o?(E=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":S,"aria-pressed":i,className:C,children:y})}),t[19]=i,t[20]=S,t[21]=C,t[22]=o,t[23]=E):E=t[23];const B=jt,$=e("header.actions.openSessionsWithShortcut",{shortcut:u});let O;t[24]!==$?(O=s.jsx("p",{children:$}),t[24]=$,t[25]=O):O=t[25];let z;t[26]!==B||t[27]!==O?(z=s.jsx(B,{children:O}),t[26]=B,t[27]=O,t[28]=z):z=t[28];let J;t[29]!==M||t[30]!==E||t[31]!==z?(J=s.jsxs(M,{children:[E,z]}),t[29]=M,t[30]=E,t[31]=z,t[32]=J):J=t[32];let K;t[33]!==l||t[34]!==i||t[35]!==a||t[36]!==e||t[37]!==f?(K=f?null:i?s.jsxs("button",{type:"button",onClick:l,className:We(Cr,"-ms-1 w-auto min-w-0 ps-1 pe-1.5 font-normal"),children:[s.jsx(oe,{name:"chat-new",className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:We(Cr,"-ms-1 shrink-0"),children:s.jsx(oe,{name:"chat-new",className:"h-4 w-4"})})}),s.jsx(jt,{children:s.jsx(Ks,{label:e("sessions.sidebar.header.actions.newSession"),shortcut:ms(Ts("new_chat",a),"")})})]}),t[33]=l,t[34]=i,t[35]=a,t[36]=e,t[37]=f,t[38]=K):K=t[38];let ee;t[39]!==J||t[40]!==K||t[41]!==_||t[42]!==A?(ee=s.jsxs("div",{ref:d,className:F,children:[_,A,J,K]}),t[39]=J,t[40]=K,t[41]=_,t[42]=A,t[43]=ee):ee=t[43];let V;return t[44]!==ee||t[45]!==T?(V=s.jsx("div",{"data-titlebar-left-controls":w,className:j,style:T,children:ee}),t[44]=ee,t[45]=T,t[46]=V):V=t[46],V};function Xb(t){return t.toggleSidebar}function Yb(t){return t.isSidebarOpen}function Jb(t){return t.shortcutOverrides}function Qb(){G.getState().closeMainSurfaces(),st.getState().openNewSessionDraft()}function ew(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 tw(t){console.warn("[titlebar] failed to open app menu",t)}function sw(t,e,n){const r=Le.c(5),[o,i]=c.useState();let a,d;return r[0]!==n||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let u=!1;return(async()=>{const[l,f]=await Promise.all([Om(t),Mm(t)]).catch(nw);if(u)return;const m=Yt(l),p=Yt(f);if(!m||!p||p===m)return;const h=n||"",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,n],r[0]=n,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 nw(){return["",""]}const rw=()=>{const t=Le.c(3),e=G(ow),n=G(iw);let r;return t[0]!==e||t[1]!==n?(r=()=>{n("integrations"),e(!0)},t[0]=e,t[1]=n,t[2]=r):r=t[2],r};function ow(t){return t.setSettingsDialogOpen}function iw(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",aw=({className:t,identity:e})=>{const{t:n}=rt(),{sourceControl:r}=Es(),o=Fm(e),i=Ii(e.provider),a=i.label,d=o?.status??null,u=hn(w=>w.setStatus),[l,f]=c.useState(!1),m=c.useCallback(async w=>{if(!(!w||l)){f(!0);try{u(e,await r.authActivate(e,w))}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?n("header.sourceControl.connectedWithLogin",{login:p,provider:a}):n("header.sourceControl.connected",{provider:a}),b=h?s.jsx("img",{src:h,alt:p?n("header.sourceControl.avatarWithLogin",{login:p}):n("header.sourceControl.avatar",{provider:a}),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3.5 w-3.5 text-foreground"});return x.length<=1?s.jsx("div",{className:We(el,t),title:g,children:b}):s.jsxs(gn,{children:[s.jsx(xn,{asChild:!0,children:s.jsx("button",{type:"button",className:We(el,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:g,disabled:l,children:b})}),s.jsxs(bn,{align:"end",className:"w-64",children:[s.jsx(Ar,{className:"typography-ui-header font-semibold text-foreground",children:n("header.sourceControl.accountsTitle",{provider:a})}),s.jsx(mn,{}),x.map(w=>{const j=w.user,v=!!w.current,T=n(Lm(w.source??"oauth"));return s.jsxs(Gt,{className:"gap-2",disabled:l,onSelect:()=>{v||m(w.id)},children:[j?.avatarUrl?s.jsx("img",{src:j.avatarUrl,alt:j.username?n("header.sourceControl.avatarWithLogin",{login:j.username}):n("header.sourceControl.avatar",{provider:a}),className:"h-6 w-6 rounded-full border border-edge bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-edge bg-muted",children:s.jsx(Ea,{descriptor:i,variant:"fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:j?.name?.trim()||j.username||i.label}),j.username?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:j.username}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:T})]}):null]}),v?s.jsx(oe,{name:"check",className:"h-4 w-4 text-primary"}):null]},w.id)})]})]})},lw=t=>JSON.stringify($m(t)),cw=async(t,e)=>{const n=await t.projectUpstream(e);if(!n?.isFork||!n.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,n.upstream.owner,n.upstream.name);return{upstream:n.upstream,branches:r}},Ad=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function dw(t){if(!Ad(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function uw(t,e,n){const r=Le.c(18),{sourceControl:o}=Es(),i=Ii(t.provider).features.referenceSearch,[a,d]=Ut.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(fw),()=>{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]!==n||r[15]!==i||r[16]!==o?(m=[t,l,e,n,i,o],r[11]=t,r[12]=l,r[13]=e,r[14]=n,r[15]=i,r[16]=o,r[17]=m):m=r[17],Ut.useEffect(f,m),a?.key===l?a.pull:null}function fw(){}const pw=t=>{const e=Le.c(93),{directory:n,context:r,changeRequest:o,onChanged:i,statusStack:a}=t,{sourceControl:d}=Es(),u=Zs(),l=ts(mw),[f,m]=Ut.useState(0),[p,h]=Ut.useState(!1),x=Fi(),g=uw(r,o.number,f);let b;e[0]!==o?(b=Bm(o),e[0]=o,e[1]=b):b=e[1];const w=b;let j;e[2]!==g||e[3]!==w?(j=g?{...w,labels:g.labels,commentCount:g.commentCount}:w,e[2]=g,e[3]=w,e[4]=j):j=e[4];const v=j,[T,F]=Ut.useState(null),_=T?.number===o.number?T.sha:null,{detail:A,latest:M,refresh:S}=Mc(n,v,!0,_),k=M.status==="ready"?M.value.pull:null,C=uc(v);let y;e[5]!==i||e[6]!==S?(y=()=>{S(),m(hw),i()},e[5]=i,e[6]=S,e[7]=y):y=e[7];const E=y,B=fc(v,r,E);let $;e[8]!==r||e[9]!==i||e[10]!==v.number||e[11]!==v.sourceRepo.owner||e[12]!==v.sourceRepo.repo||e[13]!==S||e[14]!==d?($=async()=>{const pe={owner:v.sourceRepo.owner,repo:v.sourceRepo.repo,number:v.number};await d.refreshProviderReads(r,{item:pe}).catch(gw),Fc(pe),m(xw),await Promise.all([S(),i()])},e[8]=r,e[9]=i,e[10]=v.number,e[11]=v.sourceRepo.owner,e[12]=v.sourceRepo.repo,e[13]=S,e[14]=d,e[15]=$):$=e[15];const O=$;let z;e[16]!==v?(z={source:"repository",reference:v},e[16]=v,e[17]=z):z=e[17];const J=z,K=u??n;let ee;e[18]!==A||e[19]!==a?(ee=A.status==="ready"&&A.value.pull&&A.value.pull.stack===void 0&&a!==void 0?{status:"ready",value:{...A.value,pull:{...A.value.pull,stack:a}}}:A,e[18]=A,e[19]=a,e[20]=ee):ee=e[20];const V=ee,Y=V.status==="ready"?V.value.pull?.stack??null:a??null,ae=Li(),P=ts(bw),de=st(ww),q=xr(P,de,n),[Q,L]=Ut.useState(!1);let ne;e[21]===Symbol.for("react.memo_cache_sentinel")?(ne={status:"idle"},e[21]=ne):ne=e[21];const W=q?()=>L(!0):void 0,te=k?.submitRequirements,Z=M.status==="error",me=o.mergeable??null;let Ie;e[22]!==r||e[23]!==J||e[24]!==E||e[25]!==Y||e[26]!==Z||e[27]!==me||e[28]!==W||e[29]!==te?(Ie=s.jsx(_i,{item:J,project:null,context:r,onStartWorktree:vw,onChanged:E,worktreeAvailable:!1,stack:Y,onStartOnTop:W,submitRequirements:te,submitRequirementsUnreadable:Z,mergeable:me}),e[22]=r,e[23]=J,e[24]=E,e[25]=Y,e[26]=Z,e[27]=me,e[28]=W,e[29]=te,e[30]=Ie):Ie=e[30];let fe;e[31]!==o.number||e[32]!==k||e[33]!==_?(fe=k?.revisions?{revisions:k.revisions,selected:_,onSelect:pe=>F(pe?{number:o.number,sha:pe}:null)}:void 0,e[31]=o.number,e[32]=k,e[33]=_,e[34]=fe):fe=e[34];let je;e[35]!==n||e[36]!==ae?(je=pe=>{ae(pe.url,n)},e[35]=n,e[36]=ae,e[37]=je):je=e[37];let $e;e[38]===Symbol.for("react.memo_cache_sentinel")?($e=()=>h(!0),e[38]=$e):$e=e[38];let Re;e[39]!==C.attachComment||e[40]!==C.attachComments?(Re={onAttach:C.attachComment,onAttachAll:C.attachComments},e[39]=C.attachComment,e[40]=C.attachComments,e[41]=Re):Re=e[41];let Fe;e[42]!==r||e[43]!==v||e[44]!==E?(Fe=s.jsx(hc,{reference:v,context:r,onChanged:E}),e[42]=r,e[43]=v,e[44]=E,e[45]=Fe):Fe=e[45];let Ve;e[46]!==r||e[47]!==A||e[48]!==v||e[49]!==E?(Ve=s.jsx(gc,{pull:v,detail:A,context:r,onChanged:E}),e[46]=r,e[47]=A,e[48]=v,e[49]=E,e[50]=Ve):Ve=e[50];const De=k?.voteLabels;let ge;e[51]!==k?.revisions?(ge=k?.revisions?.at(-1)?.sha,e[51]=k?.revisions,e[52]=ge):ge=e[52];const xe=_===null;let Se;e[53]!==r||e[54]!==v||e[55]!==E||e[56]!==De||e[57]!==ge||e[58]!==xe?(Se=s.jsx(pc,{reference:v,context:r,onRefresh:E,voteLabels:De,latestRevision:ge,onLatestRevision:xe},v.number),e[53]=r,e[54]=v,e[55]=E,e[56]=De,e[57]=ge,e[58]=xe,e[59]=Se):Se=e[59];const Be=l??"";let Pe;e[60]!==K||e[61]!==Be?(Pe={id:Be,path:K},e[60]=K,e[61]=Be,e[62]=Pe):Pe=e[62];let Me;e[63]!==r||e[64]!==K||e[65]!==v||e[66]!==_||e[67]!==Pe?(Me=s.jsx(xc,{pull:v,project:Pe,repository:null,context:r,projectOwnsDirectory:Sw,currentDirectory:K,revision:_}),e[63]=r,e[64]=K,e[65]=v,e[66]=_,e[67]=Pe,e[68]=Me):Me=e[68];let Je;e[69]!==n||e[70]!==J||e[71]!==x||e[72]!==O||e[73]!==V||e[74]!==Ie||e[75]!==fe||e[76]!==je||e[77]!==Re||e[78]!==Fe||e[79]!==Ve||e[80]!==Se||e[81]!==Me||e[82]!==B?(Je=s.jsx($i,{item:J,directory:n,pullStatus:Bi,trackerDetail:ne,repositoryDetail:V,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:yw,now:x,footer:Ie,revisionChoice:fe,onOpenStackLayer:je,onOpenChecks:$e,onRefresh:O,commentAttachments:Re,threadActions:B,labelsControl:Fe,reviewersControl:Ve,reply:Se,pullLinks:Me}),e[69]=n,e[70]=J,e[71]=x,e[72]=O,e[73]=V,e[74]=Ie,e[75]=fe,e[76]=je,e[77]=Re,e[78]=Fe,e[79]=Ve,e[80]=Se,e[81]=Me,e[82]=B,e[83]=Je):Je=e[83];let X;e[84]!==C.attachFailedChecks||e[85]!==p||e[86]!==r||e[87]!==v?(X=s.jsx(mc,{pull:v,context:r,open:p,onOpenChange:h,onAttachFailed:C.attachFailedChecks}),e[84]=C.attachFailedChecks,e[85]=p,e[86]=r,e[87]=v,e[88]=X):X=e[88];const Ee=q?s.jsx(zm,{open:Q,onOpenChange:L,project:{id:q.id,path:qr(q.path)??q.path},initialSourceBranch:v.head,onWorktreeCreated:kw}):null;let _e;return e[89]!==Je||e[90]!==X||e[91]!==Ee?(_e=s.jsxs(s.Fragment,{children:[Je,X,Ee]}),e[89]=Je,e[90]=X,e[91]=Ee,e[92]=_e):_e=e[92],_e};function mw(t){return t.activeProjectId}function hw(t){return t+1}function gw(){}function xw(t){return t+1}function bw(t){return t.projects}function ww(t){return t.availableWorktreesByProject}function yw(){}function vw(){}function Sw(){return!0}function kw(t){st.getState().openNewSessionDraft({directoryOverride:t,preserveDirectoryOverride:!0})}const jw=/^Change-Id:\s*I[0-9a-f]{40}$/,Cw=50,Tw=t=>(t.replace(/\r\n/g,`
|
|
3
3
|
`).trim().split(/\n[ \t]*\n/).at(-1)??"").split(`
|
|
4
4
|
`).some(r=>jw.test(r.trim())),Nw=t=>{const e=t[0]??null,n=t.filter(r=>!Tw(r.body));return{status:"ready",commits:t.length,subject:e?.message.trim()||null,tip:e?.hash??null,missing:n.length===0?"none":n.length===1&&n[0]===e?"tip":"many",missingCount:n.length}};function Ew(t,e,n,r,o){const i=Le.c(15),[a,d]=c.useState(null);let u;i[0]!==e||i[1]!==n||i[2]!==t||i[3]!==o?(u=JSON.stringify([t,e,n,o]),i[0]=e,i[1]=n,i[2]=t,i[3]=o,i[4]=u):u=i[4];const l=u;let f,m;if(i[5]!==e||i[6]!==n||i[7]!==t||i[8]!==r||i[9]!==l?(f=()=>{if(!r||!t||!e||!n)return;let h=!1;return d({key:l,value:{status:"loading"}}),Lc(t,{from:e,to:n,maxCount:Cw}).then(x=>{h||d({key:l,value:Nw(x.all)})}).catch(()=>{h||d({key:l,value:{status:"error"}})}),()=>{h=!0}},m=[e,n,t,r,l],i[5]=e,i[6]=n,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 Iw=t=>{const e=Le.c(111),{preflight:n,topic:r,onTopicChange:o,hashtags:i,onHashtagsChange:a,wip:d,onWipChange:u,privateChange:l,onPrivateChange:f,onAddChangeId:m,disabled:p}=t,{t:h}=rt(),x=n?.status==="ready"?n: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 me;e[2]!==Z?(me=s.jsx("span",{className:"text-muted-foreground",children:Z}),e[2]=Z,e[3]=me):me=e[3],g=me}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 me;e[6]!==Z?(me=s.jsx("span",{className:"min-w-0 flex-1 text-[var(--status-warning)]",children:Z}),e[6]=Z,e[7]=me):me=e[7];let Ie;e[8]!==p||e[9]!==m||e[10]!==h?(Ie=m?s.jsx(us,{sideOffset:8,label:h("contextTooltips.git.addChangeId"),className:"shrink-0",children:s.jsx(ft,{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]=Ie):Ie=e[11];let fe;e[12]!==me||e[13]!==Ie?(fe=s.jsxs(s.Fragment,{children:[me,Ie]}),e[12]=me,e[13]=Ie,e[14]=fe):fe=e[14],g=fe}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 me;e[18]!==Z?(me=s.jsx("span",{className:"text-[var(--status-warning)]",children:Z}),e[18]=Z,e[19]=me):me=e[19],g=me}else if(n?.status==="error"){let Z;e[20]!==h?(Z=h("gitView.change.push.readFailed"),e[20]=h,e[21]=Z):Z=e[21];let me;e[22]!==Z?(me=s.jsx("span",{className:"text-[var(--status-error-text)]",children:Z}),e[22]=Z,e[23]=me):me=e[23],g=me}let b;e[24]!==h?(b=h("gitView.change.push.subject"),e[24]=h,e[25]=b):b=e[25];let w;e[26]!==b?(w=s.jsx("div",{className:"typography-micro text-muted-foreground",children:b}),e[26]=b,e[27]=w):w=e[27];const j=x?.subject??void 0;let v;e[28]!==n?.status||e[29]!==x?.subject?(v=x?.subject??(n?.status==="loading"?s.jsx(oe,{name:"loader-4",className:"size-3.5 animate-spin text-muted-foreground"}):null),e[28]=n?.status,e[29]=x?.subject,e[30]=v):v=e[30];let T;e[31]!==j||e[32]!==v?(T=s.jsx("div",{className:"min-h-5 truncate typography-ui-label text-foreground",title:j,children:v}),e[31]=j,e[32]=v,e[33]=T):T=e[33];let F;e[34]!==h?(F=h("gitView.change.push.subjectHint"),e[34]=h,e[35]=F):F=e[35];let _;e[36]!==F?(_=s.jsx("div",{className:"typography-micro text-muted-foreground",children:F}),e[36]=F,e[37]=_):_=e[37];let A;e[38]!==w||e[39]!==T||e[40]!==_?(A=s.jsxs("div",{className:"space-y-1",children:[w,T,_]}),e[38]=w,e[39]=T,e[40]=_,e[41]=A):A=e[41];let M;e[42]!==h?(M=h("gitView.change.push.topic"),e[42]=h,e[43]=M):M=e[43];let S;e[44]!==M?(S=s.jsx("div",{className:"typography-micro text-muted-foreground",children:M}),e[44]=M,e[45]=S):S=e[45];let k;e[46]!==o?(k=Z=>o(Z.target.value),e[46]=o,e[47]=k):k=e[47];let C;e[48]!==h?(C=h("gitView.change.push.optional"),e[48]=h,e[49]=C):C=e[49];let y;e[50]!==p||e[51]!==k||e[52]!==C||e[53]!==r?(y=s.jsx(On,{value:r,onChange:k,placeholder:C,disabled:p}),e[50]=p,e[51]=k,e[52]=C,e[53]=r,e[54]=y):y=e[54];let E;e[55]!==S||e[56]!==y?(E=s.jsxs("label",{className:"space-y-1",children:[S,y]}),e[55]=S,e[56]=y,e[57]=E):E=e[57];let B;e[58]!==h?(B=h("gitView.change.push.hashtags"),e[58]=h,e[59]=B):B=e[59];let $;e[60]!==B?($=s.jsx("div",{className:"typography-micro text-muted-foreground",children:B}),e[60]=B,e[61]=$):$=e[61];let O;e[62]!==a?(O=Z=>a(Z.target.value),e[62]=a,e[63]=O):O=e[63];let z;e[64]!==h?(z=h("gitView.change.push.hashtagsPlaceholder"),e[64]=h,e[65]=z):z=e[65];let J;e[66]!==p||e[67]!==i||e[68]!==O||e[69]!==z?(J=s.jsx(On,{value:i,onChange:O,placeholder:z,disabled:p}),e[66]=p,e[67]=i,e[68]=O,e[69]=z,e[70]=J):J=e[70];let K;e[71]!==$||e[72]!==J?(K=s.jsxs("label",{className:"space-y-1",children:[$,J]}),e[71]=$,e[72]=J,e[73]=K):K=e[73];let ee;e[74]!==E||e[75]!==K?(ee=s.jsxs("div",{className:"flex flex-col gap-3",children:[E,K]}),e[74]=E,e[75]=K,e[76]=ee):ee=e[76];let V;e[77]!==h?(V=h("gitView.change.push.wip"),e[77]=h,e[78]=V):V=e[78];let Y;e[79]!==p||e[80]!==u||e[81]!==V||e[82]!==d?(Y=s.jsx(ti,{checked:d,onChange:u,disabled:p,ariaLabel:V}),e[79]=p,e[80]=u,e[81]=V,e[82]=d,e[83]=Y):Y=e[83];let ae;e[84]!==h?(ae=h("gitView.change.push.wip"),e[84]=h,e[85]=ae):ae=e[85];let P;e[86]!==Y||e[87]!==ae?(P=s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[Y,ae]}),e[86]=Y,e[87]=ae,e[88]=P):P=e[88];let de;e[89]!==h?(de=h("gitView.change.push.private"),e[89]=h,e[90]=de):de=e[90];let q;e[91]!==p||e[92]!==f||e[93]!==l||e[94]!==de?(q=s.jsx(ti,{checked:l,onChange:f,disabled:p,ariaLabel:de}),e[91]=p,e[92]=f,e[93]=l,e[94]=de,e[95]=q):q=e[95];let Q;e[96]!==h?(Q=h("gitView.change.push.private"),e[96]=h,e[97]=Q):Q=e[97];let L;e[98]!==q||e[99]!==Q?(L=s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 typography-meta text-foreground",children:[q,Q]}),e[98]=q,e[99]=Q,e[100]=L):L=e[100];let ne;e[101]!==P||e[102]!==L?(ne=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[P,L]}),e[101]=P,e[102]=L,e[103]=ne):ne=e[103];let W;e[104]!==g?(W=s.jsx("div",{className:"flex min-h-7 items-center gap-2 typography-micro",children:g}),e[104]=g,e[105]=W):W=e[105];let te;return e[106]!==ee||e[107]!==ne||e[108]!==W||e[109]!==A?(te=s.jsxs("div",{className:"flex flex-col gap-3",children:[A,ee,ne,W]}),e[106]=ee,e[107]=ne,e[108]=W,e[109]=A,e[110]=te):te=e[110],te};function Pw(t,e){const{git:n,sourceControl:r}=Es(),{t:o}=rt(),i=zf(),a=Wf({directory:t,branch:e,chooseContributor:i.choose}),d=Wm(t,n,r),u=async(p,h)=>{const x=d.start();if(!x)return Te.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 b=g.code==="review-option-invalid"?o("gitView.change.push.invalidOption"):a.errorMessage(g);return b?Te.info(b):Te.error(p),!1}return g instanceof Vm||g instanceof Hm?(Te.error(p,{description:g.message||void 0}),!1):(Te.error(p,{description:g instanceof Error?Hf(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 qm({directory:t,git:n,sourceControl:r,review:p,onOperation:h.onOperation})}):Promise.resolve(!1),m=s.jsxs(s.Fragment,{children:[a.context?s.jsx(Uf,{context:a.context,onSelect:a.settle}):null,a.confirmDialog,s.jsx(Vf,{candidates:i.candidates,onSelect:i.settle})]});return{push:l,pushForReview:f,dialogs:m}}const Rw=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"}},Dw=(t,e)=>{const{currentSessionId:n,getDirectoryForSession:r}=st.getState(),o=n?r(n):null;!n||!o||Yt(o)!==Yt(t)||rh(n,o,oh({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},_w=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},Aw=[2e3,5e3];let tl=0;const Ow=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(tl+=1,`source-control-${Date.now().toString(36)}-${tl.toString(36)}`)},Mw=(t,e,n)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...n]),Od="openchamber:pr-create-as-draft:v1",sl=()=>{try{return localStorage.getItem(Od)==="true"}catch{return!1}},Fw=t=>{try{localStorage.setItem(Od,String(t))}catch{}},Bo=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Ys=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):""},Lw=(t,e)=>{const n=Ys(t);if(!n||n.includes("->"))return"";if(e){const o=`${e}/`;return n.startsWith(o)?n.slice(o.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},$w=(t,e)=>`${t}::${e}`,zo=new Map,nl=Ln;function Bw(t,e,n){const r=Le.c(14);let o;r[0]!==n?(o=n?lw(n):null,r[0]=n,r[1]=o):o=r[1];const i=o;let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=a):a=r[2];const[d,u]=c.useState(a);let l,f;r[3]!==i||r[4]!==t||r[5]!==n||r[6]!==e?(l=()=>{if(!t||!n||!i)return;let p=!1;return(async()=>{try{const h=await cw(e,n);p||u({contextKey:i,detectedUpstream:h.upstream,upstreamBranches:h.branches})}catch{}})(),()=>{p=!0}},f=[i,t,n,e],r[3]=i,r[4]=t,r[5]=n,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 zw=({directory:t,branch:e,baseBranch:n,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:a})=>{const{t:d}=rt(),u=$c(t),l=Hu(),f=Ql(I=>I.byId),m=I=>f.has(I),p=l(u?.provider),h=p.terminology.changeRequest,x=p.features.createByPush,g=c.useCallback((I,ve)=>d(Vs(I,h),ve),[h,d]),b=rw(),{sourceControl:w,git:j}=Es(),v=zi(),T=hn(I=>I.entries),{isMobile:F,hasTouchInput:_,screenWidth:A}=wn(),M=G(I=>I.openContextSurface),S=Km(I=>I.requestTarget),k=!F&&A>=768&&!Ni(),C=c.useMemo(()=>$w(t,e),[t,e]),y=c.useMemo(()=>zo.get(C)??null,[C]),E=ys(I=>I.ensureEntry),B=ys(I=>I.setParams),$=ys(I=>I.beginActiveContextsLoad),O=ys(I=>I.commitActiveContexts),z=ys(I=>I.releaseActiveContexts),J=c.useId(),K=ys(I=>I.startWatching),ee=ys(I=>I.stopWatching),V=ys(I=>I.refresh),[Y,ae]=c.useState(()=>y?.title??Bo(e)),[P,de]=c.useState(()=>y?.body??""),[q,Q]=c.useState(()=>y?.draft??sl()),[L,ne]=c.useState(()=>y?.additionalContext??""),[W,te]=c.useState(()=>y?.targetBaseBranchChosen===!0),[Z,me]=c.useState(()=>{const I=typeof y?.targetBaseBranch=="string"?Ys(y.targetBaseBranch):"";return I||Ys(n)}),Ie=c.useCallback(I=>{te(!0),me(I)},[]),[fe,je]=c.useState(!1),[$e,Re]=c.useState(!1),[Fe,Ve]=c.useState(""),[De,ge]=c.useState(""),[xe,Se]=c.useState(!1),[Be,Pe]=c.useState(0),[Me,Je]=c.useState(!1),X=Bc(t,w),Ee=X.scope.runtimeKey;c.useEffect(()=>{if(!t)return;const I=X.scope.runtimeKey,ve=$(I,t,J),he=X.contexts.filter(it=>Ia(T[Hn(it)],it).connected);return O(I,t,J,ve,he),()=>{z(I,t,J)}},[$,X.contexts,X.scope.runtimeKey,O,t,z,T,J]);const pe=X.contexts[0]??null,R=ys(I=>{if(!pe||!Z)return null;const ve=Gm(I.entries,pe,Z);if(!ve||ve.defaultBranch===Z)return null;const he=ve.changeRequest??ve.pr??null;return he?.state==="open"?he:null}),ie=hn(I=>u?I.entries[Hn(u)]?.hasChecked===!0:!1),Ce=pe?.primaryRemote??null,Ne=c.useMemo(()=>pe?Hn(pe):"",[pe]),ze=hn(I=>I.entries[Ne]),qe=pe?Ia(ze,pe):{authChecked:ze?.hasChecked??!1,connected:!1},Ue=qe.authChecked,[tt,He]=c.useState(0),[Ze,Qe]=c.useState({key:"",status:"loading",capabilities:null}),[ot,pt]=c.useState(!1),{detectedUpstream:at,upstreamBranches:xt}=Bw(t,w,pe);c.useEffect(()=>{if(!pe)return;let I=!1;const ve=Hn(pe);return Qe({key:ve,status:"loading",capabilities:null}),w.capabilities(pe).then(he=>{I||Qe({key:ve,status:"ready",capabilities:he})}).catch(()=>{I||Qe({key:ve,status:"error",capabilities:null})}),()=>{I=!0}},[tt,pe,w]);const le=Ze.key===Ne?Ze:null,be=le?.status==="ready"?le.capabilities:null;c.useEffect(()=>{pt(!1)},[t]);const N=!!(t&&e&&n&&(e!==n||at!==null||x)),ce=c.useMemo(()=>pe?Zm(pe,e):"",[e,pe]),U=c.useRef(ce);U.current=ce;const we=c.useCallback((I,ve)=>I===Jt()&&ve===U.current,[]),ke=ys(I=>I.entries[ce]),Xe=c.useMemo(()=>ce?[ce]:[],[ce]);Wi(Xm(Xe));const Oe=ke?.isLoading??!1,se=qe.connected?ke?.status??null:null,ue=X.error?g("settings.sourceControl.instance.status.operationFailed"):ke?.error??null,et=ke?.isInitialStatusResolved??!1,ye=c.useMemo(()=>{const I=ot?null:Ce,ve=new Set;for(const nt of i){const Nt=Lw(nt,I);!Nt||Nt==="HEAD"||ve.add(Nt)}if(ot)for(const nt of xt)nt&&nt!=="HEAD"&&ve.add(nt);const he=Ys(n);he&&he!=="HEAD"&&ve.add(he);const it=Ys(Z);return it&&it!=="HEAD"&&ve.add(it),Array.from(ve).sort((nt,Nt)=>nt.localeCompare(Nt))},[n,i,Ce,Z,xt,ot]);c.useEffect(()=>{const I=Ys(n);if(!Z&&I){me(I);return}if(ye.length!==0&&!ye.includes(Z)){const ve=ye.includes(I)?I:ye[0];ve&&me(ve)}},[ye,n,Z]);const bt=c.useRef([]),Tt=c.useRef(new Map),vt=c.useCallback(I=>{const ve=Tt.current.get(I);if(ve?.inFlight)return null;if(ve)return ve.inFlight=!0,ve.key;const he=Ow();return Tt.current.set(I,{key:he,inFlight:!0}),he},[]),Pt=c.useCallback((I,ve,he)=>{const it=Tt.current.get(I);!it||it.key!==ve||(he?it.inFlight=!1:Tt.current.delete(I))},[]);c.useEffect(()=>{at&&pt(!0)},[at]),c.useEffect(()=>{ot&&at?.defaultBranch&&me(at.defaultBranch)},[ot,at?.defaultBranch]);const Ke=se?.changeRequest??se?.pr??null,ct=se?.identity??pe,Rt=c.useMemo(()=>se?.project??(se?.repo&&ct?{...se.repo,...ct,id:Ao(se.repo.owner,se.repo.repo),name:se.repo.repo}:null),[se?.project,se?.repo,ct]),ht=Ke?.state==="merged"||Ke?.state==="closed",Ct=ht?null:Ke,lt=se?.ci?.summary??se?.checks??null,[Et,qt]=c.useState(!1),dt=c.useRef(!0);c.useEffect(()=>(dt.current=!0,()=>{dt.current=!1}),[]);const ut=c.useCallback(async I=>{await V(ce,I)},[ce,V]),Ot=c.useCallback((I,ve)=>{bt.current.forEach(he=>{window.clearTimeout(he)}),bt.current=Aw.map(he=>window.setTimeout(()=>{we(I,ve)&&V(ve,{force:!0,silent:!0,markInitialResolved:!0})},he))},[we,V]),Zt=c.useCallback(async(I,ve,he)=>{await dw({error:I,isCurrent:()=>we(ve,he),refresh:()=>V(he,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>Ot(ve,he)})},[we,V,Ot]);c.useEffect(()=>{!pe||!ce||(E(ce),B(ce,{directory:t,branch:e,remoteName:pe.primaryRemote,canShow:N,identity:pe,readContext:pe,sourceControl:w,authChecked:qe.authChecked,connected:qe.connected}))},[e,N,t,E,ce,pe,w,qe.authChecked,qe.connected,B]);const is=600,as=c.useCallback(async()=>{if(Et)return;qt(!0);const I=Date.now();try{if(await ut({force:!0}),Ke&&se?.repo&&ct){const ve={owner:se.repo.owner,repo:se.repo.repo,number:Ke.number};await w.refreshProviderReads(ct,{item:ve}).catch(()=>{})}}finally{const ve=is-(Date.now()-I);ve>0&&await new Promise(he=>window.setTimeout(he,ve)),dt.current&&qt(!1)}},[Et,Ke,ut,w,se?.repo,ct]);c.useEffect(()=>{if(!(!pe||!ce))return K(ce),()=>{ee(ce)}},[ce,pe,K,ee]),c.useEffect(()=>{const I=zo.get(C)??null;ae(I?.title??Bo(e)),de(I?.body??""),Q(I?.draft??sl());const ve=I?.targetBaseBranchChosen===!0&&!!I.targetBaseBranch;te(ve),me(ve&&I?.targetBaseBranch?Ys(I.targetBaseBranch):Ys(n))},[n,e,C]),c.useEffect(()=>{!pe||!ce||!qe.connected||ut({markInitialResolved:!0})},[ce,pe,ut,qe.connected]),c.useEffect(()=>{!N||!pe||!qe.connected||ut({force:!0,silent:!0,markInitialResolved:!0})},[N,pe,ut,qe.connected]),c.useEffect(()=>{const I=()=>{const he=ys.getState().entries[ce]?.lastRefreshAt??0;Date.now()-he>6e4&&ut({force:!0,silent:!0})},ve=()=>{document.visibilityState==="visible"&&I()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",ve),()=>{window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",ve)}},[ce,ut]),c.useEffect(()=>{Ue&&!qe.connected&&ut({force:!0,silent:!0,markInitialResolved:!0})},[ut,qe.connected,Ue]),c.useEffect(()=>{!t||!e||zo.set(C,{title:Y,body:P,draft:q,additionalContext:L,targetBaseBranch:Z,targetBaseBranchChosen:W})},[C,Y,P,q,L,Z,W,t,e]),c.useEffect(()=>()=>{bt.current.forEach(I=>{window.clearTimeout(I)}),bt.current=[]},[ce,Ee]),c.useEffect(()=>()=>{Tt.current.clear()},[]);const ss=ot&&at?.defaultBranchSha?at.defaultBranchSha:pe?`${pe.primaryRemote}/${Z}`:Z;c.useEffect(()=>{if(!t||!e||!ss)return;let I=!1;return Lc(t,{from:ss,to:e,maxCount:2}).then(ve=>{const he=ve.all.length===1?ve.all[0]?.message.trim():"";I||!he||ae(it=>it===Bo(e)?he:it)}).catch(()=>{}),()=>{I=!0}},[e,ss,t]);const Xt=x?se?.localRevision?.uploadedAs===null:!r||o>0,ls=Pw(t,e),ns=Ew(t,ss,e,x&&N,Be),Is=c.useId(),Ps=I=>{Q(I),Fw(I)},cs=c.useCallback(async()=>{if(!fe&&t){je(!0);try{const ve={base:ss,head:e,...pe?.provider?{changeRequestProvider:l(pe.provider)}:{}};L&&(ve.context=L);const he=await Ym(t,ve);he.title?.trim()&&ae(he.title.trim()),he.body?.trim()&&de(he.body.trim()),a?.()}catch(I){const ve=I instanceof Error?I.message:String(I);Te.error(g("gitView.pr.toast.generateDescriptionFailed"),{description:ve})}finally{je(!1)}}},[L,e,ss,l,t,fe,a,pe,g]),rs=c.useCallback(async()=>{if(be?.changeRequests!==!0){Te.error(g("gitView.pr.toast.createPrFailed"),{description:g("gitView.pr.capabilitiesUnavailable")});return}const I=Y.trim();if(!I){Te.error(g("gitView.pr.toast.titleRequired"));return}const ve=Z.trim();if(!ve){Te.error(g("gitView.pr.toast.baseBranchRequired"));return}if(!ot&&ve===e){Te.error(g("gitView.pr.toast.baseMustDifferFromHead"));return}const he=ot?at:Rt;if(!pe||!he){Te.error(g("gitView.pr.toast.createPrFailed"),{description:ue??g("gitView.pr.statusUnavailable")});return}if(Xt&&(Re(!0),!await ls.push())){Re(!1);return}const it=Jt(),nt=ce,Nt={owner:he.owner,name:he.name},At=P.trim()?P:void 0,Dt=ot?void 0:pe.primaryRemote,Mt=ot?pe.primaryRemote:void 0,ws=Mw(it,pe,[Nt.owner,Nt.name,e,ve,I,At,q,Dt,Mt]),nn=vt(ws);if(!nn){Re(!1);return}Re(!0);let Io=!1,ia=!1;try{const Ms={...pe,idempotencyKey:nn,target:{project:Nt,head:e,base:ve},title:I,draft:q};At!==void 0&&(Ms.body=At),Dt&&(Ms.remote=Dt),Mt&&(Ms.headRemote=Mt);const rn=await w.changeRequestCreate(Ms);if(ia=!0,Pt(ws,nn,!1),!we(it,nt)||(rn.result.stacked===!1?Te.warning(g("stacks.toast.createdNotStacked"),{description:g("stacks.toast.createdNotStackedDescription",{base:ve})}):Te.success(g(rn.result.stacked?"stacks.toast.createdStacked":"gitView.pr.toast.prCreated")),await ut({force:!0}),!we(it,nt)))return;const kr=ys.getState().entries[nt]?.status,Po=kr?.changeRequest??kr?.pr;Po&&Po.number===rn.target.number&&Dw(t,Po),Ot(it,nt)}catch(Ms){const rn=Ms instanceof Error?Ms:new Error(String(Ms));Io=Ad(rn);const kr=rn.message;Te.error(g("gitView.pr.toast.createPrFailed"),{description:kr}),Io&&await Zt(rn,it,nt)}finally{ia||Pt(ws,nn,Io),Re(!1)}},[vt,P,e,ls,at,t,q,ue,Pt,we,Xt,ce,pe,Zt,ut,Ot,w,be?.changeRequests,Rt,Z,Y,ot,g]),Kt=async()=>{const I=Z.trim();if(!I){Te.error(g("gitView.pr.toast.baseBranchRequired"));return}const ve={target:I,wip:q,private:xe};Fe.trim()&&(ve.topic=Fe.trim());const he=De.split(/[\s,]+/).filter(Boolean);he.length>0&&(ve.hashtags=he),Re(!0);try{if(!await ls.pushForReview(ve))return;Te.success(g("gitView.change.push.toast.pushed")),await ut({force:!0})}finally{Re(!1)}},Os=async I=>{Re(!0);try{if(!await ls.pushForReview({target:I.base}))return;Te.success(g("gitView.change.push.toast.uploaded")),await ut({force:!0})}finally{Re(!1)}},re=j.addChangeIdToHead,Ye=async()=>{const I=ns?.status==="ready"?ns.tip:null;if(!(!re||!I||!await v.confirm({title:g("gitView.change.changeId.confirmTitle"),message:g("gitView.change.changeId.confirmMessage"),action:g("gitView.change.changeId.add")})))try{await re(t,I),Te.success(g("gitView.change.changeId.toast.added"))}catch(he){Te.error(g("gitView.change.changeId.toast.failed"),{description:he instanceof Error?he.message:String(he)})}finally{Pe(he=>he+1)}},gt="border-0 bg-transparent rounded-none px-4 py-3";if(!N)return s.jsx("section",{className:gt,children:s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:g("gitView.pullRequest.availableOnFeatureBranches")}),u?s.jsx(aw,{identity:u}):null]})});const wt=se?.changeRequest&&se.changeRequest.state==="open"?se.changeRequest:Ct&&Rt&&ct?{...ct,id:`${Ao(Rt.owner,Rt.name)}#${Ct.number}`,number:Ct.number,project:{...ct,id:Rt.id,owner:Rt.owner,name:Rt.name,url:Rt.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&&pe){const I=s.jsx(pw,{directory:t,context:pe,changeRequest:wt,onChanged:()=>ut({force:!0,silent:!0,markInitialResolved:!0}),statusStack:se?.stack});if(!(x&&Xt))return s.jsx("div",{className:"h-full min-h-0",children:I});const ve=wt.revisionNumber!==void 0?wt.revisionNumber+1:null;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-edge-muted px-4 py-2",children:[s.jsx(oe,{name:"arrow-up",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",children:g("gitView.change.push.notUploaded")}),s.jsx(us,{sideOffset:8,label:g("contextTooltips.git.uploadPatchset"),className:"shrink-0",children:s.jsxs(ft,{size:"sm",className:"shrink-0",onClick:()=>{Os(wt)},disabled:$e,children:[$e?s.jsx(oe,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(oe,{name:"upload-2",className:"size-4"}),ve!==null?g("gitView.change.push.uploadPatchset",{number:ve}):g("gitView.change.push.uploadNew")]})}),ls.dialogs]}),s.jsx("div",{className:"min-h-0 flex-1",children:I})]})}const _t=Rt?.url||null,Vt=ot&&at?.url?at.url:_t,H=le?.status==="error",Ge=!!se?.connected,mt=!!(!pe&&u&&X.status==="ready"&&ie),It=!!(ct&&Ue&&se?.connected===!1)||mt,$t=ct??u,Bt=$t?l($t.provider).label:null,Ft=_w(se),js=Ft?`var(--pr-${Ft})`:"var(--status-info)",Rs=Ft==="draft"?"git-pr-draft":Ft==="merged"?"git-merge":Ft==="closed"?"git-close-pull-request":"git-pull-request",Xs=Bt?g("gitView.pr.actions.openOnProviderAria",{provider:Bt}):g("gitView.header.openPullRequest"),Co=Ke?[g(Ke.state==="merged"?"sessions.sidebar.group.pr.status.merged":Ke.state==="closed"?"sessions.sidebar.group.pr.status.closed":Ke.draft?"sessions.sidebar.group.pr.status.draft":"sessions.sidebar.group.pr.status.open"),Ke.state==="open"&&Ke.mergeable===!1?g("gitView.pr.notMergeable"):null,Ke.state==="open"&&typeof Ke.mergeableState=="string"&&Ke.mergeableState&&Ke.mergeableState!=="unknown"?Ke.mergeableState:null].filter(Boolean).join(" · "):"",To=lt?lt.total>0?`${lt.success}/${lt.total} ${g("gitView.pr.checks.label")}`:`${lt.state} ${g("gitView.pr.checks.label")}`:"",vr="px-0 py-3 border-b border-edge-muted flex flex-col gap-1",$n="flex flex-col gap-3 py-3",Bn=s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Oe||Et,onClick:()=>{as()},"aria-label":g("gitView.pr.actions.refreshAria"),children:s.jsx(oe,{name:Oe||Et?"loader-4":"refresh",className:We("size-4 text-muted-foreground",(Oe||Et)&&"animate-spin")})})}),s.jsx(jt,{children:s.jsx("p",{children:g("gitView.pr.actions.refresh")})})]}),No=Me||L.trim().length>0,zn=Xt?r?o===1?g("gitView.pr.unpushed.one"):g("gitView.pr.unpushed.many",{count:o}):g("gitView.pr.unpushed.unpublished"):null,Sr=g(Xt?q?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":q?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),Eo=$e||!Ge||be?.changeRequests!==!0||!Z.trim()||!ot&&Z.trim()===e,D=$e||!Ge||!Z.trim()||ns?.status!=="ready"||ns.commits===0||ns.missing!=="none";return s.jsxs("section",{className:gt,children:[Ke?s.jsxs("div",{className:vr,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(us,{sideOffset:8,label:Xs,className:"shrink-0",children:s.jsxs(ft,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{nl(Ke.url)},"aria-label":Xs,children:[s.jsx(oe,{name:Rs,className:"size-4 shrink-0",style:{color:js}}),Bt?g("gitView.pr.actions.openOnProvider",{provider:Bt}):g("gitView.header.openPullRequest")]})}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:g("gitView.pullRequest.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:aa(l(ct?.provider),Ke.number)})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Bn})]}),s.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:js},children:Co}),lt?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${Rw(lt.state)}`}),To]}):null,r&&Ce&&r.split("/")[0]!==Ce?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",Ce]}):null]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:k&&pe&&m(pe.provider)?s.jsx(us,{sideOffset:8,label:g("contextTooltips.git.walkthrough"),className:"shrink-0",children:s.jsxs(ft,{variant:"outline",size:"sm",className:We("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",qf),onClick:()=>{S(t,{source:{kind:"pr",number:Ke.number,...Rt?{sourceRepo:{owner:Rt.owner,repo:Rt.name}}:{}},context:pe}),M(t,"walkthrough")},"aria-label":g("walkthrough.action.open"),children:[s.jsx(oe,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:g("walkthrough.action.open")})]})}):null})]})]}):null,s.jsxs("div",{className:$n,children:[H?s.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[s.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:g("gitView.pr.capabilitiesUnavailable")}),s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>He(I=>I+1),children:g("settings.sourceControl.transport.retry")})]}):null,It&&Bt?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:g("gitView.pr.providerNotConnected",{provider:Bt})}),s.jsx(ft,{variant:"outline",size:"sm",onClick:b,className:"w-fit",children:g("gitView.pr.actions.openSettings")})]}):null,ue?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:g("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:ue}),X.error?s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>{X.retry()},disabled:X.status==="loading",children:g("settings.sourceControl.transport.retry")}):null,Vt?s.jsx(ft,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:Vt,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(oe,{name:"external-link",className:"size-4"}),g("gitView.pr.actions.repo")]})}):null]}):null,(Ct||!Ke&&!et)&&!ue&&!It&&(X.status==="loading"||pe)?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(Jm,{className:"size-4"}),g("gitView.pr.checkingStatus")]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[Ke&&ht?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md oc-tile-inset px-2.5 py-2",children:[s.jsx(oe,{name:Ke.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:js}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Ke.state==="merged"?g("gitView.pr.history.merged",{number:Ke.number,base:Ke.base||Z}):g("gitView.pr.history.closed",{number:Ke.number})}),s.jsx(us,{sideOffset:8,label:Xs,className:"shrink-0",children:s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{nl(Ke.url)},"aria-label":Xs,children:s.jsx(oe,{name:"external-link",className:"size-3.5"})})})]}):null,s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(oe,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),s.jsx(oe,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),ot&&at?s.jsx("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:Ao(at.owner,at.name)}):null,ye.length>0?s.jsxs(Qm,{value:Z,onValueChange:Ie,children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(eh,{className:"w-auto min-w-0","aria-label":g("gitView.pr.field.baseBranch"),children:s.jsx(th,{placeholder:g("gitView.pr.placeholder.selectBaseBranch")})})}),s.jsx(jt,{children:s.jsx("p",{children:g("gitView.pr.field.baseBranch")})})]}),s.jsx(sh,{children:ye.map(I=>s.jsx(nh,{value:I,children:I},I))})]}):s.jsx(On,{value:Z,onChange:I=>Ie(I.target.value),placeholder:g("gitView.pr.placeholder.main"),"aria-label":g("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),s.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[Vt?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:s.jsx("a",{href:Vt,target:"_blank",rel:"noopener noreferrer","aria-label":g("gitView.pr.actions.repo"),children:s.jsx(oe,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),s.jsx(jt,{children:s.jsx("p",{children:g("gitView.pr.actions.repo")})})]}):null,Bn]})]}),R?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[s.jsx(oe,{name:"stack",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:g("stacks.create.stacksOn",{reference:aa(l(pe?.provider),R.number)})})]}):null,x?s.jsx(Iw,{preflight:ns,topic:Fe,onTopicChange:Ve,hashtags:De,onHashtagsChange:ge,wip:q,onWipChange:Ps,privateChange:xe,onPrivateChange:Se,onAddChangeId:re?()=>{Ye()}:void 0,disabled:$e}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.title")}),s.jsx(On,{value:Y,onChange:I=>ae(I.target.value),placeholder:g("gitView.pr.placeholder.title"),autoCorrect:_?"on":"off",autoCapitalize:_?"sentences":"off",spellCheck:_})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("label",{htmlFor:Is,className:"typography-micro text-muted-foreground",children:g("gitView.pr.field.description")}),s.jsxs("div",{className:"flex items-center",children:[s.jsx(us,{sideOffset:8,label:g("contextTooltips.git.generateDescription"),children:s.jsxs(ft,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:cs,disabled:fe||$e,children:[fe?s.jsx(oe,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(oe,{name:"ai-generate-2",className:"size-3.5 text-primary"}),g("gitView.commit.generate")]})}),s.jsxs(gn,{children:[s.jsx(us,{sideOffset:8,label:g("gitView.pr.generate.optionsAria"),children:s.jsx(xn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:fe||$e,"aria-label":g("gitView.pr.generate.optionsAria"),children:s.jsx(oe,{name:"arrow-down-s",className:"size-3.5"})})})}),s.jsx(bn,{align:"end",className:"w-60",children:s.jsxs(Gt,{onSelect:()=>Je(!0),children:[s.jsx(oe,{name:"sticky-note",className:"size-4 shrink-0"}),g("gitView.pr.generate.withNotes")]})})]})]})]}),No?s.jsxs("div",{className:"relative",children:[s.jsx(Pa,{value:L,onChange:I=>ne(I.target.value),className:"min-h-[72px] pe-9",placeholder:g("gitView.pr.placeholder.additionalContext"),"aria-label":g("gitView.pr.generate.notesAria"),autoFocus:Me&&!L}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{ne(""),Je(!1)},"aria-label":g("gitView.pr.generate.removeNotesAria"),children:s.jsx(oe,{name:"close",className:"size-3.5"})})}),s.jsx(jt,{children:s.jsx("p",{children:g("gitView.pr.generate.removeNotesAria")})})]})]}):null,s.jsx(Pa,{id:Is,value:P,onChange:I=>de(I.target.value),className:"min-h-[140px]",placeholder:g("gitView.pr.placeholder.whatChanged"),autoCorrect:_?"on":"off",autoCapitalize:_?"sentences":"off",spellCheck:_})]})]}),zn&&!x?s.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[s.jsx(oe,{name:"arrow-up",className:"size-3.5 shrink-0"}),zn]}):null,s.jsx("div",{className:"flex justify-end",children:x?s.jsx(us,{sideOffset:8,label:g("contextTooltips.git.pushForReview"),children:s.jsxs(ft,{size:"sm",className:"justify-center gap-2",onClick:()=>{Kt()},disabled:D,children:[$e?s.jsx(oe,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(oe,{name:"upload-2",className:"size-4"}),s.jsx("span",{children:g("gitView.change.push.forReview")})]})}):s.jsxs("div",{className:"flex items-center",children:[s.jsx(us,{sideOffset:8,label:g("contextTooltips.git.createChangeRequest"),children:s.jsxs(ft,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:rs,disabled:Eo,children:[$e?s.jsx(oe,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(oe,{name:q?"git-pr-draft":"git-pull-request",className:"size-4"}),s.jsx("span",{children:Sr})]})}),s.jsxs(gn,{children:[s.jsx(us,{sideOffset:8,label:g("gitView.pr.createKindAria"),children:s.jsx(xn,{asChild:!0,children:s.jsx(ft,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:$e,"aria-label":g("gitView.pr.createKindAria"),children:s.jsx(oe,{name:"arrow-down-s",className:"size-4"})})})}),s.jsx(bn,{align:"end",className:"w-56",children:s.jsxs(zc,{value:q?"draft":"ready",onValueChange:I=>Ps(I==="draft"),children:[s.jsx(Kr,{value:"ready",children:g("gitView.pr.actions.createPr")}),s.jsx(Kr,{value:"draft",children:g("gitView.pr.actions.createDraftPr")})]})})]})]})}),ls.dialogs,v.dialog]})]})]})},Ww=()=>{const t=Le.c(98),{t:e}=rt(),{git:n,sourceControl:r}=Es(),o=Zs();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=po(d??null),p=lh(d??null),h=ch(d??null),x=Bc(d,r),{ensureAll:g,ensureNestedRepos:b,selectNestedRepo:w}=Mn(ai(Uw)),j=st(Vw),v=st(Hw),T=st(qw),F=st(Kw);let _;t[1]!==o?(_=Yt(o),t[1]=o,t[2]=_):_=t[2];const A=_;let M;e:{if(!A){M=void 0;break e}let ge;t[3]!==F||t[4]!==A||t[5]!==T?(ge=Vr(F,A)??Vr(T.values(),A),t[3]=F,t[4]=A,t[5]=T,t[6]=ge):ge=t[6],M=ge}const S=M;let k;t[7]!==j||t[8]!==S||t[9]!==v?.open||t[10]!==T?(k=()=>{if(j)return T.get(j)??S;if(v?.open)return S},t[7]=j,t[8]=S,t[9]=v?.open,t[10]=T,t[11]=k):k=t[11],v?.open;let C;t[12]!==k?(C=k(),t[12]=k,t[13]=C):C=t[13];const y=C;let E;t[14]!==j?(E=ge=>j?ge.getAttachment(j):void 0,t[14]=j,t[15]=E):E=t[15];const B=Pc(E),$=B&&!B.degraded&&!B.legacy?B.worktreeRoot??void 0:void 0,O=sw(o,y,m?.current??void 0);let z,J;t[16]!==g||t[17]!==n||t[18]!==d?(z=()=>{!d||!n||g(d,n)},J=[d,g,n],t[16]=g,t[17]=n,t[18]=d,t[19]=z,t[20]=J):(z=t[19],J=t[20]),c.useEffect(z,J);const[K,ee]=c.useState(null);let V;t[21]!==$||t[22]!==O?.projectDirectory?(V=()=>{const ge=$||O?.projectDirectory;if(!ge){ee(null);return}let xe=!1;return dh(ge).then(Se=>{if(xe)return;const Be=Se.trim();ee(Be&&Be!=="HEAD"?Be:null)}).catch(()=>{xe||ee(null)}),()=>{xe=!0}},t[21]=$,t[22]=O?.projectDirectory,t[23]=V):V=t[23];const Y=O?.projectDirectory;let ae;t[24]!==$||t[25]!==Y?(ae=[$,Y],t[24]=$,t[25]=Y,t[26]=ae):ae=t[26],c.useEffect(V,ae);let P;e:{if(!p?.all){let xe;t[27]===Symbol.for("react.memo_cache_sentinel")?(xe=[],t[27]=xe):xe=t[27],P=xe;break e}let ge;t[28]!==p.all?(ge=p.all.filter(Gw).sort(),t[28]=p.all,t[29]=ge):ge=t[29],P=ge}const de=P;let q;e:{if(!p?.all){let xe;t[30]===Symbol.for("react.memo_cache_sentinel")?(xe=[],t[30]=xe):xe=t[30],q=xe;break e}let ge;t[31]!==p.all?(ge=p.all.filter(Zw).map(Xw).sort(),t[31]=p.all,t[32]=ge):ge=t[32],q=ge}const Q=q,L=m?.current??null,ne=x.contexts[0]?.primaryRemote,W=ne?p?.defaultBranches?.[ne]:void 0;let te;t[33]!==x.contexts[0]||t[34]!==x.read?.repository.remotes||t[35]!==L||t[36]!==W||t[37]!==de||t[38]!==K||t[39]!==O?.createdFromBranch?(te=()=>Zf({remoteNames:new Set(x.contexts[0]?.primaryRemote?[x.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(x.read?.repository.remotes.map(Yw)??[]),localBranches:de,worktreeCreatedFromBranch:O?.createdFromBranch,rootBranchHint:K,defaultBranch:W,headBranch:L,fallbackToConventional:!1}),t[33]=x.contexts[0],t[34]=x.read?.repository.remotes,t[35]=L,t[36]=W,t[37]=de,t[38]=K,t[39]=O?.createdFromBranch,t[40]=te):te=t[40],O?.createdFromBranch;let Z;t[41]!==te?(Z=te(),t[41]=te,t[42]=Z):Z=t[42];const Ie=Kf(d??null,L,!0,x,p,Z),fe=ec($c(o??null)?.provider);if(!o){let ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(oe,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[43]=ge):ge=t[43];let xe;t[44]!==fe||t[45]!==e?(xe=e(Vs("gitView.pullRequest.title",fe)),t[44]=fe,t[45]=e,t[46]=xe):xe=t[46];let Se;t[47]!==xe?(Se=s.jsx("div",{className:"typography-ui-header text-foreground",children:xe}),t[47]=xe,t[48]=Se):Se=t[48];let Be;t[49]!==fe||t[50]!==e?(Be=e(Vs("gitView.pullRequest.createHint",fe)),t[49]=fe,t[50]=e,t[51]=Be):Be=t[51];let Pe;t[52]!==Be?(Pe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Be}),t[52]=Be,t[53]=Pe):Pe=t[53];let Me;return t[54]!==Se||t[55]!==Pe?(Me=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ge,Se,Pe]}),t[54]=Se,t[55]=Pe,t[56]=Me):Me=t[56],Me}if(f){let ge;return t[57]!==f.directory||t[58]!==f.message?(ge=s.jsx(Gf,{directory:f.directory,message:f.message}),t[57]=f.directory,t[58]=f.message,t[59]=ge):ge=t[59],ge}if(a===!1&&h!==!0){let ge;t[60]!==o||t[61]!==b?(ge=()=>{b(o,{force:!0})},t[60]=o,t[61]=b,t[62]=ge):ge=t[62];let xe;return t[63]!==o||t[64]!==h||t[65]!==u||t[66]!==a||t[67]!==ge?(xe=s.jsx(Xf,{root:o,rootIsGitRepo:a,resolvedIsGitRepo:h,nestedRepos:u,onRetryDiscovery:ge}),t[63]=o,t[64]=h,t[65]=u,t[66]=a,t[67]=ge,t[68]=xe):xe=t[68],xe}if(!L){let ge;t[69]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(oe,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[69]=ge):ge=t[69];let xe;t[70]!==fe||t[71]!==e?(xe=e(Vs("gitView.pullRequest.title",fe)),t[70]=fe,t[71]=e,t[72]=xe):xe=t[72];let Se;t[73]!==xe?(Se=s.jsx("div",{className:"typography-ui-header text-foreground",children:xe}),t[73]=xe,t[74]=Se):Se=t[74];let Be;t[75]!==fe||t[76]!==e?(Be=e(Vs("gitView.pullRequest.createHint",fe)),t[75]=fe,t[76]=e,t[77]=Be):Be=t[77];let Pe;t[78]!==Be?(Pe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Be}),t[78]=Be,t[79]=Pe):Pe=t[79];let Me;return t[80]!==Se||t[81]!==Pe?(Me=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ge,Se,Pe]}),t[80]=Se,t[81]=Pe,t[82]=Me):Me=t[82],Me}let je;t[83]!==o||t[84]!==d||t[85]!==l||t[86]!==w?(je=l?s.jsx("div",{className:"flex shrink-0 items-center border-b border-edge px-4 py-2",children:s.jsx(uh,{repositories:l,selectedRepository:d??null,onSelectRepository:ge=>{o&&w(o,ge)},repositoryRoot:o??void 0})}):null,t[83]=o,t[84]=d,t[85]=l,t[86]=w,t[87]=je):je=t[87];const $e=d??o,Re=m?.tracking??void 0,Fe=m?.ahead??0;let Ve;t[88]!==Ie||t[89]!==L||t[90]!==Q||t[91]!==$e||t[92]!==Re||t[93]!==Fe?(Ve=s.jsx(gs,{as:fh,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(zw,{directory:$e,branch:L,baseBranch:Ie,trackingBranch:Re,ahead:Fe,remoteBranches:Q})}),t[88]=Ie,t[89]=L,t[90]=Q,t[91]=$e,t[92]=Re,t[93]=Fe,t[94]=Ve):Ve=t[94];let De;return t[95]!==je||t[96]!==Ve?(De=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[je,Ve]}),t[95]=je,t[96]=Ve,t[97]=De):De=t[97],De};function Uw(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function Vw(t){return t.currentSessionId}function Hw(t){return t.newSessionDraft}function qw(t){return t.worktreeMetadata}function Kw(t){return t.availableWorktrees}function Gw(t){return!t.startsWith("remotes/")}function Zw(t){return t.startsWith("remotes/")}function Xw(t){return t.replace(/^remotes\//,"")}function Yw(t){return t.name}const Md=[],Jw=t=>{const e=Le.c(17),n=mo(),r=Wc();let o;e[0]!==t.url||e[1]!==r||e[2]!==n?(o=Uc(t.url,n,r),e[0]=t.url,e[1]=r,e[2]=n,e[3]=o):o=e[3];const i=o;Yf(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)&&(Ln(u),G.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"?s.jsx(ey,{url:u,provider:i.provider,identifier:i.identifier,visible:t.visible,onUnavailable:f,onShown:p}):s.jsx(Qw,{...t,kind:i.kind,onUnavailable:f,onShown:p}):s.jsx(Xi,{url:u});h=s.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},Xn=t=>{const e=Le.c(8),{message:n,onRetry:r}=t,{t:o}=rt();let i;e[0]!==n?(i=s.jsx("span",{children:n}),e[0]=n,e[1]=i):i=e[1];let a;e[2]!==r||e[3]!==o?(a=r?s.jsx(ft,{size:"sm",variant:"outline",onClick:r,children:o("references.picker.actions.retry")}):null,e[2]=r,e[3]=o,e[4]=a):a=e[4];let d;return e[5]!==i||e[6]!==a?(d=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,a]}),e[5]=i,e[6]=a,e[7]=d):d=e[7],d},Xi=t=>{const e=Le.c(14),{url:n}=t,{t:r}=rt();let o;e[0]!==r?(o=r("contextPanel.tracker.unavailable"),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=s.jsx("span",{children:o}),e[2]=o,e[3]=i):i=e[3];let a;e[4]!==n?(a=()=>{Ln(n)},e[4]=n,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=s.jsx(ft,{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=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,u]}),e[11]=i,e[12]=u,e[13]=l):l=e[13],l},rl=t=>{const e=Le.c(25),{enabled:n,directory:r,url:o,kind:i,linked:a}=t;let d;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==a||e[4]!==o?(d={enabled:n,directory:r,kind:i,filter:Da,query:o,linked:a},e[0]=r,e[1]=n,e[2]=i,e[3]=a,e[4]=o,e[5]=d):d=e[5];const u=Ra(d),l=mo();let f;e[6]!==o||e[7]!==l?(f=C=>C.find(y=>kh(y.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 C=i==="issue"?wh(o,l):null,y=l.match(o);p=C?.descriptor.terminology.sharedNumberSpace&&y?yh(C,"pull",y.number):null,e[9]=i,e[10]=o,e[11]=l,e[12]=p}else p=e[12];const h=p,x=ty,[g,b]=Ut.useState(null),w=g===o;n&&h&&!w&&x(u)&&!m(u.items)&&b(o);const j=n&&w&&h!==null,v=h??"";let T;e[13]!==r||e[14]!==a||e[15]!==j||e[16]!==v?(T={enabled:j,directory:r,kind:"pull",filter:Da,query:v,linked:a},e[13]=r,e[14]=a,e[15]=j,e[16]=v,e[17]=T):T=e[17];const F=Ra(T),_=w?F:u;let A;e[18]!==_.items||e[19]!==m?(A=m(_.items),e[18]=_.items,e[19]=m,e[20]=A):A=e[20];const M=A,S=n&&x(_)&&!M;let k;return e[21]!==_||e[22]!==M||e[23]!==S?(k={lookup:_,reference:M,missing:S},e[21]=_,e[22]=M,e[23]=S,e[24]=k):k=e[24],k},Qw=t=>{const e=Le.c(128),{url:n,directory:r,panelDirectory:o,foreign:i,visible:a,kind:d,onUnavailable:u,onShown:l}=t,{t:f}=rt(),{sourceControl:m}=Es(),p=ts(sy),h=hh(r,n),x=h.directory,g=mo(),b=gh(x),w=b&&b!=="missing"?b:null,j=h.status==="ready";let v;e[0]!==d||e[1]!==x||e[2]!==j||e[3]!==n?(v={enabled:j,directory:x,url:n,kind:d,linked:!1},e[0]=d,e[1]=x,e[2]=j,e[3]=n,e[4]=v):v=e[4];const T=rl(v);let F;e[5]!==n||e[6]!==g?(F=g.match(n),e[5]=n,e[6]=g,e[7]=F):F=e[7];const _=F,A=w!==null&&_?.provider===w.provider&&_.instance===w.instance,M=h.status==="ready"&&!T.reference&&(T.missing||T.lookup.status==="error"&&!h.owned),S=M&&A;let k;e[8]!==d||e[9]!==x||e[10]!==S||e[11]!==n?(k={enabled:S,directory:x,url:n,kind:d,linked:!0},e[8]=d,e[9]=x,e[10]=S,e[11]=n,e[12]=k):k=e[12];const C=rl(k),y=T.reference??C.reference,E=T.reference||!M?T.lookup:C.lookup,B=y?.linked===!0;let $;e[13]!==w||e[14]!==B?($=w&&B?{...w,linked:!0}:w,e[13]=w,e[14]=B,e[15]=$):$=e[15];const O=$,z=B?null:O;let J;if(e[16]!==E.followed||e[17]!==y?.number){let He;e[19]!==y?.number?(He=Ze=>!jh(Ze)&&Ze.number===y?.number,e[19]=y?.number,e[20]=He):He=e[20],J=E.followed.filter(He),e[16]=E.followed,e[17]=y?.number,e[18]=J}else J=e[18];Wi(a?J:Md);const ee=M&&!y&&(!A||C.missing||C.lookup.status==="error");let V,Y;e[21]!==u||e[22]!==ee?(V=()=>{ee&&u()},Y=[u,ee],e[21]=u,e[22]=ee,e[23]=V,e[24]=Y):(V=e[23],Y=e[24]),Ut.useEffect(V,Y);const ae=y!==null;let P,de;e[25]!==ae||e[26]!==l?(P=()=>{ae&&l()},de=[ae,l],e[25]=ae,e[26]=l,e[27]=P,e[28]=de):(P=e[27],de=e[28]),Ut.useEffect(P,de);const{detail:q,refresh:Q}=Mc(x,y,!0);let L;e[29]!==y?(L=y?[y]:[],e[29]=y,e[30]=L):L=e[30];const ne=xh(x,L),W=uc(y),[te,Z]=Ut.useState(!1),me=Fi(),{retry:Ie}=E;let fe;e[31]!==Q||e[32]!==Ie?(fe=()=>Promise.all([Q(),Ie()]).then(ny),e[31]=Q,e[32]=Ie,e[33]=fe):fe=e[33];const je=fe,$e=fc(y,z,je),Re=Li(),Fe=q.status==="ready"?q.value.pull?.stack??null:null;let Ve;e[34]!==y||e[35]!==je||e[36]!==m||e[37]!==z?(Ve=async()=>{if(z&&y){const He={owner:y.sourceRepo.owner,repo:y.sourceRepo.repo,number:y.number};await m.refreshProviderReads(z,{item:He}).catch(ry),Fc(He)}await je()},e[34]=y,e[35]=je,e[36]=m,e[37]=z,e[38]=Ve):Ve=e[38];const De=Ve;if(!y){if(ee){let Ze;return e[39]!==n?(Ze=s.jsx(Xi,{url:n}),e[39]=n,e[40]=Ze):Ze=e[40],Ze}if(h.status==="failed"){let Ze;e[41]!==f?(Ze=f("gitView.empty.discoverFailed"),e[41]=f,e[42]=Ze):Ze=e[42];let Qe;return e[43]!==h.retry||e[44]!==Ze?(Qe=s.jsx(Xn,{message:Ze,onRetry:h.retry}),e[43]=h.retry,e[44]=Ze,e[45]=Qe):Qe=e[45],Qe}let He;return e[46]!==E.error||e[47]!==E.status||e[48]!==Ie||e[49]!==f?(He=E.status==="error"?s.jsx(Xn,{message:E.error??f("contextPanel.tracker.loadFailed"),onRetry:()=>{Ie()}}):s.jsx(Xn,{message:f("common.loading")}),e[46]=E.error,e[47]=E.status,e[48]=Ie,e[49]=f,e[50]=He):He=e[50],He}let ge;e[51]!==y?(ge={source:"repository",reference:y},e[51]=y,e[52]=ge):ge=e[52];const xe=ge,Se=y.kind==="pull"?y:null;let Be;e[53]!==Se||e[54]!==ne?(Be=Se?ne(Se):Bi,e[53]=Se,e[54]=ne,e[55]=Be):Be=e[55];let Pe;e[56]===Symbol.for("react.memo_cache_sentinel")?(Pe={status:"idle"},e[56]=Pe):Pe=e[56];let Me;e[57]!==je?(Me=()=>{je()},e[57]=je,e[58]=Me):Me=e[58];let Je;e[59]!==O||e[60]!==xe||e[61]!==Fe||e[62]!==Me?(Je=s.jsx(_i,{item:xe,project:null,context:O,onStartWorktree:iy,onChanged:Me,worktreeAvailable:!1,stack:Fe}),e[59]=O,e[60]=xe,e[61]=Fe,e[62]=Me,e[63]=Je):Je=e[63];let X;e[64]!==r||e[65]!==Re?(X=He=>{Re(He.url,r)},e[64]=r,e[65]=Re,e[66]=X):X=e[66];let Ee;e[67]!==O||e[68]!==Se?(Ee=Se&&O?()=>Z(!0):void 0,e[67]=O,e[68]=Se,e[69]=Ee):Ee=e[69];const _e=O?De:void 0;let pe;e[70]!==q.status||e[71]!==q.value||e[72]!==xe||e[73]!==y||e[74]!==je||e[75]!==z?(pe=y.state!=="merged"&&z&&(y.kind!=="discussion"||bh(y,q.status==="ready"?q.value.discussion:void 0))?s.jsx(Qf,{item:xe,context:z,onChanged:()=>{je()}}):void 0,e[70]=q.status,e[71]=q.value,e[72]=xe,e[73]=y,e[74]=je,e[75]=z,e[76]=pe):pe=e[76];let R;e[77]!==W.attachComment||e[78]!==W.attachComments?(R={onAttach:W.attachComment,onAttachAll:W.attachComments},e[77]=W.attachComment,e[78]=W.attachComments,e[79]=R):R=e[79];let ie;e[80]!==y||e[81]!==je||e[82]!==z?(ie=z?s.jsx(hc,{reference:y,context:z,onChanged:je}):void 0,e[80]=y,e[81]=je,e[82]=z,e[83]=ie):ie=e[83];let Ce;e[84]!==q||e[85]!==Se||e[86]!==je||e[87]!==z?(Ce=Se&&z?s.jsx(gc,{pull:Se,detail:q,context:z,onChanged:je}):void 0,e[84]=q,e[85]=Se,e[86]=je,e[87]=z,e[88]=Ce):Ce=e[88];let Ne;e[89]!==q.status||e[90]!==q.value||e[91]!==y||e[92]!==je||e[93]!==z?(Ne=z&&(q.status!=="ready"||q.value.discussion?.canComment!==!1)?s.jsx(pc,{reference:y,context:z,onRefresh:je}):void 0,e[89]=q.status,e[90]=q.value,e[91]=y,e[92]=je,e[93]=z,e[94]=Ne):Ne=e[94];let ze;e[95]!==p||e[96]!==O||e[97]!==r||e[98]!==i||e[99]!==o||e[100]!==Se||e[101]!==x?(ze=Se&&O?s.jsx(xc,{pull:Se,project:{id:p??"",path:r},repository:x,context:O,projectOwnsDirectory:()=>!i,currentDirectory:o}):null,e[95]=p,e[96]=O,e[97]=r,e[98]=i,e[99]=o,e[100]=Se,e[101]=x,e[102]=ze):ze=e[102];let qe;e[103]!==q||e[104]!==xe||e[105]!==me||e[106]!==x||e[107]!==Be||e[108]!==Je||e[109]!==X||e[110]!==Ee||e[111]!==_e||e[112]!==pe||e[113]!==R||e[114]!==ie||e[115]!==Ce||e[116]!==Ne||e[117]!==ze||e[118]!==$e?(qe=s.jsx($i,{item:xe,directory:x,pullStatus:Be,trackerDetail:Pe,repositoryDetail:q,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:oy,now:me,footer:Je,onOpenStackLayer:X,onOpenChecks:Ee,onRefresh:_e,threadActions:$e,stateMenu:pe,commentAttachments:R,labelsControl:ie,reviewersControl:Ce,reply:Ne,pullLinks:ze}),e[103]=q,e[104]=xe,e[105]=me,e[106]=x,e[107]=Be,e[108]=Je,e[109]=X,e[110]=Ee,e[111]=_e,e[112]=pe,e[113]=R,e[114]=ie,e[115]=Ce,e[116]=Ne,e[117]=ze,e[118]=$e,e[119]=qe):qe=e[119];let Ue;e[120]!==W.attachFailedChecks||e[121]!==te||e[122]!==O||e[123]!==Se?(Ue=Se&&O?s.jsx(mc,{pull:Se,context:O,open:te,onOpenChange:Z,onAttachFailed:W.attachFailedChecks}):null,e[120]=W.attachFailedChecks,e[121]=te,e[122]=O,e[123]=Se,e[124]=Ue):Ue=e[124];let tt;return e[125]!==qe||e[126]!==Ue?(tt=s.jsxs(s.Fragment,{children:[qe,Ue]}),e[125]=qe,e[126]=Ue,e[127]=tt):tt=e[127],tt},ey=t=>{const e=Le.c(50),{url:n,provider:r,identifier:o,visible:i,onUnavailable:a,onShown:d}=t,{t:u}=rt(),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);Wi(i?h:Md);const x=Li(),g=Fi(),b=l!=="ready",w=m.status==="error",j=m.status==="ready";let v,T;e[4]!==b||e[5]!==w||e[6]!==a?(v=()=>{(b||w)&&a()},T=[b,w,a],e[4]=b,e[5]=w,e[6]=a,e[7]=v,e[8]=T):(v=e[7],T=e[8]),Ut.useEffect(v,T);let F,_;if(e[9]!==d||e[10]!==j?(F=()=>{j&&d()},_=[d,j],e[9]=d,e[10]=j,e[11]=F,e[12]=_):(F=e[11],_=e[12]),Ut.useEffect(F,_),b){let O;return e[13]!==n?(O=s.jsx(Xi,{url:n}),e[13]=n,e[14]=O):O=e[14],O}if(m.status==="error"){let O;e[15]!==m.error||e[16]!==u?(O=m.error||u("contextPanel.tracker.loadFailed"),e[15]=m.error,e[16]=u,e[17]=O):O=e[17];let z;e[18]!==p?(z=()=>{p()},e[18]=p,e[19]=z):z=e[19];let J;return e[20]!==O||e[21]!==z?(J=s.jsx(Xn,{message:O,onRetry:z}),e[20]=O,e[21]=z,e[22]=J):J=e[22],J}if(m.status!=="ready"){let O;e[23]!==u?(O=u("common.loading"),e[23]=u,e[24]=O):O=e[24];let z;return e[25]!==O?(z=s.jsx(Xn,{message:O}),e[25]=O,e[26]=z):z=e[26],z}let A;e[27]!==m.value||e[28]!==r?(A={source:"tracker",provider:r,item:m.value},e[27]=m.value,e[28]=r,e[29]=A):A=e[29];const M=A;let S;e[30]===Symbol.for("react.memo_cache_sentinel")?(S={status:"idle"},e[30]=S):S=e[30];let k;e[31]!==p?(k=()=>{p()},e[31]=p,e[32]=k):k=e[32];let C;e[33]!==M||e[34]!==k?(C=s.jsx(_i,{item:M,project:null,context:null,onStartWorktree:ly,onChanged:k,worktreeAvailable:!1}),e[33]=M,e[34]=k,e[35]=C):C=e[35];let y;e[36]!==p?(y=()=>{p()},e[36]=p,e[37]=y):y=e[37];let E;e[38]!==m.value||e[39]!==y?(E=s.jsx(Jf,{item:m.value,onChanged:y}),e[38]=m.value,e[39]=y,e[40]=E):E=e[40];let B;e[41]!==x?(B=O=>{x(O.url,null)},e[41]=x,e[42]=B):B=e[42];let $;return e[43]!==m||e[44]!==M||e[45]!==g||e[46]!==E||e[47]!==B||e[48]!==C?($=s.jsx($i,{item:M,directory:null,pullStatus:Bi,trackerDetail:m,repositoryDetail:S,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:ay,now:g,footer:C,trackerStateControl:E,onOpenTrackerItem:B}),e[43]=m,e[44]=M,e[45]=g,e[46]=E,e[47]=B,e[48]=C,e[49]=$):$=e[49],$};function ty(t){return(t.status==="ready"||t.status==="unavailable")&&!t.refreshing}function sy(t){return t.activeProjectId}function ny(){}function ry(){}function oy(){}function iy(){}function ay(){}function ly(){}const Zr=new Map,cy=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},dy=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},uy=(t,e)=>{if(e.length===0)return Zr;const n=new Set(e),r=new Map,o=new Map;for(const i of t)for(const a of i.session){if(!n.has(a.id))continue;const d=a.title?.trim();if(!d)continue;const u=dy(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?Zr:o},yo=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,fy=t=>t.kind==="record",py=t=>{const e=Le.c(5),{node:n}=t,r=n.tone==="string"?"text-foreground":"font-mono text-muted-foreground";let o;e[0]!==r?(o=We("whitespace-pre-wrap break-words",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==n.text||e[3]!==o?(i=s.jsx("span",{dir:"auto",className:o,children:n.text}),e[2]=n.text,e[3]=o,e[4]=i):i=e[4],i},my=t=>{const e=Le.c(4),{node:n}=t;let r;e[0]!==n.entries?(r=n.entries.map(hy),e[0]=n.entries,e[1]=r):r=e[1];let o;return e[2]!==r?(o=s.jsx("dl",{className:"flex flex-col gap-1.5",children:r}),e[2]=r,e[3]=o):o=e[3],o},vo=t=>{const e=Le.c(13),{node:n}=t;if(n.kind==="scalar"){let i;return e[0]!==n?(i=s.jsx(py,{node:n}),e[0]=n,e[1]=i):i=e[1],i}if(n.kind==="record"){let i;return e[2]!==n?(i=s.jsx(my,{node:n}),e[2]=n,e[3]=i):i=e[3],i}if(n.items.length===0){let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"font-mono text-muted-foreground",children:"[]"}),e[4]=i):i=e[4],i}if(n.items.every(fy)){let i;e[5]!==n.items?(i=n.items.map(gy),e[5]=n.items,e[6]=i):i=e[6];let a;return e[7]!==i?(a=s.jsx("div",{className:"flex flex-col gap-1.5",children:i}),e[7]=i,e[8]=a):a=e[8],a}let r;e[9]!==n.items?(r=n.items.map(xy),e[9]=n.items,e[10]=r):r=e[10];let o;return e[11]!==r?(o=s.jsx("ul",{className:"flex list-disc flex-col gap-0.5 ps-4",children:r}),e[11]=r,e[12]=o):o=e[12],o},Fd=t=>{const e=Le.c(24),{answer:n}=t,{t:r}=rt(),[o,i]=c.useState(!1);if(n.kind==="text"){let g;return e[0]!==n.text?(g=s.jsx(Ch,{content:n.text,singleTilde:!1,className:"typography-markdown-body",enableFileReferences:!1}),e[0]=n.text,e[1]=g):g=e[1],g}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>i(by),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=s.jsx(St,{asChild:!0,children:s.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=s.jsx(jt,{sideOffset:6,children:f}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==u||e[15]!==m?(p=s.jsx("div",{className:"flex justify-end",children:s.jsxs(kt,{children:[u,m]})}),e[14]=u,e[15]=m,e[16]=p):p=e[16];let h;e[17]!==n.tree||e[18]!==n.value||e[19]!==o?(h=o?s.jsx("pre",{dir:"ltr",className:"overflow-x-auto whitespace-pre-wrap break-words font-mono typography-meta text-foreground",children:JSON.stringify(n.value,null,2)}):s.jsx(vo,{node:n.tree}),e[17]=n.tree,e[18]=n.value,e[19]=o,e[20]=h):h=e[20];let x;return e[21]!==p||e[22]!==h?(x=s.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 hy(t){const[e,n]=t,r=n.kind==="scalar"&&n.text.length<=60&&!n.text.includes(`
|
|
5
|
-
`);return s.jsxs("div",{className:We("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[s.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),s.jsx("dd",{className:"min-w-0 typography-meta",children:s.jsx(vo,{node:n})})]},e)}function gy(t,e){return s.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:s.jsx(vo,{node:t})},e)}function xy(t,e){return s.jsx("li",{className:"typography-meta",children:s.jsx(vo,{node:t})},e)}function by(t){return!t}const Ld=t=>t.slice(t.indexOf("/")+1),Yi=t=>{const e=Le.c(7),{start:n,end:r,className:o}=t,i=Dh(n!==void 0&&r===void 0);if(n===void 0)return null;let a;e[0]!==o?(a=We("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const d=(r??i)-n;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=s.jsx("span",{className:a,dir:"auto",children:u}),e[4]=a,e[5]=u,e[6]=l):l=e[6],l},wy=t=>{const e=t.flatMap(o=>o.startedAt===void 0||o.replayed?[]:[o.startedAt]);if(e.length===0)return{start:void 0,end:void 0};const n=t.some(o=>o.state==="running"||o.state==="queued"),r=t.flatMap(o=>o.endedAt===void 0?[]:[o.endedAt]);return{start:Math.min(...e),end:n?void 0:Math.max(...r,...e)}},yy=t=>{const e=Le.c(18),{run:n,groups:r}=t,{t:o}=rt();let i,a,d,u,l,f;if(e[0]!==r||e[1]!==n||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=r.filter(Ty);if(p.length===0){f=null;break e}i=gs,a="overlay-scrollbar-wrapper--no-gutter",d=!1,u="flex gap-1.5 pb-1";let h;e[9]!==n||e[10]!==o?(h=x=>{const g=x.agents.length,b=wy(x.agents),w=n.state==="running"&&n.currentPhase===x.title;return s.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[s.jsx("div",{className:We("truncate typography-meta",w?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?s.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):s.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?s.jsx(Yi,{start:b.start,end:b.end,className:"ms-auto"}):null]}),s.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?s.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(x.done/g*100)}%`,background:x.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},x.title)},e[9]=n,e[10]=o,e[11]=h):h=e[11],l=p.map(h)}e[0]=r,e[1]=n,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=s.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},vy=t=>{const e=Le.c(30),{run:n,agent:r,onOpenSession:o}=t,{t:i}=rt(),[a,d]=c.useState(null),[u,l]=c.useState(!1),[f,m]=c.useState(!1);let p;e[0]!==r.key||e[1]!==n.id?(p=()=>{let T=!0;return l(!1),Ah(n.id,r.key).then(F=>{T&&d(F)}).catch(()=>{T&&l(!0)}),()=>{T=!1}},e[0]=r.key,e[1]=n.id,e[2]=p):p=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==n.id?(h=[r.key,r.state,n.id],e[3]=r.key,e[4]=r.state,e[5]=n.id,e[6]=h):h=e[6],c.useEffect(p,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?s.jsx("p",{className:"typography-meta",style:{color:r.state==="failed"?"var(--status-error)":void 0},children:r.error}):null,e[7]=r.error,e[8]=r.state,e[9]=x):x=e[9];let g;e[10]!==u||e[11]!==i?(g=u?s.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 b;e[13]!==a||e[14]!==u||e[15]!==i?(b=!a&&!u?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),s.jsx(Hi,{})]}):null,e[13]=a,e[14]=u,e[15]=i,e[16]=b):b=e[16];let w;e[17]!==a||e[18]!==f||e[19]!==i?(w=a?s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),s.jsx("div",{className:"mt-1",children:a.result===void 0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):s.jsx(Fd,{answer:a.result})})]}),s.jsxs("section",{children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>m(Ny),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(oe,{name:"arrow-right-s",className:We("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]})}),s.jsx(jt,{sideOffset:6,children:i(f?"contextTooltips.workspace.workflow.promptHide":"contextTooltips.workspace.workflow.promptShow")})]}),f?s.jsx(gs,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:!0,children:a.prompt}):null]})]}):null,e[17]=a,e[18]=f,e[19]=i,e[20]=w):w=e[20];let j;e[21]!==o||e[22]!==i?(j=o?s.jsx("div",{children:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[s.jsx(oe,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}),s.jsx(jt,{sideOffset:6,children:i("contextTooltips.workspace.workflow.agentSession")})]})}):null,e[21]=o,e[22]=i,e[23]=j):j=e[23];let v;return e[24]!==x||e[25]!==g||e[26]!==b||e[27]!==w||e[28]!==j?(v=s.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[x,g,b,w,j]}),e[24]=x,e[25]=g,e[26]=b,e[27]=w,e[28]=j,e[29]=v):v=e[29],v},Sy=t=>{const e=Le.c(57),{run:n,agent:r,showModel:o,columns:i,open:a,onToggle:d,onOpenSession:u}=t,{t:l}=rt();let f,m,p,h,x,g,b,w,j,v,T;if(e[0]!==r||e[1]!==i.tokens||e[2]!==d||e[3]!==a||e[4]!==o||e[5]!==l){const S=Ph(r.state),k=Rh(r);f="button",h=d,x=a,g=r.label,b="flex h-7 w-full min-w-0 items-center gap-2 rounded-md text-start typography-meta text-foreground/80 hover:text-foreground";const C=S.icon,y=S.color?{color:S.color}:void 0,E=l(S.labelKey);e[17]!==S||e[18]!==y||e[19]!==E?(w=s.jsx(oe,{name:C,className:"size-3.5 shrink-0",style:y,"aria-label":E}),e[17]=S,e[18]=y,e[19]=E,e[20]=w):w=e[20],e[21]!==r.label?(j=s.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?(v=r.replayed?s.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]=v):v=e[25],e[26]!==r.model||e[27]!==o?(T=o&&r.model?s.jsx("span",{className:"oc-tile-inset max-w-[9rem] shrink-0 truncate rounded-full px-1.5 typography-micro text-muted-foreground",title:r.model,dir:"ltr",children:Ld(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=T):T=e[28];const B=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==B?(m=s.jsx(Yi,{start:B,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=B,e[31]=m):m=e[31],p=i.tokens?s.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:k===null||r.replayed?"":Ui(k)}):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]=b,e[13]=w,e[14]=j,e[15]=v,e[16]=T}else f=e[6],m=e[7],p=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13],j=e[14],v=e[15],T=e[16];let F;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(F=i.cost?s.jsx("span",{className:"min-w-14 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"ltr",children:r.usage&&!r.replayed&&r.usage.cost>0?Vi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=F):F=e[35];let _;e[36]!==f||e[37]!==m||e[38]!==p||e[39]!==F||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==b||e[44]!==w||e[45]!==j||e[46]!==v||e[47]!==T?(_=s.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:b,children:[w,j,v,T,m,p,F]}),e[36]=f,e[37]=m,e[38]=p,e[39]=F,e[40]=h,e[41]=x,e[42]=g,e[43]=b,e[44]=w,e[45]=j,e[46]=v,e[47]=T,e[48]=_):_=e[48];let A;e[49]!==r||e[50]!==u||e[51]!==a||e[52]!==n?(A=a?s.jsx(vy,{run:n,agent:r,onOpenSession:u}):null,e[49]=r,e[50]=u,e[51]=a,e[52]=n,e[53]=A):A=e[53];let M;return e[54]!==_||e[55]!==A?(M=s.jsxs(s.Fragment,{children:[_,A]}),e[54]=_,e[55]=A,e[56]=M):M=e[56],M},ky=(t,e)=>{const n=Ih(t);if(n.measured===0)return null;const r=[];return e.tokens&&r.push(Ui(n.tokens)),e.cost&&n.cost>0&&r.push(Vi(n.cost)),r.length>0?r.join(" · "):null},jy=t=>{const e=new Set(t.map(r=>r.model??null)),[n]=e;return e.size===1&&n?Ld(n):null},Cy=t=>{const e=Le.c(51),{run:n,directory:r}=t,{t:o}=rt();let i;e[0]!==n?(i=Th(n),e[0]=n,e[1]=i):i=e[1];const a=i,d=Nh(r),[u,l]=c.useState(Ey),[f,m]=c.useState(Iy);let p,h,x,g,b,w;if(e[2]!==a||e[3]!==u||e[4]!==d||e[5]!==n||e[6]!==o||e[7]!==f){const T=Eh(n),F=T.measured>0,_=T.cost>0;let A,M,S;if(e[14]!==a||e[15]!==u||e[16]!==d||e[17]!==n||e[18]!==o||e[19]!==F||e[20]!==_||e[21]!==f){const k={tokens:F,cost:_},C=n.agents.filter(Py).length,y=Ry;b="flex h-full min-h-0 flex-col";let E;e[28]!==a||e[29]!==n?(E=s.jsx(yy,{run:n,groups:a}),e[28]=a,e[29]=n,e[30]=E):E=e[30];const B=a.map($=>{if($.agents.length===0)return null;const O=$.title??"",z=$.done+$.failed===$.agents.length,K=(n.state==="running"&&z)===f.has(O),ee=jy($.agents),V=ky($.agents,k);return s.jsxs("section",{className:"mt-3",children:[s.jsxs("button",{type:"button",onClick:()=>y(m,O),"aria-expanded":K,className:"flex h-7 w-full min-w-0 items-center gap-1.5 text-start typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(oe,{name:"arrow-right-s",className:We("size-3.5 shrink-0 transition-transform",K&&"rotate-90 rtl:-rotate-90")}),s.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:$.title??o("chat.workflow.phase.unphased")}),ee?s.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${ee}`}):null,V?s.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:V}):null,s.jsx("span",{className:We("shrink-0 tabular-nums font-normal",!V&&"ms-auto"),dir:"auto",children:V?`· ${$.done}/${$.agents.length}`:`${$.done}/${$.agents.length}`})]}),K?$.agents.map(Y=>{const ae=Y.sessionId;return s.jsx(Sy,{run:n,agent:Y,showModel:ee===null,columns:k,open:u.has(Y.key),onToggle:()=>y(l,Y.key),onOpenSession:ae?()=>d(ae,Y.label):null},Y.key)}):null]},O)});e[31]!==E||e[32]!==B?(w=s.jsxs(gs,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[E,B]}),e[31]=E,e[32]=B,e[33]=w):w=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",A="tabular-nums",M="auto",S=o("workflows.panel.summary.agents",{done:C,total:n.agents.length}),e[14]=a,e[15]=u,e[16]=d,e[17]=n,e[18]=o,e[19]=F,e[20]=_,e[21]=f,e[22]=A,e[23]=M,e[24]=S,e[25]=p,e[26]=b,e[27]=w}else A=e[22],M=e[23],S=e[24],p=e[25],b=e[26],w=e[27];e[34]!==A||e[35]!==M||e[36]!==S?(h=s.jsx("span",{className:A,dir:M,children:S}),e[34]=A,e[35]=M,e[36]=S,e[37]=h):h=e[37],e[38]!==n.endedAt||e[39]!==n.startedAt||e[40]!==n.state?(x=n.startedAt!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx(Yi,{start:n.startedAt,end:n.state==="running"?void 0:n.endedAt??n.startedAt})]}):null,e[38]=n.endedAt,e[39]=n.startedAt,e[40]=n.state,e[41]=x):x=e[41],g=T.measured>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:Ui(T.tokens)})}),T.cost>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"ltr",children:Vi(T.cost)})]}):null]}):null,e[2]=a,e[3]=u,e[4]=d,e[5]=n,e[6]=o,e[7]=f,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=b,e[13]=w}else p=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13];let j;e[42]!==p||e[43]!==h||e[44]!==x||e[45]!==g?(j=s.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 v;return e[47]!==b||e[48]!==w||e[49]!==j?(v=s.jsxs("div",{className:b,children:[w,j]}),e[47]=b,e[48]=w,e[49]=j,e[50]=v):v=e[50],v};function Ty(t){return t.title!==null}function Ny(t){return!t}function Ey(){return new Set}function Iy(){return new Set}function Py(t){return t.state==="completed"}function Ry(t,e){return t(n=>{const r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})}const Dy={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},_y=[{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"}],Ay=1500,Oy=(t,e)=>{const n=Le.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;n[0]!==t.id||n[1]!==u?(f=()=>{if(!u)return;let g=!0;const b=d.current?.runId===t.id?d.current.at:0,w=Math.max(0,b+Ay-Date.now()),j=setTimeout(()=>{d.current={runId:t.id,at:Date.now()},Vh(t.id).then(v=>{g&&(o(v),a(null))}).catch(()=>{g&&a(t.id)})},w);return()=>{g=!1,clearTimeout(j)}},n[0]=t.id,n[1]=u,n[2]=f):f=n[2];let m;n[3]!==l||n[4]!==t.id||n[5]!==t.state||n[6]!==u?(m=[l,t.id,t.state,u],n[3]=l,n[4]=t.id,n[5]=t.state,n[6]=u,n[7]=m):m=n[7],c.useEffect(f,m);const p=r?.runId===t.id?r:null,h=i===t.id;let x;return n[8]!==p||n[9]!==h?(x={detail:p,failed:h},n[8]=p,n[9]=h,n[10]=x):x=n[10],x},My=t=>new Intl.DateTimeFormat(qc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),Fy=t=>{const e=Le.c(8),{run:n,detail:r}=t,{t:o}=rt(),i=r?.logs??n.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=s.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=s.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=d):d=e[7],d},Ly=t=>{const e=Le.c(24),{run:n,detail:r,failed:o}=t,{t:i}=rt();if(n.error&&(n.state==="failed"||n.state==="stopped")){const u=n.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]!==n.error||e[3]!==l?(f=s.jsx("p",{className:"px-4 py-6 typography-meta",style:l,children:n.error}),e[2]=n.error,e[3]=l,e[4]=f):f=e[4],f}if(n.state==="awaiting-approval"||n.state==="running"||n.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=s.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=s.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=s.jsx(Hi,{}),e[15]=l):l=e[15];let f;return e[16]!==u?(f=s.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=s.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=s.jsx("div",{className:"px-4 py-3",children:s.jsx(Fd,{answer:a})}),e[22]=a,e[23]=d):d=e[23],d},$y=t=>{const e=Le.c(16),{detail:n,failed:r}=t,{t:o}=rt();if(!n){let m;e[0]!==r||e[1]!==o?(m=r?o("workflows.panel.detail.loadFailed"):s.jsxs(s.Fragment,{children:[o("workflows.panel.agent.loading"),s.jsx(Hi,{})]}),e[0]=r,e[1]=o,e[2]=m):m=e[2];let p;return e[3]!==m?(p=s.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=n.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?s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),s.jsx(gs,{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]!==n.script?(l=s.jsx(gs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:n.script}),e[11]=n.script,e[12]=l):l=e[12];let f;return e[13]!==u||e[14]!==l?(f=s.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=Le.c(83),{run:n}=t,{t:r}=rt(),{pending:o,act:i}=Uh(),a=o===n.id;if(n.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]!==n.id?(u=()=>i(n.id,"approve"),e[2]=i,e[3]=n.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=s.jsx(oe,{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=s.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=s.jsxs(ft,{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=s.jsx(us,{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 b;e[22]!==i||e[23]!==n.id?(b=()=>i(n.id,"decline"),e[22]=i,e[23]=n.id,e[24]=b):b=e[24];let w;e[25]!==r?(w=r("chat.workflow.action.decline"),e[25]=r,e[26]=w):w=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(oe,{name:"close",className:"size-3.5"}),e[27]=j):j=e[27];let v;e[28]!==r?(v=r("chat.workflow.action.decline"),e[28]=r,e[29]=v):v=e[29];let T;e[30]!==v?(T=s.jsx("span",{className:"workflows-header__action-label",children:v}),e[30]=v,e[31]=T):T=e[31];let F;e[32]!==a||e[33]!==b||e[34]!==w||e[35]!==T?(F=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:b,"aria-label":w,children:[j,T]}),e[32]=a,e[33]=b,e[34]=w,e[35]=T,e[36]=F):F=e[36];let _;e[37]!==F||e[38]!==g?(_=s.jsx(us,{label:g,side:"bottom",className:"shrink-0",children:F}),e[37]=F,e[38]=g,e[39]=_):_=e[39];let A;return e[40]!==_||e[41]!==x?(A=s.jsxs(s.Fragment,{children:[x,_]}),e[40]=_,e[41]=x,e[42]=A):A=e[42],A}if(n.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]!==n.id?(u=()=>i(n.id,"stop"),e[45]=i,e[46]=n.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=s.jsx(oe,{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=s.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=s.jsxs(ft,{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=s.jsx(us,{label:d,side:"bottom",className:"shrink-0",children:h}),e[60]=d,e[61]=h,e[62]=x):x=e[62],x}if(n.state==="failed"||n.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]!==n.id?(u=()=>i(n.id,"resume"),e[65]=i,e[66]=n.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=s.jsx(oe,{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=s.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=s.jsxs(ft,{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=s.jsx(us,{label:d,side:"bottom",className:"shrink-0",children:h}),e[80]=d,e[81]=h,e[82]=x):x=e[82],x}return null},zy=()=>{const t=Le.c(2),e=ps(Gy);let n;return t[0]!==e?(n={get:r=>e.get(r)?.title},t[0]=e,t[1]=n):n=t[1],n},ol=t=>{const e=Le.c(31),{run:n,selected:r,caption:o,onSelect:i}=t,{t:a}=rt();let d,u,l,f,m,p,h;if(e[0]!==i||e[1]!==n.state||e[2]!==a){const T=Hc(n.state);u=Gt,h=i,d=oe,l=T.icon,f="size-3.5 shrink-0",m=T.color?{color:T.color}:void 0,p=a(T.labelKey),e[0]=i,e[1]=n.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=s.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]!==n.name?(g=s.jsx("span",{className:"truncate",dir:"auto",children:n.name}),e[16]=n.name,e[17]=g):g=e[17];let b;e[18]!==o?(b=o?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=b):b=e[19];let w;e[20]!==g||e[21]!==b?(w=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,b]}),e[20]=g,e[21]=b,e[22]=w):w=e[22];let j;e[23]!==r?(j=r?s.jsx(oe,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=j):j=e[24];let v;return e[25]!==u||e[26]!==j||e[27]!==h||e[28]!==x||e[29]!==w?(v=s.jsxs(u,{onSelect:h,children:[x,w,j]}),e[25]=u,e[26]=j,e[27]=h,e[28]=x,e[29]=w,e[30]=v):v=e[30],v},Wy=t=>{const e=Le.c(63),{runs:n,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:d,onRunSaved:u,onDelete:l}=t,{t:f}=rt();let m;e[0]!==r.state?(m=Hc(r.state),e[0]=r.state,e[1]=m):m=e[1];const p=m;let h,x,g,b,w,j,v;if(e[2]!==p.color||e[3]!==p.icon||e[4]!==d||e[5]!==n||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const M=n.slice().reverse();let S;e[18]!==o?(S=Y=>Y.parentSessionId===o,e[18]=o,e[19]=S):S=e[19];const k=M.filter(S);let C;e[20]!==o?(C=Y=>Y.parentSessionId!==o,e[20]=o,e[21]=C):C=e[21];const y=M.filter(C);x=gn;let E;e[22]!==f?(E=f("workflows.panel.runPicker"),e[22]=f,e[23]=E):E=e[23];let B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=We(Wh(),"max-w-[14rem] shrink-0"),e[24]=B):B=e[24];let $;e[25]!==p.color?($=p.color?{color:p.color}:void 0,e[25]=p.color,e[26]=$):$=e[26];let O;e[27]!==p.icon||e[28]!==$?(O=s.jsx(oe,{name:p.icon,className:"size-3.5",style:$}),e[27]=p.icon,e[28]=$,e[29]=O):O=e[29];let z;e[30]!==r.name?(z=s.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=z):z=e[31];let J;e[32]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(oe,{name:"arrow-down-s",className:"size-4"}),e[32]=J):J=e[32];let K;e[33]!==O||e[34]!==z||e[35]!==E?(K=s.jsx(St,{asChild:!0,children:s.jsx(xn,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":E,className:B,children:[O,z,J]})})}),e[33]=O,e[34]=z,e[35]=E,e[36]=K):K=e[36];let ee;e[37]!==f?(ee=f("contextTooltips.workspace.workflow.pickRun"),e[37]=f,e[38]=ee):ee=e[38];let V;e[39]!==ee?(V=s.jsx(jt,{side:"bottom",sideOffset:6,children:ee}),e[39]=ee,e[40]=V):V=e[40],e[41]!==K||e[42]!==V?(v=s.jsxs(kt,{children:[K,V]}),e[41]=K,e[42]=V,e[43]=v):v=e[43],h=bn,g="start",b="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",w=k.length>0?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{children:f("workflows.panel.picker.thisSession")}),k.map(Y=>s.jsx(ol,{run:Y,selected:Y.id===r.id,onSelect:()=>d(Y.id)},Y.id))]}):null,j=y.length>0?s.jsxs(s.Fragment,{children:[k.length>0?s.jsx(mn,{}):null,s.jsx(Ar,{children:f("workflows.panel.picker.otherSessions")}),y.map(Y=>s.jsx(ol,{run:Y,selected:Y.id===r.id,caption:i.get(Y.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>d(Y.id)},Y.id))]}):null,e[2]=p.color,e[3]=p.icon,e[4]=d,e[5]=n,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=i,e[10]=f,e[11]=h,e[12]=x,e[13]=g,e[14]=b,e[15]=w,e[16]=j,e[17]=v}else h=e[11],x=e[12],g=e[13],b=e[14],w=e[15],j=e[16],v=e[17];let T;e[44]!==u||e[45]!==a||e[46]!==f?(T=a.length>0?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsx(Ar,{children:f("workflows.panel.picker.saved")}),a.map(M=>s.jsxs(Gt,{disabled:!!M.error,onSelect:()=>u(M.name),title:M.error??M.description,children:[s.jsx(oe,{name:"play",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:M.name})]},M.name))]}):null,e[44]=u,e[45]=a,e[46]=f,e[47]=T):T=e[47];let F;e[48]!==l||e[49]!==f?(F=l?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsxs(Gt,{variant:"destructive",onSelect:l,children:[s.jsx(oe,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[48]=l,e[49]=f,e[50]=F):F=e[50];let _;e[51]!==h||e[52]!==g||e[53]!==b||e[54]!==w||e[55]!==j||e[56]!==T||e[57]!==F?(_=s.jsxs(h,{align:g,className:b,children:[w,j,T,F]}),e[51]=h,e[52]=g,e[53]=b,e[54]=w,e[55]=j,e[56]=T,e[57]=F,e[58]=_):_=e[58];let A;return e[59]!==x||e[60]!==v||e[61]!==_?(A=s.jsxs(x,{children:[v,_]}),e[59]=x,e[60]=v,e[61]=_,e[62]=A):A=e[62],A},Uy=(t,e,n,r)=>{const o=Le.c(11),{t:i}=rt(),{confirm:a,dialog:d}=zi(),u=qi(Zy);let l;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==u||o[4]!==r||o[5]!==n||o[6]!==i?(l=async p=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:p}),message:i(n?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const x=await Lh({directory:t,scriptDirectory:e,sessionId:n,name:p});n?u(r,x.runId):(u(x.sessionId,x.runId),st.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;Te.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]=n,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},Vy=t=>{const e=Le.c(23),{saved:n,onRunSaved:r}=t,{t:o}=rt();if(n.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=s.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=s.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=s.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]!==n||e[14]!==o){let m;e[16]!==r||e[17]!==o?(m=p=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:p.name}),p.description||p.error?s.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:p.error??p.description,children:p.error??p.description}):null]}),s.jsx(us,{label:o("workflows.panel.saved.runAria",{name:p.name}),className:"shrink-0",children:s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:!!p.error,onClick:()=>r(p.name),"aria-label":o("workflows.panel.saved.runAria",{name:p.name}),children:[s.jsx(oe,{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=n.map(m),e[12]=r,e[13]=n,e[14]=o,e[15]=l}else l=e[15];let f;return e[19]!==a||e[20]!==u||e[21]!==l?(f=s.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},Hy=t=>{const e=Le.c(17),{directory:n}=t,r=st(Xy),o=Oh(n),i=Mh(o),a=Fh(o?.savedDirectory??null),d=r??`directory:${n??""}`;let u;e[0]!==d?(u=b=>b.selectedBySession[d],e[0]=d,e[1]=u):u=e[1];const l=qi(u),{run:f,dialog:m}=Uy(n,o?.savedDirectory??null,r,d);let p;e[2]!==i||e[3]!==l||e[4]!==r?(p=i.find(b=>b.id===l)??i.filter(b=>b.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]!==n||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==d||e[12]!==r?(x=h?s.jsx(qy,{sessionId:r,selectionKey:d,runs:i,saved:a,run:h,directory:n,onRunSaved:b=>{f(b)}}):s.jsx(Vy,{saved:a,onRunSaved:b=>{f(b)}}),e[6]=n,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=s.jsxs(s.Fragment,{children:[m,x]}),e[14]=m,e[15]=x,e[16]=g):g=e[16],g},qy=t=>{const e=Le.c(58),{sessionId:n,selectionKey:r,runs:o,saved:i,run:a,directory:d,onRunSaved:u}=t,{t:l}=rt(),f=qi(Yy),m=zy(),[p,h]=c.useState("agents"),{detail:x,failed:g}=Oy(a,p),b=c.useRef(null);$h(b,Dy);const{confirm:w,dialog:j}=zi(),v=a.state==="running"||a.state==="awaiting-approval",T=a.parentSessionId!==n;let F;e[0]!==w||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==l?(F=async()=>{if(await w({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 Bh(a.id),zh.getState().remove(a.parentSessionId,a.id)}catch(Y){const ae=Y;Te.error(l("workflows.panel.delete.failed"),{description:ae instanceof Error?ae.message:void 0})}},e[0]=w,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=l,e[5]=F):F=e[5];const _=F;let A;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(A=()=>{f(a.parentSessionId,a.id),st.getState().setCurrentSession(a.parentSessionId,a.directory)},e[6]=a.directory,e[7]=a.id,e[8]=a.parentSessionId,e[9]=f,e[10]=A):A=e[10];const M=A;let S;e[11]!==f||e[12]!==r?(S=V=>f(r,V),e[11]=f,e[12]=r,e[13]=S):S=e[13];let k;e[14]!==_||e[15]!==v?(k=v?null:()=>{_()},e[14]=_,e[15]=v,e[16]=k):k=e[16];let C;e[17]!==u||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==n||e[22]!==m||e[23]!==S||e[24]!==k?(C=s.jsx(Wy,{runs:o,selected:a,sessionId:n,sessionTitles:m,saved:i,onSelect:S,onRunSaved:u,onDelete:k}),e[17]=u,e[18]=a,e[19]=o,e[20]=i,e[21]=n,e[22]=m,e[23]=S,e[24]=k,e[25]=C):C=e[25];let y;e[26]!==l?(y=l("workflows.panel.view.label"),e[26]=l,e[27]=y):y=e[27];let E;e[28]!==l||e[29]!==p?(E=_y.map(V=>{const Y=V.id===p;return s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>h(V.id),"aria-current":Y?"page":void 0,"aria-label":l(V.labelKey),className:We("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",Y?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(oe,{name:V.icon,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:l(V.labelKey)})]})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:l(V.tooltipKey)})]},V.id)}),e[28]=l,e[29]=p,e[30]=E):E=e[30];let B;e[31]!==y||e[32]!==E?(B=s.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":y,children:E}),e[31]=y,e[32]=E,e[33]=B):B=e[33];let $;e[34]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=$):$=e[34];let O;e[35]!==T||e[36]!==M||e[37]!==a.parentSessionId||e[38]!==m||e[39]!==l?(O=T?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{type:"button",size:"sm",variant:"ghost",onClick:M,"aria-label":l("workflows.panel.agent.openSession"),children:[s.jsx(oe,{name:"chat-4",className:"size-3.5"}),s.jsx("span",{className:"workflows-header__action-label",children:l("workflows.panel.agent.openSession")})]})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:m.get(a.parentSessionId)||l("workflows.panel.picker.untitledSession")})]}):null,e[35]=T,e[36]=M,e[37]=a.parentSessionId,e[38]=m,e[39]=l,e[40]=O):O=e[40];let z;e[41]!==a?(z=s.jsx(By,{run:a}),e[41]=a,e[42]=z):z=e[42];let J;e[43]!==O||e[44]!==z||e[45]!==C||e[46]!==B?(J=s.jsx(Vc,{children:s.jsxs("div",{ref:b,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[C,B,$,O,z]})}),e[43]=O,e[44]=z,e[45]=C,e[46]=B,e[47]=J):J=e[47];let K;e[48]!==x||e[49]!==d||e[50]!==g||e[51]!==a||e[52]!==p?(K=p==="agents"?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(Cy,{run:a,directory:d},a.id)}):s.jsxs(gs,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[p==="log"?s.jsx(Fy,{run:a,detail:x}):null,p==="result"?s.jsx(Ly,{run:a,detail:x,failed:g}):null,p==="script"?s.jsx($y,{detail:x,failed:g}):null]}),e[48]=x,e[49]=d,e[50]=g,e[51]=a,e[52]=p,e[53]=K):K=e[53];let ee;return e[54]!==j||e[55]!==J||e[56]!==K?(ee=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,J,K]}),e[54]=j,e[55]=J,e[56]=K,e[57]=ee):ee=e[57],ee};function Ky(t,e){return s.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:My(t.at)}),s.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function Gy(t){return t.entityById}function Zy(t){return t.select}function Xy(t){return t.currentSessionId}function Yy(t){return t.select}const il=60,Jy=t=>{try{return new URL(t).origin}catch{return""}},Wo=new Set,$d=bo()((t,e)=>({byOrigin:{},resolve:(n,r,o)=>{const i=Jy(n);!i||!r||e().byOrigin[i]||Wo.has(i)||(Wo.add(i),Tn("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(()=>{Wo.delete(i)}))}})),Ji=t=>t,fi=t=>{const e=Ji(t).type;return typeof e=="string"?e:""},Qy=t=>{const e=Ji(t).tool;return typeof e=="string"?e:""},ev=t=>{const e=Ji(t).text;return typeof e=="string"?e:""},tv=t=>{const e=fi(t);return e==="tool"?Qy(t).trim().toLowerCase()||"tool":e||"unknown"},sv=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=tv(n);e.includes(r)||e.push(r)}return e.join(" + ")},nv=t=>t.replace(/\s+/g," ").trim(),rv=t=>{for(const n of t)if(fi(n)==="text"){const r=nv(ev(n));if(r.length===0)continue;return r}const e=t.filter(n=>fi(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},ov=(t,e,n)=>`${n(t)} / ${n(e)}`,iv=t=>{if(t==="12h")return!0;if(t==="24h")return!1},av=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=iv(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},lv=(t,{windowTokens:e,compacted:n=!1})=>{const r=n?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},pi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Xr={user:0,assistant:0,tool:0,other:0},Bs=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Bd=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...pi,total:Bs(n)};if(!n||typeof n!="object")return pi;const r=n,o=Bs(r.input),i=Bs(r.output),a=Bs(r.reasoning),d=Bs(r.cache?.read),u=Bs(r.cache?.write),l=Bs(r.total);return{input:o,output:i,reasoning:a,cacheRead:d,cacheWrite:u,total:l>0?l:o+i+a+d+u}},cv=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},bs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+bs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+bs(n),0):0,dv=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Xr,assistant:bs(n.text)+bs(n.content)};const o=cv(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:bs(n.input)+bs(n.output)+bs(n.error)+bs(n.call?.input)+bs(n.call?.output)+bs(n.call?.error)+bs(n.raw)+Math.round(bs(n.metadata)*.25)+Math.round(bs(n.state)*.1)+Math.round((qu(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}},zd=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),uv=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",al=new WeakMap,fv=t=>{const e=al.get(t);if(e)return e;const n=uv(t);let r={...Xr};for(const o of t.parts)r=zd(r,dv(o,n));return al.set(t,r),r},pv=(t,e)=>{if(t.length===0)return{...Xr};const n=t.reduce((r,o)=>zd(r,fv(o)),{...Xr});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},un=t=>t.toLocaleString(qc()),mv=(t,e)=>!t||!Number.isFinite(t)?"-":Yh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),hv=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},ll=t=>{const e=Le.c(21),{title:n,figures:r}=t,{t:o}=rt();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]!==n){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]!==n?(u=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:n}),e[12]=n,e[13]=u):u=e[13],i="grid grid-cols-3 gap-x-4 gap-y-2.5",a=m.map(bv),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]=n,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=s.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=s.jsxs("div",{className:d,children:[u,l]}),e[17]=d,e[18]=u,e[19]=l,e[20]=f):f=e[20],f},gv=c.memo(function(e){const n=Le.c(54),{message:r,isExpanded:o,isCopied:i,timeFormatPreference:a,onToggle:d,onCopy:u}=e,{t:l}=rt(),f=r.info.role,m=f==="assistant",p=f==="user",h=r.info.time?.created??null;let x;n[0]!==r.parts?(x=sv(r.parts),n[0]=r.parts,n[1]=x):x=n[1];const g=x;let b,w,j,v;if(n[2]!==m||n[3]!==p||n[4]!==r||n[5]!==h||n[6]!==g||n[7]!==a){const J=m?Bd(r):null;let K;n[12]!==p||n[13]!==r.parts?(K=p?rv(r.parts):"",n[12]=p,n[13]=r.parts,n[14]=K):K=n[14],v=K;let ee;n[15]!==h||n[16]!==a?(ee=av(h,a),n[15]=h,n[16]=a,n[17]=ee):ee=n[17],w=ee,b=g||"—",j=J?ov(J.input,J.output,un):"",n[2]=m,n[3]=p,n[4]=r,n[5]=h,n[6]=g,n[7]=a,n[8]=b,n[9]=w,n[10]=j,n[11]=v}else b=n[8],w=n[9],j=n[10],v=n[11];const T=j,F=f||"unknown",_=g?`${F}: ${g}`:F;let A;n[18]!==o||n[19]!==r.info||n[20]!==r.parts?(A=o?JSON.stringify({info:r.info,parts:r.parts},null,2):"",n[18]=o,n[19]=r.info,n[20]=r.parts,n[21]=A):A=n[21];const M=A;let S;n[22]!==r.info.id||n[23]!==d?(S=()=>d(r.info.id),n[22]=r.info.id,n[23]=d,n[24]=S):S=n[24];const k=m?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content";let C;n[25]!==k?(C={gridTemplateColumns:k},n[25]=k,n[26]=C):C=n[26];let y;n[27]!==b||n[28]!==T||n[29]!==m||n[30]!==p||n[31]!==_||n[32]!==v?(y=p?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",v]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:m?b:_}),m&&s.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:T})]}),n[27]=b,n[28]=T,n[29]=m,n[30]=p,n[31]=_,n[32]=v,n[33]=y):y=n[33];let E;n[34]!==w?(E=s.jsx("span",{className:"text-end text-muted-foreground",children:w}),n[34]=w,n[35]=E):E=n[35];let B;n[36]!==C||n[37]!==y||n[38]!==E?(B=s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:C,children:[y,E]}),n[36]=C,n[37]=y,n[38]=E,n[39]=B):B=n[39];let $;n[40]!==o||n[41]!==S||n[42]!==B?($=s.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:S,children:B}),n[40]=o,n[41]=S,n[42]=B,n[43]=$):$=n[43];let O;n[44]!==i||n[45]!==o||n[46]!==M||n[47]!==r.info.id||n[48]!==u||n[49]!==l?(O=o&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs(gs,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[s.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:J=>{J.stopPropagation(),u(r.info.id,M)},"aria-label":l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),children:i?s.jsx(oe,{name:"check",className:"size-3.5"}):s.jsx(oe,{name:"file-copy",className:"size-3.5"})})}),s.jsx(jt,{sideOffset:6,children:l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson")})]})}),s.jsx(Hh,{language:"json",code:M,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})}),n[44]=i,n[45]=o,n[46]=M,n[47]=r.info.id,n[48]=u,n[49]=l,n[50]=O):O=n[50];let z;return n[51]!==$||n[52]!==O?(z=s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[$,O]}),n[51]=$,n[52]=O,n[53]=z):z=n[53],z}),xv=()=>{const t=Le.c(216),{t:e}=rt(),n=qh(),r=G(wv);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=st(yv),m=st(vv),p=Kh(m??void 0),h=Gh(f??"",m??void 0),x=Wt(Sv);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),a(kv),u(null)},t[1]=g):g=t[1];let b;t[2]!==m||t[3]!==f?(b=[m,f],t[2]=m,t[3]=f,t[4]=b):b=t[4],c.useEffect(g,b);let w,j;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},j=[],t[5]=w,t[6]=j):(w=t[5],j=t[6]),c.useEffect(w,j);let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=Ke=>{a(ct=>({...ct,[Ke]:ct[Ke]!==!0}))},t[7]=v):v=t[7];const T=v;let F;t[8]===Symbol.for("react.memo_cache_sentinel")?(F=async(Ke,ct)=>{(await wr(ct)).ok?(u(Ke),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{u(ht=>ht===Ke?null:ht),l.current=null},2e3)):u(null)},t[8]=F):F=t[8];const _=F;let A,M,S,k,C,y,E,B,$,O,z,J,K,ee;if(t[9]!==f||t[10]!==x||t[11]!==h||t[12]!==p||t[13]!==e){C=f?p.find(as=>as.id===f)??null:null,A=h.filter(jv);let Ke;t[28]!==h?(Ke=h.filter(Cv),t[28]=h,t[29]=Ke):Ke=t[29],ee=Ke;let ct;t[30]!==h?(ct=Ic(h.map(Tv)),t[30]=h,t[31]=ct):ct=t[31];const Rt=ct,ht=Rt?h[Rt.index]??null:null,Ct=Rt?.state==="compacted";z=ht?Bd(ht):pi,S=Zh({input:z.input,cache:{read:z.cacheRead,write:z.cacheWrite}}),J=Number.isFinite(C?.cost)?Bs(C?.cost):A.reduce(Nv,0);const lt=ht?.info??null,Et=x,qt=lt?.providerID||"",dt=lt?.modelID||"";let ut;t[32]!==Et||t[33]!==qt||t[34]!==dt?(ut=hv(Et,qt,dt),t[32]=Et,t[33]=qt,t[34]=dt,t[35]=ut):ut=t[35],B=ut,k=B.contextLimit,K=Ct?null:k&&k>0?Math.min(999,z.total/k*100):0;const Ot=[...h].reverse().find(Ev),Zt=Ot?.info.role==="system"?Ot.info.text:"",is=pv(h,Zt);M=lv(is,{windowTokens:z.total,compacted:Ct}),y=h[0]?.info?.time?.created,E=h.length>0?h[h.length-1]?.info?.time?.created:null,$=C?.title||e("contextSidebar.session.untitled"),O=Xh(C),t[9]=f,t[10]=x,t[11]=h,t[12]=p,t[13]=e,t[14]=A,t[15]=M,t[16]=S,t[17]=k,t[18]=C,t[19]=y,t[20]=E,t[21]=B,t[22]=$,t[23]=O,t[24]=z,t[25]=J,t[26]=K,t[27]=ee}else A=t[14],M=t[15],S=t[16],k=t[17],C=t[18],y=t[19],E=t[20],B=t[21],$=t[22],O=t[23],z=t[24],J=t[25],K=t[26],ee=t[27];const V=C?.time?.created??y??null,Y=E??C?.time?.created??null;let ae;t[36]!==A.length||t[37]!==M||t[38]!==S||t[39]!==k||t[40]!==B||t[41]!==h.length||t[42]!==Y||t[43]!==$||t[44]!==O||t[45]!==V||t[46]!==z||t[47]!==J||t[48]!==K||t[49]!==ee.length?(ae={sessionTitle:$,sessionTotals:O,messagesCount:h.length,userMessagesCount:ee.length,assistantMessagesCount:A.length,createdAt:V,lastActivityAt:Y,providerModel:B,tokenBreakdown:z,usagePercent:K,cacheHitRate:S,totalAssistantCost:J,contextLimit:k,breakdown:M,breakdownTotal:M.total},t[36]=A.length,t[37]=M,t[38]=S,t[39]=k,t[40]=B,t[41]=h.length,t[42]=Y,t[43]=$,t[44]=O,t[45]=V,t[46]=z,t[47]=J,t[48]=K,t[49]=ee.length,t[50]=ae):ae=t[50];const P=ae;if(!f){let Ke;t[51]!==e?(Ke=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Ke):Ke=t[52];let ct;return t[53]!==Ke?(ct=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ke}),t[53]=Ke,t[54]=ct):ct=t[54],ct}let de;t[55]!==e?(de=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=de):de=t[56];let q;t[57]!==de||t[58]!==P.breakdown.user?(q={key:"user",label:de,value:P.breakdown.user,color:"var(--status-success)"},t[57]=de,t[58]=P.breakdown.user,t[59]=q):q=t[59];let Q;t[60]!==e?(Q=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=Q):Q=t[61];let L;t[62]!==Q||t[63]!==P.breakdown.assistant?(L={key:"assistant",label:Q,value:P.breakdown.assistant,color:"var(--primary-base)"},t[62]=Q,t[63]=P.breakdown.assistant,t[64]=L):L=t[64];let ne;t[65]!==e?(ne=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=ne):ne=t[66];let W;t[67]!==ne||t[68]!==P.breakdown.tool?(W={key:"tool",label:ne,value:P.breakdown.tool,color:"var(--status-warning)"},t[67]=ne,t[68]=P.breakdown.tool,t[69]=W):W=t[69];let te;t[70]!==e?(te=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=te):te=t[71];let Z;t[72]!==te||t[73]!==P.breakdown.other?(Z={key:"other",label:te,value:P.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=te,t[73]=P.breakdown.other,t[74]=Z):Z=t[74];let me;t[75]!==q||t[76]!==L||t[77]!==W||t[78]!==Z?(me=[q,L,W,Z],t[75]=q,t[76]=L,t[77]=W,t[78]=Z,t[79]=me):me=t[79];const Ie=me;let fe;t[80]!==n||t[81]!==P.sessionTitle?(fe=n?s.jsx(Vc,{children:s.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:s.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:P.sessionTitle,children:P.sessionTitle})})}):null,t[80]=n,t[81]=P.sessionTitle,t[82]=fe):fe=t[82];let je;t[83]!==n||t[84]!==P.sessionTitle?(je=n?null:s.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:P.sessionTitle}),t[83]=n,t[84]=P.sessionTitle,t[85]=je):je=t[85];const $e=!n&&"mt-1";let Re;t[86]!==$e?(Re=We($e,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[86]=$e,t[87]=Re):Re=t[87];let Fe;t[88]!==P.providerModel.modelName||t[89]!==P.providerModel.providerName?(Fe=s.jsxs("span",{children:[P.providerModel.providerName," / ",P.providerModel.modelName]}),t[88]=P.providerModel.modelName,t[89]=P.providerModel.providerName,t[90]=Fe):Fe=t[90];let Ve;t[91]!==r||t[92]!==P.createdAt?(Ve=P.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:mv(P.createdAt,r)})]}),t[91]=r,t[92]=P.createdAt,t[93]=Ve):Ve=t[93];let De;t[94]!==Re||t[95]!==Fe||t[96]!==Ve?(De=s.jsxs("div",{className:Re,children:[Fe,Ve]}),t[94]=Re,t[95]=Fe,t[96]=Ve,t[97]=De):De=t[97];let ge;t[98]!==je||t[99]!==De?(ge=s.jsxs("div",{className:"mb-6",children:[je,De]}),t[98]=je,t[99]=De,t[100]=ge):ge=t[100];let xe;t[101]!==e?(xe=e("contextSidebar.section.context"),t[101]=e,t[102]=xe):xe=t[102];let Se;t[103]!==xe?(Se=s.jsx("span",{className:"typography-micro text-muted-foreground",children:xe}),t[103]=xe,t[104]=Se):Se=t[104];let Be;t[105]!==P.tokenBreakdown.total||t[106]!==P.usagePercent?(Be=P.usagePercent===null?"—":un(P.tokenBreakdown.total),t[105]=P.tokenBreakdown.total,t[106]=P.usagePercent,t[107]=Be):Be=t[107];let Pe;t[108]!==P.contextLimit?(Pe=P.contextLimit?` / ${un(P.contextLimit)}`:"",t[108]=P.contextLimit,t[109]=Pe):Pe=t[109];let Me;t[110]!==Be||t[111]!==Pe?(Me=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Be,Pe]}),t[110]=Be,t[111]=Pe,t[112]=Me):Me=t[112];let Je;t[113]!==Se||t[114]!==Me?(Je=s.jsxs("div",{className:"flex items-baseline justify-between",children:[Se,Me]}),t[113]=Se,t[114]=Me,t[115]=Je):Je=t[115];let X;t[116]!==P.usagePercent?(X=P.usagePercent!==null&&P.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,P.usagePercent)}%`,backgroundColor:P.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=P.usagePercent,t[117]=X):X=t[117];let Ee;t[118]!==X?(Ee=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:X}),t[118]=X,t[119]=Ee):Ee=t[119];let _e;t[120]!==e||t[121]!==P.usagePercent?(_e=P.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:P.usagePercent.toFixed(1)}),t[120]=e,t[121]=P.usagePercent,t[122]=_e):_e=t[122];let pe;t[123]!==_e?(pe=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:_e}),t[123]=_e,t[124]=pe):pe=t[124];let R;t[125]!==Je||t[126]!==Ee||t[127]!==pe?(R=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Je,Ee,pe]}),t[125]=Je,t[126]=Ee,t[127]=pe,t[128]=R):R=t[128];let ie;t[129]!==e?(ie=e("contextSidebar.stats.messages"),t[129]=e,t[130]=ie):ie=t[130];let Ce;t[131]!==P.messagesCount?(Ce=un(P.messagesCount),t[131]=P.messagesCount,t[132]=Ce):Ce=t[132];let Ne;t[133]!==ie||t[134]!==Ce?(Ne={label:ie,value:Ce},t[133]=ie,t[134]=Ce,t[135]=Ne):Ne=t[135];let ze;t[136]!==e?(ze=e("contextSidebar.stats.user"),t[136]=e,t[137]=ze):ze=t[137];let qe;t[138]!==P.userMessagesCount?(qe=un(P.userMessagesCount),t[138]=P.userMessagesCount,t[139]=qe):qe=t[139];let Ue;t[140]!==ze||t[141]!==qe?(Ue={label:ze,value:qe},t[140]=ze,t[141]=qe,t[142]=Ue):Ue=t[142];let tt;t[143]!==e?(tt=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=tt):tt=t[144];let He;t[145]!==P.assistantMessagesCount?(He=un(P.assistantMessagesCount),t[145]=P.assistantMessagesCount,t[146]=He):He=t[146];let Ze;t[147]!==tt||t[148]!==He?(Ze={label:tt,value:He},t[147]=tt,t[148]=He,t[149]=Ze):Ze=t[149];let Qe;t[150]!==e?(Qe=e("contextSidebar.stats.cost"),t[150]=e,t[151]=Qe):Qe=t[151];let ot;t[152]!==P.totalAssistantCost?(ot=md(P.totalAssistantCost),t[152]=P.totalAssistantCost,t[153]=ot):ot=t[153];let pt;t[154]!==Qe||t[155]!==ot?(pt={label:Qe,value:ot},t[154]=Qe,t[155]=ot,t[156]=pt):pt=t[156];let at;t[157]!==Ne||t[158]!==Ue||t[159]!==Ze||t[160]!==pt?(at=[Ne,Ue,Ze,pt],t[157]=Ne,t[158]=Ue,t[159]=Ze,t[160]=pt,t[161]=at):at=t[161];const xt=at;let le;t[162]!==xt?(le=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:xt.map(Iv)}),t[162]=xt,t[163]=le):le=t[163];let be;t[164]!==e?(be=e("contextSidebar.section.sessionTotals"),t[164]=e,t[165]=be):be=t[165];let Ae;t[166]!==be||t[167]!==P.sessionTotals?(Ae=s.jsx(ll,{title:be,figures:P.sessionTotals}),t[166]=be,t[167]=P.sessionTotals,t[168]=Ae):Ae=t[168];let N;t[169]!==e?(N=e("contextSidebar.section.lastAssistantMessage"),t[169]=e,t[170]=N):N=t[170];const ce=P.tokenBreakdown.input+P.tokenBreakdown.cacheRead+P.tokenBreakdown.cacheWrite,U=P.cacheHitRate.hasInput?P.cacheHitRate.percent:null;let we;t[171]!==ce||t[172]!==U||t[173]!==P.tokenBreakdown?(we={...P.tokenBreakdown,prompt:ce,cacheHitPercent:U},t[171]=ce,t[172]=U,t[173]=P.tokenBreakdown,t[174]=we):we=t[174];let ke;t[175]!==N||t[176]!==we?(ke=s.jsx(ll,{title:N,figures:we}),t[175]=N,t[176]=we,t[177]=ke):ke=t[177];let Xe;t[178]!==Ie||t[179]!==P.breakdownTotal?(Xe=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Ie.map(Ke=>Ke.value<=0||P.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${Ke.value/P.breakdownTotal*100}%`,backgroundColor:Ke.color}},Ke.key))}),t[178]=Ie,t[179]=P.breakdownTotal,t[180]=Xe):Xe=t[180];let Oe;t[181]!==Ie||t[182]!==P.breakdownTotal?(Oe=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Ie.map(Ke=>{const ct=P.breakdownTotal>0?Ke.value/P.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ke.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[Ke.label," ",s.jsxs("span",{className:"tabular-nums",children:[ct.toFixed(0),"%"]})]})]},Ke.key)})}),t[181]=Ie,t[182]=P.breakdownTotal,t[183]=Oe):Oe=t[183];let se;t[184]!==Xe||t[185]!==Oe?(se=s.jsxs("div",{className:"mb-6",children:[Xe,Oe]}),t[184]=Xe,t[185]=Oe,t[186]=se):se=t[186];let ue;t[187]!==e?(ue=e("contextSidebar.section.rawMessages"),t[187]=e,t[188]=ue):ue=t[188];let et;t[189]!==ue?(et=s.jsx("div",{className:"typography-micro text-muted-foreground",children:ue}),t[189]=ue,t[190]=et):et=t[190];let ye;if(t[191]!==d||t[192]!==i||t[193]!==h||t[194]!==r){let Ke;t[196]!==d||t[197]!==i||t[198]!==r?(Ke=ct=>s.jsx(gv,{message:ct,isExpanded:i[ct.info.id]===!0,isCopied:d===ct.info.id,timeFormatPreference:r,onToggle:T,onCopy:_},ct.info.id),t[196]=d,t[197]=i,t[198]=r,t[199]=Ke):Ke=t[199],ye=[...h].reverse().map(Ke),t[191]=d,t[192]=i,t[193]=h,t[194]=r,t[195]=ye}else ye=t[195];let bt;t[200]!==ye?(bt=s.jsx("div",{className:"mt-2.5 space-y-1",children:ye}),t[200]=ye,t[201]=bt):bt=t[201];let Tt;t[202]!==et||t[203]!==bt?(Tt=s.jsxs("div",{children:[et,bt]}),t[202]=et,t[203]=bt,t[204]=Tt):Tt=t[204];let vt;t[205]!==ge||t[206]!==R||t[207]!==le||t[208]!==Ae||t[209]!==ke||t[210]!==se||t[211]!==Tt?(vt=s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ge,R,le,Ae,ke,se,Tt]}),t[205]=ge,t[206]=R,t[207]=le,t[208]=Ae,t[209]=ke,t[210]=se,t[211]=Tt,t[212]=vt):vt=t[212];let Pt;return t[213]!==fe||t[214]!==vt?(Pt=s.jsxs(gs,{outerClassName:"h-full",className:"bg-background",children:[fe,vt]}),t[213]=fe,t[214]=vt,t[215]=Pt):Pt=t[215],Pt};function bv(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value===null?"—":t.format==="percent"?`${t.value.toFixed(1)}%`:un(t.value)})]},t.label)}function wv(t){return t.timeFormatPreference}function yv(t){return t.currentSessionId}function vv(t){return t.currentSessionDirectory}function Sv(t){return t.providers}function kv(t){return Object.keys(t).length>0?{}:t}function jv(t){return t.info.role==="assistant"}function Cv(t){return t.info.role==="user"}function Tv(t){return t.info}function Nv(t,e){const n=Bs(e.info.cost);return t+n}function Ev(t){return t.info.role==="system"}function Iv(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}const Mr=(t,e)=>{const[n,r]=c.useState(null),o=t?.id??null;return e&&n!==o&&r(o),e||n===null||n===o?t:null},Pv=280,Rv=.28,Dv=240,_v=.35,Av=(t,e,n=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=n?n.top:i-Math.min(Dv,e.height*_v),d=Math.min(Pv,t.width*Rv,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)}}},Uo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,Ov=(t,e)=>Uo(t.bottom,e)?"bottom":Uo(t.left,e)?"left":Uo(t.right,e)?"right":null,Gs=bo(()=>({drag:null,hovered:null})),Fr=t=>{if(!t)return null;const{left:e,top:n,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:n,width:r,height:o}:null},Vo=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),Ho=t=>Fr(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Wd=t=>{const e=Fr(document.querySelector("[data-workspace-row]")),n=Fr(document.querySelector("[data-workspace-chat]"));if(!e||!n)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=Av(e,n,Fr(r)),i={left:Ho("left")??Vo(o.left),right:Ho("right")??Vo(o.right),bottom:Ho("bottom")??Vo(o.bottom)};return Gs.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Ud=t=>{const{drag:e,hovered:n}=Gs.getState();if(!e)return;const r=Ov(e.targets,t);r!==n&&Gs.setState({hovered:r})},mi=()=>{Gs.getState().drag&&Gs.setState({drag:null,hovered:null})},Vd=t=>{const{drag:e,hovered:n}=Gs.getState();if(Gs.setState({drag:null,hovered:null}),!e||!n)return!1;const r=G.getState();n!==e.from&&r.moveContextSurfaceToZone(e.mode,n);const o=t?fs(t):"";if(o){const i=G.getState();Ti(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Qi=(t,e)=>{let n=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(n||(n=Wd(t)),n&&Ud(a)):n&&(mi(),n=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),n?(Vd(i),!0):!1),cancel:()=>{o(),n&&mi()}}},cl={left:null,right:null,bottom:null},ur=bo(()=>({body:cl,headerSlot:cl})),Hd=(t,e,n)=>{const r=ur.getState()[t];r[e]!==n&&ur.setState({[t]:{...r,[e]:n}})},Mv=(t,e)=>Hd("body",t,e),Fv=(t,e)=>Hd("headerSlot",t,e),Yn=t=>{const e=c.useRef(t);e.current=t;const[n,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{Mi(o)},[t,o]),c.useEffect(()=>()=>Kc(o),[o]),n},qo=t=>{const e=Yn(t);return t||e},Lv=hr(()=>Lt(()=>import("./GitView-wWoZ95Yt.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}))),ea=320,qd=320,$v=24,Bv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},dl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(ea,Math.round(t))):Pi,zv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(ea,t-qd),ul=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Lr=(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"):_n(t)?sr.getState().guests.find(r=>r.id===Ur(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Wv=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},Uv=(t,e,n)=>{if(t.mode==="chat"){const r=yo(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?oo(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Wv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Lr(t.mode,n)},Vv=t=>{const e=Le.c(8),{mode:n}=t,r=Ki();let o;if(e[0]!==n||e[1]!==r){let l;e[3]!==n?(l=f=>f.mode===n,e[3]=n,e[4]=l):l=e[4],o=r.find(l),e[0]=n,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??rg,d=i?.iconSrc;let u;return e[5]!==a||e[6]!==d?(u=s.jsx(fo,{icon:a,iconSrc:d,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u},Hv=t=>{const e=Le.c(2),{sessionId:n}=t,r=jc(n);let o;return e[0]!==r?(o=r?s.jsx(Tc,{state:r,className:"h-3.5 w-3.5"}):s.jsx(oe,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},qv=t=>{const e=Le.c(6),{url:n}=t,r=mo(),o=Wc();let i;if(e[0]!==o||e[1]!==n||e[2]!==r){const u=n?Uc(n,r,o):null;i=u?u.source==="tracker"?ng(u.provider).icon:sg[u.kind]:"git-branch",e[0]=o,e[1]=n,e[2]=r,e[3]=i}else i=e[3];const a=i;let d;return e[4]!==a?(d=s.jsx(oe,{name:a,className:"h-3.5 w-3.5"}),e[4]=a,e[5]=d):d=e[5],d},fl=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(ho,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(wc,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(oe,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(oe,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(qv,{url:t.targetPath});if(t.mode==="notes")return s.jsx(oe,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(oe,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(oe,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return s.jsx(oe,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const n=yo(t.dedupeKey);return n?s.jsx(Hv,{sessionId:n}):s.jsx(oe,{name:"chat-4",className:"h-3.5 w-3.5"})}if(_n(t.mode))return s.jsx(Vv,{mode:t.mode});if(t.mode==="browser"){const n=Kv(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(oe,{name:"global",className:"h-3.5 w-3.5"})}},Kv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Gv=t=>{const e=Zc(),n=c.useRef(Zr),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=uy(i,r.current);return cy(n.current,a)?n.current:(n.current=a,a)},[e]),()=>Zr)},Zv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Xv=8,Yv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',Jv=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Kd=320,ta=160,hi=200,Qv={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(ta,Math.round(t))):Kd,e0=t=>t===null?Number.POSITIVE_INFINITY:Math.max(ta,t-hi),Ko=({zone:t="right"})=>{const e=Qv[t],n=co(),r=e.axis==="y",{t:o,direction:i}=rt(),a=i==="rtl",d=Zs()??"",u=ec(Jh(d||null)),l=c.useCallback((re,Ye)=>o(Vs(re,u),Ye),[u,o]),f=c.useMemo(()=>Bv(d),[d]),m=G(re=>f?re.contextPanelByDirectory[f]:void 0),p=G(re=>re.contextSurfaceZones),h=G(re=>re.shortcutOverrides),x=G(re=>re.closeContextZone),g=G(re=>re.closeContextPanelTab),b=G(re=>re.pinContextPanelTab),w=G(re=>re.toggleContextPanelExpanded),j=G(re=>re.setContextZoneSize),v=G(re=>re.setContextZoneExpandedChatSize),T=G(re=>re.setActiveContextPanelTab),F=G(re=>re.reorderContextPanelTabs),_=G(re=>re.contextEditorTreeVisible),A=G(re=>re.contextEditorTreeWidth),M=G(re=>re.setContextEditorTreeWidth),S=G(re=>re.toggleContextEditorTree),k=G(re=>re.contextEditorVisible),C=G(re=>re.toggleContextEditor),y=G(re=>re.fileTreeSide),E=G(re=>re.openNewContextBrowserTab),B=$d(re=>re.byOrigin),[$,O]=c.useState(null),z=c.useCallback(re=>{O(re),Fv(t,re)},[t]),J=c.useCallback(re=>{Mv(t,re)},[t]),K=c.useMemo(()=>m?.tabs??[],[m?.tabs]),ee=m?Wr(m,p,t):null,V=m?tr(m,t):Ku,Y=Or(re=>re.workStatusReserved),ae=Or(re=>re.workStatusBesidePanel),P=Or(re=>re.chatCovered),de=t==="bottom"&&P,q=!!(V.isOpen&&ee)&&!de,Q=Mr(ee,q),L=c.useMemo(()=>K.some(re=>re.mode==="file"&&re.targetPath),[K]),ne=L&&(k||!_),W=!r&&Q?.mode==="file"&&!ne,te=!!(q&&V.expanded&&!W),Z=G(re=>re.contextZoneSizes[t]),me=W?A:r?pl(Z??Kd,Number.POSITIVE_INFINITY):dl(Z??Pi,Number.POSITIVE_INFINITY),Ie=c.useCallback((re,Ye)=>r?pl(re,e0(Ye)):dl(re,zv(Ye)),[r]),fe=r?hi:qd,je=G(re=>r?0:re.sidebarWidth),$e=G(re=>re.contextZoneExpandedChatSizes[t]),Re=Math.max(fe,$e??(r?hi:je)),Fe=t==="right"?"left":t==="left"?"right":null,Ve=G(re=>{if(!Fe||!f)return 0;const Ye=re.contextPanelByDirectory[f],gt=Ye&&Gn(Ye,re.contextSurfaceZones,Fe)?Wr(Ye,re.contextSurfaceZones,Fe):null;return Ye&>?Gu(Ye,gt,Fe,re):0}),De=Fe==="right"&&Y&&!P&&Ve===0?kn:Ve,ge=t==="right"&&Y&&!P,xe=ge&&ae&&!te,[Se,Be]=c.useState(null),Pe=c.useRef(null),Me=c.useRef(De);Me.current=De;const Je=c.useRef(q);Je.current=q;const X=c.useRef(()=>!1);X.current=re=>te||!W&&re-Me.current-fe<me;const Ee=c.useCallback(()=>{let re=Pe.current;if(re!==null&&!r&&Je.current){const Ye=document.querySelector("[data-left-sidebar]");Ye&&(re+=Math.round(Ye.getBoundingClientRect().width-(Number.parseFloat(Ye.style.width)||0)))}Be(re!==null&&X.current(re)?re:null)},[r]),_e=Se!==null?Se-De:null,pe=W?me:te&&_e!==null?Math.max(r?ta:ea,_e-Re):Ie(me,_e),R=q&&Q?.mode==="chat",ie=c.useMemo(()=>{const re=[];if(!R)return re;for(const Ye of K){if(Ye.mode!=="chat")continue;const gt=yo(Ye.dedupeKey);gt&&!re.includes(gt)&&re.push(gt)}return re},[R,K]),Ce=Gv(ie),[Ne,ze]=c.useState(!1),qe=c.useRef(0),Ue=c.useRef(pe),tt=c.useRef(null),He=c.useRef(null),Ze=c.useRef(null),Qe=c.useRef(null),ot=c.useRef(!1);c.useLayoutEffect(()=>{const re=r?Ze.current?.parentElement:Ze.current?.closest("[data-workspace-row]");if(!re||typeof ResizeObserver>"u")return;const Ye=new ResizeObserver(gt=>{const wt=gt[gt.length-1]?.contentRect,_t=r?wt?.height:wt?.width;Pe.current=_t?Math.round(_t):null,Mi(Ee)});return Ye.observe(re),Pe.current=(r?re.clientHeight:re.clientWidth)||null,Ee(),()=>{Ye.disconnect(),Kc(Ee)}},[Ee,r]);const pt=!r&&q&&(te||Se!==null),at=G(re=>pt&&re.isSidebarOpen);c.useLayoutEffect(()=>{Ee()},[Ee,me,te,q,De,at]),c.useEffect(()=>{if(!q||ot.current){ot.current=q;return}const re=window.requestAnimationFrame(()=>{Qe.current?.focus({preventScroll:!0})});return ot.current=!0,()=>window.cancelAnimationFrame(re)},[q]);const xt=c.useRef(null),le=c.useRef(null),be=c.useRef(null),Ae=c.useRef(null),N=c.useRef(!1),ce=c.useRef(null),U=c.useRef(!1),we=c.useCallback(re=>{const Ye=Ze.current,gt=ce.current;if(!Ye||!gt)return;const wt=r?"height":"width";Ye.style[wt]=U.current?`${re+kn}px`:`min(${re}px, 100%)`,gt.style[wt]=`calc(${re}px - ${e.gutterSize})`},[e.gutterSize,r]),ke=c.useCallback(()=>{le.current=null;const re=tt.current;re!==null&&we(re)},[we]);c.useEffect(()=>()=>{le.current!==null&&cancelAnimationFrame(le.current),be.current?.(),be.current=null,Ae.current?.remove(),Ae.current=null},[]);const Xe=c.useCallback(re=>{const Ye=xt.current,gt=W?Jo(re):Ie(re,Ye);return Ye===null?gt:Math.min(gt,Math.max(1,Ye))},[Ie,W]),Oe=c.useCallback(re=>{if(!q||!f)return;He.current=re.pointerId,ze(!0),qe.current=r?re.clientY:re.clientX,Ue.current=pe,tt.current=pe;const Ye=r?Ze.current?.parentElement?.clientHeight:(Ze.current?.closest("[data-workspace-row]")?.clientWidth??0)-Me.current-(xe?kn:0);xt.current=Ye&&Ye>0?Ye:null,Ae.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),Ae.current=gt,be.current?.(),be.current=Ac(r?"height":"width"),re.preventDefault()},[xe,f,q,r,pe]),se=c.useCallback(()=>{const re=Xe(tt.current??pe),Ye=xt.current;le.current!==null&&(cancelAnimationFrame(le.current),le.current=null);const gt=Ze.current,wt=ce.current;if(gt&&wt){const _t=r?"height":"width";gt.style.setProperty(e.sizeVariable,`${re}px`),gt.style[_t]=Kt.current,wt.style[_t]=Os.current}tt.current=null,xt.current=null,N.current=!0,Ae.current?.remove(),Ae.current=null,W?M(re):te?Ye!==null&&v(t,Ye-re):j(t,re),ze(!1),He.current=null,be.current?.(),be.current=null},[Xe,e.sizeVariable,te,W,r,M,v,j,pe,t]);c.useEffect(()=>{if(!Ne)return;const re=wt=>{if(He.current!==wt.pointerId)return;const _t=r?wt.clientY:wt.clientX,Vt=t==="left"?_t-qe.current:qe.current-_t,H=!r&&a?-Vt:Vt,Ge=Xe(Ue.current+H);tt.current!==Ge&&(tt.current=Ge,le.current===null&&(le.current=requestAnimationFrame(ke)))},Ye=wt=>{He.current===wt.pointerId&&se()},gt=()=>{se()};return window.addEventListener("pointermove",re),window.addEventListener("pointerup",Ye),window.addEventListener("pointercancel",Ye),window.addEventListener("blur",gt),()=>{window.removeEventListener("pointermove",re),window.removeEventListener("pointerup",Ye),window.removeEventListener("pointercancel",Ye),window.removeEventListener("blur",gt)}},[ke,Xe,se,Ne,a,r,t]),c.useEffect(()=>{Ne||(tt.current=null,Ae.current?.remove(),Ae.current=null)},[Ne]);const ue=c.useCallback(()=>{f&&x(f,t)},[x,f,t]),et=c.useCallback(()=>{f&&w(f,t)},[f,w,t]),ye=Q?.mode==="file"||Q?.mode==="chat"||Q?.mode==="browser"||Q?.mode==="pr",bt=c.useMemo(()=>{if(!Q)return[];const re=K.filter(Ye=>Ye.mode===Q.mode);return Q.mode==="pr"?[...re.filter(jr),...re.filter(Ye=>!jr(Ye))]:re},[Q,K]),Tt=po(Q?.mode==="pr"&&f?f:null)?.current??null,vt=Q?.id,Pt=c.useMemo(()=>{const re=Qh(bt.filter(Ye=>Ye.mode==="file").map(Ye=>ul(Ye.targetPath,d)));return bt.map(Ye=>{const gt=jr(Ye),wt=gt?Tt||o("contextPanel.tracker.branchTab"):Uv(Ye,Ce,l),_t=Zv(wt,$v),Vt=ul(Ye.targetPath,d);return{id:Ye.id,label:_t,labelFolder:Ye.mode==="file"?re.get(Vt):void 0,icon:fl(Ye,B),title:Vt?`${wt}: ${Vt}`:wt,closeLabel:o("contextPanel.tab.closeTabAria",{label:_t}),closeShortcut:Ye.id===vt&&_s()?ms("mod+w",""):void 0,closable:!gt,preview:Ye.preview}})},[bt,vt,d,B,Ce,o,l,Tt]),Ke=Q?.mode==="context"?s.jsx(fn,{value:$,children:s.jsx(xv,{})}):Q?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(fn,{value:$,children:s.jsx(Lv,{isActive:q})})}):Q?.mode==="pr"?Q.targetPath?s.jsx(Jw,{url:Q.targetPath,directory:Q.targetDirectory??d,panelDirectory:d,tabId:Q.id,foreign:!!Q.targetDirectory,visible:q},Q.id):s.jsx(Ww,{}):Q?.mode==="notes"?s.jsx(fn,{value:$,children:s.jsx(ep,{visible:q})}):Q?.mode==="workflows"?s.jsx(fn,{value:$,children:s.jsx(Hy,{directory:d||null})}):null,ct=Q?.mode==="file",Rt=ct&&!!Q?.targetPath&&ne,ht=q&&Q&&ye&&!Rt&&!jr(Q)?Q.id:null;c.useEffect(()=>{if(!(!f||!ht))return dc(()=>g(f,ht),Ze)},[g,f,ht]);const Ct=G(re=>re.closeContextPanelTabs),lt=c.useCallback(re=>{if(!f)return null;const{id:Ye,index:gt,allIds:wt,close:_t}=re,Vt=()=>Ct(f,wt.filter(Rs=>Rs!==Ye)),H=wt.slice(0,gt),Ge=wt.slice(gt+1),mt=()=>Ct(f,a?Ge:H),It=()=>Ct(f,a?H:Ge),$t=()=>Ct(f,wt),Bt=wt.length>1,Ft=a?gt===wt.length-1:gt===0,js=a?gt===0:gt===wt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Cs,{onClick:_t,children:[s.jsx(oe,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),s.jsx(In,{}),s.jsxs(Cs,{onClick:Vt,disabled:!Bt,children:[s.jsx(oe,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Cs,{onClick:mt,disabled:Ft,children:[s.jsx(oe,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Cs,{onClick:It,disabled:js,children:[s.jsx(oe,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),s.jsx(In,{}),s.jsxs(Cs,{onClick:$t,disabled:!Bt,children:[s.jsx(oe,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),Q?s.jsxs(s.Fragment,{children:[s.jsx(In,{}),s.jsx(bc,{mode:Q.mode})]}):null]})},[Q,Ct,f,a,o]),Et=c.useCallback((re,Ye)=>{const gt=K.find(_t=>_t.id===re);if(!gt)return null;const wt=Qi({mode:gt.mode,label:Lr(gt.mode,l),from:t},Ye);return{finish:()=>wt.finish(f),cancel:wt.cancel}},[f,l,K,t]),[qt,dt]=c.useState(null),ut=c.useCallback(re=>{if(!Q||re.button!==0||re.pointerType==="touch"||re.target instanceof Element&&re.target.closest(Yv))return;const Ye=Q.mode,gt=Lr(Ye,l),wt={x:re.clientX,y:re.clientY};let _t=!1;const Vt=It=>{const $t={x:It.clientX,y:It.clientY};!_t&&(Math.hypot($t.x-wt.x,$t.y-wt.y)<Xv||(_t=Wd({mode:Ye,label:gt,from:t}),!_t))||Ud($t)},H=()=>{window.removeEventListener("pointermove",Vt),window.removeEventListener("pointerup",Ge),window.removeEventListener("pointercancel",mt),window.removeEventListener("blur",mt)},Ge=()=>{H(),_t&&Vd(f)},mt=()=>{H(),_t&&mi()};window.addEventListener("pointermove",Vt),window.addEventListener("pointerup",Ge),window.addEventListener("pointercancel",mt),window.addEventListener("blur",mt)},[Q,f,l,t]);c.useEffect(()=>{if(qt)return qt.addEventListener("pointerdown",ut),()=>qt.removeEventListener("pointerdown",ut)},[ut,qt]);const Ot=s.jsxs("header",{ref:dt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[ye?s.jsx(eg,{items:Pt,activeId:Q?.id??null,onSelect:re=>{f&&T(f,re)},onClose:re=>{f&&g(f,re)},onReorder:(re,Ye)=>{f&&F(f,re,Ye)},onDoubleClickTab:re=>{f&&b(f,re)},layoutMode:"scrollable",variant:"default",tabContextMenu:lt,onTabDragOut:Et}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[Q?fl(Q,B):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:Q?Lr(Q.mode,l):null})]}),s.jsx("div",{ref:z,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),s.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[Q?.mode==="browser"?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&E(f)},className:"h-7 w-7 p-0","aria-label":o("contextPanel.browser.newTab"),children:s.jsx(oe,{name:"add",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.browser.newTab")})]}):null,ct?["left","right"].map(re=>{const Ye=re===y;if(!Ye&&!L)return null;const gt=o(Ye?"contextRail.editorTree.toggle":"contextRail.editor.toggle"),wt=Ye?_:ne,_t=o(Ye?wt?"contextTooltips.panel.hideFileTree":"contextTooltips.panel.showFileTree":wt?"contextTooltips.panel.hideFileEditor":"contextTooltips.panel.showFileEditor");return s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:Ye?S:C,className:"h-7 w-7 p-0","aria-label":gt,"aria-pressed":wt,children:s.jsx(oe,{name:re==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:_t})]},re)}):null,W?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:et,className:"h-7 w-7 p-0","aria-label":o(te?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:te?s.jsx(oe,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(oe,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:o(te?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:ms(Ts("toggle_context_panel_expanded",h),"")})})]}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:ue,className:"h-7 w-7 p-0","aria-label":o("contextPanel.actions.closePanel"),children:s.jsx(oe,{name:"close",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.actions.closePanel")})]})]})]}),Zt=q?xe?`calc(var(${e.sizeVariable}) + ${kn}px)`:`min(var(${e.sizeVariable}), 100%)`:ge?`${kn}px`:"0px",is=xe?`${kn}px`:"0px";U.current=xe;const as=t==="bottom"&&Gn(m,p,"left"),ss=t==="bottom"&&(Y&&!P||Gn(m,p,"right")),Xt=`${q}|${te}|${ge}|${q&&xe}|${q?me:""}`,ls=c.useRef(Xt),ns=c.useRef(P),Is=ns.current!==P;c.useLayoutEffect(()=>{ns.current=P},[P]),c.useLayoutEffect(()=>{if(ls.current===Xt)return;ls.current=Xt;const re=N.current;!Is&&!re&&_c(n)},[Xt,Is,n]),c.useLayoutEffect(()=>{N.current=!1});const Ps=!Dr(q,Yn(q),Q?.mode),cs={[e.sizeVariable]:`${pe}px`,...r?{height:Zt,maxHeight:"100%"}:{width:Zt,maxWidth:"100%"},transitionDuration:Is||Ne?"0ms":`${n}ms`,transitionTimingFunction:An},rs=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,Kt=c.useRef(Zt);Kt.current=Zt;const Os=c.useRef(rs);return Os.current=rs,s.jsxs("aside",{ref:Ze,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":q?"true":"false",tabIndex:-1,className:We("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:cs,children:[s.jsx("div",{ref:Qe,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?s.jsx("div",{ref:tg,className:We("absolute inset-y-0 z-0 flex",xe?"inset-s-0":"inset-e-0",P&&"invisible")}):null,q&&s.jsx("div",{className:e.handle,style:{marginInlineStart:is},onPointerDown:Oe,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{ref:ce,"data-zone-card":"",className:We("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(as?"ms-0":"ms-2"),t==="bottom"&&(ss?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity,margin-inline-start]",!q&&"opacity-0",Ps&&"pointer-events-none select-none"),style:{...r?{height:rs,width:`calc(100% - ${(as?0:.5)+(ss?0:.375)}rem)`}:{width:rs},...t==="right"?{marginInlineStart:`calc(0.5rem + ${is})`}:null,transitionDuration:Ne?"0ms":`${n}ms`,transitionTimingFunction:An},inert:Ps||void 0,children:s.jsxs(Gc.Provider,{value:!0,children:[Ot,s.jsx("div",{ref:J,className:"relative min-h-0 flex-1 overflow-hidden",children:Q&&Jv(Q.mode)?Ke:null})]})})]})},t0=sn({port:wo().int().positive(),url:Ns().min(1),command:Ns(),directory:Ns().min(1).optional()}),s0=t=>{const e=sn({servers:jd(mx())}).safeParse(t);return e.success?e.data.servers.flatMap(n=>{const r=t0.safeParse(n);return r.success?[r.data]:[]}):null},n0=async(t,e)=>{try{const n=await qs("/api/dev-servers",{signal:t,directory:e});if(!n.ok)return{kind:"unavailable"};const r=s0(await n.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},r0=async t=>{try{const e=await qs("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},o0=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},i0=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=o0(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0,directory:r.directory}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},a0=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),ml=(t,e)=>{if(!e)return null;let n=null;for(const r of t)a0(r.path,e)&&(!n||r.path.length>n.path.length)&&(n=r);return n},l0=t=>t.slice(t.lastIndexOf("/")+1)||t,c0=({candidates:t,folders:e,directory:n})=>{const r=e.flatMap(u=>{const l=Yt(u.path),f=Yt(u.projectPath);return l&&f?[{path:l,projectPath:f}]:[]}),o=Yt(n),i=o?{path:o,projectPath:ml(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(u=>{const l=Yt(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?l0(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)},d0=t=>({sessionId:t.sessionId,directory:t.directory?fs(t.directory):null}),u0=2e3,f0=sn({title:Ns(),settled:dr()}),p0=4e4,m0=50,Jn=400,hs=new Map,As=new Map;let gi=null,xi=null;const fr=new Map;let zs=null,en=null,Qn=null;const Ws=async t=>{try{const e=await qs("/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}},h0=async(t,e)=>{try{const n=await qs("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},Gd=async(t,e=u0)=>{const n=Date.now()+e;for(;!hs.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,m0));return hs.get(t)??null},Yr=t=>hs.has(t)||As.has(t),Fn=t=>hs.get(t)??As.get(t)??null,bi=()=>[...hs.values(),...[...As.values()].filter(t=>!hs.has(t.tabId))],sa=t=>{const e=xi?Fn(xi):null,n=e?.directory===gi?e:null;if(!t.sessionId){if(n)return n.tabId;const i=bi().filter(u=>u.directory===gi),a=i.filter(u=>hs.has(u.tabId)),d=a.length>0?a:i;return d.length>0?d[d.length-1].tabId:null}if(n?.ownerSessionId===t.sessionId)return n.tabId;const r=fr.get(t.sessionId);if(r&&Fn(r)?.ownerSessionId===t.sessionId)return r;const o=bi().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:n&&n.ownerSessionId===null&&(!t.directory||n.directory===t.directory)?n.tabId:null},g0=t=>{const e=sa(t);return e&&Fn(e)?.ownerSessionId===t.sessionId?e:null},x0=(t,e)=>{t.sessionId&&Fn(e)?.ownerSessionId===t.sessionId&&fr.set(t.sessionId,e)},Zd=async t=>{const e=hs.get(t);if(e)return e;const n=As.get(t);return n?(n.wake(),Gd(t)):null},Xd=t=>{const e=sa(t);return bi().filter(n=>!t.sessionId||!t.directory||n.ownerSessionId===t.sessionId||n.directory===t.directory).map(n=>{let r={title:"",url:""};try{r=n.describe()}catch{}const o=n.ownerSessionId===null?"user":n.ownerSessionId===t.sessionId?"you":"another session";return{id:n.tabId,title:r.title,url:r.url,owner:o,active:n.tabId===e}})},Yd=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Jd=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.`,b0=t=>{const e=Xd(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
|
|
5
|
+
`);return s.jsxs("div",{className:We("min-w-0",r?"flex items-baseline gap-2":"flex flex-col gap-0.5"),children:[s.jsx("dt",{className:"shrink-0 typography-micro text-muted-foreground",dir:"ltr",children:e}),s.jsx("dd",{className:"min-w-0 typography-meta",children:s.jsx(vo,{node:n})})]},e)}function gy(t,e){return s.jsx("div",{className:"oc-tile-inset rounded-lg px-3 py-2",children:s.jsx(vo,{node:t})},e)}function xy(t,e){return s.jsx("li",{className:"typography-meta",children:s.jsx(vo,{node:t})},e)}function by(t){return!t}const Ld=t=>t.slice(t.indexOf("/")+1),Yi=t=>{const e=Le.c(7),{start:n,end:r,className:o}=t,i=Dh(n!==void 0&&r===void 0);if(n===void 0)return null;let a;e[0]!==o?(a=We("shrink-0 whitespace-nowrap tabular-nums",o),e[0]=o,e[1]=a):a=e[1];const d=(r??i)-n;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=s.jsx("span",{className:a,dir:"auto",children:u}),e[4]=a,e[5]=u,e[6]=l):l=e[6],l},wy=t=>{const e=t.flatMap(o=>o.startedAt===void 0||o.replayed?[]:[o.startedAt]);if(e.length===0)return{start:void 0,end:void 0};const n=t.some(o=>o.state==="running"||o.state==="queued"),r=t.flatMap(o=>o.endedAt===void 0?[]:[o.endedAt]);return{start:Math.min(...e),end:n?void 0:Math.max(...r,...e)}},yy=t=>{const e=Le.c(18),{run:n,groups:r}=t,{t:o}=rt();let i,a,d,u,l,f;if(e[0]!==r||e[1]!==n||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{const p=r.filter(Ty);if(p.length===0){f=null;break e}i=gs,a="overlay-scrollbar-wrapper--no-gutter",d=!1,u="flex gap-1.5 pb-1";let h;e[9]!==n||e[10]!==o?(h=x=>{const g=x.agents.length,b=wy(x.agents),w=n.state==="running"&&n.currentPhase===x.title;return s.jsxs("div",{className:"oc-tile min-w-[7.5rem] flex-1 rounded-lg px-2.5 py-2",children:[s.jsx("div",{className:We("truncate typography-meta",w?"font-semibold text-foreground":"text-foreground"),dir:"auto",children:x.title}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 typography-micro text-muted-foreground",children:[g>0?s.jsx("span",{className:"tabular-nums",dir:"auto",children:`${x.done}/${g}`}):s.jsx("span",{children:o("workflows.panel.phase.waiting")}),g>0?s.jsx(Yi,{start:b.start,end:b.end,className:"ms-auto"}):null]}),s.jsx("div",{className:"oc-tile-inset mt-1.5 h-1 overflow-hidden rounded-full",children:g>0?s.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(x.done/g*100)}%`,background:x.failed>0?"var(--status-warning)":"var(--status-success)"}}):null})]},x.title)},e[9]=n,e[10]=o,e[11]=h):h=e[11],l=p.map(h)}e[0]=r,e[1]=n,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=s.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},vy=t=>{const e=Le.c(30),{run:n,agent:r,onOpenSession:o}=t,{t:i}=rt(),[a,d]=c.useState(null),[u,l]=c.useState(!1),[f,m]=c.useState(!1);let p;e[0]!==r.key||e[1]!==n.id?(p=()=>{let T=!0;return l(!1),Ah(n.id,r.key).then(F=>{T&&d(F)}).catch(()=>{T&&l(!0)}),()=>{T=!1}},e[0]=r.key,e[1]=n.id,e[2]=p):p=e[2];let h;e[3]!==r.key||e[4]!==r.state||e[5]!==n.id?(h=[r.key,r.state,n.id],e[3]=r.key,e[4]=r.state,e[5]=n.id,e[6]=h):h=e[6],c.useEffect(p,h);let x;e[7]!==r.error||e[8]!==r.state?(x=r.error?s.jsx("p",{className:"typography-meta",style:{color:r.state==="failed"?"var(--status-error)":void 0},children:r.error}):null,e[7]=r.error,e[8]=r.state,e[9]=x):x=e[9];let g;e[10]!==u||e[11]!==i?(g=u?s.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 b;e[13]!==a||e[14]!==u||e[15]!==i?(b=!a&&!u?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("workflows.panel.agent.loading"),s.jsx(Hi,{})]}):null,e[13]=a,e[14]=u,e[15]=i,e[16]=b):b=e[16];let w;e[17]!==a||e[18]!==f||e[19]!==i?(w=a?s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:i("workflows.panel.agent.answer")}),s.jsx("div",{className:"mt-1",children:a.result===void 0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:i("workflows.panel.agent.noAnswer")}):s.jsx(Fd,{answer:a.result})})]}),s.jsxs("section",{children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>m(Ny),"aria-expanded":f,className:"flex items-center gap-1 typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(oe,{name:"arrow-right-s",className:We("size-3.5 transition-transform",f&&"rotate-90 rtl:-rotate-90")}),i("workflows.panel.agent.prompt")]})}),s.jsx(jt,{sideOffset:6,children:i(f?"contextTooltips.workspace.workflow.promptHide":"contextTooltips.workspace.workflow.promptShow")})]}),f?s.jsx(gs,{as:"pre",dir:"auto",outerClassName:"mt-1 max-h-72",className:"whitespace-pre-wrap break-words font-mono typography-micro text-foreground",disableHorizontal:!0,children:a.prompt}):null]})]}):null,e[17]=a,e[18]=f,e[19]=i,e[20]=w):w=e[20];let j;e[21]!==o||e[22]!==i?(j=o?s.jsx("div",{children:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{type:"button",size:"xs",variant:"ghost",onClick:o,children:[s.jsx(oe,{name:"chat-4",className:"size-3.5"}),i("workflows.panel.agent.openSession")]})}),s.jsx(jt,{sideOffset:6,children:i("contextTooltips.workspace.workflow.agentSession")})]})}):null,e[21]=o,e[22]=i,e[23]=j):j=e[23];let v;return e[24]!==x||e[25]!==g||e[26]!==b||e[27]!==w||e[28]!==j?(v=s.jsxs("div",{className:"oc-tile mb-1.5 ms-5 flex flex-col gap-2 rounded-lg px-3 py-2.5",children:[x,g,b,w,j]}),e[24]=x,e[25]=g,e[26]=b,e[27]=w,e[28]=j,e[29]=v):v=e[29],v},Sy=t=>{const e=Le.c(57),{run:n,agent:r,showModel:o,columns:i,open:a,onToggle:d,onOpenSession:u}=t,{t:l}=rt();let f,m,p,h,x,g,b,w,j,v,T;if(e[0]!==r||e[1]!==i.tokens||e[2]!==d||e[3]!==a||e[4]!==o||e[5]!==l){const S=Ph(r.state),k=Rh(r);f="button",h=d,x=a,g=r.label,b="flex h-7 w-full min-w-0 items-center gap-2 rounded-md text-start typography-meta text-foreground/80 hover:text-foreground";const C=S.icon,y=S.color?{color:S.color}:void 0,E=l(S.labelKey);e[17]!==S||e[18]!==y||e[19]!==E?(w=s.jsx(oe,{name:C,className:"size-3.5 shrink-0",style:y,"aria-label":E}),e[17]=S,e[18]=y,e[19]=E,e[20]=w):w=e[20],e[21]!==r.label?(j=s.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?(v=r.replayed?s.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]=v):v=e[25],e[26]!==r.model||e[27]!==o?(T=o&&r.model?s.jsx("span",{className:"oc-tile-inset max-w-[9rem] shrink-0 truncate rounded-full px-1.5 typography-micro text-muted-foreground",title:r.model,dir:"ltr",children:Ld(r.model)}):null,e[26]=r.model,e[27]=o,e[28]=T):T=e[28];const B=r.replayed?void 0:r.startedAt;e[29]!==r.endedAt||e[30]!==B?(m=s.jsx(Yi,{start:B,end:r.endedAt,className:"min-w-12 text-end typography-micro text-muted-foreground"}),e[29]=r.endedAt,e[30]=B,e[31]=m):m=e[31],p=i.tokens?s.jsx("span",{className:"min-w-12 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"auto",children:k===null||r.replayed?"":Ui(k)}):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]=b,e[13]=w,e[14]=j,e[15]=v,e[16]=T}else f=e[6],m=e[7],p=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13],j=e[14],v=e[15],T=e[16];let F;e[32]!==r.replayed||e[33]!==r.usage||e[34]!==i.cost?(F=i.cost?s.jsx("span",{className:"min-w-14 shrink-0 whitespace-nowrap text-end tabular-nums typography-micro text-muted-foreground",dir:"ltr",children:r.usage&&!r.replayed&&r.usage.cost>0?Vi(r.usage.cost):""}):null,e[32]=r.replayed,e[33]=r.usage,e[34]=i.cost,e[35]=F):F=e[35];let _;e[36]!==f||e[37]!==m||e[38]!==p||e[39]!==F||e[40]!==h||e[41]!==x||e[42]!==g||e[43]!==b||e[44]!==w||e[45]!==j||e[46]!==v||e[47]!==T?(_=s.jsxs("button",{type:f,onClick:h,"aria-expanded":x,title:g,className:b,children:[w,j,v,T,m,p,F]}),e[36]=f,e[37]=m,e[38]=p,e[39]=F,e[40]=h,e[41]=x,e[42]=g,e[43]=b,e[44]=w,e[45]=j,e[46]=v,e[47]=T,e[48]=_):_=e[48];let A;e[49]!==r||e[50]!==u||e[51]!==a||e[52]!==n?(A=a?s.jsx(vy,{run:n,agent:r,onOpenSession:u}):null,e[49]=r,e[50]=u,e[51]=a,e[52]=n,e[53]=A):A=e[53];let M;return e[54]!==_||e[55]!==A?(M=s.jsxs(s.Fragment,{children:[_,A]}),e[54]=_,e[55]=A,e[56]=M):M=e[56],M},ky=(t,e)=>{const n=Ih(t);if(n.measured===0)return null;const r=[];return e.tokens&&r.push(Ui(n.tokens)),e.cost&&n.cost>0&&r.push(Vi(n.cost)),r.length>0?r.join(" · "):null},jy=t=>{const e=new Set(t.map(r=>r.model??null)),[n]=e;return e.size===1&&n?Ld(n):null},Cy=t=>{const e=Le.c(51),{run:n,directory:r}=t,{t:o}=rt();let i;e[0]!==n?(i=Th(n),e[0]=n,e[1]=i):i=e[1];const a=i,d=Nh(r),[u,l]=c.useState(Ey),[f,m]=c.useState(Iy);let p,h,x,g,b,w;if(e[2]!==a||e[3]!==u||e[4]!==d||e[5]!==n||e[6]!==o||e[7]!==f){const T=Eh(n),F=T.measured>0,_=T.cost>0;let A,M,S;if(e[14]!==a||e[15]!==u||e[16]!==d||e[17]!==n||e[18]!==o||e[19]!==F||e[20]!==_||e[21]!==f){const k={tokens:F,cost:_},C=n.agents.filter(Py).length,y=Ry;b="flex h-full min-h-0 flex-col";let E;e[28]!==a||e[29]!==n?(E=s.jsx(yy,{run:n,groups:a}),e[28]=a,e[29]=n,e[30]=E):E=e[30];const B=a.map($=>{if($.agents.length===0)return null;const O=$.title??"",z=$.done+$.failed===$.agents.length,K=(n.state==="running"&&z)===f.has(O),ee=jy($.agents),V=ky($.agents,k);return s.jsxs("section",{className:"mt-3",children:[s.jsxs("button",{type:"button",onClick:()=>y(m,O),"aria-expanded":K,className:"flex h-7 w-full min-w-0 items-center gap-1.5 text-start typography-micro font-medium text-muted-foreground hover:text-foreground",children:[s.jsx(oe,{name:"arrow-right-s",className:We("size-3.5 shrink-0 transition-transform",K&&"rotate-90 rtl:-rotate-90")}),s.jsx("span",{className:"min-w-0 truncate",dir:"auto",children:$.title??o("chat.workflow.phase.unphased")}),ee?s.jsx("span",{className:"min-w-0 truncate font-normal",dir:"ltr",children:`· ${ee}`}):null,V?s.jsx("span",{className:"ms-auto shrink-0 tabular-nums font-normal",dir:"ltr",children:V}):null,s.jsx("span",{className:We("shrink-0 tabular-nums font-normal",!V&&"ms-auto"),dir:"auto",children:V?`· ${$.done}/${$.agents.length}`:`${$.done}/${$.agents.length}`})]}),K?$.agents.map(Y=>{const ae=Y.sessionId;return s.jsx(Sy,{run:n,agent:Y,showModel:ee===null,columns:k,open:u.has(Y.key),onToggle:()=>y(l,Y.key),onOpenSession:ae?()=>d(ae,Y.label):null},Y.key)}):null]},O)});e[31]!==E||e[32]!==B?(w=s.jsxs(gs,{outerClassName:"min-h-0 flex-1",className:"px-3 py-3",disableHorizontal:!0,children:[E,B]}),e[31]=E,e[32]=B,e[33]=w):w=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",A="tabular-nums",M="auto",S=o("workflows.panel.summary.agents",{done:C,total:n.agents.length}),e[14]=a,e[15]=u,e[16]=d,e[17]=n,e[18]=o,e[19]=F,e[20]=_,e[21]=f,e[22]=A,e[23]=M,e[24]=S,e[25]=p,e[26]=b,e[27]=w}else A=e[22],M=e[23],S=e[24],p=e[25],b=e[26],w=e[27];e[34]!==A||e[35]!==M||e[36]!==S?(h=s.jsx("span",{className:A,dir:M,children:S}),e[34]=A,e[35]=M,e[36]=S,e[37]=h):h=e[37],e[38]!==n.endedAt||e[39]!==n.startedAt||e[40]!==n.state?(x=n.startedAt!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx(Yi,{start:n.startedAt,end:n.state==="running"?void 0:n.endedAt??n.startedAt})]}):null,e[38]=n.endedAt,e[39]=n.startedAt,e[40]=n.state,e[41]=x):x=e[41],g=T.measured>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"auto",children:o("workflows.panel.summary.tokens",{tokens:Ui(T.tokens)})}),T.cost>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsx("span",{className:"tabular-nums",dir:"ltr",children:Vi(T.cost)})]}):null]}):null,e[2]=a,e[3]=u,e[4]=d,e[5]=n,e[6]=o,e[7]=f,e[8]=p,e[9]=h,e[10]=x,e[11]=g,e[12]=b,e[13]=w}else p=e[8],h=e[9],x=e[10],g=e[11],b=e[12],w=e[13];let j;e[42]!==p||e[43]!==h||e[44]!==x||e[45]!==g?(j=s.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 v;return e[47]!==b||e[48]!==w||e[49]!==j?(v=s.jsxs("div",{className:b,children:[w,j]}),e[47]=b,e[48]=w,e[49]=j,e[50]=v):v=e[50],v};function Ty(t){return t.title!==null}function Ny(t){return!t}function Ey(){return new Set}function Iy(){return new Set}function Py(t){return t.state==="completed"}function Ry(t,e){return t(n=>{const r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})}const Dy={steps:["data-workflows-header-compact","data-workflows-header-tight","data-workflows-header-narrow"]},_y=[{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"}],Ay=1500,Oy=(t,e)=>{const n=Le.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;n[0]!==t.id||n[1]!==u?(f=()=>{if(!u)return;let g=!0;const b=d.current?.runId===t.id?d.current.at:0,w=Math.max(0,b+Ay-Date.now()),j=setTimeout(()=>{d.current={runId:t.id,at:Date.now()},Vh(t.id).then(v=>{g&&(o(v),a(null))}).catch(()=>{g&&a(t.id)})},w);return()=>{g=!1,clearTimeout(j)}},n[0]=t.id,n[1]=u,n[2]=f):f=n[2];let m;n[3]!==l||n[4]!==t.id||n[5]!==t.state||n[6]!==u?(m=[l,t.id,t.state,u],n[3]=l,n[4]=t.id,n[5]=t.state,n[6]=u,n[7]=m):m=n[7],c.useEffect(f,m);const p=r?.runId===t.id?r:null,h=i===t.id;let x;return n[8]!==p||n[9]!==h?(x={detail:p,failed:h},n[8]=p,n[9]=h,n[10]=x):x=n[10],x},My=t=>new Intl.DateTimeFormat(qc(),{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t),Fy=t=>{const e=Le.c(8),{run:n,detail:r}=t,{t:o}=rt(),i=r?.logs??n.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=s.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=s.jsx("ol",{className:"flex flex-col gap-1 px-3 py-3",children:a}),e[6]=a,e[7]=d):d=e[7],d},Ly=t=>{const e=Le.c(24),{run:n,detail:r,failed:o}=t,{t:i}=rt();if(n.error&&(n.state==="failed"||n.state==="stopped")){const u=n.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]!==n.error||e[3]!==l?(f=s.jsx("p",{className:"px-4 py-6 typography-meta",style:l,children:n.error}),e[2]=n.error,e[3]=l,e[4]=f):f=e[4],f}if(n.state==="awaiting-approval"||n.state==="running"||n.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=s.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=s.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=s.jsx(Hi,{}),e[15]=l):l=e[15];let f;return e[16]!==u?(f=s.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=s.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=s.jsx("div",{className:"px-4 py-3",children:s.jsx(Fd,{answer:a})}),e[22]=a,e[23]=d):d=e[23],d},$y=t=>{const e=Le.c(16),{detail:n,failed:r}=t,{t:o}=rt();if(!n){let m;e[0]!==r||e[1]!==o?(m=r?o("workflows.panel.detail.loadFailed"):s.jsxs(s.Fragment,{children:[o("workflows.panel.agent.loading"),s.jsx(Hi,{})]}),e[0]=r,e[1]=o,e[2]=m):m=e[2];let p;return e[3]!==m?(p=s.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=n.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?s.jsxs("section",{children:[s.jsx("h4",{className:"typography-micro font-medium text-muted-foreground",children:o("workflows.panel.script.args")}),s.jsx(gs,{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]!==n.script?(l=s.jsx(gs,{as:"pre",dir:"ltr",outerClassName:"overlay-scrollbar-wrapper--no-gutter oc-tile rounded-lg",fillContainer:!1,className:"px-3 py-2 font-mono typography-micro leading-relaxed text-foreground",children:n.script}),e[11]=n.script,e[12]=l):l=e[12];let f;return e[13]!==u||e[14]!==l?(f=s.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=Le.c(83),{run:n}=t,{t:r}=rt(),{pending:o,act:i}=Uh(),a=o===n.id;if(n.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]!==n.id?(u=()=>i(n.id,"approve"),e[2]=i,e[3]=n.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=s.jsx(oe,{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=s.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=s.jsxs(ft,{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=s.jsx(us,{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 b;e[22]!==i||e[23]!==n.id?(b=()=>i(n.id,"decline"),e[22]=i,e[23]=n.id,e[24]=b):b=e[24];let w;e[25]!==r?(w=r("chat.workflow.action.decline"),e[25]=r,e[26]=w):w=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(oe,{name:"close",className:"size-3.5"}),e[27]=j):j=e[27];let v;e[28]!==r?(v=r("chat.workflow.action.decline"),e[28]=r,e[29]=v):v=e[29];let T;e[30]!==v?(T=s.jsx("span",{className:"workflows-header__action-label",children:v}),e[30]=v,e[31]=T):T=e[31];let F;e[32]!==a||e[33]!==b||e[34]!==w||e[35]!==T?(F=s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:b,"aria-label":w,children:[j,T]}),e[32]=a,e[33]=b,e[34]=w,e[35]=T,e[36]=F):F=e[36];let _;e[37]!==F||e[38]!==g?(_=s.jsx(us,{label:g,side:"bottom",className:"shrink-0",children:F}),e[37]=F,e[38]=g,e[39]=_):_=e[39];let A;return e[40]!==_||e[41]!==x?(A=s.jsxs(s.Fragment,{children:[x,_]}),e[40]=_,e[41]=x,e[42]=A):A=e[42],A}if(n.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]!==n.id?(u=()=>i(n.id,"stop"),e[45]=i,e[46]=n.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=s.jsx(oe,{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=s.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=s.jsxs(ft,{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=s.jsx(us,{label:d,side:"bottom",className:"shrink-0",children:h}),e[60]=d,e[61]=h,e[62]=x):x=e[62],x}if(n.state==="failed"||n.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]!==n.id?(u=()=>i(n.id,"resume"),e[65]=i,e[66]=n.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=s.jsx(oe,{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=s.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=s.jsxs(ft,{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=s.jsx(us,{label:d,side:"bottom",className:"shrink-0",children:h}),e[80]=d,e[81]=h,e[82]=x):x=e[82],x}return null},zy=()=>{const t=Le.c(2),e=ps(Gy);let n;return t[0]!==e?(n={get:r=>e.get(r)?.title},t[0]=e,t[1]=n):n=t[1],n},ol=t=>{const e=Le.c(31),{run:n,selected:r,caption:o,onSelect:i}=t,{t:a}=rt();let d,u,l,f,m,p,h;if(e[0]!==i||e[1]!==n.state||e[2]!==a){const T=Hc(n.state);u=Gt,h=i,d=oe,l=T.icon,f="size-3.5 shrink-0",m=T.color?{color:T.color}:void 0,p=a(T.labelKey),e[0]=i,e[1]=n.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=s.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]!==n.name?(g=s.jsx("span",{className:"truncate",dir:"auto",children:n.name}),e[16]=n.name,e[17]=g):g=e[17];let b;e[18]!==o?(b=o?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",dir:"auto",children:o}):null,e[18]=o,e[19]=b):b=e[19];let w;e[20]!==g||e[21]!==b?(w=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[g,b]}),e[20]=g,e[21]=b,e[22]=w):w=e[22];let j;e[23]!==r?(j=r?s.jsx(oe,{name:"check",className:"size-3.5 shrink-0"}):null,e[23]=r,e[24]=j):j=e[24];let v;return e[25]!==u||e[26]!==j||e[27]!==h||e[28]!==x||e[29]!==w?(v=s.jsxs(u,{onSelect:h,children:[x,w,j]}),e[25]=u,e[26]=j,e[27]=h,e[28]=x,e[29]=w,e[30]=v):v=e[30],v},Wy=t=>{const e=Le.c(63),{runs:n,selected:r,sessionId:o,sessionTitles:i,saved:a,onSelect:d,onRunSaved:u,onDelete:l}=t,{t:f}=rt();let m;e[0]!==r.state?(m=Hc(r.state),e[0]=r.state,e[1]=m):m=e[1];const p=m;let h,x,g,b,w,j,v;if(e[2]!==p.color||e[3]!==p.icon||e[4]!==d||e[5]!==n||e[6]!==r.id||e[7]!==r.name||e[8]!==o||e[9]!==i||e[10]!==f){const M=n.slice().reverse();let S;e[18]!==o?(S=Y=>Y.parentSessionId===o,e[18]=o,e[19]=S):S=e[19];const k=M.filter(S);let C;e[20]!==o?(C=Y=>Y.parentSessionId!==o,e[20]=o,e[21]=C):C=e[21];const y=M.filter(C);x=gn;let E;e[22]!==f?(E=f("workflows.panel.runPicker"),e[22]=f,e[23]=E):E=e[23];let B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=We(Wh(),"max-w-[14rem] shrink-0"),e[24]=B):B=e[24];let $;e[25]!==p.color?($=p.color?{color:p.color}:void 0,e[25]=p.color,e[26]=$):$=e[26];let O;e[27]!==p.icon||e[28]!==$?(O=s.jsx(oe,{name:p.icon,className:"size-3.5",style:$}),e[27]=p.icon,e[28]=$,e[29]=O):O=e[29];let z;e[30]!==r.name?(z=s.jsx("span",{className:"workflows-header__run-name min-w-0 truncate",dir:"auto",children:r.name}),e[30]=r.name,e[31]=z):z=e[31];let J;e[32]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(oe,{name:"arrow-down-s",className:"size-4"}),e[32]=J):J=e[32];let K;e[33]!==O||e[34]!==z||e[35]!==E?(K=s.jsx(St,{asChild:!0,children:s.jsx(xn,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":E,className:B,children:[O,z,J]})})}),e[33]=O,e[34]=z,e[35]=E,e[36]=K):K=e[36];let ee;e[37]!==f?(ee=f("contextTooltips.workspace.workflow.pickRun"),e[37]=f,e[38]=ee):ee=e[38];let V;e[39]!==ee?(V=s.jsx(jt,{side:"bottom",sideOffset:6,children:ee}),e[39]=ee,e[40]=V):V=e[40],e[41]!==K||e[42]!==V?(v=s.jsxs(kt,{children:[K,V]}),e[41]=K,e[42]=V,e[43]=v):v=e[43],h=bn,g="start",b="max-h-[min(var(--available-height),28rem)] w-[18rem] max-w-[calc(100vw-2rem)] overflow-y-auto",w=k.length>0?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{children:f("workflows.panel.picker.thisSession")}),k.map(Y=>s.jsx(ol,{run:Y,selected:Y.id===r.id,onSelect:()=>d(Y.id)},Y.id))]}):null,j=y.length>0?s.jsxs(s.Fragment,{children:[k.length>0?s.jsx(mn,{}):null,s.jsx(Ar,{children:f("workflows.panel.picker.otherSessions")}),y.map(Y=>s.jsx(ol,{run:Y,selected:Y.id===r.id,caption:i.get(Y.parentSessionId)||f("workflows.panel.picker.untitledSession"),onSelect:()=>d(Y.id)},Y.id))]}):null,e[2]=p.color,e[3]=p.icon,e[4]=d,e[5]=n,e[6]=r.id,e[7]=r.name,e[8]=o,e[9]=i,e[10]=f,e[11]=h,e[12]=x,e[13]=g,e[14]=b,e[15]=w,e[16]=j,e[17]=v}else h=e[11],x=e[12],g=e[13],b=e[14],w=e[15],j=e[16],v=e[17];let T;e[44]!==u||e[45]!==a||e[46]!==f?(T=a.length>0?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsx(Ar,{children:f("workflows.panel.picker.saved")}),a.map(M=>s.jsxs(Gt,{disabled:!!M.error,onSelect:()=>u(M.name),title:M.error??M.description,children:[s.jsx(oe,{name:"play",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",dir:"auto",children:M.name})]},M.name))]}):null,e[44]=u,e[45]=a,e[46]=f,e[47]=T):T=e[47];let F;e[48]!==l||e[49]!==f?(F=l?s.jsxs(s.Fragment,{children:[s.jsx(mn,{}),s.jsxs(Gt,{variant:"destructive",onSelect:l,children:[s.jsx(oe,{name:"delete-bin",className:"size-3.5 shrink-0"}),f("workflows.panel.delete.action")]})]}):null,e[48]=l,e[49]=f,e[50]=F):F=e[50];let _;e[51]!==h||e[52]!==g||e[53]!==b||e[54]!==w||e[55]!==j||e[56]!==T||e[57]!==F?(_=s.jsxs(h,{align:g,className:b,children:[w,j,T,F]}),e[51]=h,e[52]=g,e[53]=b,e[54]=w,e[55]=j,e[56]=T,e[57]=F,e[58]=_):_=e[58];let A;return e[59]!==x||e[60]!==v||e[61]!==_?(A=s.jsxs(x,{children:[v,_]}),e[59]=x,e[60]=v,e[61]=_,e[62]=A):A=e[62],A},Uy=(t,e,n,r)=>{const o=Le.c(11),{t:i}=rt(),{confirm:a,dialog:d}=zi(),u=qi(Zy);let l;o[0]!==a||o[1]!==t||o[2]!==e||o[3]!==u||o[4]!==r||o[5]!==n||o[6]!==i?(l=async p=>{if(!(!t||!e||!await a({title:i("workflows.panel.saved.confirmTitle",{name:p}),message:i(n?"workflows.panel.saved.confirmHere":"workflows.panel.saved.confirmNew"),action:i("workflows.panel.saved.confirmAction")})))try{const x=await Lh({directory:t,scriptDirectory:e,sessionId:n,name:p});n?u(r,x.runId):(u(x.sessionId,x.runId),st.getState().setCurrentSession(x.sessionId,t))}catch(x){const g=x;Te.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]=n,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},Vy=t=>{const e=Le.c(23),{saved:n,onRunSaved:r}=t,{t:o}=rt();if(n.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=s.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=s.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=s.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]!==n||e[14]!==o){let m;e[16]!==r||e[17]!==o?(m=p=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-meta text-foreground",dir:"auto",children:p.name}),p.description||p.error?s.jsx("div",{className:"truncate typography-micro text-muted-foreground",dir:"auto",title:p.error??p.description,children:p.error??p.description}):null]}),s.jsx(us,{label:o("workflows.panel.saved.runAria",{name:p.name}),className:"shrink-0",children:s.jsxs(ft,{type:"button",size:"sm",variant:"outline",disabled:!!p.error,onClick:()=>r(p.name),"aria-label":o("workflows.panel.saved.runAria",{name:p.name}),children:[s.jsx(oe,{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=n.map(m),e[12]=r,e[13]=n,e[14]=o,e[15]=l}else l=e[15];let f;return e[19]!==a||e[20]!==u||e[21]!==l?(f=s.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},Hy=t=>{const e=Le.c(17),{directory:n}=t,r=st(Xy),o=Oh(n),i=Mh(o),a=Fh(o?.savedDirectory??null),d=r??`directory:${n??""}`;let u;e[0]!==d?(u=b=>b.selectedBySession[d],e[0]=d,e[1]=u):u=e[1];const l=qi(u),{run:f,dialog:m}=Uy(n,o?.savedDirectory??null,r,d);let p;e[2]!==i||e[3]!==l||e[4]!==r?(p=i.find(b=>b.id===l)??i.filter(b=>b.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]!==n||e[7]!==h||e[8]!==f||e[9]!==i||e[10]!==a||e[11]!==d||e[12]!==r?(x=h?s.jsx(qy,{sessionId:r,selectionKey:d,runs:i,saved:a,run:h,directory:n,onRunSaved:b=>{f(b)}}):s.jsx(Vy,{saved:a,onRunSaved:b=>{f(b)}}),e[6]=n,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=s.jsxs(s.Fragment,{children:[m,x]}),e[14]=m,e[15]=x,e[16]=g):g=e[16],g},qy=t=>{const e=Le.c(58),{sessionId:n,selectionKey:r,runs:o,saved:i,run:a,directory:d,onRunSaved:u}=t,{t:l}=rt(),f=qi(Yy),m=zy(),[p,h]=c.useState("agents"),{detail:x,failed:g}=Oy(a,p),b=c.useRef(null);$h(b,Dy);const{confirm:w,dialog:j}=zi(),v=a.state==="running"||a.state==="awaiting-approval",T=a.parentSessionId!==n;let F;e[0]!==w||e[1]!==a.id||e[2]!==a.name||e[3]!==a.parentSessionId||e[4]!==l?(F=async()=>{if(await w({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 Bh(a.id),zh.getState().remove(a.parentSessionId,a.id)}catch(Y){const ae=Y;Te.error(l("workflows.panel.delete.failed"),{description:ae instanceof Error?ae.message:void 0})}},e[0]=w,e[1]=a.id,e[2]=a.name,e[3]=a.parentSessionId,e[4]=l,e[5]=F):F=e[5];const _=F;let A;e[6]!==a.directory||e[7]!==a.id||e[8]!==a.parentSessionId||e[9]!==f?(A=()=>{f(a.parentSessionId,a.id),st.getState().setCurrentSession(a.parentSessionId,a.directory)},e[6]=a.directory,e[7]=a.id,e[8]=a.parentSessionId,e[9]=f,e[10]=A):A=e[10];const M=A;let S;e[11]!==f||e[12]!==r?(S=V=>f(r,V),e[11]=f,e[12]=r,e[13]=S):S=e[13];let k;e[14]!==_||e[15]!==v?(k=v?null:()=>{_()},e[14]=_,e[15]=v,e[16]=k):k=e[16];let C;e[17]!==u||e[18]!==a||e[19]!==o||e[20]!==i||e[21]!==n||e[22]!==m||e[23]!==S||e[24]!==k?(C=s.jsx(Wy,{runs:o,selected:a,sessionId:n,sessionTitles:m,saved:i,onSelect:S,onRunSaved:u,onDelete:k}),e[17]=u,e[18]=a,e[19]=o,e[20]=i,e[21]=n,e[22]=m,e[23]=S,e[24]=k,e[25]=C):C=e[25];let y;e[26]!==l?(y=l("workflows.panel.view.label"),e[26]=l,e[27]=y):y=e[27];let E;e[28]!==l||e[29]!==p?(E=_y.map(V=>{const Y=V.id===p;return s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>h(V.id),"aria-current":Y?"page":void 0,"aria-label":l(V.labelKey),className:We("flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors",Y?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(oe,{name:V.icon,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"workflows-header__label whitespace-nowrap typography-meta",children:l(V.labelKey)})]})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:l(V.tooltipKey)})]},V.id)}),e[28]=l,e[29]=p,e[30]=E):E=e[30];let B;e[31]!==y||e[32]!==E?(B=s.jsx("nav",{className:"flex shrink-0 items-center gap-1","aria-label":y,children:E}),e[31]=y,e[32]=E,e[33]=B):B=e[33];let $;e[34]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx("div",{"aria-hidden":!0,className:"min-w-0 flex-1"}),e[34]=$):$=e[34];let O;e[35]!==T||e[36]!==M||e[37]!==a.parentSessionId||e[38]!==m||e[39]!==l?(O=T?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{type:"button",size:"sm",variant:"ghost",onClick:M,"aria-label":l("workflows.panel.agent.openSession"),children:[s.jsx(oe,{name:"chat-4",className:"size-3.5"}),s.jsx("span",{className:"workflows-header__action-label",children:l("workflows.panel.agent.openSession")})]})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:m.get(a.parentSessionId)||l("workflows.panel.picker.untitledSession")})]}):null,e[35]=T,e[36]=M,e[37]=a.parentSessionId,e[38]=m,e[39]=l,e[40]=O):O=e[40];let z;e[41]!==a?(z=s.jsx(By,{run:a}),e[41]=a,e[42]=z):z=e[42];let J;e[43]!==O||e[44]!==z||e[45]!==C||e[46]!==B?(J=s.jsx(Vc,{children:s.jsxs("div",{ref:b,className:"workflows-header flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden ps-1 pe-1",children:[C,B,$,O,z]})}),e[43]=O,e[44]=z,e[45]=C,e[46]=B,e[47]=J):J=e[47];let K;e[48]!==x||e[49]!==d||e[50]!==g||e[51]!==a||e[52]!==p?(K=p==="agents"?s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(Cy,{run:a,directory:d},a.id)}):s.jsxs(gs,{outerClassName:"min-h-0 flex-1",disableHorizontal:!0,children:[p==="log"?s.jsx(Fy,{run:a,detail:x}):null,p==="result"?s.jsx(Ly,{run:a,detail:x,failed:g}):null,p==="script"?s.jsx($y,{detail:x,failed:g}):null]}),e[48]=x,e[49]=d,e[50]=g,e[51]=a,e[52]=p,e[53]=K):K=e[53];let ee;return e[54]!==j||e[55]!==J||e[56]!==K?(ee=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[j,J,K]}),e[54]=j,e[55]=J,e[56]=K,e[57]=ee):ee=e[57],ee};function Ky(t,e){return s.jsxs("li",{className:"flex min-w-0 gap-3 typography-meta",children:[s.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",dir:"ltr",children:My(t.at)}),s.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words text-foreground",dir:"auto",children:t.message})]},`${t.at}-${e}`)}function Gy(t){return t.entityById}function Zy(t){return t.select}function Xy(t){return t.currentSessionId}function Yy(t){return t.select}const il=60,Jy=t=>{try{return new URL(t).origin}catch{return""}},Wo=new Set,$d=bo()((t,e)=>({byOrigin:{},resolve:(n,r,o)=>{const i=Jy(n);!i||!r||e().byOrigin[i]||Wo.has(i)||(Wo.add(i),Tn("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(()=>{Wo.delete(i)}))}})),Ji=t=>t,fi=t=>{const e=Ji(t).type;return typeof e=="string"?e:""},Qy=t=>{const e=Ji(t).tool;return typeof e=="string"?e:""},ev=t=>{const e=Ji(t).text;return typeof e=="string"?e:""},tv=t=>{const e=fi(t);return e==="tool"?Qy(t).trim().toLowerCase()||"tool":e||"unknown"},sv=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=tv(n);e.includes(r)||e.push(r)}return e.join(" + ")},nv=t=>t.replace(/\s+/g," ").trim(),rv=t=>{for(const n of t)if(fi(n)==="text"){const r=nv(ev(n));if(r.length===0)continue;return r}const e=t.filter(n=>fi(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},ov=(t,e,n)=>`${n(t)} / ${n(e)}`,iv=t=>{if(t==="12h")return!0;if(t==="24h")return!1},av=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=iv(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},lv=(t,{windowTokens:e,compacted:n=!1})=>{const r=n?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},pi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Xr={user:0,assistant:0,tool:0,other:0},Bs=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Bd=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof n=="number")return{...pi,total:Bs(n)};if(!n||typeof n!="object")return pi;const r=n,o=Bs(r.input),i=Bs(r.output),a=Bs(r.reasoning),d=Bs(r.cache?.read),u=Bs(r.cache?.write),l=Bs(r.total);return{input:o,output:i,reasoning:a,cacheRead:d,cacheWrite:u,total:l>0?l:o+i+a+d+u}},cv=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},bs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+bs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+bs(n),0):0,dv=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Xr,assistant:bs(n.text)+bs(n.content)};const o=cv(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:bs(n.input)+bs(n.output)+bs(n.error)+bs(n.call?.input)+bs(n.call?.output)+bs(n.call?.error)+bs(n.raw)+Math.round(bs(n.metadata)*.25)+Math.round(bs(n.state)*.1)+Math.round((qu(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}},zd=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),uv=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",al=new WeakMap,fv=t=>{const e=al.get(t);if(e)return e;const n=uv(t);let r={...Xr};for(const o of t.parts)r=zd(r,dv(o,n));return al.set(t,r),r},pv=(t,e)=>{if(t.length===0)return{...Xr};const n=t.reduce((r,o)=>zd(r,fv(o)),{...Xr});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},un=t=>t.toLocaleString(qc()),mv=(t,e)=>!t||!Number.isFinite(t)?"-":Yh(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),hv=(t,e,n)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===n);return{providerName:r?.name||e||"-",modelName:o?.name||n||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},ll=t=>{const e=Le.c(21),{title:n,figures:r}=t,{t:o}=rt();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]!==n){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]!==n?(u=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:n}),e[12]=n,e[13]=u):u=e[13],i="grid grid-cols-3 gap-x-4 gap-y-2.5",a=m.map(bv),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]=n,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=s.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=s.jsxs("div",{className:d,children:[u,l]}),e[17]=d,e[18]=u,e[19]=l,e[20]=f):f=e[20],f},gv=c.memo(function(e){const n=Le.c(54),{message:r,isExpanded:o,isCopied:i,timeFormatPreference:a,onToggle:d,onCopy:u}=e,{t:l}=rt(),f=r.info.role,m=f==="assistant",p=f==="user",h=r.info.time?.created??null;let x;n[0]!==r.parts?(x=sv(r.parts),n[0]=r.parts,n[1]=x):x=n[1];const g=x;let b,w,j,v;if(n[2]!==m||n[3]!==p||n[4]!==r||n[5]!==h||n[6]!==g||n[7]!==a){const J=m?Bd(r):null;let K;n[12]!==p||n[13]!==r.parts?(K=p?rv(r.parts):"",n[12]=p,n[13]=r.parts,n[14]=K):K=n[14],v=K;let ee;n[15]!==h||n[16]!==a?(ee=av(h,a),n[15]=h,n[16]=a,n[17]=ee):ee=n[17],w=ee,b=g||"—",j=J?ov(J.input,J.output,un):"",n[2]=m,n[3]=p,n[4]=r,n[5]=h,n[6]=g,n[7]=a,n[8]=b,n[9]=w,n[10]=j,n[11]=v}else b=n[8],w=n[9],j=n[10],v=n[11];const T=j,F=f||"unknown",_=g?`${F}: ${g}`:F;let A;n[18]!==o||n[19]!==r.info||n[20]!==r.parts?(A=o?JSON.stringify({info:r.info,parts:r.parts},null,2):"",n[18]=o,n[19]=r.info,n[20]=r.parts,n[21]=A):A=n[21];const M=A;let S;n[22]!==r.info.id||n[23]!==d?(S=()=>d(r.info.id),n[22]=r.info.id,n[23]=d,n[24]=S):S=n[24];const k=m?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content";let C;n[25]!==k?(C={gridTemplateColumns:k},n[25]=k,n[26]=C):C=n[26];let y;n[27]!==b||n[28]!==T||n[29]!==m||n[30]!==p||n[31]!==_||n[32]!==v?(y=p?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",v]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:m?b:_}),m&&s.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:T})]}),n[27]=b,n[28]=T,n[29]=m,n[30]=p,n[31]=_,n[32]=v,n[33]=y):y=n[33];let E;n[34]!==w?(E=s.jsx("span",{className:"text-end text-muted-foreground",children:w}),n[34]=w,n[35]=E):E=n[35];let B;n[36]!==C||n[37]!==y||n[38]!==E?(B=s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:C,children:[y,E]}),n[36]=C,n[37]=y,n[38]=E,n[39]=B):B=n[39];let $;n[40]!==o||n[41]!==S||n[42]!==B?($=s.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:S,children:B}),n[40]=o,n[41]=S,n[42]=B,n[43]=$):$=n[43];let O;n[44]!==i||n[45]!==o||n[46]!==M||n[47]!==r.info.id||n[48]!==u||n[49]!==l?(O=o&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs(gs,{outerClassName:"max-h-[26rem] bg-[var(--surface-background)]",className:"group relative",disableHorizontal:!0,children:[s.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:J=>{J.stopPropagation(),u(r.info.id,M)},"aria-label":l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),children:i?s.jsx(oe,{name:"check",className:"size-3.5"}):s.jsx(oe,{name:"file-copy",className:"size-3.5"})})}),s.jsx(jt,{sideOffset:6,children:l(i?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson")})]})}),s.jsx(Hh,{language:"json",code:M,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})}),n[44]=i,n[45]=o,n[46]=M,n[47]=r.info.id,n[48]=u,n[49]=l,n[50]=O):O=n[50];let z;return n[51]!==$||n[52]!==O?(z=s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[$,O]}),n[51]=$,n[52]=O,n[53]=z):z=n[53],z}),xv=()=>{const t=Le.c(216),{t:e}=rt(),n=qh(),r=G(wv);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=st(yv),m=st(vv),p=Kh(m??void 0),h=Gh(f??"",m??void 0),x=Wt(Sv);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),a(kv),u(null)},t[1]=g):g=t[1];let b;t[2]!==m||t[3]!==f?(b=[m,f],t[2]=m,t[3]=f,t[4]=b):b=t[4],c.useEffect(g,b);let w,j;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},j=[],t[5]=w,t[6]=j):(w=t[5],j=t[6]),c.useEffect(w,j);let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=Ke=>{a(ct=>({...ct,[Ke]:ct[Ke]!==!0}))},t[7]=v):v=t[7];const T=v;let F;t[8]===Symbol.for("react.memo_cache_sentinel")?(F=async(Ke,ct)=>{(await wr(ct)).ok?(u(Ke),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{u(ht=>ht===Ke?null:ht),l.current=null},2e3)):u(null)},t[8]=F):F=t[8];const _=F;let A,M,S,k,C,y,E,B,$,O,z,J,K,ee;if(t[9]!==f||t[10]!==x||t[11]!==h||t[12]!==p||t[13]!==e){C=f?p.find(as=>as.id===f)??null:null,A=h.filter(jv);let Ke;t[28]!==h?(Ke=h.filter(Cv),t[28]=h,t[29]=Ke):Ke=t[29],ee=Ke;let ct;t[30]!==h?(ct=Ic(h.map(Tv)),t[30]=h,t[31]=ct):ct=t[31];const Rt=ct,ht=Rt?h[Rt.index]??null:null,Ct=Rt?.state==="compacted";z=ht?Bd(ht):pi,S=Zh({input:z.input,cache:{read:z.cacheRead,write:z.cacheWrite}}),J=Number.isFinite(C?.cost)?Bs(C?.cost):A.reduce(Nv,0);const lt=ht?.info??null,Et=x,qt=lt?.providerID||"",dt=lt?.modelID||"";let ut;t[32]!==Et||t[33]!==qt||t[34]!==dt?(ut=hv(Et,qt,dt),t[32]=Et,t[33]=qt,t[34]=dt,t[35]=ut):ut=t[35],B=ut,k=B.contextLimit,K=Ct?null:k&&k>0?Math.min(999,z.total/k*100):0;const Ot=[...h].reverse().find(Ev),Zt=Ot?.info.role==="system"?Ot.info.text:"",is=pv(h,Zt);M=lv(is,{windowTokens:z.total,compacted:Ct}),y=h[0]?.info?.time?.created,E=h.length>0?h[h.length-1]?.info?.time?.created:null,$=C?.title||e("contextSidebar.session.untitled"),O=Xh(C),t[9]=f,t[10]=x,t[11]=h,t[12]=p,t[13]=e,t[14]=A,t[15]=M,t[16]=S,t[17]=k,t[18]=C,t[19]=y,t[20]=E,t[21]=B,t[22]=$,t[23]=O,t[24]=z,t[25]=J,t[26]=K,t[27]=ee}else A=t[14],M=t[15],S=t[16],k=t[17],C=t[18],y=t[19],E=t[20],B=t[21],$=t[22],O=t[23],z=t[24],J=t[25],K=t[26],ee=t[27];const V=C?.time?.created??y??null,Y=E??C?.time?.created??null;let ae;t[36]!==A.length||t[37]!==M||t[38]!==S||t[39]!==k||t[40]!==B||t[41]!==h.length||t[42]!==Y||t[43]!==$||t[44]!==O||t[45]!==V||t[46]!==z||t[47]!==J||t[48]!==K||t[49]!==ee.length?(ae={sessionTitle:$,sessionTotals:O,messagesCount:h.length,userMessagesCount:ee.length,assistantMessagesCount:A.length,createdAt:V,lastActivityAt:Y,providerModel:B,tokenBreakdown:z,usagePercent:K,cacheHitRate:S,totalAssistantCost:J,contextLimit:k,breakdown:M,breakdownTotal:M.total},t[36]=A.length,t[37]=M,t[38]=S,t[39]=k,t[40]=B,t[41]=h.length,t[42]=Y,t[43]=$,t[44]=O,t[45]=V,t[46]=z,t[47]=J,t[48]=K,t[49]=ee.length,t[50]=ae):ae=t[50];const P=ae;if(!f){let Ke;t[51]!==e?(Ke=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Ke):Ke=t[52];let ct;return t[53]!==Ke?(ct=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ke}),t[53]=Ke,t[54]=ct):ct=t[54],ct}let de;t[55]!==e?(de=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=de):de=t[56];let q;t[57]!==de||t[58]!==P.breakdown.user?(q={key:"user",label:de,value:P.breakdown.user,color:"var(--status-success)"},t[57]=de,t[58]=P.breakdown.user,t[59]=q):q=t[59];let Q;t[60]!==e?(Q=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=Q):Q=t[61];let L;t[62]!==Q||t[63]!==P.breakdown.assistant?(L={key:"assistant",label:Q,value:P.breakdown.assistant,color:"var(--primary-base)"},t[62]=Q,t[63]=P.breakdown.assistant,t[64]=L):L=t[64];let ne;t[65]!==e?(ne=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=ne):ne=t[66];let W;t[67]!==ne||t[68]!==P.breakdown.tool?(W={key:"tool",label:ne,value:P.breakdown.tool,color:"var(--status-warning)"},t[67]=ne,t[68]=P.breakdown.tool,t[69]=W):W=t[69];let te;t[70]!==e?(te=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=te):te=t[71];let Z;t[72]!==te||t[73]!==P.breakdown.other?(Z={key:"other",label:te,value:P.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=te,t[73]=P.breakdown.other,t[74]=Z):Z=t[74];let me;t[75]!==q||t[76]!==L||t[77]!==W||t[78]!==Z?(me=[q,L,W,Z],t[75]=q,t[76]=L,t[77]=W,t[78]=Z,t[79]=me):me=t[79];const Ie=me;let fe;t[80]!==n||t[81]!==P.sessionTitle?(fe=n?s.jsx(Vc,{children:s.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:s.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:P.sessionTitle,children:P.sessionTitle})})}):null,t[80]=n,t[81]=P.sessionTitle,t[82]=fe):fe=t[82];let je;t[83]!==n||t[84]!==P.sessionTitle?(je=n?null:s.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:P.sessionTitle}),t[83]=n,t[84]=P.sessionTitle,t[85]=je):je=t[85];const $e=!n&&"mt-1";let Re;t[86]!==$e?(Re=We($e,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground"),t[86]=$e,t[87]=Re):Re=t[87];let Fe;t[88]!==P.providerModel.modelName||t[89]!==P.providerModel.providerName?(Fe=s.jsxs("span",{children:[P.providerModel.providerName," / ",P.providerModel.modelName]}),t[88]=P.providerModel.modelName,t[89]=P.providerModel.providerName,t[90]=Fe):Fe=t[90];let Ve;t[91]!==r||t[92]!==P.createdAt?(Ve=P.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:mv(P.createdAt,r)})]}),t[91]=r,t[92]=P.createdAt,t[93]=Ve):Ve=t[93];let De;t[94]!==Re||t[95]!==Fe||t[96]!==Ve?(De=s.jsxs("div",{className:Re,children:[Fe,Ve]}),t[94]=Re,t[95]=Fe,t[96]=Ve,t[97]=De):De=t[97];let ge;t[98]!==je||t[99]!==De?(ge=s.jsxs("div",{className:"mb-6",children:[je,De]}),t[98]=je,t[99]=De,t[100]=ge):ge=t[100];let xe;t[101]!==e?(xe=e("contextSidebar.section.context"),t[101]=e,t[102]=xe):xe=t[102];let Se;t[103]!==xe?(Se=s.jsx("span",{className:"typography-micro text-muted-foreground",children:xe}),t[103]=xe,t[104]=Se):Se=t[104];let Be;t[105]!==P.tokenBreakdown.total||t[106]!==P.usagePercent?(Be=P.usagePercent===null?"—":un(P.tokenBreakdown.total),t[105]=P.tokenBreakdown.total,t[106]=P.usagePercent,t[107]=Be):Be=t[107];let Pe;t[108]!==P.contextLimit?(Pe=P.contextLimit?` / ${un(P.contextLimit)}`:"",t[108]=P.contextLimit,t[109]=Pe):Pe=t[109];let Me;t[110]!==Be||t[111]!==Pe?(Me=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[Be,Pe]}),t[110]=Be,t[111]=Pe,t[112]=Me):Me=t[112];let Je;t[113]!==Se||t[114]!==Me?(Je=s.jsxs("div",{className:"flex items-baseline justify-between",children:[Se,Me]}),t[113]=Se,t[114]=Me,t[115]=Je):Je=t[115];let X;t[116]!==P.usagePercent?(X=P.usagePercent!==null&&P.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,P.usagePercent)}%`,backgroundColor:P.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=P.usagePercent,t[117]=X):X=t[117];let Ee;t[118]!==X?(Ee=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:X}),t[118]=X,t[119]=Ee):Ee=t[119];let _e;t[120]!==e||t[121]!==P.usagePercent?(_e=P.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:P.usagePercent.toFixed(1)}),t[120]=e,t[121]=P.usagePercent,t[122]=_e):_e=t[122];let pe;t[123]!==_e?(pe=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:_e}),t[123]=_e,t[124]=pe):pe=t[124];let R;t[125]!==Je||t[126]!==Ee||t[127]!==pe?(R=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Je,Ee,pe]}),t[125]=Je,t[126]=Ee,t[127]=pe,t[128]=R):R=t[128];let ie;t[129]!==e?(ie=e("contextSidebar.stats.messages"),t[129]=e,t[130]=ie):ie=t[130];let Ce;t[131]!==P.messagesCount?(Ce=un(P.messagesCount),t[131]=P.messagesCount,t[132]=Ce):Ce=t[132];let Ne;t[133]!==ie||t[134]!==Ce?(Ne={label:ie,value:Ce},t[133]=ie,t[134]=Ce,t[135]=Ne):Ne=t[135];let ze;t[136]!==e?(ze=e("contextSidebar.stats.user"),t[136]=e,t[137]=ze):ze=t[137];let qe;t[138]!==P.userMessagesCount?(qe=un(P.userMessagesCount),t[138]=P.userMessagesCount,t[139]=qe):qe=t[139];let Ue;t[140]!==ze||t[141]!==qe?(Ue={label:ze,value:qe},t[140]=ze,t[141]=qe,t[142]=Ue):Ue=t[142];let tt;t[143]!==e?(tt=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=tt):tt=t[144];let He;t[145]!==P.assistantMessagesCount?(He=un(P.assistantMessagesCount),t[145]=P.assistantMessagesCount,t[146]=He):He=t[146];let Ze;t[147]!==tt||t[148]!==He?(Ze={label:tt,value:He},t[147]=tt,t[148]=He,t[149]=Ze):Ze=t[149];let Qe;t[150]!==e?(Qe=e("contextSidebar.stats.cost"),t[150]=e,t[151]=Qe):Qe=t[151];let ot;t[152]!==P.totalAssistantCost?(ot=md(P.totalAssistantCost),t[152]=P.totalAssistantCost,t[153]=ot):ot=t[153];let pt;t[154]!==Qe||t[155]!==ot?(pt={label:Qe,value:ot},t[154]=Qe,t[155]=ot,t[156]=pt):pt=t[156];let at;t[157]!==Ne||t[158]!==Ue||t[159]!==Ze||t[160]!==pt?(at=[Ne,Ue,Ze,pt],t[157]=Ne,t[158]=Ue,t[159]=Ze,t[160]=pt,t[161]=at):at=t[161];const xt=at;let le;t[162]!==xt?(le=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:xt.map(Iv)}),t[162]=xt,t[163]=le):le=t[163];let be;t[164]!==e?(be=e("contextSidebar.section.sessionTotals"),t[164]=e,t[165]=be):be=t[165];let Ae;t[166]!==be||t[167]!==P.sessionTotals?(Ae=s.jsx(ll,{title:be,figures:P.sessionTotals}),t[166]=be,t[167]=P.sessionTotals,t[168]=Ae):Ae=t[168];let N;t[169]!==e?(N=e("contextSidebar.section.lastAssistantMessage"),t[169]=e,t[170]=N):N=t[170];const ce=P.tokenBreakdown.input+P.tokenBreakdown.cacheRead+P.tokenBreakdown.cacheWrite,U=P.cacheHitRate.hasInput?P.cacheHitRate.percent:null;let we;t[171]!==ce||t[172]!==U||t[173]!==P.tokenBreakdown?(we={...P.tokenBreakdown,prompt:ce,cacheHitPercent:U},t[171]=ce,t[172]=U,t[173]=P.tokenBreakdown,t[174]=we):we=t[174];let ke;t[175]!==N||t[176]!==we?(ke=s.jsx(ll,{title:N,figures:we}),t[175]=N,t[176]=we,t[177]=ke):ke=t[177];let Xe;t[178]!==Ie||t[179]!==P.breakdownTotal?(Xe=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Ie.map(Ke=>Ke.value<=0||P.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${Ke.value/P.breakdownTotal*100}%`,backgroundColor:Ke.color}},Ke.key))}),t[178]=Ie,t[179]=P.breakdownTotal,t[180]=Xe):Xe=t[180];let Oe;t[181]!==Ie||t[182]!==P.breakdownTotal?(Oe=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Ie.map(Ke=>{const ct=P.breakdownTotal>0?Ke.value/P.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ke.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[Ke.label," ",s.jsxs("span",{className:"tabular-nums",children:[ct.toFixed(0),"%"]})]})]},Ke.key)})}),t[181]=Ie,t[182]=P.breakdownTotal,t[183]=Oe):Oe=t[183];let se;t[184]!==Xe||t[185]!==Oe?(se=s.jsxs("div",{className:"mb-6",children:[Xe,Oe]}),t[184]=Xe,t[185]=Oe,t[186]=se):se=t[186];let ue;t[187]!==e?(ue=e("contextSidebar.section.rawMessages"),t[187]=e,t[188]=ue):ue=t[188];let et;t[189]!==ue?(et=s.jsx("div",{className:"typography-micro text-muted-foreground",children:ue}),t[189]=ue,t[190]=et):et=t[190];let ye;if(t[191]!==d||t[192]!==i||t[193]!==h||t[194]!==r){let Ke;t[196]!==d||t[197]!==i||t[198]!==r?(Ke=ct=>s.jsx(gv,{message:ct,isExpanded:i[ct.info.id]===!0,isCopied:d===ct.info.id,timeFormatPreference:r,onToggle:T,onCopy:_},ct.info.id),t[196]=d,t[197]=i,t[198]=r,t[199]=Ke):Ke=t[199],ye=[...h].reverse().map(Ke),t[191]=d,t[192]=i,t[193]=h,t[194]=r,t[195]=ye}else ye=t[195];let bt;t[200]!==ye?(bt=s.jsx("div",{className:"mt-2.5 space-y-1",children:ye}),t[200]=ye,t[201]=bt):bt=t[201];let Tt;t[202]!==et||t[203]!==bt?(Tt=s.jsxs("div",{children:[et,bt]}),t[202]=et,t[203]=bt,t[204]=Tt):Tt=t[204];let vt;t[205]!==ge||t[206]!==R||t[207]!==le||t[208]!==Ae||t[209]!==ke||t[210]!==se||t[211]!==Tt?(vt=s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ge,R,le,Ae,ke,se,Tt]}),t[205]=ge,t[206]=R,t[207]=le,t[208]=Ae,t[209]=ke,t[210]=se,t[211]=Tt,t[212]=vt):vt=t[212];let Pt;return t[213]!==fe||t[214]!==vt?(Pt=s.jsxs(gs,{outerClassName:"h-full",className:"bg-background",children:[fe,vt]}),t[213]=fe,t[214]=vt,t[215]=Pt):Pt=t[215],Pt};function bv(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value===null?"—":t.format==="percent"?`${t.value.toFixed(1)}%`:un(t.value)})]},t.label)}function wv(t){return t.timeFormatPreference}function yv(t){return t.currentSessionId}function vv(t){return t.currentSessionDirectory}function Sv(t){return t.providers}function kv(t){return Object.keys(t).length>0?{}:t}function jv(t){return t.info.role==="assistant"}function Cv(t){return t.info.role==="user"}function Tv(t){return t.info}function Nv(t,e){const n=Bs(e.info.cost);return t+n}function Ev(t){return t.info.role==="system"}function Iv(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}const Mr=(t,e)=>{const[n,r]=c.useState(null),o=t?.id??null;return e&&n!==o&&r(o),e||n===null||n===o?t:null},Pv=280,Rv=.28,Dv=240,_v=.35,Av=(t,e,n=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=n?n.top:i-Math.min(Dv,e.height*_v),d=Math.min(Pv,t.width*Rv,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)}}},Uo=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,Ov=(t,e)=>Uo(t.bottom,e)?"bottom":Uo(t.left,e)?"left":Uo(t.right,e)?"right":null,Gs=bo(()=>({drag:null,hovered:null})),Fr=t=>{if(!t)return null;const{left:e,top:n,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:n,width:r,height:o}:null},Vo=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),Ho=t=>Fr(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Wd=t=>{const e=Fr(document.querySelector("[data-workspace-row]")),n=Fr(document.querySelector("[data-workspace-chat]"));if(!e||!n)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=Av(e,n,Fr(r)),i={left:Ho("left")??Vo(o.left),right:Ho("right")??Vo(o.right),bottom:Ho("bottom")??Vo(o.bottom)};return Gs.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Ud=t=>{const{drag:e,hovered:n}=Gs.getState();if(!e)return;const r=Ov(e.targets,t);r!==n&&Gs.setState({hovered:r})},mi=()=>{Gs.getState().drag&&Gs.setState({drag:null,hovered:null})},Vd=t=>{const{drag:e,hovered:n}=Gs.getState();if(Gs.setState({drag:null,hovered:null}),!e||!n)return!1;const r=G.getState();n!==e.from&&r.moveContextSurfaceToZone(e.mode,n);const o=t?fs(t):"";if(o){const i=G.getState();Ti(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Qi=(t,e)=>{let n=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(n||(n=Wd(t)),n&&Ud(a)):n&&(mi(),n=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),n?(Vd(i),!0):!1),cancel:()=>{o(),n&&mi()}}},cl={left:null,right:null,bottom:null},ur=bo(()=>({body:cl,headerSlot:cl})),Hd=(t,e,n)=>{const r=ur.getState()[t];r[e]!==n&&ur.setState({[t]:{...r,[e]:n}})},Mv=(t,e)=>Hd("body",t,e),Fv=(t,e)=>Hd("headerSlot",t,e),Yn=t=>{const e=c.useRef(t);e.current=t;const[n,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{Mi(o)},[t,o]),c.useEffect(()=>()=>Kc(o),[o]),n},qo=t=>{const e=Yn(t);return t||e},Lv=hr(()=>Lt(()=>import("./GitView-ZI_EafL9.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}))),ea=320,qd=320,$v=24,Bv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},dl=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(ea,Math.round(t))):Pi,zv=t=>t===null?Number.POSITIVE_INFINITY:Math.max(ea,t-qd),ul=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Lr=(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"):_n(t)?sr.getState().guests.find(r=>r.id===Ur(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Wv=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},Uv=(t,e,n)=>{if(t.mode==="chat"){const r=yo(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?oo(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Wv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Lr(t.mode,n)},Vv=t=>{const e=Le.c(8),{mode:n}=t,r=Ki();let o;if(e[0]!==n||e[1]!==r){let l;e[3]!==n?(l=f=>f.mode===n,e[3]=n,e[4]=l):l=e[4],o=r.find(l),e[0]=n,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??rg,d=i?.iconSrc;let u;return e[5]!==a||e[6]!==d?(u=s.jsx(fo,{icon:a,iconSrc:d,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u},Hv=t=>{const e=Le.c(2),{sessionId:n}=t,r=jc(n);let o;return e[0]!==r?(o=r?s.jsx(Tc,{state:r,className:"h-3.5 w-3.5"}):s.jsx(oe,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},qv=t=>{const e=Le.c(6),{url:n}=t,r=mo(),o=Wc();let i;if(e[0]!==o||e[1]!==n||e[2]!==r){const u=n?Uc(n,r,o):null;i=u?u.source==="tracker"?ng(u.provider).icon:sg[u.kind]:"git-branch",e[0]=o,e[1]=n,e[2]=r,e[3]=i}else i=e[3];const a=i;let d;return e[4]!==a?(d=s.jsx(oe,{name:a,className:"h-3.5 w-3.5"}),e[4]=a,e[5]=d):d=e[5],d},fl=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(ho,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(wc,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(oe,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(oe,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(qv,{url:t.targetPath});if(t.mode==="notes")return s.jsx(oe,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(oe,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(oe,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="workflows")return s.jsx(oe,{name:"flow-chart",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const n=yo(t.dedupeKey);return n?s.jsx(Hv,{sessionId:n}):s.jsx(oe,{name:"chat-4",className:"h-3.5 w-3.5"})}if(_n(t.mode))return s.jsx(Vv,{mode:t.mode});if(t.mode==="browser"){const n=Kv(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(oe,{name:"global",className:"h-3.5 w-3.5"})}},Kv=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Gv=t=>{const e=Zc(),n=c.useRef(Zr),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=uy(i,r.current);return cy(n.current,a)?n.current:(n.current=a,a)},[e]),()=>Zr)},Zv=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Xv=8,Yv='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',Jv=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="workflows",Kd=320,ta=160,hi=200,Qv={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(ta,Math.round(t))):Kd,e0=t=>t===null?Number.POSITIVE_INFINITY:Math.max(ta,t-hi),Ko=({zone:t="right"})=>{const e=Qv[t],n=co(),r=e.axis==="y",{t:o,direction:i}=rt(),a=i==="rtl",d=Zs()??"",u=ec(Jh(d||null)),l=c.useCallback((re,Ye)=>o(Vs(re,u),Ye),[u,o]),f=c.useMemo(()=>Bv(d),[d]),m=G(re=>f?re.contextPanelByDirectory[f]:void 0),p=G(re=>re.contextSurfaceZones),h=G(re=>re.shortcutOverrides),x=G(re=>re.closeContextZone),g=G(re=>re.closeContextPanelTab),b=G(re=>re.pinContextPanelTab),w=G(re=>re.toggleContextPanelExpanded),j=G(re=>re.setContextZoneSize),v=G(re=>re.setContextZoneExpandedChatSize),T=G(re=>re.setActiveContextPanelTab),F=G(re=>re.reorderContextPanelTabs),_=G(re=>re.contextEditorTreeVisible),A=G(re=>re.contextEditorTreeWidth),M=G(re=>re.setContextEditorTreeWidth),S=G(re=>re.toggleContextEditorTree),k=G(re=>re.contextEditorVisible),C=G(re=>re.toggleContextEditor),y=G(re=>re.fileTreeSide),E=G(re=>re.openNewContextBrowserTab),B=$d(re=>re.byOrigin),[$,O]=c.useState(null),z=c.useCallback(re=>{O(re),Fv(t,re)},[t]),J=c.useCallback(re=>{Mv(t,re)},[t]),K=c.useMemo(()=>m?.tabs??[],[m?.tabs]),ee=m?Wr(m,p,t):null,V=m?tr(m,t):Ku,Y=Or(re=>re.workStatusReserved),ae=Or(re=>re.workStatusBesidePanel),P=Or(re=>re.chatCovered),de=t==="bottom"&&P,q=!!(V.isOpen&&ee)&&!de,Q=Mr(ee,q),L=c.useMemo(()=>K.some(re=>re.mode==="file"&&re.targetPath),[K]),ne=L&&(k||!_),W=!r&&Q?.mode==="file"&&!ne,te=!!(q&&V.expanded&&!W),Z=G(re=>re.contextZoneSizes[t]),me=W?A:r?pl(Z??Kd,Number.POSITIVE_INFINITY):dl(Z??Pi,Number.POSITIVE_INFINITY),Ie=c.useCallback((re,Ye)=>r?pl(re,e0(Ye)):dl(re,zv(Ye)),[r]),fe=r?hi:qd,je=G(re=>r?0:re.sidebarWidth),$e=G(re=>re.contextZoneExpandedChatSizes[t]),Re=Math.max(fe,$e??(r?hi:je)),Fe=t==="right"?"left":t==="left"?"right":null,Ve=G(re=>{if(!Fe||!f)return 0;const Ye=re.contextPanelByDirectory[f],gt=Ye&&Gn(Ye,re.contextSurfaceZones,Fe)?Wr(Ye,re.contextSurfaceZones,Fe):null;return Ye&>?Gu(Ye,gt,Fe,re):0}),De=Fe==="right"&&Y&&!P&&Ve===0?kn:Ve,ge=t==="right"&&Y&&!P,xe=ge&&ae&&!te,[Se,Be]=c.useState(null),Pe=c.useRef(null),Me=c.useRef(De);Me.current=De;const Je=c.useRef(q);Je.current=q;const X=c.useRef(()=>!1);X.current=re=>te||!W&&re-Me.current-fe<me;const Ee=c.useCallback(()=>{let re=Pe.current;if(re!==null&&!r&&Je.current){const Ye=document.querySelector("[data-left-sidebar]");Ye&&(re+=Math.round(Ye.getBoundingClientRect().width-(Number.parseFloat(Ye.style.width)||0)))}Be(re!==null&&X.current(re)?re:null)},[r]),_e=Se!==null?Se-De:null,pe=W?me:te&&_e!==null?Math.max(r?ta:ea,_e-Re):Ie(me,_e),R=q&&Q?.mode==="chat",ie=c.useMemo(()=>{const re=[];if(!R)return re;for(const Ye of K){if(Ye.mode!=="chat")continue;const gt=yo(Ye.dedupeKey);gt&&!re.includes(gt)&&re.push(gt)}return re},[R,K]),Ce=Gv(ie),[Ne,ze]=c.useState(!1),qe=c.useRef(0),Ue=c.useRef(pe),tt=c.useRef(null),He=c.useRef(null),Ze=c.useRef(null),Qe=c.useRef(null),ot=c.useRef(!1);c.useLayoutEffect(()=>{const re=r?Ze.current?.parentElement:Ze.current?.closest("[data-workspace-row]");if(!re||typeof ResizeObserver>"u")return;const Ye=new ResizeObserver(gt=>{const wt=gt[gt.length-1]?.contentRect,_t=r?wt?.height:wt?.width;Pe.current=_t?Math.round(_t):null,Mi(Ee)});return Ye.observe(re),Pe.current=(r?re.clientHeight:re.clientWidth)||null,Ee(),()=>{Ye.disconnect(),Kc(Ee)}},[Ee,r]);const pt=!r&&q&&(te||Se!==null),at=G(re=>pt&&re.isSidebarOpen);c.useLayoutEffect(()=>{Ee()},[Ee,me,te,q,De,at]),c.useEffect(()=>{if(!q||ot.current){ot.current=q;return}const re=window.requestAnimationFrame(()=>{Qe.current?.focus({preventScroll:!0})});return ot.current=!0,()=>window.cancelAnimationFrame(re)},[q]);const xt=c.useRef(null),le=c.useRef(null),be=c.useRef(null),Ae=c.useRef(null),N=c.useRef(!1),ce=c.useRef(null),U=c.useRef(!1),we=c.useCallback(re=>{const Ye=Ze.current,gt=ce.current;if(!Ye||!gt)return;const wt=r?"height":"width";Ye.style[wt]=U.current?`${re+kn}px`:`min(${re}px, 100%)`,gt.style[wt]=`calc(${re}px - ${e.gutterSize})`},[e.gutterSize,r]),ke=c.useCallback(()=>{le.current=null;const re=tt.current;re!==null&&we(re)},[we]);c.useEffect(()=>()=>{le.current!==null&&cancelAnimationFrame(le.current),be.current?.(),be.current=null,Ae.current?.remove(),Ae.current=null},[]);const Xe=c.useCallback(re=>{const Ye=xt.current,gt=W?Jo(re):Ie(re,Ye);return Ye===null?gt:Math.min(gt,Math.max(1,Ye))},[Ie,W]),Oe=c.useCallback(re=>{if(!q||!f)return;He.current=re.pointerId,ze(!0),qe.current=r?re.clientY:re.clientX,Ue.current=pe,tt.current=pe;const Ye=r?Ze.current?.parentElement?.clientHeight:(Ze.current?.closest("[data-workspace-row]")?.clientWidth??0)-Me.current-(xe?kn:0);xt.current=Ye&&Ye>0?Ye:null,Ae.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),Ae.current=gt,be.current?.(),be.current=Ac(r?"height":"width"),re.preventDefault()},[xe,f,q,r,pe]),se=c.useCallback(()=>{const re=Xe(tt.current??pe),Ye=xt.current;le.current!==null&&(cancelAnimationFrame(le.current),le.current=null);const gt=Ze.current,wt=ce.current;if(gt&&wt){const _t=r?"height":"width";gt.style.setProperty(e.sizeVariable,`${re}px`),gt.style[_t]=Kt.current,wt.style[_t]=Os.current}tt.current=null,xt.current=null,N.current=!0,Ae.current?.remove(),Ae.current=null,W?M(re):te?Ye!==null&&v(t,Ye-re):j(t,re),ze(!1),He.current=null,be.current?.(),be.current=null},[Xe,e.sizeVariable,te,W,r,M,v,j,pe,t]);c.useEffect(()=>{if(!Ne)return;const re=wt=>{if(He.current!==wt.pointerId)return;const _t=r?wt.clientY:wt.clientX,Vt=t==="left"?_t-qe.current:qe.current-_t,H=!r&&a?-Vt:Vt,Ge=Xe(Ue.current+H);tt.current!==Ge&&(tt.current=Ge,le.current===null&&(le.current=requestAnimationFrame(ke)))},Ye=wt=>{He.current===wt.pointerId&&se()},gt=()=>{se()};return window.addEventListener("pointermove",re),window.addEventListener("pointerup",Ye),window.addEventListener("pointercancel",Ye),window.addEventListener("blur",gt),()=>{window.removeEventListener("pointermove",re),window.removeEventListener("pointerup",Ye),window.removeEventListener("pointercancel",Ye),window.removeEventListener("blur",gt)}},[ke,Xe,se,Ne,a,r,t]),c.useEffect(()=>{Ne||(tt.current=null,Ae.current?.remove(),Ae.current=null)},[Ne]);const ue=c.useCallback(()=>{f&&x(f,t)},[x,f,t]),et=c.useCallback(()=>{f&&w(f,t)},[f,w,t]),ye=Q?.mode==="file"||Q?.mode==="chat"||Q?.mode==="browser"||Q?.mode==="pr",bt=c.useMemo(()=>{if(!Q)return[];const re=K.filter(Ye=>Ye.mode===Q.mode);return Q.mode==="pr"?[...re.filter(jr),...re.filter(Ye=>!jr(Ye))]:re},[Q,K]),Tt=po(Q?.mode==="pr"&&f?f:null)?.current??null,vt=Q?.id,Pt=c.useMemo(()=>{const re=Qh(bt.filter(Ye=>Ye.mode==="file").map(Ye=>ul(Ye.targetPath,d)));return bt.map(Ye=>{const gt=jr(Ye),wt=gt?Tt||o("contextPanel.tracker.branchTab"):Uv(Ye,Ce,l),_t=Zv(wt,$v),Vt=ul(Ye.targetPath,d);return{id:Ye.id,label:_t,labelFolder:Ye.mode==="file"?re.get(Vt):void 0,icon:fl(Ye,B),title:Vt?`${wt}: ${Vt}`:wt,closeLabel:o("contextPanel.tab.closeTabAria",{label:_t}),closeShortcut:Ye.id===vt&&_s()?ms("mod+w",""):void 0,closable:!gt,preview:Ye.preview}})},[bt,vt,d,B,Ce,o,l,Tt]),Ke=Q?.mode==="context"?s.jsx(fn,{value:$,children:s.jsx(xv,{})}):Q?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(fn,{value:$,children:s.jsx(Lv,{isActive:q})})}):Q?.mode==="pr"?Q.targetPath?s.jsx(Jw,{url:Q.targetPath,directory:Q.targetDirectory??d,panelDirectory:d,tabId:Q.id,foreign:!!Q.targetDirectory,visible:q},Q.id):s.jsx(Ww,{}):Q?.mode==="notes"?s.jsx(fn,{value:$,children:s.jsx(ep,{visible:q})}):Q?.mode==="workflows"?s.jsx(fn,{value:$,children:s.jsx(Hy,{directory:d||null})}):null,ct=Q?.mode==="file",Rt=ct&&!!Q?.targetPath&&ne,ht=q&&Q&&ye&&!Rt&&!jr(Q)?Q.id:null;c.useEffect(()=>{if(!(!f||!ht))return dc(()=>g(f,ht),Ze)},[g,f,ht]);const Ct=G(re=>re.closeContextPanelTabs),lt=c.useCallback(re=>{if(!f)return null;const{id:Ye,index:gt,allIds:wt,close:_t}=re,Vt=()=>Ct(f,wt.filter(Rs=>Rs!==Ye)),H=wt.slice(0,gt),Ge=wt.slice(gt+1),mt=()=>Ct(f,a?Ge:H),It=()=>Ct(f,a?H:Ge),$t=()=>Ct(f,wt),Bt=wt.length>1,Ft=a?gt===wt.length-1:gt===0,js=a?gt===0:gt===wt.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Cs,{onClick:_t,children:[s.jsx(oe,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),s.jsx(In,{}),s.jsxs(Cs,{onClick:Vt,disabled:!Bt,children:[s.jsx(oe,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Cs,{onClick:mt,disabled:Ft,children:[s.jsx(oe,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Cs,{onClick:It,disabled:js,children:[s.jsx(oe,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),s.jsx(In,{}),s.jsxs(Cs,{onClick:$t,disabled:!Bt,children:[s.jsx(oe,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),Q?s.jsxs(s.Fragment,{children:[s.jsx(In,{}),s.jsx(bc,{mode:Q.mode})]}):null]})},[Q,Ct,f,a,o]),Et=c.useCallback((re,Ye)=>{const gt=K.find(_t=>_t.id===re);if(!gt)return null;const wt=Qi({mode:gt.mode,label:Lr(gt.mode,l),from:t},Ye);return{finish:()=>wt.finish(f),cancel:wt.cancel}},[f,l,K,t]),[qt,dt]=c.useState(null),ut=c.useCallback(re=>{if(!Q||re.button!==0||re.pointerType==="touch"||re.target instanceof Element&&re.target.closest(Yv))return;const Ye=Q.mode,gt=Lr(Ye,l),wt={x:re.clientX,y:re.clientY};let _t=!1;const Vt=It=>{const $t={x:It.clientX,y:It.clientY};!_t&&(Math.hypot($t.x-wt.x,$t.y-wt.y)<Xv||(_t=Wd({mode:Ye,label:gt,from:t}),!_t))||Ud($t)},H=()=>{window.removeEventListener("pointermove",Vt),window.removeEventListener("pointerup",Ge),window.removeEventListener("pointercancel",mt),window.removeEventListener("blur",mt)},Ge=()=>{H(),_t&&Vd(f)},mt=()=>{H(),_t&&mi()};window.addEventListener("pointermove",Vt),window.addEventListener("pointerup",Ge),window.addEventListener("pointercancel",mt),window.addEventListener("blur",mt)},[Q,f,l,t]);c.useEffect(()=>{if(qt)return qt.addEventListener("pointerdown",ut),()=>qt.removeEventListener("pointerdown",ut)},[ut,qt]);const Ot=s.jsxs("header",{ref:dt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[ye?s.jsx(eg,{items:Pt,activeId:Q?.id??null,onSelect:re=>{f&&T(f,re)},onClose:re=>{f&&g(f,re)},onReorder:(re,Ye)=>{f&&F(f,re,Ye)},onDoubleClickTab:re=>{f&&b(f,re)},layoutMode:"scrollable",variant:"default",tabContextMenu:lt,onTabDragOut:Et}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[Q?fl(Q,B):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:Q?Lr(Q.mode,l):null})]}),s.jsx("div",{ref:z,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),s.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[Q?.mode==="browser"?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&E(f)},className:"h-7 w-7 p-0","aria-label":o("contextPanel.browser.newTab"),children:s.jsx(oe,{name:"add",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.browser.newTab")})]}):null,ct?["left","right"].map(re=>{const Ye=re===y;if(!Ye&&!L)return null;const gt=o(Ye?"contextRail.editorTree.toggle":"contextRail.editor.toggle"),wt=Ye?_:ne,_t=o(Ye?wt?"contextTooltips.panel.hideFileTree":"contextTooltips.panel.showFileTree":wt?"contextTooltips.panel.hideFileEditor":"contextTooltips.panel.showFileEditor");return s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:Ye?S:C,className:"h-7 w-7 p-0","aria-label":gt,"aria-pressed":wt,children:s.jsx(oe,{name:re==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:_t})]},re)}):null,W?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:et,className:"h-7 w-7 p-0","aria-label":o(te?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:te?s.jsx(oe,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(oe,{name:"fullscreen",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:s.jsx(Ks,{label:o(te?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),shortcut:ms(Ts("toggle_context_panel_expanded",h),"")})})]}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:ue,className:"h-7 w-7 p-0","aria-label":o("contextPanel.actions.closePanel"),children:s.jsx(oe,{name:"close",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("contextPanel.actions.closePanel")})]})]})]}),Zt=q?xe?`calc(var(${e.sizeVariable}) + ${kn}px)`:`min(var(${e.sizeVariable}), 100%)`:ge?`${kn}px`:"0px",is=xe?`${kn}px`:"0px";U.current=xe;const as=t==="bottom"&&Gn(m,p,"left"),ss=t==="bottom"&&(Y&&!P||Gn(m,p,"right")),Xt=`${q}|${te}|${ge}|${q&&xe}|${q?me:""}`,ls=c.useRef(Xt),ns=c.useRef(P),Is=ns.current!==P;c.useLayoutEffect(()=>{ns.current=P},[P]),c.useLayoutEffect(()=>{if(ls.current===Xt)return;ls.current=Xt;const re=N.current;!Is&&!re&&_c(n)},[Xt,Is,n]),c.useLayoutEffect(()=>{N.current=!1});const Ps=!Dr(q,Yn(q),Q?.mode),cs={[e.sizeVariable]:`${pe}px`,...r?{height:Zt,maxHeight:"100%"}:{width:Zt,maxWidth:"100%"},transitionDuration:Is||Ne?"0ms":`${n}ms`,transitionTimingFunction:An},rs=`calc(var(${e.sizeVariable}) - ${e.gutterSize})`,Kt=c.useRef(Zt);Kt.current=Zt;const Os=c.useRef(rs);return Os.current=rs,s.jsxs("aside",{ref:Ze,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":q?"true":"false",tabIndex:-1,className:We("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:cs,children:[s.jsx("div",{ref:Qe,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?s.jsx("div",{ref:tg,className:We("absolute inset-y-0 z-0 flex",xe?"inset-s-0":"inset-e-0",P&&"invisible")}):null,q&&s.jsx("div",{className:e.handle,style:{marginInlineStart:is},onPointerDown:Oe,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{ref:ce,"data-zone-card":"",className:We("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(as?"ms-0":"ms-2"),t==="bottom"&&(ss?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity,margin-inline-start]",!q&&"opacity-0",Ps&&"pointer-events-none select-none"),style:{...r?{height:rs,width:`calc(100% - ${(as?0:.5)+(ss?0:.375)}rem)`}:{width:rs},...t==="right"?{marginInlineStart:`calc(0.5rem + ${is})`}:null,transitionDuration:Ne?"0ms":`${n}ms`,transitionTimingFunction:An},inert:Ps||void 0,children:s.jsxs(Gc.Provider,{value:!0,children:[Ot,s.jsx("div",{ref:J,className:"relative min-h-0 flex-1 overflow-hidden",children:Q&&Jv(Q.mode)?Ke:null})]})})]})},t0=sn({port:wo().int().positive(),url:Ns().min(1),command:Ns(),directory:Ns().min(1).optional()}),s0=t=>{const e=sn({servers:jd(mx())}).safeParse(t);return e.success?e.data.servers.flatMap(n=>{const r=t0.safeParse(n);return r.success?[r.data]:[]}):null},n0=async(t,e)=>{try{const n=await qs("/api/dev-servers",{signal:t,directory:e});if(!n.ok)return{kind:"unavailable"};const r=s0(await n.json());return r?{kind:"ready",servers:r}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},r0=async t=>{try{const e=await qs("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},o0=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},i0=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const o=o0(r);o!==null&&!n.has(o)&&n.set(o,r)}return e?e.map(r=>{const o=n.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0,directory:r.directory}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...n.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},a0=(t,e)=>e===t||e.startsWith(t.endsWith("/")?t:`${t}/`),ml=(t,e)=>{if(!e)return null;let n=null;for(const r of t)a0(r.path,e)&&(!n||r.path.length>n.path.length)&&(n=r);return n},l0=t=>t.slice(t.lastIndexOf("/")+1)||t,c0=({candidates:t,folders:e,directory:n})=>{const r=e.flatMap(u=>{const l=Yt(u.path),f=Yt(u.projectPath);return l&&f?[{path:l,projectPath:f}]:[]}),o=Yt(n),i=o?{path:o,projectPath:ml(r,o)?.projectPath??o}:null,a=i?[...r,i]:r;return t.map(u=>{const l=Yt(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?l0(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)},d0=t=>({sessionId:t.sessionId,directory:t.directory?fs(t.directory):null}),u0=2e3,f0=sn({title:Ns(),settled:dr()}),p0=4e4,m0=50,Jn=400,hs=new Map,As=new Map;let gi=null,xi=null;const fr=new Map;let zs=null,en=null,Qn=null;const Ws=async t=>{try{const e=await qs("/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}},h0=async(t,e)=>{try{const n=await qs("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},Gd=async(t,e=u0)=>{const n=Date.now()+e;for(;!hs.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,m0));return hs.get(t)??null},Yr=t=>hs.has(t)||As.has(t),Fn=t=>hs.get(t)??As.get(t)??null,bi=()=>[...hs.values(),...[...As.values()].filter(t=>!hs.has(t.tabId))],sa=t=>{const e=xi?Fn(xi):null,n=e?.directory===gi?e:null;if(!t.sessionId){if(n)return n.tabId;const i=bi().filter(u=>u.directory===gi),a=i.filter(u=>hs.has(u.tabId)),d=a.length>0?a:i;return d.length>0?d[d.length-1].tabId:null}if(n?.ownerSessionId===t.sessionId)return n.tabId;const r=fr.get(t.sessionId);if(r&&Fn(r)?.ownerSessionId===t.sessionId)return r;const o=bi().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:n&&n.ownerSessionId===null&&(!t.directory||n.directory===t.directory)?n.tabId:null},g0=t=>{const e=sa(t);return e&&Fn(e)?.ownerSessionId===t.sessionId?e:null},x0=(t,e)=>{t.sessionId&&Fn(e)?.ownerSessionId===t.sessionId&&fr.set(t.sessionId,e)},Zd=async t=>{const e=hs.get(t);if(e)return e;const n=As.get(t);return n?(n.wake(),Gd(t)):null},Xd=t=>{const e=sa(t);return bi().filter(n=>!t.sessionId||!t.directory||n.ownerSessionId===t.sessionId||n.directory===t.directory).map(n=>{let r={title:"",url:""};try{r=n.describe()}catch{}const o=n.ownerSessionId===null?"user":n.ownerSessionId===t.sessionId?"you":"another session";return{id:n.tabId,title:r.title,url:r.url,owner:o,active:n.tabId===e}})},Yd=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Jd=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.`,b0=t=>{const e=Xd(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
|
`)}`:"")},w0=()=>"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.",y0=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.`,v0=()=>"This browser.close did not come from a session, so there is no tab it opened to close. Nothing was closed.",es=(t,e)=>h0(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:Xc()})}:e),S0=async(t,e,n)=>{if(!e.sessionId){if(!await Ws(t.requestId))return;await es(t,{ok:!1,error:v0()});return}const r=n??g0(e);if(r===null){if(await new Promise(a=>setTimeout(a,Jn)),!await Ws(t.requestId))return;await es(t,{ok:!1,error:w0()});return}if(!Yr(r)){if(hs.size===0&&As.size===0&&!en)return;if(await new Promise(a=>setTimeout(a,Jn)),!Yr(r)){if(!await Ws(t.requestId))return;await es(t,{ok:!1,error:Jd(r)});return}}const o=Fn(r);if(!o||o.ownerSessionId!==e.sessionId){if(!await Ws(t.requestId))return;await es(t,{ok:!1,error:y0(r)});return}if(!await Ws(t.requestId))return;if(!(en?en(o.directory,r):!1)){await es(t,{ok:!1,error:en?`The browser tab ${r} could not be closed.`:"There is no browser here to close a tab in."});return}e.sessionId&&fr.get(e.sessionId)===r&&fr.delete(e.sessionId),await es(t,{ok:!0,data:{closed:!0,tabId:r}})},k0=async t=>{const e=t.action==="browser.open",n=t.action==="browser.close",r=d0(t.context),{tabId:o,...i}=t.parameters,a=o===void 0?null:String(o);if(n){await S0(t,r,a);return}if(a!==null){if(!Yr(a)){if(hs.size===0&&As.size===0&&!zs)return;if(await new Promise(l=>setTimeout(l,Jn)),Yr(a)){await hl(t,r,a,i);return}if(!await Ws(t.requestId))return;await es(t,{ok:!1,error:Jd(a)});return}await hl(t,r,a,i);return}const d=sa(r);if(!d&&!(e&&zs)){if(!r.sessionId||(await new Promise(l=>setTimeout(l,Jn)),!await Ws(t.requestId)))return;await es(t,{ok:!1,error:b0(r)});return}if(!(e&&zs!==null)&&r.sessionId&&Fn(d)?.ownerSessionId!==r.sessionId&&await new Promise(l=>setTimeout(l,Jn)),!!await Ws(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await es(t,{ok:!1,error:"url is required"});return}const f=Date.now(),m=e&&zs?zs(l,t.context):null;if(e&&!m&&!d){await es(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(m){r.sessionId&&fr.set(r.sessionId,m);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"",x=!!h&&h!=="fill",g=Xc();if(!x&&!g){await es(t,{ok:!0,data:{url:l,opened:!0,tabId:m}});return}const b=await Gd(m);if(!b&&!x){await es(t,{ok:!0,data:{url:l,opened:!0,tabId:m,settled:!1}});return}if(!b){await es(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 w=x?await b.run("browser.resize",{viewport:h}):null,j=w&&typeof w=="object"?w.viewport??null:null,v=g?f0.safeParse(await b.run("browser.settle",{budgetMs:Math.max(0,p0-(Date.now()-f))}).catch(()=>null)):null;await es(t,{ok:!0,data:Object.assign({url:l,opened:!0,tabId:m},x?{viewportApplied:!0,viewport:j}:{},v?v.success?v.data:{settled:!1}:{})});return}const p=await Zd(d);await es(t,p?await Qd(p,r,t.action,i):{ok:!1,error:Yd(d)})}catch(l){await es(t,{ok:!1,error:l instanceof Error?l.message:String(l)})}},hl=async(t,e,n,r)=>{if(!await Ws(t.requestId))return;x0(e,n);const o=await Zd(n);await es(t,o?await Qd(o,e,t.action,r):{ok:!1,error:Yd(n)})},Qd=async(t,e,n,r)=>{try{const o=await t.run(n,r);return n==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:Xd(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},So=()=>{Qn||(Qn=tn(t=>{t.type==="browser-control-request"&&k0({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},ko=()=>{hs.size>0||As.size>0||zs||en||!Qn||(Qn(),Qn=null)},j0=t=>(hs.set(t.tabId,t),So(),()=>{hs.get(t.tabId)===t&&hs.delete(t.tabId),ko()}),C0=t=>(As.set(t.tabId,t),So(),()=>{As.get(t.tabId)===t&&As.delete(t.tabId),ko()}),T0=(t,e)=>{gi=t,e&&(xi=e)},N0=t=>(zs=t,So(),()=>{zs===t&&(zs=null),ko()}),E0=t=>(en=t,So(),()=>{en===t&&(en=null),ko()}),I0=50,P0=6,R0=2048,D0=200,eu=t=>{const e=En(String(t??"").trim());if(!e||e.length>R0)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},_0=(t,e)=>{const n=eu(e.url);if(!n)return t;const r=t.find(a=>a.url===n),o=String(e.title??"").trim().slice(0,D0)||r?.title||"";return[{url:n,title:o,lastVisitedAt:e.at},...t.filter(a=>a.url!==n)].slice(0,I0)},A0=(t,e)=>{const n=eu(e);return t.filter(r=>r.url!==n)},O0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),tu=(t,e,n=P0)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((a,d)=>d.lastVisitedAt-a.lastVisitedAt);if(!r)return o.slice(0,n);const i=r.replace(/^https?:\/\//,"");return o.filter(a=>{const d=O0(a);return a.url===r||d===i?!1:d.includes(i)}).slice(0,n)},gl=20,$r=t=>{const e=Yt((t||"").trim());return e?JSON.stringify([Jt(),e]):""},M0=t=>{const e=Object.keys(t);if(e.length<=gl)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,gl);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},Pn=bo()(px(t=>({byProject:{},recordVisit:(e,n)=>{const r=$r(e);r&&t(o=>{const i=o.byProject[r]??[],a=_0(i,{...n,at:Date.now()});return a===i?o:{byProject:M0({...o.byProject,[r]:a})}})},forget:(e,n)=>{const r=$r(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:A0(i,n)}}:o})},clear:e=>{const n=$r(e);n&&t(r=>{if(!(n in r.byProject))return r;const o={...r.byProject};return delete o[n],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Zu(),partialize:t=>({byProject:t.byProject})})),F0=[],su=t=>e=>{const n=$r(t);return(n?e.byProject[n]:void 0)??F0},na=t=>{const e=Le.c(10),{t:n}=rt();let r;e[0]!==t?(r=ks(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=pn(i);if(o===null)return null;if(!a){let l;return e[4]!==n?(l=n("contextPanel.browser.spaceAddress"),e[4]=n,e[5]=l):l=e[5],l}let d;e[6]!==a.machine||e[7]!==a.placeId||e[8]!==n?(d=a.machine??(a.placeId==="docker"?n("spaces.create.place.localDocker"):a.placeId),e[6]=a.machine,e[7]=a.placeId,e[8]=n,e[9]=d):d=e[9];const u=d;return`${a.name} · ${u}`},xl=6e3,L0=120,$0=80,B0=32,z0=100,W0=`
|
|
8
8
|
var MAX_ELEMENTS = ${L0};
|
|
@@ -495,4 +495,4 @@ ${t}
|
|
|
495
495
|
inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
|
|
496
496
|
styles: styles
|
|
497
497
|
};
|
|
498
|
-
`),Y0=t=>{const e=Le.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:d}=rt();if(n.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]!==n||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)=>s.jsxs("div",{role:"option","aria-selected":h===r,className:We("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:[s.jsx(oe,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||oo(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:We("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:s.jsx(oe,{name:"close",className:"size-3","aria-hidden":"true"})})}),s.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=n.map(m),e[2]=r,e[3]=n,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=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":u,children:l}),e[15]=u,e[16]=l,e[17]=f):f=e[17],f},vs=t=>{const e=Le.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:a}=t,d=a?"secondary":"ghost",u=a&&"text-foreground";let l;e[0]!==u?(l=We("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]!==n?(f=s.jsx(oe,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,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=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:s.jsx(ft,{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=s.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=s.jsxs(kt,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=h):h=e[16],h},nu=t=>{const e=Le.c(110),{address:n,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:b,onOpenDevTools:w,isAnnotating:j,onHardReload:v,onZoomIn:T,onZoomOut:F,onZoomReset:_,zoomPercent:A,onClearCookies:M,onClearCache:S,onToggleDeviceBar:k,isDeviceBarOpen:C}=t;let y;e[0]!==o?(y=o===void 0?[]:o,e[0]=o,e[1]=y):y=e[1];const E=y,B=p===void 0?!0:p,$=A===void 0?100:A,{t:O}=rt(),[z,J]=c.useState(!1),[K,ee]=c.useState(-1);let V;e[2]!==z||e[3]!==E?(V=z?E:[],e[2]=z,e[3]=E,e[4]=V):V=e[4];const Y=V;let ae;e[5]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>{ee(-1)},e[5]=ae):ae=e[5];let P;e[6]!==n||e[7]!==z?(P=[n,z],e[6]=n,e[7]=z,e[8]=P):P=e[8],c.useEffect(ae,P);let de;e[9]!==d?(de=He=>{J(!1),ee(-1),d(He)},e[9]=d,e[10]=de):de=e[10];const q=de;let Q;e[11]!==K||e[12]!==q||e[13]!==Y?(Q=He=>{if(Y.length!==0){if(He.key==="ArrowDown"||He.key==="ArrowUp"){He.preventDefault();const Ze=He.key==="ArrowDown"?1:-1,Qe=Y.length;ee(ot=>{const pt=ot+Ze;return pt<-1?Qe-1:pt>=Qe?-1:pt});return}if(He.key==="Escape"&&K>=0){He.preventDefault(),ee(-1);return}if(He.key==="Enter"&&K>=0){He.preventDefault();const Ze=Y[K];Ze&&q(Ze.url)}}},e[11]=K,e[12]=q,e[13]=Y,e[14]=Q):Q=e[14];const L=Q;let ne;e[15]!==O?(ne=O("contextPanel.browser.back"),e[15]=O,e[16]=ne):ne=e[16];const W=!h;let te;e[17]!==u||e[18]!==ne||e[19]!==W?(te=s.jsx(vs,{icon:"arrow-left",label:ne,onClick:u,disabled:W}),e[17]=u,e[18]=ne,e[19]=W,e[20]=te):te=e[20];let Z;e[21]!==O?(Z=O("contextPanel.browser.forward"),e[21]=O,e[22]=Z):Z=e[22];const me=!x;let Ie;e[23]!==l||e[24]!==Z||e[25]!==me?(Ie=s.jsx(vs,{icon:"arrow-right",label:Z,onClick:l,disabled:me}),e[23]=l,e[24]=Z,e[25]=me,e[26]=Ie):Ie=e[26];let fe;e[27]!==g||e[28]!==O?(fe=O(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=O,e[29]=fe):fe=e[29];let je;e[30]!==f||e[31]!==fe?(je=s.jsx(vs,{icon:"refresh",label:fe,onClick:f}),e[30]=f,e[31]=fe,e[32]=je):je=e[32];let $e;e[33]!==v||e[34]!==O?($e=v?s.jsx(vs,{icon:"restart",label:O("contextPanel.browser.hardReload"),onClick:v}):null,e[33]=v,e[34]=O,e[35]=$e):$e=e[35];let Re;e[36]!==n||e[37]!==q?(Re=He=>{He.preventDefault(),q(n)},e[36]=n,e[37]=q,e[38]=Re):Re=e[38];let Fe;e[39]!==r?(Fe=r?s.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:s.jsx(oe,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=Fe):Fe=e[40];let Ve;e[41]!==a?(Ve=He=>a(He.target.value),e[41]=a,e[42]=Ve):Ve=e[42];let De,ge;e[43]===Symbol.for("react.memo_cache_sentinel")?(De=()=>J(!0),ge=()=>J(!1),e[43]=De,e[44]=ge):(De=e[43],ge=e[44]);const xe=Y.length>0,Se=r&&"ps-8";let Be;e[45]!==Se?(Be=We("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",Se,"typography-micro text-foreground outline-none"),e[45]=Se,e[46]=Be):Be=e[46];let Pe;e[47]!==O?(Pe=O("contextPanel.browser.addressAria"),e[47]=O,e[48]=Pe):Pe=e[48];let Me;e[49]!==n||e[50]!==L||e[51]!==Ve||e[52]!==xe||e[53]!==Be||e[54]!==Pe?(Me=s.jsx("input",{value:n,onChange:Ve,onFocus:De,onBlur:ge,onKeyDown:L,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":xe,"aria-controls":"openchamber-browser-address-suggestions",className:Be,"aria-label":Pe}),e[49]=n,e[50]=L,e[51]=Ve,e[52]=xe,e[53]=Be,e[54]=Pe,e[55]=Me):Me=e[55];let Je;e[56]!==i?(Je=He=>i?.(He),e[56]=i,e[57]=Je):Je=e[57];let X;e[58]!==K||e[59]!==q||e[60]!==Je||e[61]!==Y?(X=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Y0,{entries:Y,activeIndex:K,onSelect:q,onForget:Je,onHighlight:ee})}),e[58]=K,e[59]=q,e[60]=Je,e[61]=Y,e[62]=X):X=e[62];let Ee;e[63]!==Re||e[64]!==Fe||e[65]!==Me||e[66]!==X?(Ee=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Re,children:[Fe,Me,X]}),e[63]=Re,e[64]=Fe,e[65]=Me,e[66]=X,e[67]=Ee):Ee=e[67];let _e;e[68]!==T||e[69]!==F||e[70]!==_||e[71]!==O||e[72]!==$?(_e=F&&T?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(vs,{icon:"subtract",label:O("contextPanel.browser.zoomOut"),onClick:F}),$!==100&&_?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:_,"aria-label":O("contextPanel.browser.zoomReset"),children:[$,"%"]})}),s.jsx(jt,{sideOffset:6,children:O("contextPanel.browser.zoomReset")})]}):null,s.jsx(vs,{icon:"add",label:O("contextPanel.browser.zoomIn"),onClick:T})]}):null,e[68]=T,e[69]=F,e[70]=_,e[71]=O,e[72]=$,e[73]=_e):_e=e[73];let pe;e[74]!==M||e[75]!==O?(pe=M?s.jsx(vs,{icon:"delete-bin",label:O("contextPanel.browser.clearCookies"),onClick:M}):null,e[74]=M,e[75]=O,e[76]=pe):pe=e[76];let R;e[77]!==S||e[78]!==O?(R=S?s.jsx(vs,{icon:"database-2",label:O("contextPanel.browser.clearCache"),onClick:S}):null,e[77]=S,e[78]=O,e[79]=R):R=e[79];let ie;e[80]!==C||e[81]!==k||e[82]!==O?(ie=k?s.jsx(vs,{icon:"smartphone",label:O("contextPanel.browser.deviceToolbar"),onClick:k,pressed:C}):null,e[80]=C,e[81]=k,e[82]=O,e[83]=ie):ie=e[83];let Ce;e[84]!==j||e[85]!==b||e[86]!==O?(Ce=b?s.jsx(vs,{icon:"markup",label:O("contextPanel.browser.annotate.toggle"),onClick:b,pressed:j}):null,e[84]=j,e[85]=b,e[86]=O,e[87]=Ce):Ce=e[87];let Ne;e[88]!==w||e[89]!==O?(Ne=w?s.jsx(vs,{icon:"terminal-box",label:O("contextPanel.browser.devTools"),onClick:w}):null,e[88]=w,e[89]=O,e[90]=Ne):Ne=e[90];let ze;e[91]!==O?(ze=O("contextPanel.browser.openExternal"),e[91]=O,e[92]=ze):ze=e[92];const qe=!B;let Ue;e[93]!==m||e[94]!==ze||e[95]!==qe?(Ue=s.jsx(vs,{icon:"external-link",label:ze,onClick:m,disabled:qe}),e[93]=m,e[94]=ze,e[95]=qe,e[96]=Ue):Ue=e[96];let tt;return e[97]!==te||e[98]!==Ie||e[99]!==je||e[100]!==$e||e[101]!==Ee||e[102]!==_e||e[103]!==pe||e[104]!==R||e[105]!==ie||e[106]!==Ce||e[107]!==Ne||e[108]!==Ue?(tt=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[te,Ie,je,$e,Ee,_e,pe,R,ie,Ce,Ne,Ue]}),e[97]=te,e[98]=Ie,e[99]=je,e[100]=$e,e[101]=Ee,e[102]=_e,e[103]=pe,e[104]=R,e[105]=ie,e[106]=Ce,e[107]=Ne,e[108]=Ue,e[109]=tt):tt=e[109],tt},Jr={kind:"fill"},bl=240,J0=3840,ru=[{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(J0,Math.max(bl,t))):bl,Qr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},ou=t=>{const e=ru.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Q0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},eS=(t,e)=>{const n=Qr(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},tS=["mobile","tablet","desktop","fill"],sS={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},yl=t=>typeof t=="string"&&tS.includes(t),wi=t=>t==="fill"?Jr:ou(sS[t])??Jr,Tr=t=>{const e=Qr(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=wi(n),o=Qr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},nS=t=>{const e=Le.c(77),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:d}=rt();let u;e[0]!==n?(u=Qr(n),e[0]=n,e[1]=u):u=e[1];const l=u,f=n.kind==="preset"?n.id:"";let m;e[2]!==r||e[3]!==l?(m=(W,te)=>{const Z=Number.parseInt(te,10);if(!Number.isFinite(Z))return;const me=l??{width:1280,height:800};r({kind:"custom",width:wl(W==="width"?Z:me.width),height:wl(W==="height"?Z:me.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=We("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=W=>{const te=ou(W.target.value);r(te??Jr)},e[6]=r,e[7]=g):g=e[7];let b;e[8]!==d?(b=d("contextPanel.browser.device.preset"),e[8]=d,e[9]=b):b=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=We("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=w):w=e[10];let j;e[11]!==d?(j=d("contextPanel.browser.device.responsive"),e[11]=d,e[12]=j):j=e[12];let v;e[13]!==j?(v=s.jsx("option",{value:"",children:j}),e[13]=j,e[14]=v):v=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=ru.map(rS),e[15]=T):T=e[15];let F;e[16]!==f||e[17]!==g||e[18]!==b||e[19]!==v?(F=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:s.jsxs("select",{value:f,onChange:g,"aria-label":b,className:w,children:[v,T]})})}),e[16]=f,e[17]=g,e[18]=b,e[19]=v,e[20]=F):F=e[20];let _;e[21]!==d?(_=d("contextPanel.browser.device.preset"),e[21]=d,e[22]=_):_=e[22];let A;e[23]!==_?(A=s.jsx(jt,{sideOffset:6,children:_}),e[23]=_,e[24]=A):A=e[24];let M;e[25]!==F||e[26]!==A?(M=s.jsxs(kt,{children:[F,A]}),e[25]=F,e[26]=A,e[27]=M):M=e[27];const S=l?String(l.width):"";let k;e[28]!==p?(k=W=>p("width",W.target.value),e[28]=p,e[29]=k):k=e[29];let C;e[30]!==d?(C=d("contextPanel.browser.device.width"),e[30]=d,e[31]=C):C=e[31];let y;e[32]!==S||e[33]!==k||e[34]!==C?(y=s.jsx("input",{value:S,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":C,className:x}),e[32]=S,e[33]=k,e[34]=C,e[35]=y):y=e[35];let E;e[36]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[36]=E):E=e[36];const B=l?String(l.height):"";let $;e[37]!==p?($=W=>p("height",W.target.value),e[37]=p,e[38]=$):$=e[38];let O;e[39]!==d?(O=d("contextPanel.browser.device.height"),e[39]=d,e[40]=O):O=e[40];let z;e[41]!==B||e[42]!==$||e[43]!==O?(z=s.jsx("input",{value:B,onChange:$,placeholder:"—",inputMode:"numeric","aria-label":O,className:x}),e[41]=B,e[42]=$,e[43]=O,e[44]=z):z=e[44];let J;e[45]!==r||e[46]!==n?(J=()=>r(Q0(n)),e[45]=r,e[46]=n,e[47]=J):J=e[47];const K=!l;let ee;e[48]!==d?(ee=d("contextPanel.browser.device.rotate"),e[48]=d,e[49]=ee):ee=e[49];let V;e[50]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(oe,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[50]=V):V=e[50];let Y;e[51]!==J||e[52]!==K||e[53]!==ee?(Y=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:J,disabled:K,"aria-label":ee,children:V})})}),e[51]=J,e[52]=K,e[53]=ee,e[54]=Y):Y=e[54];let ae;e[55]!==d?(ae=d("contextPanel.browser.device.rotate"),e[55]=d,e[56]=ae):ae=e[56];let P;e[57]!==ae?(P=s.jsx(jt,{sideOffset:6,children:ae}),e[57]=ae,e[58]=P):P=e[58];let de;e[59]!==Y||e[60]!==P?(de=s.jsxs(kt,{children:[Y,P]}),e[59]=Y,e[60]=P,e[61]=de):de=e[61];let q;e[62]!==a||e[63]!==l?(q=l&&a<1?s.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]=q):q=e[64];let Q;e[65]===Symbol.for("react.memo_cache_sentinel")?(Q=["system","light","dark"],e[65]=Q):Q=e[65];let L;e[66]!==o||e[67]!==i||e[68]!==d?(L=s.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:Q.map(W=>s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:o===W?"secondary":"ghost",size:"xs",className:We("shrink-0 rounded-full px-2.5 typography-micro",o===W?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(W),"aria-pressed":o===W,children:d(W==="system"?"contextPanel.browser.device.schemeSystem":W==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")})}),s.jsx(jt,{sideOffset:6,children:d(W==="system"?"contextTooltips.terminalBrowser.device.schemeSystem":W==="light"?"contextTooltips.terminalBrowser.device.schemeLight":"contextTooltips.terminalBrowser.device.schemeDark")})]},W))}),e[66]=o,e[67]=i,e[68]=d,e[69]=L):L=e[69];let ne;return e[70]!==M||e[71]!==y||e[72]!==z||e[73]!==de||e[74]!==q||e[75]!==L?(ne=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[M,y,E,z,de,q,L]}),e[70]=M,e[71]=y,e[72]=z,e[73]=de,e[74]=q,e[75]=L,e[76]=ne):ne=e[76],ne};function rS(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const eo=new Map,yi=new Set,iu=()=>{for(const t of yi)t()},Go=(t,e)=>{const n=t.trim();n&&(e.length===0?eo.delete(n):eo.set(n,[...e]),iu())},oS=t=>{eo.delete(t.trim())&&iu()},au=[],iS=t=>eo.get(t.trim())??au,aS=t=>(yi.add(t),()=>{yi.delete(t)}),lS=t=>{const e=Le.c(2);let n;return e[0]!==t?(n=()=>iS(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(aS,n,cS)};function cS(){return au}const lu="oc.browser.hiddenDevServerPorts.v1",dS=li(Ns(),jd(wo().int().positive())),vi=new Set,cu=[];let Nr=null;const ra=()=>{const t=gr().getItem(lu);if(Nr&&Nr.raw===t)return Nr.value;let e={};if(t!==null)try{const n=dS.safeParse(JSON.parse(t));n.success&&(e=n.data)}catch{e={}}return Nr={raw:t,value:e},e},du=t=>{gr().setItem(lu,JSON.stringify(t));for(const e of vi)e()},uS=(t=Jt())=>ra()[t]??cu,fS=t=>{const e=Jt(),n=ra(),r=n[e]??[];r.includes(t)||du({...n,[e]:[...r,t].sort((o,i)=>o-i)})},pS=()=>{const t=Jt(),e=ra();if(!e[t])return;const n={...e};delete n[t],du(n)},mS=t=>(vi.add(t),()=>{vi.delete(t)}),hS=()=>c.useSyncExternalStore(mS,gS,xS);function gS(){return uS()}function xS(){return cu}const bS=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},wS=2e3,yS=t=>yc("http://localhost",t),uu=t=>{const e=Le.c(62),{onOpen:n,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=rt();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=lS(i);let m;e[1]!==i?(m=()=>yS(i),e[1]=i,e[2]=m):m=e[2];const[p]=c.useState(m);let h;e[3]!==i?(h=()=>tp(i),e[3]=i,e[4]=h):h=e[4];const[x]=c.useState(h);let g;e[5]!==i?(g=Ei(i),e[5]=i,e[6]=g):g=e[6];const b=g,w=na(i),j=Xu(i);let v,T;e[7]!==i||e[8]!==j||e[9]!==o?(v=()=>{if(j){l({kind:"ready",servers:[]});return}if(!o)return;let q=!0,Q=null;const L=new AbortController,ne=()=>{n0(L.signal,i).then(W=>{q&&(l(W),Q=setTimeout(ne,wS))})};return ne(),()=>{q=!1,Q&&clearTimeout(Q),L.abort()}},T=[i,j,o],e[7]=i,e[8]=j,e[9]=o,e[10]=v,e[11]=T):(v=e[10],T=e[11]),c.useEffect(v,T);const F=ts(vS),_=st(SS);let A;if(e[12]!==F||e[13]!==_){const q=F.map(kS);let Q;e[15]!==_?(Q=[..._].flatMap(jS),e[15]=_,e[16]=Q):Q=e[16],A=[...q,...Q],e[12]=F,e[13]=_,e[14]=A}else A=e[14];const M=A;let S;e[17]!==f||e[18]!==i||e[19]!==u.kind||e[20]!==u.servers||e[21]!==M?(S=c0({candidates:i0({announced:f,discovered:u.kind==="ready"?u.servers:null}),folders:M,directory:i}),e[17]=f,e[18]=i,e[19]=u.kind,e[20]=u.servers,e[21]=M,e[22]=S):S=e[22];const k=S,C=hS(),[y,E]=c.useState(!1);let B;if(e[23]!==k||e[24]!==C||e[25]!==y){let q;e[27]!==C||e[28]!==y?(q=Q=>Q.announced||!C.includes(Q.port)&&(y||!Q.outsideWork),e[27]=C,e[28]=y,e[29]=q):q=e[29],B=k.filter(q),e[23]=k,e[24]=C,e[25]=y,e[26]=B}else B=e[26];const $=B,O=k.length-$.length;let z;e[30]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(og,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=z):z=e[30];let J;e[31]!==a?(J=a("contextPanel.browser.empty"),e[31]=a,e[32]=J):J=e[32];let K;e[33]!==J?(K=s.jsx("span",{className:"typography-ui-header text-foreground",children:J}),e[33]=J,e[34]=K):K=e[34];let ee;e[35]!==a?(ee=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=ee):ee=e[36];let V;e[37]!==ee?(V=s.jsx("span",{className:"typography-micro text-muted-foreground",children:ee}),e[37]=ee,e[38]=V):V=e[38];let Y;e[39]!==K||e[40]!==V?(Y=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[K,V]}),e[39]=K,e[40]=V,e[41]=Y):Y=e[41];let ae;e[42]!==f||e[43]!==k.length||e[44]!==i||e[45]!==O||e[46]!==b||e[47]!==n||e[48]!==p||e[49]!==w||e[50]!==x||e[51]!==a||e[52]!==$?(ae=k.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),p&&!x?s.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx(gs,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:$.map(q=>s.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[s.jsxs(ft,{type:"button",variant:"outline",size:"sm",className:We("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(oS(i),n(q.url))},children:[b?s.jsx("span",{className:"shrink-0",role:"img","aria-label":w??a("contextPanel.browser.spaceAddress"),title:w??a("contextPanel.browser.spaceAddress"),children:s.jsx(oe,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):s.jsx(oe,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsxs("span",{className:"truncate",children:[oo(q.url)||q.url,s.jsx("span",{className:"typography-micro text-muted-foreground",children:bS(q.url)})]}),x?s.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:s.jsx(oe,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):q.folderName?s.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:q.directory,children:[s.jsx(oe,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",dir:"auto",children:q.folderName})]}):null]}),q.announced?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>fS(q.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:q.port}),children:s.jsx(oe,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})}),s.jsx(jt,{sideOffset:6,children:a("contextPanel.browser.devServers.hide",{port:q.port})})]})]},q.port))}),O>0?s.jsx(ft,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{pS(),E(!0)},children:O===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:O}):a("contextPanel.browser.devServers.showHiddenPlural",{count:O})}):null]}):null,e[42]=f,e[43]=k.length,e[44]=i,e[45]=O,e[46]=b,e[47]=n,e[48]=p,e[49]=w,e[50]=x,e[51]=a,e[52]=$,e[53]=ae):ae=e[53];let P;e[54]!==k.length||e[55]!==u.kind||e[56]!==a?(P=k.length===0&&u.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=k.length,e[55]=u.kind,e[56]=a,e[57]=P):P=e[57];let de;return e[58]!==Y||e[59]!==ae||e[60]!==P?(de=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[z,Y,ae,P]}),e[58]=Y,e[59]=ae,e[60]=P,e[61]=de):de=e[61],de};function vS(t){return t.projects}function SS(t){return t.availableWorktreesByProject}function kS(t){return{path:t.path,projectPath:t.path}}function jS(t){const[e,n]=t;return n.map(r=>({path:r.path,projectPath:e}))}const CS=3e4,TS=3,NS=250,ES={attempts:0,windowStartedAt:null},IS=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=CS,r=n?0:t.attempts;return r>=TS?null:{delayMs:NS*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},PS=-3,Er=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Nn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},RS=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:ig),[i,a]=c.useState(e),[d,u]=c.useState(""),[l,f]=c.useState(!1),[m,p]=c.useState(!1),h=c.useRef(n);h.current=n;const x=c.useRef(ES);return c.useEffect(()=>{if(!t)return;const g=()=>{try{const k=t.getURL();return Er(k)?k:""}catch{return""}},b=()=>{try{f(t.canGoBack()),p(t.canGoForward())}catch{}},w=k=>{Er(k)&&(a(k),h.current(k))},j=()=>{const k=g();o({kind:"loading",url:k})},v=()=>{const k=g();let C="";try{C=t.getTitle()||""}catch{C=""}u(C),w(k),b(),o(y=>y.kind==="failed"?y:{kind:"ready",url:k,title:C})},T=k=>{const C=Nn(k);Er(C.url)&&(w(C.url),b())},F=k=>{const C=Nn(k),y=Array.isArray(C.favicons)?C.favicons.find(Boolean):"",E=g();if(!y||!E)return;let B=-1;try{B=t.getWebContentsId()}catch{return}!Number.isFinite(B)||B<0||$d.getState().resolve(E,y,B)},_=k=>{const C=Nn(k);typeof C.title=="string"&&u(C.title)},A=k=>{const C=Nn(k);if(C.isMainFrame===!1)return;const y=typeof C.errorCode=="number"?C.errorCode:0;y!==PS&&o({kind:"failed",url:Er(C.validatedURL)?C.validatedURL:g(),code:y,description:typeof C.errorDescription=="string"?C.errorDescription:""})};let M=null;const S=()=>{const k=g(),C=IS(x.current,Date.now());if(!C){o({kind:"failed",url:k,code:0,description:"",crashed:!0});return}x.current=C.state,o({kind:"loading",url:k}),M=setTimeout(()=>{M=null;try{t.reload()}catch{o({kind:"failed",url:k,code:0,description:"",crashed:!0})}},C.delayMs)};t.addEventListener("did-start-loading",j),t.addEventListener("did-stop-loading",v),t.addEventListener("did-navigate",T),t.addEventListener("did-navigate-in-page",T),t.addEventListener("page-title-updated",_),t.addEventListener("page-favicon-updated",F),t.addEventListener("did-fail-load",A),t.addEventListener("render-process-gone",S),t.addEventListener("crashed",S);try{!t.isLoading()&&g()&&v()}catch{}return()=>{M!==null&&clearTimeout(M),t.removeEventListener("render-process-gone",S),t.removeEventListener("crashed",S),t.removeEventListener("did-start-loading",j),t.removeEventListener("did-stop-loading",v),t.removeEventListener("did-navigate",T),t.removeEventListener("did-navigate-in-page",T),t.removeEventListener("page-title-updated",_),t.removeEventListener("page-favicon-updated",F),t.removeEventListener("did-fail-load",A)}},[t]),{status:r,url:i,title:d,canGoBack:l,canGoForward:m}},vl=1e3,fu=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},DS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},_S=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},AS=(t,e)=>{const n=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=_S());const d=u=>{if(document.activeElement!==t){i.current=DS(u);return}const l=e.current,f=n.current>r.current||Date.now()<o.current;l&&fu(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);n.current+=1;try{return await d(m)}finally{n.current-=1,o.current=Date.now()+vl,f()}},[a,t])},OS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),MS=()=>document.visibilityState==="visible",FS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Ir=.5,LS=-3,$S=4,BS="persist:openchamber-browser",pu=(t,e,n)=>ks(t)!==null&&sc(e)?{icon:"instance",label:n}:void 0,Sl=t=>{const e=ks(t);return e?`openchamber-space-preview:${e}`:BS},kl="openchamber:browser-panel-open-tab",zS=sn({webContentsId:wo(),url:Ns().min(1),background:dr()}),jl=20,WS=600,US=2e4,VS=15e3,Cl=500,Tl=5e3,HS=3e4,qS=3e3,Nl=1e3,KS=250,GS=sn({quiet:dr()}),ZS=()=>new Promise(t=>{let e=0,n=0,r=0,o;const i=l=>{clearTimeout(o),t(l)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},d=()=>{n=e,r=performance.now()+Nl,o=setTimeout(u,Nl)},u=()=>{e>n||performance.now()-r>KS?d():i(!1)};requestAnimationFrame(a),d()}),XS=t=>{if(!t||fu(t))return()=>{};const e=t.getBoundingClientRect(),n=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=n}},YS=({initialUrl:t,directory:e,siteDirectory:n,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=rt(),{currentTheme:d}=io(),u=c.useRef(null),[l,f]=c.useState(null),m=c.useCallback(le=>{u.current=le,f(le)},[]),p=G(le=>le.setContextPanelTabTargetPath),h=c.useRef(En(t)),x=h.current!==Qs?h.current:"",[g,b]=c.useState(x?null:Qs),w=na(n),[j,v]=c.useState(x),[T,F]=c.useState(!1),[_,A]=c.useState(!1),[M,S]=c.useState(0),k=c.useRef(0),[C,y]=c.useState(!1),[E,B]=c.useState(Jr),$=c.useRef(E);$.current=E;const O=c.useRef([]),[z,J]=c.useState("system"),[K,ee]=c.useState({width:0,height:0}),V=c.useRef(null),Y=c.useRef(null),ae=fs(e),P=c.useRef(!!x&&!Yu(ae,r)),de=c.useRef(null);c.useEffect(()=>{tc(ae,r)},[ae,r]);const q=c.useRef(!1),Q=c.useRef(Date.now()),L=c.useCallback(le=>{!le||le===Qs||!e||!r||p(e,r,le)},[e,r,p]),ne=RS(l,{initialUrl:x,onUrlChange:c.useCallback(le=>{const be=vn(le);v(be),L(be)},[L])}),[W,te]=c.useState(null),[Z,me]=c.useState(ks(n)===null);c.useEffect(()=>{const le=ks(n);if(le===null){me(!0);return}let be=!0;return me(!1),Tn("desktop_space_preview_prepare",{spaceId:le}).then(()=>{be&&me(!0)}).catch(()=>{be&&te(x||"http://localhost/")}),()=>{be=!1}},[n,x]);const Ie=ag(e),fe=lg(),je=ne.status.kind==="loading",$e=Pn(su(n)),Re=Pn(le=>le.recordVisit),Fe=Pn(le=>le.forget);c.useEffect(()=>{ne.status.kind==="ready"&&Re(n,{url:vn(ne.status.url),title:ne.status.title})},[n,ne.status,Re]);const Ve=c.useMemo(()=>tu($e,j),[$e,j]),De=c.useCallback(le=>{const be=En(le);be!==Qs&&(P.current=!1,v(be),te(null),va(be,n).then(Ae=>{const N=u.current;if(!N){b(Ae);return}try{N.loadURL(Ae)}catch{b(Ae)}}).catch(Ae=>{Ae instanceof Sa&&te(be)}))},[n]);c.useEffect(()=>{if(!x)return;let le=!0;return va(x,n).then(be=>{le&&b(be)}).catch(be=>{if(le){if(be instanceof Sa){te(x),P.current=!1,b(Qs);return}b(x)}}),()=>{le=!1}},[]);const ge=c.useMemo(()=>({executeJavaScript:async(le,be)=>{const Ae=u.current;if(!Ae)throw new Error("Browser view is not available");return Ae.executeJavaScript(le,be)},capturePage:async()=>{const le=u.current;if(!le)return null;const be=le.getWebContentsId();return Number.isFinite(be)?await Tn("desktop_browser_capture_page",{webContentsId:be}):null}}),[]),xe=c.useCallback(()=>{if(T){F(!1),Oo(ge);return}if(!ne.url){Te.error(a("contextPanel.browser.annotate.noPage"));return}const le=cg(d.metadata.variant==="light"?"light":"dark");F(!0),dg({host:ge,theme:le,labels:fe}).then(async be=>{F(!1),be&&await Ie(be)}).catch(()=>{F(!1),Te.error(a("contextPanel.browser.annotate.failed"))})},[ge,Ie,d,T,ne.url,fe,a]);c.useEffect(()=>{if(!T)return;const le=be=>{Oc(be)||be.key!=="Escape"||(be.preventDefault(),be.stopImmediatePropagation(),F(!1),Oo(ge))};return window.addEventListener("keydown",le,!0),()=>window.removeEventListener("keydown",le,!0)},[ge,T]);const Se=c.useRef(!1);c.useEffect(()=>{if(!l)return;const le=()=>{Se.current=!0};return l.addEventListener("dom-ready",le),l.addEventListener("did-fail-load",le),()=>{l.removeEventListener("dom-ready",le),l.removeEventListener("did-fail-load",le)}},[l]);const Be=c.useCallback(async()=>{const le=Date.now()+VS;for(;!(u.current&&Se.current)&&Date.now()<le;)await new Promise(be=>setTimeout(be,100));return u.current},[]),Pe=c.useCallback(async(le=8e3)=>{const be=Date.now();for(;;){const Ae=u.current;if(!Ae)return!1;let N=!1;try{N=Ae.isLoading()}catch{return!1}if(!N)return!0;if(Date.now()-be>le)return!1;await new Promise(ce=>setTimeout(ce,120))}},[]),Me=c.useCallback(async(le,be)=>{const Ae=G0({quietMs:Cl,maxMs:be});let N;const ce=new Promise(U=>{N=setTimeout(()=>U(null),be+1e3)});try{const U=GS.safeParse(await Promise.race([le.executeJavaScript(Ae,!1),ce]));return U.success&&U.data.quiet}catch{return!1}finally{clearTimeout(N)}},[]),Je=c.useCallback(async(le,be=HS)=>{const Ae=Date.now(),N=await Pe(Math.min(25e3,Math.max(0,be-Tl))),ce=be-(Date.now()-Ae),U=N&&ce>Cl&&await Me(le,Math.min(Tl,ce));let we="";try{we=le.getTitle()||""}catch{we=""}return{title:we,settled:U}},[Pe,Me]),X=c.useCallback(async(le,be,Ae)=>{const N=await Be();if(!N)throw new Error("The browser panel is not ready");const ce=()=>{yl(be.viewport)&&(B(wi(be.viewport)),y(!0))};if(le==="browser.back"||le==="browser.forward"){const ue=le==="browser.back";if(!(ue?N.canGoBack():N.canGoForward()))throw new Error(ue?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");ue?N.goBack():N.goForward(),await new Promise(bt=>setTimeout(bt,150)),await Pe();let ye="";try{ye=N.getTitle()||""}catch{ye=""}return{url:vn(N.getURL()),title:ye}}if(le==="browser.capture"){const ue=XS(V.current);try{if(!await ZS())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 Pe()&&await Me(N,qS);const et=await ge.capturePage();if(!et)throw new Error("The page could not be captured");let ye="";try{ye=N.getTitle()||""}catch{ye=""}return{...et,url:vn(N.getURL()),title:ye,viewport:Tr($.current)}}finally{ue()}}if(le==="browser.resize"){if(!yl(be.viewport))throw new Error("viewport is required");return ce(),await new Promise(ue=>setTimeout(ue,200)),await Pe(),{viewport:Tr(wi(be.viewport))}}if(le==="browser.open"){const ue=typeof be.url=="string"?be.url:"";if(!ue)throw new Error("url is required");return ce(),De(ue),await new Promise(et=>setTimeout(et,150)),{url:En(ue),...await Je(N),opened:!0,viewport:Tr($.current)}}if(le==="browser.settle"){const ue=wo().safeParse(be.budgetMs);return Je(N,ue.success?ue.data:void 0)}await Pe();const U=ue=>typeof ue=="string"&&ue?ue:void 0,ke=(()=>{switch(le){case"browser.snapshot":return U0({selector:U(be.selector)});case"browser.click":return V0({selector:U(be.selector),text:U(be.text)});case"browser.type":return H0({selector:String(be.selector??""),value:String(be.value??""),submit:be.submit===!0});case"browser.select":return q0({selector:String(be.selector??""),label:typeof be.label=="string"?be.label:void 0,value:typeof be.value=="string"?be.value:void 0});case"browser.inspect":return X0({selector:String(be.selector??"")});case"browser.scroll":return K0({selector:U(be.selector),direction:U(be.direction)});default:return null}})();if(!ke)throw new Error(`Unsupported browser action: ${le}`);let Xe=()=>{};(le==="browser.click"||le==="browser.type")&&(await Tn("desktop_browser_keep_page_focused",{webContentsId:N.getWebContentsId()}).then(et=>et.focused===!0).catch(()=>!1)||(Xe=Ae(),N.focus({preventScroll:!0})));let Oe;try{Oe=await N.executeJavaScript(ke,!0)}finally{Xe()}if(!Oe||typeof Oe!="object")throw new Error("The page returned no result");const se=Oe;if(se.ok!==!0)throw new Error(typeof se.error=="string"&&se.error?se.error:"Browser action failed");if(le==="browser.snapshot"){const ue=O.current;return{...se,viewport:Tr($.current),...ue.length>0?{consoleProblems:[...ue]}:{}}}return(le==="browser.click"||le==="browser.select"||le==="browser.type"&&be.submit===!0)&&(await new Promise(ue=>setTimeout(ue,150)),await Pe()),Oe},[ge,De,Je,Pe,Me,Be]),Ee=AS(l,V),[_e,pe]=c.useState(!1),R=c.useCallback((le,be)=>(pe(!0),Ee(Ae=>X(le,be,Ae))),[Ee,X]),ie=c.useCallback(()=>{const le=u.current;if(!le)return{title:"",url:""};let be="",Ae="";try{be=le.getTitle()||""}catch{be=""}try{Ae=vn(le.getURL())}catch{Ae=""}return{title:be,url:Ae}},[]);c.useEffect(()=>j0({tabId:r,directory:ae,ownerSessionId:o,describe:ie,run:R}),[ie,o,R,ae,r]),c.useEffect(()=>{const le=ge;return()=>{Oo(le)}},[ge]),c.useEffect(()=>{if(!l)return;const le=Ae=>{const N=Ae;if(typeof N.level!="number"||N.level<2)return;const ce=N.sourceId?`${N.sourceId}${N.line?`:${N.line}`:""}`:"";O.current.push({level:N.level>=3?"error":"warning",message:String(N.message??"").slice(0,400),source:ce}),O.current.length>jl&&O.current.splice(0,O.current.length-jl)},be=()=>{O.current=[]};return l.addEventListener("console-message",le),l.addEventListener("did-start-loading",be),()=>{l.removeEventListener("console-message",le),l.removeEventListener("did-start-loading",be)}},[l]);const Ce=c.useRef(new Set),Ne=c.useCallback(le=>{Ce.current.clear(),De(le)},[De]),ze=c.useRef(ne.status);ze.current=ne.status;const qe=c.useRef(!1);ne.status.kind==="ready"&&ne.status.url&&(qe.current=!0),c.useEffect(()=>Ju(ae,r,le=>{ef(ze.current,qe.current)&&Ne(le)}),[Ne,ae,r]),c.useEffect(()=>{if(!l)return;const le=Ae=>{const N=Nn(Ae),ce=typeof N.url=="string"?N.url:"";!ce||!ka(ce,n)||(Ae.preventDefault(),De(ce))},be=Ae=>{const N=Nn(Ae);if(N.isMainFrame===!1||N.errorCode===-3)return;const ce=typeof N.validatedURL=="string"?N.validatedURL:"";!ce||!ka(ce,n)||Ce.current.has(ce)||(Ce.current.add(ce),De(ce))};return l.addEventListener("will-navigate",le),l.addEventListener("did-fail-load",be),()=>{l.removeEventListener("will-navigate",le),l.removeEventListener("did-fail-load",be)}},[n,De,l]),c.useEffect(()=>{if(!l)return;const le=be=>{if(!(be instanceof CustomEvent))return;const Ae=zS.safeParse(be.detail);if(!Ae.success)return;let N=-1;try{N=l.getWebContentsId()}catch{return}Ae.data.webContentsId===N&&G.getState().openContextBrowser(ae,Ae.data.url,{reveal:!Ae.data.background})};return window.addEventListener(kl,le),()=>window.removeEventListener(kl,le)},[ae,l]);const Ue=c.useCallback(le=>{const be=Math.min($S,Math.max(LS,le));k.current=be,S(be);try{u.current?.setZoomLevel(be)}catch{}},[]);c.useEffect(()=>{const le=be=>{if(!(be instanceof CustomEvent))return;const Ae=be.detail,N=u.current;!N||document.activeElement!==N||(Ae==="zoom-in"?Ue(k.current+Ir):Ae==="zoom-out"?Ue(k.current-Ir):Ae==="zoom-reset"&&Ue(0))};return window.addEventListener("openchamber:zoom",le),()=>window.removeEventListener("openchamber:zoom",le)},[Ue]);const tt=c.useCallback(le=>{Tn("desktop_browser_clear_data",{partition:Sl(n),cookies:le==="cookies",cache:le==="cache"}).then(()=>{Te.success(a(le==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{u.current?.reloadIgnoringCache()}catch{}}).catch(()=>Te.error(a("contextPanel.browser.clearFailed")))},[n,a]);c.useEffect(()=>{const le=V.current;if(!le||typeof ResizeObserver>"u")return;const be=new ResizeObserver(Ae=>{const N=Ae[0]?.contentRect;N&&ee({width:N.width,height:N.height})});return be.observe(le),()=>be.disconnect()},[]);const He=c.useCallback(le=>{J(le);const be=u.current;if(!be)return;let Ae=-1;try{Ae=be.getWebContentsId()}catch{return}Tn("desktop_browser_set_color_scheme",{webContentsId:Ae,scheme:le}).catch(N=>{J("system"),Te.error(N instanceof Error?N.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),Ze=c.useCallback(()=>{try{je?u.current?.stop():u.current?.reload()}catch{}},[je]),Qe=ne.status,ot=c.useSyncExternalStore(OS,MS),pt=i&&ot||o!==null||_e;c.useEffect(()=>{const le=U=>{A(!0);const we=setTimeout(()=>{try{u.current?.reload()}catch{}},U);return()=>clearTimeout(we)};if(Qe.kind==="loading")return;const be=P.current||de.current===Qe;if(P.current&&(Qe.kind==="failed"||Qe.kind==="ready"&&Qe.url)&&(P.current=!1,de.current=Qe),Qe.kind==="failed"){const U=Qu(Qe,{run:Y.current,restored:be,watched:pt,now:Date.now()});if(Y.current=U.run,U.next==="retry")return le(U.delayMs);A(U.next==="pause");return}if(Y.current=null,Qe.kind!=="ready"||!Qe.url||!sc(Qe.url)){q.current=!0,A(!1);return}if(be||q.current||Date.now()-Q.current>US){q.current=!0,A(!1);return}let Ae=!1,N=null;return(ks(n)?Promise.resolve(null):r0(vn(Qe.url))).then(U=>{if(!Ae){if(U===null||U<500){q.current=!0,A(!1);return}N=le(WS)}}),()=>{Ae=!0,N?.()}},[n,Qe,pt]);const at=ne.status.kind==="failed"&&!_?ne.status:null,xt=eS(E,K);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(nu,{address:j,onAddressChange:v,onSubmit:Ne,suggestions:Ve,onForgetSuggestion:le=>Fe(n,le),onBack:()=>{try{u.current?.goBack()}catch{}},onForward:()=>{try{u.current?.goForward()}catch{}},onReload:Ze,onOpenExternal:()=>{Ln(ne.url||j)},addressMark:pu(n,j,w??a("contextPanel.browser.spaceAddress")),canOpenExternal:ks(n)===null,canGoBack:ne.canGoBack,canGoForward:ne.canGoForward,isLoading:je,onAnnotate:xe,isAnnotating:T,onOpenDevTools:()=>{try{u.current?.openDevTools()}catch{}},onHardReload:()=>{try{u.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ue(M+Ir),onZoomOut:()=>Ue(M-Ir),onZoomReset:()=>Ue(0),zoomPercent:Math.round(Math.pow(1.2,M)*100),onClearCookies:()=>tt("cookies"),onClearCache:()=>tt("cache"),onToggleDeviceBar:()=>y(le=>!le),isDeviceBarOpen:C}),C?s.jsx(nS,{viewport:E,onViewportChange:B,colorScheme:z,onColorSchemeChange:He,scale:xt?.scale??1}):null,s.jsxs("div",{ref:V,className:We("relative min-h-0 flex-1 bg-background",xt&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&Z?s.jsx("webview",{ref:m,src:g,partition:Sl(n),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:xt?{width:`${xt.width}px`,height:`${xt.height}px`,transform:`scale(${xt.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!x&&!ne.url&&!je?s.jsx(uu,{onOpen:Ne,directory:n,visible:i}):null,_?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,W?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[ks(n)!==null?s.jsx(oe,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a(ks(n)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:W})})]}):null,at&&!W?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:at.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:at.crashed?a("contextPanel.browser.crashedHint"):at.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,je?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},JS=t=>{const e=Le.c(75),{initialUrl:n,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:d}=rt(),u=G(e2);let l;e[0]!==n?(l=En(n),e[0]=n,e[1]=l):l=e[1];const f=l,m=f!==Qs?f:"",[p,h]=c.useState(m);let x;e[2]!==o||e[3]!==m?(x=Do(m,o),e[2]=o,e[3]=m,e[4]=x):x=e[4];const[g,b]=c.useState(x);let w;e[5]!==o||e[6]!==m?(w=yc(m,o)?m:"",e[5]=o,e[6]=m,e[7]=w):w=e[7];const[j,v]=c.useState(w);let T;e[8]!==o?(T=ks(o),e[8]=o,e[9]=T):T=e[9];const F=T!==null,_=na(o);let A;e[10]!==m?(A=m?[m]:[],e[10]=m,e[11]=A):A=e[11];const[M,S]=c.useState(A),[k,C]=c.useState(m?0:-1),[y,E]=c.useReducer(t2,0);let B,$;e[12]!==i||e[13]!==r?(B=()=>{tc(fs(r),i)},$=[r,i],e[12]=i,e[13]=r,e[14]=B,e[15]=$):(B=e[14],$=e[15]),c.useEffect(B,$);let O;e[16]!==u||e[17]!==i||e[18]!==r?(O=Ve=>{!Ve||Ve===Qs||!r||!i||u(r,i,Ve)},e[16]=u,e[17]=i,e[18]=r,e[19]=O):O=e[19];const z=O;let J;e[20]!==o?(J=su(o),e[20]=o,e[21]=J):J=e[21];const K=Pn(J),ee=Pn(s2),V=Pn(n2);let Y;e[22]!==p||e[23]!==K?(Y=tu(K,p),e[22]=p,e[23]=K,e[24]=Y):Y=e[24];const ae=Y;let P;e[25]!==o||e[26]!==k||e[27]!==z||e[28]!==ee?(P=Ve=>{const De=En(Ve);if(De===Qs)return;h(De);const ge=Do(De,o);b(ge),v(ge?"":De),z(De),ee(o,{url:De}),S(xe=>{const Se=k>=0?xe.slice(0,k+1):[];return Se[Se.length-1]===De?(C(Se.length-1),Se):(C(Se.length),[...Se,De])})},e[25]=o,e[26]=k,e[27]=z,e[28]=ee,e[29]=P):P=e[29];const de=P;let q;e[30]!==o||e[31]!==M||e[32]!==z?(q=Ve=>{const De=M[Ve];if(!De)return;C(Ve),h(De);const ge=Do(De,o);b(ge),v(ge?"":De),z(De)},e[30]=o,e[31]=M,e[32]=z,e[33]=q):q=e[33];const Q=q;let L;e[34]!==o||e[35]!==V?(L=Ve=>V(o,Ve),e[34]=o,e[35]=V,e[36]=L):L=e[36];let ne,W;e[37]!==Q||e[38]!==k?(ne=()=>Q(k-1),W=()=>Q(k+1),e[37]=Q,e[38]=k,e[39]=ne,e[40]=W):(ne=e[39],W=e[40]);let te;e[41]!==p||e[42]!==g?(te=()=>{Ln(g||p)},e[41]=p,e[42]=g,e[43]=te):te=e[43];let Z;e[44]!==_||e[45]!==d?(Z=_??d("contextPanel.browser.spaceAddress"),e[44]=_,e[45]=d,e[46]=Z):Z=e[46];let me;e[47]!==p||e[48]!==o||e[49]!==Z?(me=pu(o,p,Z),e[47]=p,e[48]=o,e[49]=Z,e[50]=me):me=e[50];const Ie=!j,fe=k>0,je=k>=0&&k<M.length-1;let $e;e[51]!==p||e[52]!==de||e[53]!==ae||e[54]!==L||e[55]!==ne||e[56]!==W||e[57]!==te||e[58]!==me||e[59]!==Ie||e[60]!==fe||e[61]!==je?($e=s.jsx(nu,{address:p,onAddressChange:h,onSubmit:de,suggestions:ae,onForgetSuggestion:L,onBack:ne,onForward:W,onReload:E,onOpenExternal:te,addressMark:me,canOpenExternal:Ie,canGoBack:fe,canGoForward:je,isLoading:!1}),e[51]=p,e[52]=de,e[53]=ae,e[54]=L,e[55]=ne,e[56]=W,e[57]=te,e[58]=me,e[59]=Ie,e[60]=fe,e[61]=je,e[62]=$e):$e=e[62];let Re;e[63]!==o||e[64]!==F||e[65]!==g||e[66]!==de||e[67]!==y||e[68]!==d||e[69]!==j||e[70]!==a?(Re=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:j?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[F?s.jsx(oe,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:d(F?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:oo(j)})}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:d("contextPanel.browser.remoteLoopback.hint")})]}):g?s.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}|${y}`):s.jsx(uu,{onOpen:de,directory:o,visible:a})}),e[63]=o,e[64]=F,e[65]=g,e[66]=de,e[67]=y,e[68]=d,e[69]=j,e[70]=a,e[71]=Re):Re=e[71];let Fe;return e[72]!==$e||e[73]!==Re?(Fe=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[$e,Re]}),e[72]=$e,e[73]=Re,e[74]=Fe):Fe=e[74],Fe},QS=t=>{const e=Le.c(3),[n]=c.useState(FS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(YS,{...t}):s.jsx(JS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function e2(t){return t.setContextPanelTabTargetPath}function t2(t){return t+1}function s2(t){return t.recordVisit}function n2(t){return t.forget}const r2=t=>{const e=Le.c(13),{zone:n,children:r}=t,[o]=c.useState(o2);let i;e[0]!==n?(i=p=>p.body[n],e[0]=n,e[1]=i):i=e[1];const a=ur(i);let d,u;e[2]!==a||e[3]!==o||e[4]!==n?(d=()=>{const p=a??ur.getState().body[n];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,n],e[2]=a,e[3]=o,e[4]=n,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=Zl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=m):m=e[12],m};function o2(){const t=document.createElement("div");return t.style.display="contents",t}const i2=200,mu=t=>`${t.path}:${t.line}:${t.column}`,El={status:"idle"},a2=t=>{const e=Le.c(9),{searchContents:n,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]!==n?(m=()=>{if(!u||!n||!r||!o.trim()){f(El);return}const h=new AbortController;let x=!1;return f({status:"searching"}),n({directory:r,query:o,regex:i,limit:i2,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,n],e[0]=u,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=d,e[6]=n,e[7]=m,e[8]=p):(m=e[7],p=e[8]),c.useEffect(m,p),l},cn=t=>{const e=Le.c(5),{className:n,children:r}=t;let o;e[0]!==n?(o=We("px-2 py-1 typography-meta text-muted-foreground",n),e[0]=n,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=s.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},l2=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},c2=t=>{const e=Le.c(44),{state:n,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:d}=rt();switch(n.status){case"idle":return null;case"searching":{let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(oe,{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=s.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=s.jsx(cn,{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=s.jsx("span",{className:"text-[var(--status-error)]",children:m}),e[11]=m,e[12]=p):p=e[12];let h;e[13]!==n.message?(h=s.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:n.message}),e[13]=n.message,e[14]=h):h=e[14];let x;return e[15]!==p||e[16]!==h?(x=s.jsxs(cn,{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]!==n.message||e[19]!==d?(m=d("sidebarFilesTree.contentSearch.failed",{message:n.message}),e[18]=n.message,e[19]=d,e[20]=m):m=e[20];let p;return e[21]!==m?(p=s.jsx(cn,{className:"text-[var(--status-error)]",children:m}),e[21]=m,e[22]=p):p=e[22],p}}if(n.matches.length===0){let m;return e[23]!==n.stopped||e[24]!==d?(m=n.stopped==="deadline"?s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.deadline")}):s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.empty")}),e[23]=n.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]!==n.matches){let m;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(m=p=>{const{name:h,directory:x}=l2(p.relativePath),g=mu(p),b=r===g;return s.jsx("li",{"data-file-tree-path":p.path,children:s.jsxs("button",{type:"button",onClick:()=>o(p),onDoubleClick:()=>o(p,{pin:!0}),draggable:!!i,onDragStart:i?w=>i(w,p):void 0,onDragEnd:a?w=>a(w,p):void 0,className:We("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",Gi(b)),title:`${p.relativePath}:${p.line}`,children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsx(ho,{filePath:p.path,className:"size-3.5 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`${x}`}):s.jsx("span",{className:"flex-1"}),s.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:p.line})]}),s.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[p.cutStart?"…":null,s.jsx(ug,{segments:fg(p.text,p.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=m):m=e[36],u=n.matches.map(m),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=n.matches,e[31]=u}else u=e[31];let l;e[37]!==n.matches.length||e[38]!==n.stopped||e[39]!==d?(l=n.stopped==="limit"?s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.limit",{count:n.matches.length})}):n.stopped==="deadline"?s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=n.matches.length,e[38]=n.stopped,e[39]=d,e[40]=l):l=e[40];let f;return e[41]!==u||e[42]!==l?(f=s.jsxs(s.Fragment,{children:[u,l]}),e[41]=u,e[42]=l,e[43]=f):f=e[43],f},Il=8;let pr=null;const hu=(t,e)=>Math.abs(e.clientX-t.x)<=Il&&Math.abs(e.clientY-t.y)<=Il,Si=t=>{pr={x:t.clientX,y:t.clientY}},ki=t=>{const e=pr;return pr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:hu(e,t)},gu=t=>pr!==null&&hu(pr,t);let xu=null;const Zo=t=>{xu=t},bu=()=>xu,Pl=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},wu=(t,e,n)=>{const r=e===null?n:e.type==="directory"?e.path:Pl(e.path);return!r||Pl(t.path)===r||t.type==="directory"&&tf(r,t.path,t.path)!==null?null:r},d2=(t,e)=>{const n=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${n}`:`${e}/${n}`},u2=({root:t,childrenByDir:e,expandedPaths:n,loadErrorsByDir:r})=>{const o=[],i=(a,d)=>{for(const u of e[a]??[]){const l=u.type==="directory"&&n.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},f2=(t,e,n)=>{const r=e.filter(o=>o>=0&&o<n&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},p2=28,Rn=t=>Array.from(t.types).includes("Files"),er=t=>Array.from(t.types).includes(lr)?bu():null,yu=(t,e,n)=>t.getData(lr)===jo(e,n.path),m2=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},h2=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),zt=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},jo=(t,e)=>{const n=zt(e),r=zt(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Un=(t,e)=>{const n=jo(t,e);if(n!==".")return n;const r=zt(t);return r.split("/").filter(Boolean).pop()??r},Br=t=>{const e=zt(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},g2=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),x2=new Set(["node_modules"]),b2=t=>x2.has(t),w2=t=>{const e=zt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},y2=8,Ds=new Map,oa=t=>JSON.stringify([Jt(),t]),v2=t=>{const e=oa(t),n=Ds.get(e);return n?(n.touchedAt=Date.now(),Ds.delete(e),Ds.set(e,n),n):null},Xo=t=>{const e=oa(t),n=Ds.get(e);if(n)return n.touchedAt=Date.now(),n;if(Ds.size>=y2){const o=Ds.keys().next().value;o!==void 0&&Ds.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Ds.set(e,r),r},S2=t=>{const e=Le.c(159),{guestActions:n,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:b,downloadFile:w,onSelect:j,onToggle:v,onRevealPath:T,onOpenDialog:F,onSetDropTarget:_,onDropFiles:A,onPickFiles:M,onMoveDragChange:S,onSetMoveDropTarget:k,onMoveDrop:C}=t,{t:y}=rt(),E=r.type==="directory";let B;e[0]!==E||e[1]!==r.path?(B=E?r.path:Br(r.path),e[0]=E,e[1]=r.path,e[2]=B):B=e[2];const $=B,{canRename:O,canCreateFile:z,canCreateFolder:J,canDelete:K,canReveal:ee}=b,V=!E&&!!w,Y=ee&&!d,ae=E&&x,P=O||z||J||ae||K||V||Y,[de,q]=c.useState(!1),[Q,L]=c.useState(!1);let ne;e[3]!==P?(ne=Pe=>{P&&(Pe?.preventDefault(),L(!0))},e[3]=P,e[4]=ne):ne=e[4];const W=ne;let te;e[5]!==E||e[6]!==r||e[7]!==j||e[8]!==v?(te=()=>{E?v(r.path):j(r)},e[5]=E,e[6]=r,e[7]=j,e[8]=v,e[9]=te):te=e[9];const Z=te;let me;e[10]!==E||e[11]!==r||e[12]!==j?(me=()=>{E||j(r,{pin:!0})},e[10]=E,e[11]=r,e[12]=j,e[13]=me):me=e[13];const Ie=me;let fe;e[14]===Symbol.for("react.memo_cache_sentinel")?(fe=Pe=>{Pe.stopPropagation(),L(!1),q(!0)},e[14]=fe):fe=e[14];const je=fe;let $e,Re,Fe,Ve,De,ge,xe;if(e[15]!==m||e[16]!==z||e[17]!==J||e[18]!==K||e[19]!==g||e[20]!==O||e[21]!==Y||e[22]!==x||e[23]!==ae||e[24]!==de||e[25]!==u||e[26]!==w||e[27]!==n||e[28]!==W||e[29]!==Ie||e[30]!==Z||e[31]!==P||e[32]!==a||e[33]!==d||e[34]!==E||e[35]!==h||e[36]!==p||e[37]!==i||e[38]!==l||e[39]!==r||e[40]!==A||e[41]!==S||e[42]!==C||e[43]!==F||e[44]!==M||e[45]!==T||e[46]!==_||e[47]!==k||e[48]!==Q||e[49]!==o||e[50]!==f||e[51]!==y||e[52]!==$){const Pe=pg(n,"file"),Me=se=>{const{Item:ue,Separator:et}=se;return s.jsxs(s.Fragment,{children:[O&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("rename",r)},children:[s.jsx(oe,{name:"edit",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.rename")]}),s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),wr(r.path).then(bt=>{if(bt.ok){Te.success(y("sidebarFilesTree.toast.pathCopied"));return}Te.error(y("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(oe,{name:"link",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.copyPath")]}),!E&&w&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),w(r.path).catch(bt=>{console.error("Download failed:",bt),Te.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(oe,{name:"download",className:"me-2 h-4 w-4"})," ",y(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Y&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),T(r.path)},children:[s.jsx(oe,{name:"folder-received",className:"me-2 h-4 w-4"})," ",y(gg())]}),!E&&Y&&ro()&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),Yl(r.path).then(bt=>{bt||Te.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(oe,{name:"external-link",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.openInDefaultApp")]}),Pe.length>0&&s.jsx(et,{}),Pe.map(ye=>s.jsxs(ue,{onClick:bt=>{bt.stopPropagation(),xg(ye,{kind:"file",action:ye.action.id,directory:o||null,path:r.path,isDirectory:E},y)},children:[s.jsx(fo,{icon:ye.icon,iconSrc:ye.iconSrc,className:"me-2 h-4 w-4"})," ",ye.action.label]},`${ye.guest.id}:${ye.action.id}`)),E&&(z||J||ae)&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),z&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("createFile",r)},children:[s.jsx(oe,{name:"file-add",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFile")]}),J&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("createFolder",r)},children:[s.jsx(oe,{name:"folder-add",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFolder")]}),ae&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),M(r.path)},children:[s.jsx(oe,{name:"upload-2",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.uploadFiles")]})]}),K&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(oe,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.delete")]})]})]})};let Je;e[60]!==g||e[61]!==r.path||e[62]!==r.type||e[63]!==S||e[64]!==o?(Je=se=>{Si(se);const ue=jo(o,r.path);!ue||ue==="."||(se.dataTransfer.setData(lr,ue),se.dataTransfer.effectAllowed=g?"copyMove":"copy",g&&S({path:r.path,type:r.type}))},e[60]=g,e[61]=r.path,e[62]=r.type,e[63]=S,e[64]=o,e[65]=Je):Je=e[65];const X=Je;let Ee;e[66]!==g||e[67]!==Z||e[68]!==S?(Ee=se=>{g&&S(null),ki(se)&&Z()},e[66]=g,e[67]=Z,e[68]=S,e[69]=Ee):Ee=e[69];const _e=Ee;let pe;e[70]!==x||e[71]!==_||e[72]!==$?(pe=se=>{!x||!$||!Rn(se.dataTransfer)||(se.preventDefault(),se.stopPropagation(),se.dataTransfer.dropEffect="copy",_($))},e[70]=x,e[71]=_,e[72]=$,e[73]=pe):pe=e[73];const R=pe;let ie;e[74]!==x||e[75]!==_||e[76]!==$?(ie=se=>{!x||!$||!Rn(se.dataTransfer)||se.relatedTarget instanceof Node&&se.currentTarget.contains(se.relatedTarget)||(se.stopPropagation(),_(null))},e[74]=x,e[75]=_,e[76]=$,e[77]=ie):ie=e[77];const Ce=ie;let Ne;e[78]!==x||e[79]!==A||e[80]!==$?(Ne=se=>{!x||!$||!Rn(se.dataTransfer)||(se.preventDefault(),se.stopPropagation(),A($,se.dataTransfer))},e[78]=x,e[79]=A,e[80]=$,e[81]=Ne):Ne=e[81];const ze=Ne;let qe;e[82]!==r.path||e[83]!==r.type||e[84]!==o?(qe=(se,ue)=>gu(se)?null:wu(ue,{path:r.path,type:r.type},o),e[82]=r.path,e[83]=r.type,e[84]=o,e[85]=qe):qe=e[85];const Ue=qe;let tt;e[86]!==g||e[87]!==Ue||e[88]!==R||e[89]!==k?(tt=se=>{const ue=g?er(se.dataTransfer):null;if(!ue){R(se);return}se.stopPropagation();const et=Ue(se,ue);k(et),et&&(se.preventDefault(),se.dataTransfer.dropEffect="move")},e[86]=g,e[87]=Ue,e[88]=R,e[89]=k,e[90]=tt):tt=e[90];const He=tt;let Ze;e[91]!==g||e[92]!==Ue||e[93]!==ze||e[94]!==C||e[95]!==k||e[96]!==o?(Ze=se=>{const ue=g?er(se.dataTransfer):null;if(!ue){ze(se);return}se.stopPropagation(),se.preventDefault(),k(null);const et=Ue(se,ue);et&&yu(se.dataTransfer,o,ue)&&C(ue,et)},e[91]=g,e[92]=Ue,e[93]=ze,e[94]=C,e[95]=k,e[96]=o,e[97]=Ze):Ze=e[97];const Qe=Ze;Re=br,ge=Q,xe=L;let ot;e[98]===Symbol.for("react.memo_cache_sentinel")?(ot={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[98]=ot):ot=e[98];let pt;e[99]!==W||e[100]!==Ce||e[101]!==He||e[102]!==Qe?(pt=s.jsx("div",{className:"group relative flex items-center typography-meta",style:ot,onContextMenu:W,onDragEnter:He,onDragOver:He,onDragLeave:Ce,onDrop:Qe}),e[99]=W,e[100]=Ce,e[101]=He,e[102]=Qe,e[103]=pt):pt=e[103];let at;e[104]!==u?(at=s.jsx(Yc,{depth:u}),e[104]=u,e[105]=at):at=e[105];let xt;e[106]!==a||e[107]!==h||e[108]!==p?(xt=We("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)]":Gi(a),h&&"opacity-50"),e[106]=a,e[107]=h,e[108]=p,e[109]=xt):xt=e[109];let le;e[110]!==u?(le=Jc(u),e[110]=u,e[111]=le):le=e[111];let be;e[112]!==le?(be={paddingInlineStart:le},e[112]=le,e[113]=be):be=e[113];let Ae;e[114]!==E||e[115]!==i||e[116]!==r.extension||e[117]!==r.path?(Ae=E?s.jsx(mg,{expanded:i}):s.jsx(ho,{filePath:r.path,extension:r.extension,className:"ms-0.5 size-3.5"}),e[114]=E,e[115]=i,e[116]=r.extension,e[117]=r.path,e[118]=Ae):Ae=e[118];let N;e[119]!==r.name||e[120]!==r.path?(N=s.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]=N):N=e[121];let ce;e[122]!==E||e[123]!==l||e[124]!==f?(ce=!E&&s.jsx(bg,{isOpen:l,status:f}),e[122]=E,e[123]=l,e[124]=f,e[125]=ce):ce=e[125];let U;e[126]!==m||e[127]!==E?(U=E&&m&&s.jsx(wg,{badge:m}),e[126]=m,e[127]=E,e[128]=U):U=e[128];let we;e[129]!==ce||e[130]!==U?(we=s.jsxs(yg,{className:"pe-2",children:[ce,U]}),e[129]=ce,e[130]=U,e[131]=we):we=e[131];let ke;e[132]!==W||e[133]!==Ie||e[134]!==_e||e[135]!==X||e[136]!==Z||e[137]!==xt||e[138]!==be||e[139]!==Ae||e[140]!==N||e[141]!==we?(ke=s.jsxs("button",{type:"button",onClick:Z,onDoubleClick:Ie,onContextMenu:W,draggable:!0,onDragStart:X,onDragEnd:_e,className:xt,style:be,children:[Ae,N,we]}),e[132]=W,e[133]=Ie,e[134]=_e,e[135]=X,e[136]=Z,e[137]=xt,e[138]=be,e[139]=Ae,e[140]=N,e[141]=we,e[142]=ke):ke=e[142];const Xe=P&&s.jsx("div",{className:We("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100",hg(a||p)),children:s.jsxs(gn,{open:de,onOpenChange:q,children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(xn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:je,"aria-label":y("diffView.actions.moreActions"),children:s.jsx(oe,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:y("diffView.actions.moreActions")})]}),s.jsx(bn,{align:"end",side:"bottom",onCloseAutoFocus:()=>q(!1),children:Me({Item:Gt,Separator:mn})})]})});e[143]!==pt||e[144]!==at||e[145]!==ke||e[146]!==Xe?(Fe=s.jsxs(ao,{render:pt,children:[at,ke,Xe]}),e[143]=pt,e[144]=at,e[145]=ke,e[146]=Xe,e[147]=Fe):Fe=e[147],$e=lo,Ve="min-w-[180px]";let Oe;e[148]===Symbol.for("react.memo_cache_sentinel")?(Oe={Item:Cs,Separator:In},e[148]=Oe):Oe=e[148],De=Me(Oe),e[15]=m,e[16]=z,e[17]=J,e[18]=K,e[19]=g,e[20]=O,e[21]=Y,e[22]=x,e[23]=ae,e[24]=de,e[25]=u,e[26]=w,e[27]=n,e[28]=W,e[29]=Ie,e[30]=Z,e[31]=P,e[32]=a,e[33]=d,e[34]=E,e[35]=h,e[36]=p,e[37]=i,e[38]=l,e[39]=r,e[40]=A,e[41]=S,e[42]=C,e[43]=F,e[44]=M,e[45]=T,e[46]=_,e[47]=k,e[48]=Q,e[49]=o,e[50]=f,e[51]=y,e[52]=$,e[53]=$e,e[54]=Re,e[55]=Fe,e[56]=Ve,e[57]=De,e[58]=ge,e[59]=xe}else $e=e[53],Re=e[54],Fe=e[55],Ve=e[56],De=e[57],ge=e[58],xe=e[59];let Se;e[149]!==$e||e[150]!==Ve||e[151]!==De?(Se=s.jsx($e,{className:Ve,children:De}),e[149]=$e,e[150]=Ve,e[151]=De,e[152]=Se):Se=e[152];let Be;return e[153]!==Re||e[154]!==Fe||e[155]!==Se||e[156]!==ge||e[157]!==xe?(Be=s.jsxs(Re,{open:ge,onOpenChange:xe,children:[Fe,Se]}),e[153]=Re,e[154]=Fe,e[155]=Se,e[156]=ge,e[157]=xe,e[158]=Be):Be=e[158],Be},k2=(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,j2=c.memo(S2,k2),C2=t=>{const e=Le.c(14),{visible:n}=t,r=n===void 0?!0:n,o=Mn(N2),i=Zs()??"",a=yr();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=uo(a,i)??"",a?.kind==="preparing"){let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(_r,{}),e[7]=p):p=e[7],f=p;break e}d=T2,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=s.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},T2=({visible:t,currentDirectory:e,panelDirectory:n})=>{const r=c.useRef(t);r.current=t;const{t:o}=rt(),{files:i,runtime:a}=Es(),d=Rc(),u=sf(a.platform),l=zt(e.trim()),f=zt(n.trim()),m=oa(l),p=nf(),h=rf(),x=of(D=>D.searchFiles),g=G(D=>D.openContextFile),b=po(t?e:null),[w,j]=c.useState(""),v=vg(w,200),T=c.useRef(null),[F,_]=c.useState([]),[A,M]=c.useState(!1),S=!!i.searchContents,[k,C]=c.useState("names"),[y,E]=c.useState(!1),B=S&&k==="contents",$=a2({searchContents:i.searchContents,directory:e,query:v,regex:y,includeHidden:p,respectGitignore:!h,active:t&&B}),O=G(D=>D.openContextFileAtLine),[z,J]=c.useState(null),[K,ee]=c.useState(null),[V,Y]=c.useState(null),[ae,P]=c.useState(null),[de,q]=c.useState(null),{hasTouchOnlyPointer:Q}=wn(),L=!!(i.rename&&l)&&!Q,ne=G(D=>D.confirmFileTreeMove),W=G(D=>D.setConfirmFileTreeMove),[te,Z]=c.useState({}),[me,Ie]=c.useState({}),fe=c.useRef(new Set),je=c.useRef(new Map),$e=c.useMemo(()=>new dx,[]);c.useEffect(()=>()=>$e.clear(),[$e]);const Re=c.useRef(null);c.useEffect(()=>{if(ee(null),P(null),q(null),!l){Z({}),Ie({}),fe.current=new Set;return}const D=v2(l);D?(Z({...D.childrenByDir}),Ie({...D.loadErrorsByDir}),fe.current=new Set(D.loadedDirs)):(Z({}),Ie({}),fe.current=new Set)},[l]),c.useEffect(()=>{if(!l)return;const D=Xo(l);D.childrenByDir=te},[l,te]),c.useEffect(()=>{if(!l)return;const D=Xo(l);D.loadErrorsByDir=me},[l,me]),c.useEffect(()=>{if(!l)return;const D=Xo(l);D.loadedDirs=new Set(fe.current)},[l,te,me]),c.useEffect(()=>()=>{if(!l)return;const D=Ds.get(m);D&&D.loadedDirs.size===0&&Object.keys(D.childrenByDir).length===0&&Ds.delete(m)},[m,l]);const Fe=c.useMemo(()=>[],[]),Ve=c.useMemo(()=>[],[]),De=xs(D=>l?D.byRoot[l]?.expandedPaths??Fe:Fe),ge=c.useMemo(()=>new Set(De),[De]),xe=xs(D=>l?D.byRoot[l]?.selectedPath??null:null),Se=xs(D=>D.setSelectedPath),Be=c.useRef(null);c.useEffect(()=>{Be.current=xe},[xe]);const Pe=xs(D=>D.addOpenPath),Me=xs(D=>D.removeOpenPathsByPrefix),Je=xs(D=>D.toggleExpandedPath),X=xs(D=>D.expandPath),Ee=xs(D=>D.collapseAllExpandedPaths),_e=G(D=>f?D.contextPanelByDirectory[f]?.tabs??Ve:Ve),pe=c.useMemo(()=>new Set(_e.map(D=>D.mode==="file"?D.targetPath:null).filter(D=>typeof D=="string"&&D.length>0).map(D=>zt(D))),[_e]),[R,ie]=c.useState(null),[Ce,Ne]=c.useState(null),[ze,qe]=c.useState(""),[Ue,tt]=c.useState(!1),He=!!i.writeFile,Ze=!!i.createDirectory,Qe=!!i.rename,ot=!!i.delete,pt=!!i.revealPath,at=c.useMemo(()=>({canRename:Qe,canCreateFile:He,canCreateFolder:Ze,canDelete:ot,canReveal:pt}),[Qe,He,Ze,ot,pt]),xt=c.useCallback(D=>{i.revealPath&&i.revealPath(D).catch(()=>{Te.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),le=c.useCallback((D,I)=>{ie(D),Ne(I),qe(D==="rename"&&I.name||""),tt(!1)},[]),be=c.useCallback((D,I)=>{const ve=I.filter(he=>he&&typeof he.name=="string"&&he.name.length>0).filter(he=>p||!he.name.startsWith(".")).filter(he=>h||!b2(he.name)).map(he=>{const it=he.name,nt=zt(he.path||""),Nt=nt?g2(nt)?nt:zt(`${D}/${nt}`):zt(`${D}/${it}`),At=he.isDirectory?"directory":"file",Dt=At==="file"&&it.includes(".")?it.split(".").pop()?.toLowerCase():void 0;return{name:it,path:Nt,type:At,extension:Dt}});return h2(ve)},[h,p]),Ae=c.useCallback(async(D,I,ve=!1)=>{if(!r.current||I?.())return;const he=zt(D.trim());if(!he||!ve&&fe.current.has(he))return;const it=Jt();return $e.run(he,async nt=>{const Nt=()=>!nt()||Jt()!==it;try{const At=!h,Dt=i.listDirectory?(await i.listDirectory(he,{respectGitignore:At})).entries:await Qo.listLocalDirectory(he,{respectGitignore:At});if(Nt())return;je.current.set(he,Dt.length);const Mt=be(he,Dt);fe.current=new Set(fe.current),fe.current.add(he),Ie(ws=>{if(!ws[he])return ws;const nn={...ws};return delete nn[he],nn}),Z(ws=>ws[he]&&ux(ws[he],Mt)?ws:{...ws,[he]:Mt})}catch(At){if(Nt())return;const Dt=At instanceof Error?At.message:String(At??"");console.error("Failed to load sidebar directory:",At),Ie(Mt=>({...Mt,[he]:Dt}))}},ve)},[$e,i,be,h]),N=c.useCallback(async()=>{if(!l)return;Re.current?.abort();const D=new AbortController;Re.current=D,$e.clear();try{const ve=(xs.getState().byRoot[l]?.expandedPaths??[]).map(nt=>zt(nt)).filter(nt=>!!nt&&nt!==l&&nt.startsWith(`${l}/`)),he=[l,...ve];fe.current=new Set(fe.current);for(const nt of he)fe.current.delete(nt);Ie(nt=>{if(Object.keys(nt).length===0)return nt;const Nt={...nt};let At=!1;for(const Dt of he)Dt in Nt&&(delete Nt[Dt],At=!0);return At?Nt:nt});const it=()=>D.signal.aborted;await Ae(l,it);for(let nt=0;nt<ve.length&&!D.signal.aborted;nt+=3){const Nt=ve.slice(nt,nt+3);await Promise.all(Nt.map(At=>Ae(At,it)))}}catch(I){if(D.signal.aborted)return;console.error("Failed to refresh sidebar tree:",I)}finally{Re.current===D&&(Re.current=null)}},[$e,Ae,l]),ce=c.useCallback(async D=>{if(!D){await N();return}const I=zt(D);fe.current=new Set(fe.current),fe.current.delete(I),await Ae(I,void 0,!0)},[Ae,N]);c.useEffect(()=>{l&&(Re.current?.abort(),fe.current=new Set,$e.clear(),Ie({}),Z(D=>Object.keys(D).length===0?D:{}),Ae(l))},[$e,Ae,l,p,h]),c.useEffect(()=>{if(!t||!l||De.length===0)return;const D=De.map(he=>zt(he)).filter(he=>!!he&&he!==l&&he.startsWith(`${l}/`)&&!fe.current.has(he)&&!$e.has(he)).sort((he,it)=>he.split("/").length-it.split("/").length);if(D.length===0)return;let I=!1;const ve=()=>I;return(async()=>{for(let he=0;he<D.length&&!I;he+=3){const it=D.slice(he,he+3);await Promise.all(it.map(nt=>Ae(nt,ve)))}})(),()=>{I=!0}},[$e,De,Ae,l,t]);const U=c.useRef(t);c.useEffect(()=>{const D=t&&!U.current;U.current=t,D&&N()},[N,t]);const we=c.useCallback(({directories:D})=>{if(!l)return;const I=new Set((xs.getState().byRoot[l]?.expandedPaths??[]).map(Dt=>zt(Dt))),ve=l==="/"?"/":`${l}/`,he=Dt=>{for(let Mt=Dt;Mt!==l;Mt=Br(Mt))if(!Mt.startsWith(ve)||!I.has(Mt))return!1;return!0},it=Dt=>{for(let Mt=Dt;Mt===l||Mt.startsWith(ve);Mt=Br(Mt)){if(fe.current.has(Mt))return Mt;if(Mt===l)break}return null},nt=new Set,Nt=new Set;for(const Dt of D??fe.current){const Mt=it(zt(Dt));Mt&&(he(Mt)?nt:Nt).add(Mt)}Nt.size>0&&(fe.current=new Set([...fe.current].filter(Dt=>!Nt.has(Dt))));const At=[...nt].filter(Dt=>(je.current.get(Dt)??0)<=sp);(async()=>{for(let Dt=0;Dt<At.length;Dt+=3)await Promise.all(At.slice(Dt,Dt+3).map(Mt=>Ae(Mt,void 0,!0)))})()},[Ae,l]);np({root:l,active:t,whileInactive:"drop",onChanges:we}),c.useEffect(()=>{if(!t)return;if(!e||B){_([]),M(!1);return}const D=v.trim();if(!D){_([]),M(!1);return}let I=!1;return M(!0),x(e,D,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(ve=>{if(I)return;const it=ve.filter(nt=>h||!w2(nt.path)).map(nt=>({name:nt.name,path:zt(nt.path),type:"file",extension:nt.extension,relativePath:nt.relativePath}));_(it)}).catch(()=>{I||_([])}).finally(()=>{I||M(!1)}),()=>{I=!0}},[B,e,v,x,p,h,t]);const ke=c.useMemo(()=>{const D=new Map;if(!b?.files)return D;for(const I of b.files)I.index==="A"||I.working_dir==="?"?D.set(I.path,"git-added"):I.index==="D"?D.set(I.path,"git-deleted"):(I.index==="M"||I.working_dir==="M")&&D.set(I.path,"git-modified");return D},[b]),Xe=c.useMemo(()=>{const D=new Map;if(!b?.files||!l)return D;for(const I of b.files){const ve=I.index==="M"||I.working_dir==="M",he=I.index==="A"||I.working_dir==="?";if(!ve&&!he)continue;const it=I.path.split("/");if(it.length<=1)continue;let nt=l;for(let Nt=0;Nt<it.length-1;Nt++){nt=`${nt}/${it[Nt]}`;let At=D.get(nt);At||(At={modified:0,added:0},D.set(nt,At)),ve&&At.modified++,he&&At.added++}}return D},[b,l]),Oe=c.useCallback(D=>{if(ke.size===0)return null;const I=D.startsWith(l+"/")?D.slice(l.length+1):D;return ke.get(I)??null},[ke,l]),se=c.useCallback(D=>{if(Xe.size===0)return null;const I=Xe.get(D);return I&&I.modified+I.added>0?I:null},[Xe]),ue=c.useCallback(async(D,I)=>{if(!l)return;const ve=await Ua(i,D.path,{directory:l});if(!ve.ok){Va(D.path,ve);return}Se(l,D.path),Pe(l,D.path),g(f,D.path,{preview:!I?.pin&&!G.getState().isMobile})},[Pe,i,g,f,l,Se]),et=c.useCallback(async(D,I)=>{if(!l)return;const ve=await Ua(i,D.path,{directory:l});if(!ve.ok){Va(D.path,ve);return}Se(l,D.path),Pe(l,D.path),J({path:D.path,key:mu(D)}),O(f,D.path,D.line,D.column,{preview:!I?.pin&&!G.getState().isMobile})},[Pe,i,O,f,l,Se]),ye=c.useCallback((D,I)=>{Si(D),Zo(null),D.dataTransfer.setData(lr,I.relativePath),D.dataTransfer.effectAllowed="copy"},[]),bt=c.useCallback((D,I)=>{ki(D)&&et(I)},[et]),[Tt,vt]=c.useState(null),Pt=c.useCallback(()=>vt(null),[]),Ke=c.useRef(null),ct=fx(Ke,{onSettled:Pt}),Rt=c.useCallback(async D=>{const I=zt(D);if(!l)return;const ve=xs.getState().byRoot[l]?.expandedPaths.includes(I)??!1;ct(D,ve,()=>{const he=Array.from(Ke.current?.querySelectorAll("[data-tree-disclosure-path]")??[],it=>it.dataset.treeDisclosurePath??"");vt(ve?null:he.slice(he.indexOf(D)+1)),Je(l,I)}),fe.current.has(I)||await Ae(I)},[Ae,l,Je,ct]),{canUpload:ht,uploadingDirectory:Ct,uploadFiles:lt,pickFiles:Et,uploadElements:qt}=rp({root:l,refreshDirectory:ce}),dt=Ct!==null,ut=Ct??K,Ot=c.useCallback((D,I)=>{const ve=m2(I);ve.length!==0&&(ee(null),lt(D,ve))},[lt]),Zt=c.useCallback(D=>{if(Zo(D),!D){Y(null),P(null);return}requestAnimationFrame(()=>{bu()?.path===D.path&&Y(D.path)})},[]),is=c.useCallback(async(D,I)=>{const ve=d2(D,I),he=await Wa(i,{tabs:f,files:l},D.path,ve);if(he==="conflict"){Te.error(o("sidebarFilesTree.toast.nameTaken",{name:ve.slice(ve.lastIndexOf("/")+1),folder:Un(l,I)}));return}if(he==="failed"){Te.error(o("sidebarFilesTree.toast.operationFailed"));return}I!==l&&X(l,I),await Promise.all([ce(Br(D.path)),ce(I)]).catch(()=>{})},[X,i,f,ce,l,o]),as=c.useCallback((D,I)=>{if(G.getState().confirmFileTreeMove){q({source:D,targetDirectory:I});return}is(D,I)},[is]),ss=c.useCallback(()=>{de&&(q(null),is(de.source,de.targetDirectory))},[is,de]),Xt=c.useCallback((D,I)=>!L||gu(D)?null:wu(I,null,l),[L,l]),ls=c.useCallback(D=>{const I=er(D.dataTransfer);if(I){const ve=Xt(D,I);if(P(ve),!ve)return;D.preventDefault(),D.dataTransfer.dropEffect="move";return}!ht||dt||!l||!Rn(D.dataTransfer)||(D.preventDefault(),D.dataTransfer.dropEffect="copy",ee(l))},[ht,Xt,dt,l]),ns=c.useCallback(D=>{if(!(D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget))){if(er(D.dataTransfer)){P(null);return}Rn(D.dataTransfer)&&ee(null)}},[]),Is=c.useCallback(D=>{const I=er(D.dataTransfer);if(I){D.preventDefault(),P(null);const ve=Xt(D,I);ve&&yu(D.dataTransfer,l,I)&&as(I,ve);return}!ht||dt||!l||!Rn(D.dataTransfer)||(D.preventDefault(),Ot(l,D.dataTransfer))},[ht,Xt,Ot,as,dt,l]),Ps=c.useCallback(async D=>{if(D?.preventDefault(),!Ce||!R)return;tt(!0);const I=()=>tt(!1),ve=()=>ie(null);if(R==="createFile"){if(!ze.trim()){Te.error(o("sidebarFilesTree.toast.filenameRequired")),I();return}if(!i.writeFile){Te.error(o("sidebarFilesTree.toast.writeNotSupported")),I();return}const he=Ce.path,it=he?`${he}/`:"",nt=zt(`${it}${ze.trim()}`);await i.writeFile(nt,"").then(async Nt=>{Nt.success&&(Te.success(o("sidebarFilesTree.toast.fileCreated")),await ce(he)),ve()}).catch(()=>Te.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(R==="createFolder"){if(!ze.trim()){Te.error(o("sidebarFilesTree.toast.folderNameRequired")),I();return}const he=Ce.path,it=he?`${he}/`:"",nt=zt(`${it}${ze.trim()}`);await i.createDirectory(nt).then(async Nt=>{Nt.success&&(Te.success(o("sidebarFilesTree.toast.folderCreated")),await ce(he)),ve()}).catch(()=>Te.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(R==="rename"){if(!ze.trim()){Te.error(o("sidebarFilesTree.toast.nameRequired")),I();return}if(!i.rename){Te.error(o("sidebarFilesTree.toast.renameNotSupported")),I();return}const he=Ce.path,it=he.split("/").slice(0,-1).join("/"),nt=it?`${it}/`:"",Nt=ze.trim(),At=zt(`${nt}${Nt}`);try{const Dt=await Wa(i,{tabs:f,files:l},he,At);Dt==="moved"?(Te.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await ce(it),ve()):Dt==="conflict"?Te.error(o("sidebarFilesTree.toast.nameTaken",{name:Nt,folder:Un(l,it)})):Te.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Te.error(o("sidebarFilesTree.toast.operationFailed"))}finally{I()}return}if(R==="delete"){if(!i.delete){Te.error(o("sidebarFilesTree.toast.deleteNotSupported")),I();return}const he=Ce.path,it=he.split("/").slice(0,-1).join("/");await i.delete(he).then(async nt=>{nt.success&&(Te.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await ce(it),l&&Me(l,he),(xe===he||xe&&xe.startsWith(he+"/"))&&Se(l,null)),ve()}).catch(()=>Te.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}I()},[R,Ce,ze,i,f,ce,Me,l,xe,Se,o]),cs=c.useMemo(()=>l?u2({root:l,childrenByDir:te,expandedPaths:ge,loadErrorsByDir:me}):[],[te,ge,me,l]),rs=c.useMemo(()=>new Map(cs.flatMap((D,I)=>D.kind==="node"?[[D.node.path,I]]:[])),[cs]),[Kt,Os]=c.useState(null),[re,Ye]=c.useState(null),gt=c.useCallback(D=>{Ke.current=D,Ye(D)},[]),[wt,_t]=c.useState(null),Vt=c.useMemo(()=>[V,wt,...Tt??[]].flatMap(D=>D?[rs.get(D)??-1]:[]),[wt,V,Tt,rs]),H=c.useCallback(D=>f2(gx(D),Vt,cs.length),[Vt,cs.length]),[Ge,mt]=c.useState(0);c.useLayoutEffect(()=>{if(!Kt||!re)return;const D=re.getBoundingClientRect().top-Kt.getBoundingClientRect().top+Kt.scrollTop;mt(Math.max(0,Math.round(D)))},[re,Kt]);const It=c.useRef(null),$t=c.useRef(new Map),Bt=c.useRef(null),Ft=c.useCallback(D=>{const I=Math.max(0,...$t.current.values());D.style.setProperty("--oc-file-tree-width",`${I}px`)},[]),js=c.useCallback((D,I)=>{const ve=D.dataset.treeRowPath,he=Ke.current;!ve||!he||I<=he.clientWidth+.5||$t.current.get(ve)!==I&&($t.current.set(ve,I),Bt.current===null&&(Bt.current=requestAnimationFrame(()=>{Bt.current=null,Ke.current&&Ft(Ke.current)})))},[Ft]);c.useEffect(()=>()=>{Bt.current!==null&&cancelAnimationFrame(Bt.current)},[]),c.useLayoutEffect(()=>{if(!re)return;const D=$t.current;for(const he of D.keys())rs.has(he)||D.delete(he);const I=Kt?.scrollLeft??0;re.style.removeProperty("--oc-file-tree-width");const ve=re.clientWidth;for(const he of re.children){const it=he instanceof HTMLElement?he.dataset.treeRowPath:void 0;if(!it)continue;const nt=he.getBoundingClientRect().width;nt>ve+.5?D.set(it,nt):D.delete(it)}Ft(re),Kt&&(Kt.scrollLeft=I)},[re,rs,Kt,Ft]);const Rs=hx({count:cs.length,enabled:Kt!==null,getScrollElement:()=>Kt,estimateSize:D=>(cs[D]?.kind==="node"?It.current:null)??p2,measureElement:(D,I,ve)=>{const he=xx(D,I,ve);return D.dataset.treeRowPath&&(It.current=he),I&&js(D,I.borderBoxSize?.[0]?.inlineSize??D.getBoundingClientRect().width),he},getItemKey:D=>cs[D]?.key??D,overscan:12,scrollMargin:Ge,rangeExtractor:H}),Xs=D=>{if(D.kind==="error")return s.jsxs("div",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:Jc(D.depth)},children:[s.jsx(Yc,{depth:D.depth}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:D.message,children:D.message}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{ce(D.directory)},children:[s.jsx(oe,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),s.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFolder")})]})]});const{node:I,depth:ve,isExpanded:he}=D,it=I.type==="directory";return s.jsx(j2,{node:I,root:l,isExpanded:he,isActive:xe===I.path,isBrowserClient:u,depth:ve,isOpen:!it&&pe.has(I.path),status:it?void 0:Oe(I.path),badge:it?se(I.path):void 0,isDropTarget:it&&(ut===I.path||ae===I.path),isDragSource:V===I.path,canUpload:ht&&!dt,canMove:L,permissions:at,downloadFile:i.downloadFile,onSelect:ue,onToggle:Rt,onRevealPath:xt,onOpenDialog:le,onSetDropTarget:ee,onDropFiles:Ot,onPickFiles:Et,onMoveDragChange:Zt,onSetMoveDropTarget:P,onMoveDrop:as,guestActions:d})},Co=c.useCallback(D=>{const I=D.target instanceof Element?D.target.closest("[data-tree-row-path]"):null;_t(I?.dataset.treeRowPath??null)},[]),To=c.useCallback(D=>{D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget)||_t(null)},[]);c.useEffect(()=>{const D=Be.current;if(!D||!Kt||!re)return;const I=rs.get(D);I===void 0||Kt.offsetParent===null||(Be.current=null,Rs.scrollToIndex(I,{align:"auto"}))});const vr=!!(l&&te[l]),$n=l?me[l]:null,Bn=v.trim().length>0,No=!A&&!Bn&&F.length===0&&!$n&&vr&&!!l,zn=ut?Un(l,ut):"",Sr=ae?Un(l,ae):"",Eo=de?de.source.path.slice(de.source.path.lastIndexOf("/")+1):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col border-b border-edge-muted",children:[s.jsx("div",{className:"flex h-8 shrink-0 items-center border-t border-edge-muted px-2",children:s.jsx(Sg,{className:"flex-1",start:null,groups:[[(He||Ze||ht)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:dt?"loader-4":"add",iconClassName:dt?"animate-spin":void 0,menu:s.jsxs(s.Fragment,{children:[He?s.jsxs(Gt,{onClick:()=>le("createFile",{path:e,type:"directory"}),children:[s.jsx(oe,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,Ze?s.jsxs(Gt,{onClick:()=>le("createFolder",{path:e,type:"directory"}),children:[s.jsx(oe,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,ht?s.jsxs(Gt,{disabled:!l||dt,onClick:()=>Et(l),children:[s.jsx(oe,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})},{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:h,onSelect:()=>af(!h)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{N()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{l&&Ee(l)}}]]})}),s.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[S?s.jsxs(gn,{children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"absolute inset-s-3 top-3 inline-flex",children:s.jsx(xn,{asChild:!0,children:s.jsxs(ft,{variant:"ghost",size:"sm",className:"relative size-6 p-0 text-muted-foreground hover:text-foreground","aria-label":o("sidebarFilesTree.search.mode.aria"),children:[s.jsx(oe,{name:B?"file-search":"search",className:"h-4 w-4"}),s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.mode.aria")})]}),s.jsx(bn,{align:"start",side:"bottom",children:s.jsxs(zc,{value:k,onValueChange:D=>C(D==="contents"?"contents":"names"),children:[s.jsxs(Kr,{value:"names",closeOnClick:!0,className:"items-center",children:[s.jsx(oe,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),s.jsxs(Kr,{value:"contents",closeOnClick:!0,className:"items-center",children:[s.jsx(oe,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):s.jsx(oe,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),s.jsx(On,{ref:T,value:w,onChange:D=>j(D.target.value),placeholder:o(B?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:We("h-8 ps-8 typography-meta",B?"pe-16":"pe-8")}),B?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"chip",size:"xs","aria-pressed":y,onClick:()=>{E(D=>!D),T.current?.focus()},"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o(y?"contextTooltips.files.searchPlainText":"sidebarFilesTree.search.regexTitle")})]}):null,w.trim().length>0?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:We("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",B?"inset-e-10":"inset-e-4"),onClick:()=>{j(""),T.current?.focus()},children:s.jsx(oe,{name:"close",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.clearAria")})]}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsxs(gs,{ref:Os,outerClassName:"h-full min-h-0",className:We("@container px-1.5 py-1.5 [overflow-anchor:none]",(ut===l||ae===l)&&"bg-interactive-selection/10"),onDragEnter:ls,onDragOver:ls,onDragLeave:ns,onDrop:Is,children:[s.jsx("ul",{className:"flex flex-col",children:B&&$.status!=="idle"?s.jsx(c2,{state:$,activeMatchKey:z&&z.path===xe?z.key:null,onOpen:et,onDragStart:ye,onDragEnd:bt}):A?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(oe,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Bn&&F.length===0?s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):F.length>0?F.map(D=>{const I=xe===D.path;return s.jsx("li",{"data-file-tree-path":D.path,children:s.jsxs("button",{type:"button",onClick:()=>ue(D),onDoubleClick:()=>ue(D,{pin:!0}),draggable:!0,onDragStart:ve=>{Si(ve),Zo(null);const he=D.relativePath||jo(l??"",D.path);!he||he==="."||(ve.dataTransfer.setData(lr,he),ve.dataTransfer.effectAllowed="copy")},onDragEnd:ve=>{ki(ve)&&ue(D)},className:We("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Gi(I)),title:D.path,children:[s.jsx(ho,{filePath:D.path,extension:D.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`${D.relativePath??D.path}`})]})},D.path)}):$n?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:$n}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{N()},children:[s.jsx(oe,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),s.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFileList")})]})]}):vr&&l?null:s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),No?s.jsx("ul",{ref:gt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Rs.getTotalSize()},onFocus:Co,onBlur:To,children:Rs.getVirtualItems().map(D=>{const I=cs[D.index];if(!I)return null;const ve=I.kind==="node"?I.node.path:void 0;return s.jsx("li",{ref:Rs.measureElement,"data-index":D.index,"data-tree-row-path":ve,"data-tree-disclosure-path":I.kind==="node"?ve:`${I.directory}/`,"data-file-tree-path":I.kind==="node"&&I.node.type==="file"?ve:void 0,className:We("absolute inset-x-0 top-0",I.kind==="node"&&"min-w-max"),style:{transform:`translateY(${D.start-Ge}px)`},children:Xs(I)},D.key)})}):null]}),ut?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(oe,{name:dt?"loader-4":"folder-received",className:We("size-4 flex-shrink-0",dt&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:zn,children:o(dt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:zn})})]}):ae?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(oe,{name:"folder-received",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Sr,children:o("sidebarFilesTree.drop.moveTarget",{path:Sr})})]}):null]}),qt,s.jsx(nr,{open:!!R,onOpenChange:D=>!D&&ie(null),children:s.jsxs(rr,{children:[s.jsxs(or,{children:[s.jsxs(ir,{children:[R==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),R==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),R==="rename"&&o("sidebarFilesTree.dialog.rename.title"),R==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(ar,{children:[R==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ce?.path??o("sidebarFilesTree.dialog.rootFallback")}),R==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ce?.path??o("sidebarFilesTree.dialog.rootFallback")}),R==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ce?.name??""}),R==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ce?.name??""})]})]}),R!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(On,{value:ze,onChange:D=>qe(D.target.value),placeholder:o(R==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:D=>{D.key==="Enter"&&Ps()},autoFocus:!0})}),s.jsxs(Hr,{children:[s.jsx(ft,{variant:"outline",onClick:()=>ie(null),disabled:Ue,children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{variant:R==="delete"?"destructive":"default",onClick:()=>{Ps()},disabled:Ue||R!=="delete"&&!ze.trim(),children:Ue?s.jsx(oe,{name:"loader-4",className:"size-4 animate-spin"}):o(R==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),s.jsx(nr,{open:de!==null,onOpenChange:D=>{D||q(null)},children:s.jsxs(rr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(or,{children:[s.jsx(ir,{children:o("sidebarFilesTree.dialog.move.title")}),s.jsx(ar,{children:de?o("sidebarFilesTree.dialog.move.description",{name:Eo,folder:Un(l,de.targetDirectory)}):null})]}),s.jsxs(Hr,{className:"w-full sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>W(!ne),children:[s.jsx(ti,{checked:!ne,onChange:D=>W(!D),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),s.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:()=>q(null),children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{onClick:ss,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function N2(t){return t.runtimeKey}const E2=hr(()=>Lt(()=>import("./WalkthroughView-DeuNxpZ7.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,215,216,217,204,218])).then(t=>({default:t.WalkthroughView}))),I2=hr(()=>Lt(()=>import("./DiffView-DPpu52DA.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,205,206,207,208,210,211,215,218])).then(t=>({default:t.DiffView}))),P2=hr(()=>Lt(()=>import("./FilesView-CPrroDyU.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,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,235,207,208,236,237,238,239,206,218,203,240])).then(t=>({default:t.FilesView}))),vu=c.lazy(()=>Lt(()=>import("./useAppFontEffects-D9nf8G19.js").then(t=>t.t9),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.PluginPane}))),Rl=c.lazy(()=>Lt(()=>import("./GuestSurfacePane-BsMH8QjU.js"),__vite__mapDeps([241,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.GuestSurfacePane}))),Su={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},R2=t=>{const e=Le.c(12),{mode:n,docking:r}=t,[o,i]=c.useState(null),a=Su[r.dock],d=Math.max(Tg,o??r.size),u=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let l;e[0]!==a.page||e[1]!==u?(l=We("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u,a.page),e[0]=a.page,e[1]=u,e[2]=l):l=e[2];let f;e[3]!==a.vertical||e[4]!==d?(f=a.vertical?{height:d}:{width:d},e[3]=a.vertical,e[4]=d,e[5]=f):f=e[5];let m;e[6]!==n?(m=s.jsx(vu,{mode:n,onResize:i}),e[6]=n,e[7]=m):m=e[7];let p;return e[8]!==l||e[9]!==f||e[10]!==m?(p=s.jsx("div",{className:l,style:f,children:m}),e[8]=l,e[9]=f,e[10]=m,e[11]=p):p=e[11],p},Cn=(t,e)=>`${t}\0${e}`,D2=({visible:t,active:e,fill:n=!1,side:r})=>{const{t:o}=rt(),i=G(v=>v.contextEditorTreeWidth),a=G(v=>v.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(v=>{const T=h.current;T&&(T.style.width=`${v}px`,T.style.setProperty("--oc-editor-tree-width",`${v}px`))},[]),g=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}p.current=v.pointerId,u(!0),l.current=v.clientX,f.current=i,m.current=i,v.preventDefault()}},b=v=>{if(!d||p.current!==v.pointerId)return;const T=r==="left"?v.clientX-l.current:l.current-v.clientX,F=no(v.currentTarget)?-T:T,_=Jo(f.current+F);m.current!==_&&(m.current=_,x(_))},w=v=>{if(p.current!==v.pointerId)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const T=Jo(m.current??i);p.current=null,m.current=null,u(!1),a(T)},j=t?i:0;return s.jsxs("div",{ref:h,className:We("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${d?m.current??j:j}px`,maxWidth:n?"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&&!n&&s.jsx("div",{"aria-hidden":"true",className:We("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!n&&s.jsx("div",{className:We("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:b,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:We("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:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(C2,{visible:t&&e})})]})},dn=t=>{const e=Le.c(12),{zone:n,isOpen:r,interactive:o,hidden:i,className:a,children:d}=t,u=!r||i;let l;e[0]!==d||e[1]!==u?(l=s.jsx(Qc,{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=s.jsx(Gc.Provider,{value:!0,children:s.jsx(lp.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=s.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]!==n?(p=s.jsx(r2,{zone:n,children:m}),e[9]=m,e[10]=n,e[11]=p):p=e[11],p},_2=()=>{const{t}=rt(),e=Zs()??"",n=c.useMemo(()=>e?fs(e):"",[e]),r=G(R=>n?R.contextPanelByDirectory[n]:void 0),o=yr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,d=uo(o,e)??"",u=G(R=>R.contextSurfaceZones),l=G(R=>R.contextPanelByDirectory),f=G(R=>R.closeContextPanelTab),m=G(R=>R.closeContextFile),p=G(R=>R.openContextPanelTab),h=G(R=>R.openAgentBrowserTab),x=G(R=>R.openContextFile),g=G(R=>R.contextEditorTreeVisible),b=G(R=>R.contextEditorVisible),w=G(R=>R.fileTreeSide),j=xs(R=>R.setSelectedPath),v=ur(R=>R.headerSlot),T=c.useMemo(()=>r?.tabs??[],[r?.tabs]),F=Or(R=>R.chatCovered),_=c.useMemo(()=>{const R=ie=>{const Ce=r?Wr(r,u,ie):null,Ne=ie==="bottom"&&F;return{activeTab:Ce,isOpen:!!(r&&tr(r,ie).isOpen&&Ce)&&!Ne}};return{left:R("left"),right:R("right"),bottom:R("bottom")}},[F,r,u]),A={left:{..._.left,activeTab:Mr(_.left.activeTab,_.left.isOpen)},right:{..._.right,activeTab:Mr(_.right.activeTab,_.right.isOpen)},bottom:{..._.bottom,activeTab:Mr(_.bottom.activeTab,_.bottom.isOpen)}},M={left:qo(A.left.isOpen),right:qo(A.right.isOpen),bottom:qo(A.bottom.isOpen)},S=R=>!M[R],k={left:Yn(A.left.isOpen),right:Yn(A.right.isOpen),bottom:Yn(A.bottom.isOpen)},C={left:Dr(A.left.isOpen,k.left,A.left.activeTab?.mode),right:Dr(A.right.isOpen,k.right,A.right.activeTab?.mode),bottom:Dr(A.bottom.isOpen,k.bottom,A.bottom.activeTab?.mode)},y=R=>{const ie=ei(u,R);return{zone:ie,...A[ie]}},E=y("file"),B=y("chat"),$=y("browser"),O=y("diff"),z=y("terminal"),J=y("walkthrough"),[K,ee]=c.useState([]),V=c.useCallback((R,ie)=>{ee(Ce=>lf(Ce,Cn(R,ie)))},[]),Y=G(R=>R.liveBrowserTabLimit);c.useEffect(()=>N0((R,ie)=>{const Ce=ie.directory?fs(ie.directory):n;if(!Ce)return null;const Ne=h(Ce,R,ie.sessionId);return Ne&&V(Ce,Ne),Ne}),[n,h,V]),c.useEffect(()=>E0((R,ie)=>G.getState().contextPanelByDirectory[R]?.tabs?.some(Ne=>Ne.id===ie&&Ne.mode==="browser")?(f(R,ie),!0):!1),[f]),c.useEffect(()=>tn(R=>{if(R.type!=="file-open-request")return;const ie=R.directory??e;ie&&x(ie,R.path)}),[e,x]),c.useEffect(()=>tn(R=>{if(R.type!=="plan-open-request")return;const ie=R.directory??e,Ce=op(ie,R.projectId);!ie||!Ce||G.getState().openProjectKnowledgePlan(ie,kg(Ce),R.planId)}),[e]);const ae=_[$.zone].activeTab,P=ae?.mode==="browser"?ae.id:null;c.useEffect(()=>{T0(n,P)},[n,P]);const de=_[E.zone].activeTab;c.useEffect(()=>{if(!d||de?.mode!=="file"||!de.targetPath)return;const R=ks(de.targetPath)===ks(d);j(fs(d),de.targetPath,{allowOutsideRoot:!o&&R})},[d,o,de,j]);const q=c.useMemo(()=>T.some(R=>R.mode==="file"&&R.targetPath),[T]),Q=c.useMemo(()=>T.some(R=>R.mode==="file"),[T]),L=q&&(b||!g),ne=E.activeTab?.mode==="file",W=c.useCallback(R=>{n&&m(n,R)},[m,n]),te=B.isOpen&&B.activeTab?.mode==="chat"?B.activeTab:null,Z=te?yo(te.dedupeKey):null,me=c.useMemo(()=>(te?.targetDirectory?fs(te.targetDirectory):"")||n||null,[te?.targetDirectory,n]),Ie=c.useMemo(()=>Z?{sessionId:Z,directory:me}:null,[Z,me]);c.useEffect(()=>{if(!me||!Z||typeof window>"u")return;const R=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Mo(me,Z,!1);return}ed(Z),Mo(me,Z,!0)};R();const ie=window.setInterval(R,1e4);return window.addEventListener("focus",R),window.addEventListener("blur",R),document.addEventListener("visibilitychange",R),()=>{window.clearInterval(ie),window.removeEventListener("focus",R),window.removeEventListener("blur",R),document.removeEventListener("visibilitychange",R),Mo(me,Z,!1)}},[me,Z]);const fe=O.activeTab,je=c.useCallback(R=>{!n||fe?.mode!=="diff"||p(n,{mode:"diff",targetPath:fe.targetPath,targetDirectory:fe.targetDirectory,stagedDiff:R==="staged",diffScope:R})},[fe,n,p]),$e=$.isOpen&&$.activeTab?.mode==="browser"?$.activeTab.id:null;c.useEffect(()=>{$e&&n&&V(n,$e)},[n,$e,V]);const{loadedBrowserTabs:Re,sleepingBrowserTabs:Fe}=c.useMemo(()=>{const R=new Set(K),ie=new Set;for(const[qe,Ue]of Object.entries(l))for(const tt of Ue.tabs)tt.mode==="browser"&&tt.ownerSessionId===null&&ie.add(Cn(qe,tt.id));const Ce=cf(K,ie,Y),Ne=[],ze=[];for(const[qe,Ue]of Object.entries(l)){const tt=qe===n;for(const He of Ue.tabs){if(He.mode!=="browser")continue;const Ze=Cn(qe,He.id),Qe=He.ownerSessionId===null,ot=tt&&He.id===$e||(Qe?Ce.has(Ze):R.has(Ze));if(!ot&&!tt&&Qe)continue;const pt={directory:qe,id:He.id,targetPath:He.targetPath,ownerSessionId:He.ownerSessionId};(ot?Ne:ze).push(pt)}}return Ne.sort((qe,Ue)=>Cn(qe.directory,qe.id)<Cn(Ue.directory,Ue.id)?-1:1),{loadedBrowserTabs:Ne,sleepingBrowserTabs:ze}},[l,n,Y,K,$e]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const R=Fe.map(ie=>C0({tabId:ie.id,directory:ie.directory,ownerSessionId:ie.ownerSessionId,describe:()=>({title:"",url:ie.targetPath??""}),wake:()=>V(ie.directory,ie.id)}));return()=>R.forEach(ie=>ie())},[Fe,V]);const Ve=c.useMemo(()=>T.filter(R=>R.mode==="diff"),[T]),De=c.useMemo(()=>T.find(R=>R.mode==="terminal")??null,[T]),ge=c.useMemo(()=>T.find(R=>R.mode==="walkthrough")??null,[T]),xe=c.useMemo(()=>T.filter(R=>_n(R.mode)),[T]),Se=sr(R=>R.guests),Be=c.useMemo(()=>new Set(Se.filter(jg).map(R=>R.id)),[Se]),Pe=c.useMemo(()=>{const R=new Map;for(const ie of Se){const Ce=Cg(ie);Ce&&R.set(ie.id,Ce)}return R},[Se]),Me=z.zone,Je=c.useCallback(R=>{const ie=Qi({mode:"terminal",label:t("layout.mainTab.terminal"),from:Me},R);return{finish:()=>ie.finish(n),cancel:ie.cancel}},[n,t,Me]),X=(R,ie)=>ie?v[R]:null,[Ee,_e]=c.useState(()=>new Set),pe=xe.filter(R=>{if(Ee.has(R.id))return!1;const ie=y(R.mode);return ie.isOpen&&ie.activeTab?.id===R.id});return pe.length>0&&_e(new Set([...Ee,...pe.map(R=>R.id)])),s.jsxs(s.Fragment,{children:[Q?s.jsxs(dn,{zone:E.zone,interactive:C[E.zone],isOpen:E.isOpen,hidden:S(E.zone),className:We("absolute inset-0 flex",w==="left"&&"flex-row-reverse",ne?"flex":"hidden"),children:[i?s.jsx("div",{className:"h-full min-w-0 flex-1",children:s.jsx(_r,{})}):q||!g?s.jsx("div",{className:We("h-full min-w-0 flex-1",q&&!L&&"hidden"),children:q?s.jsx(c.Suspense,{fallback:null,children:s.jsx(P2,{mode:"editor-only",visible:!S(E.zone)&&ne&&L,onCloseFile:W})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(oe,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,i?null:s.jsx(D2,{visible:g,active:E.isOpen&&ne,fill:!L,side:w})]}):null,te&&Z&&Ie?s.jsx(dn,{zone:B.zone,interactive:C[B.zone],isOpen:B.isOpen,hidden:S(B.zone),className:"absolute inset-0 bg-background",children:s.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:Z}),className:"h-full",children:s.jsx(vc,{pinnedSession:Ie,readOnly:te.readOnly})})},te.id):null,Re.map(R=>{const ie=R.directory===n&&$.activeTab?.id===R.id,Ce=R.directory===n?a??R.directory:R.directory;return s.jsx(dn,{zone:$.zone,interactive:C[$.zone],isOpen:$.isOpen,hidden:S($.zone),className:We("absolute inset-0",!ie&&"invisible pointer-events-none"),children:s.jsx("div",{className:"h-full","aria-hidden":!ie||void 0,children:s.jsx(Qc,{paused:!ie,children:R.directory===n&&i?s.jsx(_r,{}):s.jsx(QS,{initialUrl:R.targetPath??"",directory:R.directory,siteDirectory:Ce,tabID:R.id,ownerSessionId:R.ownerSessionId,visible:ie&&$.isOpen},Ce)})})},Cn(R.directory,R.id))}),Ve.map(R=>{const ie=O.activeTab?.id===R.id;return s.jsx(dn,{zone:O.zone,interactive:C[O.zone],isOpen:O.isOpen,hidden:S(O.zone),className:We("absolute inset-0",!ie&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(fn,{value:X(O.zone,ie),children:i&&!R.targetDirectory?s.jsx(_r,{}):s.jsx(I2,{directory:R.targetDirectory??a,visible:O.isOpen&&ie,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:R.diffScope??(R.stagedDiff?"staged":null),onDiffScopeChange:je,targetFilePath:R.targetPath,flushContent:!0})})})},R.id)}),De?s.jsx(dn,{zone:z.zone,interactive:C[z.zone],isOpen:z.isOpen,hidden:S(z.zone),className:We("absolute inset-0",z.activeTab?.mode==="terminal"?"block":"hidden"),children:s.jsx(fn,{value:X(z.zone,z.activeTab?.mode==="terminal"),children:s.jsx(ip.Provider,{value:Je,children:s.jsx(ap,{visible:z.isOpen&&z.activeTab?.mode==="terminal",directory:De.targetDirectory,onLastTabClosed:()=>{n&&f(n,De.id)}})})})}):null,ge?s.jsx(dn,{zone:J.zone,interactive:C[J.zone],isOpen:J.isOpen,hidden:S(J.zone),className:We("absolute inset-0",J.activeTab?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(fn,{value:X(J.zone,J.activeTab?.mode==="walkthrough"),children:s.jsx(E2,{directory:ge.targetDirectory??e,visible:J.isOpen&&J.activeTab?.mode==="walkthrough"})})})}):null,xe.map(R=>{if(!_n(R.mode))return null;const ie=y(R.mode);if(!Ee.has(R.id))return null;const Ce=Ur(R.mode),Ne=Be.has(Ce),ze=Pe.get(Ce),qe=ie.activeTab?.id===R.id,Ue=qe&&ie.isOpen;return Ne&&!ze&&!Ue?null:s.jsx(dn,{zone:ie.zone,interactive:C[ie.zone],isOpen:ie.isOpen,hidden:S(ie.zone),className:We("absolute inset-0",qe?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ne?ze?s.jsxs("div",{className:We("flex h-full",Su[ze.dock].container),children:[s.jsx(R2,{mode:R.mode,docking:ze}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ue?s.jsx(Rl,{mode:R.mode}):null})]}):s.jsx(Rl,{mode:R.mode}):s.jsx(vu,{mode:R.mode})})},R.id)})]})},A2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},O2=()=>{const t=Le.c(20),{t:e}=rt(),n=Gs(M2),r=Gs(F2),o=c.useRef(null),[i,a]=c.useState(!1);let d,u;t[0]!==n?(d=()=>{if(!n){a(!1);return}const w=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(w)},u=[n],t[0]=n,t[1]=d,t[2]=u):(d=t[1],u=t[2]),c.useEffect(d,u);let l,f;if(t[3]!==n?(l=()=>{if(!n)return;const w=j=>{const v=o.current;v&&(v.style.transform=`translate(${j.clientX+12}px, ${j.clientY+12}px)`)};return window.addEventListener("pointermove",w),()=>window.removeEventListener("pointermove",w)},f=[n],t[3]=n,t[4]=l,t[5]=f):(l=t[4],f=t[5]),c.useEffect(l,f),!n)return null;const m=i?"opacity-100":"opacity-0";let p;t[6]!==m?(p=We("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=s.jsx("div",{className:p}),t[8]=p,t[9]=h):h=t[9];let x;t[10]!==n.frames||t[11]!==r||t[12]!==e?(x=Ri.map(w=>{const j=n.frames[w];if(j.width<=0||j.height<=0)return null;const v=r===w;return s.jsx("div",{className:We("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",v?"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:s.jsx("span",{className:"typography-ui-label",children:e(A2[w])})},w)}),t[10]=n.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==n.label?(g=s.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:n.label}),t[14]=n.label,t[15]=g):g=t[15];let b;return t[16]!==h||t[17]!==x||t[18]!==g?(b=Zl.createPortal(s.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,x,g]}),document.body),t[16]=h,t[17]=x,t[18]=g,t[19]=b):b=t[19],b};function M2(t){return t.drag}function F2(t){return t.hovered}const Dl=320,L2=({rowWidth:t,leftWidth:e,rightWidth:n,sidebarWidth:r,opening:o})=>{let i=t-e-n;if(i>=Dl)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Dl)return{collapseSidebar:a,displace:null};const d=o==="left"?"right":"left";return{collapseSidebar:a,displace:(d==="left"?e:n)>0?d:null}},$2=({directoryKey:t,folded:e,readRowWidth:n})=>{const r=b=>{const w=b.contextPanelByDirectory[t];return{left:Gn(w,b.contextSurfaceZones,"left"),right:Gn(w,b.contextSurfaceZones,"right")}},o=(b,w,j)=>{const v=b.contextPanelByDirectory[t];return(j&&v?Wr(v,b.contextSurfaceZones,w):null)?b.contextZoneSizes[w]??Pi:0},i=b=>{const w=b.contextPanelByDirectory[t];return w?Ri.some(j=>tr(w,j).expanded&&df(w,b,j)):!1};let a=null,d=!1,u=r(G.getState()),l=i(G.getState());const f=b=>{e.current=b,G.getState().setSidebarFoldedForExpandedZone(b==="expanded")},m=b=>{d=!0,G.getState().setSidebarOpen(b),d=!1},p=()=>{f(null),G.getState().isSidebarOpen||m(!0)};!e.current&&G.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?l:u[h])&&p(),!e.current&&l&&G.getState().isSidebarOpen&&(f("expanded"),m(!1));const x=(b,w,j)=>{const v=n();if(!v)return;const T=e.current==="expanded",F=L2({rowWidth:T?v-b.sidebarWidth:v,leftWidth:o(b,"left",j.left),rightWidth:o(b,"right",j.right),sidebarWidth:b.isSidebarOpen||T?b.sidebarWidth:null,opening:w});if(F.displace){const _=tr(b.contextPanelByDirectory[t],F.displace).activeTabId;_&&(a={side:F.displace,by:w,tabId:_})}F.collapseSidebar&&(f(w),b.isSidebarOpen&&m(!1)),F.displace&&b.closeContextZone(t,F.displace)},g=b=>{if(a?.side===b){e.current===b&&f(a.by);return}const w=a?.by===b?a:null;w&&(a=null),e.current===b&&(w?f(w.side):p()),w&&G.getState().setActiveContextPanelTab(t,w.tabId)};return G.subscribe((b,w)=>{b.isSidebarOpen!==w.isSidebarOpen&&!d&&f(null);const j=r(b),v=i(b),T=u,F=l;u=j,l=v;const _=["left","right"],A=_.filter(S=>j[S]&&!T[S]),M=_.filter(S=>!j[S]&&T[S]);for(const S of M){const k=S==="left"?"right":"left";A.includes(k)&&(e.current===S&&f(k),a?.by===S&&(a=null))}for(const S of M)g(S);for(const S of A)x(b,S,j);v&&!F&&b.isSidebarOpen?(f("expanded"),m(!1)):!v&&F&&e.current==="expanded"&&p()})},B2=()=>{const t=Le.c(5),e=Zs();let n;t[0]!==e?(n=e?fs(e):"",t[0]=e,t[1]=n):n=t[1];const r=n,o=c.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return $2({directoryKey:r,folded:o,readRowWidth:z2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),c.useEffect(i,a),null};function z2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const W2=t=>{const e=Le.c(54),{open:n,onOpenChange:r}=t,{t:o}=rt(),i=G(U2),a=G(V2),d=G(H2),u=G(q2),l=G(K2),f=Ki(),m=G(Ng);let p;if(e[0]!==i||e[1]!==f||e[2]!==m){let K;e[4]!==m?(K=ee=>m||ee.id!=="workflows",e[4]=m,e[5]=K):K=e[5],p=si(i,f).filter(K),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 K;e[9]!==d?(K=ee=>d.includes(ee.id),e[9]=d,e[10]=K):K=e[10],g=h.every(K),e[6]=d,e[7]=h,e[8]=g}else g=e[8];const b=g,w=c.useRef(!1);let j;e[11]!==d||e[12]!==h||e[13]!==o?(j=h.map((K,ee)=>({id:K.id,label:K.label??o(K.labelKey),visible:!d.includes(K.id),groupStart:ee>0&&Js(h[ee-1])!==Js(K)})),e[11]=d,e[12]=h,e[13]=o,e[14]=j):j=e[14];const v=j;let T;e[15]!==i||e[16]!==f||e[17]!==a?(T=K=>{const ee=si(K,f).map(G2).filter(Y=>K.includes(Y)),V=new Set(ee);a([...ee,...i.filter(Y=>!V.has(Y))])},e[15]=i,e[16]=f,e[17]=a,e[18]=T):T=e[18];const F=T;let _;e[19]!==r?(_=(K,ee)=>{if(!K&&ee.reason==="escape-key"&&w.current){ee.cancel(),ee.allowPropagation();return}w.current=!1,r(K)},e[19]=r,e[20]=_):_=e[20];let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=K=>{w.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(K.key)&&K.preventBaseUIHandler()},e[21]=A):A=e[21];let M;e[22]!==o?(M=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=M):M=e[23];let S;e[24]!==M?(S=s.jsx(ir,{children:M}),e[24]=M,e[25]=S):S=e[25];let k;e[26]!==o?(k=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=k):k=e[27];let C;e[28]!==k?(C=s.jsx(ar,{children:k}),e[28]=k,e[29]=C):C=e[29];let y;e[30]!==C||e[31]!==S?(y=s.jsxs(or,{children:[S,C]}),e[30]=C,e[31]=S,e[32]=y):y=e[32];let E;e[33]!==o?(E=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=K=>{w.current=K},e[35]=B):B=e[35];let $;e[36]!==F||e[37]!==v||e[38]!==u||e[39]!==E?($=s.jsx(cp,{items:v,onVisibleChange:u,onReorder:F,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:E,onDraggingChange:B}),e[36]=F,e[37]=v,e[38]=u,e[39]=E,e[40]=$):$=e[40];let O;e[41]!==x||e[42]!==b||e[43]!==l||e[44]!==o?(O=x?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ft,{variant:"link",size:"xs",onClick:()=>l([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=b,e[43]=l,e[44]=o,e[45]=O):O=e[45];let z;e[46]!==y||e[47]!==$||e[48]!==O?(z=s.jsxs(rr,{className:"max-w-md",onKeyDown:A,children:[y,$,O]}),e[46]=y,e[47]=$,e[48]=O,e[49]=z):z=e[49];let J;return e[50]!==n||e[51]!==z||e[52]!==_?(J=s.jsx(nr,{open:n,onOpenChange:_,children:z}),e[50]=n,e[51]=z,e[52]=_,e[53]=J):J=e[53],J};function U2(t){return t.contextRailOrder}function V2(t){return t.setContextRailOrder}function H2(t){return t.contextRailHiddenSurfaces}function q2(t){return t.setContextRailSurfaceVisible}function K2(t){return t.setContextRailHiddenSurfaces}function G2(t){return t.id}const ku=150,Z2=500,X2=[],Y2=t=>{const e=Le.c(70),{surface:n,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:d,badgeAriaLabel:u,badgeDescription:l,orderNumber:f,showOrderNumber:m,onSelect:p}=t,h=G(ek);let x;e[0]!==h?(x=Ai("switch_context_surface",h),e[0]=h,e[1]=x):x=e[1];const g=x;let b;e[2]!==f||e[3]!==g?(b=g&&g!==kc&&f!=null&&f<=10?ms(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=b):b=e[4];const w=b;let j;e[5]!==n.id?(j={id:n.id},e[5]=n.id,e[6]=j):j=e[6];const{attributes:v,listeners:T,setNodeRef:F,transform:_,transition:A,isDragging:M}=vd(j),S=d!=null&&d>0;let k;e[7]!==_?(k=kd.Translate.toString(_),e[7]=_,e[8]=k):k=e[8];let C;e[9]!==k||e[10]!==A?(C={transform:k,transition:A},e[9]=k,e[10]=A,e[11]=C):C=e[11];const y=M&&"z-10 opacity-70";let E;e[12]!==y?(E=We("relative",y),e[12]=y,e[13]=E):E=e[13];let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{}),e[14]=B):B=e[14];let $;e[15]!==p||e[16]!==n?($=()=>p(n),e[15]=p,e[16]=n,e[17]=$):$=e[17];const O=u??i,z=n.id,J=r?"text-primary":"text-muted-foreground hover:text-foreground";let K;e[18]!==J?(K=We("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",J),e[18]=J,e[19]=K):K=e[19];let ee;e[20]!==n.icon||e[21]!==n.iconSrc||e[22]!==n.id?(ee=n.id==="diff"?s.jsx(wc,{className:"h-[17px] w-[17px]"}):s.jsx(fo,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=n.icon,e[21]=n.iconSrc,e[22]=n.id,e[23]=ee):ee=e[23];let V;e[24]!==S||e[25]!==f||e[26]!==o||e[27]!==m?(V=m&&f!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:f===10?"0":f}):S?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):o?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[24]=S,e[25]=f,e[26]=o,e[27]=m,e[28]=V):V=e[28];let Y;e[29]!==v||e[30]!==r||e[31]!==T||e[32]!==n.id||e[33]!==O||e[34]!==K||e[35]!==ee||e[36]!==V||e[37]!==$?(Y=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...v,...T,onClick:$,"aria-label":O,"aria-pressed":r,"data-context-surface":z,className:K,children:[ee,V]})}),e[29]=v,e[30]=r,e[31]=T,e[32]=n.id,e[33]=O,e[34]=K,e[35]=ee,e[36]=V,e[37]=$,e[38]=Y):Y=e[38];let ae;e[39]!==h||e[40]!==n.id||e[41]!==w?(ae=n.id==="terminal"?ms(Ts("toggle_terminal",h),""):w,e[39]=h,e[40]=n.id,e[41]=w,e[42]=ae):ae=e[42];let P;e[43]!==i||e[44]!==ae?(P=s.jsx(Ks,{label:i,shortcut:ae}),e[43]=i,e[44]=ae,e[45]=P):P=e[45];let de;e[46]!==a?(de=s.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[46]=a,e[47]=de):de=e[47];let q;e[48]!==l?(q=l?s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null,e[48]=l,e[49]=q):q=e[49];let Q;e[50]!==n.id?(Q=n.id==="context"?s.jsx(Nd,{}):null,e[50]=n.id,e[51]=Q):Q=e[51];let L;e[52]!==P||e[53]!==de||e[54]!==q||e[55]!==Q?(L=s.jsx(jt,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[P,de,q,Q]})}),e[52]=P,e[53]=de,e[54]=q,e[55]=Q,e[56]=L):L=e[56];let ne;e[57]!==Y||e[58]!==L?(ne=s.jsx(ao,{render:B,children:s.jsxs(kt,{delayDuration:ku,children:[Y,L]})}),e[57]=Y,e[58]=L,e[59]=ne):ne=e[59];let W;e[60]!==n.mode?(W=s.jsx(lo,{children:s.jsx(bc,{mode:n.mode})}),e[60]=n.mode,e[61]=W):W=e[61];let te;e[62]!==ne||e[63]!==W?(te=s.jsxs(br,{children:[ne,W]}),e[62]=ne,e[63]=W,e[64]=te):te=e[64];let Z;return e[65]!==F||e[66]!==te||e[67]!==C||e[68]!==E?(Z=s.jsx("div",{ref:F,style:C,className:E,children:te}),e[65]=F,e[66]=te,e[67]=C,e[68]=E,e[69]=Z):Z=e[69],Z},J2=t=>{if(!t)return{icon:"ticket-2"};const e=Dg(t,"line");return e?{icon:e}:{icon:_g,iconSrc:Ag(t)}},Q2=()=>{const t=Le.c(122),{t:e}=rt(),n=Zs();let r;t[0]!==n?(r=n?fs(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Oe=>o?Oe.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=G(i),d=G(tk),u=G(sk),l=G(nk),f=G(rk),m=G(ok),p=G(ik),h=G(ak),x=G(lk),g=uf();let b;t[4]!==g?(b=Oe=>g.some(se=>se.instances.defaultInstance!==null&&Oe.entries[Hn({provider:se.id,instance:se.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=b):b=t[5];const w=hn(b),j=hn(dk),v=Eg(o||null),T=Ii(v==="none"?null:v??g[0]?.id),F=v==="none"?"pullRequest":T.terminology.changeRequest,{screenWidth:_}=wn(),A=yr(),M=n??null;let S;t[6]!==A||t[7]!==M?(S=uo(A,M),t[6]=A,t[7]=M,t[8]=S):S=t[8];const k=S,C=Ig(k),y=po(C),{git:E}=Es(),B=Mn(uk),$=Mn(fk);let O,z;t[9]!==B||t[10]!==$||t[11]!==E||t[12]!==C||t[13]!==k?(O=()=>{if(!E||!k||!C||C===k)return;la(()=>B(C,E));const Oe=Yt(k),se=Yt(C);return cr.onGitRefreshHint(ue=>{const et=Yt(ue.directory);et!==Oe&&et!==se||la(()=>$(C,E,{silent:!0}))})},z=[B,$,E,C,k],t[9]=B,t[10]=$,t[11]=E,t[12]=C,t[13]=k,t[14]=O,t[15]=z):(O=t[14],z=t[15]),c.useEffect(O,z);let J;t[16]!==x?(J=Ai("switch_context_surface",x),t[16]=x,t[17]=J):J=t[17];const K=J,[ee,V]=c.useState(!1);let Y,ae;t[18]!==K?(ae=()=>{const Oe=new Set;let se=null,ue=!1;const et=pk,ye=()=>{Aa(K,Oe)?!ue&&se===null&&(se=setTimeout(()=>V(!0),Z2)):(ue=!1,se!==null&&(clearTimeout(se),se=null),V(!1))},bt=Pt=>{if(Oe.add(Pt.key.toLowerCase()),et(Pt.key)&&Aa(K,Oe)){ue=!0,se!==null&&(clearTimeout(se),se=null),V(!1);return}ye()},Tt=Pt=>{Oe.delete(Pt.key.toLowerCase()),ye()},vt=()=>{Oe.clear(),ue=!1,se!==null&&(clearTimeout(se),se=null),V(!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),se!==null&&clearTimeout(se)}},Y=[K],t[18]=K,t[19]=Y,t[20]=ae):(Y=t[19],ae=t[20]),c.useEffect(ae,Y);let P;t[21]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},t[21]=P):P=t[21];let de;t[22]===Symbol.for("react.memo_cache_sentinel")?(de={activationConstraint:{delay:200,tolerance:6}},t[22]=de):de=t[22];const q=xd(Gr(wd,P),Gr(bd,de)),Q=Ki(),L=_a(mk),ne=_a(hk),W=a?.tabs??X2,te=Pg(W,n||null);let Z;t[23]!==h||t[24]!==a?(Z=Ti(a,h),t[23]=h,t[24]=a,t[25]=Z):Z=t[25];const me=Z,Ie=y?.files.length??0;let fe;if(t[26]!==l||t[27]!==u||t[28]!==Q||t[29]!==v||t[30]!==_||t[31]!==j||t[32]!==W||t[33]!==T||t[34]!==te){let Oe;t[36]!==v||t[37]!==T?(Oe=se=>se.id==="pr"?{...se,...J2(v==="none"?null:T)}:se,t[36]=v,t[37]=T,t[38]=Oe):Oe=t[38],fe=Rg({railOrder:u,hiddenSurfaces:l,isVSCode:Ni(),screenWidth:_,tabs:W,sourceControlConnected:j,workflowsShown:te,extras:Q}).map(Oe),t[26]=l,t[27]=u,t[28]=Q,t[29]=v,t[30]=_,t[31]=j,t[32]=W,t[33]=T,t[34]=te,t[35]=fe}else fe=t[35];const je=fe;let $e;t[39]!==W?($e=W.some(gk),t[39]=W,t[40]=$e):$e=t[40];const Re=$e;let Fe,Ve;t[41]!==p||t[42]!==h||t[43]!==w||t[44]!==o||t[45]!==Re||t[46]!==me||t[47]!==j?(Fe=()=>{!o||!w||j||Re||!me.has("pr")||p(o,ei(h,"pr"))},Ve=[p,h,o,w,Re,me,j],t[41]=p,t[42]=h,t[43]=w,t[44]=o,t[45]=Re,t[46]=me,t[47]=j,t[48]=Fe,t[49]=Ve):(Fe=t[48],Ve=t[49]),c.useEffect(Fe,Ve);const[De,ge]=c.useState(!1),xe=c.useRef(null),Se=c.useRef(null);let Be;t[50]!==F||t[51]!==je||t[52]!==e?(Be=Oe=>{const se=je.find(et=>et.id===Oe.active.id),ue=xe.current?.getBoundingClientRect().left;!se||ue===void 0||(Se.current?.cancel(),Se.current=Qi({mode:se.mode,label:se.label??e(Vs(se.labelKey,F)),from:ei(G.getState().contextSurfaceZones,se.mode)},et=>et.x<ue-16))},t[50]=F,t[51]=je,t[52]=e,t[53]=Be):Be=t[53];const Pe=Be;let Me;t[54]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>{Se.current?.cancel(),Se.current=null},t[54]=Me):Me=t[54];const Je=Me;let X,Ee;t[55]===Symbol.for("react.memo_cache_sentinel")?(X=()=>()=>Se.current?.cancel(),Ee=[],t[55]=X,t[56]=Ee):(X=t[55],Ee=t[56]),c.useEffect(X,Ee);let _e;t[57]!==o||t[58]!==Q||t[59]!==f?(_e=Oe=>{const se=Se.current;if(Se.current=null,se?.finish(o))return;const{active:ue,over:et}=Oe;if(!et||ue.id===et.id)return;const ye=si(G.getState().contextRailOrder,Q),bt=Ke=>{const ct=ye.find(Rt=>Rt.id===Ke);return ct?Js(ct):null};if(bt(ue.id)!==bt(et.id))return;const Tt=ye.map(xk),vt=Tt.indexOf(ue.id),Pt=Tt.indexOf(et.id);vt===-1||Pt===-1||f(tx(Tt,vt,Pt))},t[57]=o,t[58]=Q,t[59]=f,t[60]=_e):_e=t[60];const pe=_e;let R;if(t[61]!==je){R=[];for(const Oe of je){const se=R.at(-1);se&&Js(se[0])===Js(Oe)?se.push(Oe):R.push([Oe])}t[61]=je,t[62]=R}else R=t[62];const ie=R;let Ce;t[63]!==je?(Ce=Oe=>{const se=je.find(et=>et.id===Oe.active.id);if(!se)return ii(Oe);const ue=Js(se);return ii({...Oe,droppableContainers:Oe.droppableContainers.filter(et=>{const ye=je.find(bt=>bt.id===et.id);return ye!==void 0&&Js(ye)===ue})})},t[63]=je,t[64]=Ce):Ce=t[64];const Ne=Ce;if(!o)return null;let ze,qe,Ue,tt,He,Ze,Qe,ot,pt,at;if(t[65]!==F||t[66]!==Ie||t[67]!==ne||t[68]!==Ne||t[69]!==o||t[70]!==ie||t[71]!==L||t[72]!==pe||t[73]!==Pe||t[74]!==m||t[75]!==ee||t[76]!==q||t[77]!==me||t[78]!==e||t[79]!==d){let Oe=0;ot=xe,t[90]!==e?(pt=e("contextRail.aria.rail"),t[90]=e,t[91]=pt):pt=t[91],at="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",ze=yd,qe=q,Ue=Ne,tt=Pe,He=Je,Ze=pe,Qe=ie.map((se,ue)=>s.jsxs(c.Fragment,{children:[ue>0?s.jsx("div",{"aria-hidden":"true",className:"h-px w-4 shrink-0 bg-edge-strong"}):null,s.jsx(Sd,{items:se.map(bk),strategy:ex,children:se.map(et=>{Oe=Oe+1;const ye=et.label??e(Vs(et.labelKey,F)),bt=et.id==="git"&&!d?Ie:0,Tt=_n(et.mode)&&!me.has(et.mode)?L[Ur(et.mode)]??0:0,vt=bt>0?bt:Tt>0?Tt:null,Pt=vt!==null&&bt===0;return s.jsx(Y2,{surface:et,isActive:me.has(et.mode),showActivityDot:!1,label:ye,description:e(Vs(et.descriptionKey,F)),badgeCount:vt,badgeAriaLabel:vt!==null?e(Pt?vt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":vt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ye,count:vt}):null,badgeDescription:vt!==null?e(Pt?vt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":vt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:vt}):null,orderNumber:Oe,showOrderNumber:ee,onSelect:Ke=>{_n(Ke.mode)&&ne(Ur(Ke.mode)),m(o,Ke.mode)}},et.id)})})]},Js(se[0]))),t[65]=F,t[66]=Ie,t[67]=ne,t[68]=Ne,t[69]=o,t[70]=ie,t[71]=L,t[72]=pe,t[73]=Pe,t[74]=m,t[75]=ee,t[76]=q,t[77]=me,t[78]=e,t[79]=d,t[80]=ze,t[81]=qe,t[82]=Ue,t[83]=tt,t[84]=He,t[85]=Ze,t[86]=Qe,t[87]=ot,t[88]=pt,t[89]=at}else ze=t[80],qe=t[81],Ue=t[82],tt=t[83],He=t[84],Ze=t[85],Qe=t[86],ot=t[87],pt=t[88],at=t[89];let xt;t[92]!==ze||t[93]!==qe||t[94]!==Ue||t[95]!==tt||t[96]!==He||t[97]!==Ze||t[98]!==Qe?(xt=s.jsx(ze,{sensors:qe,collisionDetection:Ue,onDragStart:tt,onDragCancel:He,onDragEnd:Ze,children:Qe}),t[92]=ze,t[93]=qe,t[94]=Ue,t[95]=tt,t[96]=He,t[97]=Ze,t[98]=Qe,t[99]=xt):xt=t[99];let le;t[100]!==e?(le=e("contextRail.configure.open"),t[100]=e,t[101]=le):le=t[101];let be;t[102]===Symbol.for("react.memo_cache_sentinel")?(be=()=>ge(!0),t[102]=be):be=t[102];let Ae;t[103]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(oe,{name:"equalizer-2",className:"h-[17px] w-[17px]"}),t[103]=Ae):Ae=t[103];let N;t[104]!==le?(N=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":le,onClick:be,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:Ae})}),t[104]=le,t[105]=N):N=t[105];let ce;t[106]!==e?(ce=e("contextRail.configure.open"),t[106]=e,t[107]=ce):ce=t[107];let U;t[108]!==ce?(U=s.jsx(jt,{side:"left",sideOffset:8,children:ce}),t[108]=ce,t[109]=U):U=t[109];let we;t[110]!==N||t[111]!==U?(we=s.jsxs(kt,{delayDuration:ku,children:[N,U]}),t[110]=N,t[111]=U,t[112]=we):we=t[112];let ke;t[113]!==De?(ke=s.jsx(W2,{open:De,onOpenChange:ge}),t[113]=De,t[114]=ke):ke=t[114];let Xe;return t[115]!==ot||t[116]!==pt||t[117]!==at||t[118]!==xt||t[119]!==we||t[120]!==ke?(Xe=s.jsxs("nav",{ref:ot,"aria-label":pt,className:at,children:[xt,we,ke]}),t[115]=ot,t[116]=pt,t[117]=at,t[118]=xt,t[119]=we,t[120]=ke,t[121]=Xe):Xe=t[121],Xe};function ek(t){return t.shortcutOverrides}function tk(t){return t.workStatusPanelVisible}function sk(t){return t.contextRailOrder}function nk(t){return t.contextRailHiddenSurfaces}function rk(t){return t.setContextRailOrder}function ok(t){return t.openContextSurface}function ik(t){return t.closeContextZone}function ak(t){return t.contextSurfaceZones}function lk(t){return t.shortcutOverrides}function ck(t){return t.status?.status==="connected"}function dk(t){return Object.values(t.entries).some(ck)}function uk(t){return t.ensureStatus}function fk(t){return t.fetchStatus}function pk(t){return t.length===1&&t>="0"&&t<="9"}function mk(t){return t.countByGuest}function hk(t){return t.clearBadge}function gk(t){return t.mode==="pr"&&t.targetPath}function xk(t){return t.id}function bk(t){return t.id}const Fs=t=>t?s.jsx("span",{className:"oc-title-rest",children:t}):void 0,Ss=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},wk=()=>{const{t}=rt(),{git:e,sourceControl:n}=Es(),[r,o]=c.useState(!1),[i,a]=c.useState(null),[d,u]=c.useState([]),[l,f]=c.useState(!1),[m,p]=c.useState(!1),[h,x]=c.useState(!1),[g,b]=c.useState(!1),[w,j]=c.useState(new Set),v=st(X=>X.getWorktreeMetadata),T=st(X=>X.setNewSessionDraftTarget),F=st(X=>X.setDraftBootstrapPendingDirectory),_=Mg,A=Bg,M=st(X=>X.deleteSessions),S=st(X=>X.archiveSessions),k=st(X=>X.unarchiveSessions),C=G(X=>X.showDeletionDialog),y=G(X=>X.setShowDeletionDialog),E=Ht(X=>X.currentDirectory),B=Ht(X=>X.homeDirectory),$=ts(X=>X.projects),O=ts(X=>X.activeProjectId),{isMobile:z,isTablet:J,hasTouchInput:K}=wn(),ee=z||J||K,V=c.useMemo(()=>{const Ee=(O?$.find(_e=>_e.id===O)??null:null)?.path??E;return Ss(Ee)},[O,E,$]),Y=c.useCallback(X=>{const _e=Ss(X.projectDirectory)||V;return{id:($.find(R=>Ss(R.path)===_e)??null)?.id??`path:${_e}`,path:_e}},[V,$]),ae=g&&w.size>0,[P,de]=c.useState(!1),q=i?.mode==="worktree"?i.worktree??d[0]?.metadata??null:null,Q=q?.path,L=q?.branch,ne=q?Y(q).path:null;c.useEffect(()=>{if(de(!1),!Q||!ne)return;let X=!1;return Og(ne,{path:Q,branch:L??""}).then(Ee=>{X||de(Ee)}),()=>{X=!0}},[L,Q,ne]);const W=c.useMemo(()=>{if(!P)return!1;const X=i?.worktree;return X&&typeof X.branch=="string"&&X.branch.trim().length>0?!!X.status?.upstream?.split("/")[0]?.trim():d.length>0&&d.every(({metadata:Ee})=>typeof Ee.branch=="string"&&Ee.branch.trim().length>0&&!!Ee.status?.upstream?.split("/")[0]?.trim())},[P,i?.worktree,d]),te=i?.mode==="worktree",Z=h||!te||!W,me=h||!te,Ie=c.useCallback(X=>{a({sessions:X.sessions,dateLabel:X.dateLabel,mode:X.mode??"session",worktree:X.worktree??null})},[]),fe=c.useCallback(()=>{a(null),u([]),f(!1),p(!1),x(!1),b(!1),j(new Set)},[]),je=c.useCallback(async X=>{if(X.sessions.length===0)return;if(X.sessions.length===1){const R=X.sessions[0];await _(R.id)?Te.success(t("sessions.sidebar.session.delete.success")):Te.error(t("sessions.sidebar.session.delete.error"));return}const Ee=X.sessions.map(R=>R.id),{deletedIds:_e,failedIds:pe}=await M(Ee);if(_e.length>0){const R=pe.length>0?pe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:pe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:pe.length}):X.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:X.dateLabel}):void 0;Te.success(_e.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:_e.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:_e.length}),{description:Fs(R)})}pe.length>0&&Te.error(pe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:pe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:pe.length}),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[_,M,t]);c.useEffect(()=>cr.onDirectoryRequest(()=>{o(!0)}),[]),c.useEffect(()=>{if(!i){u([]),f(!1),p(!1),b(!1),j(new Set);return}const X=i.sessions.map(pe=>{const R=v(pe.id);return R?{session:pe,metadata:R}:null}).filter(pe=>!!pe);u(X),f(!1),b(!1),j(new Set);const Ee=new Map;if(i.worktree?.path&&Ee.set(Ss(i.worktree.path),i.worktree),X.forEach(({metadata:pe})=>{pe.path&&Ee.set(Ss(pe.path),pe)}),Ee.size===0){b(!0);return}let _e=!1;return(async()=>{const pe=new Map,R=new Set;await Promise.all(Array.from(Ee.entries()).map(async([ie,Ce])=>{try{const Ne=await Oa(Ce.path);pe.set(ie,Ne),Ne?.isDirty&&R.add(ie)}catch{Ce.status&&(pe.set(ie,Ce.status),Ce.status.isDirty&&R.add(ie))}})).catch(ie=>{console.warn("Failed to inspect worktree status before deletion:",ie)}),!_e&&(j(R),b(!0),a(ie=>{if(!ie?.worktree?.path)return ie;const Ce=Ss(ie.worktree.path),Ne=pe.get(Ce);if(!Ne)return ie;const ze=ie.worktree.status;return ze?.isDirty===Ne.isDirty&&ze?.ahead===Ne.ahead&&ze?.behind===Ne.behind&&ze?.upstream===Ne.upstream?ie:{...ie,worktree:{...ie.worktree,status:Ne}}}),u(ie=>ie.map(Ce=>{const Ne=Ss(Ce.metadata.path),ze=pe.get(Ne);return ze?{session:Ce.session,metadata:{...Ce.metadata,status:ze}}:Ce})))})(),()=>{_e=!0}},[i,v]),c.useEffect(()=>{W||f(!1)},[W]);const $e=c.useCallback(async(X,Ee,_e,pe)=>{const R=l&&W,ie=Y(X),Ce=Ss(X.path),Ne=Ss(ie.path);try{await Fg(ie,X,{deleteRemoteBranch:R,deleteLocalBranch:Ee,remoteName:X.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:n},skipTeardown:pe});const ze=tt=>!!(Ce&&tt&&Lg(Ce,tt)),qe=st.getState().newSessionDraft,Ue=Ss(qe?.directoryOverride);return qe?.open&&ze(Ue)&&Ne&&(F(null),T({projectId:ie.id,directoryOverride:Ne},{force:!0})),ze(Ss(Ht.getState().currentDirectory))&&Ne&&Ht.getState().setDirectory(Ne,{showOverlay:!1}),!0}catch(ze){if(ze instanceof Error&&$g(ze))throw ze;return Te.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:_e,description:Fs(ze instanceof Error?ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[W,l,Y,e,F,T,n,t]),Re=c.useCallback((X,Ee,_e)=>{const pe=l&&W,R=async(ie,Ce)=>{const Ne=Te.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Ma(X)}));Hg(X.path);try{const ze=await qg({sessionIds:Ce,removeWorktree:()=>$e(X,_e,Ne,ie),restoreSessions:Ue=>k(Ue,{undo:!0}),archiveSessions:async Ue=>Ue.length===1?await A(Ue[0])?{archivedIds:Ue,failedIds:[]}:{archivedIds:[],failedIds:Ue}:S(Ue)});if(!ze.removed)return;Ec(Ce,{projectId:Y(X).id}),Te.success(t(pe?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ne,description:Fs(Ma(X))});const{failedIds:qe}=ze.archive;qe.length>0&&Te.error(qe.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:qe.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:qe.length}),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(ze){Te.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ne,description:Fs(ze instanceof Error?ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain")),...ze instanceof Error?Kg(ze,t("sessions.sidebar.sessionDialogs.worktree.deleteWithoutTeardown"),()=>{R(!0,Gg(Ce,X.path))}):void 0})}finally{Zg(X.path)}};return R(!1,Ee)},[A,S,W,l,Y,$e,t,k]),Fe=c.useRef(new Set),Ve=c.useCallback(async(X,Ee)=>{const _e=Ss(X.path);if(!Fe.current.has(_e)){Fe.current.add(_e);try{const pe=await Oa(X.path).catch(()=>{});if(!zg(pe)){Ie({sessions:Ee,mode:"worktree",worktree:X});return}await Re(X,Ee.map(R=>R.id),!0)}finally{Fe.current.delete(_e)}}},[Ie,Re]);c.useEffect(()=>cr.onDeleteRequest(X=>{if(!C&&(X.mode??"session")==="session"){je(X);return}if(X.mode==="worktree"&&X.skipDialogIfSafe&&X.worktree){Ve(X.worktree,X.sessions);return}Ie(X)}),[Ie,C,je,Ve]);const De=c.useCallback(async()=>{if(i){x(!0);try{if(te){const X=i.worktree??d[0]?.metadata;if(!X){Te.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),x(!1);return}Re(X,i.sessions.map(Ee=>Ee.id),m&&P),fe();return}if(i.sessions.length===1){const X=i.sessions[0];if(!await _(X.id)){Te.error(t("sessions.sidebar.session.delete.error")),x(!1);return}Te.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const X=i.sessions.map(pe=>pe.id),{deletedIds:Ee,failedIds:_e}=await M(X);if(Ee.length>0){const pe=_e.length>0?_e.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:_e.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:_e.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;Te.success(Ee.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ee.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ee.length}),{description:Fs(pe),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(_e.length>0&&(Te.error(_e.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:_e.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:_e.length}),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Ee.length===0)){x(!1);return}}fe()}finally{x(!1)}}},[P,i,d,m,_,M,fe,te,Re,t]),ge=i?.worktree??d[0]?.metadata??null;let xe="";if(i?.mode==="worktree"){const X=i.sessions.length;X===0?xe=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):X===1?xe=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:X}):xe=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:X})}else if(i){const X=i.sessions.length;X===1?xe=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):xe=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:X,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:X})}const Se=i?s.jsxs("div",{className:We(te?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&s.jsxs("div",{className:We(te?"oc-tile rounded-lg p-3":"oc-tile space-y-1.5 rounded-lg p-3"),children:[te&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),s.jsxs("ul",{className:We(te?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(X=>s.jsxs("li",{className:We(te?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[s.jsx("span",{className:We(!te&&"hidden"),children:"•"}),s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:X.title||t("sessions.sidebar.session.untitled")})]},X.id)),i.sessions.length>5&&s.jsx("li",{className:We(te?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:i.sessions.length-5})})]})]}),te?s.jsxs("div",{className:"oc-tile space-y-2 rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),ge?.label?s.jsx("span",{className:"typography-micro text-muted-foreground",children:ge.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:ge?Wg(ge.path,B):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),ae&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"oc-tile rounded-lg p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Be=te&&P?W?s.jsxs("button",{type:"button",onClick:()=>{Z||f(X=>!X)},disabled:Z,"aria-pressed":l,className:We("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Z?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[l?s.jsx(oe,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(oe,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,Pe=te&&P?s.jsxs("button",{type:"button",onClick:()=>{me||p(X=>!X)},disabled:me,"aria-pressed":m,className:We("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",me?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[m?s.jsx(oe,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(oe,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Me=te?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Pe,Be]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:fe,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:De,disabled:h,children:t(h?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>y(!C),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":!C,children:[C?s.jsx(oe,{name:"checkbox-blank",className:"size-4"}):s.jsx(oe,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:fe,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:De,disabled:h,children:h?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Je=te?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[ee?s.jsx(Ug,{open:!!i,onClose:()=>{h||fe()},title:Je,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Me}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[xe&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:xe}),Se]})}):s.jsx(nr,{open:!!i,onOpenChange:X=>{if(!X){if(h)return;fe()}},children:s.jsxs(rr,{className:We(te?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(or,{children:[s.jsxs(ir,{className:We(te&&"flex items-center gap-2"),children:[te&&s.jsx(oe,{name:"delete-bin",className:"h-5 w-5"}),Je]}),xe&&s.jsx(ar,{children:xe})]}),te?s.jsx(gs,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:Se}):s.jsx("div",{children:Se}),s.jsx(Hr,{className:"mt-2 gap-2 pt-1 pb-1",children:Me})]})}),s.jsx(Vg,{open:r,onOpenChange:o})]})},ju=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],yk=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,vk=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,Sk=t=>ju.some(({pattern:e})=>e.test(t));async function kk(t,e,n){if(!t)return null;const r=Tk(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=Nk(n);if(o){const i=await Ek(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 jk(t)){const o=await Ck(),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 jk(t){const e=`${t}/index.html`,n=await to(e,t);return typeof n=="string"&&n.trim().length>0}async function Ck(){try{const t=await qs("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Tk(t){for(const e of t){const n=vk.exec(e.command.trim())?.[1];if(n&&Sk(n)||e.source!=="shared"&&yk.test(e.name.trim()))return e}return null}function Nk(t){for(const{pattern:e}of ju)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ek(t){const e=await to(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of n){const i=await to(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function to(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await qs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=nc()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await qs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Ik(t){try{const e=await to(`${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 Pk=/\{(worktree|branch)\}/g,Yo=63,Rk=new Set(["main","master"]),Cu=t=>/\{(worktree|branch)\}/.test(t??""),Dk=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},Tu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Yo)return e;const n=await Dk(e);return n?`${e.slice(0,Yo-7).replace(/-+$/,"")}-${n}`:e.slice(0,Yo).replace(/-+$/,"")},_k=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},Ak=async(t,e,n)=>{const r=n.includes("{branch}"),o=n.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:_k(i.current),linkedWorktree:o}},Ok=async t=>!t.linkedWorktree||!t.branch||Rk.has(t.branch)?"":Tu(t.branch.split("/").pop()??""),Mk=t=>{const e=t.lastIndexOf("@"),n=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",d=i.split(".").map(u=>u.replace(/^-+|-+$/g,"")).filter(Boolean);return`${n}${d.join(".")}${a}`},Fk=async(t,e)=>{const n={worktree:await Ok(e),branch:e.branch?await Tu(e.branch):""},r=t.replace(Pk,(u,l)=>n[l]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",d=""]=o;return`${i}${Mk(a)}${d}`},Lk=async(t,e,n)=>Cu(e)?Fk(e,await Ak(t,n,e)):e,Nu="oc.projectActions.selectedAction.v1",$k=li(Ns(),li(Ns(),Ns())),Eu=()=>{const t=gr().getItem(Nu);if(t===null)return{};try{const e=$k.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},_l=(t,e=Jt())=>Eu()[e]?.[t]??null,Bk=(t,e,n=Jt())=>{const r=Eu();r[n]?.[t]!==e&&gr().setItem(Nu,JSON.stringify({...r,[n]:{...r[n],[t]:e}}))},zk=15e3,Wk=3e3,Uk=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Vk=({projectRef:t,directory:e,allowMobile:n=!1})=>{const{t:r}=rt(),{currentTheme:o}=io(),{terminal:i,runtime:a,git:d}=Es(),u=Zs(),{isMobile:l}=wn(),f=c.useMemo(()=>_s(),[]),m=ja(N=>N.instances),p=ja(N=>N.load),h=G(N=>N.terminalShell),x=G(N=>N.terminalLoginShells.includes(N.terminalShell)),g=G(N=>N.setSettingsPage),b=G(N=>N.setSettingsDialogOpen),w=G(N=>N.setSettingsProjectsSelectedId),j=G(N=>N.openContextPreview),v=yt(N=>N.ensureDirectory),T=yt(N=>N.reconcileServerSessions),F=yt(N=>N.setTabLabel),_=yt(N=>N.setTabIconKey),A=yt(N=>N.setActiveTab),M=yt(N=>N.setConnecting),S=yt(N=>N.setTabSessionId),k=yt(N=>N.setTabPurpose),C=yt(N=>N.allocateActionExecution),y=yt(N=>N.setTabLifecycle),E=yt(N=>N.setTabPreviewUrl),B=yt(N=>N.matchesActionExecution),$=yt(N=>N.captureStartedActionMutationRevisions),[O,z]=c.useState([]),J=c.useRef(null),[K,ee]=c.useState(()=>t?.id?_l(t.id):null),[V,Y]=c.useState(!1),ae=c.useRef({}),P=c.useRef({}),de=c.useRef({}),q=c.useRef(new Set),Q=c.useRef(0),[L,ne]=c.useState({}),W=t?.id??null,te=t?.path??"";c.useEffect(()=>{ee(W?_l(W):null)},[W]);const Z=c.useMemo(()=>W?{id:W,path:te}:null,[W,te]);c.useEffect(()=>{f&&p().catch(()=>{})},[f,p]);const me=c.useCallback(async N=>{await Ln(N)},[]),Ie=c.useCallback(async()=>{if(!Z)return;const N=Q.current+1;Q.current=N,Y(!0);try{const ce=await Fo(Z);if(Q.current!==N)return;J.current=ce;const U=ce.projectActions;z(U)}catch{if(Q.current!==N)return}finally{Q.current===N&&Y(!1)}},[Z]),fe=c.useMemo(()=>_o(e||Z?.path||""),[e,Z?.path]),je=c.useMemo(()=>_o(Z?.path||""),[Z?.path]),$e=c.useMemo(()=>_o(u||"")||fe,[u,fe]),Re=c.useRef($e);c.useEffect(()=>{Re.current=$e},[$e]);const Fe=yt(N=>fe?N.getDirectoryState(fe):void 0),Ve=yt(N=>je&&je!==fe?N.getDirectoryState(je):void 0),De=c.useMemo(()=>{const N=fe?[{directory:fe,state:Fe}]:[];return je&&je!==fe&&N.push({directory:je,state:Ve}),N},[Fe,fe,je,Ve]),ge=c.useMemo(()=>{const N=fe?[fe]:[];return je&&je!==fe&&N.push(je),N},[fe,je]),xe=c.useCallback(N=>N.id!==on&&N.runIn==="parent"&&je||fe,[fe,je]),Se=c.useCallback((N,ce,U)=>`${N}::${ce}::${U}`,[]),Be=c.useCallback((N,ce,U=yt.getState())=>N?U.getDirectoryState(N)?.tabs.find(we=>we.purpose.type==="project-action"&&we.purpose.actionId===ce)??null:null,[]),Pe=c.useMemo(()=>{const N={};for(const{directory:ce,state:U}of De)for(const we of U?.tabs??[]){if(we.purpose.type!=="project-action"||!we.purpose.executionId||!we.terminalSessionId||we.lifecycle==="idle"||we.lifecycle==="exited")continue;const ke=Sn(ce,we.purpose.actionId),Xe=Se(ce,we.purpose.actionId,we.purpose.executionId);N[ke]={directory:ce,actionId:we.purpose.actionId,tabId:we.id,sessionId:we.terminalSessionId,executionId:we.purpose.executionId,status:we.lifecycle==="stopping"?"stopping":L[Xe]?"waiting-for-preview":"running"}}return N},[Se,L,De]),Me=c.useCallback((N,ce,U)=>{const we=Sn(N,ce),ke=Se(N,ce,U),Oe=ae.current[we]?.executionId===U,se=globalThis.window,ue=et=>{se?.clearTimeout(de.current[et]),delete de.current[et]};Oe&&(delete ae.current[we],ue(we)),P.current[ke]?.(),delete P.current[ke],ue(ke),ne(et=>{if(!et[ke])return et;const ye={...et};return delete ye[ke],ye})},[Se]),Je=c.useCallback(N=>{P.current[N]?.(),delete P.current[N]},[]),X=c.useCallback(N=>{window.clearTimeout(de.current[N]),delete de.current[N]},[]);c.useEffect(()=>{const N=P.current,ce=de.current;return()=>{for(const U of Object.keys(N))Je(U);for(const U of Object.keys(ce))X(U)}},[X,Je]),c.useEffect(()=>{const N=new Set(ge);for(const ce of Object.values(ae.current))N.has(ce.directory)||Me(ce.directory,ce.actionId,ce.executionId);for(const ce of Object.keys(P.current)){const U=ce.split("::",1)[0]??"";N.has(U)||Je(ce)}},[Me,Je,ge]);const Ee=c.useCallback((N,ce)=>{G.getState().openContextPanelTab(N,{mode:"terminal",targetDirectory:ce===N?null:ce})},[]),_e=c.useMemo(()=>({id:on,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),pe=!l,R=c.useMemo(()=>pe?[...O,_e]:O,[O,_e,pe]),ie=c.useMemo(()=>K?R.find(N=>N.id===K)??null:null,[R,K]);c.useEffect(()=>{Ie()},[Ie]);const[Ce,Ne]=c.useState(0),ze=c.useCallback(()=>(Ne(N=>N+1),()=>Ne(N=>N-1)),[]),qe=Ce>0;c.useEffect(()=>{if(!qe)return;const N=ge.map(ce=>dp(i,ce,$,U=>T(ce,U.sessions,{startedActionMutationRevisions:U.startedActionMutationRevisions})));return()=>{for(const ce of N)ce()}},[$,qe,T,i,ge]),c.useEffect(()=>{for(const{directory:N,state:ce}of De)if(N)for(const U of ce?.tabs??[]){if(U.purpose.type!=="project-action")continue;const we=U.purpose.actionId,ke=R.find(se=>se.id===we),Xe=ke?.name??we,Oe=ke?.icon||"play";U.label!==Xe&&F(N,U.id,Xe),U.iconKey!==Oe&&_(N,U.id,Oe)}},[R,_,F,De]),c.useEffect(()=>{const N=globalThis.window;if(!N)return;const ce=U=>{const we=U.detail;W&&(we?.projectId&&we.projectId!==W||Ie())};return N.addEventListener(Ca,ce),()=>{N.removeEventListener(Ca,ce)}},[Ie,W]),c.useEffect(()=>{const N=U=>{delete de.current[U];const we=ae.current[U];if(!we||we.openedUrl)return;const ke=Se(we.directory,we.actionId,we.executionId),Xe=we.announced;if(Xe.length!==0){if(window.clearTimeout(de.current[ke]),delete de.current[ke],we.openedUrl=!0,ne(Oe=>{if(!Oe[ke])return Oe;const se={...Oe};return delete se[ke],se}),Xe.length===1){Go(we.directory,[]),E(we.directory,we.tabId,Xe[0],{locked:!1,autoOpened:!0}),j(we.directory,Xe[0]);return}we.offering=!0,Go(we.directory,Xe),G.getState().openContextSurface(we.directory,"browser"),Te.info(r("projectActions.toast.multipleServers"))}},ce=()=>{const U=yt.getState(),we=U.sessions,ke=Pe;for(const[Xe,Oe]of Object.entries(ke)){const ue=we.get(Oe.directory)?.tabs.find(ht=>ht.id===Oe.tabId);if(!ue||ue.terminalSessionId!==Oe.sessionId){Me(Oe.directory,Oe.actionId,Oe.executionId);continue}const et=ae.current[Xe],ye=et?.executionId===Oe.executionId?et:{hostDirectory:Re.current||Oe.directory,directory:Oe.directory,tabId:Oe.tabId,actionId:Oe.actionId,executionId:Oe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};ae.current[Xe]=ye;const bt=R.find(ht=>ht.id===Oe.actionId),Tt=U.getBuffer(Oe.directory,Oe.tabId).chunks;if(!bt||Tt.length===0)continue;const vt=Tt.filter(ht=>ye.lastSeenChunkId===null||ht.id>ye.lastSeenChunkId);if(vt.length===0)continue;const Pt=vt.map(ht=>ht.data).join(""),Ke=`${ye.tail}${Pt}`;for(const ht of gp(Ke))ye.proxiedPorts.includes(ht)||ye.proxiedPorts.push(ht);if(ye.openInPreview&&(!ye.openedUrl||ye.offering)){const ht=xp(Ke,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!Ta()}),Ct=ye.announced.length;for(const Et of ht)ye.announced.includes(Et)||ye.announced.push(Et);const lt=ye.announced.length-Ct;ye.offering&<>0?Go(Oe.directory,ye.announced):!ye.openedUrl&&Ct===0&&ye.announced.length>0&&(window.clearTimeout(de.current[Xe]),de.current[Xe]=window.setTimeout(()=>N(Xe),Wk))}const ct=!ye.openedUrl&&bt.autoOpenUrl===!0&&!ye.openInPreview?bp(Ke,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!Ta()}):null,Rt=vt[vt.length-1]?.id??ye.lastSeenChunkId;if(ye.lastSeenChunkId=Rt,ye.tail=Ke.slice(-512),ct)if(ye.openedUrl=!0,ye.openInPreview){const ht=ke[Xe];ht&&(E(ht.directory,ht.tabId,ct,{locked:!1,autoOpened:!1,expectedExecutionId:ht.executionId}),ht.status==="waiting-for-preview"&&ne(Ct=>{const lt=Se(ht.directory,ht.actionId,ht.executionId);if(!Ct[lt])return Ct;const Et={...Ct};return delete Et[lt],Et}),window.clearTimeout(de.current[Xe]),delete de.current[Xe],j(ht.directory,ct))}else me(ct),Te.success(r("projectActions.toast.openedUrlFromOutput"));ae.current[Xe]=ye}for(const Xe of Object.keys(ae.current))if(!ke[Xe]){const Oe=ae.current[Xe],se=Oe?we.get(Oe.directory)?.tabs.find(et=>et.id===Oe.tabId):void 0;if(se?.purpose.type==="project-action"&&se.purpose.executionId===Oe?.executionId&&!!se.terminalSessionId&&se.lifecycle!=="idle"&&se.lifecycle!=="exited")continue;delete ae.current[Xe],window.clearTimeout(de.current[Xe]),delete de.current[Xe]}};return ce(),yt.subscribe((U,we)=>{(U.sessions!==we.sessions||U.buffers!==we.buffers)&&ce()})},[Me,Re,R,Se,j,me,Pe,E,r]),c.useEffect(()=>{for(const{directory:N,state:ce}of De)for(const U of ce?.tabs??[]){if(U.purpose.type!=="project-action"||!U.purpose.executionId||!U.terminalSessionId||U.lifecycle!=="running")continue;const we=U.purpose.actionId,ke=U.purpose.executionId,Xe=Se(N,we,ke);if(P.current[Xe])continue;const Oe=i.connect(U.terminalSessionId,{onEvent:se=>{if(!B(N,U.id,ke))return;se.type==="snapshot"&&(yt.getState().replaceBuffer(N,U.id,se.data??"",se.sequence??0,ca(se)),se.status==="running"&&yt.getState().setTabLifecycle(N,U.id,"running",{expectedExecutionId:ke}),se.status==="exited"&&(yt.getState().setTabLifecycle(N,U.id,"exited",{expectedExecutionId:ke}),yt.getState().setTabPurpose(N,U.id,{type:"project-action",actionId:we,executionId:null}),Me(N,we,ke)));const ue=se.type==="data"?se.data??"":"";ue&&yt.getState().appendToBuffer(N,U.id,ue,se.sequence,se.replayData),se.type==="exit"&&(yt.getState().setTabLifecycle(N,U.id,"exited",{expectedExecutionId:ke}),yt.getState().setTabPurpose(N,U.id,{type:"project-action",actionId:we,executionId:null}),Me(N,we,ke))},onError:(se,ue)=>{!ue||!B(N,U.id,ke)||(yt.getState().setTabLifecycle(N,U.id,"exited",{expectedExecutionId:ke}),yt.getState().setTabSessionId(N,U.id,null,{expectedExecutionId:ke}),yt.getState().setTabPurpose(N,U.id,{type:"project-action",actionId:we,executionId:null}),Me(N,we,ke))}},N);P.current[Xe]=Oe.close}},[Me,Se,B,i,De]);const Ue=c.useCallback(async N=>{const ce=xe(N);if(!ce)throw new Error(r("projectActions.error.noActiveDirectory"));const U=Sn(ce,N.id);v(ce);const we=yt.getState(),ke=Be(ce,N.id,we),Xe=ke?.id??we.createTab(ce);F(ce,Xe,N.name),_(ce,Xe,N.icon||"play"),ke||k(ce,Xe,{type:"project-action",actionId:N.id,executionId:null}),A(ce,Xe);const se=yt.getState().getDirectoryState(ce)?.tabs.find(ue=>ue.id===Xe);return{executionDirectory:ce,key:U,tabId:Xe,sessionId:se?.terminalSessionId??null,executionId:se?.purpose.type==="project-action"?se.purpose.executionId:null}},[v,xe,Be,A,_,F,k,r]),tt=c.useCallback(async N=>{if(a.isVSCode||!n&&l)return;if(!fe){Te.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ce=Sn(xe(N),N.id),U=Pe[ce];if(U&&U.status==="running"||q.current.has(ce))return;q.current.add(ce);let we=null;try{const ke=N.id===on?await(async()=>{const dt=Z??{id:"",path:fe},[ut,Ot]=await Promise.all([Fo(dt),Ik(fe)]),Zt=await kk(fe,ut.projectActions,Ot);if(!Zt)throw new Error(r("contextPanel.preview.noDevServer"));return ut.projectActions.find(as=>as.id===Zt.actionId)?.source==="shared"&&!await Fa(dt,ut)?null:{id:on,name:r("projectActions.actions.autoDiscover"),command:Zt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Zt.previewUrlHint||""}})():N;if(!ke)return;const Xe=ke.autoOpenUrl===!0&&(ke.openUrl||"").trim().length>0,Oe=!Xe&&N.id!==on,se=Re.current||fe,{executionDirectory:ue,key:et,tabId:ye}=await Ue(ke),bt=up(ke.command);if(!bt)throw new Error(r("projectActions.error.failedToRunAction"));const Tt=ke.autoOpenUrl===!0&&f&&(ke.desktopOpenSshForward||"").trim().length>0,vt=ke.autoOpenUrl&&ke.openUrl||"";let Pt=!1;const Ke=Cu(vt)?await Lk(d,vt,ue).catch(()=>(Pt=!0,"")):vt,ct=ke.autoOpenUrl?Uk(Ke):null,Rt=ke.autoOpenUrl&&f?fp(ke.desktopOpenSshForward,m):null;if(i.listSessions){const dt=Be(ue,ke.id);if(dt?.purpose.type==="project-action"&&dt.purpose.executionId===null){const ut=await pp(i,ue,{captureStartedActionMutationRevisions:$});ut&&T(ue,ut.sessions,{startedActionMutationRevisions:ut.startedActionMutationRevisions})}}const ht=Be(ue,ke.id);let Ct,lt;if(ht?.lifecycle==="running"&&ht.terminalSessionId&&ht.purpose.type==="project-action"&&ht.purpose.executionId)Ct=ht.terminalSessionId,lt=ht.purpose.executionId;else{const dt=ht?.purpose.type==="project-action"?ht.purpose.executionId:null;dt&&Me(ue,ke.id,dt);const ut=C(ue,ye,ke.id);if(!ut)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));we={directory:ue,tabId:ye,id:ut},M(ue,ye,!0,{expectedExecutionId:ut});const Ot=await mp({terminal:i,createOptions:{cwd:ue,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:()=>B(ue,ye,ut),purpose:{type:"project-action",actionId:ke.id,executionId:ut}});if(!B(ue,ye,ut)){Ot.sessionId===ut&&await i.close(Ot.sessionId).catch(()=>{});return}lt=Ot.purpose?.type==="project-action"?Ot.purpose.executionId:ut,Ct=Ot.sessionId,k(ue,ye,{type:"project-action",actionId:ke.id,executionId:lt}),S(ue,ye,Ct,{expectedExecutionId:lt}),M(ue,ye,!1,{expectedExecutionId:lt})}Oe&&se&&Ee(se,ue),ae.current[et]={hostDirectory:se,directory:ue,tabId:ye,actionId:ke.id,executionId:lt,lastSeenChunkId:null,openedUrl:!!Rt||!!ct||Xe,tail:"",openInPreview:ke.id===on,announced:[],offering:!1,proxiedPorts:[]};const Et=Se(ue,ke.id,lt);M(ue,ye,!0,{expectedExecutionId:lt});const qt=i.connect(Ct,{onEvent:dt=>{if(!B(ue,ye,lt)||dt.purpose?.type==="project-action"&&dt.purpose.executionId!==lt)return;dt.type==="snapshot"&&(yt.getState().replaceBuffer(ue,ye,dt.data??"",dt.sequence??0,ca(dt)),yt.getState().setConnecting(ue,ye,!1,{expectedExecutionId:lt}),dt.purpose?.type==="project-action"&&yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:dt.purpose.actionId,executionId:dt.purpose.executionId}),dt.status==="running"&&yt.getState().setTabLifecycle(ue,ye,"running",{expectedExecutionId:lt}),dt.status==="exited"&&(yt.getState().setTabLifecycle(ue,ye,"exited",{expectedExecutionId:lt}),yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:ke.id,executionId:null}),Me(ue,ke.id,lt)));const ut=dt.type==="data"?dt.data??"":"";ut&&yt.getState().appendToBuffer(ue,ye,ut,dt.sequence,dt.replayData),dt.type==="exit"&&(yt.getState().setTabLifecycle(ue,ye,"exited",{expectedExecutionId:lt}),yt.getState().setConnecting(ue,ye,!1,{expectedExecutionId:lt}),yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:ke.id,executionId:null}),Me(ue,ke.id,lt))},onError:(dt,ut)=>{B(ue,ye,lt)&&(yt.getState().setConnecting(ue,ye,!1,{expectedExecutionId:lt}),ut&&(yt.getState().setTabLifecycle(ue,ye,"exited",{expectedExecutionId:lt}),yt.getState().setTabSessionId(ue,ye,null,{expectedExecutionId:lt}),yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:ke.id,executionId:null}),Me(ue,ke.id,lt)))}},ue);if(!B(ue,ye,lt)){qt.close();return}P.current[Et]?.(),P.current[Et]=qt.close,window.clearTimeout(de.current[Et]),delete de.current[Et],ke.id===on&&!ct&&(ne(dt=>({...dt,[Et]:!0})),de.current[Et]=window.setTimeout(()=>{delete de.current[Et];const dt=ae.current[et];!dt||dt.executionId!==lt||dt.openedUrl||dt.offering||B(ue,ye,lt)&&(ne(ut=>{if(!ut[Et])return ut;const Ot={...ut};return delete Ot[Et],Ot}),yt.getState().setActiveTab(ue,ye),Ee(dt.hostDirectory,ue))},zk)),Rt?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),me(Rt),Te.success(r("projectActions.toast.openedForwardedUrl"))):ct?(E(ue,ye,ct,{locked:!0,autoOpened:!0,expectedExecutionId:lt}),j(se,ct),Te.success(r("projectActions.toast.openedActionUrl"))):Pt?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),Te.error(r("projectActions.error.openUrlTemplateUnresolved"))):Xe?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),Te.error(r("projectActions.error.invalidCustomUrlFormat"))):Tt?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),Te.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):E(ue,ye,null,{locked:!1,autoOpened:!1,expectedExecutionId:lt})}catch(ke){if(we&&B(we.directory,we.tabId,we.id)){const{directory:Xe,tabId:Oe,id:se}=we;Me(Xe,N.id,se),y(Xe,Oe,"exited",{expectedExecutionId:se}),k(Xe,Oe,{type:"project-action",actionId:N.id,executionId:null})}if(ke instanceof Error&&ke.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(ke instanceof Error&&(ke.message==="COMMAND_MODE_UNSUPPORTED"||ke.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Te.error(r("projectActions.error.failedToCreateTerminalSession"));return}Te.error(ke instanceof Error?ke.message:r("projectActions.error.failedToRunAction"))}finally{q.current.delete(ce)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Re,m,Ue,d,n,l,f,fe,x,h,me,j,Pe,Ee,a.isVSCode,xe,B,Me,Se,Be,T,C,$,M,y,k,E,S,Z,r,i]),He=c.useCallback(async N=>{const ce=Sn(xe(N),N.id),U=Pe[ce];U&&await hp({terminal:i,sessionId:U.sessionId,isExecutionStillCurrent:()=>B(U.directory,U.tabId,U.executionId),markStopping:()=>{y(U.directory,U.tabId,"stopping",{expectedExecutionId:U.executionId})},restoreRunning:()=>{y(U.directory,U.tabId,"running",{expectedExecutionId:U.executionId})},clearSession:()=>{S(U.directory,U.tabId,null,{expectedExecutionId:U.executionId})},finalizeExit:()=>{y(U.directory,U.tabId,"exited",{expectedExecutionId:U.executionId}),k(U.directory,U.tabId,{type:"project-action",actionId:U.actionId,executionId:null}),Me(U.directory,U.actionId,U.executionId)}})},[Me,xe,B,Pe,y,k,S,i]),Ze=c.useCallback(async N=>{if(N.source==="shared"&&Z){const ce=J.current?.trust.trusted?J.current:await Fo(Z);if(J.current=ce,!await Fa(Z,ce))return;J.current={...ce,trust:{...ce.trust,trusted:!0}}}await tt(N)},[tt,Z]),Qe=c.useCallback(N=>Pe[Sn(xe(N),N.id)]??null,[xe,Pe]),ot=(ie&&Qe(ie)?ie:null)??R.find(N=>Qe(N)!==null)??ie??R[0]??null,pt=c.useCallback(N=>{const ce=Qe(N);if(ce?.status!=="stopping"){if(ce){He(N);return}Ze(N)}},[Ze,Qe,He]),at=c.useCallback(N=>{Ze(N)},[Ze]),xt=c.useCallback(N=>{He(N)},[He]),le=c.useCallback(N=>{ee(N.id),W&&Bk(W,N.id)},[W]),be=c.useCallback(()=>{Z?.id&&(w(Z.id),g("projects"),b(!0))},[b,g,w,Z?.id]),Ae=!a.isVSCode&&(n||!l)&&!!Z&&!!fe;return c.useMemo(()=>({available:Ae,actions:Ae?R:[],shown:Ae?ot:null,isLoading:V,observe:ze,runOf:Qe,select:le,run:at,stop:xt,toggle:pt,openSettings:be}),[Ae,R,V,ze,be,at,Qe,le,ot,xt,pt])},Hk=t=>{const e=Le.c(6);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const o=Vk(r);let i;return e[3]!==n||e[4]!==o?(i=s.jsx(Ed.Provider,{value:o,children:n}),e[3]=n,e[4]=o,e[5]=i):i=e[5],i},qk=t=>{const e=Le.c(4),{children:n}=t,r=Pd(),o=yr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let d;return e[0]!==n||e[1]!==a||e[2]!==i?(d=s.jsx(Hk,{projectRef:i,directory:a,children:n}),e[0]=n,e[1]=a,e[2]=i,e[3]=d):d=e[3],d},Kk=2e4,Gk=14400*1e3,Zk=t=>Object.entries(t).map(([e,n])=>`${e}@${n.version}`).sort().join(","),Xk="openchamber.guests.announcedUpdates",Yk=()=>{const{t}=rt(),e=c.useRef(t);e.current=t,c.useEffect(()=>{let n=!1;const r=async()=>{const a=Jt();await td();const d=await wp(!1);if(n||!d.ok||Jt()!==a)return;const u=sr.getState();u.applyUpdates(d.updates,u.runtimeKey);const l=sr.getState().guests.filter(g=>d.updates[g.id]),f=Zk(d.updates),m=gr(),p=`${Xk}:${a}`;if(l.length===0||m.getItem(p)===f)return;m.setItem(p,f);const h=e.current,[x]=l;Te.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=G.getState();g.setSettingsPage("extensions"),g.setSettingsDialogOpen(!0)}}})};let o;const i=window.setTimeout(()=>{r(),o=window.setInterval(()=>{r()},Gk)},Kk);return()=>{n=!0,window.clearTimeout(i),window.clearInterval(o)}},[])},Jk=()=>{cr.requestDirectoryDialog()},Qk=()=>{G.getState().setNewWorktreeDialogOpen(!0)},ej=()=>{const t=Ht.getState().currentDirectory;if(!t)return!1;G.getState().openContextOverview(t)},tj=()=>{nd()},sj=()=>{if(!G.getState().overviewFeatureAvailable)return!1;G.getState().setOverviewOpen(!0)},nj=()=>{window.location.reload()},rj=()=>{const t=G.getState();t.setSessionSwitcherOpen(!1),t.setArchivePageOpen(!0)},Iu=t=>{const e=Ht.getState().currentDirectory;if(!e)return!1;const n=G.getState();return n.setProjectContextTab(t),n.openContextSurface(e,"notes"),!0},oj=()=>Iu("notes"),ij=()=>Iu("todos"),aj=t=>()=>{yp(t)},lj=t=>()=>{const e=st.getState().currentSessionId,n=Ht.getState().currentDirectory;if(!e||!n)return!1;const r=sd(go.getState().ids,n,e)?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";vp({directory:n,sessionId:e}).catch(()=>Te.error(t(r)))},cj=t=>()=>{const e=st.getState().currentSessionId;if(!e)return!1;wr(e).then(n=>{if(n.ok){Te.success(t("sessions.sidebar.session.copyId.success"));return}Te.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Te.error(t("sessions.sidebar.session.copyId.error")))},dj=t=>()=>{if(!G.getState().sessionWorkEnabled)return!1;const e=st.getState().currentSessionId;if(!e)return!1;const n=ps.getState().activeSessions.find(i=>i.id===e);if(!n||n.parentID)return!1;const r=Hs(n)??Ht.getState().currentDirectory;if(!r||mr(r))return!1;const o=Oi(n)?"done":"open";Nc(e,r,o).catch(()=>Te.error(t("sessions.sidebar.session.work.updateFailed")))},uj=()=>{G.getState().setSessionSwitcherOpen(!1),Xg()};function fj(){const t=Le.c(13),{t:e}=rt();let n;t[0]!==e?(n=aj(e),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=lj(e),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=cj(e),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=dj(e),t[6]=e,t[7]=i):i=t[7];let a;t[8]!==n||t[9]!==r||t[10]!==o||t[11]!==i?(a={open_new_worktree_dialog:Qk,add_project:Jk,show_context_usage:ej,show_opencode_status:tj,open_overview:sj,reload_ui:nj,open_archive:rj,open_notes:oj,open_todos:ij,restart_opencode:n,pin_current_session:r,copy_current_session_id:o,toggle_work_current_session:i,open_multi_run:uj},t[8]=n,t[9]=r,t[10]=o,t[11]=i,t[12]=a):a=t[12],Dc(a)}function pj(t){const e=[],n=(r,o)=>{const i=Yt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const mj=new Map,hj=[],gj=t=>{const e=Le.c(20),{isVSCode:n}=t,r=Zc(),o=ts(xj),i=Ht(bj),a=st(wj);let d;e[0]!==n?(d=A=>n?mj:A.availableWorktreesByProject,e[0]=n,e[1]=d):d=e[1];const u=st(d),l=!n;let f;e[2]!==u||e[3]!==o||e[4]!==l?(f=Sp(o,u,{includeWorktrees:l}),e[2]=u,e[3]=o,e[4]=l,e[5]=f):f=e[5];const m=f,p=ps(yj),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,pj({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 b=c.useRef(null);let w,j;e[12]!==n||e[13]!==m?(w=()=>{const A=new Set(m),M=b.current;b.current=A;const S=M?[...A].filter(k=>!M.has(k)):n?[...A]:[];S.length&&rd(S,ni())},j=[n,m],e[12]=n,e[13]=m,e[14]=w,e[15]=j):(w=e[14],j=e[15]),c.useEffect(w,j);let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[16]=v):v=e[16],c.useEffect(vj,v);const T=p!=null,F=p??hj;let _;e[17]!==F||e[18]!==T?(_={enabled:!0,hasAuthoritativeGlobalSessions:T,sessions:F},e[17]=F,e[18]=T,e[19]=_):_=e[19],kp(_)};function xj(t){return t.projects}function bj(t){return t.currentDirectory}function wj(t){return t.currentSessionDirectory}function yj(t){return t.authoritativeSessions}function vj(){let t=null,e=!1;const n=new Set,r=tn(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")n.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Yg(ni());return}const i=[...n];n.clear(),i.length&&rd(i,ni())},500)});return()=>{t&&clearTimeout(t),r()}}const Sj=()=>Lt(()=>import("./SettingsWindow-BVEVntuV.js"),__vite__mapDeps([242,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,243,181,182,183,244,245,222,223,224,225,232,201,188,189,202,246,247,212,231,217,248,249,250,251])).then(t=>t.SettingsWindow),kj=()=>Lt(()=>import("./CommandPalette-DHk0MqYi.js"),__vite__mapDeps([252,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,250,211,181,182,183,209,210,212])).then(t=>t.CommandPalette),jj=()=>Lt(()=>import("./HelpDialog-BZtzVj6Z.js"),__vite__mapDeps([253,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.HelpDialog),Cj=()=>Lt(()=>import("./ProjectActionsDialog-ByPMdwFG.js"),__vite__mapDeps([254,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,209,210,211,212])).then(t=>t.ProjectActionsDialog),Tj=()=>Lt(()=>import("./OpenCodeStatusDialog-9WRgjgWL.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])).then(t=>t.OpenCodeStatusDialog),Nj=()=>Lt(()=>import("./RunOverview-uFEfusCK.js"),__vite__mapDeps([256,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.RunOverview),Ej=()=>Lt(()=>import("./ScheduledTasksDialog-J8i_b433.js"),__vite__mapDeps([257,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,240,258,259,237])).then(t=>t.ScheduledTasksDialog),Ij=()=>Lt(()=>import("./ArchiveView-DvLmQllR.js"),__vite__mapDeps([260,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,261])).then(t=>t.ArchiveView),Pj=()=>Lt(()=>import("./IntegrationsCatalogView-DJAOTlcc.js"),__vite__mapDeps([262,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,244])).then(t=>t.IntegrationsCatalogView),Rj=()=>Lt(()=>import("./UsageStatsView-CMf29PeL.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])).then(t=>t.UsageStatsView),Dj=()=>Lt(()=>import("./SourceBoardView-BW1OSOo1.js"),__vite__mapDeps([264,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,251])).then(t=>t.SourceBoardView),_j=()=>Lt(()=>import("./OverviewView-BzA9rGEs.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,181,182,183])).then(t=>t.OverviewView),Aj=()=>Lt(()=>import("./WorktreesView-jHcQwWBH.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,261])).then(t=>t.WorktreesView),Oj=()=>Lt(()=>import("./SpacesView-BgncMV45.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,248,181,182,183])).then(t=>t.SpacesView),Mj=()=>Lt(()=>import("./SpaceAccessDialog-6GhzlMD8.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,269])).then(t=>t.SpaceAccessDialog),Fj=()=>Lt(()=>import("./SpaceApplyDialog-zB4jAExK.js"),__vite__mapDeps([270,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),Lj=()=>Lt(()=>import("./SpaceSetupOutput-6GuKiRed.js"),__vite__mapDeps([271,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,269])).then(t=>t.SpaceSetupOutputDialog),Ls=()=>G.getState().closeMainSurfaces(),os=t=>{const e=Le.c(2),{needed:n,load:r,onFailure:o}=t,i=xo(n,r,o);let a;return e[0]!==i?(a=i?s.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},Pu=c.memo(t=>{const e=Le.c(11),{isMobile:n}=t,r=G(Bj),o=!r&&!n,i=co();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=Gb(a);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Wb,{}),e[3]=u):u=e[3];const l=r||d.state!==!1;let f;e[4]!==l?(f=s.jsx(jp,{isVisible:l}),e[4]=l,e[5]=f):f=e[5];let m;return e[6]!==n||e[7]!==r||e[8]!==d||e[9]!==f?(m=s.jsx(zb,{isOpen:r,isMobile:n,className:"border-border",topBar:u,peek:d,children:f}),e[6]=n,e[7]=r,e[8]=d,e[9]=f,e[10]=m):m=e[10],m});Pu.displayName="LeftSidebar";const $j=()=>{const t=Le.c(111);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],gj(e),fj(),Cp();const n=G(zj),r=G(Wj),o=G(Uj),i=G(Vj);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const d=xo(o,Sj,a),u=G(Hj),l=G(qj),f=G(Kj),m=G(Gj),p=G(Zj),h=G(Xj),x=G(Yj),g=G(Jj),b=G(Qj),w=G(e3),j=G(t3),v=G(s3),T=G(n3),F=pn(r3),_=pn(o3),A=pn(i3),M=G(a3),S=Jg();let k;if(t[3]!==S||t[4]!==M){let at;t[6]!==M?(at=xt=>xt.id===M,t[6]=M,t[7]=at):at=t[7],k=S.find(at),t[3]=S,t[4]=M,t[5]=k}else k=t[5];const C=k;let y,E;t[8]!==C||t[9]!==M?(y=()=>{M&&!C&&G.getState().setOpenGuestPage(null)},E=[M,C],t[8]=C,t[9]=M,t[10]=y,t[11]=E):(y=t[10],E=t[11]),c.useEffect(y,E);let B;t[12]===Symbol.for("react.memo_cache_sentinel")?(B=[],t[12]=B):B=t[12],c.useEffect(c3,B);let $;t[13]===Symbol.for("react.memo_cache_sentinel")?($=[],t[13]=$):$=t[13],c.useEffect(d3,$);const O=l||f||m||p||h||x||!!g||b||u||!!C;let z,J;t[14]!==O?(z=()=>{od(O)},J=[O],t[14]=O,t[15]=z,t[16]=J):(z=t[15],J=t[16]),c.useLayoutEffect(z,J);let K;t[17]===Symbol.for("react.memo_cache_sentinel")?(K=[],t[17]=K):K=t[17],c.useEffect(f3,K);let ee;t[18]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[18]=ee):ee=t[18],c.useEffect(m3,ee);const{isMobile:V}=wn();Tp(),Yk();let Y,ae;t[19]!==V||t[20]!==r?(Y=()=>{G.getState().isMobile!==V&&r(V)},ae=[V,r],t[19]=V,t[20]=r,t[21]=Y,t[22]=ae):(Y=t[21],ae=t[22]),c.useEffect(Y,ae);let P;t[23]!==w?(P=s.jsx(os,{needed:w,load:kj,onFailure:h3}),t[23]=w,t[24]=P):P=t[24];let de;t[25]!==j?(de=s.jsx(os,{needed:j,load:jj,onFailure:g3}),t[25]=j,t[26]=de):de=t[26];let q;t[27]!==v?(q=s.jsx(os,{needed:v,load:Cj,onFailure:x3}),t[27]=v,t[28]=q):q=t[28];let Q;t[29]!==T?(Q=s.jsx(os,{needed:T,load:Tj,onFailure:b3}),t[29]=T,t[30]=Q):Q=t[30];let L,ne;t[31]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(Ep,{}),ne=s.jsx(wk,{}),t[31]=L,t[32]=ne):(L=t[31],ne=t[32]);let W;t[33]!==F||t[34]!==_||t[35]!==A||t[36]!==n?(W=n?s.jsxs(s.Fragment,{children:[s.jsx(os,{needed:F,load:Mj,onFailure:w3}),s.jsx(Ip,{}),s.jsx(os,{needed:_,load:Fj,onFailure:y3}),s.jsx(Pp,{}),s.jsx(os,{needed:A,load:Lj,onFailure:v3})]}):null,t[33]=F,t[34]=_,t[35]=A,t[36]=n,t[37]=W):W=t[37];let te;t[38]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Zb,{}),t[38]=te):te=t[38];let Z;t[39]!==V?(Z=s.jsx(Pu,{isMobile:V}),t[39]=V,t[40]=Z):Z=t[40];let me;t[41]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Bb,{}),t[41]=me):me=t[41];let Ie;t[42]===Symbol.for("react.memo_cache_sentinel")?(Ie=s.jsx(Ko,{zone:"left"}),t[42]=Ie):Ie=t[42];const fe=O&&"invisible";let je;t[43]!==fe?(je=We("absolute inset-0",fe),t[43]=fe,t[44]=je):je=t[44];const $e=!o&&!O;let Re;t[45]!==$e?(Re=s.jsx(Qt,{children:s.jsx(vc,{active:$e})}),t[45]=$e,t[46]=Re):Re=t[46];let Fe;t[47]!==je||t[48]!==Re?(Fe=s.jsx("div",{className:je,children:Re}),t[47]=je,t[48]=Re,t[49]=Fe):Fe=t[49];let Ve;t[50]!==u?(Ve=s.jsx(Qt,{children:s.jsx(os,{needed:u,load:Nj,onFailure:Ls})}),t[50]=u,t[51]=Ve):Ve=t[51];let De;t[52]!==l?(De=s.jsx(Qt,{children:s.jsx(os,{needed:l,load:Ej,onFailure:Ls})}),t[52]=l,t[53]=De):De=t[53];let ge;t[54]!==f?(ge=s.jsx(Qt,{children:s.jsx(os,{needed:f,load:Ij,onFailure:Ls})}),t[54]=f,t[55]=ge):ge=t[55];let xe;t[56]!==m?(xe=s.jsx(Qt,{children:s.jsx(os,{needed:m,load:Pj,onFailure:Ls})}),t[56]=m,t[57]=xe):xe=t[57];let Se;t[58]!==p?(Se=p&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Rj,onFailure:Ls})})}),t[58]=p,t[59]=Se):Se=t[59];let Be;t[60]!==h?(Be=s.jsx(os,{needed:h,load:Dj,onFailure:Ls}),t[60]=h,t[61]=Be):Be=t[61];let Pe;t[62]!==x?(Pe=s.jsx(Qt,{children:s.jsx(os,{needed:x,load:_j,onFailure:Ls})}),t[62]=x,t[63]=Pe):Pe=t[63];const Me=!!g;let Je;t[64]!==Me?(Je=s.jsx(Qt,{children:s.jsx(os,{needed:Me,load:Aj,onFailure:Ls})}),t[64]=Me,t[65]=Je):Je=t[65];let X;t[66]!==b?(X=b?s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Oj,onFailure:Ls})}):null,t[66]=b,t[67]=X):X=t[67];let Ee;t[68]!==C?(Ee=C&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(Qg,{mode:`plugin:${C.id}`,surface:"page",item:null,onDismiss:S3})})}),t[68]=C,t[69]=Ee):Ee=t[69];let _e;t[70]!==Fe||t[71]!==Ve||t[72]!==De||t[73]!==ge||t[74]!==xe||t[75]!==Se||t[76]!==Be||t[77]!==Pe||t[78]!==Je||t[79]!==X||t[80]!==Ee?(_e=s.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[Fe,Ve,De,ge,xe,Se,Be,Pe,Je,X,Ee]}),t[70]=Fe,t[71]=Ve,t[72]=De,t[73]=ge,t[74]=xe,t[75]=Se,t[76]=Be,t[77]=Pe,t[78]=Je,t[79]=X,t[80]=Ee,t[81]=_e):_e=t[81];let pe;t[82]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(Ko,{zone:"bottom"}),t[82]=pe):pe=t[82];let R;t[83]!==_e?(R=s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[_e,pe]}),t[83]=_e,t[84]=R):R=t[84];let ie,Ce,Ne,ze;t[85]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx(Ko,{zone:"right"}),Ce=s.jsx(_2,{}),Ne=s.jsx(O2,{}),ze=s.jsx(B2,{}),t[85]=ie,t[86]=Ce,t[87]=Ne,t[88]=ze):(ie=t[85],Ce=t[86],Ne=t[87],ze=t[88]);let qe;t[89]!==R?(qe=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Ie,s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[R,ie,Ce,Ne,ze]})]})}),t[89]=R,t[90]=qe):qe=t[90];let Ue;t[91]===Symbol.for("react.memo_cache_sentinel")?(Ue=s.jsx("div",{"data-page-scroll-lock":"true",children:s.jsx(Qt,{children:s.jsx(Q2,{})})}),t[91]=Ue):Ue=t[91];let tt;t[92]===Symbol.for("react.memo_cache_sentinel")?(tt=s.jsx(Qt,{children:s.jsx(Z1,{})}),t[92]=tt):tt=t[92];let He;t[93]!==qe?(He=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[me,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[qe,Ue,tt]})]}),t[93]=qe,t[94]=He):He=t[94];let Ze;t[95]!==Z||t[96]!==He?(Ze=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[Z,He]}),t[95]=Z,t[96]=He,t[97]=Ze):Ze=t[97];let Qe;t[98]!==d||t[99]!==o||t[100]!==i?(Qe=d?s.jsx(d,{open:o,onOpenChange:i}):null,t[98]=d,t[99]=o,t[100]=i,t[101]=Qe):Qe=t[101];let ot;t[102]===Symbol.for("react.memo_cache_sentinel")?(ot=null,t[102]=ot):ot=t[102];let pt;return t[103]!==P||t[104]!==de||t[105]!==q||t[106]!==Q||t[107]!==W||t[108]!==Ze||t[109]!==Qe?(pt=s.jsx(e1.Provider,{value:!0,children:s.jsx(Np,{children:s.jsx(qk,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[P,de,q,Q,L,ne,W,te,Ze,Qe,ot]})})})}),t[103]=P,t[104]=de,t[105]=q,t[106]=Q,t[107]=W,t[108]=Ze,t[109]=Qe,t[110]=pt):pt=t[110],pt};function Bj(t){return t.isSidebarOpen}function zj(t){return t.isolatedSpacesEnabled}function Wj(t){return t.setIsMobile}function Uj(t){return t.isSettingsDialogOpen}function Vj(t){return t.setSettingsDialogOpen}function Hj(t){return t.runOverviewKey!==null}function qj(t){return t.isScheduledTasksDialogOpen}function Kj(t){return t.isArchivePageOpen}function Gj(t){return t.isIntegrationsCatalogOpen}function Zj(t){return t.isUsageStatsPageOpen}function Xj(t){return t.isSourceBoardOpen}function Yj(t){return t.isOverviewOpen}function Jj(t){return t.worktreesPageProjectId}function Qj(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function e3(t){return t.isCommandPaletteOpen}function t3(t){return t.isHelpDialogOpen}function s3(t){return t.isProjectActionsDialogOpen}function n3(t){return t.isOpenCodeStatusDialogOpen}function r3(t){return t.accessDialog!==null}function o3(t){return t.applyDialog!==null}function i3(t){return t.setupOutputDialog!==null}function a3(t){return t.openGuestPageId}function l3(){return G.getState().setOpenGuestPage(null)}function c3(){return rc(l3)}function d3(){return G1()}function u3(){return od(!1)}function f3(){return u3}function p3(){return G.getState().closeMainSurfaces()}function m3(){const t=p3,e=st.subscribe((n,r)=>{const o=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,i=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function h3(){return G.getState().setCommandPaletteOpen(!1)}function g3(){return G.getState().setHelpDialogOpen(!1)}function x3(){return G.getState().setProjectActionsDialogOpen(!1)}function b3(){return G.getState().setOpenCodeStatusDialogOpen(!1)}function w3(){return pn.getState().closeAccessDialog()}function y3(){return pn.getState().closeApplyDialog()}function v3(){return pn.getState().closeSetupOutputDialog()}function S3(){return G.getState().setOpenGuestPage(null)}const ji="openchamber_requests_in_flight",Ru=1e3,k3=300*1e3,so=Math.ceil(k3/Ru),j3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ji)==="1"}catch{return!1}},Du=()=>({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 C3=1;const T3=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},N3=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},_u=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,o)=>r-o),n},Dn=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},E3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,o)=>{const i=C3++;T3(i,Date.now());try{return await e(r,o)}finally{N3(i)}};window.fetch=n},Al=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Vn=t=>{t.length>so&&t.splice(0,t.length-so)},I3=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=_u(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Dn(e,50)),t.p90Samples.push(Dn(e,90)),t.p99Samples.push(Dn(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Vn(t.samples),Vn(t.p50Samples),Vn(t.p90Samples),Vn(t.p99Samples),Vn(t.maxSamples),t.lastSampleAt=Date.now()},P3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(I3,Ru))},Ol=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Ml=t=>{if(!(typeof window>"u"))try{if(t){Ol(),Al(),window.localStorage.setItem(ji,"1"),window.__openchamberRequestsInFlight__=Du(),E3(),P3();return}window.localStorage.removeItem(ji),Ol(),Al(),delete window.__openchamberRequestsInFlight__}catch{}},k5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Du();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},j5=()=>{if(typeof window>"u")return Fl();const t=window.__openchamberRequestsInFlight__;if(!j3()||!t)return Fl();const e=_u(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:Dn(e,50),ageP90:Dn(e,90),ageP99:Dn(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:so}},Fl=()=>({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:so}),R3=(t,e,n)=>t1(t.filter(r=>!id(r)&&!r.parentID),e,n),D3=()=>R3(ps.getState().activeSessions,go.getState().ids,Zi.getState().rankById??s1),_3=(t,e,n)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=n>0?0:t.length-1;return r>=0&&(o=(r+n+t.length)%t.length),t[o]},A3=()=>{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()??"":""},O3=async()=>{const t=A3()||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")},Ll="openchamber:menu-action",$l="openchamber:check-for-updates",M3=t=>{const e=Le.c(24),{t:n}=rt(),r=st(F3),o=G(L3),i=G($3),a=G(B3),d=G(z3),u=G(W3),l=G(U3),f=G(V3),m=Sc(H3),{setThemeMode:p}=io(),h=c.useRef(!1),x=G(q3);let g,b;e[0]!==x?(g=()=>{zr()&&Us("desktop_set_menu_shortcuts",{shortcuts:n1(x)}).catch(K3)},b=[x],e[0]=x,e[1]=g,e[2]=b):(g=e[1],b=e[2]),c.useEffect(g,b);let w;e[3]!==m?(w=()=>{h.current||(h.current=!0,m().then(G3).finally(()=>{h.current=!1}))},e[3]=m,e[4]=w):w=e[4];const j=w,v=Z3;let T;e[5]!==u?(T=C=>{const y=st.getState().currentSessionId,E=_3(D3(),y,C);E&&(u(!1),st.getState().setCurrentSession(E.id,Hs(E)))},e[5]=u,e[6]=T):T=e[6];const F=T,_=X3;let A;e[7]!==F||e[8]!==t||e[9]!==r||e[10]!==f||e[11]!==i||e[12]!==u||e[13]!==l||e[14]!==p||e[15]!==n||e[16]!==o||e[17]!==a||e[18]!==d?(A=C=>{e:switch(C){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 y=st.getState(),E=Ht.getState().currentDirectory;r(y.currentSessionId&&E?{directoryOverride:E}:void 0);break e}case"new-worktree-session":{u(!1),i1();break e}case"change-workspace":{v();break e}case"toggle-right-sidebar":{const y=Ht.getState().currentDirectory;if(!y)break e;const E=G.getState(),B=fs(y),$=E.contextPanelByDirectory[B],O=$?ff($.tabs,E.contextSurfaceZones,"right",tr($,"right").activeTabId):null;$?.isOpen?E.closeContextPanel(B):O?E.setActiveContextPanelTab(B,O):E.openContextSurface(B,"git");break e}case"open-right-sidebar-git":{const y=Ht.getState().currentDirectory;if(!y)break e;G.getState().openContextSurface(fs(y),"git");break e}case"open-right-sidebar-files":{const y=Ht.getState().currentDirectory;if(!y)break e;G.getState().openContextSurface(fs(y),"file");break e}case"toggle-terminal":{const y=Ht.getState().currentDirectory;if(!y)break e;G.getState().openContextSurface(fs(y),"terminal");break e}case"toggle-context-panel-expanded":{o1(Ht.getState().currentDirectory);break e}case"copy":{const y=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(y)||O3();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":{r1();break e}case"toggle-sidebar":{d();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{La(-1);break e}case"go-forward":{La(1);break e}case"previous-session":{F(-1);break e}case"next-session":{F(1);break e}case"previous-project":{_(-1);break e}case"next-project":{_(1);break e}case"help-dialog":{a();break e}case"download-logs":nd().catch(()=>{Te.error(n("openCodeStatusDialog.toast.collectFailed"))})}},e[7]=F,e[8]=t,e[9]=r,e[10]=f,e[11]=i,e[12]=u,e[13]=l,e[14]=p,e[15]=n,e[16]=o,e[17]=a,e[18]=d,e[19]=A):A=e[19];const M=A;let S,k;e[20]!==M||e[21]!==j?(S=()=>{const C=E=>{const B=E.detail;B&&M(B)},y=()=>{j()};return window.addEventListener(Ll,C),window.addEventListener($l,y),()=>{window.removeEventListener(Ll,C),window.removeEventListener($l,y)}},k=[M,j],e[20]=M,e[21]=j,e[22]=S,e[23]=k):(S=e[22],k=e[23]),c.useEffect(S,k)};function F3(t){return t.openNewSessionDraft}function L3(t){return t.toggleCommandPalette}function $3(t){return t.setCommandPaletteOpen}function B3(t){return t.toggleHelpDialog}function z3(t){return t.toggleSidebar}function W3(t){return t.setSessionSwitcherOpen}function U3(t){return t.setSettingsDialogOpen}function V3(t){return t.setAboutDialogOpen}function H3(t){return t.checkForUpdates}function q3(t){return t.shortcutOverrides}function K3(t){console.warn("[menu-actions] failed to update menu shortcuts",t)}function G3(){const{available:t,error:e}=Sc.getState();if(e){Te.error("Failed to check for updates",{description:e});return}t||Te.success("You are on the latest version")}function Z3(){cr.requestDirectoryDialog()}function X3(t){const{activeProjectId:e,projects:n,setActiveProject:r}=ts.getState();if(n.length===0)return;const o=n.findIndex(d=>d.id===e);let i=t>0?0:n.length-1;o>=0&&(i=(o+t+n.length)%n.length);const a=n[i];a&&r(a.id)}const Bl="openchamber:install-extension",Au=t=>bx({source:t,confirmed:!1}),Y3=()=>{const t=Le.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(e4,e)};function J3(t){const{url:e}=t.detail??{};typeof e=="string"&&e&&Au(e)}function Q3(t){return t.forEach(Au)}function e4(){const t=J3;return window.addEventListener(Bl,t),pf().then(Q3),()=>window.removeEventListener(Bl,t)}const zl=(t,{isAdmitted:e,isPlaced:n,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||id(t)?!1:n||o.pinned&&r||o.work&&Oi(t),t4="openchamber:tray-action",s4=5e3,n4=500,r4=20,Wl=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ul=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Ou=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Mu=t=>t.title.trim()||"Question",o4=new Set,i4=(t,e)=>m1(t,e,o4,Zi.getState().rankById),a4=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},l4=(t,e,n,r,o)=>{if(!t)return"";const i=xr(n,r,t),a=e.project?.name,d=i?.label?.trim()||a?.trim()||a4(t),u=qr(t);let l=u&&o.get(u)||"";if(!l){for(const[f,m]of Mn.getState().directories)if(qr(f)===u){l=m.status?.current??"";break}}if(!l)for(const f of r.values()){const m=u?Vr(f,u):void 0;if(m?.branch){l=m.branch;break}}return l?`${d} · ${l}`:d},c4=()=>{const{dictionary:t}=xf.getState(),e=(l,f)=>bf(t,l,f),{results:n,dropdownProviderIds:r,displayMode:o,extensionProviders:i}=fd.getState(),a=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:a,groups:[]};const d=new Map(n.map(l=>[l.providerId,l])),u=[];for(const l of h1(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:x1(h),value:g1(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}},d4=async()=>{try{if(ro())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=mf();if(e&&da(e,t))return"Local OpenChamber";const r=(await Di()).hosts.find(o=>e?da(e,ic(o)):!1);return r?.label?.trim()?hf(r.label.trim()):"Instance"}catch{return""}},u4=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=oi()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,a]of o.children.entries()){const d=a.getState();d.vcs?.branch&&e.set(qr(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;n.push({kind:"permission",id:f.id,sessionId:m,sessionTitle:"",label:Ou(f),directory:i,canSave:pd(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;n.push({kind:"form",id:f.id,sessionId:m,sessionTitle:"",label:Mu(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},f4=(t,e)=>{const n=ps.getState().activeSessions,r=d1(n),o=S=>r.descendantsOf(S,"active").map(k=>k.id),i=ts.getState().projects,a=st.getState().availableWorktreesByProject,d=go.getState().ids,u=(S,k)=>{const C=Hs(S),y=$a(C,i,a);return mr(C)||S.projectID===gf?zl(S,{isAdmitted:y,isPlaced:k.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):zl(S,{isAdmitted:y,isPlaced:Ei(C)||xr(i,a,C)!==null,isPinned:sd(d,S.directory,S.id),zones:k})},l=oc.getState(),f={chats:l.showChatsSection,pinned:l.showPinnedSection,work:G.getState().sessionWorkEnabled&&l.showWorkSection},m={chats:!0,pinned:!0,work:!0},p=u1(ri.getState().activeSessionIds,[ad.getState().runningSessionIds,ld.getState().sessionIds,cd.getState().sessionIds,dd.getState().bySession.keys()]),h=S=>p1(S)&&!p.has(S.id),x=G.getState().dockBadgeEnabled?n.filter(S=>h(S)&&u(S,f)):[],g=x.length,b=x.sort((S,k)=>(k.time.idle??k.time.updated)-(S.time.idle??S.time.updated)||S.id.localeCompare(k.id)).slice(0,10).map(S=>({id:S.id,title:S.title,directory:Hs(S)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:b};const w=u4(),j=new Map(w.titleById);for(const S of n)S?.id&&S.title&&j.set(S.id,S.title);const v=ri.getState().statusById,T=S=>{const k=w.statusById.get(S);return k&&k!=="idle"?k:v.get(S)?.status.type??k??"idle"},F=S=>{const k=S.map(C=>T(C));return k.includes("busy")?"busy":k.includes("retry")?"retry":"idle"},_=n.filter(S=>S?.id&&!S.parentID).filter(S=>u(S,m)).slice().sort(i4).slice(0,r4).map(S=>{const k=[S.id,...o(S.id)],C=Hs(S)??"";return{id:S.id,title:S.title||"Untitled session",status:F(k),branch:C?w.branchByDirectory.get(C)??"":"",unseen:h(S)?1:0,hasError:h(S)&&f1(S),directory:C,subtitle:l4(C,S,i,a,w.branchByDirectory)}}),A=w.approvals.map(S=>({...S,sessionTitle:j.get(S.sessionId)||""})),M=new Set(A.map(S=>S.id));for(const[S,k]of ud.getState().bySession){const C=j.get(S)||"";for(const y of k.permissions)M.has(y.id)||(M.add(y.id),A.push({kind:"permission",id:y.id,sessionId:S,sessionTitle:C,label:Ou(y),directory:k.directory,canSave:pd(y.save)}));for(const y of[...k.forms,...k.pages])M.has(y.id)||(M.add(y.id),A.push({kind:"form",id:y.id,sessionId:S,sessionTitle:C,label:Mu(y),directory:k.directory,canSave:!1}))}return{sessions:_,approvals:A.filter(S=>$a(S.directory,i,a)),instanceName:t,usage:c4(),dockBadgeCount:g,dockUnreadSessions:b}},p4=()=>{c.useEffect(()=>{if(!Wl()||!zr())return;const t=Ul();let e=!1,n="",r=null,o="";const i=()=>{if(e)return;const y=f4(o,t),E=JSON.stringify(y);E!==n&&(n=E,Us("desktop_tray_update",y))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},n4))},d=ps.subscribe(()=>a()),u=ri.subscribe(()=>a()),l=ad.subscribe(()=>a()),f=ld.subscribe(()=>a()),m=cd.subscribe(()=>a()),p=dd.subscribe(()=>a()),h=G.subscribe((y,E)=>{(y.dockBadgeEnabled!==E.dockBadgeEnabled||y.sessionWorkEnabled!==E.sessionWorkEnabled)&&a()}),x=ts.subscribe(()=>a()),g=st.subscribe(()=>a()),b=go.subscribe(()=>a()),w=oc.subscribe((y,E)=>{(y.showChatsSection!==E.showChatsSection||y.showPinnedSection!==E.showPinnedSection||y.showWorkSection!==E.showWorkSection)&&a()}),j=()=>{e=!0,r!==null&&window.clearTimeout(r),d(),u(),l(),f(),m(),p(),h(),x(),g(),b(),w()};if(!t)return i(),j;d4().then(y=>{e||(o=y,i())});const v=new Map,T=()=>{if(e)return;let y;try{y=oi()}catch{return}const E=new Set;for(const[B,$]of y.children.entries())E.add(B),v.has(B)||v.set(B,$.subscribe(()=>a()));for(const[B,$]of v)E.has(B)||($(),v.delete(B))};let F=null;try{F=oi().subscribeRegistry(()=>{T(),a()})}catch{}T();const _=Mn.subscribe(()=>a()),A=ud.subscribe(()=>a()),M=Zi.subscribe(()=>a()),S=fd.subscribe(()=>a()),k=Wt.subscribe((y,E)=>{y.isInitialized&&!E.isInitialized&&Lo(!0)});Lo(!0);const C=window.setInterval(()=>{T(),i()},s4);return i(),()=>{j(),window.clearInterval(C),_(),A(),M(),S(),k(),F?.();for(const y of v.values())y();v.clear()}},[]),c.useEffect(()=>{if(!Wl()||!zr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{switch(i.type){case"mark-all-read":l1().then(()=>c1()).catch(()=>{});break;case"menu-opened":Ul()&&Lo();break;case"respond-permission":a1(i.sessionId,i.id,i.response).catch(()=>{Te.error("Failed to respond to permission request")});break}};let r=null,o=!1;return e(t4,i=>{const a=i?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(i=>{if(o){i();return}r=i,Us("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=!0;try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},m4=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,h4=(t,e,n,r)=>r||[t,e,n].filter(Boolean).join("|")||void 0,g4=t=>{t.kind!=="plugin"||!t.title||Te.info(t.title,{id:h4(t.kind,t.title,t.body,t.tag),description:t.body})},x4=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,b4=t=>{const e=Le.c(3),n=!0;let r,o;e[0]!==n?(r=()=>{if(!(_s()||!ac()||!globalThis.window))return tn(w4)},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function w4(t){if(t.type!=="notification")return;const e=G.getState();if(!e.nativeNotificationsEnabled)return;const n=m4();if(x4(t.payload,n)){g4(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&n)return;nc()?.notifications?.notifyAgentCompletion(t.payload)}const y4=()=>{const t=Le.c(4),{t:e}=rt(),n=G(v4);let r,o;t[0]!==n||t[1]!==e?(r=()=>tn(i=>{i.type==="browser-provider-reset"&&(n("builtin"),Te.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),c.useEffect(r,o)};function v4(t){return t.setBrowserProvider}const S4=()=>{const t=Le.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(j4,e)};function k4(t){t.type==="guests-changed"?b1():t.type==="event-stream-ready"&&td()}function j4(){return tn(k4)}const C4=()=>{const t=Le.c(3),{t:e}=rt();let n,r;t[0]!==e?(n=()=>tn(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=Wt.getState().providers,d=u=>a.find(l=>l.id===u);if(i.kind==="account"){const u=d(i.providerId)?.name||i.providerId;Te.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}Te.info(e("chat.limitFailover.toast.model",{model:Ba(d(i.providerId),i.modelId),fallback:Ba(d(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),c.useEffect(n,r)},Vl="relay-limit-reached",T4=()=>{const t=Le.c(3),{t:e}=rt();let n,r;t[0]!==e?(n=()=>{const o=()=>{Te.error(e("relayConnection.limitReached.title"),{id:Vl,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:N4}})};return ua(lc()?.getStatus())&&o(),wf(a=>{ua(a)?o():(a.state==="connected"||a.state==="idle")&&Te.dismiss(Vl)})},r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),c.useEffect(n,r)};function N4(){return lc()?.retry()}const Hl=()=>{yf()||(w1(),y1(Rp.map(t=>t.id)))},E4=(t,e)=>{const n=Le.c(5);let r;n[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(Hl,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(Hl,3e3);return()=>clearTimeout(i)},n[0]=t,n[1]=r):r=n[1];let o;n[2]!==e||n[3]!==t?(o=[t,e],n[2]=e,n[3]=t,n[4]=o):o=n[4],c.useEffect(r,o)},ql="pwa-install-toast-shown",Kl="pwa-install-toast-dismissed",I4=()=>{const t=Le.c(6),{browserTab:e}=Dp(),{t:n}=rt(),r=c.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),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&&(Te.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"&&Te.success(r.current("pwa.installPrompt.started"))},p=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),u=g;const b=fa(),w=vf();_p({dismissed:b.getItem(Kl),sessionShown:w.getItem(ql),hasActiveToast:l!==null})&&(w.setItem(ql,"true"),l=Te.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:()=>{fa().setItem(Kl,"true"),f()}}}))},h=()=>{u=null,f(),Te.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)},Fu=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,P4=()=>{xs.setState({byRoot:{},runtimeSnapshots:{}});const t=G.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const n of Ri)t.closeContextZone(e,n)},R4=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Lu=async(t,e)=>{const n=(await Di()).hosts.find(o=>o.id===t);if(!n)throw new Error("host-not-found");if(n.relay){await Cf(n.id,e);return}const r=Tf(ic(n));if(!r)throw new Error("host-not-found");Nf({apiBaseUrl:r,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:Ef(n),sshForwarded:n.sshForwarded===!0})},D4=async t=>{const e=await Di(),n=await kf(t,e.hosts);await jf({hosts:n.hosts,defaultHostId:e.defaultHostId||n.hostId,initialHostChoiceCompleted:!0}),await Lu(n.hostId,{reconnectActive:!0})},_4=async t=>{const e=await Sf();for(const n of e)try{n.type==="pairing"?await D4(n.link):await Lu(n.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",n.type,o),t(R4(o))}},Ci="project-config-invalid",A4=()=>{const t=Le.c(9),{t:e}=rt(),n=Wt(O4);let r;t[0]!==n?(r=p=>p.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const o=Wt(r),[i,a]=Ut.useState(!1);let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const p=Wt.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){Te.dismiss(Ci);return}Te.error(e("projectConfigError.toast.title"),{id:Ci,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&s.jsx(gs,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick: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]),Ut.useEffect(l,f);let m;return t[8]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[8]=m):m=t[8],Ut.useEffect(F4,m),null};function O4(t){return t.activeDirectoryKey}function M4(){Te.dismiss(Ci)}function F4(){return M4}const L4="\x1B",$4=new RegExp(`${L4}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Pr=Ns().transform(t=>t.replace($4,"").trim()).nullish(),B4=sn({isOpenCodeReady:dr().optional(),openCodeRunning:dr().optional(),lastOpenCodeError:Pr,opencodeBinaryResolved:Pr,lastOpenCodeLaunchDiagnostics:sn({sourceBinary:Pr,binary:Pr}).nullish()}),z4=async(t,e=qs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=B4.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},W4=(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"}},U4=sn({openchamberVersion:Ns()}),V4=async(t,e=qs)=>{const n=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)return null;const r=U4.safeParse(await n.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},H4=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function q4({version:t}){const{t:e}=rt(),[n,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const d=await Op();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=n.kind==="manual"?n:null,a=i?.info?.updateCommand||"openchamber update";return s.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),s.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),s.jsxs(ft,{type:"button",onClick:()=>{o()},disabled:n.kind==="checking",children:[s.jsx(oe,{name:n.kind==="checking"?"loader":"download",className:n.kind==="checking"?"size-4 animate-spin":"size-4"}),n.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&s.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),s.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),s.jsx(Ap,{open:n.kind==="available",onOpenChange:d=>{d||r({kind:"idle"})},info:n.kind==="available"?n.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Gl=hr(()=>Lt(()=>import("./OnboardingScreen-DuWvo16v.js"),__vite__mapDeps([272,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}))),K4=()=>Lt(()=>import("./AboutDialog-Bbu8cDW8.js"),__vite__mapDeps([273,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,249])).then(t=>t.AboutDialog),G4=()=>Lt(()=>import("./MemoryDebugPanel-xYvjTjLG.js"),__vite__mapDeps([274,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),Z4=()=>{const t=Le.c(6),e=G(e5),n=G(t5);let r;t[0]!==n?(r=()=>n(!1),t[0]=n,t[1]=r):r=t[1];const o=xo(e,K4,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==n?(i=s.jsx(o,{open:e,onOpenChange:n}),t[2]=o,t[3]=e,t[4]=n,t[5]=i):i=t[5],i},X4=t=>{const e=Le.c(3),{onClose:n}=t,r=xo(!0,G4,n);let o;return e[0]!==r||e[1]!==n?(o=r?s.jsx(r,{onClose:n}):null,e[0]=r,e[1]=n,e[2]=o):o=e[2],o},Y4=t=>{const e=Le.c(47),{onRetry:n,isRetrying:r}=t,{t:o}=rt(),[i,a]=c.useState(null);let d,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const S=new AbortController,k=Jt(),C=setTimeout(()=>S.abort(),5e3);return z4(S.signal).then(y=>{!S.signal.aborted&&Jt()===k&&a(y)}).catch(s5).finally(()=>clearTimeout(C)),()=>{S.abort(),clearTimeout(C)}},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 S=new AbortController,k=Jt(),C=setTimeout(()=>S.abort(),5e3);return V4(S.signal).then(y=>{S.signal.aborted||Jt()!==k||f(y&&H4(y)?y:null)}).catch(n5).finally(()=>clearTimeout(C)),()=>{S.abort(),clearTimeout(C)}},p=[],e[2]=m,e[3]=p):(m=e[2],p=e[3]),c.useEffect(m,p);const h=Wt(r5),x=i?null:h?.message??null;if(l){let S;e[4]!==l?(S=s.jsx(q4,{version:l}),e[4]=l,e[5]=S):S=e[5];let k;e[6]!==r||e[7]!==o?(k=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=k):k=e[8];let C;e[9]!==r||e[10]!==n||e[11]!==k?(C=s.jsx(ft,{type:"button",variant:"outline",onClick:n,disabled:r,children:k}),e[9]=r,e[10]=n,e[11]=k,e[12]=C):C=e[12];let y;return e[13]!==S||e[14]!==C?(y=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[S,C]})}),e[13]=S,e[14]=C,e[15]=y):y=e[15],y}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let b;e[18]!==g?(b=s.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let w;e[20]!==i||e[21]!==h||e[22]!==o?(w=o(W4(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=w):w=e[23];let j;e[24]!==w?(j=s.jsx("p",{className:"typography-markdown text-muted-foreground",children:w}),e[24]=w,e[25]=j):j=e[25];let v;e[26]!==b||e[27]!==j?(v=s.jsxs("div",{className:"flex flex-col gap-2",children:[b,j]}),e[26]=b,e[27]=j,e[28]=v):v=e[28];let T;e[29]!==x||e[30]!==o?(T=x&&s.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:x})]}),e[29]=x,e[30]=o,e[31]=T):T=e[31];let F;e[32]!==i||e[33]!==o?(F=i&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[32]=i,e[33]=o,e[34]=F):F=e[34];let _;e[35]!==r||e[36]!==o?(_=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=_):_=e[37];let A;e[38]!==r||e[39]!==n||e[40]!==_?(A=s.jsx(ft,{type:"button",onClick:n,disabled:r,children:_}),e[38]=r,e[39]=n,e[40]=_,e[41]=A):A=e[41];let M;return e[42]!==T||e[43]!==F||e[44]!==A||e[45]!==v?(M=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[v,T,F,A]})}),e[42]=T,e[43]=F,e[44]=A,e[45]=v,e[46]=M):M=e[46],M};function J4({apis:t}){Y3(),c.useEffect(()=>v1(),[]),c.useEffect(()=>{If("App:mounted"),Pf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Wt(L=>L.initializeApp),n=Wt(L=>L.isInitialized),r=Wt(L=>L.isConnected),o=Wt(L=>L.providersLoaded),i=Wt(L=>L.agentsLoaded),a=Wt(L=>L.loadProviders),d=Wt(L=>L.loadAgents),u=st(L=>L.error),l=st(L=>L.clearError),f=Ht(L=>L.currentDirectory),m=Ht(L=>L.isSwitchingDirectory),[p,h]=c.useState(!1),x=hn(L=>L.refreshAll),g=Ql(L=>L.refresh),[b,w]=c.useState(()=>t.runtime.isVSCode),[j,v]=c.useState(!1),[T,F]=c.useState(0),[_,A]=c.useState(0),[M,S]=c.useState(!1),k=G(L=>L.wideChatLayoutEnabled),C=G(L=>L.mobileKeyboardMode),y=c.useMemo(()=>_s(),[]),[E,B]=c.useState(()=>pa()),[$,O]=c.useState(()=>{const L=Ro();return L!==null?ma({isDesktopShell:!0,bootOutcome:L}):null}),z=c.useRef(!1),{t:J}=rt(),K=c.useRef(!1);c.useEffect(()=>{if(!n||E!=="valid"||K.current)return;const L=Ro();L?.target!=="local"||L.status!=="ok"||!L.sshStartupFallbackHostId||(K.current=!0,Te.error(J("desktopHostSwitcher.startup.title"),{description:J("desktopHostSwitcher.startup.fellBackToLocal")}))},[E,n,J]);const ee=c.useRef(!1);c.useEffect(()=>{!n||!Fu()||ee.current||(ee.current=!0,Te.info(J("desktopSafeStart.title"),{description:J("desktopSafeStart.description"),duration:1/0}))},[n,J]),c.useEffect(()=>(ha(p),Ml(p),()=>{ha(!1),Ml(!1)}),[p]),c.useEffect(()=>{Rf(C)},[C]),c.useEffect(()=>{w(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>rc(L=>{Fp(L)&&Lp(L),A(ne=>ne+1),v(!1),F(ne=>ne+1)}),[]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",k),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[k]),c.useEffect(()=>(ga(t),()=>ga(null)),[t]),c.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:!0}),S1(t.trackers))},[t.sourceControl,t.trackers,r,x,g,_]),k1();const V=E==="valid",Y=$?.screen==="main";c.useEffect(()=>{if(!Df({isDesktopShell:y,bootOutcomeKnown:V}))return;j1();const L=setTimeout(()=>{const ne=document.getElementById("initial-loading");ne&&(ne.classList.add("fade-out"),setTimeout(()=>{ne.remove()},300))},150);return()=>clearTimeout(L)},[y,V]),c.useEffect(()=>{if(!y||E!=="malformed")return;const L=document.getElementById("initial-loading");L&&(L.textContent="Desktop startup failed — please restart the app.")},[y,E]),c.useEffect(()=>{b||e()},[e,b]),c.useEffect(()=>{if(b||n)return;let L=!0,ne,W=0;const te=10,Z=1e3,me=async()=>{if(!L)return;if(W>=te){v(!0);return}const Ie=Wt.getState();if(Ie.isInitialized){v(!1);return}W+=1,await Ie.initializeApp();const fe=Wt.getState();if(!L)return;if(fe.isInitialized){v(!1);return}if(W>=te){v(!0);return}const je=Math.min(Z*Math.pow(2,W-1),4e3);ne=setTimeout(me,je)};return ne=setTimeout(me,Z),()=>{L=!1,ne&&clearTimeout(ne)}},[T,n,b]),c.useEffect(()=>{n&&v(!1)},[n]),c.useEffect(()=>{if(!j)return;const L=document.getElementById("initial-loading");L&&(L.classList.add("fade-out"),setTimeout(()=>{L.remove()},300))},[j]),c.useEffect(()=>{if(b||!r||o&&i)return;let L=!0,ne=0;const W=15,te=async()=>{const me=Wt.getState();if(!(me.providersLoaded&&me.agentsLoaded))try{me.providersLoaded||await a({source:"startupRecovery"}),Wt.getState().agentsLoaded||await d({source:"startupRecovery"})}catch{}};te();const Z=setInterval(()=>{if(L){if(++ne>=W){clearInterval(Z);return}te()}},2e3);return()=>{L=!1,clearInterval(Z)}},[r,b,d,a,o,i]),c.useEffect(()=>{m||b||r&&Qo.setDirectory(f)},[f,m,r,b]),c.useEffect(()=>{if(typeof window>"u")return;const L=ne=>{const W=ne.detail,te=typeof W?.sessionId=="string"?W.sessionId.trim():"";if(!te)return;const Z=typeof W?.directory=="string"&&W.directory.trim().length>0?W.directory.trim():null,me=typeof W?.messageId=="string"&&W.messageId.trim()||null;xa(te,String(W?.runtimeKey??"").trim(),me)||za(te,{directory:Z,messageId:me,requireKnownSession:W?.requireKnownSession===!0})};return window.addEventListener("openchamber:open-session",L),_f().then(ne=>{for(const W of ne)xa(W.sessionId,W.runtimeKey,W.messageId)||(W.requireKnownSession?za(W.sessionId,{messageId:W.messageId,requireKnownSession:!0}):C1(W.sessionId,W.messageId))}),()=>window.removeEventListener("openchamber:open-session",L)},[]),c.useEffect(()=>{if(!_s())return;const L=()=>{_4(ne=>{Te.error(J(ne==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":ne==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",L),L(),()=>window.removeEventListener("openchamber:host-actions-ready",L)},[J]);const ae=c.useRef({attempt:null,running:!1,done:!1});c.useLayoutEffect(()=>{const L=ae.current;L.attempt||(L.attempt=$p({selectNow:!Bp().sessionId}))},[]),c.useEffect(()=>{const L=ae.current,ne=()=>{const W=L.attempt;if(!W||L.running||L.done)return;const te=Wt.getState().isInitialized;L.running=!0,W().then(Z=>{if(L.running=!1,Z!=="failed"||te){L.done=!0;return}Wt.getState().isInitialized&&ne()})};ne()},[n]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{Us("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Rr()})};return window.addEventListener("openchamber:open-mini-chat",L),()=>window.removeEventListener("openchamber:open-mini-chat",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{const ne=st.getState().currentSessionId;ne&&ed(ne)};return window.addEventListener("focus",L),()=>window.removeEventListener("focus",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=ne=>{const W=ne.detail,te=typeof W?.directory=="string"&&W.directory.trim().length>0?W.directory.trim():null,Z=typeof W?.projectId=="string"&&W.projectId.trim().length>0?W.projectId.trim():null,me=!!(te||Z);G.getState().setSessionSwitcherOpen(!1),st.getState().openNewSessionDraft({target:me?"project":"chat",selectedProjectId:me?Z:null,directoryOverride:me?te:null,preserveDirectoryOverride:!!te})};return window.addEventListener("openchamber:open-draft-session",L),()=>window.removeEventListener("openchamber:open-draft-session",L)},[]),c.useEffect(()=>{typeof window>"u"||!n||m||z.current||(z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,m]),T1(),b4(),zp(f||null),y4(),Wp(t.sourceControl),Up(t.trackers),Vp(),S4(),C4(),N1(),Hp(),T4(),E4(n&&r,_),I4(),E1(),X1(),qp();const P=c.useCallback(()=>{h(L=>!L)},[]);M3(P),p4(),Y1(!0),c.useEffect(()=>{const L=()=>h(ne=>!ne);return window.addEventListener("openchamber:memory-debug-toggle",L),()=>window.removeEventListener("openchamber:memory-debug-toggle",L)},[]),c.useEffect(()=>{u&&setTimeout(()=>l(),5e3)},[l,u]),c.useEffect(()=>{if(!y||E!=="not-injected")return;let L=!1,ne=0;const W=200,te=2e3,Z=50,me=()=>{if(L)return;ne++;const Ie=pa();if(Ie!=="not-injected"){if(L=!0,B(Ie),Ie==="valid"){const je=Ro();je&&O(ma({isDesktopShell:!0,bootOutcome:je}))}return}const fe=Math.min(W*Math.pow(1.1,ne),te);if(ne>=Z){const je=document.getElementById("initial-loading");je&&!je.textContent?.includes("taking longer")&&(je.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(me,fe)};return window.setTimeout(me,W),()=>{L=!0}},[y,E]);const de=c.useCallback(async()=>{if(Af({isDesktopShell:_s(),isDesktopLocalOriginActive:ro()})){await Of();return}window.location.reload()},[]),q=c.useCallback(async()=>{if(!M){v(!1),S(!0);try{await Wt.getState().initializeApp()}finally{S(!1)}Wt.getState().isInitialized||F(L=>L+1)}},[M]),Q=L=>{if(L.screen==="recovery")return L.variant};if(y&&$&&$.screen!=="main"){if($.screen==="chooser")return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Gl,{mode:"first-launch",localAvailable:$.localAvailable!==!1,onCliAvailable:de,onChooseRemote:()=>{}})})})});const L=Q($),ne=$.screen==="recovery"&&"url"in $?$.url:void 0,W=$.screen==="recovery"&&"hostId"in $?$.hostId:void 0;return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Gl,{mode:"recovery",recoveryVariant:L,recoveryHostUrl:ne,recoveryHostLabel:void 0,recoveryHostId:W,localAvailable:$.localAvailable!==!1,onCliAvailable:de})})})})}return j&&!n&&!b?s.jsx(Qt,{children:s.jsx(Y4,{onRetry:()=>{q()},isRetrying:M},_)}):s.jsx(Qt,{children:s.jsx(I1,{sdk:Qo.getSdkClient(),directory:f||"",children:s.jsx(P1,{apis:t,children:s.jsx(Kp,{children:s.jsx(R1,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:y?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(D1,{backgroundWorkEnabled:!0}),s.jsx(Gp,{}),s.jsx(A4,{}),s.jsx($j,{}),y?s.jsx(Zp,{ready:V&&Y}):null,s.jsx(_1,{}),s.jsx(A1,{}),s.jsx(O1,{}),s.jsx(M1,{}),s.jsx(F1,{}),s.jsx(Xp,{}),s.jsx(Z4,{}),p&&s.jsx(X4,{onClose:()=>h(!1)})]})})})})},_)})}function Q4(t){const e=Le.c(2);let n;return e[0]!==t?(n=s.jsx(Mp,{children:s.jsx(J4,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function e5(t){return t.isAboutDialogOpen}function t5(t){return t.setAboutDialogOpen}function s5(){}function n5(){}function r5(t){return t.lastInitFailure}const o5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Mf();Fu()&&P4();Yp();Jp();Ff().then(()=>{L1().catch(t=>{console.error("[main] settings init failed:",t)}),$1(),B1(),z1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const $u=document.getElementById("root");if(!$u)throw new Error("Root element not found");W1();Bu.createRoot($u).render(s.jsx(Ut.StrictMode,{children:s.jsx(U1,{children:s.jsx(V1,{children:s.jsx(H1,{children:s.jsx(q1,{children:s.jsx(Q4,{apis:o5})})})})})}));const C5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Ga as P,vb as a,Jk as b,tj as c,sj as d,nj as e,cj as f,j5 as g,uj as h,rj as i,oj as j,ij as k,aj as l,R3 as m,sw as n,Qk as o,lj as p,C5 as q,k5 as r,ej as s,Id as u};
|
|
498
|
+
`),Y0=t=>{const e=Le.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:d}=rt();if(n.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]!==n||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)=>s.jsxs("div",{role:"option","aria-selected":h===r,className:We("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:[s.jsx(oe,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||oo(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:We("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:s.jsx(oe,{name:"close",className:"size-3","aria-hidden":"true"})})}),s.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=n.map(m),e[2]=r,e[3]=n,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=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":u,children:l}),e[15]=u,e[16]=l,e[17]=f):f=e[17],f},vs=t=>{const e=Le.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:a}=t,d=a?"secondary":"ghost",u=a&&"text-foreground";let l;e[0]!==u?(l=We("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]!==n?(f=s.jsx(oe,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,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=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:s.jsx(ft,{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=s.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=s.jsxs(kt,{children:[m,p]}),e[14]=m,e[15]=p,e[16]=h):h=e[16],h},nu=t=>{const e=Le.c(110),{address:n,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:b,onOpenDevTools:w,isAnnotating:j,onHardReload:v,onZoomIn:T,onZoomOut:F,onZoomReset:_,zoomPercent:A,onClearCookies:M,onClearCache:S,onToggleDeviceBar:k,isDeviceBarOpen:C}=t;let y;e[0]!==o?(y=o===void 0?[]:o,e[0]=o,e[1]=y):y=e[1];const E=y,B=p===void 0?!0:p,$=A===void 0?100:A,{t:O}=rt(),[z,J]=c.useState(!1),[K,ee]=c.useState(-1);let V;e[2]!==z||e[3]!==E?(V=z?E:[],e[2]=z,e[3]=E,e[4]=V):V=e[4];const Y=V;let ae;e[5]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>{ee(-1)},e[5]=ae):ae=e[5];let P;e[6]!==n||e[7]!==z?(P=[n,z],e[6]=n,e[7]=z,e[8]=P):P=e[8],c.useEffect(ae,P);let de;e[9]!==d?(de=He=>{J(!1),ee(-1),d(He)},e[9]=d,e[10]=de):de=e[10];const q=de;let Q;e[11]!==K||e[12]!==q||e[13]!==Y?(Q=He=>{if(Y.length!==0){if(He.key==="ArrowDown"||He.key==="ArrowUp"){He.preventDefault();const Ze=He.key==="ArrowDown"?1:-1,Qe=Y.length;ee(ot=>{const pt=ot+Ze;return pt<-1?Qe-1:pt>=Qe?-1:pt});return}if(He.key==="Escape"&&K>=0){He.preventDefault(),ee(-1);return}if(He.key==="Enter"&&K>=0){He.preventDefault();const Ze=Y[K];Ze&&q(Ze.url)}}},e[11]=K,e[12]=q,e[13]=Y,e[14]=Q):Q=e[14];const L=Q;let ne;e[15]!==O?(ne=O("contextPanel.browser.back"),e[15]=O,e[16]=ne):ne=e[16];const W=!h;let te;e[17]!==u||e[18]!==ne||e[19]!==W?(te=s.jsx(vs,{icon:"arrow-left",label:ne,onClick:u,disabled:W}),e[17]=u,e[18]=ne,e[19]=W,e[20]=te):te=e[20];let Z;e[21]!==O?(Z=O("contextPanel.browser.forward"),e[21]=O,e[22]=Z):Z=e[22];const me=!x;let Ie;e[23]!==l||e[24]!==Z||e[25]!==me?(Ie=s.jsx(vs,{icon:"arrow-right",label:Z,onClick:l,disabled:me}),e[23]=l,e[24]=Z,e[25]=me,e[26]=Ie):Ie=e[26];let fe;e[27]!==g||e[28]!==O?(fe=O(g?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=g,e[28]=O,e[29]=fe):fe=e[29];let je;e[30]!==f||e[31]!==fe?(je=s.jsx(vs,{icon:"refresh",label:fe,onClick:f}),e[30]=f,e[31]=fe,e[32]=je):je=e[32];let $e;e[33]!==v||e[34]!==O?($e=v?s.jsx(vs,{icon:"restart",label:O("contextPanel.browser.hardReload"),onClick:v}):null,e[33]=v,e[34]=O,e[35]=$e):$e=e[35];let Re;e[36]!==n||e[37]!==q?(Re=He=>{He.preventDefault(),q(n)},e[36]=n,e[37]=q,e[38]=Re):Re=e[38];let Fe;e[39]!==r?(Fe=r?s.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:s.jsx(oe,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=Fe):Fe=e[40];let Ve;e[41]!==a?(Ve=He=>a(He.target.value),e[41]=a,e[42]=Ve):Ve=e[42];let De,ge;e[43]===Symbol.for("react.memo_cache_sentinel")?(De=()=>J(!0),ge=()=>J(!1),e[43]=De,e[44]=ge):(De=e[43],ge=e[44]);const xe=Y.length>0,Se=r&&"ps-8";let Be;e[45]!==Se?(Be=We("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",Se,"typography-micro text-foreground outline-none"),e[45]=Se,e[46]=Be):Be=e[46];let Pe;e[47]!==O?(Pe=O("contextPanel.browser.addressAria"),e[47]=O,e[48]=Pe):Pe=e[48];let Me;e[49]!==n||e[50]!==L||e[51]!==Ve||e[52]!==xe||e[53]!==Be||e[54]!==Pe?(Me=s.jsx("input",{value:n,onChange:Ve,onFocus:De,onBlur:ge,onKeyDown:L,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":xe,"aria-controls":"openchamber-browser-address-suggestions",className:Be,"aria-label":Pe}),e[49]=n,e[50]=L,e[51]=Ve,e[52]=xe,e[53]=Be,e[54]=Pe,e[55]=Me):Me=e[55];let Je;e[56]!==i?(Je=He=>i?.(He),e[56]=i,e[57]=Je):Je=e[57];let X;e[58]!==K||e[59]!==q||e[60]!==Je||e[61]!==Y?(X=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Y0,{entries:Y,activeIndex:K,onSelect:q,onForget:Je,onHighlight:ee})}),e[58]=K,e[59]=q,e[60]=Je,e[61]=Y,e[62]=X):X=e[62];let Ee;e[63]!==Re||e[64]!==Fe||e[65]!==Me||e[66]!==X?(Ee=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Re,children:[Fe,Me,X]}),e[63]=Re,e[64]=Fe,e[65]=Me,e[66]=X,e[67]=Ee):Ee=e[67];let _e;e[68]!==T||e[69]!==F||e[70]!==_||e[71]!==O||e[72]!==$?(_e=F&&T?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(vs,{icon:"subtract",label:O("contextPanel.browser.zoomOut"),onClick:F}),$!==100&&_?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:_,"aria-label":O("contextPanel.browser.zoomReset"),children:[$,"%"]})}),s.jsx(jt,{sideOffset:6,children:O("contextPanel.browser.zoomReset")})]}):null,s.jsx(vs,{icon:"add",label:O("contextPanel.browser.zoomIn"),onClick:T})]}):null,e[68]=T,e[69]=F,e[70]=_,e[71]=O,e[72]=$,e[73]=_e):_e=e[73];let pe;e[74]!==M||e[75]!==O?(pe=M?s.jsx(vs,{icon:"delete-bin",label:O("contextPanel.browser.clearCookies"),onClick:M}):null,e[74]=M,e[75]=O,e[76]=pe):pe=e[76];let R;e[77]!==S||e[78]!==O?(R=S?s.jsx(vs,{icon:"database-2",label:O("contextPanel.browser.clearCache"),onClick:S}):null,e[77]=S,e[78]=O,e[79]=R):R=e[79];let ie;e[80]!==C||e[81]!==k||e[82]!==O?(ie=k?s.jsx(vs,{icon:"smartphone",label:O("contextPanel.browser.deviceToolbar"),onClick:k,pressed:C}):null,e[80]=C,e[81]=k,e[82]=O,e[83]=ie):ie=e[83];let Ce;e[84]!==j||e[85]!==b||e[86]!==O?(Ce=b?s.jsx(vs,{icon:"markup",label:O("contextPanel.browser.annotate.toggle"),onClick:b,pressed:j}):null,e[84]=j,e[85]=b,e[86]=O,e[87]=Ce):Ce=e[87];let Ne;e[88]!==w||e[89]!==O?(Ne=w?s.jsx(vs,{icon:"terminal-box",label:O("contextPanel.browser.devTools"),onClick:w}):null,e[88]=w,e[89]=O,e[90]=Ne):Ne=e[90];let ze;e[91]!==O?(ze=O("contextPanel.browser.openExternal"),e[91]=O,e[92]=ze):ze=e[92];const qe=!B;let Ue;e[93]!==m||e[94]!==ze||e[95]!==qe?(Ue=s.jsx(vs,{icon:"external-link",label:ze,onClick:m,disabled:qe}),e[93]=m,e[94]=ze,e[95]=qe,e[96]=Ue):Ue=e[96];let tt;return e[97]!==te||e[98]!==Ie||e[99]!==je||e[100]!==$e||e[101]!==Ee||e[102]!==_e||e[103]!==pe||e[104]!==R||e[105]!==ie||e[106]!==Ce||e[107]!==Ne||e[108]!==Ue?(tt=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[te,Ie,je,$e,Ee,_e,pe,R,ie,Ce,Ne,Ue]}),e[97]=te,e[98]=Ie,e[99]=je,e[100]=$e,e[101]=Ee,e[102]=_e,e[103]=pe,e[104]=R,e[105]=ie,e[106]=Ce,e[107]=Ne,e[108]=Ue,e[109]=tt):tt=e[109],tt},Jr={kind:"fill"},bl=240,J0=3840,ru=[{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(J0,Math.max(bl,t))):bl,Qr=t=>t.kind==="fill"?null:{width:t.width,height:t.height},ou=t=>{const e=ru.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Q0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},eS=(t,e)=>{const n=Qr(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},tS=["mobile","tablet","desktop","fill"],sS={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},yl=t=>typeof t=="string"&&tS.includes(t),wi=t=>t==="fill"?Jr:ou(sS[t])??Jr,Tr=t=>{const e=Qr(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=wi(n),o=Qr(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},nS=t=>{const e=Le.c(77),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:d}=rt();let u;e[0]!==n?(u=Qr(n),e[0]=n,e[1]=u):u=e[1];const l=u,f=n.kind==="preset"?n.id:"";let m;e[2]!==r||e[3]!==l?(m=(W,te)=>{const Z=Number.parseInt(te,10);if(!Number.isFinite(Z))return;const me=l??{width:1280,height:800};r({kind:"custom",width:wl(W==="width"?Z:me.width),height:wl(W==="height"?Z:me.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=We("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=W=>{const te=ou(W.target.value);r(te??Jr)},e[6]=r,e[7]=g):g=e[7];let b;e[8]!==d?(b=d("contextPanel.browser.device.preset"),e[8]=d,e[9]=b):b=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=We("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=w):w=e[10];let j;e[11]!==d?(j=d("contextPanel.browser.device.responsive"),e[11]=d,e[12]=j):j=e[12];let v;e[13]!==j?(v=s.jsx("option",{value:"",children:j}),e[13]=j,e[14]=v):v=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=ru.map(rS),e[15]=T):T=e[15];let F;e[16]!==f||e[17]!==g||e[18]!==b||e[19]!==v?(F=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:s.jsxs("select",{value:f,onChange:g,"aria-label":b,className:w,children:[v,T]})})}),e[16]=f,e[17]=g,e[18]=b,e[19]=v,e[20]=F):F=e[20];let _;e[21]!==d?(_=d("contextPanel.browser.device.preset"),e[21]=d,e[22]=_):_=e[22];let A;e[23]!==_?(A=s.jsx(jt,{sideOffset:6,children:_}),e[23]=_,e[24]=A):A=e[24];let M;e[25]!==F||e[26]!==A?(M=s.jsxs(kt,{children:[F,A]}),e[25]=F,e[26]=A,e[27]=M):M=e[27];const S=l?String(l.width):"";let k;e[28]!==p?(k=W=>p("width",W.target.value),e[28]=p,e[29]=k):k=e[29];let C;e[30]!==d?(C=d("contextPanel.browser.device.width"),e[30]=d,e[31]=C):C=e[31];let y;e[32]!==S||e[33]!==k||e[34]!==C?(y=s.jsx("input",{value:S,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":C,className:x}),e[32]=S,e[33]=k,e[34]=C,e[35]=y):y=e[35];let E;e[36]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[36]=E):E=e[36];const B=l?String(l.height):"";let $;e[37]!==p?($=W=>p("height",W.target.value),e[37]=p,e[38]=$):$=e[38];let O;e[39]!==d?(O=d("contextPanel.browser.device.height"),e[39]=d,e[40]=O):O=e[40];let z;e[41]!==B||e[42]!==$||e[43]!==O?(z=s.jsx("input",{value:B,onChange:$,placeholder:"—",inputMode:"numeric","aria-label":O,className:x}),e[41]=B,e[42]=$,e[43]=O,e[44]=z):z=e[44];let J;e[45]!==r||e[46]!==n?(J=()=>r(Q0(n)),e[45]=r,e[46]=n,e[47]=J):J=e[47];const K=!l;let ee;e[48]!==d?(ee=d("contextPanel.browser.device.rotate"),e[48]=d,e[49]=ee):ee=e[49];let V;e[50]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(oe,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[50]=V):V=e[50];let Y;e[51]!==J||e[52]!==K||e[53]!==ee?(Y=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex shrink-0",children:s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:J,disabled:K,"aria-label":ee,children:V})})}),e[51]=J,e[52]=K,e[53]=ee,e[54]=Y):Y=e[54];let ae;e[55]!==d?(ae=d("contextPanel.browser.device.rotate"),e[55]=d,e[56]=ae):ae=e[56];let P;e[57]!==ae?(P=s.jsx(jt,{sideOffset:6,children:ae}),e[57]=ae,e[58]=P):P=e[58];let de;e[59]!==Y||e[60]!==P?(de=s.jsxs(kt,{children:[Y,P]}),e[59]=Y,e[60]=P,e[61]=de):de=e[61];let q;e[62]!==a||e[63]!==l?(q=l&&a<1?s.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]=q):q=e[64];let Q;e[65]===Symbol.for("react.memo_cache_sentinel")?(Q=["system","light","dark"],e[65]=Q):Q=e[65];let L;e[66]!==o||e[67]!==i||e[68]!==d?(L=s.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:Q.map(W=>s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:o===W?"secondary":"ghost",size:"xs",className:We("shrink-0 rounded-full px-2.5 typography-micro",o===W?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(W),"aria-pressed":o===W,children:d(W==="system"?"contextPanel.browser.device.schemeSystem":W==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")})}),s.jsx(jt,{sideOffset:6,children:d(W==="system"?"contextTooltips.terminalBrowser.device.schemeSystem":W==="light"?"contextTooltips.terminalBrowser.device.schemeLight":"contextTooltips.terminalBrowser.device.schemeDark")})]},W))}),e[66]=o,e[67]=i,e[68]=d,e[69]=L):L=e[69];let ne;return e[70]!==M||e[71]!==y||e[72]!==z||e[73]!==de||e[74]!==q||e[75]!==L?(ne=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[M,y,E,z,de,q,L]}),e[70]=M,e[71]=y,e[72]=z,e[73]=de,e[74]=q,e[75]=L,e[76]=ne):ne=e[76],ne};function rS(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const eo=new Map,yi=new Set,iu=()=>{for(const t of yi)t()},Go=(t,e)=>{const n=t.trim();n&&(e.length===0?eo.delete(n):eo.set(n,[...e]),iu())},oS=t=>{eo.delete(t.trim())&&iu()},au=[],iS=t=>eo.get(t.trim())??au,aS=t=>(yi.add(t),()=>{yi.delete(t)}),lS=t=>{const e=Le.c(2);let n;return e[0]!==t?(n=()=>iS(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(aS,n,cS)};function cS(){return au}const lu="oc.browser.hiddenDevServerPorts.v1",dS=li(Ns(),jd(wo().int().positive())),vi=new Set,cu=[];let Nr=null;const ra=()=>{const t=gr().getItem(lu);if(Nr&&Nr.raw===t)return Nr.value;let e={};if(t!==null)try{const n=dS.safeParse(JSON.parse(t));n.success&&(e=n.data)}catch{e={}}return Nr={raw:t,value:e},e},du=t=>{gr().setItem(lu,JSON.stringify(t));for(const e of vi)e()},uS=(t=Jt())=>ra()[t]??cu,fS=t=>{const e=Jt(),n=ra(),r=n[e]??[];r.includes(t)||du({...n,[e]:[...r,t].sort((o,i)=>o-i)})},pS=()=>{const t=Jt(),e=ra();if(!e[t])return;const n={...e};delete n[t],du(n)},mS=t=>(vi.add(t),()=>{vi.delete(t)}),hS=()=>c.useSyncExternalStore(mS,gS,xS);function gS(){return uS()}function xS(){return cu}const bS=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},wS=2e3,yS=t=>yc("http://localhost",t),uu=t=>{const e=Le.c(62),{onOpen:n,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=rt();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=lS(i);let m;e[1]!==i?(m=()=>yS(i),e[1]=i,e[2]=m):m=e[2];const[p]=c.useState(m);let h;e[3]!==i?(h=()=>tp(i),e[3]=i,e[4]=h):h=e[4];const[x]=c.useState(h);let g;e[5]!==i?(g=Ei(i),e[5]=i,e[6]=g):g=e[6];const b=g,w=na(i),j=Xu(i);let v,T;e[7]!==i||e[8]!==j||e[9]!==o?(v=()=>{if(j){l({kind:"ready",servers:[]});return}if(!o)return;let q=!0,Q=null;const L=new AbortController,ne=()=>{n0(L.signal,i).then(W=>{q&&(l(W),Q=setTimeout(ne,wS))})};return ne(),()=>{q=!1,Q&&clearTimeout(Q),L.abort()}},T=[i,j,o],e[7]=i,e[8]=j,e[9]=o,e[10]=v,e[11]=T):(v=e[10],T=e[11]),c.useEffect(v,T);const F=ts(vS),_=st(SS);let A;if(e[12]!==F||e[13]!==_){const q=F.map(kS);let Q;e[15]!==_?(Q=[..._].flatMap(jS),e[15]=_,e[16]=Q):Q=e[16],A=[...q,...Q],e[12]=F,e[13]=_,e[14]=A}else A=e[14];const M=A;let S;e[17]!==f||e[18]!==i||e[19]!==u.kind||e[20]!==u.servers||e[21]!==M?(S=c0({candidates:i0({announced:f,discovered:u.kind==="ready"?u.servers:null}),folders:M,directory:i}),e[17]=f,e[18]=i,e[19]=u.kind,e[20]=u.servers,e[21]=M,e[22]=S):S=e[22];const k=S,C=hS(),[y,E]=c.useState(!1);let B;if(e[23]!==k||e[24]!==C||e[25]!==y){let q;e[27]!==C||e[28]!==y?(q=Q=>Q.announced||!C.includes(Q.port)&&(y||!Q.outsideWork),e[27]=C,e[28]=y,e[29]=q):q=e[29],B=k.filter(q),e[23]=k,e[24]=C,e[25]=y,e[26]=B}else B=e[26];const $=B,O=k.length-$.length;let z;e[30]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(og,{width:110,height:110,className:"shrink-0 opacity-20"}),e[30]=z):z=e[30];let J;e[31]!==a?(J=a("contextPanel.browser.empty"),e[31]=a,e[32]=J):J=e[32];let K;e[33]!==J?(K=s.jsx("span",{className:"typography-ui-header text-foreground",children:J}),e[33]=J,e[34]=K):K=e[34];let ee;e[35]!==a?(ee=a("contextPanel.browser.emptyHint"),e[35]=a,e[36]=ee):ee=e[36];let V;e[37]!==ee?(V=s.jsx("span",{className:"typography-micro text-muted-foreground",children:ee}),e[37]=ee,e[38]=V):V=e[38];let Y;e[39]!==K||e[40]!==V?(Y=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[K,V]}),e[39]=K,e[40]=V,e[41]=Y):Y=e[41];let ae;e[42]!==f||e[43]!==k.length||e[44]!==i||e[45]!==O||e[46]!==b||e[47]!==n||e[48]!==p||e[49]!==w||e[50]!==x||e[51]!==a||e[52]!==$?(ae=k.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),p&&!x?s.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx(gs,{outerClassName:"min-h-0",className:"flex flex-col gap-1 pe-0.5",disableHorizontal:!0,children:$.map(q=>s.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[s.jsxs(ft,{type:"button",variant:"outline",size:"sm",className:We("min-w-0 flex-1 justify-start gap-2",p&&"cursor-default opacity-60"),"aria-disabled":p||void 0,onClick:()=>{p||(oS(i),n(q.url))},children:[b?s.jsx("span",{className:"shrink-0",role:"img","aria-label":w??a("contextPanel.browser.spaceAddress"),title:w??a("contextPanel.browser.spaceAddress"),children:s.jsx(oe,{name:"instance",className:"size-3.5","aria-hidden":"true"})}):s.jsx(oe,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsxs("span",{className:"truncate",children:[oo(q.url)||q.url,s.jsx("span",{className:"typography-micro text-muted-foreground",children:bS(q.url)})]}),x?s.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:s.jsx(oe,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):q.folderName?s.jsxs("span",{className:"ms-auto flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",title:q.directory,children:[s.jsx(oe,{name:"folder",className:"size-3 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",dir:"auto",children:q.folderName})]}):null]}),q.announced?null:s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>fS(q.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:q.port}),children:s.jsx(oe,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})}),s.jsx(jt,{sideOffset:6,children:a("contextPanel.browser.devServers.hide",{port:q.port})})]})]},q.port))}),O>0?s.jsx(ft,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:()=>{pS(),E(!0)},children:O===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:O}):a("contextPanel.browser.devServers.showHiddenPlural",{count:O})}):null]}):null,e[42]=f,e[43]=k.length,e[44]=i,e[45]=O,e[46]=b,e[47]=n,e[48]=p,e[49]=w,e[50]=x,e[51]=a,e[52]=$,e[53]=ae):ae=e[53];let P;e[54]!==k.length||e[55]!==u.kind||e[56]!==a?(P=k.length===0&&u.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[54]=k.length,e[55]=u.kind,e[56]=a,e[57]=P):P=e[57];let de;return e[58]!==Y||e[59]!==ae||e[60]!==P?(de=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[z,Y,ae,P]}),e[58]=Y,e[59]=ae,e[60]=P,e[61]=de):de=e[61],de};function vS(t){return t.projects}function SS(t){return t.availableWorktreesByProject}function kS(t){return{path:t.path,projectPath:t.path}}function jS(t){const[e,n]=t;return n.map(r=>({path:r.path,projectPath:e}))}const CS=3e4,TS=3,NS=250,ES={attempts:0,windowStartedAt:null},IS=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=CS,r=n?0:t.attempts;return r>=TS?null:{delayMs:NS*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},PS=-3,Er=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Nn=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},RS=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:ig),[i,a]=c.useState(e),[d,u]=c.useState(""),[l,f]=c.useState(!1),[m,p]=c.useState(!1),h=c.useRef(n);h.current=n;const x=c.useRef(ES);return c.useEffect(()=>{if(!t)return;const g=()=>{try{const k=t.getURL();return Er(k)?k:""}catch{return""}},b=()=>{try{f(t.canGoBack()),p(t.canGoForward())}catch{}},w=k=>{Er(k)&&(a(k),h.current(k))},j=()=>{const k=g();o({kind:"loading",url:k})},v=()=>{const k=g();let C="";try{C=t.getTitle()||""}catch{C=""}u(C),w(k),b(),o(y=>y.kind==="failed"?y:{kind:"ready",url:k,title:C})},T=k=>{const C=Nn(k);Er(C.url)&&(w(C.url),b())},F=k=>{const C=Nn(k),y=Array.isArray(C.favicons)?C.favicons.find(Boolean):"",E=g();if(!y||!E)return;let B=-1;try{B=t.getWebContentsId()}catch{return}!Number.isFinite(B)||B<0||$d.getState().resolve(E,y,B)},_=k=>{const C=Nn(k);typeof C.title=="string"&&u(C.title)},A=k=>{const C=Nn(k);if(C.isMainFrame===!1)return;const y=typeof C.errorCode=="number"?C.errorCode:0;y!==PS&&o({kind:"failed",url:Er(C.validatedURL)?C.validatedURL:g(),code:y,description:typeof C.errorDescription=="string"?C.errorDescription:""})};let M=null;const S=()=>{const k=g(),C=IS(x.current,Date.now());if(!C){o({kind:"failed",url:k,code:0,description:"",crashed:!0});return}x.current=C.state,o({kind:"loading",url:k}),M=setTimeout(()=>{M=null;try{t.reload()}catch{o({kind:"failed",url:k,code:0,description:"",crashed:!0})}},C.delayMs)};t.addEventListener("did-start-loading",j),t.addEventListener("did-stop-loading",v),t.addEventListener("did-navigate",T),t.addEventListener("did-navigate-in-page",T),t.addEventListener("page-title-updated",_),t.addEventListener("page-favicon-updated",F),t.addEventListener("did-fail-load",A),t.addEventListener("render-process-gone",S),t.addEventListener("crashed",S);try{!t.isLoading()&&g()&&v()}catch{}return()=>{M!==null&&clearTimeout(M),t.removeEventListener("render-process-gone",S),t.removeEventListener("crashed",S),t.removeEventListener("did-start-loading",j),t.removeEventListener("did-stop-loading",v),t.removeEventListener("did-navigate",T),t.removeEventListener("did-navigate-in-page",T),t.removeEventListener("page-title-updated",_),t.removeEventListener("page-favicon-updated",F),t.removeEventListener("did-fail-load",A)}},[t]),{status:r,url:i,title:d,canGoBack:l,canGoForward:m}},vl=1e3,fu=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},DS=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},_S=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},AS=(t,e)=>{const n=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=_S());const d=u=>{if(document.activeElement!==t){i.current=DS(u);return}const l=e.current,f=n.current>r.current||Date.now()<o.current;l&&fu(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);n.current+=1;try{return await d(m)}finally{n.current-=1,o.current=Date.now()+vl,f()}},[a,t])},OS=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),MS=()=>document.visibilityState==="visible",FS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Ir=.5,LS=-3,$S=4,BS="persist:openchamber-browser",pu=(t,e,n)=>ks(t)!==null&&sc(e)?{icon:"instance",label:n}:void 0,Sl=t=>{const e=ks(t);return e?`openchamber-space-preview:${e}`:BS},kl="openchamber:browser-panel-open-tab",zS=sn({webContentsId:wo(),url:Ns().min(1),background:dr()}),jl=20,WS=600,US=2e4,VS=15e3,Cl=500,Tl=5e3,HS=3e4,qS=3e3,Nl=1e3,KS=250,GS=sn({quiet:dr()}),ZS=()=>new Promise(t=>{let e=0,n=0,r=0,o;const i=l=>{clearTimeout(o),t(l)},a=()=>{e+=1,e>=2?i(!0):requestAnimationFrame(a)},d=()=>{n=e,r=performance.now()+Nl,o=setTimeout(u,Nl)},u=()=>{e>n||performance.now()-r>KS?d():i(!1)};requestAnimationFrame(a),d()}),XS=t=>{if(!t||fu(t))return()=>{};const e=t.getBoundingClientRect(),n=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=n}},YS=({initialUrl:t,directory:e,siteDirectory:n,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=rt(),{currentTheme:d}=io(),u=c.useRef(null),[l,f]=c.useState(null),m=c.useCallback(le=>{u.current=le,f(le)},[]),p=G(le=>le.setContextPanelTabTargetPath),h=c.useRef(En(t)),x=h.current!==Qs?h.current:"",[g,b]=c.useState(x?null:Qs),w=na(n),[j,v]=c.useState(x),[T,F]=c.useState(!1),[_,A]=c.useState(!1),[M,S]=c.useState(0),k=c.useRef(0),[C,y]=c.useState(!1),[E,B]=c.useState(Jr),$=c.useRef(E);$.current=E;const O=c.useRef([]),[z,J]=c.useState("system"),[K,ee]=c.useState({width:0,height:0}),V=c.useRef(null),Y=c.useRef(null),ae=fs(e),P=c.useRef(!!x&&!Yu(ae,r)),de=c.useRef(null);c.useEffect(()=>{tc(ae,r)},[ae,r]);const q=c.useRef(!1),Q=c.useRef(Date.now()),L=c.useCallback(le=>{!le||le===Qs||!e||!r||p(e,r,le)},[e,r,p]),ne=RS(l,{initialUrl:x,onUrlChange:c.useCallback(le=>{const be=vn(le);v(be),L(be)},[L])}),[W,te]=c.useState(null),[Z,me]=c.useState(ks(n)===null);c.useEffect(()=>{const le=ks(n);if(le===null){me(!0);return}let be=!0;return me(!1),Tn("desktop_space_preview_prepare",{spaceId:le}).then(()=>{be&&me(!0)}).catch(()=>{be&&te(x||"http://localhost/")}),()=>{be=!1}},[n,x]);const Ie=ag(e),fe=lg(),je=ne.status.kind==="loading",$e=Pn(su(n)),Re=Pn(le=>le.recordVisit),Fe=Pn(le=>le.forget);c.useEffect(()=>{ne.status.kind==="ready"&&Re(n,{url:vn(ne.status.url),title:ne.status.title})},[n,ne.status,Re]);const Ve=c.useMemo(()=>tu($e,j),[$e,j]),De=c.useCallback(le=>{const be=En(le);be!==Qs&&(P.current=!1,v(be),te(null),va(be,n).then(Ae=>{const N=u.current;if(!N){b(Ae);return}try{N.loadURL(Ae)}catch{b(Ae)}}).catch(Ae=>{Ae instanceof Sa&&te(be)}))},[n]);c.useEffect(()=>{if(!x)return;let le=!0;return va(x,n).then(be=>{le&&b(be)}).catch(be=>{if(le){if(be instanceof Sa){te(x),P.current=!1,b(Qs);return}b(x)}}),()=>{le=!1}},[]);const ge=c.useMemo(()=>({executeJavaScript:async(le,be)=>{const Ae=u.current;if(!Ae)throw new Error("Browser view is not available");return Ae.executeJavaScript(le,be)},capturePage:async()=>{const le=u.current;if(!le)return null;const be=le.getWebContentsId();return Number.isFinite(be)?await Tn("desktop_browser_capture_page",{webContentsId:be}):null}}),[]),xe=c.useCallback(()=>{if(T){F(!1),Oo(ge);return}if(!ne.url){Te.error(a("contextPanel.browser.annotate.noPage"));return}const le=cg(d.metadata.variant==="light"?"light":"dark");F(!0),dg({host:ge,theme:le,labels:fe}).then(async be=>{F(!1),be&&await Ie(be)}).catch(()=>{F(!1),Te.error(a("contextPanel.browser.annotate.failed"))})},[ge,Ie,d,T,ne.url,fe,a]);c.useEffect(()=>{if(!T)return;const le=be=>{Oc(be)||be.key!=="Escape"||(be.preventDefault(),be.stopImmediatePropagation(),F(!1),Oo(ge))};return window.addEventListener("keydown",le,!0),()=>window.removeEventListener("keydown",le,!0)},[ge,T]);const Se=c.useRef(!1);c.useEffect(()=>{if(!l)return;const le=()=>{Se.current=!0};return l.addEventListener("dom-ready",le),l.addEventListener("did-fail-load",le),()=>{l.removeEventListener("dom-ready",le),l.removeEventListener("did-fail-load",le)}},[l]);const Be=c.useCallback(async()=>{const le=Date.now()+VS;for(;!(u.current&&Se.current)&&Date.now()<le;)await new Promise(be=>setTimeout(be,100));return u.current},[]),Pe=c.useCallback(async(le=8e3)=>{const be=Date.now();for(;;){const Ae=u.current;if(!Ae)return!1;let N=!1;try{N=Ae.isLoading()}catch{return!1}if(!N)return!0;if(Date.now()-be>le)return!1;await new Promise(ce=>setTimeout(ce,120))}},[]),Me=c.useCallback(async(le,be)=>{const Ae=G0({quietMs:Cl,maxMs:be});let N;const ce=new Promise(U=>{N=setTimeout(()=>U(null),be+1e3)});try{const U=GS.safeParse(await Promise.race([le.executeJavaScript(Ae,!1),ce]));return U.success&&U.data.quiet}catch{return!1}finally{clearTimeout(N)}},[]),Je=c.useCallback(async(le,be=HS)=>{const Ae=Date.now(),N=await Pe(Math.min(25e3,Math.max(0,be-Tl))),ce=be-(Date.now()-Ae),U=N&&ce>Cl&&await Me(le,Math.min(Tl,ce));let we="";try{we=le.getTitle()||""}catch{we=""}return{title:we,settled:U}},[Pe,Me]),X=c.useCallback(async(le,be,Ae)=>{const N=await Be();if(!N)throw new Error("The browser panel is not ready");const ce=()=>{yl(be.viewport)&&(B(wi(be.viewport)),y(!0))};if(le==="browser.back"||le==="browser.forward"){const ue=le==="browser.back";if(!(ue?N.canGoBack():N.canGoForward()))throw new Error(ue?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");ue?N.goBack():N.goForward(),await new Promise(bt=>setTimeout(bt,150)),await Pe();let ye="";try{ye=N.getTitle()||""}catch{ye=""}return{url:vn(N.getURL()),title:ye}}if(le==="browser.capture"){const ue=XS(V.current);try{if(!await ZS())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 Pe()&&await Me(N,qS);const et=await ge.capturePage();if(!et)throw new Error("The page could not be captured");let ye="";try{ye=N.getTitle()||""}catch{ye=""}return{...et,url:vn(N.getURL()),title:ye,viewport:Tr($.current)}}finally{ue()}}if(le==="browser.resize"){if(!yl(be.viewport))throw new Error("viewport is required");return ce(),await new Promise(ue=>setTimeout(ue,200)),await Pe(),{viewport:Tr(wi(be.viewport))}}if(le==="browser.open"){const ue=typeof be.url=="string"?be.url:"";if(!ue)throw new Error("url is required");return ce(),De(ue),await new Promise(et=>setTimeout(et,150)),{url:En(ue),...await Je(N),opened:!0,viewport:Tr($.current)}}if(le==="browser.settle"){const ue=wo().safeParse(be.budgetMs);return Je(N,ue.success?ue.data:void 0)}await Pe();const U=ue=>typeof ue=="string"&&ue?ue:void 0,ke=(()=>{switch(le){case"browser.snapshot":return U0({selector:U(be.selector)});case"browser.click":return V0({selector:U(be.selector),text:U(be.text)});case"browser.type":return H0({selector:String(be.selector??""),value:String(be.value??""),submit:be.submit===!0});case"browser.select":return q0({selector:String(be.selector??""),label:typeof be.label=="string"?be.label:void 0,value:typeof be.value=="string"?be.value:void 0});case"browser.inspect":return X0({selector:String(be.selector??"")});case"browser.scroll":return K0({selector:U(be.selector),direction:U(be.direction)});default:return null}})();if(!ke)throw new Error(`Unsupported browser action: ${le}`);let Xe=()=>{};(le==="browser.click"||le==="browser.type")&&(await Tn("desktop_browser_keep_page_focused",{webContentsId:N.getWebContentsId()}).then(et=>et.focused===!0).catch(()=>!1)||(Xe=Ae(),N.focus({preventScroll:!0})));let Oe;try{Oe=await N.executeJavaScript(ke,!0)}finally{Xe()}if(!Oe||typeof Oe!="object")throw new Error("The page returned no result");const se=Oe;if(se.ok!==!0)throw new Error(typeof se.error=="string"&&se.error?se.error:"Browser action failed");if(le==="browser.snapshot"){const ue=O.current;return{...se,viewport:Tr($.current),...ue.length>0?{consoleProblems:[...ue]}:{}}}return(le==="browser.click"||le==="browser.select"||le==="browser.type"&&be.submit===!0)&&(await new Promise(ue=>setTimeout(ue,150)),await Pe()),Oe},[ge,De,Je,Pe,Me,Be]),Ee=AS(l,V),[_e,pe]=c.useState(!1),R=c.useCallback((le,be)=>(pe(!0),Ee(Ae=>X(le,be,Ae))),[Ee,X]),ie=c.useCallback(()=>{const le=u.current;if(!le)return{title:"",url:""};let be="",Ae="";try{be=le.getTitle()||""}catch{be=""}try{Ae=vn(le.getURL())}catch{Ae=""}return{title:be,url:Ae}},[]);c.useEffect(()=>j0({tabId:r,directory:ae,ownerSessionId:o,describe:ie,run:R}),[ie,o,R,ae,r]),c.useEffect(()=>{const le=ge;return()=>{Oo(le)}},[ge]),c.useEffect(()=>{if(!l)return;const le=Ae=>{const N=Ae;if(typeof N.level!="number"||N.level<2)return;const ce=N.sourceId?`${N.sourceId}${N.line?`:${N.line}`:""}`:"";O.current.push({level:N.level>=3?"error":"warning",message:String(N.message??"").slice(0,400),source:ce}),O.current.length>jl&&O.current.splice(0,O.current.length-jl)},be=()=>{O.current=[]};return l.addEventListener("console-message",le),l.addEventListener("did-start-loading",be),()=>{l.removeEventListener("console-message",le),l.removeEventListener("did-start-loading",be)}},[l]);const Ce=c.useRef(new Set),Ne=c.useCallback(le=>{Ce.current.clear(),De(le)},[De]),ze=c.useRef(ne.status);ze.current=ne.status;const qe=c.useRef(!1);ne.status.kind==="ready"&&ne.status.url&&(qe.current=!0),c.useEffect(()=>Ju(ae,r,le=>{ef(ze.current,qe.current)&&Ne(le)}),[Ne,ae,r]),c.useEffect(()=>{if(!l)return;const le=Ae=>{const N=Nn(Ae),ce=typeof N.url=="string"?N.url:"";!ce||!ka(ce,n)||(Ae.preventDefault(),De(ce))},be=Ae=>{const N=Nn(Ae);if(N.isMainFrame===!1||N.errorCode===-3)return;const ce=typeof N.validatedURL=="string"?N.validatedURL:"";!ce||!ka(ce,n)||Ce.current.has(ce)||(Ce.current.add(ce),De(ce))};return l.addEventListener("will-navigate",le),l.addEventListener("did-fail-load",be),()=>{l.removeEventListener("will-navigate",le),l.removeEventListener("did-fail-load",be)}},[n,De,l]),c.useEffect(()=>{if(!l)return;const le=be=>{if(!(be instanceof CustomEvent))return;const Ae=zS.safeParse(be.detail);if(!Ae.success)return;let N=-1;try{N=l.getWebContentsId()}catch{return}Ae.data.webContentsId===N&&G.getState().openContextBrowser(ae,Ae.data.url,{reveal:!Ae.data.background})};return window.addEventListener(kl,le),()=>window.removeEventListener(kl,le)},[ae,l]);const Ue=c.useCallback(le=>{const be=Math.min($S,Math.max(LS,le));k.current=be,S(be);try{u.current?.setZoomLevel(be)}catch{}},[]);c.useEffect(()=>{const le=be=>{if(!(be instanceof CustomEvent))return;const Ae=be.detail,N=u.current;!N||document.activeElement!==N||(Ae==="zoom-in"?Ue(k.current+Ir):Ae==="zoom-out"?Ue(k.current-Ir):Ae==="zoom-reset"&&Ue(0))};return window.addEventListener("openchamber:zoom",le),()=>window.removeEventListener("openchamber:zoom",le)},[Ue]);const tt=c.useCallback(le=>{Tn("desktop_browser_clear_data",{partition:Sl(n),cookies:le==="cookies",cache:le==="cache"}).then(()=>{Te.success(a(le==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{u.current?.reloadIgnoringCache()}catch{}}).catch(()=>Te.error(a("contextPanel.browser.clearFailed")))},[n,a]);c.useEffect(()=>{const le=V.current;if(!le||typeof ResizeObserver>"u")return;const be=new ResizeObserver(Ae=>{const N=Ae[0]?.contentRect;N&&ee({width:N.width,height:N.height})});return be.observe(le),()=>be.disconnect()},[]);const He=c.useCallback(le=>{J(le);const be=u.current;if(!be)return;let Ae=-1;try{Ae=be.getWebContentsId()}catch{return}Tn("desktop_browser_set_color_scheme",{webContentsId:Ae,scheme:le}).catch(N=>{J("system"),Te.error(N instanceof Error?N.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),Ze=c.useCallback(()=>{try{je?u.current?.stop():u.current?.reload()}catch{}},[je]),Qe=ne.status,ot=c.useSyncExternalStore(OS,MS),pt=i&&ot||o!==null||_e;c.useEffect(()=>{const le=U=>{A(!0);const we=setTimeout(()=>{try{u.current?.reload()}catch{}},U);return()=>clearTimeout(we)};if(Qe.kind==="loading")return;const be=P.current||de.current===Qe;if(P.current&&(Qe.kind==="failed"||Qe.kind==="ready"&&Qe.url)&&(P.current=!1,de.current=Qe),Qe.kind==="failed"){const U=Qu(Qe,{run:Y.current,restored:be,watched:pt,now:Date.now()});if(Y.current=U.run,U.next==="retry")return le(U.delayMs);A(U.next==="pause");return}if(Y.current=null,Qe.kind!=="ready"||!Qe.url||!sc(Qe.url)){q.current=!0,A(!1);return}if(be||q.current||Date.now()-Q.current>US){q.current=!0,A(!1);return}let Ae=!1,N=null;return(ks(n)?Promise.resolve(null):r0(vn(Qe.url))).then(U=>{if(!Ae){if(U===null||U<500){q.current=!0,A(!1);return}N=le(WS)}}),()=>{Ae=!0,N?.()}},[n,Qe,pt]);const at=ne.status.kind==="failed"&&!_?ne.status:null,xt=eS(E,K);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(nu,{address:j,onAddressChange:v,onSubmit:Ne,suggestions:Ve,onForgetSuggestion:le=>Fe(n,le),onBack:()=>{try{u.current?.goBack()}catch{}},onForward:()=>{try{u.current?.goForward()}catch{}},onReload:Ze,onOpenExternal:()=>{Ln(ne.url||j)},addressMark:pu(n,j,w??a("contextPanel.browser.spaceAddress")),canOpenExternal:ks(n)===null,canGoBack:ne.canGoBack,canGoForward:ne.canGoForward,isLoading:je,onAnnotate:xe,isAnnotating:T,onOpenDevTools:()=>{try{u.current?.openDevTools()}catch{}},onHardReload:()=>{try{u.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ue(M+Ir),onZoomOut:()=>Ue(M-Ir),onZoomReset:()=>Ue(0),zoomPercent:Math.round(Math.pow(1.2,M)*100),onClearCookies:()=>tt("cookies"),onClearCache:()=>tt("cache"),onToggleDeviceBar:()=>y(le=>!le),isDeviceBarOpen:C}),C?s.jsx(nS,{viewport:E,onViewportChange:B,colorScheme:z,onColorSchemeChange:He,scale:xt?.scale??1}):null,s.jsxs("div",{ref:V,className:We("relative min-h-0 flex-1 bg-background",xt&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null&&Z?s.jsx("webview",{ref:m,src:g,partition:Sl(n),allowpopups:"true",webpreferences:o!==null?"backgroundThrottling=no":void 0,style:xt?{width:`${xt.width}px`,height:`${xt.height}px`,transform:`scale(${xt.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,g!==null&&!x&&!ne.url&&!je?s.jsx(uu,{onOpen:Ne,directory:n,visible:i}):null,_?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,W?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[ks(n)!==null?s.jsx(oe,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:a(ks(n)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:W})})]}):null,at&&!W?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:at.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:at.crashed?a("contextPanel.browser.crashedHint"):at.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,je?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},JS=t=>{const e=Le.c(75),{initialUrl:n,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:d}=rt(),u=G(e2);let l;e[0]!==n?(l=En(n),e[0]=n,e[1]=l):l=e[1];const f=l,m=f!==Qs?f:"",[p,h]=c.useState(m);let x;e[2]!==o||e[3]!==m?(x=Do(m,o),e[2]=o,e[3]=m,e[4]=x):x=e[4];const[g,b]=c.useState(x);let w;e[5]!==o||e[6]!==m?(w=yc(m,o)?m:"",e[5]=o,e[6]=m,e[7]=w):w=e[7];const[j,v]=c.useState(w);let T;e[8]!==o?(T=ks(o),e[8]=o,e[9]=T):T=e[9];const F=T!==null,_=na(o);let A;e[10]!==m?(A=m?[m]:[],e[10]=m,e[11]=A):A=e[11];const[M,S]=c.useState(A),[k,C]=c.useState(m?0:-1),[y,E]=c.useReducer(t2,0);let B,$;e[12]!==i||e[13]!==r?(B=()=>{tc(fs(r),i)},$=[r,i],e[12]=i,e[13]=r,e[14]=B,e[15]=$):(B=e[14],$=e[15]),c.useEffect(B,$);let O;e[16]!==u||e[17]!==i||e[18]!==r?(O=Ve=>{!Ve||Ve===Qs||!r||!i||u(r,i,Ve)},e[16]=u,e[17]=i,e[18]=r,e[19]=O):O=e[19];const z=O;let J;e[20]!==o?(J=su(o),e[20]=o,e[21]=J):J=e[21];const K=Pn(J),ee=Pn(s2),V=Pn(n2);let Y;e[22]!==p||e[23]!==K?(Y=tu(K,p),e[22]=p,e[23]=K,e[24]=Y):Y=e[24];const ae=Y;let P;e[25]!==o||e[26]!==k||e[27]!==z||e[28]!==ee?(P=Ve=>{const De=En(Ve);if(De===Qs)return;h(De);const ge=Do(De,o);b(ge),v(ge?"":De),z(De),ee(o,{url:De}),S(xe=>{const Se=k>=0?xe.slice(0,k+1):[];return Se[Se.length-1]===De?(C(Se.length-1),Se):(C(Se.length),[...Se,De])})},e[25]=o,e[26]=k,e[27]=z,e[28]=ee,e[29]=P):P=e[29];const de=P;let q;e[30]!==o||e[31]!==M||e[32]!==z?(q=Ve=>{const De=M[Ve];if(!De)return;C(Ve),h(De);const ge=Do(De,o);b(ge),v(ge?"":De),z(De)},e[30]=o,e[31]=M,e[32]=z,e[33]=q):q=e[33];const Q=q;let L;e[34]!==o||e[35]!==V?(L=Ve=>V(o,Ve),e[34]=o,e[35]=V,e[36]=L):L=e[36];let ne,W;e[37]!==Q||e[38]!==k?(ne=()=>Q(k-1),W=()=>Q(k+1),e[37]=Q,e[38]=k,e[39]=ne,e[40]=W):(ne=e[39],W=e[40]);let te;e[41]!==p||e[42]!==g?(te=()=>{Ln(g||p)},e[41]=p,e[42]=g,e[43]=te):te=e[43];let Z;e[44]!==_||e[45]!==d?(Z=_??d("contextPanel.browser.spaceAddress"),e[44]=_,e[45]=d,e[46]=Z):Z=e[46];let me;e[47]!==p||e[48]!==o||e[49]!==Z?(me=pu(o,p,Z),e[47]=p,e[48]=o,e[49]=Z,e[50]=me):me=e[50];const Ie=!j,fe=k>0,je=k>=0&&k<M.length-1;let $e;e[51]!==p||e[52]!==de||e[53]!==ae||e[54]!==L||e[55]!==ne||e[56]!==W||e[57]!==te||e[58]!==me||e[59]!==Ie||e[60]!==fe||e[61]!==je?($e=s.jsx(nu,{address:p,onAddressChange:h,onSubmit:de,suggestions:ae,onForgetSuggestion:L,onBack:ne,onForward:W,onReload:E,onOpenExternal:te,addressMark:me,canOpenExternal:Ie,canGoBack:fe,canGoForward:je,isLoading:!1}),e[51]=p,e[52]=de,e[53]=ae,e[54]=L,e[55]=ne,e[56]=W,e[57]=te,e[58]=me,e[59]=Ie,e[60]=fe,e[61]=je,e[62]=$e):$e=e[62];let Re;e[63]!==o||e[64]!==F||e[65]!==g||e[66]!==de||e[67]!==y||e[68]!==d||e[69]!==j||e[70]!==a?(Re=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:j?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[F?s.jsx(oe,{name:"instance",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,s.jsx("span",{className:"typography-ui-header text-foreground",children:d(F?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:oo(j)})}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:d("contextPanel.browser.remoteLoopback.hint")})]}):g?s.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}|${y}`):s.jsx(uu,{onOpen:de,directory:o,visible:a})}),e[63]=o,e[64]=F,e[65]=g,e[66]=de,e[67]=y,e[68]=d,e[69]=j,e[70]=a,e[71]=Re):Re=e[71];let Fe;return e[72]!==$e||e[73]!==Re?(Fe=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[$e,Re]}),e[72]=$e,e[73]=Re,e[74]=Fe):Fe=e[74],Fe},QS=t=>{const e=Le.c(3),[n]=c.useState(FS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(YS,{...t}):s.jsx(JS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function e2(t){return t.setContextPanelTabTargetPath}function t2(t){return t+1}function s2(t){return t.recordVisit}function n2(t){return t.forget}const r2=t=>{const e=Le.c(13),{zone:n,children:r}=t,[o]=c.useState(o2);let i;e[0]!==n?(i=p=>p.body[n],e[0]=n,e[1]=i):i=e[1];const a=ur(i);let d,u;e[2]!==a||e[3]!==o||e[4]!==n?(d=()=>{const p=a??ur.getState().body[n];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,n],e[2]=a,e[3]=o,e[4]=n,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=Zl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=m):m=e[12],m};function o2(){const t=document.createElement("div");return t.style.display="contents",t}const i2=200,mu=t=>`${t.path}:${t.line}:${t.column}`,El={status:"idle"},a2=t=>{const e=Le.c(9),{searchContents:n,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]!==n?(m=()=>{if(!u||!n||!r||!o.trim()){f(El);return}const h=new AbortController;let x=!1;return f({status:"searching"}),n({directory:r,query:o,regex:i,limit:i2,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,n],e[0]=u,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=d,e[6]=n,e[7]=m,e[8]=p):(m=e[7],p=e[8]),c.useEffect(m,p),l},cn=t=>{const e=Le.c(5),{className:n,children:r}=t;let o;e[0]!==n?(o=We("px-2 py-1 typography-meta text-muted-foreground",n),e[0]=n,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=s.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},l2=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},c2=t=>{const e=Le.c(44),{state:n,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:d}=rt();switch(n.status){case"idle":return null;case"searching":{let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(oe,{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=s.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=s.jsx(cn,{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=s.jsx("span",{className:"text-[var(--status-error)]",children:m}),e[11]=m,e[12]=p):p=e[12];let h;e[13]!==n.message?(h=s.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:n.message}),e[13]=n.message,e[14]=h):h=e[14];let x;return e[15]!==p||e[16]!==h?(x=s.jsxs(cn,{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]!==n.message||e[19]!==d?(m=d("sidebarFilesTree.contentSearch.failed",{message:n.message}),e[18]=n.message,e[19]=d,e[20]=m):m=e[20];let p;return e[21]!==m?(p=s.jsx(cn,{className:"text-[var(--status-error)]",children:m}),e[21]=m,e[22]=p):p=e[22],p}}if(n.matches.length===0){let m;return e[23]!==n.stopped||e[24]!==d?(m=n.stopped==="deadline"?s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.deadline")}):s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.empty")}),e[23]=n.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]!==n.matches){let m;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(m=p=>{const{name:h,directory:x}=l2(p.relativePath),g=mu(p),b=r===g;return s.jsx("li",{"data-file-tree-path":p.path,children:s.jsxs("button",{type:"button",onClick:()=>o(p),onDoubleClick:()=>o(p,{pin:!0}),draggable:!!i,onDragStart:i?w=>i(w,p):void 0,onDragEnd:a?w=>a(w,p):void 0,className:We("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",Gi(b)),title:`${p.relativePath}:${p.line}`,children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsx(ho,{filePath:p.path,className:"size-3.5 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:h}),x?s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`${x}`}):s.jsx("span",{className:"flex-1"}),s.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:p.line})]}),s.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[p.cutStart?"…":null,s.jsx(ug,{segments:fg(p.text,p.ranges)})]})]})},g)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=m):m=e[36],u=n.matches.map(m),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=n.matches,e[31]=u}else u=e[31];let l;e[37]!==n.matches.length||e[38]!==n.stopped||e[39]!==d?(l=n.stopped==="limit"?s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.limit",{count:n.matches.length})}):n.stopped==="deadline"?s.jsx(cn,{children:d("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=n.matches.length,e[38]=n.stopped,e[39]=d,e[40]=l):l=e[40];let f;return e[41]!==u||e[42]!==l?(f=s.jsxs(s.Fragment,{children:[u,l]}),e[41]=u,e[42]=l,e[43]=f):f=e[43],f},Il=8;let pr=null;const hu=(t,e)=>Math.abs(e.clientX-t.x)<=Il&&Math.abs(e.clientY-t.y)<=Il,Si=t=>{pr={x:t.clientX,y:t.clientY}},ki=t=>{const e=pr;return pr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:hu(e,t)},gu=t=>pr!==null&&hu(pr,t);let xu=null;const Zo=t=>{xu=t},bu=()=>xu,Pl=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},wu=(t,e,n)=>{const r=e===null?n:e.type==="directory"?e.path:Pl(e.path);return!r||Pl(t.path)===r||t.type==="directory"&&tf(r,t.path,t.path)!==null?null:r},d2=(t,e)=>{const n=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${n}`:`${e}/${n}`},u2=({root:t,childrenByDir:e,expandedPaths:n,loadErrorsByDir:r})=>{const o=[],i=(a,d)=>{for(const u of e[a]??[]){const l=u.type==="directory"&&n.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},f2=(t,e,n)=>{const r=e.filter(o=>o>=0&&o<n&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},p2=28,Rn=t=>Array.from(t.types).includes("Files"),er=t=>Array.from(t.types).includes(lr)?bu():null,yu=(t,e,n)=>t.getData(lr)===jo(e,n.path),m2=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},h2=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),zt=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},jo=(t,e)=>{const n=zt(e),r=zt(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Un=(t,e)=>{const n=jo(t,e);if(n!==".")return n;const r=zt(t);return r.split("/").filter(Boolean).pop()??r},Br=t=>{const e=zt(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},g2=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),x2=new Set(["node_modules"]),b2=t=>x2.has(t),w2=t=>{const e=zt(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},y2=8,Ds=new Map,oa=t=>JSON.stringify([Jt(),t]),v2=t=>{const e=oa(t),n=Ds.get(e);return n?(n.touchedAt=Date.now(),Ds.delete(e),Ds.set(e,n),n):null},Xo=t=>{const e=oa(t),n=Ds.get(e);if(n)return n.touchedAt=Date.now(),n;if(Ds.size>=y2){const o=Ds.keys().next().value;o!==void 0&&Ds.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Ds.set(e,r),r},S2=t=>{const e=Le.c(159),{guestActions:n,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:b,downloadFile:w,onSelect:j,onToggle:v,onRevealPath:T,onOpenDialog:F,onSetDropTarget:_,onDropFiles:A,onPickFiles:M,onMoveDragChange:S,onSetMoveDropTarget:k,onMoveDrop:C}=t,{t:y}=rt(),E=r.type==="directory";let B;e[0]!==E||e[1]!==r.path?(B=E?r.path:Br(r.path),e[0]=E,e[1]=r.path,e[2]=B):B=e[2];const $=B,{canRename:O,canCreateFile:z,canCreateFolder:J,canDelete:K,canReveal:ee}=b,V=!E&&!!w,Y=ee&&!d,ae=E&&x,P=O||z||J||ae||K||V||Y,[de,q]=c.useState(!1),[Q,L]=c.useState(!1);let ne;e[3]!==P?(ne=Pe=>{P&&(Pe?.preventDefault(),L(!0))},e[3]=P,e[4]=ne):ne=e[4];const W=ne;let te;e[5]!==E||e[6]!==r||e[7]!==j||e[8]!==v?(te=()=>{E?v(r.path):j(r)},e[5]=E,e[6]=r,e[7]=j,e[8]=v,e[9]=te):te=e[9];const Z=te;let me;e[10]!==E||e[11]!==r||e[12]!==j?(me=()=>{E||j(r,{pin:!0})},e[10]=E,e[11]=r,e[12]=j,e[13]=me):me=e[13];const Ie=me;let fe;e[14]===Symbol.for("react.memo_cache_sentinel")?(fe=Pe=>{Pe.stopPropagation(),L(!1),q(!0)},e[14]=fe):fe=e[14];const je=fe;let $e,Re,Fe,Ve,De,ge,xe;if(e[15]!==m||e[16]!==z||e[17]!==J||e[18]!==K||e[19]!==g||e[20]!==O||e[21]!==Y||e[22]!==x||e[23]!==ae||e[24]!==de||e[25]!==u||e[26]!==w||e[27]!==n||e[28]!==W||e[29]!==Ie||e[30]!==Z||e[31]!==P||e[32]!==a||e[33]!==d||e[34]!==E||e[35]!==h||e[36]!==p||e[37]!==i||e[38]!==l||e[39]!==r||e[40]!==A||e[41]!==S||e[42]!==C||e[43]!==F||e[44]!==M||e[45]!==T||e[46]!==_||e[47]!==k||e[48]!==Q||e[49]!==o||e[50]!==f||e[51]!==y||e[52]!==$){const Pe=pg(n,"file"),Me=se=>{const{Item:ue,Separator:et}=se;return s.jsxs(s.Fragment,{children:[O&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("rename",r)},children:[s.jsx(oe,{name:"edit",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.rename")]}),s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),wr(r.path).then(bt=>{if(bt.ok){Te.success(y("sidebarFilesTree.toast.pathCopied"));return}Te.error(y("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(oe,{name:"link",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.copyPath")]}),!E&&w&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),w(r.path).catch(bt=>{console.error("Download failed:",bt),Te.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(oe,{name:"download",className:"me-2 h-4 w-4"})," ",y(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Y&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),T(r.path)},children:[s.jsx(oe,{name:"folder-received",className:"me-2 h-4 w-4"})," ",y(gg())]}),!E&&Y&&ro()&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),Yl(r.path).then(bt=>{bt||Te.error(y("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(oe,{name:"external-link",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.openInDefaultApp")]}),Pe.length>0&&s.jsx(et,{}),Pe.map(ye=>s.jsxs(ue,{onClick:bt=>{bt.stopPropagation(),xg(ye,{kind:"file",action:ye.action.id,directory:o||null,path:r.path,isDirectory:E},y)},children:[s.jsx(fo,{icon:ye.icon,iconSrc:ye.iconSrc,className:"me-2 h-4 w-4"})," ",ye.action.label]},`${ye.guest.id}:${ye.action.id}`)),E&&(z||J||ae)&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),z&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("createFile",r)},children:[s.jsx(oe,{name:"file-add",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFile")]}),J&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("createFolder",r)},children:[s.jsx(oe,{name:"folder-add",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.newFolder")]}),ae&&s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),M(r.path)},children:[s.jsx(oe,{name:"upload-2",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.uploadFiles")]})]}),K&&s.jsxs(s.Fragment,{children:[s.jsx(et,{}),s.jsxs(ue,{onClick:ye=>{ye.stopPropagation(),F("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(oe,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",y("sidebarFilesTree.menu.delete")]})]})]})};let Je;e[60]!==g||e[61]!==r.path||e[62]!==r.type||e[63]!==S||e[64]!==o?(Je=se=>{Si(se);const ue=jo(o,r.path);!ue||ue==="."||(se.dataTransfer.setData(lr,ue),se.dataTransfer.effectAllowed=g?"copyMove":"copy",g&&S({path:r.path,type:r.type}))},e[60]=g,e[61]=r.path,e[62]=r.type,e[63]=S,e[64]=o,e[65]=Je):Je=e[65];const X=Je;let Ee;e[66]!==g||e[67]!==Z||e[68]!==S?(Ee=se=>{g&&S(null),ki(se)&&Z()},e[66]=g,e[67]=Z,e[68]=S,e[69]=Ee):Ee=e[69];const _e=Ee;let pe;e[70]!==x||e[71]!==_||e[72]!==$?(pe=se=>{!x||!$||!Rn(se.dataTransfer)||(se.preventDefault(),se.stopPropagation(),se.dataTransfer.dropEffect="copy",_($))},e[70]=x,e[71]=_,e[72]=$,e[73]=pe):pe=e[73];const R=pe;let ie;e[74]!==x||e[75]!==_||e[76]!==$?(ie=se=>{!x||!$||!Rn(se.dataTransfer)||se.relatedTarget instanceof Node&&se.currentTarget.contains(se.relatedTarget)||(se.stopPropagation(),_(null))},e[74]=x,e[75]=_,e[76]=$,e[77]=ie):ie=e[77];const Ce=ie;let Ne;e[78]!==x||e[79]!==A||e[80]!==$?(Ne=se=>{!x||!$||!Rn(se.dataTransfer)||(se.preventDefault(),se.stopPropagation(),A($,se.dataTransfer))},e[78]=x,e[79]=A,e[80]=$,e[81]=Ne):Ne=e[81];const ze=Ne;let qe;e[82]!==r.path||e[83]!==r.type||e[84]!==o?(qe=(se,ue)=>gu(se)?null:wu(ue,{path:r.path,type:r.type},o),e[82]=r.path,e[83]=r.type,e[84]=o,e[85]=qe):qe=e[85];const Ue=qe;let tt;e[86]!==g||e[87]!==Ue||e[88]!==R||e[89]!==k?(tt=se=>{const ue=g?er(se.dataTransfer):null;if(!ue){R(se);return}se.stopPropagation();const et=Ue(se,ue);k(et),et&&(se.preventDefault(),se.dataTransfer.dropEffect="move")},e[86]=g,e[87]=Ue,e[88]=R,e[89]=k,e[90]=tt):tt=e[90];const He=tt;let Ze;e[91]!==g||e[92]!==Ue||e[93]!==ze||e[94]!==C||e[95]!==k||e[96]!==o?(Ze=se=>{const ue=g?er(se.dataTransfer):null;if(!ue){ze(se);return}se.stopPropagation(),se.preventDefault(),k(null);const et=Ue(se,ue);et&&yu(se.dataTransfer,o,ue)&&C(ue,et)},e[91]=g,e[92]=Ue,e[93]=ze,e[94]=C,e[95]=k,e[96]=o,e[97]=Ze):Ze=e[97];const Qe=Ze;Re=br,ge=Q,xe=L;let ot;e[98]===Symbol.for("react.memo_cache_sentinel")?(ot={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[98]=ot):ot=e[98];let pt;e[99]!==W||e[100]!==Ce||e[101]!==He||e[102]!==Qe?(pt=s.jsx("div",{className:"group relative flex items-center typography-meta",style:ot,onContextMenu:W,onDragEnter:He,onDragOver:He,onDragLeave:Ce,onDrop:Qe}),e[99]=W,e[100]=Ce,e[101]=He,e[102]=Qe,e[103]=pt):pt=e[103];let at;e[104]!==u?(at=s.jsx(Yc,{depth:u}),e[104]=u,e[105]=at):at=e[105];let xt;e[106]!==a||e[107]!==h||e[108]!==p?(xt=We("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)]":Gi(a),h&&"opacity-50"),e[106]=a,e[107]=h,e[108]=p,e[109]=xt):xt=e[109];let le;e[110]!==u?(le=Jc(u),e[110]=u,e[111]=le):le=e[111];let be;e[112]!==le?(be={paddingInlineStart:le},e[112]=le,e[113]=be):be=e[113];let Ae;e[114]!==E||e[115]!==i||e[116]!==r.extension||e[117]!==r.path?(Ae=E?s.jsx(mg,{expanded:i}):s.jsx(ho,{filePath:r.path,extension:r.extension,className:"ms-0.5 size-3.5"}),e[114]=E,e[115]=i,e[116]=r.extension,e[117]=r.path,e[118]=Ae):Ae=e[118];let N;e[119]!==r.name||e[120]!==r.path?(N=s.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]=N):N=e[121];let ce;e[122]!==E||e[123]!==l||e[124]!==f?(ce=!E&&s.jsx(bg,{isOpen:l,status:f}),e[122]=E,e[123]=l,e[124]=f,e[125]=ce):ce=e[125];let U;e[126]!==m||e[127]!==E?(U=E&&m&&s.jsx(wg,{badge:m}),e[126]=m,e[127]=E,e[128]=U):U=e[128];let we;e[129]!==ce||e[130]!==U?(we=s.jsxs(yg,{className:"pe-2",children:[ce,U]}),e[129]=ce,e[130]=U,e[131]=we):we=e[131];let ke;e[132]!==W||e[133]!==Ie||e[134]!==_e||e[135]!==X||e[136]!==Z||e[137]!==xt||e[138]!==be||e[139]!==Ae||e[140]!==N||e[141]!==we?(ke=s.jsxs("button",{type:"button",onClick:Z,onDoubleClick:Ie,onContextMenu:W,draggable:!0,onDragStart:X,onDragEnd:_e,className:xt,style:be,children:[Ae,N,we]}),e[132]=W,e[133]=Ie,e[134]=_e,e[135]=X,e[136]=Z,e[137]=xt,e[138]=be,e[139]=Ae,e[140]=N,e[141]=we,e[142]=ke):ke=e[142];const Xe=P&&s.jsx("div",{className:We("oc-file-tree-row-end -ms-7 w-7 pe-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100",hg(a||p)),children:s.jsxs(gn,{open:de,onOpenChange:q,children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(xn,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:je,"aria-label":y("diffView.actions.moreActions"),children:s.jsx(oe,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:y("diffView.actions.moreActions")})]}),s.jsx(bn,{align:"end",side:"bottom",onCloseAutoFocus:()=>q(!1),children:Me({Item:Gt,Separator:mn})})]})});e[143]!==pt||e[144]!==at||e[145]!==ke||e[146]!==Xe?(Fe=s.jsxs(ao,{render:pt,children:[at,ke,Xe]}),e[143]=pt,e[144]=at,e[145]=ke,e[146]=Xe,e[147]=Fe):Fe=e[147],$e=lo,Ve="min-w-[180px]";let Oe;e[148]===Symbol.for("react.memo_cache_sentinel")?(Oe={Item:Cs,Separator:In},e[148]=Oe):Oe=e[148],De=Me(Oe),e[15]=m,e[16]=z,e[17]=J,e[18]=K,e[19]=g,e[20]=O,e[21]=Y,e[22]=x,e[23]=ae,e[24]=de,e[25]=u,e[26]=w,e[27]=n,e[28]=W,e[29]=Ie,e[30]=Z,e[31]=P,e[32]=a,e[33]=d,e[34]=E,e[35]=h,e[36]=p,e[37]=i,e[38]=l,e[39]=r,e[40]=A,e[41]=S,e[42]=C,e[43]=F,e[44]=M,e[45]=T,e[46]=_,e[47]=k,e[48]=Q,e[49]=o,e[50]=f,e[51]=y,e[52]=$,e[53]=$e,e[54]=Re,e[55]=Fe,e[56]=Ve,e[57]=De,e[58]=ge,e[59]=xe}else $e=e[53],Re=e[54],Fe=e[55],Ve=e[56],De=e[57],ge=e[58],xe=e[59];let Se;e[149]!==$e||e[150]!==Ve||e[151]!==De?(Se=s.jsx($e,{className:Ve,children:De}),e[149]=$e,e[150]=Ve,e[151]=De,e[152]=Se):Se=e[152];let Be;return e[153]!==Re||e[154]!==Fe||e[155]!==Se||e[156]!==ge||e[157]!==xe?(Be=s.jsxs(Re,{open:ge,onOpenChange:xe,children:[Fe,Se]}),e[153]=Re,e[154]=Fe,e[155]=Se,e[156]=ge,e[157]=xe,e[158]=Be):Be=e[158],Be},k2=(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,j2=c.memo(S2,k2),C2=t=>{const e=Le.c(14),{visible:n}=t,r=n===void 0?!0:n,o=Mn(N2),i=Zs()??"",a=yr();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=uo(a,i)??"",a?.kind==="preparing"){let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(_r,{}),e[7]=p):p=e[7],f=p;break e}d=T2,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=s.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},T2=({visible:t,currentDirectory:e,panelDirectory:n})=>{const r=c.useRef(t);r.current=t;const{t:o}=rt(),{files:i,runtime:a}=Es(),d=Rc(),u=sf(a.platform),l=zt(e.trim()),f=zt(n.trim()),m=oa(l),p=nf(),h=rf(),x=of(D=>D.searchFiles),g=G(D=>D.openContextFile),b=po(t?e:null),[w,j]=c.useState(""),v=vg(w,200),T=c.useRef(null),[F,_]=c.useState([]),[A,M]=c.useState(!1),S=!!i.searchContents,[k,C]=c.useState("names"),[y,E]=c.useState(!1),B=S&&k==="contents",$=a2({searchContents:i.searchContents,directory:e,query:v,regex:y,includeHidden:p,respectGitignore:!h,active:t&&B}),O=G(D=>D.openContextFileAtLine),[z,J]=c.useState(null),[K,ee]=c.useState(null),[V,Y]=c.useState(null),[ae,P]=c.useState(null),[de,q]=c.useState(null),{hasTouchOnlyPointer:Q}=wn(),L=!!(i.rename&&l)&&!Q,ne=G(D=>D.confirmFileTreeMove),W=G(D=>D.setConfirmFileTreeMove),[te,Z]=c.useState({}),[me,Ie]=c.useState({}),fe=c.useRef(new Set),je=c.useRef(new Map),$e=c.useMemo(()=>new dx,[]);c.useEffect(()=>()=>$e.clear(),[$e]);const Re=c.useRef(null);c.useEffect(()=>{if(ee(null),P(null),q(null),!l){Z({}),Ie({}),fe.current=new Set;return}const D=v2(l);D?(Z({...D.childrenByDir}),Ie({...D.loadErrorsByDir}),fe.current=new Set(D.loadedDirs)):(Z({}),Ie({}),fe.current=new Set)},[l]),c.useEffect(()=>{if(!l)return;const D=Xo(l);D.childrenByDir=te},[l,te]),c.useEffect(()=>{if(!l)return;const D=Xo(l);D.loadErrorsByDir=me},[l,me]),c.useEffect(()=>{if(!l)return;const D=Xo(l);D.loadedDirs=new Set(fe.current)},[l,te,me]),c.useEffect(()=>()=>{if(!l)return;const D=Ds.get(m);D&&D.loadedDirs.size===0&&Object.keys(D.childrenByDir).length===0&&Ds.delete(m)},[m,l]);const Fe=c.useMemo(()=>[],[]),Ve=c.useMemo(()=>[],[]),De=xs(D=>l?D.byRoot[l]?.expandedPaths??Fe:Fe),ge=c.useMemo(()=>new Set(De),[De]),xe=xs(D=>l?D.byRoot[l]?.selectedPath??null:null),Se=xs(D=>D.setSelectedPath),Be=c.useRef(null);c.useEffect(()=>{Be.current=xe},[xe]);const Pe=xs(D=>D.addOpenPath),Me=xs(D=>D.removeOpenPathsByPrefix),Je=xs(D=>D.toggleExpandedPath),X=xs(D=>D.expandPath),Ee=xs(D=>D.collapseAllExpandedPaths),_e=G(D=>f?D.contextPanelByDirectory[f]?.tabs??Ve:Ve),pe=c.useMemo(()=>new Set(_e.map(D=>D.mode==="file"?D.targetPath:null).filter(D=>typeof D=="string"&&D.length>0).map(D=>zt(D))),[_e]),[R,ie]=c.useState(null),[Ce,Ne]=c.useState(null),[ze,qe]=c.useState(""),[Ue,tt]=c.useState(!1),He=!!i.writeFile,Ze=!!i.createDirectory,Qe=!!i.rename,ot=!!i.delete,pt=!!i.revealPath,at=c.useMemo(()=>({canRename:Qe,canCreateFile:He,canCreateFolder:Ze,canDelete:ot,canReveal:pt}),[Qe,He,Ze,ot,pt]),xt=c.useCallback(D=>{i.revealPath&&i.revealPath(D).catch(()=>{Te.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),le=c.useCallback((D,I)=>{ie(D),Ne(I),qe(D==="rename"&&I.name||""),tt(!1)},[]),be=c.useCallback((D,I)=>{const ve=I.filter(he=>he&&typeof he.name=="string"&&he.name.length>0).filter(he=>p||!he.name.startsWith(".")).filter(he=>h||!b2(he.name)).map(he=>{const it=he.name,nt=zt(he.path||""),Nt=nt?g2(nt)?nt:zt(`${D}/${nt}`):zt(`${D}/${it}`),At=he.isDirectory?"directory":"file",Dt=At==="file"&&it.includes(".")?it.split(".").pop()?.toLowerCase():void 0;return{name:it,path:Nt,type:At,extension:Dt}});return h2(ve)},[h,p]),Ae=c.useCallback(async(D,I,ve=!1)=>{if(!r.current||I?.())return;const he=zt(D.trim());if(!he||!ve&&fe.current.has(he))return;const it=Jt();return $e.run(he,async nt=>{const Nt=()=>!nt()||Jt()!==it;try{const At=!h,Dt=i.listDirectory?(await i.listDirectory(he,{respectGitignore:At})).entries:await Qo.listLocalDirectory(he,{respectGitignore:At});if(Nt())return;je.current.set(he,Dt.length);const Mt=be(he,Dt);fe.current=new Set(fe.current),fe.current.add(he),Ie(ws=>{if(!ws[he])return ws;const nn={...ws};return delete nn[he],nn}),Z(ws=>ws[he]&&ux(ws[he],Mt)?ws:{...ws,[he]:Mt})}catch(At){if(Nt())return;const Dt=At instanceof Error?At.message:String(At??"");console.error("Failed to load sidebar directory:",At),Ie(Mt=>({...Mt,[he]:Dt}))}},ve)},[$e,i,be,h]),N=c.useCallback(async()=>{if(!l)return;Re.current?.abort();const D=new AbortController;Re.current=D,$e.clear();try{const ve=(xs.getState().byRoot[l]?.expandedPaths??[]).map(nt=>zt(nt)).filter(nt=>!!nt&&nt!==l&&nt.startsWith(`${l}/`)),he=[l,...ve];fe.current=new Set(fe.current);for(const nt of he)fe.current.delete(nt);Ie(nt=>{if(Object.keys(nt).length===0)return nt;const Nt={...nt};let At=!1;for(const Dt of he)Dt in Nt&&(delete Nt[Dt],At=!0);return At?Nt:nt});const it=()=>D.signal.aborted;await Ae(l,it);for(let nt=0;nt<ve.length&&!D.signal.aborted;nt+=3){const Nt=ve.slice(nt,nt+3);await Promise.all(Nt.map(At=>Ae(At,it)))}}catch(I){if(D.signal.aborted)return;console.error("Failed to refresh sidebar tree:",I)}finally{Re.current===D&&(Re.current=null)}},[$e,Ae,l]),ce=c.useCallback(async D=>{if(!D){await N();return}const I=zt(D);fe.current=new Set(fe.current),fe.current.delete(I),await Ae(I,void 0,!0)},[Ae,N]);c.useEffect(()=>{l&&(Re.current?.abort(),fe.current=new Set,$e.clear(),Ie({}),Z(D=>Object.keys(D).length===0?D:{}),Ae(l))},[$e,Ae,l,p,h]),c.useEffect(()=>{if(!t||!l||De.length===0)return;const D=De.map(he=>zt(he)).filter(he=>!!he&&he!==l&&he.startsWith(`${l}/`)&&!fe.current.has(he)&&!$e.has(he)).sort((he,it)=>he.split("/").length-it.split("/").length);if(D.length===0)return;let I=!1;const ve=()=>I;return(async()=>{for(let he=0;he<D.length&&!I;he+=3){const it=D.slice(he,he+3);await Promise.all(it.map(nt=>Ae(nt,ve)))}})(),()=>{I=!0}},[$e,De,Ae,l,t]);const U=c.useRef(t);c.useEffect(()=>{const D=t&&!U.current;U.current=t,D&&N()},[N,t]);const we=c.useCallback(({directories:D})=>{if(!l)return;const I=new Set((xs.getState().byRoot[l]?.expandedPaths??[]).map(Dt=>zt(Dt))),ve=l==="/"?"/":`${l}/`,he=Dt=>{for(let Mt=Dt;Mt!==l;Mt=Br(Mt))if(!Mt.startsWith(ve)||!I.has(Mt))return!1;return!0},it=Dt=>{for(let Mt=Dt;Mt===l||Mt.startsWith(ve);Mt=Br(Mt)){if(fe.current.has(Mt))return Mt;if(Mt===l)break}return null},nt=new Set,Nt=new Set;for(const Dt of D??fe.current){const Mt=it(zt(Dt));Mt&&(he(Mt)?nt:Nt).add(Mt)}Nt.size>0&&(fe.current=new Set([...fe.current].filter(Dt=>!Nt.has(Dt))));const At=[...nt].filter(Dt=>(je.current.get(Dt)??0)<=sp);(async()=>{for(let Dt=0;Dt<At.length;Dt+=3)await Promise.all(At.slice(Dt,Dt+3).map(Mt=>Ae(Mt,void 0,!0)))})()},[Ae,l]);np({root:l,active:t,whileInactive:"drop",onChanges:we}),c.useEffect(()=>{if(!t)return;if(!e||B){_([]),M(!1);return}const D=v.trim();if(!D){_([]),M(!1);return}let I=!1;return M(!0),x(e,D,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(ve=>{if(I)return;const it=ve.filter(nt=>h||!w2(nt.path)).map(nt=>({name:nt.name,path:zt(nt.path),type:"file",extension:nt.extension,relativePath:nt.relativePath}));_(it)}).catch(()=>{I||_([])}).finally(()=>{I||M(!1)}),()=>{I=!0}},[B,e,v,x,p,h,t]);const ke=c.useMemo(()=>{const D=new Map;if(!b?.files)return D;for(const I of b.files)I.index==="A"||I.working_dir==="?"?D.set(I.path,"git-added"):I.index==="D"?D.set(I.path,"git-deleted"):(I.index==="M"||I.working_dir==="M")&&D.set(I.path,"git-modified");return D},[b]),Xe=c.useMemo(()=>{const D=new Map;if(!b?.files||!l)return D;for(const I of b.files){const ve=I.index==="M"||I.working_dir==="M",he=I.index==="A"||I.working_dir==="?";if(!ve&&!he)continue;const it=I.path.split("/");if(it.length<=1)continue;let nt=l;for(let Nt=0;Nt<it.length-1;Nt++){nt=`${nt}/${it[Nt]}`;let At=D.get(nt);At||(At={modified:0,added:0},D.set(nt,At)),ve&&At.modified++,he&&At.added++}}return D},[b,l]),Oe=c.useCallback(D=>{if(ke.size===0)return null;const I=D.startsWith(l+"/")?D.slice(l.length+1):D;return ke.get(I)??null},[ke,l]),se=c.useCallback(D=>{if(Xe.size===0)return null;const I=Xe.get(D);return I&&I.modified+I.added>0?I:null},[Xe]),ue=c.useCallback(async(D,I)=>{if(!l)return;const ve=await Ua(i,D.path,{directory:l});if(!ve.ok){Va(D.path,ve);return}Se(l,D.path),Pe(l,D.path),g(f,D.path,{preview:!I?.pin&&!G.getState().isMobile})},[Pe,i,g,f,l,Se]),et=c.useCallback(async(D,I)=>{if(!l)return;const ve=await Ua(i,D.path,{directory:l});if(!ve.ok){Va(D.path,ve);return}Se(l,D.path),Pe(l,D.path),J({path:D.path,key:mu(D)}),O(f,D.path,D.line,D.column,{preview:!I?.pin&&!G.getState().isMobile})},[Pe,i,O,f,l,Se]),ye=c.useCallback((D,I)=>{Si(D),Zo(null),D.dataTransfer.setData(lr,I.relativePath),D.dataTransfer.effectAllowed="copy"},[]),bt=c.useCallback((D,I)=>{ki(D)&&et(I)},[et]),[Tt,vt]=c.useState(null),Pt=c.useCallback(()=>vt(null),[]),Ke=c.useRef(null),ct=fx(Ke,{onSettled:Pt}),Rt=c.useCallback(async D=>{const I=zt(D);if(!l)return;const ve=xs.getState().byRoot[l]?.expandedPaths.includes(I)??!1;ct(D,ve,()=>{const he=Array.from(Ke.current?.querySelectorAll("[data-tree-disclosure-path]")??[],it=>it.dataset.treeDisclosurePath??"");vt(ve?null:he.slice(he.indexOf(D)+1)),Je(l,I)}),fe.current.has(I)||await Ae(I)},[Ae,l,Je,ct]),{canUpload:ht,uploadingDirectory:Ct,uploadFiles:lt,pickFiles:Et,uploadElements:qt}=rp({root:l,refreshDirectory:ce}),dt=Ct!==null,ut=Ct??K,Ot=c.useCallback((D,I)=>{const ve=m2(I);ve.length!==0&&(ee(null),lt(D,ve))},[lt]),Zt=c.useCallback(D=>{if(Zo(D),!D){Y(null),P(null);return}requestAnimationFrame(()=>{bu()?.path===D.path&&Y(D.path)})},[]),is=c.useCallback(async(D,I)=>{const ve=d2(D,I),he=await Wa(i,{tabs:f,files:l},D.path,ve);if(he==="conflict"){Te.error(o("sidebarFilesTree.toast.nameTaken",{name:ve.slice(ve.lastIndexOf("/")+1),folder:Un(l,I)}));return}if(he==="failed"){Te.error(o("sidebarFilesTree.toast.operationFailed"));return}I!==l&&X(l,I),await Promise.all([ce(Br(D.path)),ce(I)]).catch(()=>{})},[X,i,f,ce,l,o]),as=c.useCallback((D,I)=>{if(G.getState().confirmFileTreeMove){q({source:D,targetDirectory:I});return}is(D,I)},[is]),ss=c.useCallback(()=>{de&&(q(null),is(de.source,de.targetDirectory))},[is,de]),Xt=c.useCallback((D,I)=>!L||gu(D)?null:wu(I,null,l),[L,l]),ls=c.useCallback(D=>{const I=er(D.dataTransfer);if(I){const ve=Xt(D,I);if(P(ve),!ve)return;D.preventDefault(),D.dataTransfer.dropEffect="move";return}!ht||dt||!l||!Rn(D.dataTransfer)||(D.preventDefault(),D.dataTransfer.dropEffect="copy",ee(l))},[ht,Xt,dt,l]),ns=c.useCallback(D=>{if(!(D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget))){if(er(D.dataTransfer)){P(null);return}Rn(D.dataTransfer)&&ee(null)}},[]),Is=c.useCallback(D=>{const I=er(D.dataTransfer);if(I){D.preventDefault(),P(null);const ve=Xt(D,I);ve&&yu(D.dataTransfer,l,I)&&as(I,ve);return}!ht||dt||!l||!Rn(D.dataTransfer)||(D.preventDefault(),Ot(l,D.dataTransfer))},[ht,Xt,Ot,as,dt,l]),Ps=c.useCallback(async D=>{if(D?.preventDefault(),!Ce||!R)return;tt(!0);const I=()=>tt(!1),ve=()=>ie(null);if(R==="createFile"){if(!ze.trim()){Te.error(o("sidebarFilesTree.toast.filenameRequired")),I();return}if(!i.writeFile){Te.error(o("sidebarFilesTree.toast.writeNotSupported")),I();return}const he=Ce.path,it=he?`${he}/`:"",nt=zt(`${it}${ze.trim()}`);await i.writeFile(nt,"").then(async Nt=>{Nt.success&&(Te.success(o("sidebarFilesTree.toast.fileCreated")),await ce(he)),ve()}).catch(()=>Te.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(R==="createFolder"){if(!ze.trim()){Te.error(o("sidebarFilesTree.toast.folderNameRequired")),I();return}const he=Ce.path,it=he?`${he}/`:"",nt=zt(`${it}${ze.trim()}`);await i.createDirectory(nt).then(async Nt=>{Nt.success&&(Te.success(o("sidebarFilesTree.toast.folderCreated")),await ce(he)),ve()}).catch(()=>Te.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}if(R==="rename"){if(!ze.trim()){Te.error(o("sidebarFilesTree.toast.nameRequired")),I();return}if(!i.rename){Te.error(o("sidebarFilesTree.toast.renameNotSupported")),I();return}const he=Ce.path,it=he.split("/").slice(0,-1).join("/"),nt=it?`${it}/`:"",Nt=ze.trim(),At=zt(`${nt}${Nt}`);try{const Dt=await Wa(i,{tabs:f,files:l},he,At);Dt==="moved"?(Te.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await ce(it),ve()):Dt==="conflict"?Te.error(o("sidebarFilesTree.toast.nameTaken",{name:Nt,folder:Un(l,it)})):Te.error(o("sidebarFilesTree.toast.operationFailed"))}catch{Te.error(o("sidebarFilesTree.toast.operationFailed"))}finally{I()}return}if(R==="delete"){if(!i.delete){Te.error(o("sidebarFilesTree.toast.deleteNotSupported")),I();return}const he=Ce.path,it=he.split("/").slice(0,-1).join("/");await i.delete(he).then(async nt=>{nt.success&&(Te.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await ce(it),l&&Me(l,he),(xe===he||xe&&xe.startsWith(he+"/"))&&Se(l,null)),ve()}).catch(()=>Te.error(o("sidebarFilesTree.toast.operationFailed"))).finally(I);return}I()},[R,Ce,ze,i,f,ce,Me,l,xe,Se,o]),cs=c.useMemo(()=>l?u2({root:l,childrenByDir:te,expandedPaths:ge,loadErrorsByDir:me}):[],[te,ge,me,l]),rs=c.useMemo(()=>new Map(cs.flatMap((D,I)=>D.kind==="node"?[[D.node.path,I]]:[])),[cs]),[Kt,Os]=c.useState(null),[re,Ye]=c.useState(null),gt=c.useCallback(D=>{Ke.current=D,Ye(D)},[]),[wt,_t]=c.useState(null),Vt=c.useMemo(()=>[V,wt,...Tt??[]].flatMap(D=>D?[rs.get(D)??-1]:[]),[wt,V,Tt,rs]),H=c.useCallback(D=>f2(gx(D),Vt,cs.length),[Vt,cs.length]),[Ge,mt]=c.useState(0);c.useLayoutEffect(()=>{if(!Kt||!re)return;const D=re.getBoundingClientRect().top-Kt.getBoundingClientRect().top+Kt.scrollTop;mt(Math.max(0,Math.round(D)))},[re,Kt]);const It=c.useRef(null),$t=c.useRef(new Map),Bt=c.useRef(null),Ft=c.useCallback(D=>{const I=Math.max(0,...$t.current.values());D.style.setProperty("--oc-file-tree-width",`${I}px`)},[]),js=c.useCallback((D,I)=>{const ve=D.dataset.treeRowPath,he=Ke.current;!ve||!he||I<=he.clientWidth+.5||$t.current.get(ve)!==I&&($t.current.set(ve,I),Bt.current===null&&(Bt.current=requestAnimationFrame(()=>{Bt.current=null,Ke.current&&Ft(Ke.current)})))},[Ft]);c.useEffect(()=>()=>{Bt.current!==null&&cancelAnimationFrame(Bt.current)},[]),c.useLayoutEffect(()=>{if(!re)return;const D=$t.current;for(const he of D.keys())rs.has(he)||D.delete(he);const I=Kt?.scrollLeft??0;re.style.removeProperty("--oc-file-tree-width");const ve=re.clientWidth;for(const he of re.children){const it=he instanceof HTMLElement?he.dataset.treeRowPath:void 0;if(!it)continue;const nt=he.getBoundingClientRect().width;nt>ve+.5?D.set(it,nt):D.delete(it)}Ft(re),Kt&&(Kt.scrollLeft=I)},[re,rs,Kt,Ft]);const Rs=hx({count:cs.length,enabled:Kt!==null,getScrollElement:()=>Kt,estimateSize:D=>(cs[D]?.kind==="node"?It.current:null)??p2,measureElement:(D,I,ve)=>{const he=xx(D,I,ve);return D.dataset.treeRowPath&&(It.current=he),I&&js(D,I.borderBoxSize?.[0]?.inlineSize??D.getBoundingClientRect().width),he},getItemKey:D=>cs[D]?.key??D,overscan:12,scrollMargin:Ge,rangeExtractor:H}),Xs=D=>{if(D.kind==="error")return s.jsxs("div",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:Jc(D.depth)},children:[s.jsx(Yc,{depth:D.depth}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:D.message,children:D.message}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{ce(D.directory)},children:[s.jsx(oe,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),s.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFolder")})]})]});const{node:I,depth:ve,isExpanded:he}=D,it=I.type==="directory";return s.jsx(j2,{node:I,root:l,isExpanded:he,isActive:xe===I.path,isBrowserClient:u,depth:ve,isOpen:!it&&pe.has(I.path),status:it?void 0:Oe(I.path),badge:it?se(I.path):void 0,isDropTarget:it&&(ut===I.path||ae===I.path),isDragSource:V===I.path,canUpload:ht&&!dt,canMove:L,permissions:at,downloadFile:i.downloadFile,onSelect:ue,onToggle:Rt,onRevealPath:xt,onOpenDialog:le,onSetDropTarget:ee,onDropFiles:Ot,onPickFiles:Et,onMoveDragChange:Zt,onSetMoveDropTarget:P,onMoveDrop:as,guestActions:d})},Co=c.useCallback(D=>{const I=D.target instanceof Element?D.target.closest("[data-tree-row-path]"):null;_t(I?.dataset.treeRowPath??null)},[]),To=c.useCallback(D=>{D.relatedTarget instanceof Node&&D.currentTarget.contains(D.relatedTarget)||_t(null)},[]);c.useEffect(()=>{const D=Be.current;if(!D||!Kt||!re)return;const I=rs.get(D);I===void 0||Kt.offsetParent===null||(Be.current=null,Rs.scrollToIndex(I,{align:"auto"}))});const vr=!!(l&&te[l]),$n=l?me[l]:null,Bn=v.trim().length>0,No=!A&&!Bn&&F.length===0&&!$n&&vr&&!!l,zn=ut?Un(l,ut):"",Sr=ae?Un(l,ae):"",Eo=de?de.source.path.slice(de.source.path.lastIndexOf("/")+1):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col border-b border-edge-muted",children:[s.jsx("div",{className:"flex h-8 shrink-0 items-center border-t border-edge-muted px-2",children:s.jsx(Sg,{className:"flex-1",start:null,groups:[[(He||Ze||ht)&&{id:"add",label:o("sidebarFilesTree.actions.addMenuTitle"),icon:dt?"loader-4":"add",iconClassName:dt?"animate-spin":void 0,menu:s.jsxs(s.Fragment,{children:[He?s.jsxs(Gt,{onClick:()=>le("createFile",{path:e,type:"directory"}),children:[s.jsx(oe,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,Ze?s.jsxs(Gt,{onClick:()=>le("createFolder",{path:e,type:"directory"}),children:[s.jsx(oe,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,ht?s.jsxs(Gt,{disabled:!l||dt,onClick:()=>Et(l),children:[s.jsx(oe,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})},{id:"gitignored",label:o("filesView.tree.actions.showGitignored"),icon:"file-forbid",pressed:h,onSelect:()=>af(!h)},{id:"refresh",label:o("sidebarFilesTree.actions.refreshTitle"),icon:"refresh",onSelect:()=>{N()}},{id:"collapse-all",label:o("sidebarFilesTree.actions.collapseAllTitle"),icon:"collapse-vertical",onSelect:()=>{l&&Ee(l)}}]]})}),s.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[S?s.jsxs(gn,{children:[s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"absolute inset-s-3 top-3 inline-flex",children:s.jsx(xn,{asChild:!0,children:s.jsxs(ft,{variant:"ghost",size:"sm",className:"relative size-6 p-0 text-muted-foreground hover:text-foreground","aria-label":o("sidebarFilesTree.search.mode.aria"),children:[s.jsx(oe,{name:B?"file-search":"search",className:"h-4 w-4"}),s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.mode.aria")})]}),s.jsx(bn,{align:"start",side:"bottom",children:s.jsxs(zc,{value:k,onValueChange:D=>C(D==="contents"?"contents":"names"),children:[s.jsxs(Kr,{value:"names",closeOnClick:!0,className:"items-center",children:[s.jsx(oe,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),s.jsxs(Kr,{value:"contents",closeOnClick:!0,className:"items-center",children:[s.jsx(oe,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):s.jsx(oe,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),s.jsx(On,{ref:T,value:w,onChange:D=>j(D.target.value),placeholder:o(B?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:We("h-8 ps-8 typography-meta",B?"pe-16":"pe-8")}),B?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"chip",size:"xs","aria-pressed":y,onClick:()=>{E(D=>!D),T.current?.focus()},"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o(y?"contextTooltips.files.searchPlainText":"sidebarFilesTree.search.regexTitle")})]}):null,w.trim().length>0?s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:We("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",B?"inset-e-10":"inset-e-4"),onClick:()=>{j(""),T.current?.focus()},children:s.jsx(oe,{name:"close",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.search.clearAria")})]}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsxs(gs,{ref:Os,outerClassName:"h-full min-h-0",className:We("@container px-1.5 py-1.5 [overflow-anchor:none]",(ut===l||ae===l)&&"bg-interactive-selection/10"),onDragEnter:ls,onDragOver:ls,onDragLeave:ns,onDrop:Is,children:[s.jsx("ul",{className:"flex flex-col",children:B&&$.status!=="idle"?s.jsx(c2,{state:$,activeMatchKey:z&&z.path===xe?z.key:null,onOpen:et,onDragStart:ye,onDragEnd:bt}):A?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(oe,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):Bn&&F.length===0?s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):F.length>0?F.map(D=>{const I=xe===D.path;return s.jsx("li",{"data-file-tree-path":D.path,children:s.jsxs("button",{type:"button",onClick:()=>ue(D),onDoubleClick:()=>ue(D,{pin:!0}),draggable:!0,onDragStart:ve=>{Si(ve),Zo(null);const he=D.relativePath||jo(l??"",D.path);!he||he==="."||(ve.dataTransfer.setData(lr,he),ve.dataTransfer.effectAllowed="copy")},onDragEnd:ve=>{ki(ve)&&ue(D)},className:We("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",Gi(I)),title:D.path,children:[s.jsx(ho,{filePath:D.path,extension:D.extension,className:"size-3.5"}),s.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`${D.relativePath??D.path}`})]})},D.path)}):$n?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:$n}),s.jsxs(kt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{N()},children:[s.jsx(oe,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})}),s.jsx(jt,{sideOffset:6,children:o("contextTooltips.files.retryFileList")})]})]}):vr&&l?null:s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),No?s.jsx("ul",{ref:gt,className:"relative min-w-[max(100%,var(--oc-file-tree-width,0px))]",style:{height:Rs.getTotalSize()},onFocus:Co,onBlur:To,children:Rs.getVirtualItems().map(D=>{const I=cs[D.index];if(!I)return null;const ve=I.kind==="node"?I.node.path:void 0;return s.jsx("li",{ref:Rs.measureElement,"data-index":D.index,"data-tree-row-path":ve,"data-tree-disclosure-path":I.kind==="node"?ve:`${I.directory}/`,"data-file-tree-path":I.kind==="node"&&I.node.type==="file"?ve:void 0,className:We("absolute inset-x-0 top-0",I.kind==="node"&&"min-w-max"),style:{transform:`translateY(${D.start-Ge}px)`},children:Xs(I)},D.key)})}):null]}),ut?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(oe,{name:dt?"loader-4":"folder-received",className:We("size-4 flex-shrink-0",dt&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:zn,children:o(dt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:zn})})]}):ae?s.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(oe,{name:"folder-received",className:"size-4 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Sr,children:o("sidebarFilesTree.drop.moveTarget",{path:Sr})})]}):null]}),qt,s.jsx(nr,{open:!!R,onOpenChange:D=>!D&&ie(null),children:s.jsxs(rr,{children:[s.jsxs(or,{children:[s.jsxs(ir,{children:[R==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),R==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),R==="rename"&&o("sidebarFilesTree.dialog.rename.title"),R==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(ar,{children:[R==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ce?.path??o("sidebarFilesTree.dialog.rootFallback")}),R==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ce?.path??o("sidebarFilesTree.dialog.rootFallback")}),R==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ce?.name??""}),R==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ce?.name??""})]})]}),R!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(On,{value:ze,onChange:D=>qe(D.target.value),placeholder:o(R==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:D=>{D.key==="Enter"&&Ps()},autoFocus:!0})}),s.jsxs(Hr,{children:[s.jsx(ft,{variant:"outline",onClick:()=>ie(null),disabled:Ue,children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{variant:R==="delete"?"destructive":"default",onClick:()=>{Ps()},disabled:Ue||R!=="delete"&&!ze.trim(),children:Ue?s.jsx(oe,{name:"loader-4",className:"size-4 animate-spin"}):o(R==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),s.jsx(nr,{open:de!==null,onOpenChange:D=>{D||q(null)},children:s.jsxs(rr,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(or,{children:[s.jsx(ir,{children:o("sidebarFilesTree.dialog.move.title")}),s.jsx(ar,{children:de?o("sidebarFilesTree.dialog.move.description",{name:Eo,folder:Un(l,de.targetDirectory)}):null})]}),s.jsxs(Hr,{className:"w-full sm:items-center sm:justify-between",children:[s.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>W(!ne),children:[s.jsx(ti,{checked:!ne,onChange:D=>W(!D),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),s.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:()=>q(null),children:o("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{onClick:ss,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function N2(t){return t.runtimeKey}const E2=hr(()=>Lt(()=>import("./WalkthroughView-Bbwyk6rg.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,215,216,217,204,218])).then(t=>({default:t.WalkthroughView}))),I2=hr(()=>Lt(()=>import("./DiffView-DwaJOPUe.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,205,206,207,208,210,211,215,218])).then(t=>({default:t.DiffView}))),P2=hr(()=>Lt(()=>import("./FilesView-Hvxe_KqA.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,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,235,207,208,236,237,238,239,206,218,203,240])).then(t=>({default:t.FilesView}))),vu=c.lazy(()=>Lt(()=>import("./useAppFontEffects-3RimJo4B.js").then(t=>t.t9),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.PluginPane}))),Rl=c.lazy(()=>Lt(()=>import("./GuestSurfacePane-Ds8luSO0.js"),__vite__mapDeps([241,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>({default:t.GuestSurfacePane}))),Su={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},R2=t=>{const e=Le.c(12),{mode:n,docking:r}=t,[o,i]=c.useState(null),a=Su[r.dock],d=Math.max(Tg,o??r.size),u=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let l;e[0]!==a.page||e[1]!==u?(l=We("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u,a.page),e[0]=a.page,e[1]=u,e[2]=l):l=e[2];let f;e[3]!==a.vertical||e[4]!==d?(f=a.vertical?{height:d}:{width:d},e[3]=a.vertical,e[4]=d,e[5]=f):f=e[5];let m;e[6]!==n?(m=s.jsx(vu,{mode:n,onResize:i}),e[6]=n,e[7]=m):m=e[7];let p;return e[8]!==l||e[9]!==f||e[10]!==m?(p=s.jsx("div",{className:l,style:f,children:m}),e[8]=l,e[9]=f,e[10]=m,e[11]=p):p=e[11],p},Cn=(t,e)=>`${t}\0${e}`,D2=({visible:t,active:e,fill:n=!1,side:r})=>{const{t:o}=rt(),i=G(v=>v.contextEditorTreeWidth),a=G(v=>v.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(v=>{const T=h.current;T&&(T.style.width=`${v}px`,T.style.setProperty("--oc-editor-tree-width",`${v}px`))},[]),g=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}p.current=v.pointerId,u(!0),l.current=v.clientX,f.current=i,m.current=i,v.preventDefault()}},b=v=>{if(!d||p.current!==v.pointerId)return;const T=r==="left"?v.clientX-l.current:l.current-v.clientX,F=no(v.currentTarget)?-T:T,_=Jo(f.current+F);m.current!==_&&(m.current=_,x(_))},w=v=>{if(p.current!==v.pointerId)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const T=Jo(m.current??i);p.current=null,m.current=null,u(!1),a(T)},j=t?i:0;return s.jsxs("div",{ref:h,className:We("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${d?m.current??j:j}px`,maxWidth:n?"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&&!n&&s.jsx("div",{"aria-hidden":"true",className:We("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!n&&s.jsx("div",{className:We("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:b,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:We("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:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(C2,{visible:t&&e})})]})},dn=t=>{const e=Le.c(12),{zone:n,isOpen:r,interactive:o,hidden:i,className:a,children:d}=t,u=!r||i;let l;e[0]!==d||e[1]!==u?(l=s.jsx(Qc,{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=s.jsx(Gc.Provider,{value:!0,children:s.jsx(lp.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=s.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]!==n?(p=s.jsx(r2,{zone:n,children:m}),e[9]=m,e[10]=n,e[11]=p):p=e[11],p},_2=()=>{const{t}=rt(),e=Zs()??"",n=c.useMemo(()=>e?fs(e):"",[e]),r=G(R=>n?R.contextPanelByDirectory[n]:void 0),o=yr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,d=uo(o,e)??"",u=G(R=>R.contextSurfaceZones),l=G(R=>R.contextPanelByDirectory),f=G(R=>R.closeContextPanelTab),m=G(R=>R.closeContextFile),p=G(R=>R.openContextPanelTab),h=G(R=>R.openAgentBrowserTab),x=G(R=>R.openContextFile),g=G(R=>R.contextEditorTreeVisible),b=G(R=>R.contextEditorVisible),w=G(R=>R.fileTreeSide),j=xs(R=>R.setSelectedPath),v=ur(R=>R.headerSlot),T=c.useMemo(()=>r?.tabs??[],[r?.tabs]),F=Or(R=>R.chatCovered),_=c.useMemo(()=>{const R=ie=>{const Ce=r?Wr(r,u,ie):null,Ne=ie==="bottom"&&F;return{activeTab:Ce,isOpen:!!(r&&tr(r,ie).isOpen&&Ce)&&!Ne}};return{left:R("left"),right:R("right"),bottom:R("bottom")}},[F,r,u]),A={left:{..._.left,activeTab:Mr(_.left.activeTab,_.left.isOpen)},right:{..._.right,activeTab:Mr(_.right.activeTab,_.right.isOpen)},bottom:{..._.bottom,activeTab:Mr(_.bottom.activeTab,_.bottom.isOpen)}},M={left:qo(A.left.isOpen),right:qo(A.right.isOpen),bottom:qo(A.bottom.isOpen)},S=R=>!M[R],k={left:Yn(A.left.isOpen),right:Yn(A.right.isOpen),bottom:Yn(A.bottom.isOpen)},C={left:Dr(A.left.isOpen,k.left,A.left.activeTab?.mode),right:Dr(A.right.isOpen,k.right,A.right.activeTab?.mode),bottom:Dr(A.bottom.isOpen,k.bottom,A.bottom.activeTab?.mode)},y=R=>{const ie=ei(u,R);return{zone:ie,...A[ie]}},E=y("file"),B=y("chat"),$=y("browser"),O=y("diff"),z=y("terminal"),J=y("walkthrough"),[K,ee]=c.useState([]),V=c.useCallback((R,ie)=>{ee(Ce=>lf(Ce,Cn(R,ie)))},[]),Y=G(R=>R.liveBrowserTabLimit);c.useEffect(()=>N0((R,ie)=>{const Ce=ie.directory?fs(ie.directory):n;if(!Ce)return null;const Ne=h(Ce,R,ie.sessionId);return Ne&&V(Ce,Ne),Ne}),[n,h,V]),c.useEffect(()=>E0((R,ie)=>G.getState().contextPanelByDirectory[R]?.tabs?.some(Ne=>Ne.id===ie&&Ne.mode==="browser")?(f(R,ie),!0):!1),[f]),c.useEffect(()=>tn(R=>{if(R.type!=="file-open-request")return;const ie=R.directory??e;ie&&x(ie,R.path)}),[e,x]),c.useEffect(()=>tn(R=>{if(R.type!=="plan-open-request")return;const ie=R.directory??e,Ce=op(ie,R.projectId);!ie||!Ce||G.getState().openProjectKnowledgePlan(ie,kg(Ce),R.planId)}),[e]);const ae=_[$.zone].activeTab,P=ae?.mode==="browser"?ae.id:null;c.useEffect(()=>{T0(n,P)},[n,P]);const de=_[E.zone].activeTab;c.useEffect(()=>{if(!d||de?.mode!=="file"||!de.targetPath)return;const R=ks(de.targetPath)===ks(d);j(fs(d),de.targetPath,{allowOutsideRoot:!o&&R})},[d,o,de,j]);const q=c.useMemo(()=>T.some(R=>R.mode==="file"&&R.targetPath),[T]),Q=c.useMemo(()=>T.some(R=>R.mode==="file"),[T]),L=q&&(b||!g),ne=E.activeTab?.mode==="file",W=c.useCallback(R=>{n&&m(n,R)},[m,n]),te=B.isOpen&&B.activeTab?.mode==="chat"?B.activeTab:null,Z=te?yo(te.dedupeKey):null,me=c.useMemo(()=>(te?.targetDirectory?fs(te.targetDirectory):"")||n||null,[te?.targetDirectory,n]),Ie=c.useMemo(()=>Z?{sessionId:Z,directory:me}:null,[Z,me]);c.useEffect(()=>{if(!me||!Z||typeof window>"u")return;const R=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Mo(me,Z,!1);return}ed(Z),Mo(me,Z,!0)};R();const ie=window.setInterval(R,1e4);return window.addEventListener("focus",R),window.addEventListener("blur",R),document.addEventListener("visibilitychange",R),()=>{window.clearInterval(ie),window.removeEventListener("focus",R),window.removeEventListener("blur",R),document.removeEventListener("visibilitychange",R),Mo(me,Z,!1)}},[me,Z]);const fe=O.activeTab,je=c.useCallback(R=>{!n||fe?.mode!=="diff"||p(n,{mode:"diff",targetPath:fe.targetPath,targetDirectory:fe.targetDirectory,stagedDiff:R==="staged",diffScope:R})},[fe,n,p]),$e=$.isOpen&&$.activeTab?.mode==="browser"?$.activeTab.id:null;c.useEffect(()=>{$e&&n&&V(n,$e)},[n,$e,V]);const{loadedBrowserTabs:Re,sleepingBrowserTabs:Fe}=c.useMemo(()=>{const R=new Set(K),ie=new Set;for(const[qe,Ue]of Object.entries(l))for(const tt of Ue.tabs)tt.mode==="browser"&&tt.ownerSessionId===null&&ie.add(Cn(qe,tt.id));const Ce=cf(K,ie,Y),Ne=[],ze=[];for(const[qe,Ue]of Object.entries(l)){const tt=qe===n;for(const He of Ue.tabs){if(He.mode!=="browser")continue;const Ze=Cn(qe,He.id),Qe=He.ownerSessionId===null,ot=tt&&He.id===$e||(Qe?Ce.has(Ze):R.has(Ze));if(!ot&&!tt&&Qe)continue;const pt={directory:qe,id:He.id,targetPath:He.targetPath,ownerSessionId:He.ownerSessionId};(ot?Ne:ze).push(pt)}}return Ne.sort((qe,Ue)=>Cn(qe.directory,qe.id)<Cn(Ue.directory,Ue.id)?-1:1),{loadedBrowserTabs:Ne,sleepingBrowserTabs:ze}},[l,n,Y,K,$e]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const R=Fe.map(ie=>C0({tabId:ie.id,directory:ie.directory,ownerSessionId:ie.ownerSessionId,describe:()=>({title:"",url:ie.targetPath??""}),wake:()=>V(ie.directory,ie.id)}));return()=>R.forEach(ie=>ie())},[Fe,V]);const Ve=c.useMemo(()=>T.filter(R=>R.mode==="diff"),[T]),De=c.useMemo(()=>T.find(R=>R.mode==="terminal")??null,[T]),ge=c.useMemo(()=>T.find(R=>R.mode==="walkthrough")??null,[T]),xe=c.useMemo(()=>T.filter(R=>_n(R.mode)),[T]),Se=sr(R=>R.guests),Be=c.useMemo(()=>new Set(Se.filter(jg).map(R=>R.id)),[Se]),Pe=c.useMemo(()=>{const R=new Map;for(const ie of Se){const Ce=Cg(ie);Ce&&R.set(ie.id,Ce)}return R},[Se]),Me=z.zone,Je=c.useCallback(R=>{const ie=Qi({mode:"terminal",label:t("layout.mainTab.terminal"),from:Me},R);return{finish:()=>ie.finish(n),cancel:ie.cancel}},[n,t,Me]),X=(R,ie)=>ie?v[R]:null,[Ee,_e]=c.useState(()=>new Set),pe=xe.filter(R=>{if(Ee.has(R.id))return!1;const ie=y(R.mode);return ie.isOpen&&ie.activeTab?.id===R.id});return pe.length>0&&_e(new Set([...Ee,...pe.map(R=>R.id)])),s.jsxs(s.Fragment,{children:[Q?s.jsxs(dn,{zone:E.zone,interactive:C[E.zone],isOpen:E.isOpen,hidden:S(E.zone),className:We("absolute inset-0 flex",w==="left"&&"flex-row-reverse",ne?"flex":"hidden"),children:[i?s.jsx("div",{className:"h-full min-w-0 flex-1",children:s.jsx(_r,{})}):q||!g?s.jsx("div",{className:We("h-full min-w-0 flex-1",q&&!L&&"hidden"),children:q?s.jsx(c.Suspense,{fallback:null,children:s.jsx(P2,{mode:"editor-only",visible:!S(E.zone)&&ne&&L,onCloseFile:W})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(oe,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,i?null:s.jsx(D2,{visible:g,active:E.isOpen&&ne,fill:!L,side:w})]}):null,te&&Z&&Ie?s.jsx(dn,{zone:B.zone,interactive:C[B.zone],isOpen:B.isOpen,hidden:S(B.zone),className:"absolute inset-0 bg-background",children:s.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:Z}),className:"h-full",children:s.jsx(vc,{pinnedSession:Ie,readOnly:te.readOnly})})},te.id):null,Re.map(R=>{const ie=R.directory===n&&$.activeTab?.id===R.id,Ce=R.directory===n?a??R.directory:R.directory;return s.jsx(dn,{zone:$.zone,interactive:C[$.zone],isOpen:$.isOpen,hidden:S($.zone),className:We("absolute inset-0",!ie&&"invisible pointer-events-none"),children:s.jsx("div",{className:"h-full","aria-hidden":!ie||void 0,children:s.jsx(Qc,{paused:!ie,children:R.directory===n&&i?s.jsx(_r,{}):s.jsx(QS,{initialUrl:R.targetPath??"",directory:R.directory,siteDirectory:Ce,tabID:R.id,ownerSessionId:R.ownerSessionId,visible:ie&&$.isOpen},Ce)})})},Cn(R.directory,R.id))}),Ve.map(R=>{const ie=O.activeTab?.id===R.id;return s.jsx(dn,{zone:O.zone,interactive:C[O.zone],isOpen:O.isOpen,hidden:S(O.zone),className:We("absolute inset-0",!ie&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(fn,{value:X(O.zone,ie),children:i&&!R.targetDirectory?s.jsx(_r,{}):s.jsx(I2,{directory:R.targetDirectory??a,visible:O.isOpen&&ie,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:R.diffScope??(R.stagedDiff?"staged":null),onDiffScopeChange:je,targetFilePath:R.targetPath,flushContent:!0})})})},R.id)}),De?s.jsx(dn,{zone:z.zone,interactive:C[z.zone],isOpen:z.isOpen,hidden:S(z.zone),className:We("absolute inset-0",z.activeTab?.mode==="terminal"?"block":"hidden"),children:s.jsx(fn,{value:X(z.zone,z.activeTab?.mode==="terminal"),children:s.jsx(ip.Provider,{value:Je,children:s.jsx(ap,{visible:z.isOpen&&z.activeTab?.mode==="terminal",directory:De.targetDirectory,onLastTabClosed:()=>{n&&f(n,De.id)}})})})}):null,ge?s.jsx(dn,{zone:J.zone,interactive:C[J.zone],isOpen:J.isOpen,hidden:S(J.zone),className:We("absolute inset-0",J.activeTab?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(fn,{value:X(J.zone,J.activeTab?.mode==="walkthrough"),children:s.jsx(E2,{directory:ge.targetDirectory??e,visible:J.isOpen&&J.activeTab?.mode==="walkthrough"})})})}):null,xe.map(R=>{if(!_n(R.mode))return null;const ie=y(R.mode);if(!Ee.has(R.id))return null;const Ce=Ur(R.mode),Ne=Be.has(Ce),ze=Pe.get(Ce),qe=ie.activeTab?.id===R.id,Ue=qe&&ie.isOpen;return Ne&&!ze&&!Ue?null:s.jsx(dn,{zone:ie.zone,interactive:C[ie.zone],isOpen:ie.isOpen,hidden:S(ie.zone),className:We("absolute inset-0",qe?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ne?ze?s.jsxs("div",{className:We("flex h-full",Su[ze.dock].container),children:[s.jsx(R2,{mode:R.mode,docking:ze}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ue?s.jsx(Rl,{mode:R.mode}):null})]}):s.jsx(Rl,{mode:R.mode}):s.jsx(vu,{mode:R.mode})})},R.id)})]})},A2={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},O2=()=>{const t=Le.c(20),{t:e}=rt(),n=Gs(M2),r=Gs(F2),o=c.useRef(null),[i,a]=c.useState(!1);let d,u;t[0]!==n?(d=()=>{if(!n){a(!1);return}const w=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(w)},u=[n],t[0]=n,t[1]=d,t[2]=u):(d=t[1],u=t[2]),c.useEffect(d,u);let l,f;if(t[3]!==n?(l=()=>{if(!n)return;const w=j=>{const v=o.current;v&&(v.style.transform=`translate(${j.clientX+12}px, ${j.clientY+12}px)`)};return window.addEventListener("pointermove",w),()=>window.removeEventListener("pointermove",w)},f=[n],t[3]=n,t[4]=l,t[5]=f):(l=t[4],f=t[5]),c.useEffect(l,f),!n)return null;const m=i?"opacity-100":"opacity-0";let p;t[6]!==m?(p=We("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=s.jsx("div",{className:p}),t[8]=p,t[9]=h):h=t[9];let x;t[10]!==n.frames||t[11]!==r||t[12]!==e?(x=Ri.map(w=>{const j=n.frames[w];if(j.width<=0||j.height<=0)return null;const v=r===w;return s.jsx("div",{className:We("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",v?"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:s.jsx("span",{className:"typography-ui-label",children:e(A2[w])})},w)}),t[10]=n.frames,t[11]=r,t[12]=e,t[13]=x):x=t[13];let g;t[14]!==n.label?(g=s.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:n.label}),t[14]=n.label,t[15]=g):g=t[15];let b;return t[16]!==h||t[17]!==x||t[18]!==g?(b=Zl.createPortal(s.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[h,x,g]}),document.body),t[16]=h,t[17]=x,t[18]=g,t[19]=b):b=t[19],b};function M2(t){return t.drag}function F2(t){return t.hovered}const Dl=320,L2=({rowWidth:t,leftWidth:e,rightWidth:n,sidebarWidth:r,opening:o})=>{let i=t-e-n;if(i>=Dl)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Dl)return{collapseSidebar:a,displace:null};const d=o==="left"?"right":"left";return{collapseSidebar:a,displace:(d==="left"?e:n)>0?d:null}},$2=({directoryKey:t,folded:e,readRowWidth:n})=>{const r=b=>{const w=b.contextPanelByDirectory[t];return{left:Gn(w,b.contextSurfaceZones,"left"),right:Gn(w,b.contextSurfaceZones,"right")}},o=(b,w,j)=>{const v=b.contextPanelByDirectory[t];return(j&&v?Wr(v,b.contextSurfaceZones,w):null)?b.contextZoneSizes[w]??Pi:0},i=b=>{const w=b.contextPanelByDirectory[t];return w?Ri.some(j=>tr(w,j).expanded&&df(w,b,j)):!1};let a=null,d=!1,u=r(G.getState()),l=i(G.getState());const f=b=>{e.current=b,G.getState().setSidebarFoldedForExpandedZone(b==="expanded")},m=b=>{d=!0,G.getState().setSidebarOpen(b),d=!1},p=()=>{f(null),G.getState().isSidebarOpen||m(!0)};!e.current&&G.getState().sidebarFoldedForExpandedZone&&(e.current="expanded");const h=e.current;h&&!(h==="expanded"?l:u[h])&&p(),!e.current&&l&&G.getState().isSidebarOpen&&(f("expanded"),m(!1));const x=(b,w,j)=>{const v=n();if(!v)return;const T=e.current==="expanded",F=L2({rowWidth:T?v-b.sidebarWidth:v,leftWidth:o(b,"left",j.left),rightWidth:o(b,"right",j.right),sidebarWidth:b.isSidebarOpen||T?b.sidebarWidth:null,opening:w});if(F.displace){const _=tr(b.contextPanelByDirectory[t],F.displace).activeTabId;_&&(a={side:F.displace,by:w,tabId:_})}F.collapseSidebar&&(f(w),b.isSidebarOpen&&m(!1)),F.displace&&b.closeContextZone(t,F.displace)},g=b=>{if(a?.side===b){e.current===b&&f(a.by);return}const w=a?.by===b?a:null;w&&(a=null),e.current===b&&(w?f(w.side):p()),w&&G.getState().setActiveContextPanelTab(t,w.tabId)};return G.subscribe((b,w)=>{b.isSidebarOpen!==w.isSidebarOpen&&!d&&f(null);const j=r(b),v=i(b),T=u,F=l;u=j,l=v;const _=["left","right"],A=_.filter(S=>j[S]&&!T[S]),M=_.filter(S=>!j[S]&&T[S]);for(const S of M){const k=S==="left"?"right":"left";A.includes(k)&&(e.current===S&&f(k),a?.by===S&&(a=null))}for(const S of M)g(S);for(const S of A)x(b,S,j);v&&!F&&b.isSidebarOpen?(f("expanded"),m(!1)):!v&&F&&e.current==="expanded"&&p()})},B2=()=>{const t=Le.c(5),e=Zs();let n;t[0]!==e?(n=e?fs(e):"",t[0]=e,t[1]=n):n=t[1];const r=n,o=c.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(r)return $2({directoryKey:r,folded:o,readRowWidth:z2})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),c.useEffect(i,a),null};function z2(){return document.querySelector("[data-workspace-row]")?.clientWidth}const W2=t=>{const e=Le.c(54),{open:n,onOpenChange:r}=t,{t:o}=rt(),i=G(U2),a=G(V2),d=G(H2),u=G(q2),l=G(K2),f=Ki(),m=G(Ng);let p;if(e[0]!==i||e[1]!==f||e[2]!==m){let K;e[4]!==m?(K=ee=>m||ee.id!=="workflows",e[4]=m,e[5]=K):K=e[5],p=si(i,f).filter(K),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 K;e[9]!==d?(K=ee=>d.includes(ee.id),e[9]=d,e[10]=K):K=e[10],g=h.every(K),e[6]=d,e[7]=h,e[8]=g}else g=e[8];const b=g,w=c.useRef(!1);let j;e[11]!==d||e[12]!==h||e[13]!==o?(j=h.map((K,ee)=>({id:K.id,label:K.label??o(K.labelKey),visible:!d.includes(K.id),groupStart:ee>0&&Js(h[ee-1])!==Js(K)})),e[11]=d,e[12]=h,e[13]=o,e[14]=j):j=e[14];const v=j;let T;e[15]!==i||e[16]!==f||e[17]!==a?(T=K=>{const ee=si(K,f).map(G2).filter(Y=>K.includes(Y)),V=new Set(ee);a([...ee,...i.filter(Y=>!V.has(Y))])},e[15]=i,e[16]=f,e[17]=a,e[18]=T):T=e[18];const F=T;let _;e[19]!==r?(_=(K,ee)=>{if(!K&&ee.reason==="escape-key"&&w.current){ee.cancel(),ee.allowPropagation();return}w.current=!1,r(K)},e[19]=r,e[20]=_):_=e[20];let A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=K=>{w.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(K.key)&&K.preventBaseUIHandler()},e[21]=A):A=e[21];let M;e[22]!==o?(M=o("contextRail.configure.dialogTitle"),e[22]=o,e[23]=M):M=e[23];let S;e[24]!==M?(S=s.jsx(ir,{children:M}),e[24]=M,e[25]=S):S=e[25];let k;e[26]!==o?(k=o("contextRail.configure.dialogDescription"),e[26]=o,e[27]=k):k=e[27];let C;e[28]!==k?(C=s.jsx(ar,{children:k}),e[28]=k,e[29]=C):C=e[29];let y;e[30]!==C||e[31]!==S?(y=s.jsxs(or,{children:[S,C]}),e[30]=C,e[31]=S,e[32]=y):y=e[32];let E;e[33]!==o?(E=o("contextRail.configure.dragInstructions"),e[33]=o,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=K=>{w.current=K},e[35]=B):B=e[35];let $;e[36]!==F||e[37]!==v||e[38]!==u||e[39]!==E?($=s.jsx(cp,{items:v,onVisibleChange:u,onReorder:F,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:E,onDraggingChange:B}),e[36]=F,e[37]=v,e[38]=u,e[39]=E,e[40]=$):$=e[40];let O;e[41]!==x||e[42]!==b||e[43]!==l||e[44]!==o?(O=x?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ft,{variant:"link",size:"xs",onClick:()=>l([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[41]=x,e[42]=b,e[43]=l,e[44]=o,e[45]=O):O=e[45];let z;e[46]!==y||e[47]!==$||e[48]!==O?(z=s.jsxs(rr,{className:"max-w-md",onKeyDown:A,children:[y,$,O]}),e[46]=y,e[47]=$,e[48]=O,e[49]=z):z=e[49];let J;return e[50]!==n||e[51]!==z||e[52]!==_?(J=s.jsx(nr,{open:n,onOpenChange:_,children:z}),e[50]=n,e[51]=z,e[52]=_,e[53]=J):J=e[53],J};function U2(t){return t.contextRailOrder}function V2(t){return t.setContextRailOrder}function H2(t){return t.contextRailHiddenSurfaces}function q2(t){return t.setContextRailSurfaceVisible}function K2(t){return t.setContextRailHiddenSurfaces}function G2(t){return t.id}const ku=150,Z2=500,X2=[],Y2=t=>{const e=Le.c(70),{surface:n,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:d,badgeAriaLabel:u,badgeDescription:l,orderNumber:f,showOrderNumber:m,onSelect:p}=t,h=G(ek);let x;e[0]!==h?(x=Ai("switch_context_surface",h),e[0]=h,e[1]=x):x=e[1];const g=x;let b;e[2]!==f||e[3]!==g?(b=g&&g!==kc&&f!=null&&f<=10?ms(`${g}+${f===10?"0":f}`):void 0,e[2]=f,e[3]=g,e[4]=b):b=e[4];const w=b;let j;e[5]!==n.id?(j={id:n.id},e[5]=n.id,e[6]=j):j=e[6];const{attributes:v,listeners:T,setNodeRef:F,transform:_,transition:A,isDragging:M}=vd(j),S=d!=null&&d>0;let k;e[7]!==_?(k=kd.Translate.toString(_),e[7]=_,e[8]=k):k=e[8];let C;e[9]!==k||e[10]!==A?(C={transform:k,transition:A},e[9]=k,e[10]=A,e[11]=C):C=e[11];const y=M&&"z-10 opacity-70";let E;e[12]!==y?(E=We("relative",y),e[12]=y,e[13]=E):E=e[13];let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{}),e[14]=B):B=e[14];let $;e[15]!==p||e[16]!==n?($=()=>p(n),e[15]=p,e[16]=n,e[17]=$):$=e[17];const O=u??i,z=n.id,J=r?"text-primary":"text-muted-foreground hover:text-foreground";let K;e[18]!==J?(K=We("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",J),e[18]=J,e[19]=K):K=e[19];let ee;e[20]!==n.icon||e[21]!==n.iconSrc||e[22]!==n.id?(ee=n.id==="diff"?s.jsx(wc,{className:"h-[17px] w-[17px]"}):s.jsx(fo,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[17px] w-[17px]"}),e[20]=n.icon,e[21]=n.iconSrc,e[22]=n.id,e[23]=ee):ee=e[23];let V;e[24]!==S||e[25]!==f||e[26]!==o||e[27]!==m?(V=m&&f!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:f===10?"0":f}):S?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):o?s.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[24]=S,e[25]=f,e[26]=o,e[27]=m,e[28]=V):V=e[28];let Y;e[29]!==v||e[30]!==r||e[31]!==T||e[32]!==n.id||e[33]!==O||e[34]!==K||e[35]!==ee||e[36]!==V||e[37]!==$?(Y=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...v,...T,onClick:$,"aria-label":O,"aria-pressed":r,"data-context-surface":z,className:K,children:[ee,V]})}),e[29]=v,e[30]=r,e[31]=T,e[32]=n.id,e[33]=O,e[34]=K,e[35]=ee,e[36]=V,e[37]=$,e[38]=Y):Y=e[38];let ae;e[39]!==h||e[40]!==n.id||e[41]!==w?(ae=n.id==="terminal"?ms(Ts("toggle_terminal",h),""):w,e[39]=h,e[40]=n.id,e[41]=w,e[42]=ae):ae=e[42];let P;e[43]!==i||e[44]!==ae?(P=s.jsx(Ks,{label:i,shortcut:ae}),e[43]=i,e[44]=ae,e[45]=P):P=e[45];let de;e[46]!==a?(de=s.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[46]=a,e[47]=de):de=e[47];let q;e[48]!==l?(q=l?s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null,e[48]=l,e[49]=q):q=e[49];let Q;e[50]!==n.id?(Q=n.id==="context"?s.jsx(Nd,{}):null,e[50]=n.id,e[51]=Q):Q=e[51];let L;e[52]!==P||e[53]!==de||e[54]!==q||e[55]!==Q?(L=s.jsx(jt,{side:"left",sideOffset:8,className:"max-w-72 break-words",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[P,de,q,Q]})}),e[52]=P,e[53]=de,e[54]=q,e[55]=Q,e[56]=L):L=e[56];let ne;e[57]!==Y||e[58]!==L?(ne=s.jsx(ao,{render:B,children:s.jsxs(kt,{delayDuration:ku,children:[Y,L]})}),e[57]=Y,e[58]=L,e[59]=ne):ne=e[59];let W;e[60]!==n.mode?(W=s.jsx(lo,{children:s.jsx(bc,{mode:n.mode})}),e[60]=n.mode,e[61]=W):W=e[61];let te;e[62]!==ne||e[63]!==W?(te=s.jsxs(br,{children:[ne,W]}),e[62]=ne,e[63]=W,e[64]=te):te=e[64];let Z;return e[65]!==F||e[66]!==te||e[67]!==C||e[68]!==E?(Z=s.jsx("div",{ref:F,style:C,className:E,children:te}),e[65]=F,e[66]=te,e[67]=C,e[68]=E,e[69]=Z):Z=e[69],Z},J2=t=>{if(!t)return{icon:"ticket-2"};const e=Dg(t,"line");return e?{icon:e}:{icon:_g,iconSrc:Ag(t)}},Q2=()=>{const t=Le.c(122),{t:e}=rt(),n=Zs();let r;t[0]!==n?(r=n?fs(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Oe=>o?Oe.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=G(i),d=G(tk),u=G(sk),l=G(nk),f=G(rk),m=G(ok),p=G(ik),h=G(ak),x=G(lk),g=uf();let b;t[4]!==g?(b=Oe=>g.some(se=>se.instances.defaultInstance!==null&&Oe.entries[Hn({provider:se.id,instance:se.instances.defaultInstance})]?.hasChecked===!0),t[4]=g,t[5]=b):b=t[5];const w=hn(b),j=hn(dk),v=Eg(o||null),T=Ii(v==="none"?null:v??g[0]?.id),F=v==="none"?"pullRequest":T.terminology.changeRequest,{screenWidth:_}=wn(),A=yr(),M=n??null;let S;t[6]!==A||t[7]!==M?(S=uo(A,M),t[6]=A,t[7]=M,t[8]=S):S=t[8];const k=S,C=Ig(k),y=po(C),{git:E}=Es(),B=Mn(uk),$=Mn(fk);let O,z;t[9]!==B||t[10]!==$||t[11]!==E||t[12]!==C||t[13]!==k?(O=()=>{if(!E||!k||!C||C===k)return;la(()=>B(C,E));const Oe=Yt(k),se=Yt(C);return cr.onGitRefreshHint(ue=>{const et=Yt(ue.directory);et!==Oe&&et!==se||la(()=>$(C,E,{silent:!0}))})},z=[B,$,E,C,k],t[9]=B,t[10]=$,t[11]=E,t[12]=C,t[13]=k,t[14]=O,t[15]=z):(O=t[14],z=t[15]),c.useEffect(O,z);let J;t[16]!==x?(J=Ai("switch_context_surface",x),t[16]=x,t[17]=J):J=t[17];const K=J,[ee,V]=c.useState(!1);let Y,ae;t[18]!==K?(ae=()=>{const Oe=new Set;let se=null,ue=!1;const et=pk,ye=()=>{Aa(K,Oe)?!ue&&se===null&&(se=setTimeout(()=>V(!0),Z2)):(ue=!1,se!==null&&(clearTimeout(se),se=null),V(!1))},bt=Pt=>{if(Oe.add(Pt.key.toLowerCase()),et(Pt.key)&&Aa(K,Oe)){ue=!0,se!==null&&(clearTimeout(se),se=null),V(!1);return}ye()},Tt=Pt=>{Oe.delete(Pt.key.toLowerCase()),ye()},vt=()=>{Oe.clear(),ue=!1,se!==null&&(clearTimeout(se),se=null),V(!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),se!==null&&clearTimeout(se)}},Y=[K],t[18]=K,t[19]=Y,t[20]=ae):(Y=t[19],ae=t[20]),c.useEffect(ae,Y);let P;t[21]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},t[21]=P):P=t[21];let de;t[22]===Symbol.for("react.memo_cache_sentinel")?(de={activationConstraint:{delay:200,tolerance:6}},t[22]=de):de=t[22];const q=xd(Gr(wd,P),Gr(bd,de)),Q=Ki(),L=_a(mk),ne=_a(hk),W=a?.tabs??X2,te=Pg(W,n||null);let Z;t[23]!==h||t[24]!==a?(Z=Ti(a,h),t[23]=h,t[24]=a,t[25]=Z):Z=t[25];const me=Z,Ie=y?.files.length??0;let fe;if(t[26]!==l||t[27]!==u||t[28]!==Q||t[29]!==v||t[30]!==_||t[31]!==j||t[32]!==W||t[33]!==T||t[34]!==te){let Oe;t[36]!==v||t[37]!==T?(Oe=se=>se.id==="pr"?{...se,...J2(v==="none"?null:T)}:se,t[36]=v,t[37]=T,t[38]=Oe):Oe=t[38],fe=Rg({railOrder:u,hiddenSurfaces:l,isVSCode:Ni(),screenWidth:_,tabs:W,sourceControlConnected:j,workflowsShown:te,extras:Q}).map(Oe),t[26]=l,t[27]=u,t[28]=Q,t[29]=v,t[30]=_,t[31]=j,t[32]=W,t[33]=T,t[34]=te,t[35]=fe}else fe=t[35];const je=fe;let $e;t[39]!==W?($e=W.some(gk),t[39]=W,t[40]=$e):$e=t[40];const Re=$e;let Fe,Ve;t[41]!==p||t[42]!==h||t[43]!==w||t[44]!==o||t[45]!==Re||t[46]!==me||t[47]!==j?(Fe=()=>{!o||!w||j||Re||!me.has("pr")||p(o,ei(h,"pr"))},Ve=[p,h,o,w,Re,me,j],t[41]=p,t[42]=h,t[43]=w,t[44]=o,t[45]=Re,t[46]=me,t[47]=j,t[48]=Fe,t[49]=Ve):(Fe=t[48],Ve=t[49]),c.useEffect(Fe,Ve);const[De,ge]=c.useState(!1),xe=c.useRef(null),Se=c.useRef(null);let Be;t[50]!==F||t[51]!==je||t[52]!==e?(Be=Oe=>{const se=je.find(et=>et.id===Oe.active.id),ue=xe.current?.getBoundingClientRect().left;!se||ue===void 0||(Se.current?.cancel(),Se.current=Qi({mode:se.mode,label:se.label??e(Vs(se.labelKey,F)),from:ei(G.getState().contextSurfaceZones,se.mode)},et=>et.x<ue-16))},t[50]=F,t[51]=je,t[52]=e,t[53]=Be):Be=t[53];const Pe=Be;let Me;t[54]===Symbol.for("react.memo_cache_sentinel")?(Me=()=>{Se.current?.cancel(),Se.current=null},t[54]=Me):Me=t[54];const Je=Me;let X,Ee;t[55]===Symbol.for("react.memo_cache_sentinel")?(X=()=>()=>Se.current?.cancel(),Ee=[],t[55]=X,t[56]=Ee):(X=t[55],Ee=t[56]),c.useEffect(X,Ee);let _e;t[57]!==o||t[58]!==Q||t[59]!==f?(_e=Oe=>{const se=Se.current;if(Se.current=null,se?.finish(o))return;const{active:ue,over:et}=Oe;if(!et||ue.id===et.id)return;const ye=si(G.getState().contextRailOrder,Q),bt=Ke=>{const ct=ye.find(Rt=>Rt.id===Ke);return ct?Js(ct):null};if(bt(ue.id)!==bt(et.id))return;const Tt=ye.map(xk),vt=Tt.indexOf(ue.id),Pt=Tt.indexOf(et.id);vt===-1||Pt===-1||f(tx(Tt,vt,Pt))},t[57]=o,t[58]=Q,t[59]=f,t[60]=_e):_e=t[60];const pe=_e;let R;if(t[61]!==je){R=[];for(const Oe of je){const se=R.at(-1);se&&Js(se[0])===Js(Oe)?se.push(Oe):R.push([Oe])}t[61]=je,t[62]=R}else R=t[62];const ie=R;let Ce;t[63]!==je?(Ce=Oe=>{const se=je.find(et=>et.id===Oe.active.id);if(!se)return ii(Oe);const ue=Js(se);return ii({...Oe,droppableContainers:Oe.droppableContainers.filter(et=>{const ye=je.find(bt=>bt.id===et.id);return ye!==void 0&&Js(ye)===ue})})},t[63]=je,t[64]=Ce):Ce=t[64];const Ne=Ce;if(!o)return null;let ze,qe,Ue,tt,He,Ze,Qe,ot,pt,at;if(t[65]!==F||t[66]!==Ie||t[67]!==ne||t[68]!==Ne||t[69]!==o||t[70]!==ie||t[71]!==L||t[72]!==pe||t[73]!==Pe||t[74]!==m||t[75]!==ee||t[76]!==q||t[77]!==me||t[78]!==e||t[79]!==d){let Oe=0;ot=xe,t[90]!==e?(pt=e("contextRail.aria.rail"),t[90]=e,t[91]=pt):pt=t[91],at="flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",ze=yd,qe=q,Ue=Ne,tt=Pe,He=Je,Ze=pe,Qe=ie.map((se,ue)=>s.jsxs(c.Fragment,{children:[ue>0?s.jsx("div",{"aria-hidden":"true",className:"h-px w-4 shrink-0 bg-edge-strong"}):null,s.jsx(Sd,{items:se.map(bk),strategy:ex,children:se.map(et=>{Oe=Oe+1;const ye=et.label??e(Vs(et.labelKey,F)),bt=et.id==="git"&&!d?Ie:0,Tt=_n(et.mode)&&!me.has(et.mode)?L[Ur(et.mode)]??0:0,vt=bt>0?bt:Tt>0?Tt:null,Pt=vt!==null&&bt===0;return s.jsx(Y2,{surface:et,isActive:me.has(et.mode),showActivityDot:!1,label:ye,description:e(Vs(et.descriptionKey,F)),badgeCount:vt,badgeAriaLabel:vt!==null?e(Pt?vt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":vt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ye,count:vt}):null,badgeDescription:vt!==null?e(Pt?vt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":vt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:vt}):null,orderNumber:Oe,showOrderNumber:ee,onSelect:Ke=>{_n(Ke.mode)&&ne(Ur(Ke.mode)),m(o,Ke.mode)}},et.id)})})]},Js(se[0]))),t[65]=F,t[66]=Ie,t[67]=ne,t[68]=Ne,t[69]=o,t[70]=ie,t[71]=L,t[72]=pe,t[73]=Pe,t[74]=m,t[75]=ee,t[76]=q,t[77]=me,t[78]=e,t[79]=d,t[80]=ze,t[81]=qe,t[82]=Ue,t[83]=tt,t[84]=He,t[85]=Ze,t[86]=Qe,t[87]=ot,t[88]=pt,t[89]=at}else ze=t[80],qe=t[81],Ue=t[82],tt=t[83],He=t[84],Ze=t[85],Qe=t[86],ot=t[87],pt=t[88],at=t[89];let xt;t[92]!==ze||t[93]!==qe||t[94]!==Ue||t[95]!==tt||t[96]!==He||t[97]!==Ze||t[98]!==Qe?(xt=s.jsx(ze,{sensors:qe,collisionDetection:Ue,onDragStart:tt,onDragCancel:He,onDragEnd:Ze,children:Qe}),t[92]=ze,t[93]=qe,t[94]=Ue,t[95]=tt,t[96]=He,t[97]=Ze,t[98]=Qe,t[99]=xt):xt=t[99];let le;t[100]!==e?(le=e("contextRail.configure.open"),t[100]=e,t[101]=le):le=t[101];let be;t[102]===Symbol.for("react.memo_cache_sentinel")?(be=()=>ge(!0),t[102]=be):be=t[102];let Ae;t[103]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(oe,{name:"equalizer-2",className:"h-[17px] w-[17px]"}),t[103]=Ae):Ae=t[103];let N;t[104]!==le?(N=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":le,onClick:be,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground",children:Ae})}),t[104]=le,t[105]=N):N=t[105];let ce;t[106]!==e?(ce=e("contextRail.configure.open"),t[106]=e,t[107]=ce):ce=t[107];let U;t[108]!==ce?(U=s.jsx(jt,{side:"left",sideOffset:8,children:ce}),t[108]=ce,t[109]=U):U=t[109];let we;t[110]!==N||t[111]!==U?(we=s.jsxs(kt,{delayDuration:ku,children:[N,U]}),t[110]=N,t[111]=U,t[112]=we):we=t[112];let ke;t[113]!==De?(ke=s.jsx(W2,{open:De,onOpenChange:ge}),t[113]=De,t[114]=ke):ke=t[114];let Xe;return t[115]!==ot||t[116]!==pt||t[117]!==at||t[118]!==xt||t[119]!==we||t[120]!==ke?(Xe=s.jsxs("nav",{ref:ot,"aria-label":pt,className:at,children:[xt,we,ke]}),t[115]=ot,t[116]=pt,t[117]=at,t[118]=xt,t[119]=we,t[120]=ke,t[121]=Xe):Xe=t[121],Xe};function ek(t){return t.shortcutOverrides}function tk(t){return t.workStatusPanelVisible}function sk(t){return t.contextRailOrder}function nk(t){return t.contextRailHiddenSurfaces}function rk(t){return t.setContextRailOrder}function ok(t){return t.openContextSurface}function ik(t){return t.closeContextZone}function ak(t){return t.contextSurfaceZones}function lk(t){return t.shortcutOverrides}function ck(t){return t.status?.status==="connected"}function dk(t){return Object.values(t.entries).some(ck)}function uk(t){return t.ensureStatus}function fk(t){return t.fetchStatus}function pk(t){return t.length===1&&t>="0"&&t<="9"}function mk(t){return t.countByGuest}function hk(t){return t.clearBadge}function gk(t){return t.mode==="pr"&&t.targetPath}function xk(t){return t.id}function bk(t){return t.id}const Fs=t=>t?s.jsx("span",{className:"oc-title-rest",children:t}):void 0,Ss=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},wk=()=>{const{t}=rt(),{git:e,sourceControl:n}=Es(),[r,o]=c.useState(!1),[i,a]=c.useState(null),[d,u]=c.useState([]),[l,f]=c.useState(!1),[m,p]=c.useState(!1),[h,x]=c.useState(!1),[g,b]=c.useState(!1),[w,j]=c.useState(new Set),v=st(X=>X.getWorktreeMetadata),T=st(X=>X.setNewSessionDraftTarget),F=st(X=>X.setDraftBootstrapPendingDirectory),_=Mg,A=Bg,M=st(X=>X.deleteSessions),S=st(X=>X.archiveSessions),k=st(X=>X.unarchiveSessions),C=G(X=>X.showDeletionDialog),y=G(X=>X.setShowDeletionDialog),E=Ht(X=>X.currentDirectory),B=Ht(X=>X.homeDirectory),$=ts(X=>X.projects),O=ts(X=>X.activeProjectId),{isMobile:z,isTablet:J,hasTouchInput:K}=wn(),ee=z||J||K,V=c.useMemo(()=>{const Ee=(O?$.find(_e=>_e.id===O)??null:null)?.path??E;return Ss(Ee)},[O,E,$]),Y=c.useCallback(X=>{const _e=Ss(X.projectDirectory)||V;return{id:($.find(R=>Ss(R.path)===_e)??null)?.id??`path:${_e}`,path:_e}},[V,$]),ae=g&&w.size>0,[P,de]=c.useState(!1),q=i?.mode==="worktree"?i.worktree??d[0]?.metadata??null:null,Q=q?.path,L=q?.branch,ne=q?Y(q).path:null;c.useEffect(()=>{if(de(!1),!Q||!ne)return;let X=!1;return Og(ne,{path:Q,branch:L??""}).then(Ee=>{X||de(Ee)}),()=>{X=!0}},[L,Q,ne]);const W=c.useMemo(()=>{if(!P)return!1;const X=i?.worktree;return X&&typeof X.branch=="string"&&X.branch.trim().length>0?!!X.status?.upstream?.split("/")[0]?.trim():d.length>0&&d.every(({metadata:Ee})=>typeof Ee.branch=="string"&&Ee.branch.trim().length>0&&!!Ee.status?.upstream?.split("/")[0]?.trim())},[P,i?.worktree,d]),te=i?.mode==="worktree",Z=h||!te||!W,me=h||!te,Ie=c.useCallback(X=>{a({sessions:X.sessions,dateLabel:X.dateLabel,mode:X.mode??"session",worktree:X.worktree??null})},[]),fe=c.useCallback(()=>{a(null),u([]),f(!1),p(!1),x(!1),b(!1),j(new Set)},[]),je=c.useCallback(async X=>{if(X.sessions.length===0)return;if(X.sessions.length===1){const R=X.sessions[0];await _(R.id)?Te.success(t("sessions.sidebar.session.delete.success")):Te.error(t("sessions.sidebar.session.delete.error"));return}const Ee=X.sessions.map(R=>R.id),{deletedIds:_e,failedIds:pe}=await M(Ee);if(_e.length>0){const R=pe.length>0?pe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:pe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:pe.length}):X.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:X.dateLabel}):void 0;Te.success(_e.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:_e.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:_e.length}),{description:Fs(R)})}pe.length>0&&Te.error(pe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:pe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:pe.length}),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[_,M,t]);c.useEffect(()=>cr.onDirectoryRequest(()=>{o(!0)}),[]),c.useEffect(()=>{if(!i){u([]),f(!1),p(!1),b(!1),j(new Set);return}const X=i.sessions.map(pe=>{const R=v(pe.id);return R?{session:pe,metadata:R}:null}).filter(pe=>!!pe);u(X),f(!1),b(!1),j(new Set);const Ee=new Map;if(i.worktree?.path&&Ee.set(Ss(i.worktree.path),i.worktree),X.forEach(({metadata:pe})=>{pe.path&&Ee.set(Ss(pe.path),pe)}),Ee.size===0){b(!0);return}let _e=!1;return(async()=>{const pe=new Map,R=new Set;await Promise.all(Array.from(Ee.entries()).map(async([ie,Ce])=>{try{const Ne=await Oa(Ce.path);pe.set(ie,Ne),Ne?.isDirty&&R.add(ie)}catch{Ce.status&&(pe.set(ie,Ce.status),Ce.status.isDirty&&R.add(ie))}})).catch(ie=>{console.warn("Failed to inspect worktree status before deletion:",ie)}),!_e&&(j(R),b(!0),a(ie=>{if(!ie?.worktree?.path)return ie;const Ce=Ss(ie.worktree.path),Ne=pe.get(Ce);if(!Ne)return ie;const ze=ie.worktree.status;return ze?.isDirty===Ne.isDirty&&ze?.ahead===Ne.ahead&&ze?.behind===Ne.behind&&ze?.upstream===Ne.upstream?ie:{...ie,worktree:{...ie.worktree,status:Ne}}}),u(ie=>ie.map(Ce=>{const Ne=Ss(Ce.metadata.path),ze=pe.get(Ne);return ze?{session:Ce.session,metadata:{...Ce.metadata,status:ze}}:Ce})))})(),()=>{_e=!0}},[i,v]),c.useEffect(()=>{W||f(!1)},[W]);const $e=c.useCallback(async(X,Ee,_e,pe)=>{const R=l&&W,ie=Y(X),Ce=Ss(X.path),Ne=Ss(ie.path);try{await Fg(ie,X,{deleteRemoteBranch:R,deleteLocalBranch:Ee,remoteName:X.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:n},skipTeardown:pe});const ze=tt=>!!(Ce&&tt&&Lg(Ce,tt)),qe=st.getState().newSessionDraft,Ue=Ss(qe?.directoryOverride);return qe?.open&&ze(Ue)&&Ne&&(F(null),T({projectId:ie.id,directoryOverride:Ne},{force:!0})),ze(Ss(Ht.getState().currentDirectory))&&Ne&&Ht.getState().setDirectory(Ne,{showOverlay:!1}),!0}catch(ze){if(ze instanceof Error&&$g(ze))throw ze;return Te.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:_e,description:Fs(ze instanceof Error?ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[W,l,Y,e,F,T,n,t]),Re=c.useCallback((X,Ee,_e)=>{const pe=l&&W,R=async(ie,Ce)=>{const Ne=Te.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Ma(X)}));Hg(X.path);try{const ze=await qg({sessionIds:Ce,removeWorktree:()=>$e(X,_e,Ne,ie),restoreSessions:Ue=>k(Ue,{undo:!0}),archiveSessions:async Ue=>Ue.length===1?await A(Ue[0])?{archivedIds:Ue,failedIds:[]}:{archivedIds:[],failedIds:Ue}:S(Ue)});if(!ze.removed)return;Ec(Ce,{projectId:Y(X).id}),Te.success(t(pe?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed"),{id:Ne,description:Fs(Ma(X))});const{failedIds:qe}=ze.archive;qe.length>0&&Te.error(qe.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:qe.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:qe.length}),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(ze){Te.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Ne,description:Fs(ze instanceof Error?ze.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain")),...ze instanceof Error?Kg(ze,t("sessions.sidebar.sessionDialogs.worktree.deleteWithoutTeardown"),()=>{R(!0,Gg(Ce,X.path))}):void 0})}finally{Zg(X.path)}};return R(!1,Ee)},[A,S,W,l,Y,$e,t,k]),Fe=c.useRef(new Set),Ve=c.useCallback(async(X,Ee)=>{const _e=Ss(X.path);if(!Fe.current.has(_e)){Fe.current.add(_e);try{const pe=await Oa(X.path).catch(()=>{});if(!zg(pe)){Ie({sessions:Ee,mode:"worktree",worktree:X});return}await Re(X,Ee.map(R=>R.id),!0)}finally{Fe.current.delete(_e)}}},[Ie,Re]);c.useEffect(()=>cr.onDeleteRequest(X=>{if(!C&&(X.mode??"session")==="session"){je(X);return}if(X.mode==="worktree"&&X.skipDialogIfSafe&&X.worktree){Ve(X.worktree,X.sessions);return}Ie(X)}),[Ie,C,je,Ve]);const De=c.useCallback(async()=>{if(i){x(!0);try{if(te){const X=i.worktree??d[0]?.metadata;if(!X){Te.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),x(!1);return}Re(X,i.sessions.map(Ee=>Ee.id),m&&P),fe();return}if(i.sessions.length===1){const X=i.sessions[0];if(!await _(X.id)){Te.error(t("sessions.sidebar.session.delete.error")),x(!1);return}Te.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const X=i.sessions.map(pe=>pe.id),{deletedIds:Ee,failedIds:_e}=await M(X);if(Ee.length>0){const pe=_e.length>0?_e.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:_e.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:_e.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;Te.success(Ee.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ee.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ee.length}),{description:Fs(pe),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(_e.length>0&&(Te.error(_e.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:_e.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:_e.length}),{description:Fs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),Ee.length===0)){x(!1);return}}fe()}finally{x(!1)}}},[P,i,d,m,_,M,fe,te,Re,t]),ge=i?.worktree??d[0]?.metadata??null;let xe="";if(i?.mode==="worktree"){const X=i.sessions.length;X===0?xe=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):X===1?xe=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:X}):xe=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:X})}else if(i){const X=i.sessions.length;X===1?xe=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):xe=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:X,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:X})}const Se=i?s.jsxs("div",{className:We(te?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&s.jsxs("div",{className:We(te?"oc-tile rounded-lg p-3":"oc-tile space-y-1.5 rounded-lg p-3"),children:[te&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:i.sessions.length})]}),s.jsxs("ul",{className:We(te?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(X=>s.jsxs("li",{className:We(te?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground"),children:[s.jsx("span",{className:We(!te&&"hidden"),children:"•"}),s.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:X.title||t("sessions.sidebar.session.untitled")})]},X.id)),i.sessions.length>5&&s.jsx("li",{className:We(te?"px-2.5 py-1 text-xs text-muted-foreground":"typography-micro text-muted-foreground"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:i.sessions.length-5})})]})]}),te?s.jsxs("div",{className:"oc-tile space-y-2 rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),ge?.label?s.jsx("span",{className:"typography-micro text-muted-foreground",children:ge.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground break-all",children:ge?Wg(ge.path,B):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),ae&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"oc-tile rounded-lg p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Be=te&&P?W?s.jsxs("button",{type:"button",onClick:()=>{Z||f(X=>!X)},disabled:Z,"aria-pressed":l,className:We("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Z?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[l?s.jsx(oe,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(oe,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,Pe=te&&P?s.jsxs("button",{type:"button",onClick:()=>{me||p(X=>!X)},disabled:me,"aria-pressed":m,className:We("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",me?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[m?s.jsx(oe,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(oe,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Me=te?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[Pe,Be]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:fe,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:De,disabled:h,children:t(h?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>y(!C),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":!C,children:[C?s.jsx(oe,{name:"checkbox-blank",className:"size-4"}):s.jsx(oe,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:fe,disabled:h,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:De,disabled:h,children:h?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Je=te?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[ee?s.jsx(Ug,{open:!!i,onClose:()=>{h||fe()},title:Je,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Me}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[xe&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:xe}),Se]})}):s.jsx(nr,{open:!!i,onOpenChange:X=>{if(!X){if(h)return;fe()}},children:s.jsxs(rr,{className:We(te?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(or,{children:[s.jsxs(ir,{className:We(te&&"flex items-center gap-2"),children:[te&&s.jsx(oe,{name:"delete-bin",className:"h-5 w-5"}),Je]}),xe&&s.jsx(ar,{children:xe})]}),te?s.jsx(gs,{outerClassName:"flex-1 min-h-0",className:"space-y-2",disableHorizontal:!0,children:Se}):s.jsx("div",{children:Se}),s.jsx(Hr,{className:"mt-2 gap-2 pt-1 pb-1",children:Me})]})}),s.jsx(Vg,{open:r,onOpenChange:o})]})},ju=[{pattern:/^dev(:.*)?$/i},{pattern:/^start$/i},{pattern:/^start:(?:dev|preview|serve)(?::.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],yk=/^(?:(?:dev(?:elopment)?|preview|serve)(?: server)?|(?:start|run)\s+(?:dev(?:elopment)?\s+)?(?:server|preview))(?:\s+\([^)]+\))?$/i,vk=/^(?:cd\s+(?:"[^"]+"|'[^']+'|[^\s;&|]+)\s*&&\s*)?(?:npm|yarn|pnpm|bun)\s+(?:run\s+)?(?:--shell=bun\s+)?([^\s;&|]+)(?:\s|$)/i,Sk=t=>ju.some(({pattern:e})=>e.test(t));async function kk(t,e,n){if(!t)return null;const r=Tk(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=Nk(n);if(o){const i=await Ek(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 jk(t)){const o=await Ck(),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 jk(t){const e=`${t}/index.html`,n=await to(e,t);return typeof n=="string"&&n.trim().length>0}async function Ck(){try{const t=await qs("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Tk(t){for(const e of t){const n=vk.exec(e.command.trim())?.[1];if(n&&Sk(n)||e.source!=="shared"&&yk.test(e.name.trim()))return e}return null}function Nk(t){for(const{pattern:e}of ju)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ek(t){const e=await to(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of n){const i=await to(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function to(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await qs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=nc()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await qs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Ik(t){try{const e=await to(`${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 Pk=/\{(worktree|branch)\}/g,Yo=63,Rk=new Set(["main","master"]),Cu=t=>/\{(worktree|branch)\}/.test(t??""),Dk=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const n=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(n).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},Tu=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Yo)return e;const n=await Dk(e);return n?`${e.slice(0,Yo-7).replace(/-+$/,"")}-${n}`:e.slice(0,Yo).replace(/-+$/,"")},_k=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},Ak=async(t,e,n)=>{const r=n.includes("{branch}"),o=n.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:_k(i.current),linkedWorktree:o}},Ok=async t=>!t.linkedWorktree||!t.branch||Rk.has(t.branch)?"":Tu(t.branch.split("/").pop()??""),Mk=t=>{const e=t.lastIndexOf("@"),n=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",d=i.split(".").map(u=>u.replace(/^-+|-+$/g,"")).filter(Boolean);return`${n}${d.join(".")}${a}`},Fk=async(t,e)=>{const n={worktree:await Ok(e),branch:e.branch?await Tu(e.branch):""},r=t.replace(Pk,(u,l)=>n[l]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",d=""]=o;return`${i}${Mk(a)}${d}`},Lk=async(t,e,n)=>Cu(e)?Fk(e,await Ak(t,n,e)):e,Nu="oc.projectActions.selectedAction.v1",$k=li(Ns(),li(Ns(),Ns())),Eu=()=>{const t=gr().getItem(Nu);if(t===null)return{};try{const e=$k.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},_l=(t,e=Jt())=>Eu()[e]?.[t]??null,Bk=(t,e,n=Jt())=>{const r=Eu();r[n]?.[t]!==e&&gr().setItem(Nu,JSON.stringify({...r,[n]:{...r[n],[t]:e}}))},zk=15e3,Wk=3e3,Uk=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Vk=({projectRef:t,directory:e,allowMobile:n=!1})=>{const{t:r}=rt(),{currentTheme:o}=io(),{terminal:i,runtime:a,git:d}=Es(),u=Zs(),{isMobile:l}=wn(),f=c.useMemo(()=>_s(),[]),m=ja(N=>N.instances),p=ja(N=>N.load),h=G(N=>N.terminalShell),x=G(N=>N.terminalLoginShells.includes(N.terminalShell)),g=G(N=>N.setSettingsPage),b=G(N=>N.setSettingsDialogOpen),w=G(N=>N.setSettingsProjectsSelectedId),j=G(N=>N.openContextPreview),v=yt(N=>N.ensureDirectory),T=yt(N=>N.reconcileServerSessions),F=yt(N=>N.setTabLabel),_=yt(N=>N.setTabIconKey),A=yt(N=>N.setActiveTab),M=yt(N=>N.setConnecting),S=yt(N=>N.setTabSessionId),k=yt(N=>N.setTabPurpose),C=yt(N=>N.allocateActionExecution),y=yt(N=>N.setTabLifecycle),E=yt(N=>N.setTabPreviewUrl),B=yt(N=>N.matchesActionExecution),$=yt(N=>N.captureStartedActionMutationRevisions),[O,z]=c.useState([]),J=c.useRef(null),[K,ee]=c.useState(()=>t?.id?_l(t.id):null),[V,Y]=c.useState(!1),ae=c.useRef({}),P=c.useRef({}),de=c.useRef({}),q=c.useRef(new Set),Q=c.useRef(0),[L,ne]=c.useState({}),W=t?.id??null,te=t?.path??"";c.useEffect(()=>{ee(W?_l(W):null)},[W]);const Z=c.useMemo(()=>W?{id:W,path:te}:null,[W,te]);c.useEffect(()=>{f&&p().catch(()=>{})},[f,p]);const me=c.useCallback(async N=>{await Ln(N)},[]),Ie=c.useCallback(async()=>{if(!Z)return;const N=Q.current+1;Q.current=N,Y(!0);try{const ce=await Fo(Z);if(Q.current!==N)return;J.current=ce;const U=ce.projectActions;z(U)}catch{if(Q.current!==N)return}finally{Q.current===N&&Y(!1)}},[Z]),fe=c.useMemo(()=>_o(e||Z?.path||""),[e,Z?.path]),je=c.useMemo(()=>_o(Z?.path||""),[Z?.path]),$e=c.useMemo(()=>_o(u||"")||fe,[u,fe]),Re=c.useRef($e);c.useEffect(()=>{Re.current=$e},[$e]);const Fe=yt(N=>fe?N.getDirectoryState(fe):void 0),Ve=yt(N=>je&&je!==fe?N.getDirectoryState(je):void 0),De=c.useMemo(()=>{const N=fe?[{directory:fe,state:Fe}]:[];return je&&je!==fe&&N.push({directory:je,state:Ve}),N},[Fe,fe,je,Ve]),ge=c.useMemo(()=>{const N=fe?[fe]:[];return je&&je!==fe&&N.push(je),N},[fe,je]),xe=c.useCallback(N=>N.id!==on&&N.runIn==="parent"&&je||fe,[fe,je]),Se=c.useCallback((N,ce,U)=>`${N}::${ce}::${U}`,[]),Be=c.useCallback((N,ce,U=yt.getState())=>N?U.getDirectoryState(N)?.tabs.find(we=>we.purpose.type==="project-action"&&we.purpose.actionId===ce)??null:null,[]),Pe=c.useMemo(()=>{const N={};for(const{directory:ce,state:U}of De)for(const we of U?.tabs??[]){if(we.purpose.type!=="project-action"||!we.purpose.executionId||!we.terminalSessionId||we.lifecycle==="idle"||we.lifecycle==="exited")continue;const ke=Sn(ce,we.purpose.actionId),Xe=Se(ce,we.purpose.actionId,we.purpose.executionId);N[ke]={directory:ce,actionId:we.purpose.actionId,tabId:we.id,sessionId:we.terminalSessionId,executionId:we.purpose.executionId,status:we.lifecycle==="stopping"?"stopping":L[Xe]?"waiting-for-preview":"running"}}return N},[Se,L,De]),Me=c.useCallback((N,ce,U)=>{const we=Sn(N,ce),ke=Se(N,ce,U),Oe=ae.current[we]?.executionId===U,se=globalThis.window,ue=et=>{se?.clearTimeout(de.current[et]),delete de.current[et]};Oe&&(delete ae.current[we],ue(we)),P.current[ke]?.(),delete P.current[ke],ue(ke),ne(et=>{if(!et[ke])return et;const ye={...et};return delete ye[ke],ye})},[Se]),Je=c.useCallback(N=>{P.current[N]?.(),delete P.current[N]},[]),X=c.useCallback(N=>{window.clearTimeout(de.current[N]),delete de.current[N]},[]);c.useEffect(()=>{const N=P.current,ce=de.current;return()=>{for(const U of Object.keys(N))Je(U);for(const U of Object.keys(ce))X(U)}},[X,Je]),c.useEffect(()=>{const N=new Set(ge);for(const ce of Object.values(ae.current))N.has(ce.directory)||Me(ce.directory,ce.actionId,ce.executionId);for(const ce of Object.keys(P.current)){const U=ce.split("::",1)[0]??"";N.has(U)||Je(ce)}},[Me,Je,ge]);const Ee=c.useCallback((N,ce)=>{G.getState().openContextPanelTab(N,{mode:"terminal",targetDirectory:ce===N?null:ce})},[]),_e=c.useMemo(()=>({id:on,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),pe=!l,R=c.useMemo(()=>pe?[...O,_e]:O,[O,_e,pe]),ie=c.useMemo(()=>K?R.find(N=>N.id===K)??null:null,[R,K]);c.useEffect(()=>{Ie()},[Ie]);const[Ce,Ne]=c.useState(0),ze=c.useCallback(()=>(Ne(N=>N+1),()=>Ne(N=>N-1)),[]),qe=Ce>0;c.useEffect(()=>{if(!qe)return;const N=ge.map(ce=>dp(i,ce,$,U=>T(ce,U.sessions,{startedActionMutationRevisions:U.startedActionMutationRevisions})));return()=>{for(const ce of N)ce()}},[$,qe,T,i,ge]),c.useEffect(()=>{for(const{directory:N,state:ce}of De)if(N)for(const U of ce?.tabs??[]){if(U.purpose.type!=="project-action")continue;const we=U.purpose.actionId,ke=R.find(se=>se.id===we),Xe=ke?.name??we,Oe=ke?.icon||"play";U.label!==Xe&&F(N,U.id,Xe),U.iconKey!==Oe&&_(N,U.id,Oe)}},[R,_,F,De]),c.useEffect(()=>{const N=globalThis.window;if(!N)return;const ce=U=>{const we=U.detail;W&&(we?.projectId&&we.projectId!==W||Ie())};return N.addEventListener(Ca,ce),()=>{N.removeEventListener(Ca,ce)}},[Ie,W]),c.useEffect(()=>{const N=U=>{delete de.current[U];const we=ae.current[U];if(!we||we.openedUrl)return;const ke=Se(we.directory,we.actionId,we.executionId),Xe=we.announced;if(Xe.length!==0){if(window.clearTimeout(de.current[ke]),delete de.current[ke],we.openedUrl=!0,ne(Oe=>{if(!Oe[ke])return Oe;const se={...Oe};return delete se[ke],se}),Xe.length===1){Go(we.directory,[]),E(we.directory,we.tabId,Xe[0],{locked:!1,autoOpened:!0}),j(we.directory,Xe[0]);return}we.offering=!0,Go(we.directory,Xe),G.getState().openContextSurface(we.directory,"browser"),Te.info(r("projectActions.toast.multipleServers"))}},ce=()=>{const U=yt.getState(),we=U.sessions,ke=Pe;for(const[Xe,Oe]of Object.entries(ke)){const ue=we.get(Oe.directory)?.tabs.find(ht=>ht.id===Oe.tabId);if(!ue||ue.terminalSessionId!==Oe.sessionId){Me(Oe.directory,Oe.actionId,Oe.executionId);continue}const et=ae.current[Xe],ye=et?.executionId===Oe.executionId?et:{hostDirectory:Re.current||Oe.directory,directory:Oe.directory,tabId:Oe.tabId,actionId:Oe.actionId,executionId:Oe.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};ae.current[Xe]=ye;const bt=R.find(ht=>ht.id===Oe.actionId),Tt=U.getBuffer(Oe.directory,Oe.tabId).chunks;if(!bt||Tt.length===0)continue;const vt=Tt.filter(ht=>ye.lastSeenChunkId===null||ht.id>ye.lastSeenChunkId);if(vt.length===0)continue;const Pt=vt.map(ht=>ht.data).join(""),Ke=`${ye.tail}${Pt}`;for(const ht of gp(Ke))ye.proxiedPorts.includes(ht)||ye.proxiedPorts.push(ht);if(ye.openInPreview&&(!ye.openedUrl||ye.offering)){const ht=xp(Ke,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!Ta()}),Ct=ye.announced.length;for(const Et of ht)ye.announced.includes(Et)||ye.announced.push(Et);const lt=ye.announced.length-Ct;ye.offering&<>0?Go(Oe.directory,ye.announced):!ye.openedUrl&&Ct===0&&ye.announced.length>0&&(window.clearTimeout(de.current[Xe]),de.current[Xe]=window.setTimeout(()=>N(Xe),Wk))}const ct=!ye.openedUrl&&bt.autoOpenUrl===!0&&!ye.openInPreview?bp(Ke,{proxiedPorts:ye.proxiedPorts,namedAddressesReachable:!Ta()}):null,Rt=vt[vt.length-1]?.id??ye.lastSeenChunkId;if(ye.lastSeenChunkId=Rt,ye.tail=Ke.slice(-512),ct)if(ye.openedUrl=!0,ye.openInPreview){const ht=ke[Xe];ht&&(E(ht.directory,ht.tabId,ct,{locked:!1,autoOpened:!1,expectedExecutionId:ht.executionId}),ht.status==="waiting-for-preview"&&ne(Ct=>{const lt=Se(ht.directory,ht.actionId,ht.executionId);if(!Ct[lt])return Ct;const Et={...Ct};return delete Et[lt],Et}),window.clearTimeout(de.current[Xe]),delete de.current[Xe],j(ht.directory,ct))}else me(ct),Te.success(r("projectActions.toast.openedUrlFromOutput"));ae.current[Xe]=ye}for(const Xe of Object.keys(ae.current))if(!ke[Xe]){const Oe=ae.current[Xe],se=Oe?we.get(Oe.directory)?.tabs.find(et=>et.id===Oe.tabId):void 0;if(se?.purpose.type==="project-action"&&se.purpose.executionId===Oe?.executionId&&!!se.terminalSessionId&&se.lifecycle!=="idle"&&se.lifecycle!=="exited")continue;delete ae.current[Xe],window.clearTimeout(de.current[Xe]),delete de.current[Xe]}};return ce(),yt.subscribe((U,we)=>{(U.sessions!==we.sessions||U.buffers!==we.buffers)&&ce()})},[Me,Re,R,Se,j,me,Pe,E,r]),c.useEffect(()=>{for(const{directory:N,state:ce}of De)for(const U of ce?.tabs??[]){if(U.purpose.type!=="project-action"||!U.purpose.executionId||!U.terminalSessionId||U.lifecycle!=="running")continue;const we=U.purpose.actionId,ke=U.purpose.executionId,Xe=Se(N,we,ke);if(P.current[Xe])continue;const Oe=i.connect(U.terminalSessionId,{onEvent:se=>{if(!B(N,U.id,ke))return;se.type==="snapshot"&&(yt.getState().replaceBuffer(N,U.id,se.data??"",se.sequence??0,ca(se)),se.status==="running"&&yt.getState().setTabLifecycle(N,U.id,"running",{expectedExecutionId:ke}),se.status==="exited"&&(yt.getState().setTabLifecycle(N,U.id,"exited",{expectedExecutionId:ke}),yt.getState().setTabPurpose(N,U.id,{type:"project-action",actionId:we,executionId:null}),Me(N,we,ke)));const ue=se.type==="data"?se.data??"":"";ue&&yt.getState().appendToBuffer(N,U.id,ue,se.sequence,se.replayData),se.type==="exit"&&(yt.getState().setTabLifecycle(N,U.id,"exited",{expectedExecutionId:ke}),yt.getState().setTabPurpose(N,U.id,{type:"project-action",actionId:we,executionId:null}),Me(N,we,ke))},onError:(se,ue)=>{!ue||!B(N,U.id,ke)||(yt.getState().setTabLifecycle(N,U.id,"exited",{expectedExecutionId:ke}),yt.getState().setTabSessionId(N,U.id,null,{expectedExecutionId:ke}),yt.getState().setTabPurpose(N,U.id,{type:"project-action",actionId:we,executionId:null}),Me(N,we,ke))}},N);P.current[Xe]=Oe.close}},[Me,Se,B,i,De]);const Ue=c.useCallback(async N=>{const ce=xe(N);if(!ce)throw new Error(r("projectActions.error.noActiveDirectory"));const U=Sn(ce,N.id);v(ce);const we=yt.getState(),ke=Be(ce,N.id,we),Xe=ke?.id??we.createTab(ce);F(ce,Xe,N.name),_(ce,Xe,N.icon||"play"),ke||k(ce,Xe,{type:"project-action",actionId:N.id,executionId:null}),A(ce,Xe);const se=yt.getState().getDirectoryState(ce)?.tabs.find(ue=>ue.id===Xe);return{executionDirectory:ce,key:U,tabId:Xe,sessionId:se?.terminalSessionId??null,executionId:se?.purpose.type==="project-action"?se.purpose.executionId:null}},[v,xe,Be,A,_,F,k,r]),tt=c.useCallback(async N=>{if(a.isVSCode||!n&&l)return;if(!fe){Te.error(r("projectActions.error.noActiveDirectoryForAction"));return}const ce=Sn(xe(N),N.id),U=Pe[ce];if(U&&U.status==="running"||q.current.has(ce))return;q.current.add(ce);let we=null;try{const ke=N.id===on?await(async()=>{const dt=Z??{id:"",path:fe},[ut,Ot]=await Promise.all([Fo(dt),Ik(fe)]),Zt=await kk(fe,ut.projectActions,Ot);if(!Zt)throw new Error(r("contextPanel.preview.noDevServer"));return ut.projectActions.find(as=>as.id===Zt.actionId)?.source==="shared"&&!await Fa(dt,ut)?null:{id:on,name:r("projectActions.actions.autoDiscover"),command:Zt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Zt.previewUrlHint||""}})():N;if(!ke)return;const Xe=ke.autoOpenUrl===!0&&(ke.openUrl||"").trim().length>0,Oe=!Xe&&N.id!==on,se=Re.current||fe,{executionDirectory:ue,key:et,tabId:ye}=await Ue(ke),bt=up(ke.command);if(!bt)throw new Error(r("projectActions.error.failedToRunAction"));const Tt=ke.autoOpenUrl===!0&&f&&(ke.desktopOpenSshForward||"").trim().length>0,vt=ke.autoOpenUrl&&ke.openUrl||"";let Pt=!1;const Ke=Cu(vt)?await Lk(d,vt,ue).catch(()=>(Pt=!0,"")):vt,ct=ke.autoOpenUrl?Uk(Ke):null,Rt=ke.autoOpenUrl&&f?fp(ke.desktopOpenSshForward,m):null;if(i.listSessions){const dt=Be(ue,ke.id);if(dt?.purpose.type==="project-action"&&dt.purpose.executionId===null){const ut=await pp(i,ue,{captureStartedActionMutationRevisions:$});ut&&T(ue,ut.sessions,{startedActionMutationRevisions:ut.startedActionMutationRevisions})}}const ht=Be(ue,ke.id);let Ct,lt;if(ht?.lifecycle==="running"&&ht.terminalSessionId&&ht.purpose.type==="project-action"&&ht.purpose.executionId)Ct=ht.terminalSessionId,lt=ht.purpose.executionId;else{const dt=ht?.purpose.type==="project-action"?ht.purpose.executionId:null;dt&&Me(ue,ke.id,dt);const ut=C(ue,ye,ke.id);if(!ut)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));we={directory:ue,tabId:ye,id:ut},M(ue,ye,!0,{expectedExecutionId:ut});const Ot=await mp({terminal:i,createOptions:{cwd:ue,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:()=>B(ue,ye,ut),purpose:{type:"project-action",actionId:ke.id,executionId:ut}});if(!B(ue,ye,ut)){Ot.sessionId===ut&&await i.close(Ot.sessionId).catch(()=>{});return}lt=Ot.purpose?.type==="project-action"?Ot.purpose.executionId:ut,Ct=Ot.sessionId,k(ue,ye,{type:"project-action",actionId:ke.id,executionId:lt}),S(ue,ye,Ct,{expectedExecutionId:lt}),M(ue,ye,!1,{expectedExecutionId:lt})}Oe&&se&&Ee(se,ue),ae.current[et]={hostDirectory:se,directory:ue,tabId:ye,actionId:ke.id,executionId:lt,lastSeenChunkId:null,openedUrl:!!Rt||!!ct||Xe,tail:"",openInPreview:ke.id===on,announced:[],offering:!1,proxiedPorts:[]};const Et=Se(ue,ke.id,lt);M(ue,ye,!0,{expectedExecutionId:lt});const qt=i.connect(Ct,{onEvent:dt=>{if(!B(ue,ye,lt)||dt.purpose?.type==="project-action"&&dt.purpose.executionId!==lt)return;dt.type==="snapshot"&&(yt.getState().replaceBuffer(ue,ye,dt.data??"",dt.sequence??0,ca(dt)),yt.getState().setConnecting(ue,ye,!1,{expectedExecutionId:lt}),dt.purpose?.type==="project-action"&&yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:dt.purpose.actionId,executionId:dt.purpose.executionId}),dt.status==="running"&&yt.getState().setTabLifecycle(ue,ye,"running",{expectedExecutionId:lt}),dt.status==="exited"&&(yt.getState().setTabLifecycle(ue,ye,"exited",{expectedExecutionId:lt}),yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:ke.id,executionId:null}),Me(ue,ke.id,lt)));const ut=dt.type==="data"?dt.data??"":"";ut&&yt.getState().appendToBuffer(ue,ye,ut,dt.sequence,dt.replayData),dt.type==="exit"&&(yt.getState().setTabLifecycle(ue,ye,"exited",{expectedExecutionId:lt}),yt.getState().setConnecting(ue,ye,!1,{expectedExecutionId:lt}),yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:ke.id,executionId:null}),Me(ue,ke.id,lt))},onError:(dt,ut)=>{B(ue,ye,lt)&&(yt.getState().setConnecting(ue,ye,!1,{expectedExecutionId:lt}),ut&&(yt.getState().setTabLifecycle(ue,ye,"exited",{expectedExecutionId:lt}),yt.getState().setTabSessionId(ue,ye,null,{expectedExecutionId:lt}),yt.getState().setTabPurpose(ue,ye,{type:"project-action",actionId:ke.id,executionId:null}),Me(ue,ke.id,lt)))}},ue);if(!B(ue,ye,lt)){qt.close();return}P.current[Et]?.(),P.current[Et]=qt.close,window.clearTimeout(de.current[Et]),delete de.current[Et],ke.id===on&&!ct&&(ne(dt=>({...dt,[Et]:!0})),de.current[Et]=window.setTimeout(()=>{delete de.current[Et];const dt=ae.current[et];!dt||dt.executionId!==lt||dt.openedUrl||dt.offering||B(ue,ye,lt)&&(ne(ut=>{if(!ut[Et])return ut;const Ot={...ut};return delete Ot[Et],Ot}),yt.getState().setActiveTab(ue,ye),Ee(dt.hostDirectory,ue))},zk)),Rt?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),me(Rt),Te.success(r("projectActions.toast.openedForwardedUrl"))):ct?(E(ue,ye,ct,{locked:!0,autoOpened:!0,expectedExecutionId:lt}),j(se,ct),Te.success(r("projectActions.toast.openedActionUrl"))):Pt?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),Te.error(r("projectActions.error.openUrlTemplateUnresolved"))):Xe?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),Te.error(r("projectActions.error.invalidCustomUrlFormat"))):Tt?(E(ue,ye,null,{locked:!0,expectedExecutionId:lt}),Te.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):E(ue,ye,null,{locked:!1,autoOpened:!1,expectedExecutionId:lt})}catch(ke){if(we&&B(we.directory,we.tabId,we.id)){const{directory:Xe,tabId:Oe,id:se}=we;Me(Xe,N.id,se),y(Xe,Oe,"exited",{expectedExecutionId:se}),k(Xe,Oe,{type:"project-action",actionId:N.id,executionId:null})}if(ke instanceof Error&&ke.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(ke instanceof Error&&(ke.message==="COMMAND_MODE_UNSUPPORTED"||ke.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Te.error(r("projectActions.error.failedToCreateTerminalSession"));return}Te.error(ke instanceof Error?ke.message:r("projectActions.error.failedToRunAction"))}finally{q.current.delete(ce)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,Re,m,Ue,d,n,l,f,fe,x,h,me,j,Pe,Ee,a.isVSCode,xe,B,Me,Se,Be,T,C,$,M,y,k,E,S,Z,r,i]),He=c.useCallback(async N=>{const ce=Sn(xe(N),N.id),U=Pe[ce];U&&await hp({terminal:i,sessionId:U.sessionId,isExecutionStillCurrent:()=>B(U.directory,U.tabId,U.executionId),markStopping:()=>{y(U.directory,U.tabId,"stopping",{expectedExecutionId:U.executionId})},restoreRunning:()=>{y(U.directory,U.tabId,"running",{expectedExecutionId:U.executionId})},clearSession:()=>{S(U.directory,U.tabId,null,{expectedExecutionId:U.executionId})},finalizeExit:()=>{y(U.directory,U.tabId,"exited",{expectedExecutionId:U.executionId}),k(U.directory,U.tabId,{type:"project-action",actionId:U.actionId,executionId:null}),Me(U.directory,U.actionId,U.executionId)}})},[Me,xe,B,Pe,y,k,S,i]),Ze=c.useCallback(async N=>{if(N.source==="shared"&&Z){const ce=J.current?.trust.trusted?J.current:await Fo(Z);if(J.current=ce,!await Fa(Z,ce))return;J.current={...ce,trust:{...ce.trust,trusted:!0}}}await tt(N)},[tt,Z]),Qe=c.useCallback(N=>Pe[Sn(xe(N),N.id)]??null,[xe,Pe]),ot=(ie&&Qe(ie)?ie:null)??R.find(N=>Qe(N)!==null)??ie??R[0]??null,pt=c.useCallback(N=>{const ce=Qe(N);if(ce?.status!=="stopping"){if(ce){He(N);return}Ze(N)}},[Ze,Qe,He]),at=c.useCallback(N=>{Ze(N)},[Ze]),xt=c.useCallback(N=>{He(N)},[He]),le=c.useCallback(N=>{ee(N.id),W&&Bk(W,N.id)},[W]),be=c.useCallback(()=>{Z?.id&&(w(Z.id),g("projects"),b(!0))},[b,g,w,Z?.id]),Ae=!a.isVSCode&&(n||!l)&&!!Z&&!!fe;return c.useMemo(()=>({available:Ae,actions:Ae?R:[],shown:Ae?ot:null,isLoading:V,observe:ze,runOf:Qe,select:le,run:at,stop:xt,toggle:pt,openSettings:be}),[Ae,R,V,ze,be,at,Qe,le,ot,xt,pt])},Hk=t=>{const e=Le.c(6);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const o=Vk(r);let i;return e[3]!==n||e[4]!==o?(i=s.jsx(Ed.Provider,{value:o,children:n}),e[3]=n,e[4]=o,e[5]=i):i=e[5],i},qk=t=>{const e=Le.c(4),{children:n}=t,r=Pd(),o=yr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let d;return e[0]!==n||e[1]!==a||e[2]!==i?(d=s.jsx(Hk,{projectRef:i,directory:a,children:n}),e[0]=n,e[1]=a,e[2]=i,e[3]=d):d=e[3],d},Kk=2e4,Gk=14400*1e3,Zk=t=>Object.entries(t).map(([e,n])=>`${e}@${n.version}`).sort().join(","),Xk="openchamber.guests.announcedUpdates",Yk=()=>{const{t}=rt(),e=c.useRef(t);e.current=t,c.useEffect(()=>{let n=!1;const r=async()=>{const a=Jt();await td();const d=await wp(!1);if(n||!d.ok||Jt()!==a)return;const u=sr.getState();u.applyUpdates(d.updates,u.runtimeKey);const l=sr.getState().guests.filter(g=>d.updates[g.id]),f=Zk(d.updates),m=gr(),p=`${Xk}:${a}`;if(l.length===0||m.getItem(p)===f)return;m.setItem(p,f);const h=e.current,[x]=l;Te.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=G.getState();g.setSettingsPage("extensions"),g.setSettingsDialogOpen(!0)}}})};let o;const i=window.setTimeout(()=>{r(),o=window.setInterval(()=>{r()},Gk)},Kk);return()=>{n=!0,window.clearTimeout(i),window.clearInterval(o)}},[])},Jk=()=>{cr.requestDirectoryDialog()},Qk=()=>{G.getState().setNewWorktreeDialogOpen(!0)},ej=()=>{const t=Ht.getState().currentDirectory;if(!t)return!1;G.getState().openContextOverview(t)},tj=()=>{nd()},sj=()=>{if(!G.getState().overviewFeatureAvailable)return!1;G.getState().setOverviewOpen(!0)},nj=()=>{window.location.reload()},rj=()=>{const t=G.getState();t.setSessionSwitcherOpen(!1),t.setArchivePageOpen(!0)},Iu=t=>{const e=Ht.getState().currentDirectory;if(!e)return!1;const n=G.getState();return n.setProjectContextTab(t),n.openContextSurface(e,"notes"),!0},oj=()=>Iu("notes"),ij=()=>Iu("todos"),aj=t=>()=>{yp(t)},lj=t=>()=>{const e=st.getState().currentSessionId,n=Ht.getState().currentDirectory;if(!e||!n)return!1;const r=sd(go.getState().ids,n,e)?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";vp({directory:n,sessionId:e}).catch(()=>Te.error(t(r)))},cj=t=>()=>{const e=st.getState().currentSessionId;if(!e)return!1;wr(e).then(n=>{if(n.ok){Te.success(t("sessions.sidebar.session.copyId.success"));return}Te.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Te.error(t("sessions.sidebar.session.copyId.error")))},dj=t=>()=>{if(!G.getState().sessionWorkEnabled)return!1;const e=st.getState().currentSessionId;if(!e)return!1;const n=ps.getState().activeSessions.find(i=>i.id===e);if(!n||n.parentID)return!1;const r=Hs(n)??Ht.getState().currentDirectory;if(!r||mr(r))return!1;const o=Oi(n)?"done":"open";Nc(e,r,o).catch(()=>Te.error(t("sessions.sidebar.session.work.updateFailed")))},uj=()=>{G.getState().setSessionSwitcherOpen(!1),Xg()};function fj(){const t=Le.c(13),{t:e}=rt();let n;t[0]!==e?(n=aj(e),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=lj(e),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=cj(e),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=dj(e),t[6]=e,t[7]=i):i=t[7];let a;t[8]!==n||t[9]!==r||t[10]!==o||t[11]!==i?(a={open_new_worktree_dialog:Qk,add_project:Jk,show_context_usage:ej,show_opencode_status:tj,open_overview:sj,reload_ui:nj,open_archive:rj,open_notes:oj,open_todos:ij,restart_opencode:n,pin_current_session:r,copy_current_session_id:o,toggle_work_current_session:i,open_multi_run:uj},t[8]=n,t[9]=r,t[10]=o,t[11]=i,t[12]=a):a=t[12],Dc(a)}function pj(t){const e=[],n=(r,o)=>{const i=Yt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const mj=new Map,hj=[],gj=t=>{const e=Le.c(20),{isVSCode:n}=t,r=Zc(),o=ts(xj),i=Ht(bj),a=st(wj);let d;e[0]!==n?(d=A=>n?mj:A.availableWorktreesByProject,e[0]=n,e[1]=d):d=e[1];const u=st(d),l=!n;let f;e[2]!==u||e[3]!==o||e[4]!==l?(f=Sp(o,u,{includeWorktrees:l}),e[2]=u,e[3]=o,e[4]=l,e[5]=f):f=e[5];const m=f,p=ps(yj),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,pj({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 b=c.useRef(null);let w,j;e[12]!==n||e[13]!==m?(w=()=>{const A=new Set(m),M=b.current;b.current=A;const S=M?[...A].filter(k=>!M.has(k)):n?[...A]:[];S.length&&rd(S,ni())},j=[n,m],e[12]=n,e[13]=m,e[14]=w,e[15]=j):(w=e[14],j=e[15]),c.useEffect(w,j);let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[16]=v):v=e[16],c.useEffect(vj,v);const T=p!=null,F=p??hj;let _;e[17]!==F||e[18]!==T?(_={enabled:!0,hasAuthoritativeGlobalSessions:T,sessions:F},e[17]=F,e[18]=T,e[19]=_):_=e[19],kp(_)};function xj(t){return t.projects}function bj(t){return t.currentDirectory}function wj(t){return t.currentSessionDirectory}function yj(t){return t.authoritativeSessions}function vj(){let t=null,e=!1;const n=new Set,r=tn(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")n.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),Yg(ni());return}const i=[...n];n.clear(),i.length&&rd(i,ni())},500)});return()=>{t&&clearTimeout(t),r()}}const Sj=()=>Lt(()=>import("./SettingsWindow-k5FSMAzV.js"),__vite__mapDeps([242,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,243,181,182,183,244,245,222,223,224,225,232,201,188,189,202,246,247,212,231,217,248,249,250,251])).then(t=>t.SettingsWindow),kj=()=>Lt(()=>import("./CommandPalette-DrsFSbmk.js"),__vite__mapDeps([252,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,250,211,181,182,183,209,210,212])).then(t=>t.CommandPalette),jj=()=>Lt(()=>import("./HelpDialog-DtZKoPZE.js"),__vite__mapDeps([253,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180])).then(t=>t.HelpDialog),Cj=()=>Lt(()=>import("./ProjectActionsDialog-B16N4lqs.js"),__vite__mapDeps([254,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,209,210,211,212])).then(t=>t.ProjectActionsDialog),Tj=()=>Lt(()=>import("./OpenCodeStatusDialog-CX3oxFSb.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])).then(t=>t.OpenCodeStatusDialog),Nj=()=>Lt(()=>import("./RunOverview-DsffX3fI.js"),__vite__mapDeps([256,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183])).then(t=>t.RunOverview),Ej=()=>Lt(()=>import("./ScheduledTasksDialog-DgrAfpeX.js"),__vite__mapDeps([257,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,240,258,259,237])).then(t=>t.ScheduledTasksDialog),Ij=()=>Lt(()=>import("./ArchiveView-Jt6Qj8Ry.js"),__vite__mapDeps([260,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,3,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,261])).then(t=>t.ArchiveView),Pj=()=>Lt(()=>import("./IntegrationsCatalogView-DgdYlI3Z.js"),__vite__mapDeps([262,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,244])).then(t=>t.IntegrationsCatalogView),Rj=()=>Lt(()=>import("./UsageStatsView-CNm8WPSk.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])).then(t=>t.UsageStatsView),Dj=()=>Lt(()=>import("./SourceBoardView-BvGoSNer.js"),__vite__mapDeps([264,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,251])).then(t=>t.SourceBoardView),_j=()=>Lt(()=>import("./OverviewView-UfIFJ3mf.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,181,182,183])).then(t=>t.OverviewView),Aj=()=>Lt(()=>import("./WorktreesView-BGIfERNs.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,261])).then(t=>t.WorktreesView),Oj=()=>Lt(()=>import("./SpacesView-BGevrpQp.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,248,181,182,183])).then(t=>t.SpacesView),Mj=()=>Lt(()=>import("./SpaceAccessDialog-DHNqUzKD.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,269])).then(t=>t.SpaceAccessDialog),Fj=()=>Lt(()=>import("./SpaceApplyDialog-DEOTeEjy.js"),__vite__mapDeps([270,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),Lj=()=>Lt(()=>import("./SpaceSetupOutput-C4NhRkjl.js"),__vite__mapDeps([271,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,269])).then(t=>t.SpaceSetupOutputDialog),Ls=()=>G.getState().closeMainSurfaces(),os=t=>{const e=Le.c(2),{needed:n,load:r,onFailure:o}=t,i=xo(n,r,o);let a;return e[0]!==i?(a=i?s.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},Pu=c.memo(t=>{const e=Le.c(11),{isMobile:n}=t,r=G(Bj),o=!r&&!n,i=co();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=Gb(a);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Wb,{}),e[3]=u):u=e[3];const l=r||d.state!==!1;let f;e[4]!==l?(f=s.jsx(jp,{isVisible:l}),e[4]=l,e[5]=f):f=e[5];let m;return e[6]!==n||e[7]!==r||e[8]!==d||e[9]!==f?(m=s.jsx(zb,{isOpen:r,isMobile:n,className:"border-border",topBar:u,peek:d,children:f}),e[6]=n,e[7]=r,e[8]=d,e[9]=f,e[10]=m):m=e[10],m});Pu.displayName="LeftSidebar";const $j=()=>{const t=Le.c(111);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],gj(e),fj(),Cp();const n=G(zj),r=G(Wj),o=G(Uj),i=G(Vj);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const d=xo(o,Sj,a),u=G(Hj),l=G(qj),f=G(Kj),m=G(Gj),p=G(Zj),h=G(Xj),x=G(Yj),g=G(Jj),b=G(Qj),w=G(e3),j=G(t3),v=G(s3),T=G(n3),F=pn(r3),_=pn(o3),A=pn(i3),M=G(a3),S=Jg();let k;if(t[3]!==S||t[4]!==M){let at;t[6]!==M?(at=xt=>xt.id===M,t[6]=M,t[7]=at):at=t[7],k=S.find(at),t[3]=S,t[4]=M,t[5]=k}else k=t[5];const C=k;let y,E;t[8]!==C||t[9]!==M?(y=()=>{M&&!C&&G.getState().setOpenGuestPage(null)},E=[M,C],t[8]=C,t[9]=M,t[10]=y,t[11]=E):(y=t[10],E=t[11]),c.useEffect(y,E);let B;t[12]===Symbol.for("react.memo_cache_sentinel")?(B=[],t[12]=B):B=t[12],c.useEffect(c3,B);let $;t[13]===Symbol.for("react.memo_cache_sentinel")?($=[],t[13]=$):$=t[13],c.useEffect(d3,$);const O=l||f||m||p||h||x||!!g||b||u||!!C;let z,J;t[14]!==O?(z=()=>{od(O)},J=[O],t[14]=O,t[15]=z,t[16]=J):(z=t[15],J=t[16]),c.useLayoutEffect(z,J);let K;t[17]===Symbol.for("react.memo_cache_sentinel")?(K=[],t[17]=K):K=t[17],c.useEffect(f3,K);let ee;t[18]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[18]=ee):ee=t[18],c.useEffect(m3,ee);const{isMobile:V}=wn();Tp(),Yk();let Y,ae;t[19]!==V||t[20]!==r?(Y=()=>{G.getState().isMobile!==V&&r(V)},ae=[V,r],t[19]=V,t[20]=r,t[21]=Y,t[22]=ae):(Y=t[21],ae=t[22]),c.useEffect(Y,ae);let P;t[23]!==w?(P=s.jsx(os,{needed:w,load:kj,onFailure:h3}),t[23]=w,t[24]=P):P=t[24];let de;t[25]!==j?(de=s.jsx(os,{needed:j,load:jj,onFailure:g3}),t[25]=j,t[26]=de):de=t[26];let q;t[27]!==v?(q=s.jsx(os,{needed:v,load:Cj,onFailure:x3}),t[27]=v,t[28]=q):q=t[28];let Q;t[29]!==T?(Q=s.jsx(os,{needed:T,load:Tj,onFailure:b3}),t[29]=T,t[30]=Q):Q=t[30];let L,ne;t[31]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(Ep,{}),ne=s.jsx(wk,{}),t[31]=L,t[32]=ne):(L=t[31],ne=t[32]);let W;t[33]!==F||t[34]!==_||t[35]!==A||t[36]!==n?(W=n?s.jsxs(s.Fragment,{children:[s.jsx(os,{needed:F,load:Mj,onFailure:w3}),s.jsx(Ip,{}),s.jsx(os,{needed:_,load:Fj,onFailure:y3}),s.jsx(Pp,{}),s.jsx(os,{needed:A,load:Lj,onFailure:v3})]}):null,t[33]=F,t[34]=_,t[35]=A,t[36]=n,t[37]=W):W=t[37];let te;t[38]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(Zb,{}),t[38]=te):te=t[38];let Z;t[39]!==V?(Z=s.jsx(Pu,{isMobile:V}),t[39]=V,t[40]=Z):Z=t[40];let me;t[41]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(Bb,{}),t[41]=me):me=t[41];let Ie;t[42]===Symbol.for("react.memo_cache_sentinel")?(Ie=s.jsx(Ko,{zone:"left"}),t[42]=Ie):Ie=t[42];const fe=O&&"invisible";let je;t[43]!==fe?(je=We("absolute inset-0",fe),t[43]=fe,t[44]=je):je=t[44];const $e=!o&&!O;let Re;t[45]!==$e?(Re=s.jsx(Qt,{children:s.jsx(vc,{active:$e})}),t[45]=$e,t[46]=Re):Re=t[46];let Fe;t[47]!==je||t[48]!==Re?(Fe=s.jsx("div",{className:je,children:Re}),t[47]=je,t[48]=Re,t[49]=Fe):Fe=t[49];let Ve;t[50]!==u?(Ve=s.jsx(Qt,{children:s.jsx(os,{needed:u,load:Nj,onFailure:Ls})}),t[50]=u,t[51]=Ve):Ve=t[51];let De;t[52]!==l?(De=s.jsx(Qt,{children:s.jsx(os,{needed:l,load:Ej,onFailure:Ls})}),t[52]=l,t[53]=De):De=t[53];let ge;t[54]!==f?(ge=s.jsx(Qt,{children:s.jsx(os,{needed:f,load:Ij,onFailure:Ls})}),t[54]=f,t[55]=ge):ge=t[55];let xe;t[56]!==m?(xe=s.jsx(Qt,{children:s.jsx(os,{needed:m,load:Pj,onFailure:Ls})}),t[56]=m,t[57]=xe):xe=t[57];let Se;t[58]!==p?(Se=p&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Rj,onFailure:Ls})})}),t[58]=p,t[59]=Se):Se=t[59];let Be;t[60]!==h?(Be=s.jsx(os,{needed:h,load:Dj,onFailure:Ls}),t[60]=h,t[61]=Be):Be=t[61];let Pe;t[62]!==x?(Pe=s.jsx(Qt,{children:s.jsx(os,{needed:x,load:_j,onFailure:Ls})}),t[62]=x,t[63]=Pe):Pe=t[63];const Me=!!g;let Je;t[64]!==Me?(Je=s.jsx(Qt,{children:s.jsx(os,{needed:Me,load:Aj,onFailure:Ls})}),t[64]=Me,t[65]=Je):Je=t[65];let X;t[66]!==b?(X=b?s.jsx(Qt,{children:s.jsx(os,{needed:!0,load:Oj,onFailure:Ls})}):null,t[66]=b,t[67]=X):X=t[67];let Ee;t[68]!==C?(Ee=C&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Qt,{children:s.jsx(Qg,{mode:`plugin:${C.id}`,surface:"page",item:null,onDismiss:S3})})}),t[68]=C,t[69]=Ee):Ee=t[69];let _e;t[70]!==Fe||t[71]!==Ve||t[72]!==De||t[73]!==ge||t[74]!==xe||t[75]!==Se||t[76]!==Be||t[77]!==Pe||t[78]!==Je||t[79]!==X||t[80]!==Ee?(_e=s.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[Fe,Ve,De,ge,xe,Se,Be,Pe,Je,X,Ee]}),t[70]=Fe,t[71]=Ve,t[72]=De,t[73]=ge,t[74]=xe,t[75]=Se,t[76]=Be,t[77]=Pe,t[78]=Je,t[79]=X,t[80]=Ee,t[81]=_e):_e=t[81];let pe;t[82]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx(Ko,{zone:"bottom"}),t[82]=pe):pe=t[82];let R;t[83]!==_e?(R=s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[_e,pe]}),t[83]=_e,t[84]=R):R=t[84];let ie,Ce,Ne,ze;t[85]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx(Ko,{zone:"right"}),Ce=s.jsx(_2,{}),Ne=s.jsx(O2,{}),ze=s.jsx(B2,{}),t[85]=ie,t[86]=Ce,t[87]=Ne,t[88]=ze):(ie=t[85],Ce=t[86],Ne=t[87],ze=t[88]);let qe;t[89]!==R?(qe=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[Ie,s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[R,ie,Ce,Ne,ze]})]})}),t[89]=R,t[90]=qe):qe=t[90];let Ue;t[91]===Symbol.for("react.memo_cache_sentinel")?(Ue=s.jsx("div",{"data-page-scroll-lock":"true",children:s.jsx(Qt,{children:s.jsx(Q2,{})})}),t[91]=Ue):Ue=t[91];let tt;t[92]===Symbol.for("react.memo_cache_sentinel")?(tt=s.jsx(Qt,{children:s.jsx(Z1,{})}),t[92]=tt):tt=t[92];let He;t[93]!==qe?(He=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[me,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[qe,Ue,tt]})]}),t[93]=qe,t[94]=He):He=t[94];let Ze;t[95]!==Z||t[96]!==He?(Ze=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[Z,He]}),t[95]=Z,t[96]=He,t[97]=Ze):Ze=t[97];let Qe;t[98]!==d||t[99]!==o||t[100]!==i?(Qe=d?s.jsx(d,{open:o,onOpenChange:i}):null,t[98]=d,t[99]=o,t[100]=i,t[101]=Qe):Qe=t[101];let ot;t[102]===Symbol.for("react.memo_cache_sentinel")?(ot=null,t[102]=ot):ot=t[102];let pt;return t[103]!==P||t[104]!==de||t[105]!==q||t[106]!==Q||t[107]!==W||t[108]!==Ze||t[109]!==Qe?(pt=s.jsx(e1.Provider,{value:!0,children:s.jsx(Np,{children:s.jsx(qk,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[P,de,q,Q,L,ne,W,te,Ze,Qe,ot]})})})}),t[103]=P,t[104]=de,t[105]=q,t[106]=Q,t[107]=W,t[108]=Ze,t[109]=Qe,t[110]=pt):pt=t[110],pt};function Bj(t){return t.isSidebarOpen}function zj(t){return t.isolatedSpacesEnabled}function Wj(t){return t.setIsMobile}function Uj(t){return t.isSettingsDialogOpen}function Vj(t){return t.setSettingsDialogOpen}function Hj(t){return t.runOverviewKey!==null}function qj(t){return t.isScheduledTasksDialogOpen}function Kj(t){return t.isArchivePageOpen}function Gj(t){return t.isIntegrationsCatalogOpen}function Zj(t){return t.isUsageStatsPageOpen}function Xj(t){return t.isSourceBoardOpen}function Yj(t){return t.isOverviewOpen}function Jj(t){return t.worktreesPageProjectId}function Qj(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function e3(t){return t.isCommandPaletteOpen}function t3(t){return t.isHelpDialogOpen}function s3(t){return t.isProjectActionsDialogOpen}function n3(t){return t.isOpenCodeStatusDialogOpen}function r3(t){return t.accessDialog!==null}function o3(t){return t.applyDialog!==null}function i3(t){return t.setupOutputDialog!==null}function a3(t){return t.openGuestPageId}function l3(){return G.getState().setOpenGuestPage(null)}function c3(){return rc(l3)}function d3(){return G1()}function u3(){return od(!1)}function f3(){return u3}function p3(){return G.getState().closeMainSurfaces()}function m3(){const t=p3,e=st.subscribe((n,r)=>{const o=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,i=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function h3(){return G.getState().setCommandPaletteOpen(!1)}function g3(){return G.getState().setHelpDialogOpen(!1)}function x3(){return G.getState().setProjectActionsDialogOpen(!1)}function b3(){return G.getState().setOpenCodeStatusDialogOpen(!1)}function w3(){return pn.getState().closeAccessDialog()}function y3(){return pn.getState().closeApplyDialog()}function v3(){return pn.getState().closeSetupOutputDialog()}function S3(){return G.getState().setOpenGuestPage(null)}const ji="openchamber_requests_in_flight",Ru=1e3,k3=300*1e3,so=Math.ceil(k3/Ru),j3=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ji)==="1"}catch{return!1}},Du=()=>({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 C3=1;const T3=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},N3=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},_u=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,o)=>r-o),n},Dn=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},E3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,o)=>{const i=C3++;T3(i,Date.now());try{return await e(r,o)}finally{N3(i)}};window.fetch=n},Al=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Vn=t=>{t.length>so&&t.splice(0,t.length-so)},I3=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=_u(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Dn(e,50)),t.p90Samples.push(Dn(e,90)),t.p99Samples.push(Dn(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Vn(t.samples),Vn(t.p50Samples),Vn(t.p90Samples),Vn(t.p99Samples),Vn(t.maxSamples),t.lastSampleAt=Date.now()},P3=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(I3,Ru))},Ol=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Ml=t=>{if(!(typeof window>"u"))try{if(t){Ol(),Al(),window.localStorage.setItem(ji,"1"),window.__openchamberRequestsInFlight__=Du(),E3(),P3();return}window.localStorage.removeItem(ji),Ol(),Al(),delete window.__openchamberRequestsInFlight__}catch{}},k5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Du();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},j5=()=>{if(typeof window>"u")return Fl();const t=window.__openchamberRequestsInFlight__;if(!j3()||!t)return Fl();const e=_u(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:Dn(e,50),ageP90:Dn(e,90),ageP99:Dn(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:so}},Fl=()=>({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:so}),R3=(t,e,n)=>t1(t.filter(r=>!id(r)&&!r.parentID),e,n),D3=()=>R3(ps.getState().activeSessions,go.getState().ids,Zi.getState().rankById??s1),_3=(t,e,n)=>{if(t.length===0)return;const r=t.findIndex(i=>i.id===e);let o=n>0?0:t.length-1;return r>=0&&(o=(r+n+t.length)%t.length),t[o]},A3=()=>{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()??"":""},O3=async()=>{const t=A3()||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")},Ll="openchamber:menu-action",$l="openchamber:check-for-updates",M3=t=>{const e=Le.c(24),{t:n}=rt(),r=st(F3),o=G(L3),i=G($3),a=G(B3),d=G(z3),u=G(W3),l=G(U3),f=G(V3),m=Sc(H3),{setThemeMode:p}=io(),h=c.useRef(!1),x=G(q3);let g,b;e[0]!==x?(g=()=>{zr()&&Us("desktop_set_menu_shortcuts",{shortcuts:n1(x)}).catch(K3)},b=[x],e[0]=x,e[1]=g,e[2]=b):(g=e[1],b=e[2]),c.useEffect(g,b);let w;e[3]!==m?(w=()=>{h.current||(h.current=!0,m().then(G3).finally(()=>{h.current=!1}))},e[3]=m,e[4]=w):w=e[4];const j=w,v=Z3;let T;e[5]!==u?(T=C=>{const y=st.getState().currentSessionId,E=_3(D3(),y,C);E&&(u(!1),st.getState().setCurrentSession(E.id,Hs(E)))},e[5]=u,e[6]=T):T=e[6];const F=T,_=X3;let A;e[7]!==F||e[8]!==t||e[9]!==r||e[10]!==f||e[11]!==i||e[12]!==u||e[13]!==l||e[14]!==p||e[15]!==n||e[16]!==o||e[17]!==a||e[18]!==d?(A=C=>{e:switch(C){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 y=st.getState(),E=Ht.getState().currentDirectory;r(y.currentSessionId&&E?{directoryOverride:E}:void 0);break e}case"new-worktree-session":{u(!1),i1();break e}case"change-workspace":{v();break e}case"toggle-right-sidebar":{const y=Ht.getState().currentDirectory;if(!y)break e;const E=G.getState(),B=fs(y),$=E.contextPanelByDirectory[B],O=$?ff($.tabs,E.contextSurfaceZones,"right",tr($,"right").activeTabId):null;$?.isOpen?E.closeContextPanel(B):O?E.setActiveContextPanelTab(B,O):E.openContextSurface(B,"git");break e}case"open-right-sidebar-git":{const y=Ht.getState().currentDirectory;if(!y)break e;G.getState().openContextSurface(fs(y),"git");break e}case"open-right-sidebar-files":{const y=Ht.getState().currentDirectory;if(!y)break e;G.getState().openContextSurface(fs(y),"file");break e}case"toggle-terminal":{const y=Ht.getState().currentDirectory;if(!y)break e;G.getState().openContextSurface(fs(y),"terminal");break e}case"toggle-context-panel-expanded":{o1(Ht.getState().currentDirectory);break e}case"copy":{const y=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(y)||O3();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":{r1();break e}case"toggle-sidebar":{d();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{La(-1);break e}case"go-forward":{La(1);break e}case"previous-session":{F(-1);break e}case"next-session":{F(1);break e}case"previous-project":{_(-1);break e}case"next-project":{_(1);break e}case"help-dialog":{a();break e}case"download-logs":nd().catch(()=>{Te.error(n("openCodeStatusDialog.toast.collectFailed"))})}},e[7]=F,e[8]=t,e[9]=r,e[10]=f,e[11]=i,e[12]=u,e[13]=l,e[14]=p,e[15]=n,e[16]=o,e[17]=a,e[18]=d,e[19]=A):A=e[19];const M=A;let S,k;e[20]!==M||e[21]!==j?(S=()=>{const C=E=>{const B=E.detail;B&&M(B)},y=()=>{j()};return window.addEventListener(Ll,C),window.addEventListener($l,y),()=>{window.removeEventListener(Ll,C),window.removeEventListener($l,y)}},k=[M,j],e[20]=M,e[21]=j,e[22]=S,e[23]=k):(S=e[22],k=e[23]),c.useEffect(S,k)};function F3(t){return t.openNewSessionDraft}function L3(t){return t.toggleCommandPalette}function $3(t){return t.setCommandPaletteOpen}function B3(t){return t.toggleHelpDialog}function z3(t){return t.toggleSidebar}function W3(t){return t.setSessionSwitcherOpen}function U3(t){return t.setSettingsDialogOpen}function V3(t){return t.setAboutDialogOpen}function H3(t){return t.checkForUpdates}function q3(t){return t.shortcutOverrides}function K3(t){console.warn("[menu-actions] failed to update menu shortcuts",t)}function G3(){const{available:t,error:e}=Sc.getState();if(e){Te.error("Failed to check for updates",{description:e});return}t||Te.success("You are on the latest version")}function Z3(){cr.requestDirectoryDialog()}function X3(t){const{activeProjectId:e,projects:n,setActiveProject:r}=ts.getState();if(n.length===0)return;const o=n.findIndex(d=>d.id===e);let i=t>0?0:n.length-1;o>=0&&(i=(o+t+n.length)%n.length);const a=n[i];a&&r(a.id)}const Bl="openchamber:install-extension",Au=t=>bx({source:t,confirmed:!1}),Y3=()=>{const t=Le.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(e4,e)};function J3(t){const{url:e}=t.detail??{};typeof e=="string"&&e&&Au(e)}function Q3(t){return t.forEach(Au)}function e4(){const t=J3;return window.addEventListener(Bl,t),pf().then(Q3),()=>window.removeEventListener(Bl,t)}const zl=(t,{isAdmitted:e,isPlaced:n,isPinned:r,zones:o})=>!e||t.parentID||t.time?.archived||id(t)?!1:n||o.pinned&&r||o.work&&Oi(t),t4="openchamber:tray-action",s4=5e3,n4=500,r4=20,Wl=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ul=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Ou=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Mu=t=>t.title.trim()||"Question",o4=new Set,i4=(t,e)=>m1(t,e,o4,Zi.getState().rankById),a4=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},l4=(t,e,n,r,o)=>{if(!t)return"";const i=xr(n,r,t),a=e.project?.name,d=i?.label?.trim()||a?.trim()||a4(t),u=qr(t);let l=u&&o.get(u)||"";if(!l){for(const[f,m]of Mn.getState().directories)if(qr(f)===u){l=m.status?.current??"";break}}if(!l)for(const f of r.values()){const m=u?Vr(f,u):void 0;if(m?.branch){l=m.branch;break}}return l?`${d} · ${l}`:d},c4=()=>{const{dictionary:t}=xf.getState(),e=(l,f)=>bf(t,l,f),{results:n,dropdownProviderIds:r,displayMode:o,extensionProviders:i}=fd.getState(),a=o==="remaining"?"remaining":"usage";if(!r.length)return{mode:a,groups:[]};const d=new Map(n.map(l=>[l.providerId,l])),u=[];for(const l of h1(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:x1(h),value:g1(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}},d4=async()=>{try{if(ro())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=mf();if(e&&da(e,t))return"Local OpenChamber";const r=(await Di()).hosts.find(o=>e?da(e,ic(o)):!1);return r?.label?.trim()?hf(r.label.trim()):"Instance"}catch{return""}},u4=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=oi()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,a]of o.children.entries()){const d=a.getState();d.vcs?.branch&&e.set(qr(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;n.push({kind:"permission",id:f.id,sessionId:m,sessionTitle:"",label:Ou(f),directory:i,canSave:pd(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;n.push({kind:"form",id:f.id,sessionId:m,sessionTitle:"",label:Mu(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},f4=(t,e)=>{const n=ps.getState().activeSessions,r=d1(n),o=S=>r.descendantsOf(S,"active").map(k=>k.id),i=ts.getState().projects,a=st.getState().availableWorktreesByProject,d=go.getState().ids,u=(S,k)=>{const C=Hs(S),y=$a(C,i,a);return mr(C)||S.projectID===gf?zl(S,{isAdmitted:y,isPlaced:k.chats,isPinned:!1,zones:{pinned:!1,work:!1}}):zl(S,{isAdmitted:y,isPlaced:Ei(C)||xr(i,a,C)!==null,isPinned:sd(d,S.directory,S.id),zones:k})},l=oc.getState(),f={chats:l.showChatsSection,pinned:l.showPinnedSection,work:G.getState().sessionWorkEnabled&&l.showWorkSection},m={chats:!0,pinned:!0,work:!0},p=u1(ri.getState().activeSessionIds,[ad.getState().runningSessionIds,ld.getState().sessionIds,cd.getState().sessionIds,dd.getState().bySession.keys()]),h=S=>p1(S)&&!p.has(S.id),x=G.getState().dockBadgeEnabled?n.filter(S=>h(S)&&u(S,f)):[],g=x.length,b=x.sort((S,k)=>(k.time.idle??k.time.updated)-(S.time.idle??S.time.updated)||S.id.localeCompare(k.id)).slice(0,10).map(S=>({id:S.id,title:S.title,directory:Hs(S)??""}));if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:g,dockUnreadSessions:b};const w=u4(),j=new Map(w.titleById);for(const S of n)S?.id&&S.title&&j.set(S.id,S.title);const v=ri.getState().statusById,T=S=>{const k=w.statusById.get(S);return k&&k!=="idle"?k:v.get(S)?.status.type??k??"idle"},F=S=>{const k=S.map(C=>T(C));return k.includes("busy")?"busy":k.includes("retry")?"retry":"idle"},_=n.filter(S=>S?.id&&!S.parentID).filter(S=>u(S,m)).slice().sort(i4).slice(0,r4).map(S=>{const k=[S.id,...o(S.id)],C=Hs(S)??"";return{id:S.id,title:S.title||"Untitled session",status:F(k),branch:C?w.branchByDirectory.get(C)??"":"",unseen:h(S)?1:0,hasError:h(S)&&f1(S),directory:C,subtitle:l4(C,S,i,a,w.branchByDirectory)}}),A=w.approvals.map(S=>({...S,sessionTitle:j.get(S.sessionId)||""})),M=new Set(A.map(S=>S.id));for(const[S,k]of ud.getState().bySession){const C=j.get(S)||"";for(const y of k.permissions)M.has(y.id)||(M.add(y.id),A.push({kind:"permission",id:y.id,sessionId:S,sessionTitle:C,label:Ou(y),directory:k.directory,canSave:pd(y.save)}));for(const y of[...k.forms,...k.pages])M.has(y.id)||(M.add(y.id),A.push({kind:"form",id:y.id,sessionId:S,sessionTitle:C,label:Mu(y),directory:k.directory,canSave:!1}))}return{sessions:_,approvals:A.filter(S=>$a(S.directory,i,a)),instanceName:t,usage:c4(),dockBadgeCount:g,dockUnreadSessions:b}},p4=()=>{c.useEffect(()=>{if(!Wl()||!zr())return;const t=Ul();let e=!1,n="",r=null,o="";const i=()=>{if(e)return;const y=f4(o,t),E=JSON.stringify(y);E!==n&&(n=E,Us("desktop_tray_update",y))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},n4))},d=ps.subscribe(()=>a()),u=ri.subscribe(()=>a()),l=ad.subscribe(()=>a()),f=ld.subscribe(()=>a()),m=cd.subscribe(()=>a()),p=dd.subscribe(()=>a()),h=G.subscribe((y,E)=>{(y.dockBadgeEnabled!==E.dockBadgeEnabled||y.sessionWorkEnabled!==E.sessionWorkEnabled)&&a()}),x=ts.subscribe(()=>a()),g=st.subscribe(()=>a()),b=go.subscribe(()=>a()),w=oc.subscribe((y,E)=>{(y.showChatsSection!==E.showChatsSection||y.showPinnedSection!==E.showPinnedSection||y.showWorkSection!==E.showWorkSection)&&a()}),j=()=>{e=!0,r!==null&&window.clearTimeout(r),d(),u(),l(),f(),m(),p(),h(),x(),g(),b(),w()};if(!t)return i(),j;d4().then(y=>{e||(o=y,i())});const v=new Map,T=()=>{if(e)return;let y;try{y=oi()}catch{return}const E=new Set;for(const[B,$]of y.children.entries())E.add(B),v.has(B)||v.set(B,$.subscribe(()=>a()));for(const[B,$]of v)E.has(B)||($(),v.delete(B))};let F=null;try{F=oi().subscribeRegistry(()=>{T(),a()})}catch{}T();const _=Mn.subscribe(()=>a()),A=ud.subscribe(()=>a()),M=Zi.subscribe(()=>a()),S=fd.subscribe(()=>a()),k=Wt.subscribe((y,E)=>{y.isInitialized&&!E.isInitialized&&Lo(!0)});Lo(!0);const C=window.setInterval(()=>{T(),i()},s4);return i(),()=>{j(),window.clearInterval(C),_(),A(),M(),S(),k(),F?.();for(const y of v.values())y();v.clear()}},[]),c.useEffect(()=>{if(!Wl()||!zr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{switch(i.type){case"mark-all-read":l1().then(()=>c1()).catch(()=>{});break;case"menu-opened":Ul()&&Lo();break;case"respond-permission":a1(i.sessionId,i.id,i.response).catch(()=>{Te.error("Failed to respond to permission request")});break}};let r=null,o=!1;return e(t4,i=>{const a=i?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(i=>{if(o){i();return}r=i,Us("desktop_tray_actions_ready")}).catch(()=>{}),()=>{o=!0;try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},m4=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,h4=(t,e,n,r)=>r||[t,e,n].filter(Boolean).join("|")||void 0,g4=t=>{t.kind!=="plugin"||!t.title||Te.info(t.title,{id:h4(t.kind,t.title,t.body,t.tag),description:t.body})},x4=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,b4=t=>{const e=Le.c(3),n=!0;let r,o;e[0]!==n?(r=()=>{if(!(_s()||!ac()||!globalThis.window))return tn(w4)},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function w4(t){if(t.type!=="notification")return;const e=G.getState();if(!e.nativeNotificationsEnabled)return;const n=m4();if(x4(t.payload,n)){g4(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&n)return;nc()?.notifications?.notifyAgentCompletion(t.payload)}const y4=()=>{const t=Le.c(4),{t:e}=rt(),n=G(v4);let r,o;t[0]!==n||t[1]!==e?(r=()=>tn(i=>{i.type==="browser-provider-reset"&&(n("builtin"),Te.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),c.useEffect(r,o)};function v4(t){return t.setBrowserProvider}const S4=()=>{const t=Le.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],c.useEffect(j4,e)};function k4(t){t.type==="guests-changed"?b1():t.type==="event-stream-ready"&&td()}function j4(){return tn(k4)}const C4=()=>{const t=Le.c(3),{t:e}=rt();let n,r;t[0]!==e?(n=()=>tn(o=>{if(o.type!=="limit-failover")return;const{failover:i}=o,a=Wt.getState().providers,d=u=>a.find(l=>l.id===u);if(i.kind==="account"){const u=d(i.providerId)?.name||i.providerId;Te.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}Te.info(e("chat.limitFailover.toast.model",{model:Ba(d(i.providerId),i.modelId),fallback:Ba(d(i.toProviderId),i.toModelId)}))}),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),c.useEffect(n,r)},Vl="relay-limit-reached",T4=()=>{const t=Le.c(3),{t:e}=rt();let n,r;t[0]!==e?(n=()=>{const o=()=>{Te.error(e("relayConnection.limitReached.title"),{id:Vl,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:N4}})};return ua(lc()?.getStatus())&&o(),wf(a=>{ua(a)?o():(a.state==="connected"||a.state==="idle")&&Te.dismiss(Vl)})},r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),c.useEffect(n,r)};function N4(){return lc()?.retry()}const Hl=()=>{yf()||(w1(),y1(Rp.map(t=>t.id)))},E4=(t,e)=>{const n=Le.c(5);let r;n[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(Hl,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(Hl,3e3);return()=>clearTimeout(i)},n[0]=t,n[1]=r):r=n[1];let o;n[2]!==e||n[3]!==t?(o=[t,e],n[2]=e,n[3]=t,n[4]=o):o=n[4],c.useEffect(r,o)},ql="pwa-install-toast-shown",Kl="pwa-install-toast-dismissed",I4=()=>{const t=Le.c(6),{browserTab:e}=Dp(),{t:n}=rt(),r=c.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),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&&(Te.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"&&Te.success(r.current("pwa.installPrompt.started"))},p=x=>{const g=x;if(typeof g.prompt!="function")return;g.preventDefault(),u=g;const b=fa(),w=vf();_p({dismissed:b.getItem(Kl),sessionShown:w.getItem(ql),hasActiveToast:l!==null})&&(w.setItem(ql,"true"),l=Te.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:()=>{fa().setItem(Kl,"true"),f()}}}))},h=()=>{u=null,f(),Te.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)},Fu=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,P4=()=>{xs.setState({byRoot:{},runtimeSnapshots:{}});const t=G.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const n of Ri)t.closeContextZone(e,n)},R4=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Lu=async(t,e)=>{const n=(await Di()).hosts.find(o=>o.id===t);if(!n)throw new Error("host-not-found");if(n.relay){await Cf(n.id,e);return}const r=Tf(ic(n));if(!r)throw new Error("host-not-found");Nf({apiBaseUrl:r,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:Ef(n),sshForwarded:n.sshForwarded===!0})},D4=async t=>{const e=await Di(),n=await kf(t,e.hosts);await jf({hosts:n.hosts,defaultHostId:e.defaultHostId||n.hostId,initialHostChoiceCompleted:!0}),await Lu(n.hostId,{reconnectActive:!0})},_4=async t=>{const e=await Sf();for(const n of e)try{n.type==="pairing"?await D4(n.link):await Lu(n.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",n.type,o),t(R4(o))}},Ci="project-config-invalid",A4=()=>{const t=Le.c(9),{t:e}=rt(),n=Wt(O4);let r;t[0]!==n?(r=p=>p.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const o=Wt(r),[i,a]=Ut.useState(!1);let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const p=Wt.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){Te.dismiss(Ci);return}Te.error(e("projectConfigError.toast.title"),{id:Ci,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&s.jsx(gs,{as:"span",outerClassName:"max-h-40",className:"whitespace-pre-wrap break-words font-mono typography-meta",disableHorizontal:!0,children:o.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick: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]),Ut.useEffect(l,f);let m;return t[8]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[8]=m):m=t[8],Ut.useEffect(F4,m),null};function O4(t){return t.activeDirectoryKey}function M4(){Te.dismiss(Ci)}function F4(){return M4}const L4="\x1B",$4=new RegExp(`${L4}\\[[0-9;?]*[ -/]*[@-~]`,"g"),Pr=Ns().transform(t=>t.replace($4,"").trim()).nullish(),B4=sn({isOpenCodeReady:dr().optional(),openCodeRunning:dr().optional(),lastOpenCodeError:Pr,opencodeBinaryResolved:Pr,lastOpenCodeLaunchDiagnostics:sn({sourceBinary:Pr,binary:Pr}).nullish()}),z4=async(t,e=qs)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=B4.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},W4=(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"}},U4=sn({openchamberVersion:Ns()}),V4=async(t,e=qs)=>{const n=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)return null;const r=U4.safeParse(await n.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},H4=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function q4({version:t}){const{t:e}=rt(),[n,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const d=await Op();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=n.kind==="manual"?n:null,a=i?.info?.updateCommand||"openchamber update";return s.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),s.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),s.jsxs(ft,{type:"button",onClick:()=>{o()},disabled:n.kind==="checking",children:[s.jsx(oe,{name:n.kind==="checking"?"loader":"download",className:n.kind==="checking"?"size-4 animate-spin":"size-4"}),n.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&s.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),s.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),s.jsx(Ap,{open:n.kind==="available",onOpenChange:d=>{d||r({kind:"idle"})},info:n.kind==="available"?n.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Gl=hr(()=>Lt(()=>import("./OnboardingScreen-Bpj6hpDe.js"),__vite__mapDeps([272,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}))),K4=()=>Lt(()=>import("./AboutDialog-uNKjHvzl.js"),__vite__mapDeps([273,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,249])).then(t=>t.AboutDialog),G4=()=>Lt(()=>import("./MemoryDebugPanel-ylQytlyw.js"),__vite__mapDeps([274,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),Z4=()=>{const t=Le.c(6),e=G(e5),n=G(t5);let r;t[0]!==n?(r=()=>n(!1),t[0]=n,t[1]=r):r=t[1];const o=xo(e,K4,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==n?(i=s.jsx(o,{open:e,onOpenChange:n}),t[2]=o,t[3]=e,t[4]=n,t[5]=i):i=t[5],i},X4=t=>{const e=Le.c(3),{onClose:n}=t,r=xo(!0,G4,n);let o;return e[0]!==r||e[1]!==n?(o=r?s.jsx(r,{onClose:n}):null,e[0]=r,e[1]=n,e[2]=o):o=e[2],o},Y4=t=>{const e=Le.c(47),{onRetry:n,isRetrying:r}=t,{t:o}=rt(),[i,a]=c.useState(null);let d,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const S=new AbortController,k=Jt(),C=setTimeout(()=>S.abort(),5e3);return z4(S.signal).then(y=>{!S.signal.aborted&&Jt()===k&&a(y)}).catch(s5).finally(()=>clearTimeout(C)),()=>{S.abort(),clearTimeout(C)}},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 S=new AbortController,k=Jt(),C=setTimeout(()=>S.abort(),5e3);return V4(S.signal).then(y=>{S.signal.aborted||Jt()!==k||f(y&&H4(y)?y:null)}).catch(n5).finally(()=>clearTimeout(C)),()=>{S.abort(),clearTimeout(C)}},p=[],e[2]=m,e[3]=p):(m=e[2],p=e[3]),c.useEffect(m,p);const h=Wt(r5),x=i?null:h?.message??null;if(l){let S;e[4]!==l?(S=s.jsx(q4,{version:l}),e[4]=l,e[5]=S):S=e[5];let k;e[6]!==r||e[7]!==o?(k=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=k):k=e[8];let C;e[9]!==r||e[10]!==n||e[11]!==k?(C=s.jsx(ft,{type:"button",variant:"outline",onClick:n,disabled:r,children:k}),e[9]=r,e[10]=n,e[11]=k,e[12]=C):C=e[12];let y;return e[13]!==S||e[14]!==C?(y=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[S,C]})}),e[13]=S,e[14]=C,e[15]=y):y=e[15],y}let g;e[16]!==o?(g=o("startup.initRecovery.title"),e[16]=o,e[17]=g):g=e[17];let b;e[18]!==g?(b=s.jsx("h1",{className:"typography-h1 text-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let w;e[20]!==i||e[21]!==h||e[22]!==o?(w=o(W4(i,h)),e[20]=i,e[21]=h,e[22]=o,e[23]=w):w=e[23];let j;e[24]!==w?(j=s.jsx("p",{className:"typography-markdown text-muted-foreground",children:w}),e[24]=w,e[25]=j):j=e[25];let v;e[26]!==b||e[27]!==j?(v=s.jsxs("div",{className:"flex flex-col gap-2",children:[b,j]}),e[26]=b,e[27]=j,e[28]=v):v=e[28];let T;e[29]!==x||e[30]!==o?(T=x&&s.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:x})]}),e[29]=x,e[30]=o,e[31]=T):T=e[31];let F;e[32]!==i||e[33]!==o?(F=i&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[32]=i,e[33]=o,e[34]=F):F=e[34];let _;e[35]!==r||e[36]!==o?(_=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=_):_=e[37];let A;e[38]!==r||e[39]!==n||e[40]!==_?(A=s.jsx(ft,{type:"button",onClick:n,disabled:r,children:_}),e[38]=r,e[39]=n,e[40]=_,e[41]=A):A=e[41];let M;return e[42]!==T||e[43]!==F||e[44]!==A||e[45]!==v?(M=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[v,T,F,A]})}),e[42]=T,e[43]=F,e[44]=A,e[45]=v,e[46]=M):M=e[46],M};function J4({apis:t}){Y3(),c.useEffect(()=>v1(),[]),c.useEffect(()=>{If("App:mounted"),Pf()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Wt(L=>L.initializeApp),n=Wt(L=>L.isInitialized),r=Wt(L=>L.isConnected),o=Wt(L=>L.providersLoaded),i=Wt(L=>L.agentsLoaded),a=Wt(L=>L.loadProviders),d=Wt(L=>L.loadAgents),u=st(L=>L.error),l=st(L=>L.clearError),f=Ht(L=>L.currentDirectory),m=Ht(L=>L.isSwitchingDirectory),[p,h]=c.useState(!1),x=hn(L=>L.refreshAll),g=Ql(L=>L.refresh),[b,w]=c.useState(()=>t.runtime.isVSCode),[j,v]=c.useState(!1),[T,F]=c.useState(0),[_,A]=c.useState(0),[M,S]=c.useState(!1),k=G(L=>L.wideChatLayoutEnabled),C=G(L=>L.mobileKeyboardMode),y=c.useMemo(()=>_s(),[]),[E,B]=c.useState(()=>pa()),[$,O]=c.useState(()=>{const L=Ro();return L!==null?ma({isDesktopShell:!0,bootOutcome:L}):null}),z=c.useRef(!1),{t:J}=rt(),K=c.useRef(!1);c.useEffect(()=>{if(!n||E!=="valid"||K.current)return;const L=Ro();L?.target!=="local"||L.status!=="ok"||!L.sshStartupFallbackHostId||(K.current=!0,Te.error(J("desktopHostSwitcher.startup.title"),{description:J("desktopHostSwitcher.startup.fellBackToLocal")}))},[E,n,J]);const ee=c.useRef(!1);c.useEffect(()=>{!n||!Fu()||ee.current||(ee.current=!0,Te.info(J("desktopSafeStart.title"),{description:J("desktopSafeStart.description"),duration:1/0}))},[n,J]),c.useEffect(()=>(ha(p),Ml(p),()=>{ha(!1),Ml(!1)}),[p]),c.useEffect(()=>{Rf(C)},[C]),c.useEffect(()=>{w(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>rc(L=>{Fp(L)&&Lp(L),A(ne=>ne+1),v(!1),F(ne=>ne+1)}),[]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",k),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[k]),c.useEffect(()=>(ga(t),()=>ga(null)),[t]),c.useEffect(()=>{r&&(g(t.sourceControl),x(t.sourceControl,{force:!0}),S1(t.trackers))},[t.sourceControl,t.trackers,r,x,g,_]),k1();const V=E==="valid",Y=$?.screen==="main";c.useEffect(()=>{if(!Df({isDesktopShell:y,bootOutcomeKnown:V}))return;j1();const L=setTimeout(()=>{const ne=document.getElementById("initial-loading");ne&&(ne.classList.add("fade-out"),setTimeout(()=>{ne.remove()},300))},150);return()=>clearTimeout(L)},[y,V]),c.useEffect(()=>{if(!y||E!=="malformed")return;const L=document.getElementById("initial-loading");L&&(L.textContent="Desktop startup failed — please restart the app.")},[y,E]),c.useEffect(()=>{b||e()},[e,b]),c.useEffect(()=>{if(b||n)return;let L=!0,ne,W=0;const te=10,Z=1e3,me=async()=>{if(!L)return;if(W>=te){v(!0);return}const Ie=Wt.getState();if(Ie.isInitialized){v(!1);return}W+=1,await Ie.initializeApp();const fe=Wt.getState();if(!L)return;if(fe.isInitialized){v(!1);return}if(W>=te){v(!0);return}const je=Math.min(Z*Math.pow(2,W-1),4e3);ne=setTimeout(me,je)};return ne=setTimeout(me,Z),()=>{L=!1,ne&&clearTimeout(ne)}},[T,n,b]),c.useEffect(()=>{n&&v(!1)},[n]),c.useEffect(()=>{if(!j)return;const L=document.getElementById("initial-loading");L&&(L.classList.add("fade-out"),setTimeout(()=>{L.remove()},300))},[j]),c.useEffect(()=>{if(b||!r||o&&i)return;let L=!0,ne=0;const W=15,te=async()=>{const me=Wt.getState();if(!(me.providersLoaded&&me.agentsLoaded))try{me.providersLoaded||await a({source:"startupRecovery"}),Wt.getState().agentsLoaded||await d({source:"startupRecovery"})}catch{}};te();const Z=setInterval(()=>{if(L){if(++ne>=W){clearInterval(Z);return}te()}},2e3);return()=>{L=!1,clearInterval(Z)}},[r,b,d,a,o,i]),c.useEffect(()=>{m||b||r&&Qo.setDirectory(f)},[f,m,r,b]),c.useEffect(()=>{if(typeof window>"u")return;const L=ne=>{const W=ne.detail,te=typeof W?.sessionId=="string"?W.sessionId.trim():"";if(!te)return;const Z=typeof W?.directory=="string"&&W.directory.trim().length>0?W.directory.trim():null,me=typeof W?.messageId=="string"&&W.messageId.trim()||null;xa(te,String(W?.runtimeKey??"").trim(),me)||za(te,{directory:Z,messageId:me,requireKnownSession:W?.requireKnownSession===!0})};return window.addEventListener("openchamber:open-session",L),_f().then(ne=>{for(const W of ne)xa(W.sessionId,W.runtimeKey,W.messageId)||(W.requireKnownSession?za(W.sessionId,{messageId:W.messageId,requireKnownSession:!0}):C1(W.sessionId,W.messageId))}),()=>window.removeEventListener("openchamber:open-session",L)},[]),c.useEffect(()=>{if(!_s())return;const L=()=>{_4(ne=>{Te.error(J(ne==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":ne==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",L),L(),()=>window.removeEventListener("openchamber:host-actions-ready",L)},[J]);const ae=c.useRef({attempt:null,running:!1,done:!1});c.useLayoutEffect(()=>{const L=ae.current;L.attempt||(L.attempt=$p({selectNow:!Bp().sessionId}))},[]),c.useEffect(()=>{const L=ae.current,ne=()=>{const W=L.attempt;if(!W||L.running||L.done)return;const te=Wt.getState().isInitialized;L.running=!0,W().then(Z=>{if(L.running=!1,Z!=="failed"||te){L.done=!0;return}Wt.getState().isInitialized&&ne()})};ne()},[n]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{Us("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Rr()})};return window.addEventListener("openchamber:open-mini-chat",L),()=>window.removeEventListener("openchamber:open-mini-chat",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{const ne=st.getState().currentSessionId;ne&&ed(ne)};return window.addEventListener("focus",L),()=>window.removeEventListener("focus",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=ne=>{const W=ne.detail,te=typeof W?.directory=="string"&&W.directory.trim().length>0?W.directory.trim():null,Z=typeof W?.projectId=="string"&&W.projectId.trim().length>0?W.projectId.trim():null,me=!!(te||Z);G.getState().setSessionSwitcherOpen(!1),st.getState().openNewSessionDraft({target:me?"project":"chat",selectedProjectId:me?Z:null,directoryOverride:me?te:null,preserveDirectoryOverride:!!te})};return window.addEventListener("openchamber:open-draft-session",L),()=>window.removeEventListener("openchamber:open-draft-session",L)},[]),c.useEffect(()=>{typeof window>"u"||!n||m||z.current||(z.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,m]),T1(),b4(),zp(f||null),y4(),Wp(t.sourceControl),Up(t.trackers),Vp(),S4(),C4(),N1(),Hp(),T4(),E4(n&&r,_),I4(),E1(),X1(),qp();const P=c.useCallback(()=>{h(L=>!L)},[]);M3(P),p4(),Y1(!0),c.useEffect(()=>{const L=()=>h(ne=>!ne);return window.addEventListener("openchamber:memory-debug-toggle",L),()=>window.removeEventListener("openchamber:memory-debug-toggle",L)},[]),c.useEffect(()=>{u&&setTimeout(()=>l(),5e3)},[l,u]),c.useEffect(()=>{if(!y||E!=="not-injected")return;let L=!1,ne=0;const W=200,te=2e3,Z=50,me=()=>{if(L)return;ne++;const Ie=pa();if(Ie!=="not-injected"){if(L=!0,B(Ie),Ie==="valid"){const je=Ro();je&&O(ma({isDesktopShell:!0,bootOutcome:je}))}return}const fe=Math.min(W*Math.pow(1.1,ne),te);if(ne>=Z){const je=document.getElementById("initial-loading");je&&!je.textContent?.includes("taking longer")&&(je.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(me,fe)};return window.setTimeout(me,W),()=>{L=!0}},[y,E]);const de=c.useCallback(async()=>{if(Af({isDesktopShell:_s(),isDesktopLocalOriginActive:ro()})){await Of();return}window.location.reload()},[]),q=c.useCallback(async()=>{if(!M){v(!1),S(!0);try{await Wt.getState().initializeApp()}finally{S(!1)}Wt.getState().isInitialized||F(L=>L+1)}},[M]),Q=L=>{if(L.screen==="recovery")return L.variant};if(y&&$&&$.screen!=="main"){if($.screen==="chooser")return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Gl,{mode:"first-launch",localAvailable:$.localAvailable!==!1,onCliAvailable:de,onChooseRemote:()=>{}})})})});const L=Q($),ne=$.screen==="recovery"&&"url"in $?$.url:void 0,W=$.screen==="recovery"&&"hostId"in $?$.hostId:void 0;return s.jsx(Qt,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Gl,{mode:"recovery",recoveryVariant:L,recoveryHostUrl:ne,recoveryHostLabel:void 0,recoveryHostId:W,localAvailable:$.localAvailable!==!1,onCliAvailable:de})})})})}return j&&!n&&!b?s.jsx(Qt,{children:s.jsx(Y4,{onRetry:()=>{q()},isRetrying:M},_)}):s.jsx(Qt,{children:s.jsx(I1,{sdk:Qo.getSdkClient(),directory:f||"",children:s.jsx(P1,{apis:t,children:s.jsx(Kp,{children:s.jsx(R1,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:y?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(D1,{backgroundWorkEnabled:!0}),s.jsx(Gp,{}),s.jsx(A4,{}),s.jsx($j,{}),y?s.jsx(Zp,{ready:V&&Y}):null,s.jsx(_1,{}),s.jsx(A1,{}),s.jsx(O1,{}),s.jsx(M1,{}),s.jsx(F1,{}),s.jsx(Xp,{}),s.jsx(Z4,{}),p&&s.jsx(X4,{onClose:()=>h(!1)})]})})})})},_)})}function Q4(t){const e=Le.c(2);let n;return e[0]!==t?(n=s.jsx(Mp,{children:s.jsx(J4,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function e5(t){return t.isAboutDialogOpen}function t5(t){return t.setAboutDialogOpen}function s5(){}function n5(){}function r5(t){return t.lastInitFailure}const o5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Mf();Fu()&&P4();Yp();Jp();Ff().then(()=>{L1().catch(t=>{console.error("[main] settings init failed:",t)}),$1(),B1(),z1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const $u=document.getElementById("root");if(!$u)throw new Error("Root element not found");W1();Bu.createRoot($u).render(s.jsx(Ut.StrictMode,{children:s.jsx(U1,{children:s.jsx(V1,{children:s.jsx(H1,{children:s.jsx(q1,{children:s.jsx(Q4,{apis:o5})})})})})}));const C5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Ga as P,vb as a,Jk as b,tj as c,sj as d,nj as e,cj as f,j5 as g,uj as h,rj as i,oj as j,ij as k,aj as l,R3 as m,sw as n,Qk as o,lj as p,C5 as q,k5 as r,ej as s,Id as u};
|