@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,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/officeDocument-COfYG-XF.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/useAppFontEffects-D9nf8G19.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-g52ii4Gs.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/documentClient-B0iRikhq.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/runtimeEndpointReset-BJm_77m2.js","assets/space-apply-BT-PjBF5.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useMarkdownLocalAssets-wPn7MXUN.js","assets/fileContentPoller-CKcqqhzG.js","assets/useInlineCommentController-CzeMiLCm.js","assets/JsonTreeView-BXv2HzlC.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/useNextRenderData-CVFf78p9.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/isFilePlainText-DJ_bXU7C.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-C7ZRQ5-2.js","assets/appThemeRegistry-BwyM6n38.js","assets/textMateThemeFromAppTheme-CRhUx8P-.js","assets/ReviewCards-CU1YHZkQ.js","assets/contextFileOpenGuard-CKnYjgFC.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/moveWorkspacePath-C4_JgpNC.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/useWholeFileComment-BexRzYws.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/scheduledTasksApi-CKPLiwD-.js","assets/pdfjs-uwkGOIm9.js","assets/vendor-pdfjs-dist-CiCxEq5L.js","assets/documentExport-Cf0gMwM0.js","assets/rezip-BWhh7dAS.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as zo}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Fe,R as o,j as r,r as an,a as df}from"./vendor-react--VO_rL_p.js";import{u as De,aO as Uc,c_ as ff,cZ as mf,A as re,d1 as hf,y as Ds,ac as st,ad as rt,B as Se,ae as it,Q as ce,aH as pf,aG as gf,aC as wf,aD as xf,aF as bf,I as ee,df as Ln,ha as Et,jp as vf,jq as So,by as Sn,jr as yf,b_ as $o,b$ as Sf,js as Cf,g2 as jf,g_ as kf,bG as Bl,jt as Ef,aL as Bo,bz as dn,fq as ln,n as un,bD as mr,ju as Hc,bF as Co,j3 as jo,bh as ko,bi as Eo,bj as No,jv as Nf,jw as Ff,jx as Rf,bk as In,jy as Kc,b6 as wr,dW as Gc,jz as Fo,ed as Tf,bt as qc,bu as Xc,bv as Yc,bw as Jc,bx as Qc,b3 as hr,ft as Zc,iv as Mf,jA as Ro,jB as Pf,jC as Df,cP as Af,bR as Vf,aQ as Lf,aP as Of,hY as If,hX as zf,aN as ro,bP as $f,ff as Bf,am as _l,jD as _f,aS as Wf,V as Wl,d8 as io,T as Uf,bB as ar,bg as Ul,Z as Hf,jE as lr,fE as Kf,jF as oo,bC as Hl,bE as cr,jG as Kl,aV as Gf,jH as qf,jI as Xf,jJ as Yf,fj as Jf,jK as Qf,jL as Zf,aU as em,jM as tm,fs as Gl,jN as nm,t as eu,q as tu,D as nu,l as su,F as ru,o as iu,a4 as ou,a5 as au,a6 as lu,a7 as dr,b2 as si,b4 as ql,gS as cu,hc as sm,jO as Xl,gE as Yl,ax as ri,aB as ii,af as uu,b1 as rm,jP as im,gO as du,gN as fu,cO as om,gP as am,jQ as lm,jR as cm,cV as um,cW as dm,jS as fm,jT as mm,gQ as hm}from"./useAppFontEffects-D9nf8G19.js";import{c9 as mu,ca as pm,bt as gm,b0 as Jl,j as pr,bc as hu,ba as wm,cb as xm,c7 as bm,cc as vm,bv as ym,u as nt,bs as kt,aX as Ht,cd as Sm,c8 as fr,v as Ql,ce as Zl,cf as ao,cg as Cm,ch as jm,b2 as To,ci as km,cj as Vn,ck as Em}from"./katex.min-g52ii4Gs.js";import{s as Nm,c as ec,C as Fm}from"./flexokiTheme-deI9tWCZ.js";import{a as pu,E as gu,i as _o,S as di,R as Rm,l as Tm}from"./vendor-codemirror-state-Cd8udR5z.js";import{E as Ge,k as fi,f as Mm,m as Pm,n as Dm,g as Am,V as Wo,D as cn,W as Vm,G as Lm}from"./vendor-codemirror-view-Ciie9ey-.js";import{v as Om,z as Im,A as zm,B as $m,s as wu}from"./vendor-codemirror-language-8HZTPOnt.js";import{aA as Bm,aB as _m,aC as Wm,aD as Um,an as Hm}from"./runtimeEndpointReset-BJm_77m2.js";import{h as xu,u as Km}from"./useMarkdownLocalAssets-wPn7MXUN.js";import{S as Gm,u as qm,c as Xm,b as Ym,F as tc}from"./fileContentPoller-CKcqqhzG.js";import{V as Jm,J as Qm,F as Zm}from"./JsonTreeView-BXv2HzlC.js";import{c as eh}from"./codeHighlight-C7ZRQ5-2.js";import{getCodeTokenTheme as th,getThemeRenderName as nh,ensurePierreThemeRegistered as nc}from"./appThemeRegistry-BwyM6n38.js";import{V as sh,W as rh}from"./useNextRenderData-CVFf78p9.js";import{V as ih}from"./ReviewCards-CU1YHZkQ.js";import{M as Mo,g as oh,a as lo,b as ah}from"./contextFileOpenGuard-CKnYjgFC.js";import{D as lh}from"./vendor-react-drawio-C6TkEvnS.js";import{e as ch,g as uh,s as dh,S as fh,h as mh}from"./vendor-codemirror-search-CWqbGraJ.js";import{a as hh,b as ph}from"./vendor-codemirror-autocomplete-BGedy2gC.js";import{p as gh}from"./parseDiffFromFile-CD1h9Yf5.js";import{jsonLanguage as wh}from"./vendor-codemirror-lang-json-DVAYKmoO.js";import{l as xh}from"./vendor-codemirror-lint-aq8IpR1c.js";import{s as bh}from"./vendor-strip-json-comments-5dJlOkP1.js";import{D as vh,a as oi,b as yh,m as Sh,c as Ch,u as jh}from"./moveWorkspacePath-C4_JgpNC.js";import{d as Uo,p as bu,e as kh,t as Eh,f as sc,g as rc,h as Nh,b as Fh,D as Po,j as Do,c as ur}from"./model-dyJJrKMm.js";import{u as Rh,a as Th}from"./vendor-fflate-DB4_FQr-.js";import{d as Ao,c as vu,n as Mh,p as ic}from"./documentClient-B0iRikhq.js";import{u as oc}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{UiBlock as Ph}from"./UiBlock-pyLxOJr6.js";import{a as Dh,u as Ah,n as Vh}from"./useInlineCommentController-CzeMiLCm.js";import{l as Lh,C as Oh,s as Ih}from"./columnWidthMemory-Cbfh5HD5.js";import{columnName as zh}from"./document-attachments-CIZjaOGe.js";import{o as zn,s as At,c as ci,n as Vo,u as $h,a as Bh,h as _h,l as ac}from"./vendor-zod--raI7LhK.js";import{u as Wh}from"./useWholeFileComment-BexRzYws.js";import{toDiffsLanguage as Uh,DIFFS_HIGHLIGHTER as Hh}from"./diffsHighlighter-BsxkaI3Q.js";import{c as Kh}from"./scheduledTasksApi-CKPLiwD-.js";function yu(n){const e=Fe.c(21),{anchor:s,quote:t,fileLabel:l,onOpen:a,onClose:c}=n,{t:m}=De(),u=Uc(),p=ff(u),d=mf(qh),[b,h]=o.useState(!1),y=o.useRef(null);let E,F;e[0]!==c?(E=()=>{const D=g=>{y.current?.contains(g.target)||c()};return document.addEventListener("pointerdown",D),()=>document.removeEventListener("pointerdown",D)},F=[c],e[0]=c,e[1]=E,e[2]=F):(E=e[1],F=e[2]),o.useEffect(E,F);let M;e[3]!==d||e[4]!==l||e[5]!==c||e[6]!==t||e[7]!==m||e[8]!==p?(M=D=>{if(p){if(!d(p,{source:"file-quote",fileLabel:l,startLine:0,endLine:0,code:t,language:"",text:D.trim()}))return re.error(m("inlineComment.toast.noRoom")),!1;queueMicrotask(Gh)}return c(),!0},e[3]=d,e[4]=l,e[5]=c,e[6]=t,e[7]=m,e[8]=p,e[9]=M):M=e[9];const N=M;let k;e[10]!==l||e[11]!==c||e[12]!==N?(k=r.jsx(Dh,{initialText:"",fileLabel:l,onSave:N,onCancel:c,floating:!0}),e[10]=l,e[11]=c,e[12]=N,e[13]=k):k=e[13];let C;e[14]!==a?(C=()=>{h(!0),a?.()},e[14]=a,e[15]=C):C=e[15];let P;return e[16]!==s||e[17]!==b||e[18]!==k||e[19]!==C?(P=r.jsx(Gm,{anchor:s,menuRef:y,commentMode:b,commentInput:k,onComment:C}),e[16]=s,e[17]=b,e[18]=k,e[19]=C,e[20]=P):P=e[20],P}function Gh(){return hf()}function qh(n){return n.addDraft}const Xh=(n,e)=>{if(!e)return null;const s=Number.parseInt(n.trim(),10);return!Number.isFinite(s)||s<1?null:Math.min(s,e.state.doc.lines)},lc=(n,e)=>{const s=n.state.doc.lineAt(e.main.head);return{lineNumber:s.number,character:e.main.head-s.from+1,selection:e}},cc=(n,e,s)=>{const t=n.state.doc.line(e),l=Math.max(1,Math.min(s,t.length+1)),a=t.from+l-1;n.dispatch({selection:pu.cursor(a),effects:Ge.scrollIntoView(a,{y:"center"})})};function Yh({open:n,onOpenChange:e,viewRef:s,variant:t="overlay"}){const{t:l}=De(),a=s.current,[c,m]=o.useState(""),u=o.useRef(null),p=o.useRef(!1),d=o.useRef(null),b=o.useRef(null),h=o.useMemo(()=>Xh(c,a),[c,a]);o.useEffect(()=>{!n||!a||(p.current=!1,u.current=lc(a,a.state.selection),m(""))},[n,a]),o.useEffect(()=>{n&&window.requestAnimationFrame(()=>{b.current?.focus(),b.current?.select()})},[n]),o.useEffect(()=>{if(!(!n||!a||!u.current)){if(h===null){const{selection:k}=u.current;a.dispatch({selection:k,effects:Ge.scrollIntoView(k.main.from,{y:"center"})});return}cc(a,h,u.current.character)}},[h,n,a]);const y=o.useCallback(()=>{if(!a||p.current||!u.current)return;const{selection:k}=u.current;a.dispatch({selection:k,effects:Ge.scrollIntoView(k.main.from,{y:"center"})})},[a]),E=o.useRef(n);o.useEffect(()=>{E.current&&!n&&y(),E.current=n},[n,y]);const F=o.useCallback(k=>{k||y(),e(k)},[e,y]),M=o.useCallback(()=>{!a||h===null||!u.current||(p.current=!0,cc(a,h,u.current.character),e(!1),a.focus())},[h,e,a]);o.useEffect(()=>{if(!n)return;const k=P=>{const D=d.current,g=P.target;!D||!(g instanceof Element)||D.contains(g)||g.closest("[data-go-to-line-toggle]")||F(!1)},C=P=>{P.key==="Escape"&&(P.preventDefault(),F(!1))};return document.addEventListener("pointerdown",k,!0),document.addEventListener("keydown",C,!0),()=>{document.removeEventListener("pointerdown",k,!0),document.removeEventListener("keydown",C,!0)}},[F,n,t]);const N=o.useMemo(()=>{if(!a)return l("goToLineDialog.helper.editorUnavailable");if(h===null){const k=u.current??lc(a,a.state.selection);return l("goToLineDialog.helper.currentLineRange",{current:k.lineNumber,max:a.state.doc.lines})}return l("goToLineDialog.helper.goToLine",{line:h})},[h,l,a]);return t==="inline"?n?r.jsxs("div",{ref:d,"data-editor-overlay":!0,className:"ms-1 flex h-6 items-center gap-1",children:[r.jsx(Ds,{ref:b,type:"number",min:1,step:1,inputMode:"numeric",value:c,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),M())},placeholder:l("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-edge bg-transparent px-2 typography-meta"}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:r.jsx(Se,{variant:"outline",size:"xs",onClick:M,disabled:!a||h===null,className:"h-6 px-2",children:l("goToLineDialog.actions.go")})})}),r.jsx(it,{side:"bottom",sideOffset:6,children:l("filesView.editor.goToLine")})]})]}):null:r.jsx("div",{ref:d,"data-editor-overlay":!0,className:ce("absolute inset-s-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",n?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:r.jsxs("div",{className:"min-w-0",children:[r.jsx(Ds,{ref:b,type:"number",min:1,step:1,inputMode:"numeric",value:c,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),M())},placeholder:l("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-edge bg-surface-elevated/60 typography-ui-label"}),r.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:N})]})})}function uc(n){const e=Fe.c(22),{path:s,className:t,title:l,trailing:a}=n,c=l===void 0?s:l,m=o.useRef(null),u=o.useRef(null),[p,d]=o.useState(!0);let b;e[0]!==s?(b=s.split(/[\\/]/).filter(Boolean).pop()??s,e[0]=s,e[1]=b):b=e[1];const h=b;let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{const g=m.current,A=u.current;if(!g||!A)return;const B=()=>d(A.offsetWidth<=g.clientWidth);B();const I=new ResizeObserver(B);return I.observe(g),()=>I.disconnect()},e[2]=y):y=e[2];let E;e[3]!==s?(E=[s],e[3]=s,e[4]=E):E=e[4],o.useLayoutEffect(y,E);let F;e[5]!==t?(F=ce("relative min-w-0 flex-1 overflow-hidden",t),e[5]=t,e[6]=F):F=e[6];const M=c??void 0,N=a?"pe-[18px]":void 0;let k;e[7]!==N?(k=ce("invisible absolute whitespace-nowrap",N),e[7]=N,e[8]=k):k=e[8];let C;e[9]!==s||e[10]!==k?(C=r.jsx("span",{ref:u,"aria-hidden":!0,className:k,children:s}),e[9]=s,e[10]=k,e[11]=C):C=e[11];let P;e[12]!==p||e[13]!==h||e[14]!==s||e[15]!==a?(P=a?r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"min-w-0 truncate",children:p?s:h}),a]}):r.jsx("span",{className:"block truncate",children:p?s:h}),e[12]=p,e[13]=h,e[14]=s,e[15]=a,e[16]=P):P=e[16];let D;return e[17]!==P||e[18]!==F||e[19]!==M||e[20]!==C?(D=r.jsxs("span",{ref:m,className:F,title:M,dir:"ltr",children:[C,P]}),e[17]=P,e[18]=F,e[19]=M,e[20]=C,e[21]=D):D=e[21],D}const Jh=new Map(Object.entries({FunctionDeclaration:"function",FunctionDefinition:"function",FunctionItem:"function",FunctionDecl:"function",MethodDeclaration:"method",MethodDecl:"method",ClassDeclaration:"class",ClassDefinition:"class",InterfaceDeclaration:"class",StructItem:"class",TraitItem:"class",ImplItem:"class",TypeAliasDeclaration:"type",EnumDeclaration:"type",EnumItem:"type",TypeSpec:"type",ModItem:"module"})),Qh=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),Zh=new Set(["ArrowFunction","FunctionExpression"]),ep=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),Su=/^(?:ATXHeading|SetextHeading)([1-6])$/,Cu=(n,e)=>{for(let s=n.firstChild;s;s=s.nextSibling)if(e.has(s.name))return s;return null},ju=n=>{if(Su.test(n.name))return"heading";const e=Jh.get(n.name);if(e)return e;const s=Qh.get(n.name);return s&&Cu(n,Zh)?s:null},tp=(n,e)=>n.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),np=(n,e=200)=>{const s=Om(n,n.doc.length,e);if(!s)return[];const t=[],l=[];return s.iterate({enter:a=>{const c=ju(a.node);if(!c)return;let m,u;if(c==="heading")m=tp(n,a.node),u=a.from;else{const d=Cu(a.node,ep);if(!d)return;m=n.sliceDoc(d.from,d.to),u=d.from}if(!m)return;for(;l.length>0&&l[l.length-1]<=a.from;)l.pop();const p=c==="heading"?Number(Su.exec(a.name)?.[1]??1)-1:l.length;t.push({name:m,kind:c,line:n.doc.lineAt(u).number,from:u,depth:p}),c!=="heading"&&l.push(a.to)}}),t},sp={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},rp="data-document-symbols-toggle";function dc({open:n,onOpenChange:e,viewRef:s}){const{t}=De(),l=s.current,a=o.useRef(null),[c,m]=o.useState([]),[u,p]=o.useState("");o.useEffect(()=>{n&&(p(""),m(l?np(l.state):[]))},[n,l]);const d=o.useCallback(()=>{e(!1),l?.focus()},[e,l]);o.useEffect(()=>{if(!n)return;const h=y=>{const E=y.target;!(E instanceof Element)||!a.current||a.current.contains(E)||E.closest(`[${rp}]`)||e(!1)};return document.addEventListener("pointerdown",h,!0),()=>document.removeEventListener("pointerdown",h,!0)},[e,n]);const b=o.useCallback(h=>{l&&l.dispatch({selection:pu.cursor(h.from),effects:Ge.scrollIntoView(h.from,{y:"center"})}),d()},[d,l]);return n?r.jsx("div",{ref:a,"data-editor-overlay":!0,className:"absolute inset-s-3 top-3 z-40 w-[min(28rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-lg",onKeyDown:h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),d())},children:r.jsxs(pf,{loop:!0,filter:(h,y)=>h.split("\0")[0].toLowerCase().includes(y.trim().toLowerCase())?1:0,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[r.jsx(gf,{autoFocus:!0,value:u,onValueChange:p,placeholder:t("filesView.symbols.placeholder"),"aria-label":t("filesView.symbols.placeholder")}),r.jsxs(wf,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[r.jsx(xf,{className:"px-3 py-4 typography-meta text-muted-foreground",children:c.length===0?t("filesView.symbols.noneInFile"):t("filesView.symbols.noMatches")}),c.map(h=>r.jsxs(bf,{value:`${h.name}\0${h.from}`,onSelect:()=>b(h),className:"gap-2",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingInlineStart:`${h.depth*12}px`},children:[r.jsx(ee,{name:sp[h.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 truncate text-foreground",children:h.name})]}),r.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:h.line})]},`${h.from}:${h.name}`))]})]})}):null}const ip=n=>{const e=Fe.c(10),{className:s,iconClassName:t}=n,{t:l}=De(),a=mu();let c;e[0]!==l?(c=l("filesView.tree.actions.showGitignored"),e[0]=l,e[1]=c):c=e[1];let m;e[2]!==a?(m=()=>pm(!a),e[2]=a,e[3]=m):m=e[3];let u;return e[4]!==s||e[5]!==t||e[6]!==a||e[7]!==c||e[8]!==m?(u=r.jsx(Ln,{label:c,icon:"file-forbid",pressed:a,className:s,iconClassName:t,onClick:m}),e[4]=s,e[5]=t,e[6]=a,e[7]=c,e[8]=m,e[9]=u):u=e[9],u},op=(n,e)=>{const s=e.trim().toLowerCase(),t=[];if(!s)return t;const l=n.toLowerCase(),a=[],c=[];if(l.length!==n.length){let p=0;for(const d of n){const b=p+d.length;for(let h=0;h<d.toLowerCase().length;h++)a.push(p),c.push(b);p=b}}let m=0,u=0;for(;;){const p=l.indexOf(s,m);if(p===-1)break;const d=a.length>0?a[p]:p,b=c.length>0?c[p+s.length-1]:p+s.length;d>=u&&(t.push({start:d,end:b}),u=b),m=p+s.length}return t},ap=(n,e)=>{if(!e.trim())return[];const s=n.ownerDocument,t=s.createTreeWalker(n,4),l=[];for(let a=t.nextNode();a;a=t.nextNode())if(!(!a.parentElement||a.parentElement.closest("svg, script, style")))for(const c of op(a.nodeValue??"",e)){const m=s.createRange();m.setStart(a,c.start),m.setEnd(a,c.end),l.push(m)}return l},lp=(n,e)=>{const s=n.ownerDocument.defaultView;if(!(!s||!n.contains(e.startContainer)))for(let t=e.startContainer.parentElement;t;t=t.parentElement){const l=s.getComputedStyle(t),a=/(auto|scroll|hidden)/.test(l.overflowX),c=/(auto|scroll|hidden)/.test(l.overflowY);if(a||c){const m=e.getBoundingClientRect(),u=t.getBoundingClientRect(),p=u.top+t.clientTop,d=u.left+t.clientLeft,b=p+t.clientHeight,h=d+t.clientWidth,y=m.top<p?m.top-p:Math.max(0,m.bottom-b),E=m.left<d?m.left-d:Math.max(0,m.right-h);(a&&E||c&&y)&&t.scrollBy({left:a?E:0,top:c?y:0})}if(t===n)break}},cp=120,co=n=>{const e=Fe.c(10),{label:s,icon:t,onClick:l,disabled:a}=n;let c;e[0]!==t?(c=r.jsx(ee,{name:t,className:"size-3.5"}),e[0]=t,e[1]=c):c=e[1];let m;e[2]!==a||e[3]!==s||e[4]!==l||e[5]!==c?(m=r.jsx(Se,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:l,"aria-label":s,disabled:a,children:c}),e[2]=a,e[3]=s,e[4]=l,e[5]=c,e[6]=m):m=e[6];let u;return e[7]!==s||e[8]!==m?(u=r.jsx(Et,{label:s,side:"bottom",children:m}),e[7]=s,e[8]=m,e[9]=u):u=e[9],u},fc=({containerRef:n,open:e,onOpenChange:s,focusNonce:t,className:l})=>{const{t:a}=De(),[c,m]=o.useState(""),[u,p]=o.useState(0),[d,b]=o.useState(0),h=o.useRef(null),[y,E]=o.useState([]),M=`oc-preview-search-${o.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,N=`${M}-current`,k=o.useRef(c);k.current=c;const C=o.useRef(null),P=o.useRef(null),D=o.useCallback((T,$=!1)=>{const W=n.current;if(!W){E([]),p(0),b(0);return}const U=ap(W,T);E(U);const q=U.length;p(q),b(pe=>!$||q===0?0:Math.min(pe,q-1))},[n]),g=o.useCallback((T,$=!1)=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{C.current=null,D(T,$)},cp)},[D]);o.useEffect(()=>()=>{C.current&&clearTimeout(C.current)},[]);const A=o.useCallback(()=>{s(!1);const T=P.current;P.current=null,T?.isConnected&&T.focus()},[s]);o.useEffect(()=>{const T=n.current;if(!e||!T)return;const $=xu(T);D(k.current,!0);const W=new MutationObserver(()=>{k.current.trim()&&(E([]),g(k.current,!0))});return W.observe(T,{childList:!0,subtree:!0,characterData:!0}),()=>{W.disconnect(),$(),C.current&&clearTimeout(C.current),C.current=null}},[n,e,D,g]),o.useEffect(()=>{if(!e)return;const T=n.current?.ownerDocument.activeElement;T instanceof HTMLElement&&!P.current&&(P.current=T),h.current?.focus()},[n,e]),o.useEffect(()=>{e&&t>0&&(h.current?.focus(),h.current?.select())},[e,t]),o.useEffect(()=>{const T=n.current,$=T?.ownerDocument.defaultView;if(!e||!T||!$||!("Highlight"in $)||!("highlights"in $.CSS))return;const W=$.CSS.highlights,U=T.ownerDocument.createElement("style");if(U.textContent=`::highlight(${M}) { background-color: color-mix(in srgb, var(--status-warning) 30%, transparent); color: var(--surface-foreground); }
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/officeDocument-CQScRmC1.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/document-attachments-CIZjaOGe.js","assets/vendor-fflate-DB4_FQr-.js","assets/useAppFontEffects-3RimJo4B.js","assets/vendor-react--VO_rL_p.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-Bs5OLoA1.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/documentClient-JcxJ7vyh.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/runtimeEndpointReset-DiTyBUwe.js","assets/space-apply-8YUOtYvk.js","assets/runtimeEndpointReset-uDNKGwhp.css","assets/useMarkdownLocalAssets-CH5Ekvbl.js","assets/fileContentPoller-BmcApnk-.js","assets/useInlineCommentController-_L6_JHZ6.js","assets/JsonTreeView-zAv-pn0X.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/useNextRenderData-CVFf78p9.js","assets/getFiletypeFromFileName-BgI9McTw.js","assets/isFilePlainText-DOjSDWo3.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/codeHighlight-BcDjh6yS.js","assets/appThemeRegistry-DYzVI9tX.js","assets/textMateThemeFromAppTheme-CVOJt2hL.js","assets/ReviewCards-BkpTYy_a.js","assets/contextFileOpenGuard-BC79wuu1.js","assets/vendor-react-drawio-C6TkEvnS.js","assets/vendor-codemirror-lint-aq8IpR1c.js","assets/moveWorkspacePath-BaEfuU4S.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/useWholeFileComment-CqHAJ2YU.js","assets/diffsHighlighter-BsxkaI3Q.js","assets/scheduledTasksApi-Z7dc8sXS.js","assets/pdfjs-uwkGOIm9.js","assets/vendor-pdfjs-dist-CiCxEq5L.js","assets/documentExport-C830mU4N.js","assets/rezip-BWhh7dAS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as zo}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Fe,R as o,j as r,r as an,a as df}from"./vendor-react--VO_rL_p.js";import{u as De,aO as Uc,c_ as ff,cZ as mf,A as re,d1 as hf,y as Ds,ac as st,ad as rt,B as Se,ae as it,Q as ce,aH as pf,aG as gf,aC as wf,aD as xf,aF as bf,I as ee,df as Ln,ha as Et,jp as vf,jq as So,by as Sn,jr as yf,b_ as $o,b$ as Sf,js as Cf,g2 as jf,g_ as kf,bG as Bl,jt as Ef,aL as Bo,bz as dn,fq as ln,n as un,bD as mr,ju as Hc,bF as Co,j3 as jo,bh as ko,bi as Eo,bj as No,jv as Nf,jw as Ff,jx as Rf,bk as In,jy as Kc,b6 as wr,dW as Gc,jz as Fo,ed as Tf,bt as qc,bu as Xc,bv as Yc,bw as Jc,bx as Qc,b3 as hr,ft as Zc,iv as Mf,jA as Ro,jB as Pf,jC as Df,cP as Af,bR as Vf,aQ as Lf,aP as Of,hY as If,hX as zf,aN as ro,bP as $f,ff as Bf,am as _l,jD as _f,aS as Wf,V as Wl,d8 as io,T as Uf,bB as ar,bg as Ul,Z as Hf,jE as lr,fE as Kf,jF as oo,bC as Hl,bE as cr,jG as Kl,aV as Gf,jH as qf,jI as Xf,jJ as Yf,fj as Jf,jK as Qf,jL as Zf,aU as em,jM as tm,fs as Gl,jN as nm,t as eu,q as tu,D as nu,l as su,F as ru,o as iu,a4 as ou,a5 as au,a6 as lu,a7 as dr,b2 as si,b4 as ql,gS as cu,hc as sm,jO as Xl,gE as Yl,ax as ri,aB as ii,af as uu,b1 as rm,jP as im,gO as du,gN as fu,cO as om,gP as am,jQ as lm,jR as cm,cV as um,cW as dm,jS as fm,jT as mm,gQ as hm}from"./useAppFontEffects-3RimJo4B.js";import{c9 as mu,ca as pm,bt as gm,b0 as Jl,j as pr,bc as hu,ba as wm,cb as xm,c7 as bm,cc as vm,bv as ym,u as nt,bs as kt,aX as Ht,cd as Sm,c8 as fr,v as Ql,ce as Zl,cf as ao,cg as Cm,ch as jm,b2 as To,ci as km,cj as Vn,ck as Em}from"./katex.min-Bs5OLoA1.js";import{s as Nm,c as ec,C as Fm}from"./flexokiTheme-BMYGLHbL.js";import{a as pu,E as gu,i as _o,S as di,R as Rm,l as Tm}from"./vendor-codemirror-state-Cd8udR5z.js";import{E as Ge,k as fi,f as Mm,m as Pm,n as Dm,g as Am,V as Wo,D as cn,W as Vm,G as Lm}from"./vendor-codemirror-view-Ciie9ey-.js";import{v as Om,z as Im,A as zm,B as $m,s as wu}from"./vendor-codemirror-language-8HZTPOnt.js";import{aA as Bm,aB as _m,aC as Wm,aD as Um,an as Hm}from"./runtimeEndpointReset-DiTyBUwe.js";import{h as xu,u as Km}from"./useMarkdownLocalAssets-CH5Ekvbl.js";import{S as Gm,u as qm,c as Xm,b as Ym,F as tc}from"./fileContentPoller-BmcApnk-.js";import{V as Jm,J as Qm,F as Zm}from"./JsonTreeView-zAv-pn0X.js";import{c as eh}from"./codeHighlight-BcDjh6yS.js";import{getCodeTokenTheme as th,getThemeRenderName as nh,ensurePierreThemeRegistered as nc}from"./appThemeRegistry-DYzVI9tX.js";import{V as sh,W as rh}from"./useNextRenderData-CVFf78p9.js";import{V as ih}from"./ReviewCards-BkpTYy_a.js";import{M as Mo,g as oh,a as lo,b as ah}from"./contextFileOpenGuard-BC79wuu1.js";import{D as lh}from"./vendor-react-drawio-C6TkEvnS.js";import{e as ch,g as uh,s as dh,S as fh,h as mh}from"./vendor-codemirror-search-CWqbGraJ.js";import{a as hh,b as ph}from"./vendor-codemirror-autocomplete-BGedy2gC.js";import{p as gh}from"./parseDiffFromFile-By5H8w4y.js";import{jsonLanguage as wh}from"./vendor-codemirror-lang-json-DVAYKmoO.js";import{l as xh}from"./vendor-codemirror-lint-aq8IpR1c.js";import{s as bh}from"./vendor-strip-json-comments-5dJlOkP1.js";import{D as vh,a as oi,b as yh,m as Sh,c as Ch,u as jh}from"./moveWorkspacePath-BaEfuU4S.js";import{d as Uo,p as bu,e as kh,t as Eh,f as sc,g as rc,h as Nh,b as Fh,D as Po,j as Do,c as ur}from"./model-dyJJrKMm.js";import{u as Rh,a as Th}from"./vendor-fflate-DB4_FQr-.js";import{d as Ao,c as vu,n as Mh,p as ic}from"./documentClient-JcxJ7vyh.js";import{u as oc}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{UiBlock as Ph}from"./UiBlock-C11qZK5T.js";import{a as Dh,u as Ah,n as Vh}from"./useInlineCommentController-_L6_JHZ6.js";import{l as Lh,C as Oh,s as Ih}from"./columnWidthMemory-BA6h4J11.js";import{columnName as zh}from"./document-attachments-CIZjaOGe.js";import{o as zn,s as At,c as ci,n as Vo,u as $h,a as Bh,h as _h,l as ac}from"./vendor-zod--raI7LhK.js";import{u as Wh}from"./useWholeFileComment-CqHAJ2YU.js";import{toDiffsLanguage as Uh,DIFFS_HIGHLIGHTER as Hh}from"./diffsHighlighter-BsxkaI3Q.js";import{c as Kh}from"./scheduledTasksApi-Z7dc8sXS.js";function yu(n){const e=Fe.c(21),{anchor:s,quote:t,fileLabel:l,onOpen:a,onClose:c}=n,{t:m}=De(),u=Uc(),p=ff(u),d=mf(qh),[b,h]=o.useState(!1),y=o.useRef(null);let E,F;e[0]!==c?(E=()=>{const D=g=>{y.current?.contains(g.target)||c()};return document.addEventListener("pointerdown",D),()=>document.removeEventListener("pointerdown",D)},F=[c],e[0]=c,e[1]=E,e[2]=F):(E=e[1],F=e[2]),o.useEffect(E,F);let M;e[3]!==d||e[4]!==l||e[5]!==c||e[6]!==t||e[7]!==m||e[8]!==p?(M=D=>{if(p){if(!d(p,{source:"file-quote",fileLabel:l,startLine:0,endLine:0,code:t,language:"",text:D.trim()}))return re.error(m("inlineComment.toast.noRoom")),!1;queueMicrotask(Gh)}return c(),!0},e[3]=d,e[4]=l,e[5]=c,e[6]=t,e[7]=m,e[8]=p,e[9]=M):M=e[9];const N=M;let k;e[10]!==l||e[11]!==c||e[12]!==N?(k=r.jsx(Dh,{initialText:"",fileLabel:l,onSave:N,onCancel:c,floating:!0}),e[10]=l,e[11]=c,e[12]=N,e[13]=k):k=e[13];let C;e[14]!==a?(C=()=>{h(!0),a?.()},e[14]=a,e[15]=C):C=e[15];let P;return e[16]!==s||e[17]!==b||e[18]!==k||e[19]!==C?(P=r.jsx(Gm,{anchor:s,menuRef:y,commentMode:b,commentInput:k,onComment:C}),e[16]=s,e[17]=b,e[18]=k,e[19]=C,e[20]=P):P=e[20],P}function Gh(){return hf()}function qh(n){return n.addDraft}const Xh=(n,e)=>{if(!e)return null;const s=Number.parseInt(n.trim(),10);return!Number.isFinite(s)||s<1?null:Math.min(s,e.state.doc.lines)},lc=(n,e)=>{const s=n.state.doc.lineAt(e.main.head);return{lineNumber:s.number,character:e.main.head-s.from+1,selection:e}},cc=(n,e,s)=>{const t=n.state.doc.line(e),l=Math.max(1,Math.min(s,t.length+1)),a=t.from+l-1;n.dispatch({selection:pu.cursor(a),effects:Ge.scrollIntoView(a,{y:"center"})})};function Yh({open:n,onOpenChange:e,viewRef:s,variant:t="overlay"}){const{t:l}=De(),a=s.current,[c,m]=o.useState(""),u=o.useRef(null),p=o.useRef(!1),d=o.useRef(null),b=o.useRef(null),h=o.useMemo(()=>Xh(c,a),[c,a]);o.useEffect(()=>{!n||!a||(p.current=!1,u.current=lc(a,a.state.selection),m(""))},[n,a]),o.useEffect(()=>{n&&window.requestAnimationFrame(()=>{b.current?.focus(),b.current?.select()})},[n]),o.useEffect(()=>{if(!(!n||!a||!u.current)){if(h===null){const{selection:k}=u.current;a.dispatch({selection:k,effects:Ge.scrollIntoView(k.main.from,{y:"center"})});return}cc(a,h,u.current.character)}},[h,n,a]);const y=o.useCallback(()=>{if(!a||p.current||!u.current)return;const{selection:k}=u.current;a.dispatch({selection:k,effects:Ge.scrollIntoView(k.main.from,{y:"center"})})},[a]),E=o.useRef(n);o.useEffect(()=>{E.current&&!n&&y(),E.current=n},[n,y]);const F=o.useCallback(k=>{k||y(),e(k)},[e,y]),M=o.useCallback(()=>{!a||h===null||!u.current||(p.current=!0,cc(a,h,u.current.character),e(!1),a.focus())},[h,e,a]);o.useEffect(()=>{if(!n)return;const k=P=>{const D=d.current,g=P.target;!D||!(g instanceof Element)||D.contains(g)||g.closest("[data-go-to-line-toggle]")||F(!1)},C=P=>{P.key==="Escape"&&(P.preventDefault(),F(!1))};return document.addEventListener("pointerdown",k,!0),document.addEventListener("keydown",C,!0),()=>{document.removeEventListener("pointerdown",k,!0),document.removeEventListener("keydown",C,!0)}},[F,n,t]);const N=o.useMemo(()=>{if(!a)return l("goToLineDialog.helper.editorUnavailable");if(h===null){const k=u.current??lc(a,a.state.selection);return l("goToLineDialog.helper.currentLineRange",{current:k.lineNumber,max:a.state.doc.lines})}return l("goToLineDialog.helper.goToLine",{line:h})},[h,l,a]);return t==="inline"?n?r.jsxs("div",{ref:d,"data-editor-overlay":!0,className:"ms-1 flex h-6 items-center gap-1",children:[r.jsx(Ds,{ref:b,type:"number",min:1,step:1,inputMode:"numeric",value:c,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),M())},placeholder:l("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-edge bg-transparent px-2 typography-meta"}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:r.jsx(Se,{variant:"outline",size:"xs",onClick:M,disabled:!a||h===null,className:"h-6 px-2",children:l("goToLineDialog.actions.go")})})}),r.jsx(it,{side:"bottom",sideOffset:6,children:l("filesView.editor.goToLine")})]})]}):null:r.jsx("div",{ref:d,"data-editor-overlay":!0,className:ce("absolute inset-s-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",n?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:r.jsxs("div",{className:"min-w-0",children:[r.jsx(Ds,{ref:b,type:"number",min:1,step:1,inputMode:"numeric",value:c,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),M())},placeholder:l("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-edge bg-surface-elevated/60 typography-ui-label"}),r.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:N})]})})}function uc(n){const e=Fe.c(22),{path:s,className:t,title:l,trailing:a}=n,c=l===void 0?s:l,m=o.useRef(null),u=o.useRef(null),[p,d]=o.useState(!0);let b;e[0]!==s?(b=s.split(/[\\/]/).filter(Boolean).pop()??s,e[0]=s,e[1]=b):b=e[1];const h=b;let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{const g=m.current,A=u.current;if(!g||!A)return;const B=()=>d(A.offsetWidth<=g.clientWidth);B();const I=new ResizeObserver(B);return I.observe(g),()=>I.disconnect()},e[2]=y):y=e[2];let E;e[3]!==s?(E=[s],e[3]=s,e[4]=E):E=e[4],o.useLayoutEffect(y,E);let F;e[5]!==t?(F=ce("relative min-w-0 flex-1 overflow-hidden",t),e[5]=t,e[6]=F):F=e[6];const M=c??void 0,N=a?"pe-[18px]":void 0;let k;e[7]!==N?(k=ce("invisible absolute whitespace-nowrap",N),e[7]=N,e[8]=k):k=e[8];let C;e[9]!==s||e[10]!==k?(C=r.jsx("span",{ref:u,"aria-hidden":!0,className:k,children:s}),e[9]=s,e[10]=k,e[11]=C):C=e[11];let P;e[12]!==p||e[13]!==h||e[14]!==s||e[15]!==a?(P=a?r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"min-w-0 truncate",children:p?s:h}),a]}):r.jsx("span",{className:"block truncate",children:p?s:h}),e[12]=p,e[13]=h,e[14]=s,e[15]=a,e[16]=P):P=e[16];let D;return e[17]!==P||e[18]!==F||e[19]!==M||e[20]!==C?(D=r.jsxs("span",{ref:m,className:F,title:M,dir:"ltr",children:[C,P]}),e[17]=P,e[18]=F,e[19]=M,e[20]=C,e[21]=D):D=e[21],D}const Jh=new Map(Object.entries({FunctionDeclaration:"function",FunctionDefinition:"function",FunctionItem:"function",FunctionDecl:"function",MethodDeclaration:"method",MethodDecl:"method",ClassDeclaration:"class",ClassDefinition:"class",InterfaceDeclaration:"class",StructItem:"class",TraitItem:"class",ImplItem:"class",TypeAliasDeclaration:"type",EnumDeclaration:"type",EnumItem:"type",TypeSpec:"type",ModItem:"module"})),Qh=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),Zh=new Set(["ArrowFunction","FunctionExpression"]),ep=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),Su=/^(?:ATXHeading|SetextHeading)([1-6])$/,Cu=(n,e)=>{for(let s=n.firstChild;s;s=s.nextSibling)if(e.has(s.name))return s;return null},ju=n=>{if(Su.test(n.name))return"heading";const e=Jh.get(n.name);if(e)return e;const s=Qh.get(n.name);return s&&Cu(n,Zh)?s:null},tp=(n,e)=>n.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),np=(n,e=200)=>{const s=Om(n,n.doc.length,e);if(!s)return[];const t=[],l=[];return s.iterate({enter:a=>{const c=ju(a.node);if(!c)return;let m,u;if(c==="heading")m=tp(n,a.node),u=a.from;else{const d=Cu(a.node,ep);if(!d)return;m=n.sliceDoc(d.from,d.to),u=d.from}if(!m)return;for(;l.length>0&&l[l.length-1]<=a.from;)l.pop();const p=c==="heading"?Number(Su.exec(a.name)?.[1]??1)-1:l.length;t.push({name:m,kind:c,line:n.doc.lineAt(u).number,from:u,depth:p}),c!=="heading"&&l.push(a.to)}}),t},sp={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},rp="data-document-symbols-toggle";function dc({open:n,onOpenChange:e,viewRef:s}){const{t}=De(),l=s.current,a=o.useRef(null),[c,m]=o.useState([]),[u,p]=o.useState("");o.useEffect(()=>{n&&(p(""),m(l?np(l.state):[]))},[n,l]);const d=o.useCallback(()=>{e(!1),l?.focus()},[e,l]);o.useEffect(()=>{if(!n)return;const h=y=>{const E=y.target;!(E instanceof Element)||!a.current||a.current.contains(E)||E.closest(`[${rp}]`)||e(!1)};return document.addEventListener("pointerdown",h,!0),()=>document.removeEventListener("pointerdown",h,!0)},[e,n]);const b=o.useCallback(h=>{l&&l.dispatch({selection:pu.cursor(h.from),effects:Ge.scrollIntoView(h.from,{y:"center"})}),d()},[d,l]);return n?r.jsx("div",{ref:a,"data-editor-overlay":!0,className:"absolute inset-s-3 top-3 z-40 w-[min(28rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-lg",onKeyDown:h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),d())},children:r.jsxs(pf,{loop:!0,filter:(h,y)=>h.split("\0")[0].toLowerCase().includes(y.trim().toLowerCase())?1:0,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[r.jsx(gf,{autoFocus:!0,value:u,onValueChange:p,placeholder:t("filesView.symbols.placeholder"),"aria-label":t("filesView.symbols.placeholder")}),r.jsxs(wf,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[r.jsx(xf,{className:"px-3 py-4 typography-meta text-muted-foreground",children:c.length===0?t("filesView.symbols.noneInFile"):t("filesView.symbols.noMatches")}),c.map(h=>r.jsxs(bf,{value:`${h.name}\0${h.from}`,onSelect:()=>b(h),className:"gap-2",children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingInlineStart:`${h.depth*12}px`},children:[r.jsx(ee,{name:sp[h.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 truncate text-foreground",children:h.name})]}),r.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:h.line})]},`${h.from}:${h.name}`))]})]})}):null}const ip=n=>{const e=Fe.c(10),{className:s,iconClassName:t}=n,{t:l}=De(),a=mu();let c;e[0]!==l?(c=l("filesView.tree.actions.showGitignored"),e[0]=l,e[1]=c):c=e[1];let m;e[2]!==a?(m=()=>pm(!a),e[2]=a,e[3]=m):m=e[3];let u;return e[4]!==s||e[5]!==t||e[6]!==a||e[7]!==c||e[8]!==m?(u=r.jsx(Ln,{label:c,icon:"file-forbid",pressed:a,className:s,iconClassName:t,onClick:m}),e[4]=s,e[5]=t,e[6]=a,e[7]=c,e[8]=m,e[9]=u):u=e[9],u},op=(n,e)=>{const s=e.trim().toLowerCase(),t=[];if(!s)return t;const l=n.toLowerCase(),a=[],c=[];if(l.length!==n.length){let p=0;for(const d of n){const b=p+d.length;for(let h=0;h<d.toLowerCase().length;h++)a.push(p),c.push(b);p=b}}let m=0,u=0;for(;;){const p=l.indexOf(s,m);if(p===-1)break;const d=a.length>0?a[p]:p,b=c.length>0?c[p+s.length-1]:p+s.length;d>=u&&(t.push({start:d,end:b}),u=b),m=p+s.length}return t},ap=(n,e)=>{if(!e.trim())return[];const s=n.ownerDocument,t=s.createTreeWalker(n,4),l=[];for(let a=t.nextNode();a;a=t.nextNode())if(!(!a.parentElement||a.parentElement.closest("svg, script, style")))for(const c of op(a.nodeValue??"",e)){const m=s.createRange();m.setStart(a,c.start),m.setEnd(a,c.end),l.push(m)}return l},lp=(n,e)=>{const s=n.ownerDocument.defaultView;if(!(!s||!n.contains(e.startContainer)))for(let t=e.startContainer.parentElement;t;t=t.parentElement){const l=s.getComputedStyle(t),a=/(auto|scroll|hidden)/.test(l.overflowX),c=/(auto|scroll|hidden)/.test(l.overflowY);if(a||c){const m=e.getBoundingClientRect(),u=t.getBoundingClientRect(),p=u.top+t.clientTop,d=u.left+t.clientLeft,b=p+t.clientHeight,h=d+t.clientWidth,y=m.top<p?m.top-p:Math.max(0,m.bottom-b),E=m.left<d?m.left-d:Math.max(0,m.right-h);(a&&E||c&&y)&&t.scrollBy({left:a?E:0,top:c?y:0})}if(t===n)break}},cp=120,co=n=>{const e=Fe.c(10),{label:s,icon:t,onClick:l,disabled:a}=n;let c;e[0]!==t?(c=r.jsx(ee,{name:t,className:"size-3.5"}),e[0]=t,e[1]=c):c=e[1];let m;e[2]!==a||e[3]!==s||e[4]!==l||e[5]!==c?(m=r.jsx(Se,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:l,"aria-label":s,disabled:a,children:c}),e[2]=a,e[3]=s,e[4]=l,e[5]=c,e[6]=m):m=e[6];let u;return e[7]!==s||e[8]!==m?(u=r.jsx(Et,{label:s,side:"bottom",children:m}),e[7]=s,e[8]=m,e[9]=u):u=e[9],u},fc=({containerRef:n,open:e,onOpenChange:s,focusNonce:t,className:l})=>{const{t:a}=De(),[c,m]=o.useState(""),[u,p]=o.useState(0),[d,b]=o.useState(0),h=o.useRef(null),[y,E]=o.useState([]),M=`oc-preview-search-${o.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,N=`${M}-current`,k=o.useRef(c);k.current=c;const C=o.useRef(null),P=o.useRef(null),D=o.useCallback((T,$=!1)=>{const W=n.current;if(!W){E([]),p(0),b(0);return}const U=ap(W,T);E(U);const q=U.length;p(q),b(pe=>!$||q===0?0:Math.min(pe,q-1))},[n]),g=o.useCallback((T,$=!1)=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{C.current=null,D(T,$)},cp)},[D]);o.useEffect(()=>()=>{C.current&&clearTimeout(C.current)},[]);const A=o.useCallback(()=>{s(!1);const T=P.current;P.current=null,T?.isConnected&&T.focus()},[s]);o.useEffect(()=>{const T=n.current;if(!e||!T)return;const $=xu(T);D(k.current,!0);const W=new MutationObserver(()=>{k.current.trim()&&(E([]),g(k.current,!0))});return W.observe(T,{childList:!0,subtree:!0,characterData:!0}),()=>{W.disconnect(),$(),C.current&&clearTimeout(C.current),C.current=null}},[n,e,D,g]),o.useEffect(()=>{if(!e)return;const T=n.current?.ownerDocument.activeElement;T instanceof HTMLElement&&!P.current&&(P.current=T),h.current?.focus()},[n,e]),o.useEffect(()=>{e&&t>0&&(h.current?.focus(),h.current?.select())},[e,t]),o.useEffect(()=>{const T=n.current,$=T?.ownerDocument.defaultView;if(!e||!T||!$||!("Highlight"in $)||!("highlights"in $.CSS))return;const W=$.CSS.highlights,U=T.ownerDocument.createElement("style");if(U.textContent=`::highlight(${M}) { background-color: color-mix(in srgb, var(--status-warning) 30%, transparent); color: var(--surface-foreground); }
|
|
3
3
|
::highlight(${N}) { background-color: color-mix(in srgb, var(--status-warning) 60%, transparent); color: var(--surface-foreground); }`,T.ownerDocument.head.append(U),y.length>0){const q=new $.Highlight;for(const be of y)q.add(be);W.set(M,q);const pe=new $.Highlight(y[Math.min(d,y.length-1)]);pe.priority=1,W.set(N,pe)}return()=>{W.delete(M),W.delete(N),U.remove()}},[n,N,M,d,e,y]),o.useEffect(()=>{const T=n.current,$=y[d];e&&T&&$&&lp(T,$)},[n,d,e,y]);const B=o.useCallback(()=>{b(T=>u===0?0:(T+1)%u)},[u]),I=o.useCallback(()=>{b(T=>u===0?0:(T-1+u)%u)},[u]),L=o.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),T.shiftKey?I():B()):T.key==="Escape"&&(T.preventDefault(),A())},[A,B,I]);return e?r.jsxs("div",{className:ce("absolute inset-e-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-edge bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",l),children:[r.jsx(ee,{name:"search",className:"ms-0.5 size-3.5 text-muted-foreground"}),r.jsx(Ds,{ref:h,value:c,onChange:T=>{m(T.target.value),g(T.target.value)},onKeyDown:L,placeholder:a("filesView.preview.find.placeholder"),"aria-label":a("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),r.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":u>0?a("filesView.preview.find.countAria",{current:d+1,total:u}):a("filesView.preview.find.noMatches"),children:c.trim()&&u===0?a("filesView.preview.find.noMatches"):u>0?`${d+1}/${u}`:""}),r.jsx(co,{label:a("filesView.preview.find.previousAria"),icon:"arrow-up",onClick:I,disabled:u===0}),r.jsx(co,{label:a("filesView.preview.find.nextAria"),icon:"arrow-down",onClick:B,disabled:u===0}),r.jsx(co,{label:a("filesView.preview.find.closeAria"),icon:"close",onClick:A})]}):null},up=(n,e)=>({path:n,size:e.size,mtimeMs:e.mtimeMs}),dp=1,mc=({stat:n,showsFailure:e,sawMissing:s,hasUnsavedChanges:t,moving:l})=>n==="missing"?t||l?"none":"show-missing":n==="failed"?"none":e?s?"reload":"none":"check-changes",fp=(n,e)=>e.size!==n.size||e.mtimeMs!==void 0&&n.mtimeMs!==void 0&&Math.abs(e.mtimeMs-n.mtimeMs)>=dp,mp=({selectedPath:n,targetPath:e,targetShown:s,targetSettled:t,showsText:l,canEdit:a,textViewMode:c})=>n!==e?s?"wait":"select-target":t?l?c==="edit"?"jump":a?"show-editor":"end":"end":"wait";function hc(){const n=Fe.c(8),[e]=an.useState(hp),s=an.useRef(!1);let t;n[0]!==e?(t=u=>{if(u==null){e.cleanUp(),s.current=!1;return}s.current||(s.current=!0,e.setup(u,u.firstElementChild??void 0))},n[0]=e,n[1]=t):t=n[1];const l=t;let a,c;n[2]!==e?(a=()=>()=>{s.current=!1,e.cleanUp()},c=[e],n[2]=e,n[3]=a,n[4]=c):(a=n[3],c=n[4]),an.useLayoutEffect(a,c);let m;return n[5]!==l||n[6]!==e?(m={virtualizer:e,setScroller:l},n[5]=l,n[6]=e,n[7]=m):m=n[7],m}function hp(){return new ih}const ku=n=>n.querySelector("[data-oc-streamdown]")?.children??null,pp=(n,e)=>{const s=ku(n);if(!s?.length)return;let t=0,l=s.length-1;for(;t<l;){const a=t+l>>1;s[a].getBoundingClientRect().bottom>e?l=a:t=a+1}return{index:t,offset:s[t].getBoundingClientRect().top-e}},Rs=new Map,gp=100;function ai(n){const[e,s]=an.useState(null),t=an.useRef(null),l=an.useRef(null),a=an.useRef(null),c=an.useCallback((m,u)=>{m&&u instanceof Jm&&(a.current={key:n,file:u,node:m});const p=t.current,d=l.current,b=()=>{t.current===p&&(p?.(),d?.())};u?queueMicrotask(b):b()},[n]);return an.useLayoutEffect(()=>{if(!e||!n)return;const m=Rs.get(n)??{top:0,left:0};let u=!0;const p=()=>a.current?.key===n?a.current.file:null,d=g=>a.current?.key===n?a.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${g-1}"]`):null;let b=null,h=0,y=null,E=null;const F=g=>{g!==y&&(E?.(),y=g,E=g?xu(g,{block:g}):null)},M=()=>{k.disconnect(),C.disconnect(),b!==null&&cancelAnimationFrame(b),b=null,F(null)},N=(g=!1)=>{if(!u)return;const A=p(),B=m.line&&A?.getLinePosition(m.line.number),I=m.line&&d(m.line.number);let L=m.top;m.line&&B&&(L=(A?.top??0)+B.top-m.line.offset),m.line&&I&&(L=e.scrollTop+I.getBoundingClientRect().top-e.getBoundingClientRect().top-m.line.offset);const T=m.block?ku(e)?.[m.block.index]??null:null;F(T),m.block&&T&&(L=e.scrollTop+T.getBoundingClientRect().top-e.getBoundingClientRect().top-m.block.offset);const $=Math.abs(e.scrollTop-L)>=1;if(e.scrollTop=L,e.scrollLeft=m.left,(!m.line||I)&&(!m.block||T)&&Math.abs(e.scrollTop-L)<1&&Math.abs(e.scrollLeft-m.left)<1){if(g&&(h=$?0:h+1),T&&h<2){b??=requestAnimationFrame(()=>{b=null,N(!0)});return}u=!1,M()}},k=new ResizeObserver(()=>N()),C=new MutationObserver(()=>{if(u){for(const g of e.children)k.observe(g);N()}});k.observe(e);for(const g of e.children)k.observe(g);C.observe(e,{childList:!0,subtree:!0});const P=()=>{if(u)return;const g=p(),A=g?.getNumericScrollAnchor(e.scrollTop-(g.top??0)),B=A&&d(A.lineNumber),I=e.getBoundingClientRect().top,L=B?B.getBoundingClientRect().top-I:null;if(Rs.delete(n),Rs.set(n,{top:e.scrollTop,left:e.scrollLeft,line:A&&L!==null&&L>=0&&L<e.clientHeight?{number:A.lineNumber,offset:L}:void 0,block:g?void 0:pp(e,I)}),Rs.size>gp){const T=Rs.keys().next().value;T!==void 0&&Rs.delete(T)}},D=()=>{u=!1,M()};return t.current=N,l.current=P,N(),e.addEventListener("scroll",P,{passive:!0}),e.addEventListener("wheel",D,{passive:!0}),e.addEventListener("touchstart",D,{passive:!0}),e.addEventListener("pointerdown",D,{passive:!0}),e.addEventListener("keydown",D),()=>{t.current=null,l.current=null,a.current?.key===n&&(a.current=null),M(),e.removeEventListener("scroll",P),e.removeEventListener("wheel",D),e.removeEventListener("touchstart",D),e.removeEventListener("pointerdown",D),e.removeEventListener("keydown",D)}},[n,e]),{setScroller:s,restore:c}}function wp(n){return!(!n.autoSaveEnabled||!n.isDirty||!n.canWrite||n.isSaving||n.fileLoading||n.isNonEditableBinary||n.wouldEmptyFile||!n.selectedFilePath||n.loadedFilePath!==n.selectedFilePath)}function xp(n){return n.selectedFilePath?n.isDirty?!(n.fileLoading||n.loadedFilePath!==n.selectedFilePath||n.isNonEditableBinary||n.draftContent===""&&n.fileContent!==""&&n.loadedFilePath!==n.selectedFilePath):!0:!1}const Eu=2e5,bp=n=>{let e=0,s=0;for(let t=0;t<n.length;t++)n.charCodeAt(t)===10&&(t>0&&n.charCodeAt(t-1)===13?e++:s++);return e>s?`\r
|
|
4
4
|
`:`
|
|
5
5
|
`},Nu=n=>n.replace(/\r\n/g,`
|
|
@@ -74,10 +74,10 @@ apply();
|
|
|
74
74
|
`,uw=()=>{const n=globalThis.location?.origin;return n&&n!=="null"?n:"*"},dw=(n,e="")=>{const s=crypto.randomUUID();return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${`default-src 'none'; img-src data:; font-src data:; style-src 'unsafe-inline'; script-src 'nonce-${s}'`}"><style>${e.replace(/<\/style/gi,"<\\/style")}</style><style>${lw}</style></head><body><div id="oc-fit">${aw(n)}</div><script nonce="${s}">const PARENT_ORIGIN = ${JSON.stringify(uw())};${cw}<\/script></body></html>`},Io=$h([At(),ci(At())]).transform(n=>Array.isArray(n)?n.join(""):n),fw=zn({output_type:At(),text:Io.optional(),data:Bh(At(),Io.catch("")).optional(),ename:At().optional(),evalue:At().optional(),traceback:ci(At()).optional()}),mw=zn({cells:ci(zn({cell_type:At(),source:Io,outputs:ci(fw).optional(),execution_count:Vo().nullable().optional()})),metadata:zn({language_info:zn({name:At().optional()}).optional()}).optional()}),po=n=>n.replace(new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g"),""),hw=n=>{const e=Fe.c(25),{value:s}=n;if(s.output_type==="error"){let d;e[0]!==s.ename||e[1]!==s.evalue||e[2]!==s.traceback?(d=po((s.traceback??[`${s.ename}: ${s.evalue}`]).join(`
|
|
75
75
|
`)),e[0]=s.ename,e[1]=s.evalue,e[2]=s.traceback,e[3]=d):d=e[3];let b;return e[4]!==d?(b=r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap font-mono typography-meta text-[color:var(--status-error)]",children:d}),e[4]=d,e[5]=b):b=e[5],b}if(s.text!==void 0){let d;e[6]!==s.text?(d=po(s.text),e[6]=s.text,e[7]=d):d=e[7];let b;return e[8]!==d?(b=r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap font-mono typography-meta text-foreground",children:d}),e[8]=d,e[9]=b):b=e[9],b}let t;e[10]!==s.data?(t=s.data??{},e[10]=s.data,e[11]=t):t=e[11];const l=t,a=l["image/png"]||l["image/jpeg"];if(a){let d;if(e[12]!==a){let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=/\s/g,e[14]=y):y=e[14],d=a.replace(y,""),e[12]=a,e[13]=d}else d=e[13];const b=`data:${l["image/png"]?"image/png":"image/jpeg"};base64,${d}`;let h;return e[15]!==b?(h=r.jsx("img",{alt:"",className:"max-w-full bg-white",src:b}),e[15]=b,e[16]=h):h=e[16],h}const c=l["text/html"];if(c){let d;e[17]!==c?(d=dw(c),e[17]=c,e[18]=d):d=e[18];let b;return e[19]!==d?(b=r.jsx("iframe",{title:"output",sandbox:"allow-scripts",srcDoc:d,className:"h-64 w-full rounded bg-white"}),e[19]=d,e[20]=b):b=e[20],b}const m=l["text/plain"]??"";let u;e[21]!==m?(u=po(m),e[21]=m,e[22]=u):u=e[22];let p;return e[23]!==u?(p=r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap font-mono typography-meta text-foreground",children:u}),e[23]=u,e[24]=p):p=e[24],p},pw=n=>{const e=Fe.c(24),{content:s,sizeBytes:t}=n,{t:l}=De();let a;try{let E;e[0]!==s?(E=mw.parse(JSON.parse(s)),e[0]=s,e[1]=E):E=e[1],a=E}catch{a=null}const c=a;if(!c){let E;e[2]!==l?(E=l("filesView.artifact.notebook.unreadable"),e[2]=l,e[3]=E):E=e[3];let F;return e[4]!==E?(F=r.jsx(dn,{title:E}),e[4]=E,e[5]=F):F=e[5],F}const m=c.metadata?.language_info?.name??"python";let u;e[6]!==c.cells.length||e[7]!==l?(u=l("filesView.artifact.notebook.cells",{count:c.cells.length}),e[6]=c.cells.length,e[7]=l,e[8]=u):u=e[8];let p;e[9]!==t?(p=fn(t),e[9]=t,e[10]=p):p=e[10];let d;e[11]!==u||e[12]!==p?(d=r.jsx(Cn,{items:[u,p]}),e[11]=u,e[12]=p,e[13]=d):d=e[13];let b;if(e[14]!==m||e[15]!==c.cells){let E;e[17]!==m?(E=(F,M)=>r.jsxs("section",{className:"flex min-w-0 flex-col gap-2",children:[F.cell_type==="markdown"?r.jsx(hr,{content:F.source,className:"typography-markdown-body",enableFileReferences:!1}):r.jsx(hr,{content:`\`\`\`${F.cell_type==="code"?m:"text"}
|
|
76
76
|
${F.source}
|
|
77
|
-
\`\`\``,enableFileReferences:!1}),(F.outputs??[]).map(gw)]},M),e[17]=m,e[18]=E):E=e[18],b=c.cells.map(E),e[14]=m,e[15]=c.cells,e[16]=b}else b=e[16];let h;e[19]!==b?(h=r.jsx(un,{outerClassName:"min-h-0 flex-1",children:r.jsx("div",{className:"flex min-w-0 flex-col gap-3 p-3",children:b})}),e[19]=b,e[20]=h):h=e[20];let y;return e[21]!==d||e[22]!==h?(y=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d,h]}),e[21]=d,e[22]=h,e[23]=y):y=e[23],y};function gw(n,e){return r.jsx(hw,{value:n},e)}const ww=100,xw=_h("type",[zn({type:ac(Go),url:At()}),zn({type:ac(Oo),text:At(),place:At(),x:Vo(),y:Vo()})]),bw=async(n,e,s)=>(await zo(async()=>{const{readOfficePreview:t}=await import("./officeDocument-
|
|
77
|
+
\`\`\``,enableFileReferences:!1}),(F.outputs??[]).map(gw)]},M),e[17]=m,e[18]=E):E=e[18],b=c.cells.map(E),e[14]=m,e[15]=c.cells,e[16]=b}else b=e[16];let h;e[19]!==b?(h=r.jsx(un,{outerClassName:"min-h-0 flex-1",children:r.jsx("div",{className:"flex min-w-0 flex-col gap-3 p-3",children:b})}),e[19]=b,e[20]=h):h=e[20];let y;return e[21]!==d||e[22]!==h?(y=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[d,h]}),e[21]=d,e[22]=h,e[23]=y):y=e[23],y};function gw(n,e){return r.jsx(hw,{value:n},e)}const ww=100,xw=_h("type",[zn({type:ac(Go),url:At()}),zn({type:ac(Oo),text:At(),place:At(),x:Vo(),y:Vo()})]),bw=async(n,e,s)=>(await zo(async()=>{const{readOfficePreview:t}=await import("./officeDocument-CQScRmC1.js");return{readOfficePreview:t}},__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,213,214,215,216,217,218,219,220,221,222,223,224]))).readOfficePreview(n,e,s),vw=(n,e)=>{if(n.byteLength!==e.byteLength)return!1;for(let s=0;s<n.length;s+=1)if(n[s]!==e[s])return!1;return!0},yw=n=>n?.match(/^HYPERLINK\(\s*"([^"]+)"/i)?.[1],Sw=({path:n,book:e,bytes:s,sizeBytes:t,readBytes:l,onSave:a,onChangedOnDisk:c,queue:m})=>{const{t:u}=De(),{sheets:p}=e.opened,[d,b]=o.useState(0),[h,y]=o.useState(null),[E,F]=o.useState(0),[M,N]=o.useState(!1),[k,C]=o.useState(e.opened.unsupported),[P,D]=o.useState("idle"),g=o.useRef(s),A=o.useRef(s),B=o.useRef([]),I=o.useRef([]),[L,T]=o.useState(()=>new Set(e.opened.unseen)),$=p[d]??p[0],W=!!a&&!$.protected,U=o.useRef(null),q=z=>{U.current=z,y(z)};o.useEffect(()=>{let z=!0;return e.layout(d,W).then(X=>{z&&q(X)},()=>{z&&N(!0)}),()=>{z=!1}},[e,d,W,E]);const pe=()=>F(z=>z+1),be=z=>h?h.rowNumbers[z]??(h.rowNumbers.at(-1)??0)+z-h.rowNumbers.length+1:0,ve=(z,X)=>h?h.notes.get(ur(h.rowNumbers[z],X)):void 0,ue=async z=>{if(!a)return!1;D("saving");try{const X=await l();if(!vw(X,g.current))return re.error(u("filesView.artifact.office.changedOnDisk")),c(),!1;if(!await a(z))throw new Error("write failed");return g.current=z,D("saved"),!0}catch{return D("failed"),!1}},Ce=z=>{m.current=m.current.then(z).catch(()=>{D("failed"),pe()})},Me=async({bytes:z,patches:X,unsupported:ne})=>{C(ne),A.current=z;const Y=U.current&&X?ic(U.current,X):null;Y?q(Y):pe(),await ue(z)},R=async(z,X)=>{if(z.status==="invalid-formula"&&re.error(u("filesView.artifact.office.invalidFormula")),z.status!=="changed"){pe();return}X(z.previous),await Me(z)},K=(z,X)=>{Ce(async()=>{const ne=z.current.pop();if(ne){if(b(ne.sheet),"bytes"in ne){const{previousBytes:Y,...se}=await e.restoreBytes(ne.bytes);X.current.push({sheet:ne.sheet,bytes:Y}),await Me(se);return}await R(await e.restore(ne.sheet,ne.cells),Y=>X.current.push({sheet:ne.sheet,cells:Y}))}})},G=z=>{Ce(async()=>{const{previousBytes:X,...ne}=await e.restructure(z);I.current=[],B.current.push({sheet:z.sheet,bytes:X}),await Me(ne)})},te=(z,X)=>$.protected||!!h?.lockedCells.has(ur(be(z),X)),Le=W&&h?{canEdit:(z,X)=>z>=0&&!te(z,X),inputOf:(z,X)=>ve(z,X)?.input??h.rows[z]?.[X]??"",commit:z=>{const X=d,ne=z.map(({row:se,column:xe,input:_e})=>({row:be(se),column:xe,input:_e})),Y=ic(h,ne.map(({row:se,column:xe,input:_e})=>({sheet:X,row:se,column:xe,display:_e,note:h.notes.get(ur(se,xe))??null})),!0);Y&&q(Y),Ce(async()=>{await R(await e.edit(X,ne),se=>{I.current=[],B.current.push({sheet:X,cells:se}),B.current.length>ww&&B.current.shift()})})},undo:()=>K(B,I),redo:()=>K(I,B),structure:h.canRestructure?{insertRow:z=>G({sheet:d,axis:"row",at:be(z),delta:1}),deleteRow:z=>G({sheet:d,axis:"row",at:be(z),delta:-1}),insertColumn:z=>G({sheet:d,axis:"column",at:z,delta:1}),deleteColumn:z=>G({sheet:d,axis:"column",at:z,delta:-1})}:void 0}:void 0,J=o.useMemo(()=>{const z=new Set;if(!h||L.size===0)return z;for(let X=0;X<h.rowNumbers.length;X+=1)for(let ne=0;ne<h.columnCount;ne+=1)L.has(`${d}:${ur(h.rowNumbers[X],ne)}`)&&z.add(`${X}:${ne}`);return z},[h,L,d]),qe=P==="idle"?"":u(`filesView.artifact.office.${P}`),Xe=k===0?"":u(k===1?"filesView.artifact.office.externalResultsSingle":"filesView.artifact.office.externalResultsPlural",{count:k});return M?r.jsx(dn,{title:u("filesView.artifact.office.unreadable"),actions:r.jsx(Et,{label:u("contextTooltips.files.retryFile"),children:r.jsx(Se,{type:"button",variant:"outline",size:"sm",onClick:c,children:u("filesView.artifact.state.retry")})})}):!h||h.sheet!==d?r.jsx(Sn,{label:u("filesView.artifact.state.loading")}):r.jsx(pi,{tableId:`${n}#${$.name}`,header:h.header,rows:h.rows,rowLabels:h.rowNumbers,columnCount:h.columnCount,dataColumnCount:h.dataColumnCount,totalRows:h.totalRows,sizeBytes:t,pinnedRows:h.headingRow?1:0,hrefOf:(z,X)=>{const ne=ve(z,X);return ne?.href??yw(ne?.formula)},editing:Le,changedCells:J,onSeen:z=>{e.seen(z.map(X=>{const[ne,Y]=X.split(":").map(Number);return`${d}:${ur(h.rowNumbers[ne],Y)}`})).then(X=>T(new Set(X)))},commentTarget:{fileLabel:n,place:p.length>1?`Sheet "${$.name}"`:void 0},describeCell:(z,X)=>{const ne=`${h.header[X]}${h.rowNumbers[z]}`;if(te(z,X))return`${ne} ${u("filesView.artifact.office.locked")}`;const Y=ve(z,X)?.formula;return Y?`${ne} =${Y}`:ne},status:[qe,Xe].filter(Boolean).join(" · "),statusHint:k===0?void 0:u("filesView.artifact.office.externalResultsHint"),actions:r.jsxs(r.Fragment,{children:[P==="failed"?r.jsx(Et,{label:u("contextTooltips.files.retrySave"),children:r.jsx(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>Ce(async()=>{await ue(A.current)}),children:u("filesView.artifact.state.retry")})}):null,p.length>1?r.jsxs(qc,{value:String(d),onValueChange:z=>b(Number(z)),children:[r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx(Xc,{className:"w-fit max-w-48","aria-label":u("filesView.artifact.office.sheet"),children:r.jsx(Yc,{children:$.name})})}),r.jsx(it,{side:"bottom",sideOffset:6,children:u("contextTooltips.files.chooseSheet")})]}),r.jsx(Jc,{children:p.map((z,X)=>r.jsx(Qc,{value:String(X),children:z.name},X))})]}):null]})},d)},Cw=({name:n,path:e,sizeBytes:s,loadBytes:t,actions:l,onSave:a,readPreview:c=bw})=>{const{t:m}=De(),[u,p]=o.useState({status:"loading"}),[d,b]=o.useState(0),h=o.useRef(Promise.resolve()),y=o.useRef(null),[E,F]=o.useState(null),M=o.useCallback(()=>F(null),[]);if(o.useEffect(()=>{const C=P=>{const D=y.current;if(!D||P.source!==D.contentWindow)return;const g=xw.safeParse(P.data);if(!g.success)return;if(g.data.type===Go){Lu(g.data.url)&&Gc(g.data.url);return}const{text:A,place:B,x:I,y:L}=g.data,T=D.getBoundingClientRect();F(A?{quote:B?`${B}:
|
|
78
78
|
${A}`:A,x:T.left+I,y:T.top+Math.max(0,L)-10}:null)};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[]),o.useEffect(()=>{const C=new AbortController,{signal:P}=C;let D;return p({status:"loading"}),(async()=>{let g;try{g=await t(e,P)}catch{P.aborted||p({status:"read-failed"});return}if(!P.aborted)try{const A=await c(n,e,g);A?.kind==="workbook"&&(D=A.book),P.aborted?D?.close():p(A?{status:"ready",preview:A}:{status:"unreadable"})}catch{P.aborted||p({status:"unreadable"})}})(),()=>{C.abort(),h.current.finally(()=>D?.close())}},[n,e,t,c,d]),u.status==="loading")return r.jsx(Sn,{label:m("filesView.artifact.state.loading")});if(u.status==="read-failed")return r.jsx(dn,{icon:r.jsx(ee,{name:"error-warning",className:"size-10 text-[color:var(--status-error)]"}),title:m("filesView.artifact.state.readFailed",{name:n}),actions:r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>b(C=>C+1),children:[r.jsx(ee,{name:"refresh",className:"me-2 size-4"}),m("filesView.artifact.state.retry")]})}),r.jsx(it,{sideOffset:6,children:m("contextTooltips.files.retryFile")})]})});if(u.status==="unreadable")return r.jsx(hi,{name:n,path:e,sizeBytes:s,download:l,description:m("filesView.artifact.office.unreadable")});const{preview:N}=u;if(N.kind==="workbook")return r.jsx(Sw,{path:e,book:N.book,bytes:N.bytes,sizeBytes:s,readBytes:()=>t(e,AbortSignal.timeout(6e4)),onSave:a?C=>a(e,C):void 0,onChangedOnDisk:()=>b(C=>C+1),queue:h});const k=N.slideCount===null?"":m(N.slideCount===1?"filesView.artifact.office.slidesSingle":"filesView.artifact.office.slidesPlural",{slides:N.slideCount});return r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r.jsx(Cn,{items:[k,fn(s)]}),r.jsx("div",{className:"min-h-0 flex-1 bg-[var(--surface-background)]",children:r.jsx("iframe",{ref:y,srcDoc:N.html,sandbox:"allow-scripts",title:n,className:"block h-full w-full border-0",style:{colorScheme:"normal"}})}),E?r.jsx(yu,{anchor:E,quote:E.quote,fileLabel:e,onClose:M},E.quote):null]})},jw=async n=>(await zo(async()=>{const{openPdf:e}=await import("./pdfjs-uwkGOIm9.js");return{openPdf:e}},__vite__mapDeps([225,226]))).openPdf(n),kw=()=>navigator.pdfViewerEnabled!==!1,go=8,Ew=new Set(["InvalidPDFException","PasswordException"]),Nw=n=>{const e=Fe.c(22),{doc:s,pageNumber:t,size:l,width:a,scroller:c,label:m}=n,u=o.useRef(null),p=o.useRef(null),[d,b]=o.useState(!1);let h,y;e[0]!==c?(h=()=>{const P=u.current;if(!P||!c)return;const D=new IntersectionObserver(g=>b(g.some(Tw)),{root:c,rootMargin:"100% 0px"});return D.observe(P),()=>D.disconnect()},y=[c],e[0]=c,e[1]=h,e[2]=y):(h=e[1],y=e[2]),o.useEffect(h,y);let E,F;e[3]!==s||e[4]!==d||e[5]!==t||e[6]!==l.width||e[7]!==a?(E=()=>{const P=p.current;if(!P)return;if(!d||a<=0){P.width=0,P.height=0;return}let D=!1,g=null;return s.getPage(t).then(A=>{if(D)return;const B=window.devicePixelRatio||1,I=A.getViewport({scale:a/l.width*B});P.width=Math.floor(I.width),P.height=Math.floor(I.height),g=A.render({canvas:P,viewport:I}),g.promise.catch(Mw)}).catch(Pw),()=>{D=!0,g?.cancel()}},F=[s,t,d,a,l.width],e[3]=s,e[4]=d,e[5]=t,e[6]=l.width,e[7]=a,e[8]=E,e[9]=F):(E=e[8],F=e[9]),o.useEffect(E,F);let M;e[10]!==l.height||e[11]!==l.width||e[12]!==a?(M=Math.round(a*l.height/l.width),e[10]=l.height,e[11]=l.width,e[12]=a,e[13]=M):M=e[13];let N;e[14]!==M||e[15]!==a?(N={width:a,height:M},e[14]=M,e[15]=a,e[16]=N):N=e[16];let k;e[17]!==m?(k=r.jsx("canvas",{ref:p,role:"img","aria-label":m,className:"block h-full w-full"}),e[17]=m,e[18]=k):k=e[18];let C;return e[19]!==N||e[20]!==k?(C=r.jsx("div",{ref:u,className:"shrink-0 bg-white",style:N,children:k}),e[19]=N,e[20]=k,e[21]=C):C=e[21],C},Fw=n=>{const e=Fe.c(29),{src:s,name:t,sizeBytes:l,download:a,openPdf:c}=n,{t:m}=De();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={status:"loading"},e[0]=u):u=e[0];const[p,d]=o.useState(u),[b,h]=o.useState(null),[y,E]=o.useState(0);let F,M;e[1]!==c||e[2]!==s?(F=()=>{if(!s)return;let L=!1,T=null;return d({status:"loading"}),(async()=>{try{if(T=await c(s),L){T.destroy();return}const $=await T.promise,W=Array.from({length:$.numPages},Dw),U=await Promise.all(W.map(async q=>{const pe=(await $.getPage(q)).getViewport({scale:1});return{width:pe.width,height:pe.height}}));L||d({status:"ready",doc:$,sizes:U})}catch($){const W=$;L||d({status:"failed",unreadable:W instanceof Error&&Ew.has(W.name)})}})(),()=>{L=!0,T?.destroy()}},M=[s,c],e[1]=c,e[2]=s,e[3]=F,e[4]=M):(F=e[3],M=e[4]),o.useEffect(F,M);let N,k;e[5]!==b?(N=()=>{if(!b)return;const L=new ResizeObserver(()=>E(Math.max(0,b.clientWidth-go*2)));return L.observe(b),()=>L.disconnect()},k=[b],e[5]=b,e[6]=N,e[7]=k):(N=e[6],k=e[7]),o.useEffect(N,k);const C=p.status==="ready"?p.sizes.length:null;let P;e[8]!==C||e[9]!==m?(P=C===null?"":m(C===1?"filesView.artifact.pdf.pagesSingle":"filesView.artifact.pdf.pagesPlural",{pages:C}),e[8]=C,e[9]=m,e[10]=P):P=e[10];const D=P;let g;e[11]!==l?(g=fn(l),e[11]=l,e[12]=g):g=e[12];let A;e[13]!==D||e[14]!==g?(A=r.jsx(Cn,{items:[D,g]}),e[13]=D,e[14]=g,e[15]=A):A=e[15];let B;e[16]!==a||e[17]!==t||e[18]!==b||e[19]!==p.doc||e[20]!==p.sizes||e[21]!==p.status||e[22]!==p.unreadable||e[23]!==m||e[24]!==y?(B=p.status==="failed"?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[r.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:m(p.unreadable?"filesView.artifact.pdf.loadFailed":"filesView.error.readFileFailed")}),a]}):p.status==="loading"?r.jsxs("div",{className:"flex items-center gap-2 p-3 typography-ui text-muted-foreground",children:[r.jsx(ee,{name:"loader-4",className:"size-4 animate-spin"}),m("common.loading")]}):r.jsx(un,{ref:h,outerClassName:"min-h-0 flex-1 bg-[var(--surface-background)]",style:{padding:go},disableHorizontal:!0,children:r.jsx("div",{className:"flex flex-col items-center",style:{gap:go},children:y>0&&p.sizes.map((L,T)=>r.jsx(Nw,{doc:p.doc,pageNumber:T+1,size:L,width:y,scroller:b,label:m("filesView.artifact.pdf.pageLabel",{page:T+1,name:t})},T))})}),e[16]=a,e[17]=t,e[18]=b,e[19]=p.doc,e[20]=p.sizes,e[21]=p.status,e[22]=p.unreadable,e[23]=m,e[24]=y,e[25]=B):B=e[25];let I;return e[26]!==A||e[27]!==B?(I=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[A,B]}),e[26]=A,e[27]=B,e[28]=I):I=e[28],I},Rw=n=>{const e=Fe.c(9),{src:s,name:t,sizeBytes:l,download:a,openPdf:c}=n,m=c===void 0?jw:c;if(kw()){let p;return e[0]!==t||e[1]!==s?(p=r.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:r.jsx("iframe",{src:s,className:"h-full w-full border-0",title:t})}),e[0]=t,e[1]=s,e[2]=p):p=e[2],p}let u;return e[3]!==a||e[4]!==t||e[5]!==m||e[6]!==l||e[7]!==s?(u=r.jsx(Fw,{src:s,name:t,sizeBytes:l,download:a,openPdf:m}),e[3]=a,e[4]=t,e[5]=m,e[6]=l,e[7]=s,e[8]=u):u=e[8],u};function Tw(n){return n.isIntersecting}function Mw(){}function Pw(){}function Dw(n,e){return e+1}const Aw=[48,32,24,18,14],Vw=["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz",`0123456789 .,;:!?&@#%()[]{}<>+-=/\\*"'`];let wo=0;const Lw=n=>{const e=Fe.c(17),{src:s,name:t,sizeBytes:l}=n,{t:a}=De(),[c,m]=o.useState("loading"),[u]=o.useState(Ow);let p,d;e[0]!==u||e[1]!==s?(p=()=>{let F=!1;m("loading");const M=new FontFace(u,`url("${s.replace(/"/g,"%22")}")`);return document.fonts.add(M),M.load().then(()=>{F||m("ready")}).catch(()=>{F||m("failed")}),()=>{F=!0,document.fonts.delete(M)}},d=[u,s],e[0]=u,e[1]=s,e[2]=p,e[3]=d):(p=e[2],d=e[3]),o.useEffect(p,d);let b;e[4]!==l?(b=fn(l),e[4]=l,e[5]=b):b=e[5];let h;e[6]!==t||e[7]!==b?(h=r.jsx(Cn,{items:[t,b]}),e[6]=t,e[7]=b,e[8]=h):h=e[8];let y;e[9]!==u||e[10]!==t||e[11]!==c||e[12]!==a?(y=c==="failed"?r.jsx(dn,{icon:r.jsx(ln,{filePath:t,className:"size-10"}),title:t,description:a("filesView.artifact.font.loadFailed")}):c==="loading"?r.jsx(Sn,{label:a("filesView.artifact.state.loading")}):r.jsx(un,{outerClassName:"min-h-0 flex-1",className:"p-4",style:{fontFamily:`"${u}"`},children:r.jsxs("div",{className:"flex flex-col gap-4",children:[Aw.map(F=>r.jsxs("div",{className:"flex items-baseline gap-3",children:[r.jsx("span",{className:"w-8 shrink-0 text-end font-sans typography-meta text-muted-foreground",children:F}),r.jsx("span",{className:"min-w-0 break-words leading-tight text-foreground",style:{fontSize:`${F}px`},children:a("filesView.artifact.font.sample")})]},F)),r.jsx("div",{className:"mt-2 flex flex-col gap-1 border-t border-edge-muted pt-4 text-foreground",style:{fontSize:"20px"},children:Vw.map(Iw)})]})}),e[9]=u,e[10]=t,e[11]=c,e[12]=a,e[13]=y):y=e[13];let E;return e[14]!==h||e[15]!==y?(E=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[h,y]}),e[14]=h,e[15]=y,e[16]=E):E=e[16],E};function Ow(){return wo=wo+1,`oc-font-preview-${wo}`}function Iw(n){return r.jsx("div",{className:"break-all leading-relaxed",children:n},n)}const ui=12,Ou=.1,Iu=16,Dc=[.1,.25,.5,.75,1,1.5,2,3,4,6,8,12,16],zw=16,Ac=30,$w=(n,e)=>{const s=e.width-ui*2,t=e.height-ui*2;return n.width<=0||n.height<=0||s<=0||t<=0?1:Math.min(1,s/n.width,t/n.height)},Bw=(n,e)=>Math.min(Iu,Math.max(Math.min(Ou,e),n)),Vc=(n,e)=>e===1?Dc.find(s=>s>n*1.001)??Iu:[...Dc].reverse().find(s=>s<n*.999)??Ou,_w=(n,e)=>{const s=e===1?n*zw:n,t=Math.max(-Ac,Math.min(Ac,s));return Math.exp(-t/100)},Lc=(n,e)=>Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY);let xo=null;const Ww='[role="tablist"], [role="menu"], [role="menubar"], [role="listbox"], [role="radiogroup"], [role="slider"], [role="combobox"], [role="tree"], [role="grid"], [role="toolbar"]',Oc="absolute top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-surface-elevated/90 text-surface-elevated-foreground hover:bg-surface-elevated focus:outline-none focus:ring-2 focus:ring-ring",Uw=({src:n,name:e,sizeBytes:s,neighbors:t,onRetry:l,download:a})=>{const{t:c,direction:m}=De(),[u,p]=o.useState(null),[d,b]=o.useState(null),[h,y]=o.useState(!1),[E,F]=o.useState(0),[M,N]=o.useState(null),[k,C]=o.useState(!1),P=o.useRef(null),D=o.useRef(null),g=o.useRef(null),A=o.useRef(null),B=o.useRef(null),I=()=>{y(!1),F(R=>R+1),l?.()};o.useEffect(()=>{const R=P.current;if(!R)return;const K=new ResizeObserver(()=>{N({width:R.clientWidth,height:R.clientHeight})});return K.observe(R),()=>K.disconnect()},[]);const L=d&&M?$w(d,M):1,T=u??L,$=u!==null&&d!==null&&M!==null&&(d.width*u+ui*2>M.width||d.height*u+ui*2>M.height),W=(R,K,G)=>{const te=g.current;if(!te||!d)return;const Le=te.getBoundingClientRect(),J=te.clientWidth/d.width;J<=0||(A.current={imageX:(K-Le.left-te.clientLeft)/J,imageY:(G-Le.top-te.clientTop)/J,clientX:K,clientY:G},df.flushSync(()=>p(Bw(R,L))))},U=R=>{const K=P.current;if(!K)return;const G=K.getBoundingClientRect();W(R,G.left+G.width/2,G.top+G.height/2)};o.useLayoutEffect(()=>{const R=A.current,K=P.current,G=g.current;if(A.current=null,!R||!K||!G||u===null||G.naturalWidth<=0)return;const te=G.getBoundingClientRect(),Le=G.clientWidth/G.naturalWidth;K.scrollLeft+=te.left+G.clientLeft+R.imageX*Le-R.clientX,K.scrollTop+=te.top+G.clientTop+R.imageY*Le-R.clientY},[u]);const q=o.useRef({zoomTo:W,shownScale:T});q.current={zoomTo:W,shownScale:T},o.useEffect(()=>{const R=P.current;if(!R)return;let K=0,G=null,te=null;const Le=Y=>{if(!Y.ctrlKey&&!Y.metaKey)return;Y.preventDefault();const se=q.current;se.zoomTo(se.shownScale*_w(Y.deltaY,Y.deltaMode),Y.clientX,Y.clientY)},J=Y=>{K=Y.touches.length,Y.touches.length===2&&(G={distance:Lc(Y.touches[0],Y.touches[1]),scale:q.current.shownScale})},qe=Y=>{if(!G||Y.touches.length!==2||G.distance<=0)return;Y.preventDefault();const[se,xe]=[Y.touches[0],Y.touches[1]];q.current.zoomTo(G.scale*(Lc(se,xe)/G.distance),(se.clientX+xe.clientX)/2,(se.clientY+xe.clientY)/2)},Xe=Y=>{K=Y.touches.length,Y.touches.length<2&&(G=null)},z=Y=>{Y.preventDefault(),te=K>0?null:q.current.shownScale},X=Y=>{Y.preventDefault(),te!==null&&q.current.zoomTo(te*Y.scale,Y.clientX,Y.clientY)},ne=Y=>{Y.preventDefault(),te=null};return R.addEventListener("wheel",Le,{passive:!1}),R.addEventListener("touchstart",J,{passive:!0}),R.addEventListener("touchmove",qe,{passive:!1}),R.addEventListener("touchend",Xe,{passive:!0}),R.addEventListener("touchcancel",Xe,{passive:!0}),R.addEventListener("gesturestart",z),R.addEventListener("gesturechange",X),R.addEventListener("gestureend",ne),()=>{R.removeEventListener("wheel",Le),R.removeEventListener("touchstart",J),R.removeEventListener("touchmove",qe),R.removeEventListener("touchend",Xe),R.removeEventListener("touchcancel",Xe),R.removeEventListener("gesturestart",z),R.removeEventListener("gesturechange",X),R.removeEventListener("gestureend",ne)}},[]);const pe=R=>{if(!$||R.pointerType!=="mouse"||R.button!==0)return;const K=R.currentTarget,G=K.getBoundingClientRect();R.clientX-G.left>=K.clientWidth||R.clientY-G.top>=K.clientHeight||(R.preventDefault(),K.setPointerCapture(R.pointerId),B.current={pointerId:R.pointerId,x:R.clientX,y:R.clientY,left:K.scrollLeft,top:K.scrollTop},C(!0))},be=R=>{const K=B.current;!K||K.pointerId!==R.pointerId||(R.currentTarget.scrollLeft=K.left-(R.clientX-K.x),R.currentTarget.scrollTop=K.top-(R.clientY-K.y))},ve=R=>{B.current?.pointerId===R.pointerId&&(B.current=null,C(!1))},ue=R=>{if(!t||u!==null||R.defaultPrevented||R.altKey||R.ctrlKey||R.metaKey||R.shiftKey)return;const K=m==="rtl"?"ArrowRight":"ArrowLeft",G=m==="rtl"?"ArrowLeft":"ArrowRight";if(R.key!==K&&R.key!==G)return;const te=D.current;if(!te||te.getClientRects().length===0)return;const Le=te.closest("[data-context-panel]")??te,J=R.target;if(J===document.body){if(!xo||!Le.contains(xo))return}else if(!(J instanceof Element)||Zc(J)||J.closest(Ww)||!Le.contains(J))return;R.preventDefault(),(R.key===K?t.previous:t.next).open()},Ce=o.useRef(ue);Ce.current=ue,o.useEffect(()=>{const R=G=>Ce.current(G),K=G=>{const te=G.target instanceof Element?G.target:null;xo=te?.closest("[data-context-panel]")??te};return document.addEventListener("keydown",R),document.addEventListener("pointerdown",K,!0),()=>{document.removeEventListener("keydown",R),document.removeEventListener("pointerdown",K,!0)}},[]);const Me=R=>{if(u===null){W(1,R.clientX,R.clientY);return}p(null)};return r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r.jsx(Cn,{items:[Au(d),fn(s)],actions:r.jsxs(r.Fragment,{children:[r.jsx(Et,{side:"bottom",label:c("filesView.artifact.image.zoomOut"),children:r.jsx(Se,{variant:"ghost",size:"xs","aria-label":c("filesView.artifact.image.zoomOut"),disabled:!d,onClick:()=>U(Vc(T,-1)),children:r.jsx(ee,{name:"subtract",className:"size-3.5"})})}),r.jsx(Et,{side:"bottom",label:c("filesView.artifact.image.actualTitle"),children:r.jsx(Se,{variant:"ghost",size:"xs",className:"min-w-11 tabular-nums","aria-label":c("filesView.artifact.image.actualTitle"),disabled:!d,onClick:()=>U(1),children:`${Math.round(T*100)}%`})}),r.jsx(Et,{side:"bottom",label:c("filesView.artifact.image.zoomIn"),children:r.jsx(Se,{variant:"ghost",size:"xs","aria-label":c("filesView.artifact.image.zoomIn"),disabled:!d,onClick:()=>U(Vc(T,1)),children:r.jsx(ee,{name:"add",className:"size-3.5"})})}),r.jsx(Et,{side:"bottom",label:c("filesView.artifact.image.fitTitle"),children:r.jsx(Se,{variant:"chip",size:"xs","aria-pressed":u===null,"aria-label":c("filesView.artifact.image.fitTitle"),onClick:()=>p(null),children:c("filesView.artifact.image.fit")})})]})}),r.jsxs("div",{ref:D,className:"relative flex min-h-0 flex-1 flex-col",children:[h?r.jsx(dn,{className:t?"px-16":void 0,icon:r.jsx(ee,{name:"image",className:"size-10 text-muted-foreground"}),title:c("filesView.artifact.image.loadFailed"),description:c("filesView.artifact.image.loadFailedDescription"),actions:r.jsxs(r.Fragment,{children:[r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:I,children:[r.jsx(ee,{name:"refresh",className:"me-2 size-4"}),c("filesView.artifact.state.retry")]})}),r.jsx(it,{sideOffset:6,children:c("contextTooltips.files.retryImage")})]}),a]})}):null,!h&&!d?r.jsx(Sn,{label:c("filesView.artifact.state.loading"),className:"pointer-events-none absolute inset-0"}):null,r.jsx(un,{ref:P,tabIndex:t?0:void 0,outerClassName:ce("min-h-0 flex-1",h&&"hidden"),className:ce("outline-none",$&&(k?"cursor-grabbing":"cursor-grab")),onPointerDown:pe,onPointerMove:be,onPointerUp:ve,onPointerCancel:ve,onDoubleClick:Me,children:r.jsx("div",{className:ce("flex items-center justify-center p-3",u===null?"h-full w-full":"min-h-full min-w-full w-max"),children:n?r.jsx("img",{ref:g,src:n,alt:e,draggable:!1,onLoad:R=>{const K=R.currentTarget;b({width:K.naturalWidth,height:K.naturalHeight})},onError:()=>y(!0),style:u!==null&&d?{width:d.width*u,height:d.height*u}:void 0,className:ce("select-none rounded-md border border-edge-muted bg-primary/10",u===null?"max-h-full max-w-full object-contain":"max-w-none shrink-0",!d&&"invisible")},`${n}:${E}`):null})}),t?r.jsxs(r.Fragment,{children:[r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx("button",{type:"button",className:ce(Oc,"inset-s-3"),"aria-label":c("filesView.artifact.image.previous",{name:t.previous.name}),onClick:()=>t.previous.open(),children:r.jsx(ee,{name:"arrow-left-s",className:"h-6 w-6"})})}),r.jsx(it,{sideOffset:6,children:c("filesView.artifact.image.previous",{name:t.previous.name})})]}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx("button",{type:"button",className:ce(Oc,"inset-e-3"),"aria-label":c("filesView.artifact.image.next",{name:t.next.name}),onClick:()=>t.next.open(),children:r.jsx(ee,{name:"arrow-right-s",className:"h-6 w-6"})})}),r.jsx(it,{sideOffset:6,children:c("filesView.artifact.image.next",{name:t.next.name})})]})]}):null]})]})},Hw=n=>{const e=Fe.c(2);let s;return e[0]!==n?(s=an.createElement(Uw,{...n,key:n.src}),e[0]=n,e[1]=s):s=e[1],s},Kw=(n,e)=>{const s=n.filter(c=>c.type==="file"&&mr(c.path)),t=s.findIndex(c=>c.path===e);if(t===-1||s.length<2)return null;const l=s[(t-1+s.length)%s.length],a=s[(t+1)%s.length];return l&&a?{previous:l,next:a}:null},Gw=1e4,qw=n=>{const e=Fe.c(25),{kind:s,src:t,renewSrc:l,name:a,sizeBytes:c,download:m}=n,{t:u}=De(),[p,d]=o.useState(null),[b,h]=o.useState(null),[y,E]=o.useState(!1),F=o.useRef(0),M=o.useRef(null);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=T=>{const $=T.currentTarget;d(Number.isFinite($.duration)?$.duration:null),$ instanceof HTMLVideoElement&&h({width:$.videoWidth,height:$.videoHeight});const W=M.current;W&&(M.current=null,$.currentTime=W.time,$.playbackRate=W.rate,W.playing&&$.play().catch(Xw))},e[0]=N):N=e[0];const k=N;let C;e[1]!==l||e[2]!==t?(C=T=>{const $=Date.now();if($-F.current<Gw){E(!0);return}F.current=$;const W=T.currentTarget;M.current={time:W.currentTime,rate:W.playbackRate,playing:!W.paused};const U=t;l().then(q=>{q===U&&E(!0)},()=>E(!0))},e[1]=l,e[2]=t,e[3]=C):C=e[3];const P=C;let D;e[4]!==p?(D=yg(p),e[4]=p,e[5]=D):D=e[5];let g;e[6]!==b?(g=Au(b),e[6]=b,e[7]=g):g=e[7];let A;e[8]!==c?(A=fn(c),e[8]=c,e[9]=A):A=e[9];let B;e[10]!==D||e[11]!==g||e[12]!==A?(B=r.jsx(Cn,{items:[D,g,A]}),e[10]=D,e[11]=g,e[12]=A,e[13]=B):B=e[13];let I;e[14]!==m||e[15]!==y||e[16]!==s||e[17]!==a||e[18]!==P||e[19]!==t||e[20]!==u?(I=y?r.jsx(dn,{icon:r.jsx(ln,{filePath:a,className:"size-10"}),title:a,description:u("filesView.artifact.media.unplayable"),actions:m}):s==="video"?r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-[var(--surface-background)] p-3",children:r.jsx("video",{src:t,controls:!0,playsInline:!0,preload:"metadata",title:a,className:"max-h-full max-w-full rounded-md",onLoadedMetadata:k,onError:P})}):r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-6",children:[r.jsx("div",{className:"typography-ui-label truncate text-foreground",children:a}),r.jsx("audio",{src:t,controls:!0,preload:"metadata",title:a,className:"w-full max-w-lg",onLoadedMetadata:k,onError:P})]}),e[14]=m,e[15]=y,e[16]=s,e[17]=a,e[18]=P,e[19]=t,e[20]=u,e[21]=I):I=e[21];let L;return e[22]!==B||e[23]!==I?(L=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[B,I]}),e[22]=B,e[23]=I,e[24]=L):L=e[24],L};function Xw(){}const Yw=zn({grant:At().min(1)}),Jw=async(n,e,s=pr)=>{const t=await s("/api/fs/preview",{method:"POST",signal:e,query:{directory:n.directory||void 0,allowOutsideWorkspace:n.outsideWorkspace?"true":void 0},headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n.path})});if(!t.ok)throw new Error(`Preview grant request failed (${t.status})`);const l=Yw.safeParse(await t.json().catch(()=>null));if(!l.success)throw new Error("Preview grant response was invalid");return l.data.grant},Qw=(n,e)=>{const s=e.split("/").map(l=>encodeURIComponent(l)).join("/"),t=s.startsWith("/")?s:`/${s}`;return hu().api(`/api/fs/preview/${encodeURIComponent(n)}${t}`)},Zw=(n,e,s)=>{const t=Fe.c(9),l=Jw;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a={status:"idle"},t[0]=a):a=t[0];const[c,m]=o.useState(a),u=n?.path??"",p=n?.directory??"",d=n?.revision??"",b=n?.outsideWorkspace??!1;let h,y;return t[1]!==p||t[2]!==e||t[3]!==l||t[4]!==b||t[5]!==u||t[6]!==d?(h=()=>{if(!u){m({status:"idle"});return}const E=new AbortController;return m({status:"loading"}),(async()=>{try{const M=await l({path:u,directory:p,revision:d,outsideWorkspace:b},E.signal);E.signal.aborted||m({status:"ready",url:Qw(M,u)})}catch(M){const N=M;if(E.signal.aborted)return;m({status:"error",message:N instanceof Error?N.message:e})}})(),()=>E.abort()},y=[u,p,d,b,e,l],t[1]=p,t[2]=e,t[3]=l,t[4]=b,t[5]=u,t[6]=d,t[7]=h,t[8]=y):(h=t[7],y=t[8]),o.useEffect(h,y),c},Ic=n=>hu().authenticatedAsset("/api/fs/raw",{path:n.path,allowOutsideWorkspace:n.outsideWorkspace?"true":void 0,directory:n.directory||void 0}),ex=(n,e,s,t=wm)=>{const l=n?.runtime??"",a=n?.path??"",c=n?.directory??"",m=n?.revision??"",u=n?.outsideWorkspace??!1,p=Mf(),d=a?JSON.stringify([l,a,c,m,u]):"",[b,h]=o.useState(null),y=o.useCallback(async()=>(await t(xm()),Ic({path:a,directory:c,outsideWorkspace:u})),[a,c,u,t]);o.useEffect(()=>{if(!d)return;let M=!1;const N=new AbortController;let k;return(async()=>{try{let P;if(p){const D=AbortSignal.any([N.signal,AbortSignal.timeout(3e4)]),g=await pr("/api/fs/raw",{query:{path:a,directory:c||void 0,allowOutsideWorkspace:u?"true":void 0},signal:D});if(!g.ok)throw new Error(s);const A=await Ro(g,Mo,D);if(M)return;k=URL.createObjectURL(A),P=k}else P=await y();if(M)return;h({key:d,url:P}),e(null)}catch(P){if(M)return;e(p?s:P instanceof Error?P.message:s),h({key:d,url:p?"":Ic({path:a,directory:c,outsideWorkspace:u})})}})(),()=>{M=!0,N.abort(),k&&URL.revokeObjectURL(k)}},[d,y,e,s,a,c,u,p]);const E=o.useCallback(async()=>{if(p)return b?.key===d?b.url:"";const M=await y();return h(N=>N?.key===d?{key:d,url:M}:N),M},[d,y,p,b]);return{src:d&&b?.key===d?b.url:"",loading:!!d&&b?.key!==d,renew:E}},tx=n=>({...n,pageUrl:Df(n.pageUrl)}),nx=n=>{const e=Fe.c(7),{frameRef:s,directory:t,pageKey:l}=n,{t:a}=De();let c;e[0]!==a?(c=a("filesView.editor.htmlAnnotate.intro"),e[0]=a,e[1]=c):c=e[1];let m;return e[2]!==t||e[3]!==s||e[4]!==l||e[5]!==c?(m={frameRef:s,directory:t,pageKey:l,intro:c,describePage:tx},e[2]=t,e[3]=s,e[4]=l,e[5]=c,e[6]=m):m=e[6],Pf(m)},zc=n=>{const e=ke(n);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const s=e.lastIndexOf("/");if(s<0)return e;if(s===0)return"/";const t=e.slice(0,s);return/^[A-Za-z]:$/.test(t)?`${t}/`:t},sx=n=>n.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),ke=n=>{if(!n)return"";const e=n.replace(/\\/g,"/"),s=e.startsWith("//");let t=e.replace(/\/+/g,"/");s&&!t.startsWith("//")&&(t=`/${t}`);const l=t==="/",a=/^[A-Za-z]:\/$/.test(t);return!l&&!a&&(t=t.replace(/\/+$/,"")),t},rx=n=>n.startsWith("/")||n.startsWith("//")||/^[A-Za-z]:\//.test(n),Ms=n=>/^[A-Za-z]:\//.test(n)?n.toLowerCase():n,Ps=(n,e)=>{const s=ke(e),t=ke(n);if(!s||!t)return!1;const l=Ms(s),a=Ms(t);return a===l||a.startsWith(`${l}/`)},$c=(n,e)=>{const s=ke(e),t=ke(n);if(!Ps(t,s))return[];const a=t.slice(s.length).replace(/^\//,"").split("/"),c=[];let m=s;for(let u=0;u<a.length-1;u++)m=m?`${m}/${a[u]}`:a[u],c.push(m);return c},On=(n,e)=>{if(!e)return"";const s=ke(e);if(!n||!Ps(s,n))return s;const t=s.slice(n.length);return t.startsWith("/")?t.slice(1):t},ix=new Set(["node_modules"]),zu=n=>{const e=Fe.c(3),{name:s,folder:t}=n;let l;return e[0]!==t||e[1]!==s?(l=t?r.jsxs("span",{dir:"ltr",children:[r.jsxs("span",{className:"text-muted-foreground opacity-70",children:[t,"/"]}),s]}):r.jsx(r.Fragment,{children:s}),e[0]=t,e[1]=s,e[2]=l):l=e[2],l},Bc=n=>{const e=Fe.c(17),{name:s,folder:t}=n,l=o.useRef(null),a=o.useRef(null),[c,m]=o.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const F=l.current,M=a.current;if(!F||!M)return;const N=()=>{m(M.scrollWidth>F.clientWidth+1)};N();const k=new ResizeObserver(N);return k.observe(F),k.observe(M),()=>{k.disconnect()}},e[0]=u):u=e[0];let p;e[1]!==t||e[2]!==s?(p=[s,t],e[1]=t,e[2]=s,e[3]=p):p=e[3],o.useLayoutEffect(u,p);let d;e[4]!==t||e[5]!==s?(d=r.jsx(zu,{name:s,folder:t}),e[4]=t,e[5]=s,e[6]=d):d=e[6];const b=d;let h;e[7]!==b?(h=r.jsx("span",{ref:a,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:b}),e[7]=b,e[8]=h):h=e[8];let y;e[9]!==t||e[10]!==s||e[11]!==c||e[12]!==b?(y=c?r.jsxs("span",{className:"open-file-name-marquee-track",children:[r.jsx("span",{className:"open-file-name-marquee-item",children:b}),r.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:b})]},`${t}/${s}`):r.jsx("span",{className:"block min-w-0 truncate",children:b}),e[9]=t,e[10]=s,e[11]=c,e[12]=b,e[13]=y):y=e[13];let E;return e[14]!==h||e[15]!==y?(E=r.jsxs("span",{ref:l,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[h,y]}),e[14]=h,e[15]=y,e[16]=E):E=e[16],E},ox=n=>ix.has(n),ax=n=>{const e=ke(n);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},lx=n=>{const s=(n instanceof Error?n.message:String(n??"")).toLowerCase();return s.includes("is a directory")||s.includes("eisdir")},cx=2e5,ux=3e4,bo=n=>{if(!n)return!1;const e=n.toLowerCase();if(e.endsWith(".excalidraw.md"))return!1;const s=e.split(".").pop();return s==="md"||s==="markdown"},vo=n=>!!(n&&Fu($o.getState().guests,n)),_c=n=>{if(!n)return!1;const e=n.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},yo=n=>{if(!n)return!1;const e=n.toLowerCase().split(".").pop();return e==="html"||e==="htm"},dx=n=>{const e=Fe.c(108),{guestActions:s,node:t,root:l,isExpanded:a,isActive:c,isMobile:m,isBrowserClient:u,alwaysShowActions:p,depth:d,isOpen:b,status:h,badge:y,permissions:E,downloadFile:F,contextMenuPath:M,setContextMenuPath:N,rightClickMenuPath:k,setRightClickMenuPath:C,onSelect:P,onToggle:D,onRevealPath:g,onOpenDialog:A,canUpload:B,onPickFiles:I}=n,{t:L}=De(),T=t.type==="directory",{canRename:$,canCreateFile:W,canCreateFolder:U,canDelete:q,canReveal:pe}=E,be=!T&&!!F,ve=pe&&!u,ue=T&&B,Ce=$||W||U||ue||q||be||ve;let Me;e[0]!==Ce||e[1]!==t.path||e[2]!==C?(Me=_e=>{Ce&&(_e?.preventDefault(),C(t.path))},e[0]=Ce,e[1]=t.path,e[2]=C,e[3]=Me):Me=e[3];const R=Me;let K;e[4]!==T||e[5]!==t||e[6]!==P||e[7]!==D?(K=()=>{T?D(t.path):P(t)},e[4]=T,e[5]=t,e[6]=P,e[7]=D,e[8]=K):K=e[8];const G=K;let te;e[9]!==t.path||e[10]!==N||e[11]!==C?(te=_e=>{_e.stopPropagation(),C(null),N(t.path)},e[9]=t.path,e[10]=N,e[11]=C,e[12]=te):te=e[12];const Le=te;let J,qe,Xe,z,X,ne,Y;if(e[13]!==p||e[14]!==y||e[15]!==W||e[16]!==U||e[17]!==q||e[18]!==$||e[19]!==ve||e[20]!==ue||e[21]!==M||e[22]!==d||e[23]!==F||e[24]!==s||e[25]!==R||e[26]!==G||e[27]!==Le||e[28]!==Ce||e[29]!==c||e[30]!==u||e[31]!==T||e[32]!==a||e[33]!==m||e[34]!==b||e[35]!==t||e[36]!==A||e[37]!==I||e[38]!==g||e[39]!==k||e[40]!==l||e[41]!==N||e[42]!==C||e[43]!==h||e[44]!==L){const _e=om(s,"file"),jn=mt=>{const{Item:Ie,Separator:mn}=mt;return r.jsxs(r.Fragment,{children:[$&&r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),A("rename",t)},children:[r.jsx(ee,{name:"edit",className:"me-2 size-4"})," ",L("sidebarFilesTree.menu.rename")]}),r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),wr(t.path).then(ze=>{if(ze.ok){re.success(L("sidebarFilesTree.toast.pathCopied"));return}re.error(L("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(ee,{name:"link",className:"me-2 size-4"})," ",L("sidebarFilesTree.menu.copyPath")]}),r.jsxs(Ie,{onClick:me=>{me.stopPropagation();const ze=On(l,t.path)||t.path;wr(ze).then(Rt=>{if(Rt.ok){re.success(L("filesView.toast.relativePathCopied"));return}re.error(L("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(ee,{name:"file-copy-2",className:"me-2 size-4"})," ",L("filesView.tree.menu.copyRelativePath")]}),!T&&F&&r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),F(t.path).catch(ze=>{console.error("Download failed:",ze),re.error(L("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(ee,{name:"download",className:"me-2 size-4"})," ",L(u?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),ve&&r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),g(t.path)},children:[r.jsx(ee,{name:"folder-received",className:"me-2 size-4"})," ",L(cm())]}),!T&&ve&&To()&&r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),fr(t.path).then(ze=>{ze||re.error(L("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(ee,{name:"external-link",className:"me-2 size-4"})," ",L("sidebarFilesTree.menu.openInDefaultApp")]}),_e.length>0&&r.jsx(mn,{}),_e.map(me=>r.jsxs(Ie,{onClick:ze=>{ze.stopPropagation(),dm(me,{kind:"file",action:me.action.id,directory:l||null,path:t.path,isDirectory:T},L)},children:[r.jsx(um,{icon:me.icon,iconSrc:me.iconSrc,className:"me-2 size-4"})," ",me.action.label]},`${me.guest.id}:${me.action.id}`)),T&&(W||U||ue)&&r.jsxs(r.Fragment,{children:[r.jsx(mn,{}),W&&r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),A("createFile",t)},children:[r.jsx(ee,{name:"file-add",className:"me-2 size-4"})," ",L("sidebarFilesTree.menu.newFile")]}),U&&r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),A("createFolder",t)},children:[r.jsx(ee,{name:"folder-add",className:"me-2 size-4"})," ",L("sidebarFilesTree.menu.newFolder")]}),ue&&r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),I(t.path)},children:[r.jsx(ee,{name:"upload-2",className:"me-2 size-4"})," ",L("sidebarFilesTree.menu.uploadFiles")]})]}),q&&r.jsxs(r.Fragment,{children:[r.jsx(mn,{}),r.jsxs(Ie,{onClick:me=>{me.stopPropagation(),A("delete",t)},className:"text-destructive focus:text-destructive",children:[r.jsx(ee,{name:"delete-bin",className:"me-2 size-4"})," ",L("sidebarFilesTree.menu.delete")]})]})]})};qe=ko,X=k===t.path,e[52]!==t.path||e[53]!==C?(ne=mt=>C(mt?t.path:null),e[52]=t.path,e[53]=C,e[54]=ne):ne=e[54];const de=m?void 0:R;let Ke;e[55]!==t.path||e[56]!==de?(Ke=r.jsx("div",{className:"group relative flex items-center","data-tree-disclosure-path":t.path,onContextMenu:de}),e[55]=t.path,e[56]=de,e[57]=Ke):Ke=e[57];let Oe;e[58]!==d?(Oe=r.jsx(du,{depth:d}),e[58]=d,e[59]=Oe):Oe=e[59];const Ye=m?void 0:R;let oe;e[60]!==c?(oe=ce("oc-file-tree-row flex w-full items-center gap-1.5 rounded-md py-1 text-start select-none",cu(c)),e[60]=c,e[61]=oe):oe=e[61];let Ze;e[62]!==d?(Ze=fu(d),e[62]=d,e[63]=Ze):Ze=e[63];let Je;e[64]!==Ze?(Je={paddingLeft:Ze},e[64]=Ze,e[65]=Je):Je=e[65];let Re;e[66]!==T||e[67]!==a||e[68]!==t.extension||e[69]!==t.path?(Re=T?r.jsx(am,{expanded:a}):r.jsx(ln,{filePath:t.path,extension:t.extension,className:"ms-0.5 size-3.5"}),e[66]=T,e[67]=a,e[68]=t.extension,e[69]=t.path,e[70]=Re):Re=e[70];let ot;e[71]!==t.name||e[72]!==t.path?(ot=r.jsx("span",{className:"oc-file-tree-row-name typography-meta",title:t.path,children:t.name}),e[71]=t.name,e[72]=t.path,e[73]=ot):ot=e[73];let zt;e[74]!==T||e[75]!==b||e[76]!==h?(zt=!T&&r.jsx(fm,{isOpen:b,status:h}),e[74]=T,e[75]=b,e[76]=h,e[77]=zt):zt=e[77];let Nt;e[78]!==y||e[79]!==T?(Nt=T&&y&&r.jsx(mm,{badge:y}),e[78]=y,e[79]=T,e[80]=Nt):Nt=e[80];let bt;e[81]!==zt||e[82]!==Nt?(bt=r.jsxs(hm,{className:"pe-2",children:[zt,Nt]}),e[81]=zt,e[82]=Nt,e[83]=bt):bt=e[83];let et;e[84]!==G||e[85]!==Ye||e[86]!==oe||e[87]!==Je||e[88]!==Re||e[89]!==ot||e[90]!==bt?(et=r.jsxs("button",{type:"button",onClick:G,onContextMenu:Ye,className:oe,style:Je,children:[Re,ot,bt]}),e[84]=G,e[85]=Ye,e[86]=oe,e[87]=Je,e[88]=Re,e[89]=ot,e[90]=bt,e[91]=et):et=e[91];const Ft=Ce&&r.jsx("div",{className:ce("oc-file-tree-row-end -ms-7 w-7 pe-1 transition-opacity",lm(c),p?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:r.jsxs(ou,{open:M===t.path,onOpenChange:mt=>N(mt?t.path:null),children:[r.jsx(au,{asChild:!0,children:r.jsx(Se,{variant:"ghost",size:"icon",className:"size-6",onClick:Le,"aria-label":L("diffView.actions.moreActions"),"data-row-tooltip":L("diffView.actions.moreActions"),children:r.jsx(ee,{name:"more-2-fill",className:"size-4"})})}),r.jsx(lu,{align:"end",side:"bottom",onCloseAutoFocus:()=>N(null),children:jn({Item:dr,Separator:uu})})]})});e[92]!==Ke||e[93]!==Oe||e[94]!==et||e[95]!==Ft?(Y=r.jsxs(Eo,{render:Ke,children:[Oe,et,Ft]}),e[92]=Ke,e[93]=Oe,e[94]=et,e[95]=Ft,e[96]=Y):Y=e[96],J=No,Xe="min-w-[180px]";let H;e[97]===Symbol.for("react.memo_cache_sentinel")?(H={Item:In,Separator:Kc},e[97]=H):H=e[97],z=jn(H),e[13]=p,e[14]=y,e[15]=W,e[16]=U,e[17]=q,e[18]=$,e[19]=ve,e[20]=ue,e[21]=M,e[22]=d,e[23]=F,e[24]=s,e[25]=R,e[26]=G,e[27]=Le,e[28]=Ce,e[29]=c,e[30]=u,e[31]=T,e[32]=a,e[33]=m,e[34]=b,e[35]=t,e[36]=A,e[37]=I,e[38]=g,e[39]=k,e[40]=l,e[41]=N,e[42]=C,e[43]=h,e[44]=L,e[45]=J,e[46]=qe,e[47]=Xe,e[48]=z,e[49]=X,e[50]=ne,e[51]=Y}else J=e[45],qe=e[46],Xe=e[47],z=e[48],X=e[49],ne=e[50],Y=e[51];let se;e[98]!==J||e[99]!==Xe||e[100]!==z?(se=r.jsx(J,{className:Xe,children:z}),e[98]=J,e[99]=Xe,e[100]=z,e[101]=se):se=e[101];let xe;return e[102]!==qe||e[103]!==X||e[104]!==ne||e[105]!==Y||e[106]!==se?(xe=r.jsxs(qe,{open:X,onOpenChange:ne,children:[Y,se]}),e[102]=qe,e[103]=X,e[104]=ne,e[105]=Y,e[106]=se,e[107]=xe):xe=e[107],xe},fx=n=>{const e=Fe.c(83),{activeDialog:s,dialogData:t,dialogInputValue:l,onDialogInputChange:a,isDialogSubmitting:c,onDialogSubmit:m,onClose:u,inputRef:p}=n,{t:d}=De(),b=!!s;let h;e[0]!==u?(h=ue=>!ue&&u(),e[0]=u,e[1]=h):h=e[1];let y;e[2]!==s||e[3]!==d?(y=s==="createFile"&&d("filesView.dialog.createFile.title"),e[2]=s,e[3]=d,e[4]=y):y=e[4];let E;e[5]!==s||e[6]!==d?(E=s==="createFolder"&&d("filesView.dialog.createFolder.title"),e[5]=s,e[6]=d,e[7]=E):E=e[7];let F;e[8]!==s||e[9]!==d?(F=s==="rename"&&d("filesView.dialog.rename.title"),e[8]=s,e[9]=d,e[10]=F):F=e[10];let M;e[11]!==s||e[12]!==d?(M=s==="delete"&&d("filesView.dialog.delete.title"),e[11]=s,e[12]=d,e[13]=M):M=e[13];let N;e[14]!==y||e[15]!==E||e[16]!==F||e[17]!==M?(N=r.jsxs(su,{children:[y,E,F,M]}),e[14]=y,e[15]=E,e[16]=F,e[17]=M,e[18]=N):N=e[18];let k;e[19]!==s||e[20]!==t?.path||e[21]!==d?(k=s==="createFile"&&d("filesView.dialog.createFile.description",{path:t?.path??d("filesView.dialog.rootFallback")}),e[19]=s,e[20]=t?.path,e[21]=d,e[22]=k):k=e[22];let C;e[23]!==s||e[24]!==t?.path||e[25]!==d?(C=s==="createFolder"&&d("filesView.dialog.createFolder.description",{path:t?.path??d("filesView.dialog.rootFallback")}),e[23]=s,e[24]=t?.path,e[25]=d,e[26]=C):C=e[26];let P;e[27]!==s||e[28]!==t?.name||e[29]!==d?(P=s==="rename"&&d("filesView.dialog.rename.description",{name:t?.name??""}),e[27]=s,e[28]=t?.name,e[29]=d,e[30]=P):P=e[30];let D;e[31]!==s||e[32]!==t?.name||e[33]!==d?(D=s==="delete"&&d("filesView.dialog.delete.description",{name:t?.name??""}),e[31]=s,e[32]=t?.name,e[33]=d,e[34]=D):D=e[34];let g;e[35]!==P||e[36]!==D||e[37]!==k||e[38]!==C?(g=r.jsxs(ru,{children:[k,C,P,D]}),e[35]=P,e[36]=D,e[37]=k,e[38]=C,e[39]=g):g=e[39];let A;e[40]!==g||e[41]!==N?(A=r.jsxs(nu,{children:[N,g]}),e[40]=g,e[41]=N,e[42]=A):A=e[42];let B;e[43]!==s||e[44]!==l||e[45]!==p||e[46]!==a||e[47]!==m||e[48]!==d?(B=s!=="delete"&&r.jsx("div",{className:"py-4",children:r.jsx(Ds,{value:l,onChange:ue=>a(ue.target.value),placeholder:d(s==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:ue=>{ue.key==="Enter"&&m()},ref:p})}),e[43]=s,e[44]=l,e[45]=p,e[46]=a,e[47]=m,e[48]=d,e[49]=B):B=e[49];let I;e[50]!==d?(I=d("filesView.dialog.cancel"),e[50]=d,e[51]=I):I=e[51];let L;e[52]!==c||e[53]!==u||e[54]!==I?(L=r.jsx(Se,{variant:"outline",onClick:u,disabled:c,children:I}),e[52]=c,e[53]=u,e[54]=I,e[55]=L):L=e[55];const T=s==="delete"?"destructive":"default";let $;e[56]!==m?($=()=>{m()},e[56]=m,e[57]=$):$=e[57];let W;e[58]!==s||e[59]!==l||e[60]!==c?(W=c||s!=="delete"&&!l.trim(),e[58]=s,e[59]=l,e[60]=c,e[61]=W):W=e[61];let U;e[62]!==s||e[63]!==c||e[64]!==d?(U=c?r.jsx(ee,{name:"loader-4",className:"size-4 animate-spin"}):d(s==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=s,e[63]=c,e[64]=d,e[65]=U):U=e[65];let q;e[66]!==T||e[67]!==$||e[68]!==W||e[69]!==U?(q=r.jsx(Se,{variant:T,onClick:$,disabled:W,children:U}),e[66]=T,e[67]=$,e[68]=W,e[69]=U,e[70]=q):q=e[70];let pe;e[71]!==L||e[72]!==q?(pe=r.jsxs(iu,{children:[L,q]}),e[71]=L,e[72]=q,e[73]=pe):pe=e[73];let be;e[74]!==p||e[75]!==A||e[76]!==B||e[77]!==pe?(be=r.jsxs(tu,{initialFocus:p,children:[A,B,pe]}),e[74]=p,e[75]=A,e[76]=B,e[77]=pe,e[78]=be):be=e[78];let ve;return e[79]!==b||e[80]!==h||e[81]!==be?(ve=r.jsx(eu,{open:b,onOpenChange:h,children:be}),e[79]=b,e[80]=h,e[81]=be,e[82]=ve):ve=e[82],ve},Ts=new Map,mx=100,Wc=n=>{const e=Fe.c(13);let s,t,l;e[0]!==n?({positionKey:t,onViewReady:s,...l}=n,e[0]=n,e[1]=s,e[2]=t,e[3]=l):(s=e[1],t=e[2],l=e[3]);const a=o.useRef(null);let c,m;e[4]!==t?(c=()=>()=>{const d=a.current;if(!d)return;const{anchor:b,head:h}=d.state.selection.main;if(Ts.delete(t),Ts.set(t,{scroll:d.scrollSnapshot(),anchor:b,head:h}),Ts.size>mx){const y=Ts.keys().next().value;y!==void 0&&Ts.delete(y)}},m=[t],e[4]=t,e[5]=c,e[6]=m):(c=e[5],m=e[6]),o.useLayoutEffect(c,m);let u;e[7]!==s||e[8]!==t?(u=d=>{a.current=d;const b=Ts.get(t);b&&d.dispatch({selection:{anchor:Math.min(b.anchor,d.state.doc.length),head:Math.min(b.head,d.state.doc.length)},effects:b.scroll}),s?.(d)},e[7]=s,e[8]=t,e[9]=u):u=e[9];let p;return e[10]!==l||e[11]!==u?(p=r.jsx(Fm,{...l,onViewReady:u}),e[10]=l,e[11]=u,e[12]=p):p=e[12],p},hx=({mode:n="full",visible:e=!0,onCloseFile:s})=>{const{t}=De(),l=Af(),{files:a,runtime:c,git:m}=Vf(),{currentTheme:u,availableThemes:p,lightThemeId:d,darkThemeId:b}=Lf(),{isMobile:h,isTablet:y,screenWidth:E}=Of(),F=bm(c.platform),M=h||y,N=vm(),k=mu(),C=Bm(),P=Uc()??"",D=If(zf(),P)??"",g=ke(D.trim()),A=ke(P.trim()),B=h||n==="full",I=B&&e,L=ro(i=>i.runtimeKey),T=JSON.stringify([L,g]),$=o.useRef(T);$.current=T;const W=JSON.stringify([L,g,N,k]),U=o.useRef(W);U.current=W;const q=n!=="editor-only",pe=n==="editor-only"&&!h,be=ym(i=>i.searchFiles),ve=$f(I?D:null),[ue,Ce]=o.useState(""),Me=Bf(ue,200),R=o.useRef(null),[K,G]=o.useState(!1),te=nt(i=>i.fileEditorWrapLines),Le=nt(i=>i.setFileEditorWrapLines),[J,qe]=o.useState(!1),Xe=o.useCallback(i=>{if(!bi.current){qe(i);return}const f=at.current;if(Bs.current){Qo.current?.().then(w=>{w&&at.current===f&&qe(i)});return}Promise.resolve(us.current?.getContent("handoff")??uo).then(w=>{if(at.current===f){if(!w.ok){re.error(w.message);return}w.snapshot&&"content"in w.snapshot&&(We(w.snapshot.content),Jt(!1)),qe(i)}})},[]),[z,X]=o.useState(!1),ne=o.useRef(0),Y=o.useCallback(i=>{ne.current=Math.max(0,ne.current+(i?1:-1))},[]),[se,xe]=o.useState("edit"),[_e,jn]=o.useState("edit"),[de,Ke]=o.useState("tree"),[Oe,Ye]=o.useState("edit"),[oe,Ze]=o.useState("preview"),[Je,Re]=o.useState("preview"),[ot,zt]=o.useState("preview"),[Nt,bt]=o.useState("preview"),[et,Ft]=o.useState("table"),[H,mt]=o.useState(null),[Ie,mn]=o.useState(0),[me,ze]=o.useState(0),Rt=o.useRef({}),Bn=o.useRef({}),Kt=o.useRef({}),ns=o.useRef({}),$t=o.useRef({}),hn=o.useRef({}),ht=o.useRef({}),vt=o.useRef({}),br=o.useMemo(()=>p.find(i=>i.metadata.id===d)??_l(!1),[p,d]),gi=o.useMemo(()=>p.find(i=>i.metadata.id===b)??_l(!0),[p,b]),Gt=o.useMemo(()=>[],[]),$e=kt(i=>g?i.byRoot[g]?.openPaths??Gt:Gt),pn=kt(i=>g?i.byRoot[g]?.selectedPath??null:null),Tt=kt(i=>g?i.byRoot[g]?.expandedPaths??Gt:Gt),vr=o.useMemo(()=>new Set(Tt),[Tt]),ss=kt(i=>i.removeOpenPath),As=kt(i=>i.removeOpenPathsByPrefix),rs=kt(i=>i.removeUnselectedOpenPath),is=kt(i=>i.removeExpandedPathsByPrefix),yt=kt(i=>i.setSelectedPath),yr=kt(i=>i.toggleExpandedPath),os=kt(i=>i.expandPaths),kn=o.useCallback(i=>{const f=ke(i),w=f.split("/"),S=w[w.length-1]||f,j=S.includes(".")?S.split(".").pop()?.toLowerCase():void 0;return{name:S,path:f,type:"file",extension:j}},[]),Bt=o.useMemo(()=>$e.map(kn),[$e,kn]),_n=o.useMemo(()=>_f($e.map(i=>On(g,i))),[$e,g]),as=i=>_n.get(On(g,i)),Wn=o.useMemo(()=>{if(pn){const i=Ms(pn);if($e.some(f=>Ms(f)===i))return pn}return $e[0]??null},[$e,pn]),v=o.useMemo(()=>Wn?kn(Wn):null,[Wn,kn]),Ae=v?.path??"",at=o.useRef(Ae);at.current=Ae,o.useEffect(()=>{if(!g||!pn)return;const i=Ms(pn);$e.some(w=>Ms(w)===i)||yt(g,$e[0]??null)},[$e,g,pn,yt]);const En=!!(g&&Ae&&!Ps(Ae,g)),qt=o.useMemo(()=>({allowOutsideWorkspace:En,directory:g||void 0}),[En,g]),St=o.useCallback(i=>({allowOutsideWorkspace:!!(g&&!Ps(i,g))}),[g]),Vs=o.useRef(null),[Sr,Cr]=o.useState({start:!1,end:!1}),jr=o.useCallback(()=>{const i=Vs.current;if(!i)return;const f=Math.abs(i.scrollLeft);Cr({start:f>2,end:f+i.clientWidth<i.scrollWidth-2})},[]),Ls=o.useRef(jr);Ls.current=jr,o.useEffect(()=>{const i=Vs.current;if(!i)return;const f=()=>Ls.current();f(),i.addEventListener("scroll",f,{passive:!0});const w=new ResizeObserver(f);return w.observe(i),()=>{i.removeEventListener("scroll",f),w.disconnect()}},[Bt.length]);const[Nn,ls]=o.useState({}),[Un,_t]=o.useState({}),pt=o.useRef(new Set),tt=o.useMemo(()=>new vh,[]);o.useEffect(()=>()=>tt.clear(),[tt]);const[x,V]=o.useState([]),[Q,ge]=o.useState(!1),[_,le]=o.useState(""),{isPlaying:Ee,play:fe,stop:Fn}=Wf(),[Be,Vt]=o.useState(!1),[lt,Pe]=o.useState(null),[$u,gn]=o.useState(""),[Te,Qe]=o.useState(null),qo=o.useRef(Te);qo.current=Te;const Xt=o.useRef(null),[wi,Xo]=o.useState(null),Os=wi&&wi.path===Te?wi.documentPath:Te,[wn,Is]=o.useState(null),kr=o.useRef(null),Rn=JSON.stringify([Ht(),g,Os]),[ye,We]=o.useState(""),[cs,xi]=o.useState(!1),[Yo,Bu]=o.useState(`
|
|
79
79
|
`),_u=o.useRef(null),Yt=o.useRef(null),Mt=o.useRef(null),Tn=o.useRef(""),zs=o.useRef(""),xn=o.useRef(null),Hn=o.useRef(null),Jo=o.useRef(null),us=o.useRef(null),[$s,Jt]=o.useState(!1),bi=o.useRef(!1);bi.current=$s;const Bs=o.useRef(!1),Qo=o.useRef(null),gt=o.useRef(null),vi=o.useRef(""),yi=o.useRef(0),ds=o.useRef(0),Kn=o.useRef(null),[Qt,Er]=o.useState(0),[Wu,fs]=o.useState("idle"),[Uu,Nr]=o.useState(!1),[Hu,Zo]=o.useState(!1),[Mn,Si]=o.useState(!1),Zt=nt(i=>i.autoSaveEnabled),Fr=nt(i=>i.shortcutOverrides),Ku=nt(i=>i.setAutoSaveEnabled),[Ci,_s]=o.useState(!1),ms=o.useRef(null),Ws=o.useRef(null),Us=o.useRef(!1),Hs=o.useRef(null),Ks=o.useRef(null),ct=o.useRef(null),Gs=o.useRef(null),ea=o.useRef(null),ta=o.useRef(0),[Gu,ji]=o.useState(0),hs=o.useRef(null),bn=o.useRef({key:"",attempts:0,targetShown:!1});o.useEffect(()=>()=>{hs.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(hs.current),hs.current=null)},[]);const[Gn,ki]=o.useState(null),[qn,qu]=o.useState(null),[Pn,na]=o.useState(""),[Xu,Ei]=o.useState(!1),[Yu,Ju]=o.useState(null),[Qu,Zu]=o.useState(null),[ed,sa]=o.useState(!1),[Ni,ra]=o.useState(!1),[ia,Rr]=o.useState(!1),[Fi,qs]=o.useState(!1),[Tr,Xs]=o.useState(!1),[oa,aa]=o.useState(0),Ys=o.useRef(null),Mr=o.useCallback(i=>{const f=i?.currentTarget??Ys.current;if(!f)return;const w=document.activeElement;w&&w!==document.body&&w!==f&&(Zc(w)||f.contains(w))||f.focus({preventScroll:!0})},[]),Js=o.useRef(null),la=!!a.writeFile,ca=!!a.createDirectory,ua=!!a.rename,da=!!a.delete,fa=!!a.revealPath,ma=oi(i=>i.availableApps),td=oi(i=>i.isCacheStale),ha=oi(i=>i.initialize),nd=oi(i=>i.loadInstalledApps);o.useEffect(()=>{ha()},[ha]);const sd=o.useCallback(i=>{a.revealPath&&a.revealPath(i).catch(()=>{re.error(t("sidebarFilesTree.toast.revealFailed"))})},[a,t]),rd=o.useCallback(async i=>{if(!v?.path||await Sm(v.path,i.id,i.appName)||await fr(v.path,i.appName))return;const S=zc(v.path)||g;S&&await fr(S,i.appName)||re.error(t("filesView.toast.openInAppFailed",{app:i.appName}))},[g,v?.path,t]),Ri=o.useCallback((i,f)=>{ki(i),qu(f),na(i==="rename"&&f.name||""),Ei(!1)},[]),[ut,Xn]=o.useState(null),en=nt(i=>i.pendingFileNavigation),Pr=nt(i=>i.setPendingFileNavigation),Ti=nt(i=>i.pendingFileFocusPath),Mi=nt(i=>i.setPendingFileFocusPath),ps=nt(i=>i.fileEditorKeymap),pa=nt(i=>i.fileEditorVimMappings);o.useEffect(()=>{ps==="vim"&&Nm(pa)},[ps,pa]);const Qs=Wl(i=>i.settingsDefaultFileViewerPreview),id=Wl(i=>i.showMessageTTSButtons);o.useEffect(()=>()=>{Hs.current!==null&&window.clearTimeout(Hs.current),Ks.current!==null&&window.clearTimeout(Ks.current)},[]);const od=o.useCallback((i,f)=>{const w=i.split(`
|
|
80
80
|
`),S=Math.max(1,f.start),j=Math.min(w.length,f.end);return S>j?"":w.slice(S-1,j).join(`
|
|
81
|
-
`)},[]),ga=o.useRef(null),ad=Ah({source:"file",fileLabel:v?.path??null,language:v?.path&&io(v.path)||"text",getCodeForRange:i=>od(_,Vh(i)),toStoreRange:i=>({startLine:i.start,endLine:i.end}),fromDraftRange:i=>({start:i.startLine,end:i.endLine})}),{drafts:wa,commentText:Dr,setCommentText:xa,editingDraftId:Ar,setSelection:ba,saveComment:va,cancel:Zs,reset:ya,startEdit:Sa,deleteDraft:Ca}=ad,ja=o.useMemo(()=>wa.filter(i=>!Uf(i)),[wa]),gs=Wh({fileLabel:v?.path??"",source:"file"}),{isDragging:ka,lineNumbersConfig:ld,isDragReleaseClick:Ea}=qm({lineSelection:ut,setLineSelection:Xn,onClear:Zs,isMobile:h});o.useEffect(()=>{Xt.current?.to!==v?.path&&(Xn(null),ya(),We(""),xi(!1))},[v?.path,ya]),o.useEffect(()=>{ba(ut)},[ut,ba]),o.useEffect(()=>{if(!ut&&!Ar)return;const i=w=>{if(Ea())return;const S=w.target;S.closest('[data-comment-input="true"]')||S.closest('[data-comment-card="true"]')||S.closest(".cm-gutterElement")||S.closest("[data-sonner-toast]")||S.closest("[data-sonner-toaster]")||Dr.trim()||(Xn(null),Zs())},f=setTimeout(()=>{document.addEventListener("click",i)},100);return()=>{clearTimeout(f),document.removeEventListener("click",i)}},[Zs,Dr,Ar,Ea,ut]),o.useEffect(()=>{if(!h||!ut)return;const i=ct.current;if(!i)return;const f=i.state.selection.main;f.empty||i.dispatch({selection:{anchor:f.head}});const w=document.getSelection();w&&!w.isCollapsed&&w.anchorNode&&i.contentDOM.contains(w.anchorNode)&&w.removeAllRanges()},[h,ut]);const Na=o.useCallback((i,f)=>{const w=f??ut??void 0;f&&Xn(f);const S=va(i,w);return S&&Xn(null),S},[ut,va]),Vr=o.useCallback((i,f)=>{const w=[];for(const S of f){if(!(S&&typeof S.name=="string"&&S.name.length>0)||!N&&S.name.startsWith(".")||!k&&ox(S.name))continue;const j=S.name,O=ke(S.path||""),Z=O?rx(O)?O:ke(`${i}/${O}`):ke(`${i}/${j}`),we=S.isDirectory?"directory":"file",Ne=we==="file"&&j.includes(".")?j.split(".").pop()?.toLowerCase():void 0;w.push({name:j,path:Z,type:we,extension:Ne})}return sx(w)},[k,N]),Ct=o.useCallback(async(i,f=!1)=>{if(!I)return;const w=ke(i.trim());if(!w||!f&&pt.current.has(w))return;const S=U.current,j=Ht();return tt.run(w,async O=>{const Z=()=>O()&&U.current===S&&Ht()===j;try{const we=!k,Ne=a.listDirectory?(await a.listDirectory(w,{respectGitignore:we})).entries:await Ql.listLocalDirectory(w,{respectGitignore:we});if(!Z())return;const he=Vr(w,Ne);pt.current=new Set(pt.current),pt.current.add(w),_t(ae=>{if(!ae[w])return ae;const Ue={...ae};return delete Ue[w],Ue}),ls(ae=>ae[w]&&yh(ae[w],he)?ae:{...ae,[w]:he})}catch(we){if(!Z())return;const Ne=we instanceof Error?we.message:String(we??"");if(Ne==="Directory not found"&&g&&w!==g){is(g,w),_t(he=>{if(!he[w])return he;const ae={...he};return delete ae[w],ae});return}console.error("Failed to load files directory:",we),_t(he=>({...he,[w]:Ne}))}},f)},[tt,a,Vr,is,g,k,I]),Lr=o.useCallback(async()=>{g&&(pt.current=new Set,tt.clear(),_t({}),ls(i=>Object.keys(i).length===0?i:{}),await Ct(g))},[tt,Ct,g]),Pt=o.useCallback(async i=>{if(!i){await Lr();return}const f=ke(i);pt.current=new Set(pt.current),pt.current.delete(f),await Ct(f,!0)},[Ct,Lr]),{canUpload:Fa,uploadingDirectory:cd,pickFiles:Ra,uploadElements:ud}=_m({root:g,refreshDirectory:Pt}),Or=cd!==null,Ta=o.useRef(""),Ma=o.useRef("");o.useEffect(()=>{if(!g)return;const i=W,f=Ta.current!==T,w=Ma.current!==i;!f&&!w||(f&&(Ta.current=T,ds.current+=1,Kn.current=null,le(""),Pe(null),gn(""),Qe(null),G(!1)),w&&(Ma.current=i,pt.current=new Set,tt.clear(),_t({}),ls(S=>Object.keys(S).length===0?S:{}),Ct(g)))},[tt,T,Ct,g,W]),o.useEffect(()=>{if(!I||!a.listDirectory)return;const i=()=>{if(!document.hidden&&Tt.length>0)for(const f of Tt)tt.has(f)||Pt(f)};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[tt,Tt,a.listDirectory,Pt,I]);const Pa=o.useRef(!1);o.useEffect(()=>{const i=I&&!Pa.current;if(Pa.current=I,!(!I||!g)&&(Ct(g),i))for(const f of Tt)tt.has(f)||Pt(f)},[tt,Tt,Ct,Pt,g,I]),o.useEffect(()=>{if(!I||!a.listDirectory||Tt.length===0)return;const i=setInterval(()=>{if(!document.hidden)for(const f of Tt)tt.has(f)||Pt(f)},8e3);return()=>clearInterval(i)},[tt,Tt,a.listDirectory,Pt,I]);const dd=o.useCallback(async i=>{if(i?.preventDefault(),!qn||!Gn)return;Ei(!0);const f=()=>{ki(null)},w=j=>{re.error(j)},S=()=>{Ei(!1)};if(Gn==="createFile"){if(!Pn.trim()){w(t("sidebarFilesTree.toast.filenameRequired")),S();return}if(!a.writeFile){w(t("sidebarFilesTree.toast.writeNotSupported")),S();return}const j=qn.path,O=j?`${j}/`:"",Z=ke(`${O}${Pn.trim()}`);await a.writeFile(Z,"").then(async we=>{we.success&&(re.success(t("sidebarFilesTree.toast.fileCreated")),await Pt(j)),f()}).catch(()=>w(t("sidebarFilesTree.toast.operationFailed"))).finally(S);return}if(Gn==="createFolder"){if(!Pn.trim()){w(t("sidebarFilesTree.toast.folderNameRequired")),S();return}const j=qn.path,O=j?`${j}/`:"",Z=ke(`${O}${Pn.trim()}`);await a.createDirectory(Z).then(async we=>{we.success&&(re.success(t("sidebarFilesTree.toast.folderCreated")),await Pt(j)),f()}).catch(()=>w(t("sidebarFilesTree.toast.operationFailed"))).finally(S);return}if(Gn==="rename"){if(!Pn.trim()){w(t("sidebarFilesTree.toast.nameRequired")),S();return}if(!a.rename){w(t("sidebarFilesTree.toast.renameNotSupported")),S();return}const j=qn.path,O=j.split("/").slice(0,-1).join("/"),Z=O?`${O}/`:"",we=Pn.trim(),Ne=ke(`${Z}${we}`);try{const he=await Sh(a,{tabs:A,files:g},j,Ne);he==="moved"?(re.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await Pt(O),f()):w(he==="conflict"?t("sidebarFilesTree.toast.nameTaken",{name:we,folder:On(g,O)||t("sidebarFilesTree.dialog.rootFallback")}):t("sidebarFilesTree.toast.operationFailed"))}catch{w(t("sidebarFilesTree.toast.operationFailed"))}finally{S()}return}if(Gn==="delete"){if(!a.delete){w(t("sidebarFilesTree.toast.deleteNotSupported")),S();return}const j=qn.path,O=j.split("/").slice(0,-1).join("/");await a.delete(j).then(async Z=>{Z.success&&(re.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await Pt(O),g&&As(g,j),(v?.path===j||v?.path.startsWith(`${j}/`))&&(g&&yt(g,null),le(""),Pe(null),gn(""),Qe(null),h&&G(!1))),f()}).catch(()=>w(t("sidebarFilesTree.toast.operationFailed"))).finally(S);return}S()},[Gn,qn,Pn,a,A,Pt,h,As,g,v?.path,yt,t]);o.useEffect(()=>{if(!D){V([]),ge(!1);return}const i=Me.trim();if(!i){V([]),ge(!1);return}let f=!1;return ge(!0),be(D,i,150,{includeHidden:N,respectGitignore:!k,type:"file"}).then(w=>{if(f)return;const j=w.filter(O=>k||!ax(O.path)).map(O=>({name:O.name,path:ke(O.path),type:"file",extension:O.extension,relativePath:O.relativePath}));V(j)}).catch(()=>{f||V([])}).finally(()=>{f||ge(!1)}),()=>{f=!0}},[D,Me,be,N,k]);const Ir=o.useCallback(async(i,f)=>{const w=St(i);if(a.readFile)return(await a.readFile(i,{...w,directory:g||void 0,...f})).content??"";const S=new URLSearchParams({path:i});w.allowOutsideWorkspace&&S.set("allowOutsideWorkspace","true"),g&&S.set("directory",g);const j=await pr(`/api/fs/read?${S.toString()}`,{cache:f?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!j.ok){const O=await j.json().catch(()=>({error:j.statusText}));throw new Error(O.error||t("filesView.error.readFileFailed"))}return j.text()},[a,St,g,t]),Lt=o.useCallback(async i=>{if(a.statFile){const f=St(i),w=await a.statFile(i,{...f,directory:g||void 0});return up(ke(i),w)}return null},[a,St,g]);o.useEffect(()=>{if(!g||!a.statFile||$e.length===0)return;let i=!1;const f=[...$e];return Promise.all(f.map(async w=>{try{const S=St(w),j=await a.statFile?.(w,{...S,directory:g||void 0});!i&&j&&!j.isFile&&rs(g,w)}catch(S){!i&&Zl(S)&&rs(g,w)}})),()=>{i=!0}},[a,$e,rs,St,g]);const Dt=ye!==_||$s,Dn=o.useCallback((i,f=!0)=>{const{content:w,lineEnding:S}=vp(i);return f&&vo(at.current)&&ze(j=>j+1),vi.current=i,yi.current+=1,Er(j=>j+1),Bu(S),le(w),Tn.current=w,zs.current=w,We(w),w},[]),vn=o.useCallback(async()=>{if(!v||!a.writeFile)return re.error(t("filesView.toast.savingNotSupported")),!1;const i=(ar(v.path)||Mn)&&!Bs.current;if(!xp({selectedFilePath:v.path,loadedFilePath:Te,fileLoading:Be,isDirty:Dt,draftContent:ye,fileContent:_,isNonEditableBinary:i}))return i?console.warn(`[saveDraft] refusing to save binary file "${v.path}".`):ye===""&&_!==""&&Te!==v.path&&console.warn(`[saveDraft] refusing to save empty draft for "${v.path}" (${_.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Dt)return!0;if(Xt.current||ao(v.path))return!1;xi(!0);try{const f=$s?us.current:null;$s&&!f&&Jt(!1);const w=f?await f.getContent("save"):uo;if(!w.ok)return re.error(w.message),!1;const S=w.snapshot;if(S&&"bytes"in S){if(!a.uploadFile)return re.error(t("filesView.toast.savingNotSupported")),!1;if(gt.current=null,!(await a.uploadFile(v.path,new Blob([S.bytes]),{overwrite:!0}))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;us.current?.markSaved(S.signature)}else{const j=yp(S?S.content:ye,Yo);if(!(await a.writeFile(v.path,j))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;S?(Dn(j,!1),us.current?.markSaved(S.signature)):(le(ye),vi.current=j,yi.current+=1)}if(g&&Ps(v.path,g)){const j=On(g,v.path);j&&Ul.requestGitRefresh({directory:g,paths:[j]})}if(g&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(ke(v.path))){const j=Hf.getState().projects.find(O=>ke(O.path)===ke(g));if(j)try{await Kh(j.id)}catch{re.error(t("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return v?.path&&lr(v.path)&&(Tn.current=ye,zs.current=ye),Lt(v.path).then(j=>{j&&(gt.current=j)}).catch(()=>{}),!0}catch(f){return re.error(f instanceof Error?f.message:t("filesView.toast.saveFailed")),!1}finally{xi(!1)}},[Dn,Mn,ye,$s,_,Be,a,Dt,Yo,Te,Lt,g,v,t]);Qo.current=vn,o.useEffect(()=>{Zt||(fs("idle"),Yt.current&&(clearTimeout(Yt.current),Yt.current=null))},[Zt]);const zr=1500;o.useEffect(()=>{const i=!!(v&&a.writeFile),f=!!(v?.path&&(ar(v.path)||Mn))&&!Bs.current;if(!wp({autoSaveEnabled:Zt,isDirty:Dt,canWrite:i,isSaving:cs,fileLoading:Be,selectedFilePath:v?.path,loadedFilePath:Te,isNonEditableBinary:f,wouldEmptyFile:ye===""&&_!==""}))return;const w=S=>{Yt.current=setTimeout(()=>{const j=Date.now()-ta.current;if(j<zr){w(zr-j);return}vn().then(O=>{O&&(fs("saved"),setTimeout(()=>fs("idle"),2e3))})},S)};return w(zr),()=>{Yt.current&&(clearTimeout(Yt.current),Yt.current=null)}},[Zt,Mn,ye,_,Be,Dt,Te,v,a.writeFile,cs,vn]),o.useEffect(()=>{fs("idle")},[v?.path]);const Da=o.useCallback(()=>{Yt.current&&(clearTimeout(Yt.current),Yt.current=null),cs||vn().then(i=>{i&&(fs("saved"),setTimeout(()=>fs("idle"),2e3))})},[cs,vn]);Kf({save_file:i=>{if(!(i.target instanceof Node)||!Gs.current?.contains(i.target)&&!ea.current?.contains(i.target))return!1;Da()},find_in_file:i=>{if(!(i.target instanceof Node))return!1;if(ft&&js()==="preview"){if(h||!(J?Js.current:Ys.current)?.contains(i.target))return!1;Xs(!0),aa(w=>w+1);return}if(!Gs.current?.contains(i.target))return!1;X(!0)}});const Aa=o.useCallback(async i=>{const f=ds.current+1;ds.current=f;const w=Ht(),S=$.current,j=()=>{if(!g||Ht()!==w||$.current!==S)return!1;const ae=kt.getState().byRoot[g],Ue=ae?.selectedPath??ae?.openPaths[0]??null;return ds.current===f&&Ue===i.path};Xt.current=null,Xo(null),Pe(null),Is(null),kr.current=null,gn(""),Qe(null),Si(!1),Vt(!0);const O=mr(i.path),Z=oo(i.path),we=Hl(i.path),Ne=ar(i.path);if(h&&G(!0),c.isDesktop&&O&&!Z){le(""),We("");return}if(!c.isDesktop&&O&&!Z){le(""),We(""),Qe(i.path),Vt(!1);return}if(we){le(""),We(""),Qe(i.path),Vt(!1);return}if(Ne){le(""),We(""),Qe(i.path),Vt(!1);return}const he=await Lt(i.path).catch(()=>null);if(j()){if(he&&he.size>Mo&&cr(i.path)){Si(!0),le(""),We(""),Qe(i.path),Vt(!1);return}if(he&&he.size>Mo){le(""),We(""),Pe(oh(he.size,t)),Is(i.path),gt.current=null,Vt(!1);return}await Ir(i.path).then(ae=>{if(!j())return;if(Co(ae)){Si(!0),le(""),We(""),Qe(i.path);return}const Ue=Dn(ae),He=bo(i.path)||yo(i.path)||_c(i.path)||lr(i.path)||oo(i.path)||Kl(i.path)||cr(i.path)||vo(i.path);xe(He?"edit":Sp(Ue,Rt.current[i.path])),Qe(i.path),Lt(i.path).then(je=>{je&&j()&&(gt.current=je)}).catch(()=>{})}).catch(ae=>{if(j()){if(lx(ae)){if(Vt(!1),g&&yt(g,null),Pe(null),le(""),We(""),Qe(null),gt.current=null,ue.trim().length>0&&Ce(""),h&&G(!1),g){const He=[...$c(i.path,g),i.path];He.length>0&&os(g,He);for(const je of He)pt.current.has(je)||Ct(je)}return}le(""),We(""),Pe(ae instanceof Error?ae.message:t("filesView.error.readFileFailed")),Is(i.path),gt.current=null}}).finally(()=>{j()&&Vt(!1)})}},[Dn,os,h,Ct,Ir,Lt,g,c.isDesktop,ue,yt,t]),$r=o.useCallback(async(i,f)=>{if(!e||!g)return;const w=$c(i,g),S=f?[...w,i]:w;if(S.length>0&&os(g,S),!I)return;const j=S.map(O=>{if(!pt.current.has(O))return Ct(O)}).filter(Boolean);await Promise.all(j)},[os,Ct,g,I,e]),Va=o.useCallback((i,f)=>{const w=f.findIndex(S=>S.path===i);return w===-1||f.length<=1?null:f[w+1]??f[w-1]??null},[]),Ot=o.useCallback(async i=>{if(Us.current)Us.current=!1;else if(Dt){_s(!0),ms.current=i;return}g&&(yt(g,i.path),$r(i.path,!1)),Pe(null),gn(""),le(""),Tn.current="",zs.current="",Jt(!1),We(""),Qe(null),h&&G(!0)},[$r,Dt,h,g,yt]);o.useEffect(()=>{v?.path&&$r(v.path,!1)},[$r,v?.path]),o.useEffect(()=>Cm(({runtimeKey:i,from:f,to:w})=>{if(i!==Ht())return;Rt.current=Vn(Rt.current,f,w),Bn.current=Vn(Bn.current,f,w),Kt.current=Vn(Kt.current,f,w),ns.current=Vn(ns.current,f,w),$t.current=Vn($t.current,f,w),hn.current=Vn(hn.current,f,w),ht.current=Vn(ht.current,f,w),vt.current=Vn(vt.current,f,w);const S=Xt.current,j=S?.to??qo.current,O=j?Em(j,f,w):null;j&&O&&(Xt.current={from:S?.from??j,to:O})}),[]),o.useEffect(()=>{const i=Xt.current;if(i&&v?.path===i.to){if(Xt.current=null,Te===i.from){Xo({path:i.to,documentPath:Os??i.from}),Qe(i.to);return}}else i&&Te!==i.from&&(Xt.current=null);if(!e)return;if(!v){ds.current+=1,Kn.current=null,Vt(!1);return}if(Te===v.path||Kn.current===v.path)return;const f=v.path;Kn.current=f,Aa(v).finally(()=>{Kn.current===f&&(Kn.current=null)})},[Os,Qt,Aa,Te,v,e]);const Br=o.useRef(Dt);Br.current=Dt;const _r=o.useCallback(()=>{ds.current+=1,Kn.current=null,gt.current=null,gn(""),Pe(null),Qe(null),Er(i=>i+1)},[]);o.useEffect(()=>Wm(({runtimeKey:i,paths:f})=>{const w=v?.path;i!==Ht()||!w||Br.current||!f.includes(ke(w))||_r()}),[_r,v?.path]),o.useEffect(()=>{if(!e||!v?.path||Te!==v.path&&wn!==v.path)return;const i=v.path,f=wn===i,w=Ht(),S=$.current,j=()=>Br.current||lr(i)&&Tn.current!==zs.current,O=!ar(i)&&!mr(i)&&!Mn?Xm({readContent:()=>Ir(i,{fresh:!0}),getLoadedContent:()=>vi.current,getLoadedRevision:()=>yi.current,isDirty:j,applyContent:je=>{if(!(Z||Ht()!==w||$.current!==S)){if(Co(je)){Qe(null);return}Dn(je)}}}):null;let Z=!1,we=!1,Ne=!1;const he=()=>{if(!document.hidden){if(we){Ne=!0;return}we=!0,Lt(i).then(async je=>{if(Z||Ht()!==w||$.current!==S||!je)return;const ts=kr.current===i,Ve=mc({stat:"found",showsFailure:f,sawMissing:ts,hasUnsavedChanges:j(),moving:!1});if(Ve==="reload"){gt.current=null,Qe(null),Er(on=>on+1);return}if(Ve!=="check-changes")return;const xt=gt.current;if(!xt||xt.path!==i){gt.current=je;return}if(fp(xt,je)){if(O&&je.size<=cx){await O.poll()&&!Z&&(gt.current=je);return}Br.current||(gt.current=je,Qe(null),Er(on=>on+1))}}).catch(je=>{if(Z||Ht()!==w||$.current!==S)return;const ts=Zl(je)?"missing":"failed",Ve=kr.current===i,xt=ao(i)||Xt.current!==null;mc({stat:ts,showsFailure:f,sawMissing:Ve,hasUnsavedChanges:j(),moving:xt})==="show-missing"&&(kr.current=i,gt.current=null,le(""),We(""),Pe(je instanceof Error?je.message:t("filesView.error.readFileFailed")),Is(i))}).finally(()=>{we=!1,Ne&&!Z&&(Ne=!1,he())})}};he();let ae=window.setInterval(he,2e3);const Ue=g?Gf(g,i,he):null;Ue?.watching.then(je=>{!je||Z||(window.clearInterval(ae),ae=window.setInterval(he,ux))});const He=()=>{document.hidden||he()};return document.addEventListener("visibilitychange",He),()=>{Z=!0,O?.dispose(),window.clearInterval(ae),Ue?.stop(),document.removeEventListener("visibilitychange",He)}},[Dn,Mn,wn,Te,Ir,Lt,g,v?.path,t,e]);const ws=o.useCallback((i,f)=>{if(s){s(i);return}if(g&&ss(g,i),v?.path===i){if(f){Ot(f);return}g&&yt(g,null),le(""),Pe(null),gn(""),Qe(null),h&&G(!1)}},[Ot,h,s,ss,g,v?.path,yt]),fd=o.useCallback(()=>{const i=ms.current,f=Ws.current;if(ms.current=null,Ws.current=null,Us.current=!0,_s(!1),Jt(!1),ze(w=>w+1),We(_),f){ws(f,i);return}if(i){Ot(i);return}},[ws,_,Ot]),md=o.useCallback(async()=>{const i=ms.current,f=Ws.current;if(!await vn()){Us.current=!1;return}if(ms.current=null,Ws.current=null,Us.current=!0,_s(!1),f){ws(f,i);return}if(i){await Ot(i);return}},[ws,Ot,vn]),er=o.useCallback(i=>{const f=v?.path===i,w=Va(i,Bt);if(f&&Dt){_s(!0),ms.current=w,Ws.current=i;return}ws(i,w)},[ws,Va,Dt,Bt,v?.path]),La=o.useRef(er);o.useEffect(()=>{La.current=er},[er]);const Pi=v?.path??null,Oa=o.useRef(null);o.useEffect(()=>{if(!(!e||!Pi))return Um(()=>La.current(Pi),Oa)},[Pi,e]);const hd=o.useMemo(()=>new Set($e),[$e]),Wr=o.useMemo(()=>Ch(B?ve?.files??[]:[]),[ve?.files,B]),pd=o.useCallback(i=>{const f=i.startsWith(g+"/")?i.slice(g.length+1):i;return Wr.statusByPath.get(f)??null},[Wr,g]),gd=o.useCallback(i=>{if(!ve?.files)return null;const f=i.startsWith(g+"/")?i.slice(g.length+1):i;return Wr.badgeByDir.get(f)??null},[ve,Wr,g]),Di=o.useRef(null),Ia=jh(Di),wd=o.useCallback(async i=>{const f=ke(i);if(!g)return;const w=kt.getState().byRoot[g]?.expandedPaths.includes(f)??!1;Ia(i,w,()=>yr(g,f)),pt.current.has(f)||await Ct(f)},[Ct,g,yr,Ia]),xd=o.useMemo(()=>({canRename:ua,canCreateFile:la,canCreateFolder:ca,canDelete:da,canReveal:fa}),[ua,la,ca,da,fa]);function za(i,f){return(Nn[i]??[]).map(S=>{const j=S.type==="directory",O=j&&vr.has(S.path),Z=v?.path===S.path;return r.jsxs("li",{children:[r.jsx(dx,{guestActions:l,node:S,root:g,isExpanded:O,isActive:Z,isMobile:h,isBrowserClient:F,alwaysShowActions:M,depth:f,isOpen:!j&&hd.has(S.path),status:j?void 0:pd(S.path),badge:j?gd(S.path):void 0,permissions:xd,downloadFile:a.downloadFile,contextMenuPath:Yu,setContextMenuPath:Ju,rightClickMenuPath:Qu,setRightClickMenuPath:Zu,onSelect:Ot,onToggle:wd,onRevealPath:sd,onOpenDialog:Ri,canUpload:Fa&&!Or,onPickFiles:Ra}),j&&O&&r.jsxs("ul",{className:"flex flex-col",children:[Un[S.path]?r.jsxs("li",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingLeft:fu(f+1)},"data-tree-disclosure-path":`${S.path}/`,children:[r.jsx(du,{depth:f+1}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:Un[S.path],children:Un[S.path]}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Pt(S.path)},children:[r.jsx(ee,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.retryFolder")})]})]}):null,za(S.path,f+1)]})]},S.path)})}const jt=!!(v?.path&&mr(v.path)),It=!!(v?.path&&oo(v.path)),Ai=It&&ot==="edit",An=!!(v?.path&&Hl(v.path)),$a=!!(v?.path&&qf(v.path)),Vi=$a||!!(v?.path&&Xf(v.path)),Li=!!(v?.path&&Yf(v.path)),Ur=!!(v?.path&&(ar(v.path)||Mn)),xs=Ur&&!jt&&!An&&!Vi&&!Li,bd=Ur||jt&&!Ai,tr=e&&v&&jt&&!Ai?zc(v.path):"",[Yn,vd]=o.useState(null),Ba=!!(tr&&Yn?.scope===W&&Yn.folder===tr),_a=!!(Ba&&Yn?.entries.some(i=>i.path===Ae)),Wa=!!tr&&!(Ba&&Yn?.readFor===Ae);o.useEffect(()=>{if(!Wa)return;let i=!1;const f=W,w=tr,S=Ae,j=!k;return(a.listDirectory?a.listDirectory(w,{respectGitignore:j}).then(Z=>Z.entries):Ql.listLocalDirectory(w,{respectGitignore:j})).then(Z=>{i||U.current!==f||vd({scope:f,folder:w,readFor:S,entries:Vr(w,Z)})}).catch(Z=>{i||console.warn("Failed to list the image folder:",Z)}),()=>{i=!0}},[a,tr,Wa,Vr,Ae,k,W]);const yd=o.useMemo(()=>{if(!_a||!Yn||!A)return null;const i=Kw(Yn.entries,Ae);if(!i)return null;const f=w=>({name:w.name,open:()=>nt.getState().openContextFile(A,w.path,{preview:!0})});return{previous:f(i.previous),next:f(i.next)}},[_a,Yn,A,Ae]),Ua=o.useMemo(()=>ke(en?.path??""),[en?.path]),bs=!!(en&&Ua&&Ae&&Ae===Ua&&!Be&&!lt&&!bd),Jn=o.useMemo(()=>On(g,Ae),[Ae,g]),Sd=!!(v&&(!jt||It)&&!An&&!xs&&_.length>0),Ha=!!(v&&Jn.length>0),dt=!!(v&&!En&&!Ur&&(!jt||It)&&a.writeFile),Qn=!!(v&&!Ur&&(!jt||It)),Oi=Rp(v?.path),wt=Oi&&(Qn||Oi.editor.content==="binary")?Oi:null,tn=wt!==null,Cd=Jf(),vs=wt?.editor.content==="binary";Bs.current=vs;const ft=!tn&&!!(v?.path&&bo(v.path)),ys=!tn&&!!(v?.path&&_c(v.path)),nn=!tn&&!!(v?.path&&yo(v.path)),sn=!tn&&!Cd&&!!(v?.path&&lr(v.path)),Ss=!tn&&!!(v?.path&&Kl(v.path)),nr=!tn&&!Mn&&!!(v?.path&&cr(v.path)),Hr=!tn&&!!(v?.path&&Qf(v.path)),sr=nr||Hr,Wt=tn,rr=tn&&(vs?H===null||H<=So:ye.length<=So),jd=$o(i=>i.status),kd=!tn&&Qn&&jd!=="unsupported"&&!!(v?.path&&Zf(v.path)),ir=Qn&&!ft&&!sn&&!Wt&&!(nn&&Oe==="preview")&&!(It&&ot==="preview")&&!(Ss&&Nt==="preview")&&!(sr&&et==="table"),Ed=ft&&_e==="edit"||nn&&Oe==="edit"||Wt&&(Je==="edit"||!rr)||It&&ot==="edit"||Ss&&Nt==="edit"||sr&&et==="text"||ys&&de==="text"||!ft&&!nn&&!ys&&!Wt&&!It&&!Ss&&!sr&&se==="edit";o.useEffect(()=>{const i=ct.current;if(!h||!z||!i)return;const f=uh(i.state);!f.caseSensitive&&!f.regexp&&!f.wholeWord||i.dispatch({effects:dh.of(new fh({search:f.search,replace:f.replace}))})},[h,z]);const Cs=(sn?oe!=="preview":Ed)&&!(ir&&se==="view");o.useEffect(()=>{Cs||(Rr(!1),qs(!1))},[Cs]);const Kr=o.useMemo(()=>Ae?em(Ae):null,[Ae]),[Ka,Ii]=o.useState(null);o.useEffect(()=>{let i=!1;const f=v?.path;if(!f||Kr){Ii(null);return}return Ii(null),tm(f).then(w=>{i||Ii(w)}),()=>{i=!0}},[v?.path,Kr]),o.useEffect(()=>{!dt&&se==="edit"&&xe("view")},[dt,se]);const zi="openchamber:files:md-viewer-mode",$i="openchamber:files:html-viewer-mode",Bi="openchamber:files:json-viewer-mode";o.useEffect(()=>{const i=v?.path;if(!i)return;xe(Rt.current[i]??"edit");let f=Qs?"preview":"edit";try{const j=localStorage.getItem(zi);(j==="preview"||j==="edit")&&(f=j)}catch{}jn(Bn.current[i]??f);let w=Qs?"preview":"edit";try{const j=localStorage.getItem($i);(j==="preview"||j==="edit")&&(w=j)}catch{}Ye(Kt.current[i]??w),Ze(ht.current[i]??(Qs?"preview":"edit")),Re(vt.current[i]??"preview"),zt(ns.current[i]??"preview"),bt($t.current[i]??"preview"),Ft(hn.current[i]??"table");let S=Qs?"tree":"text";try{const j=localStorage.getItem(Bi);(j==="tree"||j==="text")&&(S=j)}catch{}Ke(S)},[v?.path,Qs]);const Ga=o.useCallback(i=>{const f=v?.path;f&&(Rt.current[f]=i),xe(i)},[v?.path]),qa=o.useCallback(i=>{const f=v?.path;f&&(Bn.current[f]=i),jn(i);try{localStorage.setItem(zi,i)}catch{}},[v?.path]),js=o.useCallback(()=>_e,[_e]),Xa=o.useCallback(i=>{const f=v?.path;f&&(ns.current[f]=i),zt(i)},[v?.path]),Ya=o.useCallback(i=>{const f=v?.path;f&&($t.current[f]=i),bt(i)},[v?.path]),Ja=o.useCallback(i=>{const f=v?.path;f&&(hn.current[f]=i),Ft(i)},[v?.path]);o.useEffect(()=>{const i=v?.path;if(mt(null),!i||Te!==i)return;let f=!1;return Lt(i).then(w=>{!f&&w&&mt(w.size)}).catch(()=>{}),()=>{f=!0}},[Qt,Te,Lt,v?.path]);const Qa=v&&ft&&js()==="preview"&&!Be?v.path:null;o.useEffect(()=>{!Qa||h||Mr()},[Mr,J,h,Qa]);const Za=o.useCallback(i=>{Ke(i);try{localStorage.setItem(Bi,i)}catch{}},[]),_i=o.useCallback(i=>{const f=v?.path;f&&(Kt.current[f]=i),Ye(i);try{localStorage.setItem($i,i)}catch{}},[v?.path]),el=o.useCallback(i=>{const f=v?.path;if(f&&(ht.current[f]=i),Mt.current&&(clearTimeout(Mt.current),Mt.current=null),xn.current!==null&&(cancelAnimationFrame(xn.current),xn.current=null),i==="edit")We(Tn.current||_),Ze(i);else{Tn.current=ye;const w=f;Ze("edit"),xn.current=requestAnimationFrame(()=>{xn.current=requestAnimationFrame(()=>{xn.current=null,!(g&&w&&kt.getState().byRoot[g]?.selectedPath!==w)&&(mn(S=>S+1),Ze("preview"))})});return}},[ye,_,g,v?.path]),tl=o.useCallback(i=>{const f=v?.path,w=()=>{f&&(vt.current[f]=i)};if(i==="edit"){if(!bi.current){w(),Jt(!1),Re(i);return}Promise.resolve(us.current?.getContent("handoff")??uo).then(j=>{if(at.current===f){if(!j.ok){re.error(j.message);return}w(),We(j.snapshot&&"content"in j.snapshot?j.snapshot.content:_),Jt(!1),Re(i)}});return}if(!rr){wt&&re.error(t("filesView.fileEditor.tooLarge",{editor:wt.editor.title}));return}w(),Jt(!1);const S=f;Hn.current!==null&&cancelAnimationFrame(Hn.current),Hn.current=requestAnimationFrame(()=>{Hn.current=null,!(g&&S&&kt.getState().byRoot[g]?.selectedPath!==S)&&(ze(j=>j+1),Re("preview"))})},[rr,_,wt,g,v?.path,t]),Wi=o.useCallback(async(i,f)=>{if(!a.writeFile||f===zs.current||Xt.current||ao(i))return!1;if(!(await a.writeFile(i,f))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;Dn(f);const S=await Lt(i).catch(()=>null);return S&&(gt.current=S),!0},[Dn,a,Lt,t]);o.useEffect(()=>()=>{Mt.current&&(clearTimeout(Mt.current),Mt.current=null),xn.current!==null&&(cancelAnimationFrame(xn.current),xn.current=null)},[oe,v?.path]);const Nd=o.useCallback(i=>{if(Tn.current=i,!Zt||!v?.path||oe!=="preview"||!a.writeFile)return;Mt.current&&clearTimeout(Mt.current);const f=v.path;Mt.current=setTimeout(()=>{Mt.current=null,Wi(f,i).then(w=>{w&&(Nr(!0),setTimeout(()=>Nr(!1),1500))}).catch(w=>{re.error(w instanceof Error?w.message:t("filesView.toast.saveFailed"))})},zr)},[Zt,oe,a.writeFile,Wi,v?.path,t]),Fd=o.useMemo(()=>sn&&(Tn.current||ye)||_,[ye,_,sn]),Rd=o.useCallback(()=>{const i=at.current;i&&(vt.current[i]="edit"),Jt(!1),Re("edit"),wt&&re.error(t("filesView.fileEditor.unsupported",{editor:wt.editor.title}))},[wt,t]);o.useEffect(()=>()=>{Hn.current!==null&&(cancelAnimationFrame(Hn.current),Hn.current=null)},[Je,v?.path]);const Td=o.useCallback(()=>Oe,[Oe]);o.useEffect(()=>{const i=w=>{const S=w?"preview":"edit",j=w?"tree":"text";for(const O of $e)Rt.current[O]="edit",bo(O)&&(Bn.current[O]=S),yo(O)&&(Kt.current[O]=S),lr(O)&&(ht.current[O]=S),vo(O)&&(vt.current[O]=S);xe("edit"),jn(S),Ye(S),Ze(S),Re(S),Ke(j);try{localStorage.setItem(zi,S),localStorage.setItem($i,S),localStorage.setItem(Bi,j)}catch{}},f=w=>{const S=!!w.detail?.enabled;i(S)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",f),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",f)}},[$e]),o.useEffect(()=>{if(!en||!g)return;const i=()=>{typeof window>"u"||hs.current===null&&(hs.current=window.requestAnimationFrame(()=>{hs.current=null,ji(Ve=>Ve+1)}))},f=(Ve,xt)=>{if(Ve.state.doc.length!==xt.length)return!1;if(xt.length===0)return!0;const on=Math.min(128,xt.length);if(Ve.state.sliceDoc(0,on)!==xt.slice(0,on))return!1;const ni=Math.max(0,xt.length-on);return Ve.state.sliceDoc(ni,xt.length)===xt.slice(ni)},w=ke(en.path);if(!w){Pr(null),bn.current={key:"",attempts:0,targetShown:!1};return}const S=`${w}:${en.line}:${en.column??1}`;bn.current.key!==S&&(bn.current={key:S,attempts:0,targetShown:!1});const j=v?.path??null;j===w&&(bn.current.targetShown=!0);const O=mp({selectedPath:j,targetPath:w,targetShown:bn.current.targetShown,targetSettled:!Be&&(Te===w||wn===w),showsText:wn!==w&&!lt&&!jt&&!An&&!xs,canEdit:dt,textViewMode:se});if(O==="select-target"){Ci||Ot(kn(w));return}if(O==="wait")return;if(O==="end"){Pr(null),bn.current={key:"",attempts:0,targetShown:!1};return}if(O==="show-editor"){xe("edit");return}if(!C)return;const Z=ct.current;if(!Z){i();return}if(!f(Z,ye)){i();return}const we=Math.max(1,Math.min(en.line,Z.state.doc.lines)),Ne=Z.state.doc.line(we),he=Math.max(1,en.column||1),ae=Math.max(0,Ne.to-Ne.from),Ue=Math.min(ae,he-1),He=Ne.from+Ue;if(!(Z.state.selection.main.head===He)||bn.current.attempts===0){bn.current.attempts+=1,Z.dispatch({selection:{anchor:He},effects:Ge.scrollIntoView(He,{y:"center"})}),Z.focus(),i();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const Ve=ct.current;Ve&&(Ve.dispatch({selection:{anchor:He},effects:Ge.scrollIntoView(He,{y:"center"})}),Ve.focus())}),Pr(null),bn.current={key:"",attempts:0,targetShown:!1}},[dt,Ci,ye,Gu,wn,lt,Be,jt,An,xs,Te,Ot,en,g,v?.path,Pr,se,kn,C]),o.useEffect(()=>{if(!Ti||!g||!C)return;const i=ke(Ti);if(!i){Mi(null);return}v?.path===i&&(Be||Te!==i&&wn!==i||(wn!==i&&!lt&&!jt&&!An&&!xs&&dt&&se==="edit"&&ct.current?.focus(),Mi(null)))},[dt,wn,lt,Be,jt,An,xs,Te,Ti,g,v?.path,Mi,se,C]);const ks=o.useCallback(i=>{if(!h||!i||typeof window>"u")return;const f=document.activeElement,w=!i.hasFocus&&f instanceof HTMLElement&&i.dom.contains(f)?f.closest('[data-comment-input="true"]'):null;if(!i.hasFocus&&!w)return;const S=window.visualViewport;if(!S)return;const j=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,j-(S.offsetTop+S.height))<=0)return;const Z=w?w.getBoundingClientRect():i.coordsAtPos(i.state.selection.main.head);if(!Z)return;const we=Math.round(S.offsetTop+S.height),he=Z.bottom+20-we;he<=0||(i.scrollDOM.scrollTop+=he)},[h]);o.useEffect(()=>{if(!h||typeof window>"u")return;const i=()=>{window.requestAnimationFrame(()=>{ks(ct.current)})},f=window.visualViewport;return f?.addEventListener("resize",i),f?.addEventListener("scroll",i,{passive:!0}),document.addEventListener("selectionchange",i),()=>{f?.removeEventListener("resize",i),f?.removeEventListener("scroll",i),document.removeEventListener("selectionchange",i)}},[h,ks]),Gl("open_go_to_line",i=>{if(!dt||se!=="edit"||h)return!1;const f=i.target;if(f?.closest('[role="dialog"]')||!(f instanceof Node)||!Gs.current?.contains(f))return!1;const w=!!f?.closest(".cm-editor");if(!!f?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!w)return!1;Rr(!0)}),Gl("open_document_symbols",i=>{if(!dt||se!=="edit"||h)return!1;const f=i.target;if(f?.closest('[role="dialog"]')||!(f instanceof Node)||!Gs.current?.contains(f))return!1;qs(!0)});const Zn=nt(i=>i.editorFontSize),nl=o.useMemo(()=>({"--text-markdown":`${Zn+1}px`,"--text-code":`${Zn-1}px`}),[Zn]),Es=v?.path&&g&&v.path.startsWith(`${g}/`)?v.path.slice(g.length+1):null,Md=nm(D||null),sl=bg(v?.path,D,Md),Ut=sl?.directory??null,es=sl?.relativePath??null,rl=ro(i=>{if(!es||!Ut)return null;const f=i.directories.get(Ut)?.status,w=f?.files.find(S=>S.path===es)??null;return JSON.stringify([Ut,es,f?.current??null,w])}),[Ui,Gr]=o.useState(null);o.useEffect(()=>{if(!Es||!es||!Ut||!rl){Gr(null);return}let i=!1;if(!m.getGitFileDiff){Gr(null);return}return m.getGitFileDiff(Ut,{path:es}).then(f=>{if(i)return;const w=ro.getState().directories.get(Ut)?.status?.files.find(O=>O.path===es),S=w!==void 0&&(w.index==="?"||w.index==="A"||w.working_dir==="?"),j=!f.isBinary&&!f.submodule&&(f.original!==""||S);Gr({path:Es,directory:Ut,text:j?f.original:null})}).catch(()=>{i||Gr({path:Es,directory:Ut,text:null})}),()=>{i=!0}},[m,rl,Ut,es,Es]);const il=o.useRef(Ui);il.current=Ui;const qr=o.useCallback(i=>{if(!i)return;const f=il.current;Gp(i,f&&f.path===Es&&f.directory===Ut?f.text:null)},[Ut,Es]);o.useEffect(()=>{qr(ct.current)},[qr,Ui]);const ol=o.useRef(()=>{});ol.current=()=>{if(!v?.path||!A)return;const i=jm(A),f=nt.getState(),w=f.contextPanelByDirectory[i]?.tabs.find(S=>S.preview&&S.targetPath===v.path);w&&f.pinContextPanelTab(i,w.id)};const al=o.useMemo(()=>Ge.updateListener.of(i=>{if(!i.docChanged)return;i.transactions.some(w=>w.isUserEvent("input")||w.isUserEvent("delete")||w.isUserEvent("undo")||w.isUserEvent("redo")||w.isUserEvent("move"))&&ol.current()}),[]),ll=o.useRef(()=>{});ll.current=i=>{const f=v?.path;!f||!A||ng(f,i,async w=>{try{const S=await a.listDirectory(w);return new Map(S.entries.map(j=>[j.name,j.isDirectory]))}catch{return null}}).then(w=>{if(w.status==="found"){nt.getState().openContextFile(A,w.path);return}re.error(w.status==="missing"?t("filesView.editor.importNotFound",{path:i}):t("filesView.editor.importLookupFailed",{path:i}))})};const cl=o.useMemo(()=>rg(i=>ll.current(i)),[]),ul=o.useMemo(()=>{if(!v?.path)return[ec(u,{fontSize:Zn})];const i=io(v.path),f=[ec(u,i?{syntaxColors:!1,fontSize:Zn}:{fontSize:Zn})],w=Kr??Ka;w&&f.push(w),i&&f.push(eh({language:i,themeName:nh(u),theme:th(u)})),te&&f.push(Ge.lineWrapping);const S=u.colors.syntax.highlights;return f.push(Kp({added:S?.diffAdded??u.colors.status.success,modified:S?.diffModified??u.colors.status.info,removed:S?.diffRemoved??u.colors.status.error},{revert:t("filesView.editor.gitHunk.revert"),close:t("filesView.editor.gitHunk.close")}),mh({highlightWordAroundCursor:!0,minSelectionLength:2}),al,Ap(),ug(),cl),mg(v.path)&&f.push(pg(t("filesView.editor.jsonSyntaxError"),{error:u.colors.status.error,tooltipBackground:u.colors.surface.elevated,tooltipForeground:u.colors.surface.elevatedForeground,border:u.colors.interactive.border})),h||f.push(Dp(),Vp({vimMode:ps==="vim"}),xg()),h&&f.push(Ge.updateListener.of(j=>{j.view.hasFocus&&(j.selectionSet||j.focusChanged||j.viewportChanged||j.geometryChanged)&&window.requestAnimationFrame(()=>{ks(j.view)})})),f},[u,v?.path,Kr,Ka,te,h,ks,Zn,al,ps,t,cl]),dl=o.useMemo(()=>({light:nc(br),dark:nc(gi)}),[br,gi]),fl=An||Vi||Li,Pd=o.useMemo(()=>v?.path&&fl?{runtime:L,path:v.path,directory:g||"",revision:String(Qt),outsideWorkspace:qt.allowOutsideWorkspace}:null,[L,v?.path,fl,g,Qt,qt.allowOutsideWorkspace]),Xr=km(),Dd=o.useMemo(()=>v?.path&&nn&&Oe==="preview"&&!c.isVSCode&&!Xr?{path:v.path,directory:g||"",revision:String(Qt),outsideWorkspace:qt.allowOutsideWorkspace}:null,[v?.path,nn,Oe,c.isVSCode,Xr,g,Qt,qt.allowOutsideWorkspace]),Hi=t("filesView.error.readFileFailed"),rn=Zw(Dd,Hi),ml=o.useRef(null),Yr=nx({frameRef:ml,directory:g,pageKey:rn.status==="ready"?rn.url:""}),Ad=!h&&rn.status==="ready",or=o.useRef(null);o.useEffect(()=>{(Oe!=="preview"||or.current!==v?.path)&&(or.current=null)},[Oe,v?.path]),o.useEffect(()=>{rn.status==="error"?Pe(rn.message):rn.status==="ready"&&Pe(null)},[rn,Pe]);const Ki=ex(Pd,Pe,Hi),Gi=Ki.loading,Vd=v?.path&&jt?It?`data:${Hc(v.path)};utf8,${encodeURIComponent(_)}`:$u:"",qi=Ki.src,Jr=v&&a.downloadFile?r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>{const i=a.downloadFile;!i||!v||i(v.path,qt).catch(f=>{console.error("Download failed:",f),re.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(ee,{name:"download",className:"me-2 size-4"}),t("filesView.editor.saveFile")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.downloadCopy")})]}):null,Ns=o.useCallback(async(i,f)=>{const w=St(i),S=await pr("/api/fs/raw",{signal:f,cache:"no-store",query:{path:i,allowOutsideWorkspace:w.allowOutsideWorkspace?"true":void 0,directory:g||void 0}});if(!S.ok)throw new Error(t("filesView.error.readFileFailed"));return S},[St,g,t]),Ld=o.useCallback(async()=>{const i=at.current;if(!i)throw new Error("No file is open.");const f=await Ns(i,AbortSignal.timeout(6e4));return new Uint8Array(await f.arrayBuffer())},[Ns]),Xi=h?lo:ah,hl=o.useCallback(async(i,f)=>{const w=AbortSignal.any([f,AbortSignal.timeout(6e4)]),S=await Ns(i,w),j=await Ro(S,lo,w);return new Uint8Array(await j.arrayBuffer())},[Ns]),Od=o.useCallback(async(i,f)=>{const w=AbortSignal.any([f,AbortSignal.timeout(3e5)]),S=await Ns(i,w),j=await Ro(S,Xi,w);return new Uint8Array(await j.arrayBuffer())},[Ns,Xi]),Yi=async i=>{if(!v)return;const{markdownToDocx:f,markdownToPrintableHtml:w,printHtml:S,rowsToXlsx:j}=await zo(async()=>{const{markdownToDocx:ae,markdownToPrintableHtml:Ue,printHtml:He,rowsToXlsx:je}=await import("./documentExport-Cf0gMwM0.js");return{markdownToDocx:ae,markdownToPrintableHtml:Ue,printHtml:He,rowsToXlsx:je}},__vite__mapDeps([227,3,2,228,104,105,106,5,6,107,108,109,103,33,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,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,1,4,7,8,9,10,11,12,93,94,95,96,97,98,99,100,101,102,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,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,213,214,215,216,217,183,218,219,220,221,222,223,224]));if(i==="pdf"){S(w(ye,v.name));return}const O=nr?bu(ye,Uo(v.path),Number.MAX_SAFE_INTEGER):null,Z=O?await j(v.name,[O.header,...O.rows]):await f(ye),we=v.path.replace(/\.[^./\\]+$/,"");let Ne=`${we}.${i}`;for(let ae=2;ae<1e3&&await Lt(Ne).catch(()=>null);ae+=1)Ne=`${we} ${ae}.${i}`;const he=Ne.split(/[/\\]/).pop()??Ne;if(!a.uploadFile){const ae=URL.createObjectURL(new Blob([Z]));Object.assign(document.createElement("a"),{href:ae,download:he}).click(),URL.revokeObjectURL(ae);return}try{if(!(await a.uploadFile(Ne,new Blob([Z]),{overwrite:!1}))?.success)throw new Error("write failed");re.success(t("filesView.export.saved",{name:he}))}catch{re.error(t("filesView.toast.writeFileFailed"))}},Id=o.useCallback(async(i,f)=>{if(!a.uploadFile||(at.current===i&&(gt.current=null),!(await a.uploadFile(i,new Blob([f]),{overwrite:!0}))?.success))return!1;if(g&&Ps(i,g)){const S=On(g,i);S&&Ul.requestGitRefresh({directory:g,paths:[S]})}return!0},[a,g]),zd=v&&To()?r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>{fr(v.path).then(i=>{i||re.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(ee,{name:"external-link",className:"me-2 size-4"}),t("sidebarFilesTree.menu.openInDefaultApp")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.openOutside")})]}):null,Qr=r.jsxs(r.Fragment,{children:[Jr,zd]}),Zr=v&&!Be&&!Gi&&!lt?(i=>{if(jt&&!Ai)return r.jsx(Hw,{src:Vd,name:i.name,sizeBytes:H,neighbors:yd,onRetry:_r,download:Jr});if(An)return r.jsx(Rw,{src:qi,name:i.name,sizeBytes:H,download:Jr});if(Vi)return r.jsx(qw,{kind:$a?"video":"audio",src:qi,renewSrc:Ki.renew,name:i.name,sizeBytes:H,download:Jr});if(Li)return r.jsx(Lw,{src:qi,name:i.name,sizeBytes:H});if(xs){const f=H!==null&&H>lo;return Xl(i.path)&&!f?r.jsx(kg,{name:i.name,path:i.path,sizeBytes:H,loadBytes:hl,actions:Qr},`${i.path}:${Qt}`):(Fo(i.path)||cr(i.path))&&!(H!==null&&H>Xi)?r.jsx(sw,{name:i.name,path:i.path,sizeBytes:H,loadBytes:Od,actions:Qr},`${i.path}:${Qt}`):Yl(i.path)&&!f?r.jsx(Cw,{name:i.name,path:i.path,sizeBytes:H,loadBytes:hl,actions:Qr,onSave:a.uploadFile&&!En?Id:void 0},`${i.path}:${Qt}`):r.jsx(hi,{name:i.name,path:i.path,sizeBytes:H,download:Qr,description:Yl(i.path)||Xl(i.path)||Fo(i.path)||cr(i.path)?t("filesView.artifact.office.tooLarge"):void 0})}return Hr&&et==="table"?r.jsx(pw,{content:_,sizeBytes:H}):nr&&et==="table"?r.jsx(Gg,{path:i.path,content:dt?ye:_,sizeBytes:H,onContentChange:dt?We:void 0},i.path):Ss&&Nt==="preview"?r.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:r.jsx(si,{fallback:r.jsxs("div",{className:"m-3 rounded-md bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:r.jsx(hr,{content:`\`\`\`mermaid
|
|
81
|
+
`)},[]),ga=o.useRef(null),ad=Ah({source:"file",fileLabel:v?.path??null,language:v?.path&&io(v.path)||"text",getCodeForRange:i=>od(_,Vh(i)),toStoreRange:i=>({startLine:i.start,endLine:i.end}),fromDraftRange:i=>({start:i.startLine,end:i.endLine})}),{drafts:wa,commentText:Dr,setCommentText:xa,editingDraftId:Ar,setSelection:ba,saveComment:va,cancel:Zs,reset:ya,startEdit:Sa,deleteDraft:Ca}=ad,ja=o.useMemo(()=>wa.filter(i=>!Uf(i)),[wa]),gs=Wh({fileLabel:v?.path??"",source:"file"}),{isDragging:ka,lineNumbersConfig:ld,isDragReleaseClick:Ea}=qm({lineSelection:ut,setLineSelection:Xn,onClear:Zs,isMobile:h});o.useEffect(()=>{Xt.current?.to!==v?.path&&(Xn(null),ya(),We(""),xi(!1))},[v?.path,ya]),o.useEffect(()=>{ba(ut)},[ut,ba]),o.useEffect(()=>{if(!ut&&!Ar)return;const i=w=>{if(Ea())return;const S=w.target;S.closest('[data-comment-input="true"]')||S.closest('[data-comment-card="true"]')||S.closest(".cm-gutterElement")||S.closest("[data-sonner-toast]")||S.closest("[data-sonner-toaster]")||Dr.trim()||(Xn(null),Zs())},f=setTimeout(()=>{document.addEventListener("click",i)},100);return()=>{clearTimeout(f),document.removeEventListener("click",i)}},[Zs,Dr,Ar,Ea,ut]),o.useEffect(()=>{if(!h||!ut)return;const i=ct.current;if(!i)return;const f=i.state.selection.main;f.empty||i.dispatch({selection:{anchor:f.head}});const w=document.getSelection();w&&!w.isCollapsed&&w.anchorNode&&i.contentDOM.contains(w.anchorNode)&&w.removeAllRanges()},[h,ut]);const Na=o.useCallback((i,f)=>{const w=f??ut??void 0;f&&Xn(f);const S=va(i,w);return S&&Xn(null),S},[ut,va]),Vr=o.useCallback((i,f)=>{const w=[];for(const S of f){if(!(S&&typeof S.name=="string"&&S.name.length>0)||!N&&S.name.startsWith(".")||!k&&ox(S.name))continue;const j=S.name,O=ke(S.path||""),Z=O?rx(O)?O:ke(`${i}/${O}`):ke(`${i}/${j}`),we=S.isDirectory?"directory":"file",Ne=we==="file"&&j.includes(".")?j.split(".").pop()?.toLowerCase():void 0;w.push({name:j,path:Z,type:we,extension:Ne})}return sx(w)},[k,N]),Ct=o.useCallback(async(i,f=!1)=>{if(!I)return;const w=ke(i.trim());if(!w||!f&&pt.current.has(w))return;const S=U.current,j=Ht();return tt.run(w,async O=>{const Z=()=>O()&&U.current===S&&Ht()===j;try{const we=!k,Ne=a.listDirectory?(await a.listDirectory(w,{respectGitignore:we})).entries:await Ql.listLocalDirectory(w,{respectGitignore:we});if(!Z())return;const he=Vr(w,Ne);pt.current=new Set(pt.current),pt.current.add(w),_t(ae=>{if(!ae[w])return ae;const Ue={...ae};return delete Ue[w],Ue}),ls(ae=>ae[w]&&yh(ae[w],he)?ae:{...ae,[w]:he})}catch(we){if(!Z())return;const Ne=we instanceof Error?we.message:String(we??"");if(Ne==="Directory not found"&&g&&w!==g){is(g,w),_t(he=>{if(!he[w])return he;const ae={...he};return delete ae[w],ae});return}console.error("Failed to load files directory:",we),_t(he=>({...he,[w]:Ne}))}},f)},[tt,a,Vr,is,g,k,I]),Lr=o.useCallback(async()=>{g&&(pt.current=new Set,tt.clear(),_t({}),ls(i=>Object.keys(i).length===0?i:{}),await Ct(g))},[tt,Ct,g]),Pt=o.useCallback(async i=>{if(!i){await Lr();return}const f=ke(i);pt.current=new Set(pt.current),pt.current.delete(f),await Ct(f,!0)},[Ct,Lr]),{canUpload:Fa,uploadingDirectory:cd,pickFiles:Ra,uploadElements:ud}=_m({root:g,refreshDirectory:Pt}),Or=cd!==null,Ta=o.useRef(""),Ma=o.useRef("");o.useEffect(()=>{if(!g)return;const i=W,f=Ta.current!==T,w=Ma.current!==i;!f&&!w||(f&&(Ta.current=T,ds.current+=1,Kn.current=null,le(""),Pe(null),gn(""),Qe(null),G(!1)),w&&(Ma.current=i,pt.current=new Set,tt.clear(),_t({}),ls(S=>Object.keys(S).length===0?S:{}),Ct(g)))},[tt,T,Ct,g,W]),o.useEffect(()=>{if(!I||!a.listDirectory)return;const i=()=>{if(!document.hidden&&Tt.length>0)for(const f of Tt)tt.has(f)||Pt(f)};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[tt,Tt,a.listDirectory,Pt,I]);const Pa=o.useRef(!1);o.useEffect(()=>{const i=I&&!Pa.current;if(Pa.current=I,!(!I||!g)&&(Ct(g),i))for(const f of Tt)tt.has(f)||Pt(f)},[tt,Tt,Ct,Pt,g,I]),o.useEffect(()=>{if(!I||!a.listDirectory||Tt.length===0)return;const i=setInterval(()=>{if(!document.hidden)for(const f of Tt)tt.has(f)||Pt(f)},8e3);return()=>clearInterval(i)},[tt,Tt,a.listDirectory,Pt,I]);const dd=o.useCallback(async i=>{if(i?.preventDefault(),!qn||!Gn)return;Ei(!0);const f=()=>{ki(null)},w=j=>{re.error(j)},S=()=>{Ei(!1)};if(Gn==="createFile"){if(!Pn.trim()){w(t("sidebarFilesTree.toast.filenameRequired")),S();return}if(!a.writeFile){w(t("sidebarFilesTree.toast.writeNotSupported")),S();return}const j=qn.path,O=j?`${j}/`:"",Z=ke(`${O}${Pn.trim()}`);await a.writeFile(Z,"").then(async we=>{we.success&&(re.success(t("sidebarFilesTree.toast.fileCreated")),await Pt(j)),f()}).catch(()=>w(t("sidebarFilesTree.toast.operationFailed"))).finally(S);return}if(Gn==="createFolder"){if(!Pn.trim()){w(t("sidebarFilesTree.toast.folderNameRequired")),S();return}const j=qn.path,O=j?`${j}/`:"",Z=ke(`${O}${Pn.trim()}`);await a.createDirectory(Z).then(async we=>{we.success&&(re.success(t("sidebarFilesTree.toast.folderCreated")),await Pt(j)),f()}).catch(()=>w(t("sidebarFilesTree.toast.operationFailed"))).finally(S);return}if(Gn==="rename"){if(!Pn.trim()){w(t("sidebarFilesTree.toast.nameRequired")),S();return}if(!a.rename){w(t("sidebarFilesTree.toast.renameNotSupported")),S();return}const j=qn.path,O=j.split("/").slice(0,-1).join("/"),Z=O?`${O}/`:"",we=Pn.trim(),Ne=ke(`${Z}${we}`);try{const he=await Sh(a,{tabs:A,files:g},j,Ne);he==="moved"?(re.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await Pt(O),f()):w(he==="conflict"?t("sidebarFilesTree.toast.nameTaken",{name:we,folder:On(g,O)||t("sidebarFilesTree.dialog.rootFallback")}):t("sidebarFilesTree.toast.operationFailed"))}catch{w(t("sidebarFilesTree.toast.operationFailed"))}finally{S()}return}if(Gn==="delete"){if(!a.delete){w(t("sidebarFilesTree.toast.deleteNotSupported")),S();return}const j=qn.path,O=j.split("/").slice(0,-1).join("/");await a.delete(j).then(async Z=>{Z.success&&(re.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await Pt(O),g&&As(g,j),(v?.path===j||v?.path.startsWith(`${j}/`))&&(g&&yt(g,null),le(""),Pe(null),gn(""),Qe(null),h&&G(!1))),f()}).catch(()=>w(t("sidebarFilesTree.toast.operationFailed"))).finally(S);return}S()},[Gn,qn,Pn,a,A,Pt,h,As,g,v?.path,yt,t]);o.useEffect(()=>{if(!D){V([]),ge(!1);return}const i=Me.trim();if(!i){V([]),ge(!1);return}let f=!1;return ge(!0),be(D,i,150,{includeHidden:N,respectGitignore:!k,type:"file"}).then(w=>{if(f)return;const j=w.filter(O=>k||!ax(O.path)).map(O=>({name:O.name,path:ke(O.path),type:"file",extension:O.extension,relativePath:O.relativePath}));V(j)}).catch(()=>{f||V([])}).finally(()=>{f||ge(!1)}),()=>{f=!0}},[D,Me,be,N,k]);const Ir=o.useCallback(async(i,f)=>{const w=St(i);if(a.readFile)return(await a.readFile(i,{...w,directory:g||void 0,...f})).content??"";const S=new URLSearchParams({path:i});w.allowOutsideWorkspace&&S.set("allowOutsideWorkspace","true"),g&&S.set("directory",g);const j=await pr(`/api/fs/read?${S.toString()}`,{cache:f?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!j.ok){const O=await j.json().catch(()=>({error:j.statusText}));throw new Error(O.error||t("filesView.error.readFileFailed"))}return j.text()},[a,St,g,t]),Lt=o.useCallback(async i=>{if(a.statFile){const f=St(i),w=await a.statFile(i,{...f,directory:g||void 0});return up(ke(i),w)}return null},[a,St,g]);o.useEffect(()=>{if(!g||!a.statFile||$e.length===0)return;let i=!1;const f=[...$e];return Promise.all(f.map(async w=>{try{const S=St(w),j=await a.statFile?.(w,{...S,directory:g||void 0});!i&&j&&!j.isFile&&rs(g,w)}catch(S){!i&&Zl(S)&&rs(g,w)}})),()=>{i=!0}},[a,$e,rs,St,g]);const Dt=ye!==_||$s,Dn=o.useCallback((i,f=!0)=>{const{content:w,lineEnding:S}=vp(i);return f&&vo(at.current)&&ze(j=>j+1),vi.current=i,yi.current+=1,Er(j=>j+1),Bu(S),le(w),Tn.current=w,zs.current=w,We(w),w},[]),vn=o.useCallback(async()=>{if(!v||!a.writeFile)return re.error(t("filesView.toast.savingNotSupported")),!1;const i=(ar(v.path)||Mn)&&!Bs.current;if(!xp({selectedFilePath:v.path,loadedFilePath:Te,fileLoading:Be,isDirty:Dt,draftContent:ye,fileContent:_,isNonEditableBinary:i}))return i?console.warn(`[saveDraft] refusing to save binary file "${v.path}".`):ye===""&&_!==""&&Te!==v.path&&console.warn(`[saveDraft] refusing to save empty draft for "${v.path}" (${_.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Dt)return!0;if(Xt.current||ao(v.path))return!1;xi(!0);try{const f=$s?us.current:null;$s&&!f&&Jt(!1);const w=f?await f.getContent("save"):uo;if(!w.ok)return re.error(w.message),!1;const S=w.snapshot;if(S&&"bytes"in S){if(!a.uploadFile)return re.error(t("filesView.toast.savingNotSupported")),!1;if(gt.current=null,!(await a.uploadFile(v.path,new Blob([S.bytes]),{overwrite:!0}))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;us.current?.markSaved(S.signature)}else{const j=yp(S?S.content:ye,Yo);if(!(await a.writeFile(v.path,j))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;S?(Dn(j,!1),us.current?.markSaved(S.signature)):(le(ye),vi.current=j,yi.current+=1)}if(g&&Ps(v.path,g)){const j=On(g,v.path);j&&Ul.requestGitRefresh({directory:g,paths:[j]})}if(g&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(ke(v.path))){const j=Hf.getState().projects.find(O=>ke(O.path)===ke(g));if(j)try{await Kh(j.id)}catch{re.error(t("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return v?.path&&lr(v.path)&&(Tn.current=ye,zs.current=ye),Lt(v.path).then(j=>{j&&(gt.current=j)}).catch(()=>{}),!0}catch(f){return re.error(f instanceof Error?f.message:t("filesView.toast.saveFailed")),!1}finally{xi(!1)}},[Dn,Mn,ye,$s,_,Be,a,Dt,Yo,Te,Lt,g,v,t]);Qo.current=vn,o.useEffect(()=>{Zt||(fs("idle"),Yt.current&&(clearTimeout(Yt.current),Yt.current=null))},[Zt]);const zr=1500;o.useEffect(()=>{const i=!!(v&&a.writeFile),f=!!(v?.path&&(ar(v.path)||Mn))&&!Bs.current;if(!wp({autoSaveEnabled:Zt,isDirty:Dt,canWrite:i,isSaving:cs,fileLoading:Be,selectedFilePath:v?.path,loadedFilePath:Te,isNonEditableBinary:f,wouldEmptyFile:ye===""&&_!==""}))return;const w=S=>{Yt.current=setTimeout(()=>{const j=Date.now()-ta.current;if(j<zr){w(zr-j);return}vn().then(O=>{O&&(fs("saved"),setTimeout(()=>fs("idle"),2e3))})},S)};return w(zr),()=>{Yt.current&&(clearTimeout(Yt.current),Yt.current=null)}},[Zt,Mn,ye,_,Be,Dt,Te,v,a.writeFile,cs,vn]),o.useEffect(()=>{fs("idle")},[v?.path]);const Da=o.useCallback(()=>{Yt.current&&(clearTimeout(Yt.current),Yt.current=null),cs||vn().then(i=>{i&&(fs("saved"),setTimeout(()=>fs("idle"),2e3))})},[cs,vn]);Kf({save_file:i=>{if(!(i.target instanceof Node)||!Gs.current?.contains(i.target)&&!ea.current?.contains(i.target))return!1;Da()},find_in_file:i=>{if(!(i.target instanceof Node))return!1;if(ft&&js()==="preview"){if(h||!(J?Js.current:Ys.current)?.contains(i.target))return!1;Xs(!0),aa(w=>w+1);return}if(!Gs.current?.contains(i.target))return!1;X(!0)}});const Aa=o.useCallback(async i=>{const f=ds.current+1;ds.current=f;const w=Ht(),S=$.current,j=()=>{if(!g||Ht()!==w||$.current!==S)return!1;const ae=kt.getState().byRoot[g],Ue=ae?.selectedPath??ae?.openPaths[0]??null;return ds.current===f&&Ue===i.path};Xt.current=null,Xo(null),Pe(null),Is(null),kr.current=null,gn(""),Qe(null),Si(!1),Vt(!0);const O=mr(i.path),Z=oo(i.path),we=Hl(i.path),Ne=ar(i.path);if(h&&G(!0),c.isDesktop&&O&&!Z){le(""),We("");return}if(!c.isDesktop&&O&&!Z){le(""),We(""),Qe(i.path),Vt(!1);return}if(we){le(""),We(""),Qe(i.path),Vt(!1);return}if(Ne){le(""),We(""),Qe(i.path),Vt(!1);return}const he=await Lt(i.path).catch(()=>null);if(j()){if(he&&he.size>Mo&&cr(i.path)){Si(!0),le(""),We(""),Qe(i.path),Vt(!1);return}if(he&&he.size>Mo){le(""),We(""),Pe(oh(he.size,t)),Is(i.path),gt.current=null,Vt(!1);return}await Ir(i.path).then(ae=>{if(!j())return;if(Co(ae)){Si(!0),le(""),We(""),Qe(i.path);return}const Ue=Dn(ae),He=bo(i.path)||yo(i.path)||_c(i.path)||lr(i.path)||oo(i.path)||Kl(i.path)||cr(i.path)||vo(i.path);xe(He?"edit":Sp(Ue,Rt.current[i.path])),Qe(i.path),Lt(i.path).then(je=>{je&&j()&&(gt.current=je)}).catch(()=>{})}).catch(ae=>{if(j()){if(lx(ae)){if(Vt(!1),g&&yt(g,null),Pe(null),le(""),We(""),Qe(null),gt.current=null,ue.trim().length>0&&Ce(""),h&&G(!1),g){const He=[...$c(i.path,g),i.path];He.length>0&&os(g,He);for(const je of He)pt.current.has(je)||Ct(je)}return}le(""),We(""),Pe(ae instanceof Error?ae.message:t("filesView.error.readFileFailed")),Is(i.path),gt.current=null}}).finally(()=>{j()&&Vt(!1)})}},[Dn,os,h,Ct,Ir,Lt,g,c.isDesktop,ue,yt,t]),$r=o.useCallback(async(i,f)=>{if(!e||!g)return;const w=$c(i,g),S=f?[...w,i]:w;if(S.length>0&&os(g,S),!I)return;const j=S.map(O=>{if(!pt.current.has(O))return Ct(O)}).filter(Boolean);await Promise.all(j)},[os,Ct,g,I,e]),Va=o.useCallback((i,f)=>{const w=f.findIndex(S=>S.path===i);return w===-1||f.length<=1?null:f[w+1]??f[w-1]??null},[]),Ot=o.useCallback(async i=>{if(Us.current)Us.current=!1;else if(Dt){_s(!0),ms.current=i;return}g&&(yt(g,i.path),$r(i.path,!1)),Pe(null),gn(""),le(""),Tn.current="",zs.current="",Jt(!1),We(""),Qe(null),h&&G(!0)},[$r,Dt,h,g,yt]);o.useEffect(()=>{v?.path&&$r(v.path,!1)},[$r,v?.path]),o.useEffect(()=>Cm(({runtimeKey:i,from:f,to:w})=>{if(i!==Ht())return;Rt.current=Vn(Rt.current,f,w),Bn.current=Vn(Bn.current,f,w),Kt.current=Vn(Kt.current,f,w),ns.current=Vn(ns.current,f,w),$t.current=Vn($t.current,f,w),hn.current=Vn(hn.current,f,w),ht.current=Vn(ht.current,f,w),vt.current=Vn(vt.current,f,w);const S=Xt.current,j=S?.to??qo.current,O=j?Em(j,f,w):null;j&&O&&(Xt.current={from:S?.from??j,to:O})}),[]),o.useEffect(()=>{const i=Xt.current;if(i&&v?.path===i.to){if(Xt.current=null,Te===i.from){Xo({path:i.to,documentPath:Os??i.from}),Qe(i.to);return}}else i&&Te!==i.from&&(Xt.current=null);if(!e)return;if(!v){ds.current+=1,Kn.current=null,Vt(!1);return}if(Te===v.path||Kn.current===v.path)return;const f=v.path;Kn.current=f,Aa(v).finally(()=>{Kn.current===f&&(Kn.current=null)})},[Os,Qt,Aa,Te,v,e]);const Br=o.useRef(Dt);Br.current=Dt;const _r=o.useCallback(()=>{ds.current+=1,Kn.current=null,gt.current=null,gn(""),Pe(null),Qe(null),Er(i=>i+1)},[]);o.useEffect(()=>Wm(({runtimeKey:i,paths:f})=>{const w=v?.path;i!==Ht()||!w||Br.current||!f.includes(ke(w))||_r()}),[_r,v?.path]),o.useEffect(()=>{if(!e||!v?.path||Te!==v.path&&wn!==v.path)return;const i=v.path,f=wn===i,w=Ht(),S=$.current,j=()=>Br.current||lr(i)&&Tn.current!==zs.current,O=!ar(i)&&!mr(i)&&!Mn?Xm({readContent:()=>Ir(i,{fresh:!0}),getLoadedContent:()=>vi.current,getLoadedRevision:()=>yi.current,isDirty:j,applyContent:je=>{if(!(Z||Ht()!==w||$.current!==S)){if(Co(je)){Qe(null);return}Dn(je)}}}):null;let Z=!1,we=!1,Ne=!1;const he=()=>{if(!document.hidden){if(we){Ne=!0;return}we=!0,Lt(i).then(async je=>{if(Z||Ht()!==w||$.current!==S||!je)return;const ts=kr.current===i,Ve=mc({stat:"found",showsFailure:f,sawMissing:ts,hasUnsavedChanges:j(),moving:!1});if(Ve==="reload"){gt.current=null,Qe(null),Er(on=>on+1);return}if(Ve!=="check-changes")return;const xt=gt.current;if(!xt||xt.path!==i){gt.current=je;return}if(fp(xt,je)){if(O&&je.size<=cx){await O.poll()&&!Z&&(gt.current=je);return}Br.current||(gt.current=je,Qe(null),Er(on=>on+1))}}).catch(je=>{if(Z||Ht()!==w||$.current!==S)return;const ts=Zl(je)?"missing":"failed",Ve=kr.current===i,xt=ao(i)||Xt.current!==null;mc({stat:ts,showsFailure:f,sawMissing:Ve,hasUnsavedChanges:j(),moving:xt})==="show-missing"&&(kr.current=i,gt.current=null,le(""),We(""),Pe(je instanceof Error?je.message:t("filesView.error.readFileFailed")),Is(i))}).finally(()=>{we=!1,Ne&&!Z&&(Ne=!1,he())})}};he();let ae=window.setInterval(he,2e3);const Ue=g?Gf(g,i,he):null;Ue?.watching.then(je=>{!je||Z||(window.clearInterval(ae),ae=window.setInterval(he,ux))});const He=()=>{document.hidden||he()};return document.addEventListener("visibilitychange",He),()=>{Z=!0,O?.dispose(),window.clearInterval(ae),Ue?.stop(),document.removeEventListener("visibilitychange",He)}},[Dn,Mn,wn,Te,Ir,Lt,g,v?.path,t,e]);const ws=o.useCallback((i,f)=>{if(s){s(i);return}if(g&&ss(g,i),v?.path===i){if(f){Ot(f);return}g&&yt(g,null),le(""),Pe(null),gn(""),Qe(null),h&&G(!1)}},[Ot,h,s,ss,g,v?.path,yt]),fd=o.useCallback(()=>{const i=ms.current,f=Ws.current;if(ms.current=null,Ws.current=null,Us.current=!0,_s(!1),Jt(!1),ze(w=>w+1),We(_),f){ws(f,i);return}if(i){Ot(i);return}},[ws,_,Ot]),md=o.useCallback(async()=>{const i=ms.current,f=Ws.current;if(!await vn()){Us.current=!1;return}if(ms.current=null,Ws.current=null,Us.current=!0,_s(!1),f){ws(f,i);return}if(i){await Ot(i);return}},[ws,Ot,vn]),er=o.useCallback(i=>{const f=v?.path===i,w=Va(i,Bt);if(f&&Dt){_s(!0),ms.current=w,Ws.current=i;return}ws(i,w)},[ws,Va,Dt,Bt,v?.path]),La=o.useRef(er);o.useEffect(()=>{La.current=er},[er]);const Pi=v?.path??null,Oa=o.useRef(null);o.useEffect(()=>{if(!(!e||!Pi))return Um(()=>La.current(Pi),Oa)},[Pi,e]);const hd=o.useMemo(()=>new Set($e),[$e]),Wr=o.useMemo(()=>Ch(B?ve?.files??[]:[]),[ve?.files,B]),pd=o.useCallback(i=>{const f=i.startsWith(g+"/")?i.slice(g.length+1):i;return Wr.statusByPath.get(f)??null},[Wr,g]),gd=o.useCallback(i=>{if(!ve?.files)return null;const f=i.startsWith(g+"/")?i.slice(g.length+1):i;return Wr.badgeByDir.get(f)??null},[ve,Wr,g]),Di=o.useRef(null),Ia=jh(Di),wd=o.useCallback(async i=>{const f=ke(i);if(!g)return;const w=kt.getState().byRoot[g]?.expandedPaths.includes(f)??!1;Ia(i,w,()=>yr(g,f)),pt.current.has(f)||await Ct(f)},[Ct,g,yr,Ia]),xd=o.useMemo(()=>({canRename:ua,canCreateFile:la,canCreateFolder:ca,canDelete:da,canReveal:fa}),[ua,la,ca,da,fa]);function za(i,f){return(Nn[i]??[]).map(S=>{const j=S.type==="directory",O=j&&vr.has(S.path),Z=v?.path===S.path;return r.jsxs("li",{children:[r.jsx(dx,{guestActions:l,node:S,root:g,isExpanded:O,isActive:Z,isMobile:h,isBrowserClient:F,alwaysShowActions:M,depth:f,isOpen:!j&&hd.has(S.path),status:j?void 0:pd(S.path),badge:j?gd(S.path):void 0,permissions:xd,downloadFile:a.downloadFile,contextMenuPath:Yu,setContextMenuPath:Ju,rightClickMenuPath:Qu,setRightClickMenuPath:Zu,onSelect:Ot,onToggle:wd,onRevealPath:sd,onOpenDialog:Ri,canUpload:Fa&&!Or,onPickFiles:Ra}),j&&O&&r.jsxs("ul",{className:"flex flex-col",children:[Un[S.path]?r.jsxs("li",{className:"sticky inset-s-0 flex w-[100cqw] items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingLeft:fu(f+1)},"data-tree-disclosure-path":`${S.path}/`,children:[r.jsx(du,{depth:f+1}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:Un[S.path],children:Un[S.path]}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Pt(S.path)},children:[r.jsx(ee,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.retryFolder")})]})]}):null,za(S.path,f+1)]})]},S.path)})}const jt=!!(v?.path&&mr(v.path)),It=!!(v?.path&&oo(v.path)),Ai=It&&ot==="edit",An=!!(v?.path&&Hl(v.path)),$a=!!(v?.path&&qf(v.path)),Vi=$a||!!(v?.path&&Xf(v.path)),Li=!!(v?.path&&Yf(v.path)),Ur=!!(v?.path&&(ar(v.path)||Mn)),xs=Ur&&!jt&&!An&&!Vi&&!Li,bd=Ur||jt&&!Ai,tr=e&&v&&jt&&!Ai?zc(v.path):"",[Yn,vd]=o.useState(null),Ba=!!(tr&&Yn?.scope===W&&Yn.folder===tr),_a=!!(Ba&&Yn?.entries.some(i=>i.path===Ae)),Wa=!!tr&&!(Ba&&Yn?.readFor===Ae);o.useEffect(()=>{if(!Wa)return;let i=!1;const f=W,w=tr,S=Ae,j=!k;return(a.listDirectory?a.listDirectory(w,{respectGitignore:j}).then(Z=>Z.entries):Ql.listLocalDirectory(w,{respectGitignore:j})).then(Z=>{i||U.current!==f||vd({scope:f,folder:w,readFor:S,entries:Vr(w,Z)})}).catch(Z=>{i||console.warn("Failed to list the image folder:",Z)}),()=>{i=!0}},[a,tr,Wa,Vr,Ae,k,W]);const yd=o.useMemo(()=>{if(!_a||!Yn||!A)return null;const i=Kw(Yn.entries,Ae);if(!i)return null;const f=w=>({name:w.name,open:()=>nt.getState().openContextFile(A,w.path,{preview:!0})});return{previous:f(i.previous),next:f(i.next)}},[_a,Yn,A,Ae]),Ua=o.useMemo(()=>ke(en?.path??""),[en?.path]),bs=!!(en&&Ua&&Ae&&Ae===Ua&&!Be&&!lt&&!bd),Jn=o.useMemo(()=>On(g,Ae),[Ae,g]),Sd=!!(v&&(!jt||It)&&!An&&!xs&&_.length>0),Ha=!!(v&&Jn.length>0),dt=!!(v&&!En&&!Ur&&(!jt||It)&&a.writeFile),Qn=!!(v&&!Ur&&(!jt||It)),Oi=Rp(v?.path),wt=Oi&&(Qn||Oi.editor.content==="binary")?Oi:null,tn=wt!==null,Cd=Jf(),vs=wt?.editor.content==="binary";Bs.current=vs;const ft=!tn&&!!(v?.path&&bo(v.path)),ys=!tn&&!!(v?.path&&_c(v.path)),nn=!tn&&!!(v?.path&&yo(v.path)),sn=!tn&&!Cd&&!!(v?.path&&lr(v.path)),Ss=!tn&&!!(v?.path&&Kl(v.path)),nr=!tn&&!Mn&&!!(v?.path&&cr(v.path)),Hr=!tn&&!!(v?.path&&Qf(v.path)),sr=nr||Hr,Wt=tn,rr=tn&&(vs?H===null||H<=So:ye.length<=So),jd=$o(i=>i.status),kd=!tn&&Qn&&jd!=="unsupported"&&!!(v?.path&&Zf(v.path)),ir=Qn&&!ft&&!sn&&!Wt&&!(nn&&Oe==="preview")&&!(It&&ot==="preview")&&!(Ss&&Nt==="preview")&&!(sr&&et==="table"),Ed=ft&&_e==="edit"||nn&&Oe==="edit"||Wt&&(Je==="edit"||!rr)||It&&ot==="edit"||Ss&&Nt==="edit"||sr&&et==="text"||ys&&de==="text"||!ft&&!nn&&!ys&&!Wt&&!It&&!Ss&&!sr&&se==="edit";o.useEffect(()=>{const i=ct.current;if(!h||!z||!i)return;const f=uh(i.state);!f.caseSensitive&&!f.regexp&&!f.wholeWord||i.dispatch({effects:dh.of(new fh({search:f.search,replace:f.replace}))})},[h,z]);const Cs=(sn?oe!=="preview":Ed)&&!(ir&&se==="view");o.useEffect(()=>{Cs||(Rr(!1),qs(!1))},[Cs]);const Kr=o.useMemo(()=>Ae?em(Ae):null,[Ae]),[Ka,Ii]=o.useState(null);o.useEffect(()=>{let i=!1;const f=v?.path;if(!f||Kr){Ii(null);return}return Ii(null),tm(f).then(w=>{i||Ii(w)}),()=>{i=!0}},[v?.path,Kr]),o.useEffect(()=>{!dt&&se==="edit"&&xe("view")},[dt,se]);const zi="openchamber:files:md-viewer-mode",$i="openchamber:files:html-viewer-mode",Bi="openchamber:files:json-viewer-mode";o.useEffect(()=>{const i=v?.path;if(!i)return;xe(Rt.current[i]??"edit");let f=Qs?"preview":"edit";try{const j=localStorage.getItem(zi);(j==="preview"||j==="edit")&&(f=j)}catch{}jn(Bn.current[i]??f);let w=Qs?"preview":"edit";try{const j=localStorage.getItem($i);(j==="preview"||j==="edit")&&(w=j)}catch{}Ye(Kt.current[i]??w),Ze(ht.current[i]??(Qs?"preview":"edit")),Re(vt.current[i]??"preview"),zt(ns.current[i]??"preview"),bt($t.current[i]??"preview"),Ft(hn.current[i]??"table");let S=Qs?"tree":"text";try{const j=localStorage.getItem(Bi);(j==="tree"||j==="text")&&(S=j)}catch{}Ke(S)},[v?.path,Qs]);const Ga=o.useCallback(i=>{const f=v?.path;f&&(Rt.current[f]=i),xe(i)},[v?.path]),qa=o.useCallback(i=>{const f=v?.path;f&&(Bn.current[f]=i),jn(i);try{localStorage.setItem(zi,i)}catch{}},[v?.path]),js=o.useCallback(()=>_e,[_e]),Xa=o.useCallback(i=>{const f=v?.path;f&&(ns.current[f]=i),zt(i)},[v?.path]),Ya=o.useCallback(i=>{const f=v?.path;f&&($t.current[f]=i),bt(i)},[v?.path]),Ja=o.useCallback(i=>{const f=v?.path;f&&(hn.current[f]=i),Ft(i)},[v?.path]);o.useEffect(()=>{const i=v?.path;if(mt(null),!i||Te!==i)return;let f=!1;return Lt(i).then(w=>{!f&&w&&mt(w.size)}).catch(()=>{}),()=>{f=!0}},[Qt,Te,Lt,v?.path]);const Qa=v&&ft&&js()==="preview"&&!Be?v.path:null;o.useEffect(()=>{!Qa||h||Mr()},[Mr,J,h,Qa]);const Za=o.useCallback(i=>{Ke(i);try{localStorage.setItem(Bi,i)}catch{}},[]),_i=o.useCallback(i=>{const f=v?.path;f&&(Kt.current[f]=i),Ye(i);try{localStorage.setItem($i,i)}catch{}},[v?.path]),el=o.useCallback(i=>{const f=v?.path;if(f&&(ht.current[f]=i),Mt.current&&(clearTimeout(Mt.current),Mt.current=null),xn.current!==null&&(cancelAnimationFrame(xn.current),xn.current=null),i==="edit")We(Tn.current||_),Ze(i);else{Tn.current=ye;const w=f;Ze("edit"),xn.current=requestAnimationFrame(()=>{xn.current=requestAnimationFrame(()=>{xn.current=null,!(g&&w&&kt.getState().byRoot[g]?.selectedPath!==w)&&(mn(S=>S+1),Ze("preview"))})});return}},[ye,_,g,v?.path]),tl=o.useCallback(i=>{const f=v?.path,w=()=>{f&&(vt.current[f]=i)};if(i==="edit"){if(!bi.current){w(),Jt(!1),Re(i);return}Promise.resolve(us.current?.getContent("handoff")??uo).then(j=>{if(at.current===f){if(!j.ok){re.error(j.message);return}w(),We(j.snapshot&&"content"in j.snapshot?j.snapshot.content:_),Jt(!1),Re(i)}});return}if(!rr){wt&&re.error(t("filesView.fileEditor.tooLarge",{editor:wt.editor.title}));return}w(),Jt(!1);const S=f;Hn.current!==null&&cancelAnimationFrame(Hn.current),Hn.current=requestAnimationFrame(()=>{Hn.current=null,!(g&&S&&kt.getState().byRoot[g]?.selectedPath!==S)&&(ze(j=>j+1),Re("preview"))})},[rr,_,wt,g,v?.path,t]),Wi=o.useCallback(async(i,f)=>{if(!a.writeFile||f===zs.current||Xt.current||ao(i))return!1;if(!(await a.writeFile(i,f))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;Dn(f);const S=await Lt(i).catch(()=>null);return S&&(gt.current=S),!0},[Dn,a,Lt,t]);o.useEffect(()=>()=>{Mt.current&&(clearTimeout(Mt.current),Mt.current=null),xn.current!==null&&(cancelAnimationFrame(xn.current),xn.current=null)},[oe,v?.path]);const Nd=o.useCallback(i=>{if(Tn.current=i,!Zt||!v?.path||oe!=="preview"||!a.writeFile)return;Mt.current&&clearTimeout(Mt.current);const f=v.path;Mt.current=setTimeout(()=>{Mt.current=null,Wi(f,i).then(w=>{w&&(Nr(!0),setTimeout(()=>Nr(!1),1500))}).catch(w=>{re.error(w instanceof Error?w.message:t("filesView.toast.saveFailed"))})},zr)},[Zt,oe,a.writeFile,Wi,v?.path,t]),Fd=o.useMemo(()=>sn&&(Tn.current||ye)||_,[ye,_,sn]),Rd=o.useCallback(()=>{const i=at.current;i&&(vt.current[i]="edit"),Jt(!1),Re("edit"),wt&&re.error(t("filesView.fileEditor.unsupported",{editor:wt.editor.title}))},[wt,t]);o.useEffect(()=>()=>{Hn.current!==null&&(cancelAnimationFrame(Hn.current),Hn.current=null)},[Je,v?.path]);const Td=o.useCallback(()=>Oe,[Oe]);o.useEffect(()=>{const i=w=>{const S=w?"preview":"edit",j=w?"tree":"text";for(const O of $e)Rt.current[O]="edit",bo(O)&&(Bn.current[O]=S),yo(O)&&(Kt.current[O]=S),lr(O)&&(ht.current[O]=S),vo(O)&&(vt.current[O]=S);xe("edit"),jn(S),Ye(S),Ze(S),Re(S),Ke(j);try{localStorage.setItem(zi,S),localStorage.setItem($i,S),localStorage.setItem(Bi,j)}catch{}},f=w=>{const S=!!w.detail?.enabled;i(S)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",f),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",f)}},[$e]),o.useEffect(()=>{if(!en||!g)return;const i=()=>{typeof window>"u"||hs.current===null&&(hs.current=window.requestAnimationFrame(()=>{hs.current=null,ji(Ve=>Ve+1)}))},f=(Ve,xt)=>{if(Ve.state.doc.length!==xt.length)return!1;if(xt.length===0)return!0;const on=Math.min(128,xt.length);if(Ve.state.sliceDoc(0,on)!==xt.slice(0,on))return!1;const ni=Math.max(0,xt.length-on);return Ve.state.sliceDoc(ni,xt.length)===xt.slice(ni)},w=ke(en.path);if(!w){Pr(null),bn.current={key:"",attempts:0,targetShown:!1};return}const S=`${w}:${en.line}:${en.column??1}`;bn.current.key!==S&&(bn.current={key:S,attempts:0,targetShown:!1});const j=v?.path??null;j===w&&(bn.current.targetShown=!0);const O=mp({selectedPath:j,targetPath:w,targetShown:bn.current.targetShown,targetSettled:!Be&&(Te===w||wn===w),showsText:wn!==w&&!lt&&!jt&&!An&&!xs,canEdit:dt,textViewMode:se});if(O==="select-target"){Ci||Ot(kn(w));return}if(O==="wait")return;if(O==="end"){Pr(null),bn.current={key:"",attempts:0,targetShown:!1};return}if(O==="show-editor"){xe("edit");return}if(!C)return;const Z=ct.current;if(!Z){i();return}if(!f(Z,ye)){i();return}const we=Math.max(1,Math.min(en.line,Z.state.doc.lines)),Ne=Z.state.doc.line(we),he=Math.max(1,en.column||1),ae=Math.max(0,Ne.to-Ne.from),Ue=Math.min(ae,he-1),He=Ne.from+Ue;if(!(Z.state.selection.main.head===He)||bn.current.attempts===0){bn.current.attempts+=1,Z.dispatch({selection:{anchor:He},effects:Ge.scrollIntoView(He,{y:"center"})}),Z.focus(),i();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const Ve=ct.current;Ve&&(Ve.dispatch({selection:{anchor:He},effects:Ge.scrollIntoView(He,{y:"center"})}),Ve.focus())}),Pr(null),bn.current={key:"",attempts:0,targetShown:!1}},[dt,Ci,ye,Gu,wn,lt,Be,jt,An,xs,Te,Ot,en,g,v?.path,Pr,se,kn,C]),o.useEffect(()=>{if(!Ti||!g||!C)return;const i=ke(Ti);if(!i){Mi(null);return}v?.path===i&&(Be||Te!==i&&wn!==i||(wn!==i&&!lt&&!jt&&!An&&!xs&&dt&&se==="edit"&&ct.current?.focus(),Mi(null)))},[dt,wn,lt,Be,jt,An,xs,Te,Ti,g,v?.path,Mi,se,C]);const ks=o.useCallback(i=>{if(!h||!i||typeof window>"u")return;const f=document.activeElement,w=!i.hasFocus&&f instanceof HTMLElement&&i.dom.contains(f)?f.closest('[data-comment-input="true"]'):null;if(!i.hasFocus&&!w)return;const S=window.visualViewport;if(!S)return;const j=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,j-(S.offsetTop+S.height))<=0)return;const Z=w?w.getBoundingClientRect():i.coordsAtPos(i.state.selection.main.head);if(!Z)return;const we=Math.round(S.offsetTop+S.height),he=Z.bottom+20-we;he<=0||(i.scrollDOM.scrollTop+=he)},[h]);o.useEffect(()=>{if(!h||typeof window>"u")return;const i=()=>{window.requestAnimationFrame(()=>{ks(ct.current)})},f=window.visualViewport;return f?.addEventListener("resize",i),f?.addEventListener("scroll",i,{passive:!0}),document.addEventListener("selectionchange",i),()=>{f?.removeEventListener("resize",i),f?.removeEventListener("scroll",i),document.removeEventListener("selectionchange",i)}},[h,ks]),Gl("open_go_to_line",i=>{if(!dt||se!=="edit"||h)return!1;const f=i.target;if(f?.closest('[role="dialog"]')||!(f instanceof Node)||!Gs.current?.contains(f))return!1;const w=!!f?.closest(".cm-editor");if(!!f?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!w)return!1;Rr(!0)}),Gl("open_document_symbols",i=>{if(!dt||se!=="edit"||h)return!1;const f=i.target;if(f?.closest('[role="dialog"]')||!(f instanceof Node)||!Gs.current?.contains(f))return!1;qs(!0)});const Zn=nt(i=>i.editorFontSize),nl=o.useMemo(()=>({"--text-markdown":`${Zn+1}px`,"--text-code":`${Zn-1}px`}),[Zn]),Es=v?.path&&g&&v.path.startsWith(`${g}/`)?v.path.slice(g.length+1):null,Md=nm(D||null),sl=bg(v?.path,D,Md),Ut=sl?.directory??null,es=sl?.relativePath??null,rl=ro(i=>{if(!es||!Ut)return null;const f=i.directories.get(Ut)?.status,w=f?.files.find(S=>S.path===es)??null;return JSON.stringify([Ut,es,f?.current??null,w])}),[Ui,Gr]=o.useState(null);o.useEffect(()=>{if(!Es||!es||!Ut||!rl){Gr(null);return}let i=!1;if(!m.getGitFileDiff){Gr(null);return}return m.getGitFileDiff(Ut,{path:es}).then(f=>{if(i)return;const w=ro.getState().directories.get(Ut)?.status?.files.find(O=>O.path===es),S=w!==void 0&&(w.index==="?"||w.index==="A"||w.working_dir==="?"),j=!f.isBinary&&!f.submodule&&(f.original!==""||S);Gr({path:Es,directory:Ut,text:j?f.original:null})}).catch(()=>{i||Gr({path:Es,directory:Ut,text:null})}),()=>{i=!0}},[m,rl,Ut,es,Es]);const il=o.useRef(Ui);il.current=Ui;const qr=o.useCallback(i=>{if(!i)return;const f=il.current;Gp(i,f&&f.path===Es&&f.directory===Ut?f.text:null)},[Ut,Es]);o.useEffect(()=>{qr(ct.current)},[qr,Ui]);const ol=o.useRef(()=>{});ol.current=()=>{if(!v?.path||!A)return;const i=jm(A),f=nt.getState(),w=f.contextPanelByDirectory[i]?.tabs.find(S=>S.preview&&S.targetPath===v.path);w&&f.pinContextPanelTab(i,w.id)};const al=o.useMemo(()=>Ge.updateListener.of(i=>{if(!i.docChanged)return;i.transactions.some(w=>w.isUserEvent("input")||w.isUserEvent("delete")||w.isUserEvent("undo")||w.isUserEvent("redo")||w.isUserEvent("move"))&&ol.current()}),[]),ll=o.useRef(()=>{});ll.current=i=>{const f=v?.path;!f||!A||ng(f,i,async w=>{try{const S=await a.listDirectory(w);return new Map(S.entries.map(j=>[j.name,j.isDirectory]))}catch{return null}}).then(w=>{if(w.status==="found"){nt.getState().openContextFile(A,w.path);return}re.error(w.status==="missing"?t("filesView.editor.importNotFound",{path:i}):t("filesView.editor.importLookupFailed",{path:i}))})};const cl=o.useMemo(()=>rg(i=>ll.current(i)),[]),ul=o.useMemo(()=>{if(!v?.path)return[ec(u,{fontSize:Zn})];const i=io(v.path),f=[ec(u,i?{syntaxColors:!1,fontSize:Zn}:{fontSize:Zn})],w=Kr??Ka;w&&f.push(w),i&&f.push(eh({language:i,themeName:nh(u),theme:th(u)})),te&&f.push(Ge.lineWrapping);const S=u.colors.syntax.highlights;return f.push(Kp({added:S?.diffAdded??u.colors.status.success,modified:S?.diffModified??u.colors.status.info,removed:S?.diffRemoved??u.colors.status.error},{revert:t("filesView.editor.gitHunk.revert"),close:t("filesView.editor.gitHunk.close")}),mh({highlightWordAroundCursor:!0,minSelectionLength:2}),al,Ap(),ug(),cl),mg(v.path)&&f.push(pg(t("filesView.editor.jsonSyntaxError"),{error:u.colors.status.error,tooltipBackground:u.colors.surface.elevated,tooltipForeground:u.colors.surface.elevatedForeground,border:u.colors.interactive.border})),h||f.push(Dp(),Vp({vimMode:ps==="vim"}),xg()),h&&f.push(Ge.updateListener.of(j=>{j.view.hasFocus&&(j.selectionSet||j.focusChanged||j.viewportChanged||j.geometryChanged)&&window.requestAnimationFrame(()=>{ks(j.view)})})),f},[u,v?.path,Kr,Ka,te,h,ks,Zn,al,ps,t,cl]),dl=o.useMemo(()=>({light:nc(br),dark:nc(gi)}),[br,gi]),fl=An||Vi||Li,Pd=o.useMemo(()=>v?.path&&fl?{runtime:L,path:v.path,directory:g||"",revision:String(Qt),outsideWorkspace:qt.allowOutsideWorkspace}:null,[L,v?.path,fl,g,Qt,qt.allowOutsideWorkspace]),Xr=km(),Dd=o.useMemo(()=>v?.path&&nn&&Oe==="preview"&&!c.isVSCode&&!Xr?{path:v.path,directory:g||"",revision:String(Qt),outsideWorkspace:qt.allowOutsideWorkspace}:null,[v?.path,nn,Oe,c.isVSCode,Xr,g,Qt,qt.allowOutsideWorkspace]),Hi=t("filesView.error.readFileFailed"),rn=Zw(Dd,Hi),ml=o.useRef(null),Yr=nx({frameRef:ml,directory:g,pageKey:rn.status==="ready"?rn.url:""}),Ad=!h&&rn.status==="ready",or=o.useRef(null);o.useEffect(()=>{(Oe!=="preview"||or.current!==v?.path)&&(or.current=null)},[Oe,v?.path]),o.useEffect(()=>{rn.status==="error"?Pe(rn.message):rn.status==="ready"&&Pe(null)},[rn,Pe]);const Ki=ex(Pd,Pe,Hi),Gi=Ki.loading,Vd=v?.path&&jt?It?`data:${Hc(v.path)};utf8,${encodeURIComponent(_)}`:$u:"",qi=Ki.src,Jr=v&&a.downloadFile?r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>{const i=a.downloadFile;!i||!v||i(v.path,qt).catch(f=>{console.error("Download failed:",f),re.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(ee,{name:"download",className:"me-2 size-4"}),t("filesView.editor.saveFile")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.downloadCopy")})]}):null,Ns=o.useCallback(async(i,f)=>{const w=St(i),S=await pr("/api/fs/raw",{signal:f,cache:"no-store",query:{path:i,allowOutsideWorkspace:w.allowOutsideWorkspace?"true":void 0,directory:g||void 0}});if(!S.ok)throw new Error(t("filesView.error.readFileFailed"));return S},[St,g,t]),Ld=o.useCallback(async()=>{const i=at.current;if(!i)throw new Error("No file is open.");const f=await Ns(i,AbortSignal.timeout(6e4));return new Uint8Array(await f.arrayBuffer())},[Ns]),Xi=h?lo:ah,hl=o.useCallback(async(i,f)=>{const w=AbortSignal.any([f,AbortSignal.timeout(6e4)]),S=await Ns(i,w),j=await Ro(S,lo,w);return new Uint8Array(await j.arrayBuffer())},[Ns]),Od=o.useCallback(async(i,f)=>{const w=AbortSignal.any([f,AbortSignal.timeout(3e5)]),S=await Ns(i,w),j=await Ro(S,Xi,w);return new Uint8Array(await j.arrayBuffer())},[Ns,Xi]),Yi=async i=>{if(!v)return;const{markdownToDocx:f,markdownToPrintableHtml:w,printHtml:S,rowsToXlsx:j}=await zo(async()=>{const{markdownToDocx:ae,markdownToPrintableHtml:Ue,printHtml:He,rowsToXlsx:je}=await import("./documentExport-C830mU4N.js");return{markdownToDocx:ae,markdownToPrintableHtml:Ue,printHtml:He,rowsToXlsx:je}},__vite__mapDeps([227,3,2,228,104,105,106,5,6,107,108,109,103,33,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,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,1,4,7,8,9,10,11,12,93,94,95,96,97,98,99,100,101,102,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,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,213,214,215,216,217,183,218,219,220,221,222,223,224]));if(i==="pdf"){S(w(ye,v.name));return}const O=nr?bu(ye,Uo(v.path),Number.MAX_SAFE_INTEGER):null,Z=O?await j(v.name,[O.header,...O.rows]):await f(ye),we=v.path.replace(/\.[^./\\]+$/,"");let Ne=`${we}.${i}`;for(let ae=2;ae<1e3&&await Lt(Ne).catch(()=>null);ae+=1)Ne=`${we} ${ae}.${i}`;const he=Ne.split(/[/\\]/).pop()??Ne;if(!a.uploadFile){const ae=URL.createObjectURL(new Blob([Z]));Object.assign(document.createElement("a"),{href:ae,download:he}).click(),URL.revokeObjectURL(ae);return}try{if(!(await a.uploadFile(Ne,new Blob([Z]),{overwrite:!1}))?.success)throw new Error("write failed");re.success(t("filesView.export.saved",{name:he}))}catch{re.error(t("filesView.toast.writeFileFailed"))}},Id=o.useCallback(async(i,f)=>{if(!a.uploadFile||(at.current===i&&(gt.current=null),!(await a.uploadFile(i,new Blob([f]),{overwrite:!0}))?.success))return!1;if(g&&Ps(i,g)){const S=On(g,i);S&&Ul.requestGitRefresh({directory:g,paths:[S]})}return!0},[a,g]),zd=v&&To()?r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>{fr(v.path).then(i=>{i||re.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(ee,{name:"external-link",className:"me-2 size-4"}),t("sidebarFilesTree.menu.openInDefaultApp")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.openOutside")})]}):null,Qr=r.jsxs(r.Fragment,{children:[Jr,zd]}),Zr=v&&!Be&&!Gi&&!lt?(i=>{if(jt&&!Ai)return r.jsx(Hw,{src:Vd,name:i.name,sizeBytes:H,neighbors:yd,onRetry:_r,download:Jr});if(An)return r.jsx(Rw,{src:qi,name:i.name,sizeBytes:H,download:Jr});if(Vi)return r.jsx(qw,{kind:$a?"video":"audio",src:qi,renewSrc:Ki.renew,name:i.name,sizeBytes:H,download:Jr});if(Li)return r.jsx(Lw,{src:qi,name:i.name,sizeBytes:H});if(xs){const f=H!==null&&H>lo;return Xl(i.path)&&!f?r.jsx(kg,{name:i.name,path:i.path,sizeBytes:H,loadBytes:hl,actions:Qr},`${i.path}:${Qt}`):(Fo(i.path)||cr(i.path))&&!(H!==null&&H>Xi)?r.jsx(sw,{name:i.name,path:i.path,sizeBytes:H,loadBytes:Od,actions:Qr},`${i.path}:${Qt}`):Yl(i.path)&&!f?r.jsx(Cw,{name:i.name,path:i.path,sizeBytes:H,loadBytes:hl,actions:Qr,onSave:a.uploadFile&&!En?Id:void 0},`${i.path}:${Qt}`):r.jsx(hi,{name:i.name,path:i.path,sizeBytes:H,download:Qr,description:Yl(i.path)||Xl(i.path)||Fo(i.path)||cr(i.path)?t("filesView.artifact.office.tooLarge"):void 0})}return Hr&&et==="table"?r.jsx(pw,{content:_,sizeBytes:H}):nr&&et==="table"?r.jsx(Gg,{path:i.path,content:dt?ye:_,sizeBytes:H,onContentChange:dt?We:void 0},i.path):Ss&&Nt==="preview"?r.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:r.jsx(si,{fallback:r.jsxs("div",{className:"m-3 rounded-md bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:r.jsx(hr,{content:`\`\`\`mermaid
|
|
82
82
|
${_}
|
|
83
83
|
\`\`\``,className:"markdown-mermaid-fullscreen h-full",enableFileReferences:!1})})}):null})(v):null,pl=pe?r.jsx("div",{className:"h-full"}):r.jsx(Sn,{label:t("filesView.artifact.state.loading")}),gl=i=>r.jsx(dn,{icon:r.jsx(ee,{name:"error-warning",className:"size-10 text-[color:var(--status-error)]"}),title:t("filesView.artifact.state.readFailed",{name:i.name}),description:lt&<!==Hi?lt:void 0,actions:r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:_r,children:[r.jsx(ee,{name:"refresh",className:"me-2 size-4"}),t("filesView.artifact.state.retry")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.retryFile")})]})});o.useEffect(()=>{let i=!1,f="";return(async()=>{if(!v?.path||!jt||It){gn("");return}Pe(null);const S=St(v.path);if(i)return;await(a.readFileBinary?a.readFileBinary(v.path,S).then(O=>O.dataUrl):(async()=>{const O=await pr("/api/fs/raw",{signal:AbortSignal.timeout(3e4),query:{path:v.path,allowOutsideWorkspace:S.allowOutsideWorkspace?"true":void 0,directory:g||void 0}});if(!O.ok)throw new Error(t("filesView.error.readFileFailed"));const Z=await O.blob();return f=URL.createObjectURL(Z),i?(URL.revokeObjectURL(f),f="",""):f})()).then(O=>{i||(gn(O),Qe(v.path))}).catch(O=>{i||(gn(""),Pe(O instanceof Error?O.message:t("filesView.error.readFileFailed")),Is(v.path))}).finally(()=>{i||Vt(!1)})})(),()=>{i=!0,f&&URL.revokeObjectURL(f)}},[Qt,a,jt,It,St,g,v?.path,qt,t]);const $d=o.useCallback(()=>ki(null),[]),Bd=o.useMemo(()=>Ym({drafts:ja,editingDraftId:Ar,commentText:Dr,onTextChange:xa,selection:ut,isDragging:ka,fileLabel:v?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:i=>({start:i.startLine,end:i.endLine}),onSave:Na,onCancel:()=>{Xn(null),Zs()},onEdit:i=>{Sa(i),Xn({start:i.startLine,end:i.endLine})},onDelete:Ca}),[Zs,Dr,Ca,Ar,ja,Na,ka,ut,v?.path,xa,Sa]),wl=hc(),xl=hc(),ei=!Be&&!lt&&Te===Ae,Ji=o.useMemo(()=>!!Ae&&Ep({hasCanvas:Wt,viewMode:Je,previewReady:ei,mountable:rr}),[rr,Je,Wt,ei,Ae]),ti=ei&&ir&&se==="view"&&!(ys&&de==="tree"),bl=ei&&ft&&js()==="preview",{setScroller:vl,restore:_d}=ai(ti?`${Rn}:code`:null),{setScroller:yl,restore:Wd}=ai(ti?`${Rn}:code:fullscreen`:null),{setScroller:Sl}=ai(bl?`${Rn}:markdown`:null),{setScroller:Cl}=ai(bl?`${Rn}:markdown:fullscreen`:null),{setScroller:jl}=wl,{setScroller:kl}=xl,Ud=o.useCallback(i=>{jl(i),vl(i)},[jl,vl]),Hd=o.useCallback(i=>{kl(i),yl(i)},[kl,yl]),Kd=o.useCallback(i=>{ga.current=i,Ys.current=i,Sl(i)},[Sl]),Gd=o.useCallback(i=>{Js.current=i,Cl(i)},[Cl]),qd=o.useCallback(i=>{A&&nt.getState().openContextFile(A,i)},[A]),Xd=ft&&_e==="preview"&&!Be,Yd=u.metadata.variant==="light"?"light":"dark",El=Km({filePath:v?.path??null,workspaceRoot:g||null,onOpenFile:qd,enabled:Xd,colorScheme:Yd}),Qi=Hm("unified"),yn=ye.length>Eu,Zi=o.useMemo(()=>yn&&ti?Cp(ye):void 0,[ti,ye,yn]),Nl=o.useCallback((i,f,w,S)=>{const j={name:i.name,contents:f,lang:Uh(io(i.path))},O=Z=>r.jsx(Zm,{file:yn&&Zi?{...j,cacheKey:`${i.path}:${Zi}`}:j,options:{disableFileHeader:!0,overflow:te?"wrap":"scroll",theme:dl,themeType:u.metadata.variant==="dark"?"dark":"light",preferredHighlighter:Hh,onPostRender:S},className:yn?"block w-full":"block h-full w-full",style:yn?void 0:{height:"100%"}},Z);return yn?r.jsx("div",{className:"h-full",children:r.jsx(sh.Provider,{value:w.virtualizer,children:r.jsx(rh.Provider,{value:Qi,children:O(`${i.path}:${Qi?"pool":"pending"}`)})})}):r.jsx("div",{className:"h-full",children:O(i.path)})},[u.metadata.variant,yn,Zi,dl,Qi,te]),Fl=({exitFullscreenOnly:i=!1,layout:f="floating"}={})=>{if(!v)return null;const w=f==="docked",S=ri(ii("save_file",Fr)),j=async ie=>{if(!(await wr(_)).ok){re.error(t("filesView.toast.copyFailed"));return}if(ie){re.success(t("filesView.editor.toast.contentsCopied"));return}sa(!0),Hs.current!==null&&window.clearTimeout(Hs.current),Hs.current=window.setTimeout(()=>{sa(!1)},1200)},O=async ie=>{if(!(await wr(Jn)).ok){re.error(t("filesView.toast.copyFailed"));return}if(ie){re.success(t("sidebarFilesTree.toast.pathCopied"));return}ra(!0),Ks.current!==null&&window.clearTimeout(Ks.current),Ks.current=window.setTimeout(()=>{ra(!1)},1200)},Z=()=>{const ie=a.downloadFile;ie&&ie(v.path,qt).catch(Fs=>{console.error("Download failed:",Fs),re.error(t("sidebarFilesTree.toast.operationFailed"))})},we=()=>{Ee?Fn():_.trim()&&fe(_)},Ne=async()=>{await vn()&&(Zo(!0),setTimeout(()=>Zo(!1),1500))},he=async()=>{const ie=Jo.current?.getXml();if(Mt.current&&(clearTimeout(Mt.current),Mt.current=null),v?.path&&ie){if(!await Wi(v.path,ie))return;Nr(!0),setTimeout(()=>Nr(!1),1500)}},ae=r.jsxs(r.Fragment,{children:[r.jsxs(dr,{className:"flex items-center gap-2",onClick:()=>{v?.path&&fr(v.path).then(ie=>{ie||re.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(ee,{name:"external-link",className:"size-4"}),r.jsx("span",{className:"typography-ui-label text-foreground",children:t("sidebarFilesTree.menu.openInDefaultApp")})]}),ma.length>0?r.jsx(uu,{}):null,ma.map(ie=>r.jsxs(dr,{className:"flex items-center gap-2",onClick:()=>{rd(ie)},children:[r.jsx(ee,{name:ie.icon,className:"size-4"}),r.jsx("span",{className:"typography-ui-label text-foreground",children:ie.label})]},ie.id)),td?r.jsxs(dr,{className:"flex items-center gap-2",onClick:()=>{nd(!0)},children:[r.jsx(ee,{name:"refresh",className:"size-4"}),r.jsx("span",{className:"typography-ui-label text-foreground",children:t("filesView.editor.refreshApps")})]}):null]}),Ue=Qn&&!(Wt&&vs)&&(dt||ft||sn||Wt),He=ft&&js()==="preview",je=()=>{Cs||(Wt?tl("edit"):sn?el("edit"):ft?qa("edit"):nn?_i("edit"):ys?Za("text"):It?Xa("edit"):Ss?Ya("edit"):sr?Ja("text"):Ga("edit"))},ts=t("documentToolbar.preview"),Ve=(ie,Fs)=>({id:"mode",label:ts,icon:"eye",pressed:ie,onSelect:()=>Fs(!ie),pinned:!0}),xt=Wt?vs?null:Ve(Je==="preview",ie=>tl(ie?"preview":"edit")):sn?Ve(oe==="preview",ie=>el(ie?"preview":"edit")):ft?Ve(He,ie=>qa(ie?"preview":"edit")):nn?Ve(Td()==="preview",ie=>_i(ie?"preview":"edit")):It?Ve(ot==="preview",ie=>Xa(ie?"preview":"edit")):Ss?Ve(Nt==="preview",ie=>Ya(ie?"preview":"edit")):sr?{id:"mode",label:Hr?ts:t("documentToolbar.tableView"),icon:Hr?"eye":"table-2",pressed:et==="table",onSelect:()=>Ja(et==="table"?"text":"table"),pinned:!0}:ys?{id:"mode",label:t("documentToolbar.treeView"),icon:"node-tree",pressed:de==="tree",onSelect:()=>Za(de==="tree"?"text":"tree"),pinned:!0}:ir&&dt?Ve(se==="view",ie=>Ga(ie?"view":"edit")):null,on=nn&&!h&&!c.isVSCode&&!Xr?{id:"annotate",label:t("contextPanel.browser.annotate.toggle"),icon:"markup",pressed:Yr.isAnnotating,onSelect:()=>{if(Ad){Yr.toggle();return}or.current=v.path,_i("preview")},pinned:!0}:null,no=He?Tr:Cs&&z,ni=Ue&&!(nr&&et==="table")?{id:"search",label:t("filesView.editor.findInFile"),icon:"search",shortcut:ri(ii("find_in_file",Fr),""),pressed:no,onSelect:()=>{if(He){if(Tr){Xs(!1);return}Xs(!0),aa(ie=>ie+1);return}je(),X(!no)}}:null,Ol=Ue?{id:"go-to-line",label:t("filesView.editor.goToLine"),icon:"hashtag",shortcut:ri(ii("open_go_to_line",Fr),""),pressed:ia,onSelect:()=>{je(),Rr(ie=>!Cs||!ie)},buttonAttributes:{"data-go-to-line-toggle":""}}:null,tf=Ue&&!h?{id:"symbols",label:t("filesView.editor.symbols"),icon:"braces",shortcut:ri(ii("open_document_symbols",Fr),""),pressed:Fi,onSelect:()=>{je(),qs(ie=>!Cs||!ie)},buttonAttributes:{"data-document-symbols-toggle":""}}:null,nf=Qn?{id:"wrap",label:t("documentToolbar.wrapLines"),icon:"text-wrap",pressed:te,onSelect:()=>Le(!te)}:null,sf=ft&&id?{id:"read-aloud",label:t(Ee?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),icon:"volume-up",iconClassName:Ee?"text-[var(--primary-text)]":void 0,onSelect:we}:null,so=t("filesView.editor.copyFilePathTitle",{path:Jn}),Il=w&&!!Jn&&!h,zl=Il&&Ha,rf={id:"comment-on-file",label:t("inlineComment.actions.commentOnFile"),icon:"chat-1",pressed:gs.isOpen,onSelect:gs.toggle},of=[To()&&{id:"open-in-app",label:t("filesView.editor.openInDesktopApp"),icon:"external-link",menu:ae},Sd&&{id:"copy-contents",label:t("filesView.editor.copyFileContents"),icon:"file-copy",done:ed,onSelect:()=>{j(!1)},onMenuSelect:()=>{j(!0)}},Ha&&!zl&&{id:"copy-path",label:so,icon:"link",done:Ni,onSelect:()=>{O(!1)},onMenuSelect:()=>{O(!0)}},!!a.downloadFile&&{id:"download",label:t("filesView.editor.saveFile"),icon:"download",onSelect:Z},ft&&{id:"export-word",label:t("filesView.export.word"),icon:"download",onSelect:()=>{Yi("docx")}},ft&&!h&&{id:"export-pdf",label:t("filesView.export.pdf"),icon:"download",onSelect:()=>{Yi("pdf")}},nr&&{id:"export-excel",label:t("filesView.export.excel"),icon:"download",onSelect:()=>{Yi("xlsx")}}],af=i?{id:"fullscreen",label:t("filesView.editor.exitFullscreen"),icon:"fullscreen-exit",onSelect:()=>Xe(!1),pinned:!0}:!h&&n==="full"?{id:"fullscreen",label:t(J?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),icon:J?"fullscreen-exit":"fullscreen",onSelect:()=>Xe(!J),pinned:!0}:null,lf=dt&&Qn?{id:"auto-save",label:t("documentToolbar.autoSave"),icon:"save-3",pressed:Zt,onSelect:()=>Ku(!Zt)}:null,cf=Wt&&Je==="preview"?r.jsx(Ln,{label:t("filesView.fileEditor.save"),icon:"save-3",done:Hu,onClick:()=>{Ne()}}):sn&&oe==="preview"?r.jsx(Ln,{label:t("filesView.diagram.saveDiagram"),icon:"save-3",done:Uu,onClick:()=>{he()}}):cs?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[r.jsx(ee,{name:"loader-4",className:"size-3.5 animate-spin"}),t("filesView.editor.saving")]}):Zt&&Wu==="saved"&&!Dt?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[r.jsx(ee,{name:"check",className:"size-3.5"}),t("filesView.editor.saved")]}):Dt?r.jsx(Ln,{label:t(Zt?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:S}),icon:"save-3",onClick:()=>{vn()}}):null,uf=dt&&Qn||Wt||sn?cf:null,$l=r.jsx(rm,{className:w?"flex-1":void 0,start:w?Il?zl?r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>{O(!1)},"aria-label":so,className:"group/path flex min-w-0 flex-1 items-center text-start typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:text-foreground focus-visible:outline-none",children:r.jsx(uc,{path:Jn,title:null,trailing:r.jsx(ee,{name:Ni?"check":"file-copy",className:ce("size-3 shrink-0 transition-opacity",Ni?"text-[color:var(--status-success)] opacity-100":"opacity-0 group-hover/path:opacity-100 group-focus-visible/path:opacity-100")})})})}),r.jsx(it,{side:"bottom",sideOffset:6,children:r.jsx(im,{label:so})})]}):r.jsx(uc,{path:Jn,className:"typography-meta text-muted-foreground"}):null:void 0,status:uf,inline:Ue?r.jsx(Yh,{open:ia,onOpenChange:Rr,viewRef:ct,variant:"inline"}):null,groups:[[xt,on],[ni,rf]],menuOnly:[Ol,tf,nf,sf,...of,lf],trailing:[af],fold:w,onMenuOpenChange:Y});return w?$l:r.jsx("div",{className:"pointer-events-auto rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",children:$l})},Rl=o.useRef(null);o.useEffect(()=>{Te&&(Bs.current&&Rl.current===Te&&ze(i=>i+1),Rl.current=Te)},[Te]);const Tl=o.useCallback(i=>{const f=at.current;f&&(vt.current[f]="edit"),Jt(!1),Re("edit"),re.error(i)},[]),Ml=n==="full"&&J,Jd=v?`${Os??v.path}:${me}:${Ml?"fullscreen":"docked"}`:"",Pl=Ji&&v&&wt?r.jsx("div",{ref:ea,className:"h-full overflow-hidden",style:{minHeight:"400px"},children:r.jsx(Np,{ref:us,guestId:wt.guestId,editorId:wt.editor.id,title:wt.editor.title,contentKind:vs?"binary":"text",path:Jn||v.path,content:ye,loadBytes:Ld,readOnly:!v||En||!a.writeFile||vs&&!a.uploadFile,onDirtyChange:Jt,onEdit:()=>{ta.current=Date.now()},onSaveRequest:Da,onUnsupported:Rd,onTooLarge:()=>Tl(t("filesView.fileEditor.tooLarge",{editor:wt.editor.title})),onLoadFailed:()=>Tl(t("filesView.error.readFileFailed"))},`${Jd}:${wt.guestId}:${wt.editor.id}`)}):null,Qd=o.useCallback(()=>{const i=nt.getState();i.requestSettingsJump("integrations","integrations.extensions.excalidraw"),i.setSettingsDialogOpen(!0)},[]),Dl=gs.editor||gs.cards?r.jsxs(un,{outerClassName:"max-h-[50%] shrink-0 border-b border-edge-muted",disableHorizontal:!0,children:[gs.editor,gs.cards]}):null,eo=r.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[r.jsx(eu,{open:Ci,onOpenChange:i=>{i||_s(!0)},children:r.jsxs(tu,{showCloseButton:!1,className:"max-w-md",children:[r.jsxs(nu,{children:[r.jsx(su,{children:t("filesView.unsaved.title")}),r.jsx(ru,{children:t("filesView.unsaved.description")})]}),r.jsxs(iu,{children:[r.jsx(Se,{variant:"outline",onClick:()=>{md()},disabled:cs,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[var(--status-success)]/20",children:t("filesView.unsaved.saveChanges")}),r.jsx(Se,{variant:"destructive",onClick:fd,children:t("filesView.unsaved.discard")})]})]})}),r.jsxs("div",{className:ce("flex flex-col flex-shrink-0",q&&"border-b border-edge-muted"),children:[q?r.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[h&&K&&r.jsx("button",{type:"button",onClick:()=>G(!1),"aria-label":t("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center me-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:r.jsx(ee,{name:"arrow-left-s",className:"size-5"})}),h?v?r.jsxs(ou,{children:[r.jsx(au,{asChild:!0,children:r.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-start typography-ui-label font-medium","aria-label":t("filesView.editor.openFilesAria"),children:[r.jsx(ln,{filePath:v.path,extension:v.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(Bc,{name:v.name,folder:as(v.path)}),r.jsx(ee,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),r.jsx(lu,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Bt.map(i=>{const f=v?.path===i.path;return r.jsxs(dr,{onSelect:w=>{if(w.target.closest("[data-close-open-file]")){w.preventDefault();return}f||Ot(i)},className:ce("flex min-w-0 items-center justify-between gap-2 overflow-hidden",f&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx(ln,{filePath:i.path,extension:i.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(Bc,{name:i.name,folder:as(i.path)})]}),r.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:w=>{w.preventDefault(),w.stopPropagation()},onClick:w=>{w.preventDefault(),w.stopPropagation(),er(i.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":t("filesView.editor.closeFileAria",{name:i.name}),children:r.jsx(ee,{name:"close",className:"size-3.5"})})]},i.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")}):Bt.length>0?r.jsxs("div",{className:"relative min-w-0 flex-1",children:[Sr.start&&r.jsx("div",{className:"pointer-events-none absolute inset-s-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r rtl:bg-gradient-to-l from-background to-transparent"}),Sr.end&&r.jsx("div",{className:"pointer-events-none absolute inset-e-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l rtl:bg-gradient-to-r from-background to-transparent"}),r.jsx("div",{ref:Vs,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Bt.map(i=>{const f=v?.path===i.path,w=as(i.path);return r.jsxs("div",{className:ce("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",f?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[r.jsx(ln,{filePath:i.path,extension:i.extension,className:"size-3.5 flex-shrink-0"}),r.jsx("button",{type:"button",onClick:()=>{f||Ot(i)},title:On(g,i.path),className:ce(!w&&"max-w-[12rem]","truncate text-start"),children:r.jsx(zu,{name:i.name,folder:w})}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),er(i.path)},className:ce("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!f&&!M&&"opacity-0 group-hover:opacity-100"),"aria-label":t("filesView.editor.closeFileAria",{name:i.name}),children:r.jsx(ee,{name:"close",className:"size-3.5"})})}),r.jsx(it,{side:"bottom",sideOffset:6,children:t("filesView.editor.closeFileAria",{name:i.name})})]})]},i.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")})]}):null,v?r.jsx("div",{className:"flex h-8 min-w-0 shrink-0 items-center border-t border-edge-muted px-2",children:Fl({layout:"docked"})}):null]}),!(n==="full"&&J)&&Dl,kd?r.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-edge-muted bg-[var(--surface-muted)] px-3 py-1.5 typography-ui text-muted-foreground",children:[r.jsx(ee,{name:"information",className:"size-4 shrink-0"}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:t("filesView.excalidraw.installHint")}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx(Se,{type:"button",size:"xs",variant:"outline",onClick:Qd,children:t("filesView.excalidraw.installAction")})}),r.jsx(it,{side:"bottom",sideOffset:6,children:t("contextTooltips.files.excalidrawSettings")})]})]}):null,r.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:r.jsx(un,{ref:Ud,outerClassName:"h-full min-w-0",className:ce("h-full min-w-0",yn&&"[overflow-anchor:none]"),children:v?Be||Gi?pl:lt?gl(v):Ji?Ml?r.jsx("div",{className:"h-full"}):Pl:Zr||(v&&sn&&oe==="preview"?r.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:r.jsx(kp,{ref:Jo,xml:Fd,onChange:Nd},`${Os??v.path}:${Ie}`)}):v&&ys&&de==="tree"?r.jsx(si,{fallback:r.jsxs("div",{className:"rounded-md bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.jsonViewerUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToTextMode")})]}),children:r.jsx("div",{className:"h-full",children:r.jsx(Qm,{className:"h-full",jsonString:_,format:"jsonc",maxHeight:"100%",initiallyExpandedDepth:2})})}):v&&ft&&js()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview overlay-scrollbar-target overlay-scrollbar-container h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Mr,ref:Kd,children:[r.jsx(tc,{containerRef:ga,filePath:v.path,fileContent:_}),_.length>500*1024&&r.jsx("div",{className:"mb-3 rounded-md bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:t("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(_.length/1024)})}),r.jsx(si,{fallback:r.jsxs("div",{className:"rounded-md bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:r.jsx("div",{style:nl,children:r.jsx(hr,{content:_,documentAssets:El,className:"typography-markdown-body",frontmatter:"properties",enableFileReferences:!1,allowRawHtml:!0,windowed:!0,tableWidthScope:v.path})})})]}),r.jsx(ql,{containerRef:Ys}),!J&&r.jsx(fc,{containerRef:Ys,open:Tr,onOpenChange:Xs,focusNonce:oa})]}):v&&nn&&Oe==="preview"&&Xr?r.jsx(dn,{icon:r.jsx(ln,{filePath:v.path,className:"size-10"}),title:t("filesView.editor.htmlPreviewRelayUnavailable"),actions:r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>{Kt.current[v.path]="edit",Ye("edit")},children:t("filesView.editor.htmlPreviewShowCode")})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.showCodeForFile")})]})}):v&&nn&&Oe==="preview"?!c.isVSCode&&rn.status==="loading"?r.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:t("common.loading")}):r.jsx("div",{className:"h-full overflow-hidden",children:r.jsx("iframe",{ref:ml,onLoad:()=>{or.current===v.path&&(or.current=null,Yr.isAnnotating||Yr.toggle())},src:rn.status==="ready"?rn.url:void 0,srcDoc:c.isVSCode?(()=>{const i=v.path.substring(0,v.path.lastIndexOf("/")+1);return i?_.replace(/<head([^>]*)>/i,`<head$1><base href="${i}">`):_})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-forms allow-popups allow-modals allow-downloads",title:t("filesView.editor.htmlPreviewTitle")})}):v&&ir&&se==="view"?Nl(v,ye,wl,_d):r.jsxs("div",{className:ce("relative h-full",bs&&"overflow-hidden"),ref:Gs,children:[!J&&r.jsx(dc,{open:Fi,onOpenChange:qs,viewRef:ct}),r.jsx("div",{className:ce("h-full",bs&&"invisible"),children:r.jsx(Wc,{positionKey:Rn,detached:!e,value:ye,onChange:We,readOnly:!dt,vimMode:ps==="vim",extensions:ul,className:ce("h-full",h&&"oc-compact-search"),blockWidgets:Bd,onViewReady:i=>{ct.current=i,qr(i),ji(f=>f+1),window.requestAnimationFrame(()=>{ks(i)})},onViewDestroy:()=>{ct.current&&(ct.current=null),ji(i=>i+1)},enableSearch:!0,searchOpen:z,onSearchOpenChange:X,highlightLines:ut?{start:Math.min(ut.start,ut.end),end:Math.max(ut.start,ut.end)}:void 0,lineNumbersConfig:ld},Rn)}),bs&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(ee,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]})):r.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:t("filesView.editor.pickFileFromTree")})})})]}),Al=!!(g&&Nn[g]),to=g?Un[g]:null,Vl=Me.trim().length>0,Zd=Al&&!Q&&!Vl&&x.length===0&&!to,Ll=B?r.jsxs("section",{className:ce("flex min-h-0 flex-col overflow-hidden",h?"h-full w-full bg-background":"h-full rounded-xl border border-edge bg-background/70"),children:[r.jsx("div",{className:ce("flex flex-col gap-2 py-2",h?"px-3":"px-2"),children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1 min-w-0",children:[r.jsx(ee,{name:"search",className:"pointer-events-none absolute inset-s-2 top-2 size-4 text-muted-foreground"}),r.jsx(Ds,{ref:R,value:ue,onChange:i=>Ce(i.target.value),placeholder:t("filesView.tree.search.placeholder"),className:"h-8 ps-8 pe-8 typography-meta"}),ue.trim().length>0&&r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":t("filesView.tree.search.clearAria"),className:"absolute inset-e-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Ce(""),R.current?.focus()},children:r.jsx(ee,{name:"close",className:"size-4"})})}),r.jsx(it,{side:"bottom",sideOffset:6,children:t("filesView.tree.search.clearAria")})]})]}),r.jsx(Ln,{label:t("filesView.tree.actions.newFileTitle"),icon:"file-add",className:"size-8",iconClassName:"size-4",onClick:()=>Ri("createFile",{path:D,type:"directory"})}),r.jsx(Ln,{label:t("filesView.tree.actions.newFolderTitle"),icon:"folder-add",className:"size-8",iconClassName:"size-4",onClick:()=>Ri("createFolder",{path:D,type:"directory"})}),Fa&&r.jsx(Ln,{label:t("sidebarFilesTree.actions.uploadFilesTitle"),icon:Or?"loader-4":"upload-2",className:"size-8",iconClassName:ce("size-4",Or&&"animate-spin"),disabled:!g||Or,onClick:()=>Ra(g)}),r.jsx(ip,{className:"size-8",iconClassName:"size-4"}),r.jsx(Ln,{label:t("filesView.tree.actions.refreshTitle"),icon:"refresh",className:"size-8",iconClassName:"size-4",onClick:()=>{Lr()}})]})}),r.jsxs(un,{outerClassName:"flex-1 min-h-0",className:ce("@container py-2",h?"px-3":"px-2"),children:[r.jsx("ul",{ref:Di,className:ce("relative flex flex-col",Zd&&"w-max min-w-full"),children:Q?r.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx(ee,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.tree.search.searching")]}):Vl&&x.length===0?r.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("mobile.files.search.empty")}):x.length>0?x.map(i=>{const f=v?.path===i.path;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>{Ot(i)},className:ce("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",cu(f)),children:[r.jsx(ln,{filePath:i.path,extension:i.extension,className:"size-3.5"}),r.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},title:i.path,children:i.relativePath??i.path})]})},i.path)}):to?r.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx("span",{className:"text-[var(--status-error)]",children:to}),r.jsxs(st,{children:[r.jsx(rt,{asChild:!0,children:r.jsxs(Se,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Lr()},children:[r.jsx(ee,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})}),r.jsx(it,{sideOffset:6,children:t("contextTooltips.files.retryFileList")})]})]}):Al?za(g,0):r.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("filesView.state.loading")})}),r.jsx(sm,{containerRef:Di})]})]}):null,ef=n==="full"&&J&&v&&r.jsxs("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:[Dl,r.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[r.jsx("div",{className:"absolute inset-e-4 top-4 z-30",children:Fl({exitFullscreenOnly:!0})}),r.jsx(un,{ref:Hd,outerClassName:"h-full min-w-0",className:ce("h-full min-w-0",yn&&"[overflow-anchor:none]"),children:Be||Gi?pl:lt?gl(v):Ji?Pl:Zr||(ft&&js()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview overlay-scrollbar-target overlay-scrollbar-container h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Mr,ref:Gd,children:[v?r.jsx(tc,{containerRef:Js,filePath:v.path,fileContent:_}):null,_.length>500*1024&&r.jsx("div",{className:"mb-3 rounded-md bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:t("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(_.length/1024)})}),r.jsx(si,{fallback:r.jsxs("div",{className:"rounded-md bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:r.jsx("div",{style:nl,children:r.jsx(hr,{content:_,documentAssets:El,className:"typography-markdown-body",frontmatter:"properties",enableFileReferences:!1,allowRawHtml:!0,windowed:!0,tableWidthScope:v.path})})})]}),r.jsx(ql,{containerRef:Js}),r.jsx(fc,{containerRef:Js,open:Tr,onOpenChange:Xs,focusNonce:oa,className:"inset-e-4 top-16"})]}):ir&&se==="view"?Nl(v,ye,xl,Wd):r.jsxs("div",{className:ce("relative h-full",bs&&"overflow-hidden"),children:[r.jsx(dc,{open:Fi,onOpenChange:qs,viewRef:ct}),r.jsx("div",{className:ce("h-full",bs&&"invisible"),children:r.jsx(Wc,{positionKey:`${Rn}:fullscreen`,value:ye,onChange:We,readOnly:!dt,vimMode:ps==="vim",extensions:ul,className:ce("h-full",h&&"oc-compact-search"),onViewReady:i=>{ct.current=i,qr(i),window.requestAnimationFrame(()=>{ks(i)})},onViewDestroy:()=>{ct.current&&(ct.current=null)}},`${Rn}:fullscreen`)}),bs&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(ee,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]}))})]})]});return r.jsxs("div",{ref:Oa,"data-find-surface":"",className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[r.jsx(fx,{activeDialog:Gn,dialogData:qn,dialogInputValue:Pn,onDialogInputChange:na,isDialogSubmitting:Xu,onDialogSubmit:dd,onClose:$d,inputRef:_u}),ud,ef,h?K?eo:Ll:n==="editor-only"?r.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:eo})}):r.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[E>=700&&r.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Ll}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-edge bg-background",children:eo})]})]})},Zx=Object.freeze(Object.defineProperty({__proto__:null,FilesView:hx},Symbol.toStringTag,{value:"Module"}));export{Zx as F,gr as n,dw as o};
|