@vantran-se/openchamber-web 2.0.9 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-DngoXxGT.js → CodeMirrorCommentWidgets-e9rY9Jxg.js} +1 -1
- package/dist/assets/{DiffView-UeB7OS2J.js → DiffView-rYnmKnFF.js} +1 -1
- package/dist/assets/{FilesView-Cs3Y7IF5.js → FilesView-DtzJk1Ke.js} +3 -3
- package/dist/assets/{GitView-DsJqHet1.js → GitView-DYd5gOSc.js} +1 -1
- package/dist/assets/{GuestAttachDialog-CN0FTkqY.js → GuestAttachDialog-Bsi0q3M9.js} +1 -1
- package/dist/assets/{GuestSurfacePane-BFbUwJOB.js → GuestSurfacePane-CYMRe3EI.js} +1 -1
- package/dist/assets/{JsonTreeView-B2artBdi.js → JsonTreeView-DIy-frOy.js} +1 -1
- package/dist/assets/{LinearIssuesView-DCcXvS3Q.js → LinearIssuesView-DDHJKaVb.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-Du-Ph58N.js → MarkdownImageGallery-BMQ4KHaO.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CnXfZsIi.js → MarkdownRendererImpl-CQi_ZSPc.js} +1 -1
- package/dist/assets/{OnboardingScreen-DdB_pV9d.js → OnboardingScreen-DiMFS3A7.js} +1 -1
- package/dist/assets/{PatchDiff-JvRN2s5u.js → PatchDiff-4jmPWx6l.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BOIbtTSo.js → PierreDiffViewer-DKHxCmze.js} +1 -1
- package/dist/assets/{PlanView-DYZs8zCF.js → PlanView-CN21khuJ.js} +1 -1
- package/dist/assets/{PluginPane-CaHXDA-2.js → PluginPane-Dx0_Dldo.js} +1 -1
- package/dist/assets/{SettingsView-CfFMLncG.js → SettingsView-CBGx68I6.js} +1 -1
- package/dist/assets/{SettingsWindow-0vSQTxkV.js → SettingsWindow-B8RpyNyO.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-DhLlAYSb.js → SubmoduleDiffSummary-hkelCkS-.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CdV4zEAG.js → ToolOutputDialog-UbbhHm0d.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-XL2mZzAG.js → ToolPartDiffPreview-7FbKWkeu.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-ACObo6xZ.js → VirtualizedFileDiff-DapU3oMs.js} +1 -1
- package/dist/assets/{WalkthroughView-B-3eK3lX.js → WalkthroughView-DhvkEmfP.js} +1 -1
- package/dist/assets/{appThemeRegistry-CgfpF2VR.js → appThemeRegistry-CWAKiwky.js} +1 -1
- package/dist/assets/{ar-SA-G6X2FPQ2-ChXWTl2B.js → ar-SA-G6X2FPQ2-DswVk5Qr.js} +1 -1
- package/dist/assets/{az-AZ-76LH7QW2-qjuQaC-s.js → az-AZ-76LH7QW2-DjkREsRV.js} +1 -1
- package/dist/assets/{bg-BG-XCXSNQG7-dsvyn4OJ.js → bg-BG-XCXSNQG7-DQo0fDKV.js} +1 -1
- package/dist/assets/{bn-BD-2XOGV67Q-BjdT9u1P.js → bn-BD-2XOGV67Q-CzA0IjiR.js} +1 -1
- package/dist/assets/{ca-ES-6MX7JW3Y-BTTmpcqZ.js → ca-ES-6MX7JW3Y-L92o9vc1.js} +1 -1
- package/dist/assets/{commitAndPush-dBUe7z8F.js → commitAndPush-D51hG7WM.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DfI7BTln.js → computeVirtualFileMetrics-BWISD0Ee.js} +1 -1
- package/dist/assets/{cs-CZ-2BRQDIVT-C5rG2tZX.js → cs-CZ-2BRQDIVT-BXRAPYTK.js} +1 -1
- package/dist/assets/{da-DK-5WZEPLOC-BOaJLF6Z.js → da-DK-5WZEPLOC-Be9eTSFu.js} +1 -1
- package/dist/assets/{de-DE-XR44H4JA-Dt-4U2No.js → de-DE-XR44H4JA-D7jcygnK.js} +1 -1
- package/dist/assets/{de-DoDk6ixL.js → de-Dzva6tmf.js} +1 -1
- package/dist/assets/{el-GR-BZB4AONW-CR60bCOY.js → el-GR-BZB4AONW-DWPB-4gi.js} +1 -1
- package/dist/assets/{es-uuDOJL65.js → es-Be7FJA1p.js} +1 -1
- package/dist/assets/{es-ES-U4NZUMDT-BxBSKTXR.js → es-ES-U4NZUMDT-BteMlYd0.js} +1 -1
- package/dist/assets/{eu-ES-A7QVB2H4-DCoZ1mko.js → eu-ES-A7QVB2H4-D3K4uMB7.js} +1 -1
- package/dist/assets/{fa-IR-HGAKTJCU-CGlSV3Cv.js → fa-IR-HGAKTJCU-D7LwSGvX.js} +1 -1
- package/dist/assets/{fi-FI-Z5N7JZ37-DjiU77q2.js → fi-FI-Z5N7JZ37-61Yx90sI.js} +1 -1
- package/dist/assets/{fr-C0viImM8.js → fr-CvtTZ_7n.js} +1 -1
- package/dist/assets/{fr-FR-RHASNOE6-tQI46EwI.js → fr-FR-RHASNOE6-BokbdDAr.js} +1 -1
- package/dist/assets/{gl-ES-HMX3MZ6V-UebXQim9.js → gl-ES-HMX3MZ6V-CfKWvFjV.js} +1 -1
- package/dist/assets/{he-IL-6SHJWFNN-CrEAMSem.js → he-IL-6SHJWFNN-BiuDhPeJ.js} +1 -1
- package/dist/assets/{hi-IN-IWLTKZ5I-CDElf1It.js → hi-IN-IWLTKZ5I-CBpbpt_D.js} +1 -1
- package/dist/assets/{hu-HU-A5ZG7DT2-BxrPciUB.js → hu-HU-A5ZG7DT2-YdbIKZJs.js} +1 -1
- package/dist/assets/{id-ID-SAP4L64H-BEUMSOdC.js → id-ID-SAP4L64H-B6lOIjuX.js} +1 -1
- package/dist/assets/{index-BW492zXv.js → index-BvpIhpBI.js} +1 -1
- package/dist/assets/{index-hsqFIGlo.js → index-CxBGclAj.js} +1 -1
- package/dist/assets/{isDiffPlainText-BrLxBox_.js → isDiffPlainText-DU3lrpLL.js} +1 -1
- package/dist/assets/{isFilePlainText-Cgi_4AsZ.js → isFilePlainText-udb3VTt2.js} +1 -1
- package/dist/assets/{it-IT-JPQ66NNP-DU7yvppw.js → it-IT-JPQ66NNP-Bmx3ltTW.js} +1 -1
- package/dist/assets/{ja-B9orD75V.js → ja-BPgcBIXr.js} +1 -1
- package/dist/assets/{ja-JP-DBVTYXUO-3JN7QvVc.js → ja-JP-DBVTYXUO-Ble1Hn10.js} +1 -1
- package/dist/assets/{kaa-6HZHGXH3-ZZvAjpex.js → kaa-6HZHGXH3-DZbQ2VK_.js} +1 -1
- package/dist/assets/{kab-KAB-ZGHBKWFO-C4wThQdT.js → kab-KAB-ZGHBKWFO-iJv1iHzt.js} +1 -1
- package/dist/assets/{kk-KZ-P5N5QNE5-DtGbDE5-.js → kk-KZ-P5N5QNE5-CVPa7-_X.js} +1 -1
- package/dist/assets/{km-KH-HSX4SM5Z-BBzQ-auj.js → km-KH-HSX4SM5Z-CG3n2D2z.js} +1 -1
- package/dist/assets/{ko-DMWq9y4E.js → ko-DavkJfF9.js} +1 -1
- package/dist/assets/{ko-KR-MTYHY66A-DKypF9JQ.js → ko-KR-MTYHY66A-4ypCzC-G.js} +1 -1
- package/dist/assets/{ku-TR-6OUDTVRD-D9ejnihQ.js → ku-TR-6OUDTVRD-rnEkr74f.js} +1 -1
- package/dist/assets/{lt-LT-XHIRWOB4-Dqmjn0mI.js → lt-LT-XHIRWOB4-CyRnYc4K.js} +1 -1
- package/dist/assets/{lv-LV-5QDEKY6T-UrP5oB7q.js → lv-LV-5QDEKY6T-ZRIiC6FR.js} +1 -1
- package/dist/assets/{main-xwL5wKzs.js → main-CrXZnahe.js} +2 -2
- package/dist/assets/{main-BjJBl7Nu.js → main-xs-JggnC.js} +4 -4
- package/dist/assets/{markdownCore-DSFyd8zF.js → markdownCore-CUxMtJCS.js} +1 -1
- package/dist/assets/{miniChat-DYbqo1MM.js → miniChat-BISrLEQj.js} +2 -2
- package/dist/assets/{mobile-BfD16Eag.js → mobile-C5yhjorl.js} +2 -2
- package/dist/assets/{mr-IN-CRQNXWMA-IPWmH5Ni.js → mr-IN-CRQNXWMA-UgSO2DIH.js} +1 -1
- package/dist/assets/{my-MM-5M5IBNSE-BLfvJLfS.js → my-MM-5M5IBNSE-D_F1DCJR.js} +1 -1
- package/dist/assets/{nb-NO-T6EIAALU-DpTcOSVU.js → nb-NO-T6EIAALU-oIGhTIX7.js} +1 -1
- package/dist/assets/{nl-NL-IS3SIHDZ-BnEpZrEO.js → nl-NL-IS3SIHDZ-cScIrIxG.js} +1 -1
- package/dist/assets/{nn-NO-6E72VCQL-cguGGiOn.js → nn-NO-6E72VCQL-CjEAl_Lv.js} +1 -1
- package/dist/assets/{oc-FR-POXYY2M6-DZRflDPj.js → oc-FR-POXYY2M6-1rehXYxp.js} +1 -1
- package/dist/assets/{pa-IN-N4M65BXN-B4LAi-bY.js → pa-IN-N4M65BXN-7iWEsMEJ.js} +1 -1
- package/dist/assets/{patchFileDiff-DkL8Aa2N.js → patchFileDiff-DzgiH2zi.js} +1 -1
- package/dist/assets/{percentages-BXMCSKIN-ChsKj3Ud.js → percentages-BXMCSKIN-nJkK2U43.js} +4 -4
- package/dist/assets/{pl-DOQ2hiXE.js → pl-DU7WIv6_.js} +1 -1
- package/dist/assets/{pl-PL-T2D74RX3-DIa8_Rxw.js → pl-PL-T2D74RX3-8-4_uRcY.js} +1 -1
- package/dist/assets/{pt-BR-5N22H2LF-CjvHq8Nl.js → pt-BR-5N22H2LF-5f518RJn.js} +1 -1
- package/dist/assets/{pt-BR-GRNT4bJk.js → pt-BR-nKukDIco.js} +1 -1
- package/dist/assets/{pt-PT-UZXXM6DQ-De7WYkMm.js → pt-PT-UZXXM6DQ-CX60-bds.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-COuZPzkA.js → renderElectronMiniChatApp-BsUuzGo8.js} +2 -2
- package/dist/assets/{renderMobileApp-BO162-O8.js → renderMobileApp-4lMkhU0J.js} +3 -3
- package/dist/assets/{ro-RO-JPDTUUEW-8cucu0w7.js → ro-RO-JPDTUUEW-WRbjlbWZ.js} +1 -1
- package/dist/assets/{ru-RU-B4JR7IUQ-C-EfBvoP.js → ru-RU-B4JR7IUQ-BOe15dMj.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-B_5A-WIc.js → runtimeEndpointReset-D56xMbiw.js} +19 -19
- package/dist/assets/{scheduledTasksApi-MxDvG-t3.js → scheduledTasksApi-BZMS2h6Z.js} +1 -1
- package/dist/assets/{shikiHighlight-B39UxQvQ.js → shikiHighlight-BPUnGgQg.js} +1 -1
- package/dist/assets/{si-LK-N5RQ5JYF-Dtp4SfIy.js → si-LK-N5RQ5JYF-DdWuRf76.js} +1 -1
- package/dist/assets/{sk-SK-C5VTKIMK-C2URq6ko.js → sk-SK-C5VTKIMK-C6bkxrp7.js} +1 -1
- package/dist/assets/{sl-SI-NN7IZMDC-DFa24yvi.js → sl-SI-NN7IZMDC-9Kz16LlM.js} +1 -1
- package/dist/assets/{subset-shared.chunk-DT8U7cSF.js → subset-shared.chunk-TyCa-VC5.js} +1 -1
- package/dist/assets/{subset-worker.chunk-DsFk1l-v.js → subset-worker.chunk-BEUpJy0_.js} +1 -1
- package/dist/assets/{sv-SE-XGPEYMSR-BW357iMU.js → sv-SE-XGPEYMSR-CEKYbCUy.js} +1 -1
- package/dist/assets/{ta-IN-2NMHFXQM-ByJpqKo_.js → ta-IN-2NMHFXQM-lt4RexfZ.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-Dmu3ECWz.js → textMateThemeFromAppTheme-AUvSJIJn.js} +1 -1
- package/dist/assets/{th-TH-HPSO5L25-oBYiL2Sw.js → th-TH-HPSO5L25-BTLJeK_p.js} +1 -1
- package/dist/assets/{tr-CcLlZCMC.js → tr-C7G7YZuM.js} +1 -1
- package/dist/assets/{tr-TR-DEFEU3FU-DuccnkGw.js → tr-TR-DEFEU3FU-D1x5-N8S.js} +1 -1
- package/dist/assets/{uk-DeV8vTnQ.js → uk-D-OHqF3o.js} +1 -1
- package/dist/assets/{uk-UA-QMV73CPH-EKbyzxQM.js → uk-UA-QMV73CPH-BoCWhdiB.js} +1 -1
- package/dist/assets/{useAppFontEffects-Cz-1Efdn.js → useAppFontEffects-FdVEdwq7.js} +101 -101
- package/dist/assets/{useInlineCommentController-BFwu6eZI.js → useInlineCommentController-Bf5t_8QQ.js} +1 -1
- package/dist/assets/{useRootScrollLock-sHvuqb26.js → useRootScrollLock-BhAup8Zd.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-CbrKiV7x.js → vendor-codemirror-language-data-CaoLP1ZV.js} +2 -2
- package/dist/assets/{vi-VN-M7AON7JQ-FnoyhtCt.js → vi-VN-M7AON7JQ-BNXFIbWh.js} +1 -1
- package/dist/assets/{web-components-CyKxJIMp.js → web-components-BKRdx0aw.js} +1 -1
- package/dist/assets/{zh-CN-CytFue-5.js → zh-CN-CN_mO1LM.js} +1 -1
- package/dist/assets/{zh-CN-LNUGB5OW-CxzUpimL.js → zh-CN-LNUGB5OW-BzAzBoiv.js} +1 -1
- package/dist/assets/{zh-HK-E62DVLB3-Bm2BpZIC.js → zh-HK-E62DVLB3-gszEMx80.js} +1 -1
- package/dist/assets/{zh-TW-B-BGC0pY.js → zh-TW-DRymoioH.js} +1 -1
- package/dist/assets/{zh-TW-RAJ6MFWO-NVEuq9tQ.js → zh-TW-RAJ6MFWO-jlMY0UDt.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 +1 -1
package/dist/assets/{CodeMirrorCommentWidgets-DngoXxGT.js → CodeMirrorCommentWidgets-e9rY9Jxg.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"./vendor-react-C3AD0CRp.js";import{I as l,a as I}from"./useInlineCommentController-
|
|
1
|
+
import{j as a}from"./vendor-react-C3AD0CRp.js";import{I as l,a as I}from"./useInlineCommentController-Bf5t_8QQ.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as r,e as Ye,j as n}from"./vendor-react-C3AD0CRp.js";import{u as Y,i as Fe,z as Zn,g as Re,J as es}from"./index-
|
|
1
|
+
import{R as r,e as Ye,j as n}from"./vendor-react-C3AD0CRp.js";import{u as Y,i as Fe,z as Zn,g as Re,J as es}from"./index-BvpIhpBI.js";import{u as ts,a as ns,b as ss,c as rs,B as is,C as os,P as on,h as as,e as ls,g as cs,i as us,f as ds}from"./patchFileDiff-DzgiH2zi.js";import{u as fs,i as ms,a as ps,b as hs,c as gs,d as xs,S as ys}from"./SubmoduleDiffSummary-hkelCkS-.js";import{u as ze,B as je,I as O,h as le,j as xn,a2 as bs,a1 as ae,bJ as ws,a3 as vs,bK as js,bL as Ns,bM as Ss,Z as an,b0 as ks,bN as yn,t as Qe,bO as Cs,bP as lt,aP as bn,bQ as Fs,bR as _t,az as Rs,z as at,aa as Ds,S as zt,A as As,C as Es,E as Ts,F as Ls}from"./useAppFontEffects-FdVEdwq7.js";import{N as Vs,b as Ms}from"./runtimeEndpointReset-D56xMbiw.js";import{P as Bs}from"./PierreDiffViewer-DKHxCmze.js";import{u as Is,v as Ps,g as _s,W as zs}from"./main-xs-JggnC.js";import{b as Os,c as Ks}from"./changesTree-CePHbFcj.js";import{p as $s}from"./VirtualizedFileDiff-DapU3oMs.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-C3BVLiwa.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-XNmn2Hnw.js";import"./vendor-use-sync-external-store-DVVwmGAS.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./PluginPane-Dx0_Dldo.js";import"./vendor-sonner-CMlKUx1I.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-CyPa587s.js";import"./vendor-clsx-C_d985j6.js";import"./vendor-base-ui-BV0ycO3d.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BERnAEiB.js";import"./vendor-floating-ui-core-DBVSD8FA.js";import"./vendor-floating-ui-react-dom-VN3-0QGl.js";import"./vendor-dnd-kit-core-B-dmENub.js";import"./vendor-dnd-kit-utilities-D2MO70n8.js";import"./vendor-dnd-kit-accessibility-vxqCsF6D.js";import"./vendor-dnd-kit-sortable-DiuAkJDx.js";import"./vendor-tanstack-react-virtual-BHz8HhxS.js";import"./vendor-tanstack-virtual-core-BoA4iGMw.js";import"./vendor-framer-motion-0pQCvQRa.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-cmdk-WpnCe4Xz.js";import"./vendor-radix-ui-react-dialog-Cya58wJc.js";import"./vendor-radix-ui-primitive-DOdKROq0.js";import"./vendor-radix-ui-react-compose-refs-OwL660na.js";import"./vendor-radix-ui-react-context-BGG-1ggC.js";import"./vendor-radix-ui-react-id-CciEoFzD.js";import"./vendor-radix-ui-react-use-layout-effect-ChlApEEc.js";import"./vendor-radix-ui-react-use-controllable-state-DprBN3PW.js";import"./vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js";import"./vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js";import"./vendor-radix-ui-react-primitive-CUfg3gbV.js";import"./vendor-radix-ui-react-slot-CLI2-QJb.js";import"./vendor-babel-runtime-CF3RwP-h.js";import"./vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js";import"./vendor-radix-ui-react-focus-scope-CqvJmvlR.js";import"./vendor-radix-ui-react-portal-EaY9b0dR.js";import"./vendor-radix-ui-react-presence-DBDb0ROU.js";import"./vendor-radix-ui-react-focus-guards-DOvT22db.js";import"./vendor-react-remove-scroll-CdTdY8wV.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-DAxITgbW.js";import"./vendor-react-style-singleton-XBDcq1Ec.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-CzUV4Fx5.js";import"./vendor-use-callback-ref-h1JrcWGd.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-Cg8boEOY.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CN8Enbjc.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-Dw1gdHuT.js";import"./vendor-codemirror-lang-json-DzRRSgj9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-B_seq3PB.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CcuPVz08.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-B3FiTjDN.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CaoLP1ZV.js";import"./vendor-codemirror-lang-python-frX4-6UW.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-Cg3hFNyu.js";import"./vendor-legendapp-list-ZsDnss2w.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-Bsi0q3M9.js";import"./web-components-BKRdx0aw.js";import"./computeVirtualFileMetrics-BWISD0Ee.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-Bf5t_8QQ.js";import"./appThemeRegistry-CWAKiwky.js";import"./textMateThemeFromAppTheme-AUvSJIJn.js";import"./vendor-katex-C8JhiARg.js";import"./useRootScrollLock-BhAup8Zd.js";import"./scheduledTasksApi-BZMS2h6Z.js";import"./vendor-cron-parser-B7wFT8N0.js";import"./vendor-luxon-BZ0puJYg.js";import"./isDiffPlainText-DU3lrpLL.js";import"./vendor-diff-C3JhlQdm.js";const Ws=r.memo(function(e){const s=Ye.c(13),{index:u,staged:g,busyHunk:m,disabled:b,onAction:N}=e,{t:v}=ze();let a;s[0]!==g?(a=g?["unstage"]:["discard","stage"],s[0]=g,s[1]=a):a=s[1];const j=a;let k;s[2]===Symbol.for("react.memo_cache_sentinel")?(k={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=k):k=s[2];let p;s[3]!==j||s[4]!==m||s[5]!==b||s[6]!==u||s[7]!==N||s[8]!==v?(p=n.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:j.map(w=>{const C=v(w==="stage"?"diffView.hunk.stageTitle":w==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),V=m?.index===u&&m.action===w;return n.jsx(je,{variant:"ghost",size:"xs",className:le("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",w==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",w==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:b||m!==null,title:C,"aria-label":C,onPointerDown:Gs,onClick:f=>{f.stopPropagation(),N(u,w)},children:n.jsx(O,{name:V?"loader-4":w==="stage"?"add":"arrow-go-back",className:le(w==="stage"?"size-4":"size-3.5",V&&"animate-spin")})},w)})}),s[3]=j,s[4]=m,s[5]=b,s[6]=u,s[7]=N,s[8]=v,s[9]=p):p=s[9];let E;return s[10]!==u||s[11]!==p?(E=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:k,"data-hunk-actions":u,children:p}),s[10]=u,s[11]=p,s[12]=E):E=s[12],E});function Gs(o){return o.stopPropagation()}const ln=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const g=s??u;return g?{path:g.path,topOffset:g.top-o}:null},Hs=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),Mt=o=>o.slice(o.lastIndexOf("/")+1),wn=(o,e)=>{const s=[],u=(g,m)=>{const b=Array.from(g.children.values()).sort((v,a)=>v.name.localeCompare(a.name));for(const v of b){const{node:a,label:j}=Ks(v),k=!e.has(a.path);s.push({kind:"directory",key:`dir:${a.path}`,depth:m,path:a.path,label:j,fileCount:a.files.length,expanded:k}),k&&u(a,m+1)}const N=[...g.directFiles].sort((v,a)=>Mt(v.path).localeCompare(Mt(a.path)));for(const v of N)s.push({kind:"file",key:`file:${v.path}`,depth:m,name:Mt(v.path),file:v})};return u(Os(o),0),s},cn=o=>{if(!o)return null;const e=o.split(`
|
|
2
2
|
`);let s=null;for(const u of e){const g=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(g){const m=Number.parseInt(g[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},qs=1100,Us=15e3,un=500,dn=300,vn=1e6,It=3,Xs=o=>o<=6?o:o<=12?6:o<=25?4:2,fn={status:"loading"},Js=3,Qs=r.memo(()=>{const o=Ye.c(4),{t:e}=ze();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),jn={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Ys=jn.M,Zs=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Ot=o=>{const e=Zs(o);return jn[e]??Ys},er=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},mn=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},pn=o=>!!o.working_dir?.trim()||o.index==="?",tr=(o,e)=>Rs(o,e),hn=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),gn=(o,e)=>{const s=o.split(`
|
|
3
3
|
`),u=e.split(`
|
|
4
4
|
`),g=Math.min(s.length,u.length);for(let m=0;m<g;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},nr=o=>o==="added"?"A":o==="deleted"?"D":"M",Pt=(o,e,s)=>us(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:ds(o,e),contextMode:s},Nn=(o,e,s)=>{const u=o??0,g=e??0;return!u&&!g?null:n.jsxs("span",{className:le("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,g?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",g]}):null]})},sr=r.memo(o=>{const e=Ye.c(68),{scope:s,workingCount:u,stagedCount:g,turnCount:m,branchCount:b,commitCount:N,prCount:v,showCommitOption:a,showBranchOption:j,onScopeChange:k}=o,{t:p}=ze(),[E,w]=r.useState(!1),C=s==="pr"?v??0:s==="staged"?g:s==="turn"?m:s==="branch"?b??0:s==="commit"?N??0:u;let V;e[0]!==s||e[1]!==p?(V=p(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=p,e[2]=V):V=e[2];const f=V;let S;e[3]!==p?(S=p("diffView.scope.selectorAria"),e[3]=p,e[4]=S):S=e[4];let M;e[5]!==C?(M=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",C]}),e[5]=C,e[6]=M):M=e[6];let I;e[7]!==f||e[8]!==M?(I=n.jsxs("span",{className:"whitespace-nowrap",children:[f,M]}),e[7]=f,e[8]=M,e[9]=I):I=e[9];let ce;e[10]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx(O,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=ce):ce=e[10];let U;e[11]!==S||e[12]!==I?(U=n.jsx(As,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":S,children:[I,ce]})}),e[11]=S,e[12]=I,e[13]=U):U=e[13];let y;e[14]!==k?(y=H=>{(H==="working"||H==="staged"||H==="turn"||H==="branch"||H==="commit"||H==="pr")&&(k?.(H),w(!1))},e[14]=k,e[15]=y):y=e[15];let K;e[16]!==p?(K=p("diffView.scope.changed"),e[16]=p,e[17]=K):K=e[17];let X;e[18]!==K?(X=n.jsx("span",{children:K}),e[18]=K,e[19]=X):X=e[19];let ue;e[20]!==u?(ue=n.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=ue):ue=e[21];let se;e[22]!==ue||e[23]!==X?(se=n.jsx(at,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[X,ue]})}),e[22]=ue,e[23]=X,e[24]=se):se=e[24];let xe;e[25]!==p?(xe=p("diffView.scope.staged"),e[25]=p,e[26]=xe):xe=e[26];let re;e[27]!==xe?(re=n.jsx("span",{children:xe}),e[27]=xe,e[28]=re):re=e[28];let ye;e[29]!==g?(ye=n.jsx("span",{className:"typography-meta text-muted-foreground",children:g}),e[29]=g,e[30]=ye):ye=e[30];let ee;e[31]!==re||e[32]!==ye?(ee=n.jsx(at,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[re,ye]})}),e[31]=re,e[32]=ye,e[33]=ee):ee=e[33];let _;e[34]!==p?(_=p("diffView.scope.lastTurn"),e[34]=p,e[35]=_):_=e[35];let te;e[36]!==_?(te=n.jsx("span",{children:_}),e[36]=_,e[37]=te):te=e[37];let ne;e[38]!==m?(ne=n.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=ne):ne=e[39];let $;e[40]!==te||e[41]!==ne?($=n.jsx(at,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[te,ne]})}),e[40]=te,e[41]=ne,e[42]=$):$=e[42];let Ne;e[43]!==b||e[44]!==j||e[45]!==p?(Ne=j?n.jsx(at,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:b??"…"})]})}):null,e[43]=b,e[44]=j,e[45]=p,e[46]=Ne):Ne=e[46];let T;e[47]!==N||e[48]!==a||e[49]!==p?(T=a&&n.jsx(at,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:N??"…"})]})}),e[47]=N,e[48]=a,e[49]=p,e[50]=T):T=e[50];let G;e[51]!==v||e[52]!==a||e[53]!==p?(G=a&&n.jsx(at,{value:"pr",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:p("session.githubIntegration.tabs.pullRequests")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:v??"…"})]})}),e[51]=v,e[52]=a,e[53]=p,e[54]=G):G=e[54];let A;e[55]!==s||e[56]!==se||e[57]!==ee||e[58]!==$||e[59]!==Ne||e[60]!==T||e[61]!==G||e[62]!==y?(A=n.jsx(Es,{align:"start",className:"w-40",children:n.jsxs(Ts,{value:s,onValueChange:y,children:[se,ee,$,Ne,T,G]})}),e[55]=s,e[56]=se,e[57]=ee,e[58]=$,e[59]=Ne,e[60]=T,e[61]=G,e[62]=y,e[63]=A):A=e[63];let de;return e[64]!==E||e[65]!==A||e[66]!==U?(de=n.jsxs(Ls,{open:E,onOpenChange:w,children:[U,A]}),e[64]=E,e[65]=A,e[66]=U,e[67]=de):de=e[67],de}),rr=r.memo(o=>{const e=Ye.c(11),{changedFiles:s,selectedFile:u,onSelectFile:g}=o,{t:m}=ze();if(s.length===0)return null;let b;if(e[0]!==s||e[1]!==g||e[2]!==u||e[3]!==m){let v;e[5]!==g||e[6]!==u||e[7]!==m?(v=a=>{const j=Ot(a),k=u===a.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>g(a.path),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",k?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(_t,{filePath:a.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:j.color},title:m(j.descriptionKey),"aria-label":m(j.descriptionKey),children:j.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:a.path,children:a.path}),Nn(a.insertions,a.deletions)]})},a.path)},e[5]=g,e[6]=u,e[7]=m,e[8]=v):v=e[8],b=s.map(v),e[0]=s,e[1]=g,e[2]=u,e[3]=m,e[4]=b}else b=e[4];let N;return e[9]!==b?(N=n.jsx(zt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:b})}),e[9]=b,e[10]=N):N=e[10],N}),Sn=12,kn=8,Bt=160,ir=.5,or=r.memo(o=>{const e=Ye.c(18),{changedFiles:s,selectedFile:u,onSelectFile:g}=o,{t:m}=ze(),[b,N]=r.useState(ur);let v;e[0]!==s||e[1]!==b?(v=wn(s,b),e[0]=s,e[1]=b,e[2]=v):v=e[2];const a=v;let j,k;e[3]!==u?(j=()=>{u&&N(f=>{const S=Array.from(f).filter(I=>u.startsWith(`${I}/`));if(S.length===0)return f;const M=new Set(f);return S.forEach(I=>M.delete(I)),M})},k=[u],e[3]=u,e[4]=j,e[5]=k):(j=e[4],k=e[5]),r.useEffect(j,k);let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=f=>{N(S=>{const M=new Set(S);return M.delete(f)||M.add(f),M})},e[6]=p):p=e[6];const E=p,w=fr;let C;if(e[7]!==g||e[8]!==a||e[9]!==u||e[10]!==m){let f;e[12]!==g||e[13]!==u||e[14]!==m?(f=S=>{const M=`${kn+S.depth*Sn}px`;if(S.kind==="directory")return n.jsxs("li",{className:"relative",children:[w(S.depth),n.jsxs("button",{type:"button",onClick:()=>E(S.path),"aria-expanded":S.expanded,"aria-label":S.expanded?m("diffView.fileTree.collapseDirectoryAria",{path:S.path}):m("diffView.fileTree.expandDirectoryAria",{path:S.path}),className:"flex w-full items-center gap-1 rounded-md py-1 pr-2 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground",style:{paddingLeft:M},title:S.path,children:[n.jsx(O,{name:"arrow-right-s",className:le("size-3.5 flex-shrink-0 transition-transform",S.expanded&&"rotate-90")}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:S.label})]})]},S.key);const I=Ot(S.file),ce=u===S.file.path;return n.jsxs("li",{className:"relative",children:[w(S.depth),n.jsxs("button",{type:"button",onClick:()=>g(S.file.path),"aria-current":ce?"true":void 0,className:le("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left transition-colors",ce?"bg-interactive-selection text-interactive-selection-foreground":"text-foreground/90 hover:bg-interactive-hover hover:text-foreground"),style:{paddingLeft:M},title:S.file.path,children:[n.jsx(_t,{filePath:S.file.path,className:"ml-0.5 size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:S.name}),n.jsx("span",{className:"typography-micro font-semibold w-3 text-center uppercase",style:{color:I.color},title:m(I.descriptionKey),"aria-label":m(I.descriptionKey),children:I.code})]})]},S.key)},e[12]=g,e[13]=u,e[14]=m,e[15]=f):f=e[15],C=a.map(f),e[7]=g,e[8]=a,e[9]=u,e[10]=m,e[11]=C}else C=e[11];let V;return e[16]!==C?(V=n.jsx(zt,{outerClassName:"flex-1 min-h-0",className:"px-1.5 py-1.5",children:n.jsx("ul",{className:"flex flex-col",children:C})}),e[16]=C,e[17]=V):V=e[17],V}),ar=r.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,renderSideBySide:g}=o,{t:m}=ze(),b=u.original.length>0,N=u.modified.length>0,v=g?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",a=g?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={contain:"layout"},e[0]=j):j=e[0];let k;e[1]!==u.original||e[2]!==s||e[3]!==b||e[4]!==a||e[5]!==g||e[6]!==m?(k=b&&n.jsxs("div",{className:a,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),n.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=b,e[4]=a,e[5]=g,e[6]=m,e[7]=k):k=e[7];let p;e[8]!==u.modified||e[9]!==s||e[10]!==N||e[11]!==b||e[12]!==a||e[13]!==g||e[14]!==m?(p=N&&n.jsxs("div",{className:a,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(b?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=N,e[11]=b,e[12]=a,e[13]=g,e[14]=m,e[15]=p):p=e[15];let E;return e[16]!==v||e[17]!==k||e[18]!==p?(E=n.jsx("div",{className:"w-full overflow-auto p-4",style:j,children:n.jsxs("div",{className:v,children:[k,p]})}),e[16]=v,e[17]=k,e[18]=p,e[19]=E):E=e[19],E}),lr=r.memo(o=>{const e=Ye.c(23),{filePath:s,diff:u,staged:g,renderSideBySide:m,wrapLines:b,hunkActions:N,onExpandContextRequest:v,pendingContextExpansion:a,contextLoading:j}=o;let k;e[0]!==s?(k=Ds(s)||"text",e[0]=s,e[1]=k):k=e[1];const p=k;if(u.submodule){let C;return e[2]!==u.submodule||e[3]!==g?(C=n.jsx(ys,{state:u.submodule,staged:g}),e[2]=u.submodule,e[3]=g,e[4]=C):C=e[4],C}if(u.isBinary){let C;return e[5]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Qs,{}),e[5]=C):C=e[5],C}if(lt(s)){let C;return e[6]!==u||e[7]!==s||e[8]!==m?(C=n.jsx(ar,{filePath:s,diff:u,renderSideBySide:m}),e[6]=u,e[7]=s,e[8]=m,e[9]=C):C=e[9],C}let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={contain:"layout"},e[10]=E):E=e[10];let w;return e[11]!==j||e[12]!==u.fileDiff||e[13]!==u.modified||e[14]!==u.original||e[15]!==s||e[16]!==N||e[17]!==p||e[18]!==v||e[19]!==a||e[20]!==m||e[21]!==b?(w=n.jsx("div",{className:"w-full",style:E,children:n.jsx(Bs,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:p,fileName:s,renderSideBySide:m,wrapLines:b,layout:"inline",hunkActions:N,onExpandContextRequest:v,pendingContextExpansion:a,contextLoading:j})}),e[11]=j,e[12]=u.fileDiff,e[13]=u.modified,e[14]=u.original,e[15]=s,e[16]=N,e[17]=p,e[18]=v,e[19]=a,e[20]=m,e[21]=b,e[22]=w):w=e[22],w}),cr=r.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:g,isSelected:m,isExpanded:b,isMounted:N,onSelect:v,onExpandedChange:a,registerSectionRef:j,showOpenInEditorAction:k=!1,isOpeningInEditor:p=!1,onOpenInEditor:E,staged:w=!1,loadFullFiles:C=!1,initialDiffData:V=null,comparisonDiff:f,onRetryComparisonDiff:S,loadFullComparisonDiff:M,readOnlyActions:I=!1,hunkActionsEnabled:ce=!1,contentRevision:U=0})=>{const{t:y}=ze(),{git:K}=xn(),X=ae(r.useCallback(x=>x.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),ue=ae(x=>x.setDiff),se=ae(x=>x.fetchStatus),xe=Y(x=>x.setDiffFileLayout),[re,ye]=r.useState(0),[ee,_]=r.useState(null),[te,ne]=r.useState(!1),[$,Ne]=r.useState(null),T=$!==null&&$.source===f?$.result:f,G=!!e&&!V&&(!f||!!M),A=r.useMemo(()=>T?T.status==="error"?{kind:"error",message:T.message}:null:ee,[T,ee]),de=T?T.status==="loading":te,[H,xt]=r.useState(null),Oe=r.useRef(!1),[Ke,ct]=r.useState(null),[yt,Ft]=r.useState(!1),[ut,$e]=r.useState(null),[Ze,We]=r.useState(null),[c,De]=r.useState(null),ie=C||c!==null;r.useEffect(()=>{if(!c||!M||!f||f.status!=="ready"||$?.source===f)return;let x=!1;return M(s.path).then(z=>{if(!x){if(z.status==="error"){Qe.error(z.message),De(null);return}Ne({source:f,result:z})}}),()=>{x=!0}},[c,s.path,$,M,f]);const be=r.useRef(null),Ae=r.useRef(null),Ge=r.useMemo(()=>Ot(s),[s]),et=u==="side-by-side",He=ie?"full":"patch",Se=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,fe=ce&&!I&&!V&&!T&&!lt(s.path),tt=JSON.stringify([Re(),e,s.path,w,Se,re,U]),W=Ke?.scope===tt?Ke.patch:null,bt=Ke?.scope===tt?Ke.submodule:null,me=r.useMemo(()=>T?T.status==="ready"?T.data:null:V||(w?Ze:ut||(X?{original:X.original,modified:X.modified,isBinary:X.isBinary,submodule:X.submodule,contextMode:"full"}:null)),[T,X,V,ut,w,Ze]),pe=me?.contextMode===He,dt=r.useCallback(x=>{Ae.current=x,j(s.path,x)},[s.path,j]),nt=r.useCallback(x=>{a(s.path,x)},[s.path,a]),st=r.useCallback(()=>{v(s.path)},[s.path,v]),qe=r.useRef({fileStatusKey:Se,staged:w});r.useEffect(()=>{if(!o)return;const x=qe.current;x.fileStatusKey===Se&&x.staged===w||(qe.current={fileStatusKey:Se,staged:w},w?We(null):$e(null),_(null),be.current=null)},[Se,w,o]);const[Ue,Rt]=r.useState(U),rt=Ue===U;r.useEffect(()=>{rt||(_(null),be.current=null)},[rt]),r.useEffect(()=>{if(!o||!b||!N||ee)return;if(!e||T||V||me&&pe&&rt&&(!fe||W!==null)){be.current=null,ne(!1);return}const x=`${e}::${s.path}::${w?"staged":"unstaged"}::${Se}::${He}::${re}::${U}`;if(be.current===x)return;be.current=x,_(null),ne(!0);let z=!1;const he=Re(),Le=ie?vn:It,Z=lt(s.path)?K.getGitFileDiff(e,{path:s.path,staged:w}):!ie&&W!==null?Promise.resolve({diff:W,submodule:bt}):K.getGitDiff(e,{path:s.path,staged:w,contextLines:Le}),Ve=fe&&ie&&W===null?K.getGitDiff(e,{path:s.path,staged:w,contextLines:It}).then(L=>L.diff):Promise.resolve(W),ke=Promise.all([Z,Ve]),Me=Us;let it;const Dt=new Promise((L,ft)=>{it=setTimeout(()=>ft(new Error(`Timed out after ${Me}ms`)),Me)});return Promise.race([ke,Dt]).then(([L,ft])=>{if(z||he!==Re())return;const Be="diff"in L&&!ie?L.diff:ft;if(fe&&ie&&Be!==null&&/^@@\s/m.test(Be)&&"diff"in L&&L.diff!==Be&&!as(L.diff,Be))throw ct(null),new Error(y("diffView.hunk.unavailable"));if(fe&&Be!==null&&ct({scope:tt,patch:Be,submodule:L.submodule}),"diff"in L){const Xe={...Pt(s.path,L.diff,He),submodule:L.submodule};w?We(Xe):$e(Xe)}else{const Xe={original:L.original??"",modified:L.modified??"",isBinary:L.isBinary,submodule:L.submodule,contextMode:"full"};w?We(Xe):ue(e,s.path,Xe,he)}Rt(U),ne(!1)}).catch(L=>{if(!(z||he!==Re())){if(ne(!1),L instanceof es){_({kind:"unavailable",reason:L.reason}),L.reason==="path_not_found"&&se(e,K,{force:!0,silent:!0});return}_({kind:"error",message:L instanceof Error?L.message:String(L)})}}).finally(()=>clearTimeout(it)),()=>{z=!0,clearTimeout(it),be.current===x&&(be.current=null)}},[W,bt,U,fe,rt,tt,T,He,me,pe,re,e,se,s.path,Se,K,V,b,N,ie,ee,ue,w,y,o]);const wt=r.useCallback(()=>{nt(!b),st()},[nt,st,b]),oe=r.useCallback(()=>{_(null),ct(null),$e(null),We(null),be.current=null,ye(x=>x+1)},[]),Ee=r.useCallback(async(x,z)=>{if(!e||!fe||de||A||Oe.current||H!==null)return;const he=W?ls(W,x):null;if(!he){Qe.error(y("diffView.hunk.unavailable"));return}if(w&&z!=="unstage"||!w&&z==="unstage")return;Oe.current=!0;const Le=Re();xt({index:x,action:z});try{const Z=z==="stage"?K.stageGitHunk:z==="unstage"?K.unstageGitHunk:K.revertGitHunk;if(!Z){Qe.error(y("diffView.hunk.unsupported"));return}if(await Z(e,s.path,he),Le!==Re())return;oe(),yn.requestGitRefresh({directory:e,paths:[s.path]}),await se(e,K)}catch(Z){if(Le!==Re())return;oe(),Qe.error(Z instanceof Error&&Z.message?Z.message:y("diffView.hunk.unavailable"))}finally{Oe.current=!1,xt(Z=>Z?.index===x&&Z.action===z?null:Z)}},[W,fe,de,A,e,se,s.path,K,H,oe,w,y]),we=r.useMemo(()=>fe&&W!==null?cs(W):[],[W,fe]),q=r.useCallback(x=>n.jsx(Ws,{index:x,staged:w,busyHunk:H,disabled:de||!!A,onAction:Ee}),[A,Ee,H,de,w]),Te=r.useMemo(()=>we.length>0?{anchors:we,render:q}:void 0,[we,q]);return n.jsxs("div",{ref:dt,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:wt,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),wt())},className:le("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:b?n.jsx(O,{name:"arrow-down-s",className:"size-4"}):n.jsx(O,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Ge.color},title:y(Ge.descriptionKey),"aria-label":y(Ge.descriptionKey),children:Ge.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(_t,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const x=s.path.lastIndexOf("/");if(x===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const z=s.path.slice(0,x),he=s.path.slice(x+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:z}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:he})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Nn(s.insertions,s.deletions),k&&E?n.jsx(je,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:y("diffView.actions.openFileInEditorAtChange"),onClick:x=>{x.stopPropagation(),E(s.path,me)},disabled:p,children:p?n.jsx(O,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(O,{name:"edit",className:"size-3.5"})}):null,n.jsx(bn,{mode:et?"side-by-side":"unified",onModeChange:x=>{const z=x==="side-by-side"?"side-by-side":"inline";xe(s.path,z)},className:"opacity-70"})]})]})}),b&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!N&&!A?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,A?.kind==="unavailable"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:A.reason==="nested_repository"?y("diffView.unavailable.nestedRepositoryTitle"):A.reason==="untracked_directory"?y("diffView.unavailable.untrackedDirectoryTitle"):y("diffView.unavailable.missingTitle")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A.reason==="nested_repository"?y("diffView.unavailable.nestedRepositoryDescription"):A.reason==="untracked_directory"?y("diffView.unavailable.untrackedDirectoryDescription"):y("diffView.unavailable.missingDescription")}),A.reason==="path_not_found"?n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:oe,children:y("diffView.actions.retry")}):null]}):null,A?.kind==="error"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A.message}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>T?S?.():oe(),children:y("diffView.actions.retry")})]}):null,N&&de&&!me&&!A?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),y("diffView.state.loadingDiff")]}):null,N&&me&&!yt&&s.insertions+s.deletions>un?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:y("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Ft(!0),children:y("diffView.actions.renderAnyway")})]}):null,N&&me&&(yt||s.insertions+s.deletions<=un)?n.jsx(n.Fragment,{children:n.jsx(lr,{filePath:s.path,diff:me,staged:w,renderSideBySide:et,wrapLines:g,hunkActions:Te,onExpandContextRequest:G?De:void 0,pendingContextExpansion:c,contextLoading:c!==null&&me.contextMode!=="full"&&!A})}):null]})]})}),Mo=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:g=!1,diffScope:m="all",onDiffScopeChange:b,targetFilePath:N=null,flushContent:v=!1})=>{const{t:a}=ze(),{git:j,files:k}=xn(),p=bs(),E=ae(t=>t.runtimeKey),{rootIsGitRepo:w,gitDirectory:C,nestedRepos:V}=ws(p??null,{enabled:o}),f=C??p,S=Y(t=>t.openContextSurface),M=Is(t=>t.requestSource),{screenWidth:I,isMobile:ce}=vs(),U=js(f??null),y=Ns(f??null),K=Ss(f??null),X=ae(t=>t.setActiveDirectory),ue=ae(t=>t.ensureStatus),se=ae(t=>t.selectNestedRepo),xe=ae(t=>t.fetchStatus),re=ae(t=>t.fetchBranches),ye=ae(t=>t.clearDiffCache),ee=ae(t=>t.setDiff),[_,te]=r.useState(null),[ne,$]=r.useState(!1),[Ne,T]=r.useState(null),[G,A]=r.useState(()=>new Set),[de,H]=r.useState(()=>new Set),[xt,Oe]=r.useState(0),[Ke,ct]=r.useState(()=>new Map),[yt,Ft]=r.useState(0),[ut,$e]=r.useState(!1),[Ze,We]=r.useState(!1),[c,De]=r.useState(m);r.useEffect(()=>{De(m)},[m]);const ie=Y(t=>t.pendingDiffFile),be=Y(t=>t.pendingDiffStaged),Ae=Y(t=>t.pendingDiffScope),Ge=Y(t=>t.setPendingDiffFile),et=Y(t=>t.diffLayoutPreference),He=Y(t=>t.diffFileLayout),Se=Y(t=>t.setDiffFileLayout),fe=Y(t=>t.diffWrapLines),tt=Y(t=>t.setDiffWrapLines),W=Y(t=>t.diffFileListMode),bt=Y(t=>t.setDiffFileListMode),me=Y(t=>t.openContextFileAtLine),pe=an(t=>t.currentSessionId),dt=ks(c==="turn"?pe??"":"",p??void 0),nt=fe,st=c==="staged"?!0:c==="working"?!1:null,qe=st??ne,Ue=ce||I<=768,Rt=!!pe&&c!=="turn"&&c!=="commit"&&c!=="pr"&&!Ue&&!Fe(),rt=c!=="turn"&&!Ue&&!Fe(),wt=!e&&!Ue&&I>=1024,oe=r.useRef(null),Ee=r.useRef(new Map),we=r.useRef(null),q=r.useRef(null),Te=r.useRef(!1),x=r.useRef(null),z=r.useRef(null),he=r.useRef(null),Le=r.useRef(null),Z=r.useCallback(()=>{const t=oe.current;if(!t)return null;const i=t.getBoundingClientRect().top,l=[];for(const[d,h]of Ee.current)h&&l.push({path:d,top:h.getBoundingClientRect().top});return ln(i,l)},[]),Ve=r.useCallback(()=>{we.current=null,Te.current=!1,T(null),q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null)},[]),ke=r.useCallback(t=>{A(i=>{if(i.has(t))return i;const l=new Set(i);return l.add(t),l})},[]),[Me,it]=r.useState([]),Dt=dt.length>0?dt[dt.length-1].id:"";r.useEffect(()=>{if(c!=="turn"||!pe||!o)return;let t=!1;return Zn.getSessionTurnDiff(pe,{directory:p??void 0}).then(i=>{t||it(i.map(l=>({file:l.file,patch:l.patch,status:l.status,additions:l.additions,deletions:l.deletions})))}).catch(i=>{t||(console.warn("[diff-view] turn diff unavailable:",i instanceof Error?i.message:i),it([]))}),()=>{t=!0}},[c,pe,Dt,p,o]);const L=r.useMemo(()=>{const t=new Map;for(const i of Me)if(i.file){if(typeof i.patch=="string"){t.set(i.file,Pt(i.file,i.patch,"patch"));continue}t.set(i.file,{original:i.before??"",modified:i.after??"",contextMode:"full"})}return t},[Me]),ft=r.useMemo(()=>y?.files?y.files.filter(pn).length:0,[y]),Be=r.useMemo(()=>y?.files?y.files.filter(mn).length:0,[y]),Xe=Me.length,J=y?.current??null,Ie=ts(f??null,J,o&&c==="pr"&&!Fe()),Pe=Ie.selectedSource,_e=ns(f??null,J,o&&c==="commit"&&!Fe()),Je=_e.selectedCommit?.hash??null;r.useEffect(()=>{(c==="commit"||c==="pr")&&Fe()&&(De("working"),b?.("working"))},[c,b]);const ot=ae(t=>f?t.directories.get(f)?.branches??null:null),Cn=ae(t=>f?t.directories.get(f)?.isLoadingBranches??!1:!1),Fn=r.useCallback(()=>{f&&re(f,j)},[f,re,j]),Rn=fs(f??null,o&&U!==!1,Cn,!!ot,Fn,Js),Kt=r.useMemo(()=>{const t=y?.tracking?.trim().split("/")[0];return(t&&ot?.defaultBranches?.[t])??ot?.defaultBranches?.origin??null},[ot,y?.tracking]),$t=!Fe()&&ms(J,Kt),Dn=y!==null,Wt=Fe()||Rn||ps(J,Kt,Dn,ot!==null),An=ss(t=>t.setOverride),{base:Ce,resolved:En,revision:Gt}=rs(f??null,J,o&&$t&&c==="branch"),[Tn,Ln]=r.useState(0);r.useEffect(()=>{const t=xs(c,!Wt);t!==c&&(De(t),t==="working"&&b?.("working"))},[c,Wt,b]);const Vn=r.useMemo(()=>c==="pr"?Pe:c==="commit"&&Je?{kind:"commit",hash:Je}:c==="branch"&&Ce&&J?{kind:"branch",baseRef:Ce,headRef:J}:null,[c,Ce,J,Je,Pe]),P=hs(f??null,Vn,o&&!Fe(),c==="branch"?Gt:""),{fetchDiff:Ht,fetchFullFile:qt}=P,Ut=c==="commit"?P.files:null,Xt=c==="commit"?P.error:null,vt=c==="branch"?P.files:null,Jt=c==="branch"?P.error:null,Qt=P.files?c==="pr"?JSON.stringify([P.key,P.revision]):P.key:null,Mn=r.useMemo(()=>c==="branch"||c==="commit"||c==="pr"?Array.from(G).sort().join("\0"):"",[c,G]),At=r.useCallback(async(t,i=!1)=>{try{const l=await Ht(t,i?vn:It);return{status:"ready",data:Pt(t,l.diff,i?"full":"patch")}}catch(l){return{status:"error",message:l instanceof Error?l.message:a("diffView.state.failedToLoadDiff")}}},[Ht,a]),Yt=r.useCallback(async t=>{try{const{original:i,modified:l}=await qt(t),d=$s({name:t,contents:i},{name:t,contents:l});return{status:"ready",data:{original:i,modified:l,fileDiff:d,contextMode:"full"}}}catch(i){return{status:"error",message:i instanceof Error?i.message:a("diffView.state.failedToLoadDiff")}}},[qt,a]),Bn=r.useMemo(()=>c==="branch"||c==="commit"?t=>At(t,!0):c==="pr"?Yt:void 0,[c,At,Yt]),In=gs(Qt,o?Mn:"",Qt?At:null,fn,JSON.stringify([c==="branch"?Gt:"",c==="pr"?P.revision:0,Tn])),Pn=vt?.length??null,D=r.useMemo(()=>{if(c==="commit"||c==="pr")return(P.files??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:d.insertions,deletions:d.deletions,isNew:d.status==="A"}));if(c==="branch")return(vt??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:0,deletions:0,isNew:d.status==="A"})).sort((d,h)=>d.path.localeCompare(h.path));if(c==="turn")return Me.map(d=>({path:d.file??"",index:"",working_dir:nr(d.status),insertions:d.additions??0,deletions:d.deletions??0,isNew:d.status==="added"})).filter(d=>d.path).sort((d,h)=>d.path.localeCompare(h.path));if(!y?.files)return[];const t=y.diffStats,i=c==="staged"?mn:c==="working"?pn:()=>!0,l=d=>{const h=t?.staged?.[d],F=t?.working?.[d];return c==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:c==="working"?{insertions:F?.insertions??0,deletions:F?.deletions??0}:{insertions:(h?.insertions??0)+(F?.insertions??0),deletions:(h?.deletions??0)+(F?.deletions??0)}};return y.files.filter(i).map(d=>{const h=l(d.path);return{...d,insertions:h.insertions,deletions:h.deletions,isNew:er(d)}}).sort((d,h)=>d.path.localeCompare(h.path))},[c,vt,P.files,Me,y]),Et=r.useMemo(()=>D.map(t=>t.path).join("\0"),[D]);r.useEffect(()=>{const t=Et?Et.split("\0"):[],i=new Set(t),l=`${f??""}:${c}:${s?"collapsed":"default"}`,d=z.current!==l;z.current=l,A(h=>{if(d){const B=s?0:Xs(t.length);return new Set(t.slice(0,B))}let F=!1;const R=new Set;for(const B of h){if(!i.has(B)){F=!0;continue}R.add(B)}return F?R:h}),H(h=>{if(d)return new Set;let F=!1;const R=new Set;for(const B of h){if(!i.has(B)){F=!0;continue}R.add(B)}return F?R:h})},[c,Et,f,s]);const Zt=r.useCallback(()=>{if(x.current=null,!o)return;const t=oe.current;if(!t)return;const i=t.getBoundingClientRect(),l=i.top-dn,d=i.bottom+dn,h={},F=[];for(const[R,B]of Ee.current){if(!B)continue;const Q=B.getBoundingClientRect();F.push({path:R,top:Q.top}),G.has(R)&&(Q.bottom<l||Q.top>d||(h[R]=!0))}he.current=ln(i.top,F),H(R=>{let B=!1;const Q=new Set(R);for(const gt of Object.keys(h))Q.has(gt)||(Q.add(gt),B=!0);return B?Q:R})},[G,o]),ge=r.useCallback(()=>{o&&(typeof window>"u"||x.current===null&&(x.current=window.requestAnimationFrame(Zt)))},[Zt,o]);r.useEffect(()=>{const t=oe.current;if(!(!o||!t))return ge(),t.addEventListener("scroll",ge,{passive:!0}),window.addEventListener("resize",ge),()=>{t.removeEventListener("scroll",ge),window.removeEventListener("resize",ge),x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null)}},[D,G,ge,o]);const Tt=r.useCallback(t=>{const i=He[t.path];if(i)return i;if(et==="inline")return"inline";if(et==="side-by-side")return"side-by-side";const l=I<qs;return t.isNew||l?"inline":"side-by-side"},[He,et,I]),en=r.useMemo(()=>D.length===0?null:D.every(t=>Tt(t)==="side-by-side")?"side-by-side":"inline",[D,Tt]);r.useEffect(()=>{o&&f&&(X(f),ue(f,j))},[f,X,ue,j,o]);const jt=JSON.stringify([E,f]),Lt=r.useRef({scope:jt,paths:new Set,dirty:!1,unscoped:!1}),tn=r.useRef(o);r.useEffect(()=>{const t=o&&!tn.current;if(tn.current=o,Lt.current.scope!==jt&&(Lt.current={scope:jt,paths:new Set,dirty:!1,unscoped:!1}),!f)return;const i=(d,h)=>{d.length&&(Le.current=Z()??he.current,ye(f,d),ct(F=>{const R=new Map(F);for(const B of d)R.set(B,(R.get(B)??0)+1);return R})),h&&Ft(F=>F+1),xe(f,j,{silent:!0})},l=Lt.current;return o&&(t||l.dirty)&&(i([...l.paths],l.unscoped),l.paths.clear(),l.dirty=!1,l.unscoped=!1),yn.onGitRefreshHint(d=>{if(hn(d.directory)!==hn(f))return;const h=d.paths??[],F=h.length===0;if(!o){l.dirty=!0,l.unscoped||=F;for(const R of h)l.paths.add(R);return}i(h,F)})},[Z,ye,f,xe,j,jt,o]),r.useLayoutEffect(()=>{const t=Le.current;if(!t)return;Le.current=null;const i=oe.current,l=Ee.current.get(t.path);if(!i||!l)return;const d=i.getBoundingClientRect().top,h=l.getBoundingClientRect().top-d;i.scrollTop=Hs(i.scrollTop,t.topOffset,h,i.scrollHeight-i.clientHeight),he.current=t},[Ke]),r.useEffect(()=>{!o||c!=="all"&&!Ae||ie&&(Ae&&De(Ae),te(ie),$(Ae==="staged"||!Ae&&be),Ge(null),Te.current=!0,we.current=ie,ke(ie),Oe(t=>t+1))},[c,ke,ie,Ae,be,Ge,o]),r.useEffect(()=>{if(c==="all")return;const t=N?.trim();t&&(te(t),$(c==="staged"),Te.current=!0,we.current=t,ke(t),Oe(i=>i+1))},[c,ke,N]),r.useEffect(()=>{if(!_)return;D.some(i=>i.path===_)||(te(null),$(!1))},[D,_]);const _n=r.useCallback((t,i)=>{const l=Ee.current;i?l.set(t,i):l.delete(t),ge()},[ge]),zn=r.useCallback((t,i)=>{Ve(),A(l=>{const d=l.has(t);if(i===d)return l;const h=new Set(l);return i?h.add(t):h.delete(t),h}),i||H(l=>{if(!l.has(t))return l;const d=new Set(l);return d.delete(t),d}),ge()},[Ve,ge]),On=r.useCallback(()=>{Ve(),A(t=>t.size>0?new Set:new Set(D.map(i=>i.path))),H(new Set),ge()},[Ve,D,ge]),Kn=r.useCallback(async t=>{if(!pe)return;const i=an.getState().getDirectoryForSession(pe)||p||"";if(!i){Qe.error(a("diffView.reviewDialog.toast.noSessionDirectory"));return}We(!0);try{await Cs({originalSessionID:pe,directory:i,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),$e(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Qe.error(l instanceof Error?l.message:a("diffView.reviewDialog.toast.startFailed"))}finally{We(!1)}},[pe,p,a]),Nt=r.useCallback(t=>{const i=Ee.current.get(t),l=oe.current;if(!i||!l)return!1;const d=i.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+d,behavior:"auto"}),!0},[]);r.useEffect(()=>{const t=we.current;if(!o||!t)return;let i=0;const l=20;let d=!1;const h=(R=!0)=>{d||(d=!0,we.current=null,Te.current=!1,R&&T(null),q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null))},F=()=>{if(d){q.current=null;return}const R=we.current;if(!R){h(),q.current=null;return}if(!Nt(R)){i+=1,i<l?q.current=window.requestAnimationFrame(F):(h(),q.current=null);return}if(u&&Te.current){T(R),h(!1);return}h()};return q.current=window.requestAnimationFrame(F),()=>{d=!0,q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null)}},[u,xt,Nt,o]);const $n=r.useCallback(t=>{},[]),ve=W==="tree"&&!Ue,Wn=Y(t=>t.diffFileTreeWidth),St=Y(t=>t.setDiffFileTreeWidth),nn=r.useRef(null),[Gn,sn]=r.useState(!1),mt=Math.max(Wn,Bt),kt=r.useCallback(t=>{const i=Math.max(Bt,(nn.current?.clientWidth??0)*ir);return Math.min(i,Math.max(Bt,t))},[]),Hn=r.useCallback(t=>{t.preventDefault();const i=t.clientX,l=mt;sn(!0);const d=F=>{St(kt(l+F.clientX-i))},h=()=>{sn(!1),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)};window.addEventListener("pointermove",d),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h)},[kt,mt,St]),qn=r.useCallback(t=>{const i=t.shiftKey?40:10,l=t.key==="ArrowLeft"?-i:t.key==="ArrowRight"?i:0;l!==0&&(t.preventDefault(),St(kt(mt+l)))},[kt,mt,St]),Vt=r.useMemo(()=>ve?wn(D,new Set).flatMap(t=>t.kind==="file"?[t.file]:[]):[],[D,ve]),pt=ve?Vt:D,ht=ve?Vt.find(t=>t.path===_)??Vt[0]??null:null,Ct=r.useCallback(t=>{if(Ve(),ve){te(t),$(!1),ke(t),oe.current?.scrollTo({top:0});return}te(t),$(!1),Te.current=!0,we.current=t,ke(t),Oe(i=>i+1),Nt(t)},[Ve,ke,ve,Nt]);r.useEffect(()=>{const t=i=>{if(!o||!i.altKey||i.metaKey||i.ctrlKey||i.shiftKey||i.key!=="ArrowDown"&&i.key!=="ArrowUp")return;const l=i.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||pt.length===0)return;const d=i.key==="ArrowDown"?1:-1,h=ve?ht?.path:_,F=h?pt.findIndex(Q=>Q.path===h):-1,R=F===-1?d>0?0:pt.length-1:F+d,B=pt[R];B&&(i.preventDefault(),Ct(B.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[_,Ct,ve,pt,ht,o]);const Un=r.useCallback(t=>{const i=t==="side-by-side"?"side-by-side":"inline";D.forEach(l=>{Se(l.path,i)})},[D,Se]),[Xn,rn]=r.useState(null),Jn=r.useCallback(async(t,i)=>{if(!f||!t)return;rn(t);const l=Re();try{let d=null;if(i?.patch&&!i.isBinary&&!lt(t)?d=cn(i.patch):i&&i.contextMode==="full"&&!i.isBinary&&!lt(t)&&(d=gn(i.original,i.modified)),d===null)try{const Q=await j.getGitDiff(f,{path:t,staged:qe,contextLines:3});d=cn(Q.diff)}catch{d=null}let h=i;if(d===null||!h){const Q=await j.getGitFileDiff(f,{path:t,staged:qe}),gt={original:Q.original??"",modified:Q.modified??"",isBinary:Q.isBinary,submodule:Q.submodule};h=gt,qe||ee(f,t,gt,l)}const F=d??(h.isBinary||lt(t)?1:gn(h.original,h.modified)),R=tr(f,t),B=await Ps(k,R,{directory:f});if(!B.ok){Qe.error(_s(B.reason));return}me(f,R,F,1)}finally{rn(d=>d===t?null:d)}},[qe,f,k,j,me,ee]),Qn=()=>{if(!f)return null;const t=(l,d=!1)=>n.jsx(cr,{visible:o,directory:f,file:l,layout:Tt(l),wrapLines:nt,isSelected:!1,isExpanded:d||G.has(l.path),isMounted:d||de.has(l.path)||l.path===Ne,onSelect:$n,onExpandedChange:zn,registerSectionRef:_n,showOpenInEditorAction:g&&c!=="turn",isOpeningInEditor:Xn===l.path,onOpenInEditor:(h,F)=>{Jn(h,F)},staged:i(l.path),readOnlyActions:c==="branch"||c==="commit"||c==="pr",hunkActionsEnabled:c==="all"||c==="working"||c==="staged",contentRevision:yt,comparisonDiff:c==="branch"||c==="commit"||c==="pr"?In.get(l.path)??fn:void 0,onRetryComparisonDiff:()=>Ln(h=>h+1),loadFullComparisonDiff:Bn,initialDiffData:c==="turn"?L.get(l.path)??null:null},`${Re()}:${f}:${l.path}:${Ke.get(l.path)??0}`),i=l=>st!==null?st:ne&&l===_;return n.jsxs("div",{ref:nn,className:le("flex min-w-0 flex-1 min-h-0 h-full",v?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[ve&&n.jsxs(n.Fragment,{children:[n.jsx("section",{className:"flex max-w-[50%] flex-shrink-0 flex-col",style:{width:`${mt}px`},children:n.jsx(or,{changedFiles:D,selectedFile:ht?.path??null,onSelectFile:Ct})}),n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":a("diffView.fileTree.resize"),tabIndex:0,onPointerDown:Hn,onKeyDown:qn,className:le("relative w-px shrink-0 cursor-col-resize bg-[var(--interactive-border)]/40","before:absolute before:inset-y-0 before:-left-1 before:-right-1 before:content-['']","hover:bg-interactive-selection focus-visible:bg-interactive-selection focus-visible:outline-none",Gn&&"bg-interactive-selection")})]}),wt&&!ve&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:a("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:D.length})]}),n.jsx(rr,{changedFiles:D,selectedFile:null,onSelectFile:Ct})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(zt,{ref:oe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:ve?ht&&t(ht,!0):D.map(l=>t(l))})})})]})},Yn=()=>{if(!f)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a("diffView.state.selectSessionDirectory")});if(c!=="turn"&&K&&!y)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.state.loadingRepositoryStatus")]});if(c!=="turn"&&U===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a("diffView.state.notGitRepository")});if(c==="pr"){if(!Pe||P.error)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:P.error??Ie.error??(Ie.loading?a("session.githubPrPicker.loading.pullRequests"):a("pullRequestComparison.select"))}),(P.error||Ie.error)&&n.jsx(je,{variant:"outline",size:"sm",onClick:()=>{Pe?P.refresh():Ie.refresh()},children:a("diffView.actions.retry")}),!Pe&&!Ie.loading&&n.jsx(on,{comparison:Ie})]});if(!P.files)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.state.loadingDiff")]})}if(c==="commit"){if(Xt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:Xt}),n.jsx(je,{variant:"outline",size:"sm",onClick:()=>{P.refresh()},children:a("diffView.actions.retry")})]});if(!Je&&!_e.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:_e.error??a("commitComparison.noCommits")});if(!Ut)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.state.loadingDiff")]})}if(c==="branch"){if(!En)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.branch.resolvingBase")]});if(!Ce)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(O,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:a("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:a("gitView.pr.toast.baseBranchRequired")})]});if(Jt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:a("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Jt}),n.jsx(je,{variant:"outline",size:"sm",onClick:()=>{P.refresh()},children:a("diffView.actions.retry")})]});if(vt===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("diffView.branch.loadingFiles")]})}return D.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c==="turn"?a("diffView.state.noLastTurnChanges"):c==="pr"?a("walkthrough.blocked.emptyDiff.description"):c==="commit"?a("commitComparison.emptyDiff"):c==="branch"&&Ce?a("diffView.branch.empty",{base:Ms(Ce)}):a("diffView.state.cleanWorkingTree")}):Qn()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[w===!1&&Array.isArray(V)&&V.length>0?n.jsx(Vs,{repositories:V,selectedRepository:C??null,onSelectRepository:t=>{p&&se(p,t)},repositoryRoot:p??void 0}):null,!ce&&(c!=="all"?n.jsx(sr,{scope:c,workingCount:ft,stagedCount:Be,turnCount:Xe,branchCount:Pn,commitCount:c==="commit"?Ut?.length??null:null,prCount:c==="pr"?P.files?.length??null:null,showCommitOption:!Fe(),showBranchOption:$t,onScopeChange:t=>{De(t),b?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:K&&!y?a("diffView.state.loadingChanges"):D.length===1?a("diffView.summary.changedFilesSingle",{count:D.length}):a("diffView.summary.changedFilesPlural",{count:D.length})})})),c==="branch"&&n.jsx(is,{branches:ot?.all??[],currentBranch:J,base:Ce,onSelect:t=>{f&&J&&An(f,J,t)}},JSON.stringify([f,J])),c==="commit"&&n.jsx(os,{commits:_e.commits,selectedHash:Je,loading:_e.loading,error:_e.error,onSelect:_e.select,onRefresh:()=>{_e.refresh()}},JSON.stringify([f,J])),c==="pr"&&n.jsxs(n.Fragment,{children:[n.jsx(on,{comparison:Ie},JSON.stringify([E,f,J])),Pe&&n.jsx(je,{variant:"ghost",size:"sm",disabled:P.loading,"aria-label":a("session.githubIssuePicker.actions.refresh"),title:a("session.githubIssuePicker.actions.refresh"),onClick:()=>{P.refresh()},children:n.jsx(O,{name:"refresh",className:"size-4"})})]}),D.length>0&&n.jsxs(je,{variant:"ghost",size:"sm",onClick:On,className:le("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:G.size>0?a("diffView.actions.collapseAll"):a("diffView.actions.expandAll"),children:[n.jsx(O,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:G.size>0?a("diffView.actions.collapseAll"):a("diffView.actions.expandAll")})]}),D.length>0&&Rt&&n.jsxs(je,{variant:"default",size:"sm",onClick:()=>$e(!0),disabled:Ze,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":a("diffView.actions.reviewAria"),children:[Ze?n.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(O,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:a("diffView.actions.review")})]}),D.length>0&&rt&&n.jsxs(je,{variant:"outline",size:"sm",onClick:()=>{const t=f??"";M(t,c==="pr"&&Pe?Pe:c==="commit"&&Je?{kind:"commit",hash:Je}:c==="branch"&&Ce&&J?{kind:"branch",baseRef:Ce,headRef:J}:{kind:"working-tree",scope:c==="staged"||c==="working"?c:"all"}),S(p??t,"walkthrough")},className:le("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",zs),"aria-label":a("walkthrough.action.open"),children:[n.jsx(O,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}),D.length>0&&!Ue&&n.jsx(je,{variant:"ghost",size:"sm",onClick:()=>bt(W==="tree"?"flat":"tree"),"aria-pressed":W==="tree",className:le("h-5 w-5 p-0 transition-opacity",W==="tree"?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:a(W==="tree"?"diffView.fileTree.showAsList":"diffView.fileTree.showAsTree"),children:n.jsx(O,{name:"node-tree",className:"size-4"})}),D.length>0&&n.jsx(je,{variant:"ghost",size:"sm",onClick:()=>tt(!fe),className:le("h-5 w-5 p-0 transition-opacity",nt?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:a(nt?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(O,{name:"text-wrap",className:"size-4"})}),en&&n.jsx(bn,{mode:en==="side-by-side"?"side-by-side":"unified",onModeChange:Un})]}),n.jsx(Fs,{open:ut,onOpenChange:$e,projectDirectory:f??null,submitting:Ze,onConfirm:Kn}),Yn()]})};function ur(){return new Set}function dr(o,e){return n.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 w-px bg-border/50",style:{left:`${kn+e*Sn+7}px`}},e)}function fr(o){return Array.from({length:o},dr)}export{Mo as DiffView,cr as MultiFileDiffEntry};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/percentages-BXMCSKIN-
|
|
2
|
-
import{_ as io}from"./vendor-vite-runtime-DD1OZmLC.js";import{e as Re,R as i,b as Gi,j as n,r as pt}from"./vendor-react-C3AD0CRp.js";import{g as it,r as pr,a0 as ao,a1 as lo,a2 as oo,a3 as co,a4 as Ze,u as ht,a5 as uo,a6 as Xi,z as fo,d as Ji,e as mo,f as ho,h as po,k as go,j as xo}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/percentages-BXMCSKIN-nJkK2U43.js","assets/vendor-react-C3AD0CRp.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-jotai-scope-3tBts5pd.js","assets/vendor-jotai-8KuHw3Mr.js","assets/vendor-clsx-C_d985j6.js","assets/vendor-roughjs-BQ23fKRo.js","assets/vendor-hachure-fill-BzXPAOFP.js","assets/vendor-path-data-parser-Bh3OoUOX.js","assets/vendor-points-on-curve-NissS9uD.js","assets/vendor-points-on-path-iS7yMbGN.js","assets/vendor-nanoid-BPwC-cGs.js","assets/vendor-radix-ui-react-popover-DtwO38E3.js","assets/vendor-radix-ui-primitive-DOdKROq0.js","assets/vendor-radix-ui-react-compose-refs-OwL660na.js","assets/vendor-radix-ui-react-context-BGG-1ggC.js","assets/vendor-radix-ui-react-dismissable-layer-3AH-Or1W.js","assets/vendor-radix-ui-react-primitive-CUfg3gbV.js","assets/vendor-radix-ui-react-slot-CLI2-QJb.js","assets/vendor-babel-runtime-CF3RwP-h.js","assets/vendor-radix-ui-react-use-callback-ref-D1Sqy0CZ.js","assets/vendor-radix-ui-react-use-escape-keydown-D0tG0-sR.js","assets/vendor-radix-ui-react-focus-guards-DOvT22db.js","assets/vendor-radix-ui-react-focus-scope-CqvJmvlR.js","assets/vendor-radix-ui-react-id-CciEoFzD.js","assets/vendor-radix-ui-react-use-layout-effect-ChlApEEc.js","assets/vendor-radix-ui-react-popper-C4hGM0BT.js","assets/vendor-floating-ui-react-dom-VN3-0QGl.js","assets/vendor-floating-ui-dom-BERnAEiB.js","assets/vendor-floating-ui-core-DBVSD8FA.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-radix-ui-react-arrow-zEsMDF-w.js","assets/vendor-radix-ui-react-use-size-DNhlRIno.js","assets/vendor-radix-ui-react-portal-EaY9b0dR.js","assets/vendor-radix-ui-react-presence-DBDb0ROU.js","assets/vendor-radix-ui-react-use-controllable-state-DprBN3PW.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-react-remove-scroll-CdTdY8wV.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-DAxITgbW.js","assets/vendor-react-style-singleton-XBDcq1Ec.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-CzUV4Fx5.js","assets/vendor-use-callback-ref-h1JrcWGd.js","assets/vendor-open-color-V9xkqpHG.js","assets/vendor-lodash.throttle-BRaj7pHu.js","assets/vendor-fuzzy-C9ETboLH.js","assets/vendor-tunnel-rat-0kpAON_t.js","assets/vendor-zustand-XNmn2Hnw.js","assets/vendor-use-sync-external-store-DVVwmGAS.js","assets/vendor-radix-ui-react-tabs-B7EwPgud.js","assets/vendor-radix-ui-react-roving-focus-DeRerYbD.js","assets/vendor-radix-ui-react-collection-HhtFkL-s.js","assets/vendor-radix-ui-react-direction-klIonjq4.js","assets/vendor-lodash.debounce-02zzrjAw.js","assets/vendor-excalidraw-laser-pointer-DaKXwR12.js","assets/vendor-browser-fs-access-Cx9MrkCf.js","assets/useAppFontEffects-FdVEdwq7.js","assets/index-BvpIhpBI.js","assets/vendor-zod-C3BVLiwa.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-ryXjyKdZ.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-CyPa587s.js","assets/vendor-base-ui-BV0ycO3d.js","assets/vendor-dnd-kit-core-B-dmENub.js","assets/vendor-dnd-kit-utilities-D2MO70n8.js","assets/vendor-dnd-kit-accessibility-vxqCsF6D.js","assets/vendor-dnd-kit-sortable-DiuAkJDx.js","assets/vendor-tanstack-react-virtual-BHz8HhxS.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.js","assets/vendor-framer-motion-0pQCvQRa.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-CMlKUx1I.js","assets/vendor-cmdk-WpnCe4Xz.js","assets/vendor-radix-ui-react-dialog-Cya58wJc.js","assets/vendor-codemirror-language-Cg8boEOY.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-CN8Enbjc.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-Dw1gdHuT.js","assets/vendor-codemirror-lang-json-DzRRSgj9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-B_seq3PB.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CcuPVz08.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-B3FiTjDN.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CaoLP1ZV.js","assets/vendor-codemirror-lang-python-frX4-6UW.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-Cg3hFNyu.js","assets/vendor-legendapp-list-ZsDnss2w.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/vendor-lz-string-UNqkxtPb.js","assets/vendor-png-chunks-extract-BCKwhb8p.js","assets/vendor-crc-32-BuFNj7fX.js","assets/vendor-png-chunk-text-Q7tuZ_MM.js","assets/vendor-png-chunks-encode-CoXIVtFh.js","assets/vendor-sliced-RCuF2qu8.js","assets/vendor-pako-BbNJEP_X.js","assets/vendor-es6-promise-pool-CNrkmOdv.js","assets/vendor-perfect-freehand-BCOc8OPd.js","assets/vendor-braintree-sanitize-url-AqzL09bP.js","assets/vendor-fractional-indexing--iv_-3Ju.js","assets/percentages-BXMCSKIN-DKtWzx8O.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as io}from"./vendor-vite-runtime-DD1OZmLC.js";import{e as Re,R as i,b as Gi,j as n,r as pt}from"./vendor-react-C3AD0CRp.js";import{g as it,r as pr,a0 as ao,a1 as lo,a2 as oo,a3 as co,a4 as Ze,u as ht,a5 as uo,a6 as Xi,z as fo,d as Ji,e as mo,f as ho,h as po,k as go,j as xo}from"./index-BvpIhpBI.js";import{u as at,Z as Yi,a2 as ba,aH as vo,h as U,dg as wo,aK as bo,y as Es,B as I,I as T,dh as yo,bR as Rs,az as jo,aA as No,j as So,a4 as Co,a3 as Fo,a1 as Ro,bL as ko,l as Eo,g as Zi,a7 as To,bb as Vo,t as se,a8 as Qi,aa as ar,di as Ss,dj as Cs,bN as Po,a0 as Mo,dk as Fs,b9 as Do,bP as lr,dl as or,dm as ea,dn as ta,dp as sa,dq as na,dr as zo,ds as Ao,dt as Lo,ab as Io,du as Oo,dv as Bo,dw as $o,e as ya,d as ja,c as Na,D as Sa,b as Ca,bW as Fa,F as gr,A as xr,C as vr,al as yn,S as cr,an as xn,x as ur,ai as Ot,aj as Bt,ak as $t,dx as _o,aF as Wo,b8 as Uo,am as Nn,cm as Ko,dy as Ho}from"./useAppFontEffects-FdVEdwq7.js";import{e as qo,s as Go,u as Xo,C as Jo,f as Yo,g as Zo,h as Qo,i as ec}from"./runtimeEndpointReset-D56xMbiw.js";import{c as ra,s as tc,P as as,C as sc}from"./shikiHighlight-BPUnGgQg.js";import{a as nc}from"./vendor-codemirror-state-C9awkmn-.js";import{E as _t}from"./vendor-codemirror-view-CiLROUVV.js";import{V as rc,J as ic,F as ac}from"./JsonTreeView-DIy-frOy.js";import{ensurePierreThemeRegistered as ia,getResolvedShikiTheme as lc}from"./appThemeRegistry-CWAKiwky.js";import{V as oc,W as cc}from"./Virtualizer-CtRzP13T.js";import{V as uc}from"./Virtualizer-D_a8gKmg.js";import{D as dc}from"./vendor-react-drawio-DR5-Wn9a.js";import{D as fc,u as vn,a as mc,s as hc,b as pc}from"./scheduledTasksApi-BZMS2h6Z.js";import{I as gc,u as xc,n as vc}from"./useInlineCommentController-Bf5t_8QQ.js";import{b as wc}from"./CodeMirrorCommentWidgets-e9rY9Jxg.js";function aa(r){const e=Re.c(41),{containerRef:t,filePath:a,fileContent:v}=r,{t:f}=at(),w=Yi(Rc),d=Yi(Fc),x=ba(),p=vo(Cc),[m,b]=i.useState(null),[N,F]=i.useState(""),[S,C]=i.useState(!1),g=i.useRef(!1),o=i.useRef(null),E=i.useRef(null),[k,M]=i.useState(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{b(null),F(""),C(!1),g.current=!1,E.current=null,M(null)},e[0]=D):D=e[0];const L=D;let R,P;e[1]!==t?(R=()=>{const _=t.current;if(!_)return;const ie=()=>{if(g.current)return;const H=window.getSelection(),ce=H?.toString().trim()??"";if(!H||!ce||H.rangeCount===0){L();return}const fe=H.getRangeAt(0);if(!_.contains(fe.commonAncestorContainer)){L();return}const be=fe.getBoundingClientRect();E.current=fe.cloneRange(),F(ce),b({x:be.left+be.width/2,y:be.top-10})},xe=H=>{o.current?.contains(H.target)||g.current&&L()};return document.addEventListener("selectionchange",ie),document.addEventListener("pointerdown",xe),()=>{document.removeEventListener("selectionchange",ie),document.removeEventListener("pointerdown",xe)}},P=[t,L],e[1]=t,e[2]=R,e[3]=P):(R=e[2],P=e[3]),i.useEffect(R,P);let z;e[4]!==v?(z=_=>{const ie=ae=>v.slice(0,ae).split(`
|
|
3
3
|
`).length,xe=Nc,H=(ae,We)=>{for(const ve of xe(ae)){const ye=v.indexOf(ve,We);if(ye>=0)return ye}return-1},ce=_.length>=8?v.indexOf(_):-1;if(ce>=0){const ae=ie(ce);return{start:ae,end:ae+_.split(`
|
|
4
4
|
`).length-1}}const fe=_.split(`
|
|
5
5
|
`).map(jc).filter(Boolean);if(fe.length===0)return null;const be=H(fe[0],0);if(be<0)return null;const ue=ie(be);if(fe.length===1)return{start:ue,end:ue};const ze=H(fe[fe.length-1],be);return ze<0?null:{start:ue,end:Math.max(ue,ie(ze))}},e[4]=v,e[5]=z):z=e[5];const $=z;let K;e[6]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{const _=E.current;if(!_){M(null);return}M(wo(_))},e[6]=K):K=e[6];const Q=K;let ne,te;e[7]!==S?(ne=()=>{if(!S)return;let _=null;const ie=()=>{_===null&&(_=window.requestAnimationFrame(()=>{_=null,Q()}))};return document.addEventListener("scroll",ie,{capture:!0,passive:!0}),window.addEventListener("resize",ie),()=>{_!==null&&window.cancelAnimationFrame(_),document.removeEventListener("scroll",ie,{capture:!0}),window.removeEventListener("resize",ie)}},te=[S,Q],e[7]=S,e[8]=ne,e[9]=te):(ne=e[8],te=e[9]),i.useEffect(ne,te);let X;e[10]!==N?(X=()=>{N&&(C(!0),g.current=!0,Q(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=X):X=e[11];const J=X;let Y;e[12]!==p||e[13]!==w||e[14]!==x||e[15]!==a||e[16]!==d||e[17]!==$||e[18]!==N?(Y=_=>{const ie=w??(d?"draft":null);if(!N||!ie||!x){L();return}const xe=$(N);p({directory:x,sessionKey:ie},{source:"file-quote",fileLabel:a,startLine:xe?.start??0,endLine:xe?.end??0,code:N,language:"",text:_.trim()}),L(),queueMicrotask(yc)},e[12]=p,e[13]=w,e[14]=x,e[15]=a,e[16]=d,e[17]=$,e[18]=N,e[19]=Y):Y=e[19];const G=Y;if(!m)return null;let ee;e[20]!==S||e[21]!==$||e[22]!==N?(ee=S?$(N):null,e[20]=S,e[21]=$,e[22]=N,e[23]=ee):ee=e[23];const $e=ee;let re;e[24]!==m.x||e[25]!==m.y?(re={left:m.x,top:m.y,transform:"translate(-50%, -100%)"},e[24]=m.x,e[25]=m.y,e[26]=re):re=e[26];let Me;e[27]!==S||e[28]!==k?(Me=S&&k&&k.length>0?Gi.createPortal(n.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:k.map(bc)}),document.body):null,e[27]=S,e[28]=k,e[29]=Me):Me=e[29];let De;e[30]!==S||e[31]!==a||e[32]!==$e||e[33]!==J||e[34]!==G||e[35]!==f?(De=S?n.jsx("div",{className:"w-[min(420px,80vw)]",children:n.jsx(gc,{fileLabel:a,lineRange:$e?{start:$e.start,end:$e.end}:void 0,onSave:G,onCancel:L})}):n.jsx("div",{className:U("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:n.jsx("button",{type:"button",onClick:J,className:U("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:f("chat.textSelection.title.commentOnSelection"),children:f("chat.textSelection.actions.comment")})}),e[30]=S,e[31]=a,e[32]=$e,e[33]=J,e[34]=G,e[35]=f,e[36]=De):De=e[36];let _e;return e[37]!==re||e[38]!==Me||e[39]!==De?(_e=Gi.createPortal(n.jsxs("div",{ref:o,className:"fixed z-50",style:re,children:[Me,De]}),document.body),e[37]=re,e[38]=Me,e[39]=De,e[40]=_e):_e=e[40],_e}function bc(r,e){return n.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:r.left,top:r.top,width:r.width,height:r.height}},e)}function yc(){bo()}function jc(r){return r.trim()}function Nc(r){const e=r.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Sc)}function Sc(r){return r.length>=8}function Cc(r){return r.addDraft}function Fc(r){return r.newSessionDraft?.open}function Rc(r){return r.currentSessionId}const kc=(r,e)=>{if(!e)return null;const t=Number.parseInt(r.trim(),10);return!Number.isFinite(t)||t<1?null:Math.min(t,e.state.doc.lines)},la=(r,e)=>{const t=r.state.doc.lineAt(e.main.head);return{lineNumber:t.number,character:e.main.head-t.from+1,selection:e}},oa=(r,e,t)=>{const a=r.state.doc.line(e),v=Math.max(1,Math.min(t,a.length+1)),f=a.from+v-1;r.dispatch({selection:nc.cursor(f),effects:_t.scrollIntoView(f,{y:"center"})})};function Ec({open:r,onOpenChange:e,view:t,variant:a="overlay"}){const{t:v}=at(),[f,w]=i.useState(""),d=i.useRef(null),x=i.useRef(!1),p=i.useRef(null),m=i.useRef(null),b=i.useMemo(()=>kc(f,t),[f,t]);i.useEffect(()=>{!r||!t||(x.current=!1,d.current=la(t,t.state.selection),w(""))},[r,t]),i.useEffect(()=>{r&&window.requestAnimationFrame(()=>{m.current?.focus(),m.current?.select()})},[r]),i.useEffect(()=>{if(!(!r||!t||!d.current)){if(b===null){const{selection:g}=d.current;t.dispatch({selection:g,effects:_t.scrollIntoView(g.main.from,{y:"center"})});return}oa(t,b,d.current.character)}},[b,r,t]);const N=i.useCallback(()=>{if(!t||x.current||!d.current)return;const{selection:g}=d.current;t.dispatch({selection:g,effects:_t.scrollIntoView(g.main.from,{y:"center"})})},[t]),F=i.useCallback(g=>{g||N(),e(g)},[e,N]),S=i.useCallback(()=>{!t||b===null||!d.current||(x.current=!0,oa(t,b,d.current.character),e(!1),t.focus())},[b,e,t]);i.useEffect(()=>{if(!r)return;const g=E=>{const k=p.current,M=E.target;!k||!(M instanceof Node)||k.contains(M)||F(!1)},o=E=>{E.key==="Escape"&&(E.preventDefault(),F(!1))};return document.addEventListener("pointerdown",g,!0),document.addEventListener("keydown",o,!0),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("keydown",o,!0)}},[F,r,a]);const C=i.useMemo(()=>{if(!t)return v("goToLineDialog.helper.editorUnavailable");if(b===null){const g=d.current??la(t,t.state.selection);return v("goToLineDialog.helper.currentLineRange",{current:g.lineNumber,max:t.state.doc.lines})}return v("goToLineDialog.helper.goToLine",{line:b})},[b,v,t]);return a==="inline"?r?n.jsxs("div",{ref:p,className:"ml-1 flex h-6 items-center gap-1",children:[n.jsx(Es,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:g=>w(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),S())},placeholder:v("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(I,{variant:"outline",size:"xs",onClick:S,disabled:!t||b===null,className:"h-6 px-2",children:v("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:p,className:U("absolute left-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",r?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx(Es,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:g=>w(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),S())},placeholder:v("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:C})]})})}const Tc=(r,e)=>{const t=e.trim().toLowerCase(),a=[];if(!t)return a;const v=r.toLowerCase();let f=0;for(;;){const w=v.indexOf(t,f);if(w===-1)break;a.push({start:w,end:w+t.length}),f=w+t.length}return a},Sn="data-md-find",dr="data-md-find-current",Ra="rounded-[2px] bg-status-warning/30 text-foreground",Vc="rounded-[2px] bg-status-warning/60 text-foreground",Pc=120,Mc=r=>r instanceof Element&&r.hasAttribute(Sn),Dc=r=>r.target instanceof Element&&r.target.hasAttribute(Sn)?!0:[...r.addedNodes].some(e=>Mc(e)),ka=r=>{const e=new Set;r.querySelectorAll(`mark[${Sn}]`).forEach(t=>{const a=t.parentNode;a&&(a.replaceChild(document.createTextNode(t.textContent??""),t),e.add(a))}),e.forEach(t=>t.normalize())},zc=(r,e)=>{ka(r);const t=e.trim().toLowerCase();if(!t)return[];const a=[],v=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(w){const d=w.parentElement;return!d||d.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),f=[];for(;v.nextNode();){const w=v.currentNode;w instanceof Text&&f.push(w)}for(const w of f){const d=w.nodeValue??"";if(!d)continue;const x=Tc(d,t);if(x.length===0)continue;const p=w.parentNode;if(!p)continue;const m=document.createDocumentFragment();let b=0;for(const N of x){N.start>b&&m.appendChild(document.createTextNode(d.slice(b,N.start)));const F=document.createElement("mark");F.setAttribute(Sn,""),F.className=Ra,F.textContent=d.slice(N.start,N.end),m.appendChild(F),a.push(F),b=N.end}b<d.length&&m.appendChild(document.createTextNode(d.slice(b))),p.replaceChild(m,w)}return a},ca=({containerRef:r,open:e,onOpenChange:t,focusNonce:a,className:v})=>{const{t:f}=at(),[w,d]=i.useState(""),[x,p]=i.useState(0),[m,b]=i.useState(0),N=i.useRef(null),F=i.useRef([]),S=i.useRef(w);S.current=w;const C=i.useRef(null),g=i.useRef(null),o=i.useCallback((R,P=!1)=>{const z=r.current;if(!z){F.current=[],p(0),b(0);return}F.current=zc(z,R);const $=F.current.length;p($),b(K=>!P||$===0?0:Math.min(K,$-1))},[r]),E=i.useCallback((R,P=!1)=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{C.current=null,o(R,P)},Pc)},[o]);i.useEffect(()=>()=>{C.current&&clearTimeout(C.current)},[]);const k=i.useCallback(()=>{t(!1);const R=g.current;g.current=null,R?.isConnected&&R.focus()},[t]);i.useEffect(()=>{const R=r.current;if(!e||!R)return;const P=new MutationObserver(z=>{!S.current.trim()||!z.some(K=>!Dc(K))||E(S.current,!0)});return P.observe(R,{childList:!0,subtree:!0,characterData:!0}),()=>{P.disconnect(),ka(R)}},[r,e,E]),i.useEffect(()=>{if(!e)return;const R=document.activeElement;R instanceof HTMLElement&&!g.current&&(g.current=R),N.current?.focus()},[e]),i.useEffect(()=>{e&&a>0&&(N.current?.focus(),N.current?.select())},[e,a]),i.useEffect(()=>{const R=r.current;if(!R||(R.querySelectorAll(`mark[${dr}]`).forEach(z=>{z.removeAttribute(dr),z.className=Ra}),x===0))return;const P=F.current[Math.min(Math.max(m,0),x-1)];P&&(P.setAttribute(dr,""),P.className=Vc,P.scrollIntoView({block:"nearest"}))},[r,m,x]);const M=i.useCallback(()=>{b(R=>x===0?0:(R+1)%x)},[x]),D=i.useCallback(()=>{b(R=>x===0?0:(R-1+x)%x)},[x]),L=i.useCallback(R=>{R.key==="Enter"?(R.preventDefault(),R.shiftKey?D():M()):R.key==="Escape"&&(R.preventDefault(),k())},[k,M,D]);return e?n.jsxs("div",{className:U("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",v),children:[n.jsx(T,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),n.jsx(Es,{ref:N,value:w,onChange:R=>{d(R.target.value),E(R.target.value)},onKeyDown:L,placeholder:f("filesView.preview.find.placeholder"),"aria-label":f("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),n.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":x>0?f("filesView.preview.find.countAria",{current:m+1,total:x}):f("filesView.preview.find.noMatches"),children:w.trim()&&x===0?f("filesView.preview.find.noMatches"):x>0?`${m+1}/${x}`:""}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:f("filesView.preview.find.previousAria"),"aria-label":f("filesView.preview.find.previousAria"),disabled:x===0,children:n.jsx(T,{name:"arrow-up",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:f("filesView.preview.find.nextAria"),"aria-label":f("filesView.preview.find.nextAria"),disabled:x===0,children:n.jsx(T,{name:"arrow-down",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:k,title:f("filesView.preview.find.closeAria"),"aria-label":f("filesView.preview.find.closeAria"),children:n.jsx(T,{name:"close",className:"size-3.5"})})]}):null},Ac=r=>{let e=!0;return{poll:async()=>{if(!e||r.isDirty())return!1;const t=r.getLoadedContent(),a=r.getLoadedRevision();try{const v=await r.readContent();if(!e||r.isDirty()||a!==r.getLoadedRevision())return!1;if(v===t)return!0;const f=await r.readContent();return!e||r.isDirty()||f!==v||a!==r.getLoadedRevision()?!1:(r.applyContent(v),!0)}catch{return!1}},dispose:()=>{e=!1}}},Lc=1,Ic=(r,e)=>e.size!==r.size||e.mtimeMs!==void 0&&r.mtimeMs!==void 0&&Math.abs(e.mtimeMs-r.mtimeMs)>=Lc;function ua(){const r=Re.c(8),[e]=pt.useState(Oc),t=pt.useRef(!1);let a;r[0]!==e?(a=x=>{if(x==null){e.cleanUp(),t.current=!1;return}t.current||(t.current=!0,e.setup(x,x.firstElementChild??void 0))},r[0]=e,r[1]=a):a=r[1];const v=a;let f,w;r[2]!==e?(f=()=>()=>{t.current=!1,e.cleanUp()},w=[e],r[2]=e,r[3]=f,r[4]=w):(f=r[3],w=r[4]),pt.useLayoutEffect(f,w);let d;return r[5]!==v||r[6]!==e?(d={virtualizer:e,setScroller:v},r[5]=v,r[6]=e,r[7]=d):d=r[7],d}function Oc(){return new uc}const ls=new Map,Bc=100;function wn(r){const[e,t]=pt.useState(null),a=pt.useRef(null),v=pt.useRef(null),f=pt.useRef(null),w=pt.useCallback((d,x)=>{d&&x instanceof rc&&(f.current={key:r,file:x,node:d});const p=a.current,m=v.current,b=()=>{a.current===p&&(p?.(),m?.())};x?queueMicrotask(b):b()},[r]);return pt.useLayoutEffect(()=>{if(!e||!r)return;const d=ls.get(r)??{top:0,left:0};let x=!0;const p=()=>f.current?.key===r?f.current.file:null,m=o=>f.current?.key===r?f.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${o-1}"]`):null,b=()=>{F.disconnect(),S.disconnect()},N=()=>{if(!x)return;const o=p(),E=d.line&&o?.getLinePosition(d.line.number),k=d.line&&m(d.line.number);let M=d.top;d.line&&E&&(M=(o?.top??0)+E.top-d.line.offset),d.line&&k&&(M=e.scrollTop+k.getBoundingClientRect().top-e.getBoundingClientRect().top-d.line.offset),e.scrollTop=M,e.scrollLeft=d.left,(!d.line||k)&&Math.abs(e.scrollTop-M)<1&&Math.abs(e.scrollLeft-d.left)<1&&(x=!1,b())},F=new ResizeObserver(N),S=new MutationObserver(()=>{if(x){for(const o of e.children)F.observe(o);N()}});F.observe(e);for(const o of e.children)F.observe(o);S.observe(e,{childList:!0,subtree:!0});const C=()=>{if(x)return;const o=p(),E=o?.getNumericScrollAnchor(e.scrollTop-(o.top??0)),k=E&&m(E.lineNumber),M=k?k.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(ls.delete(r),ls.set(r,{top:e.scrollTop,left:e.scrollLeft,line:E&&M!==null&&M>=0&&M<e.clientHeight?{number:E.lineNumber,offset:M}:void 0}),ls.size>Bc){const D=ls.keys().next().value;D!==void 0&&ls.delete(D)}},g=()=>{x=!1,b()};return a.current=N,v.current=C,N(),e.addEventListener("scroll",C,{passive:!0}),e.addEventListener("wheel",g,{passive:!0}),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("pointerdown",g,{passive:!0}),e.addEventListener("keydown",g),()=>{a.current=null,v.current=null,f.current?.key===r&&(f.current=null),b(),e.removeEventListener("scroll",C),e.removeEventListener("wheel",g),e.removeEventListener("touchstart",g),e.removeEventListener("pointerdown",g),e.removeEventListener("keydown",g)}},[r,e]),{setScroller:t,restore:w}}function $c(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function _c(r){return r.selectedFilePath?r.isDirty?!(r.fileLoading||r.loadedFilePath!==r.selectedFilePath||r.isNonEditableBinary||r.draftContent===""&&r.fileContent!==""&&r.loadedFilePath!==r.selectedFilePath):!0:!1}const Ea=2e5,Wc=r=>{let e=0,t=0;for(let a=0;a<r.length;a++)r.charCodeAt(a)===10&&(a>0&&r.charCodeAt(a-1)===13?e++:t++);return e>t?`\r
|
|
@@ -10,7 +10,7 @@ import{_ as io}from"./vendor-vite-runtime-DD1OZmLC.js";import{e as Re,R as i,b a
|
|
|
10
10
|
`?t.replace(/\n/g,`\r
|
|
11
11
|
`):t},Hc=(r,e)=>e??(r.length>Ea?"view":"edit"),qc=r=>{let e=2166136261;for(let t=0;t<r.length;t++)e^=r.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${r.length}:${e.toString(16)}`},Gc='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function da(){if(typeof document>"u")return!1;const r=document.documentElement.getAttribute("data-theme");return r==="dark"||!r&&window.matchMedia("(prefers-color-scheme: dark)").matches}const Xc=i.forwardRef(function({xml:e,readOnly:t,className:a,onChange:v},f){const w=i.useRef(e),d=i.useRef(null),x=i.useRef(!1),[p,m]=i.useState(da),b=i.useRef(e),N=i.useRef(e);N.current!==e&&(N.current=e,b.current=e,w.current=e);const F=i.useRef(p);F.current!==p&&(F.current=p,b.current=w.current);const S=i.useRef(null);i.useEffect(()=>{const o=()=>m(da());o();const E=new MutationObserver(o);return E.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>E.disconnect()},[]),i.useEffect(()=>{const o=setTimeout(()=>{S.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(o)},[]),i.useImperativeHandle(f,()=>({getXml:()=>w.current}));const C=i.useCallback(()=>{!e&&!x.current&&(x.current=!0,setTimeout(()=>{d.current?.template({})},500))},[e]),g=i.useCallback(o=>{w.current=o.xml,v?.(o.xml)},[v]);return n.jsx("div",{ref:S,className:U("h-full w-full",a),children:n.jsx(dc,{ref:d,xml:b.current||Gc,autosave:!0,urlParameters:{ui:t?"simple":p?"dark":"kennedy",spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:C,onAutoSave:g},p?"dark":"light")})}),Jc={en:"en",de:"de-DE",es:"es-ES",fr:"fr-FR",ja:"ja-JP",ko:"ko-KR",pl:"pl-PL","pt-BR":"pt-BR",tr:"tr-TR",uk:"uk-UA","zh-CN":"zh-CN","zh-TW":"zh-TW"},td=r=>Jc[r],Va=/^(#{1,6}[ \t]+Drawing[^\n]*\r?\n)([^`]*)(```(?:compressed-json|json)[ \t]*\r?\n)([\s\S]*?)(\r?\n```)/m,sd=r=>{const e=Va.exec(r);if(!e)return null;const t=e.index+e[1].length+e[2].length+e[3].length;return{start:t,end:t+e[4].length,compressed:e[3].includes("compressed-json")}},Yc=r=>{const e=r.trim();if(!e.startsWith("{"))return!1;try{const t=JSON.parse(e);return Array.isArray(t.elements)}catch{return!1}},Zc=r=>Yc(r)||Va.test(r),wr=r=>r.trim()===""||Zc(r),Qc=r=>r.isExcalidraw&&r.viewMode==="preview"&&r.previewReady&&wr(r.draft),eu=r=>r.toLowerCase().endsWith(".excalidraw.md")?"obsidian":"json",nd=(r,e)=>{let t=0;for(const a of r)t=t*31+a.version+a.versionNonce|0;return[r.length,t,e.viewBackgroundColor??"",e.gridModeEnabled?1:0,e.gridSize??"",e.gridStep??""].join(":")},rd=r=>{let e=r,t=r;return{observe:a=>{const v=a!==t;return t=a,{edited:v,dirty:a!==e}},markSaved:a=>(e=a,t!==a)}},Ts=r=>{const e=Re.c(18),{items:t,actions:a,className:v}=r;let f,w,d,x;if(e[0]!==a||e[1]!==v||e[2]!==t){x=Symbol.for("react.early_return_sentinel");e:{const N=t.filter(tu);if(N.length===0&&!a){x=null;break e}e[7]!==v?(d=U("flex min-h-7 items-center gap-2 border-b border-border/40 bg-[var(--surface-subtle)] px-3 py-1",v),e[7]=v,e[8]=d):d=e[8],f="min-w-0 flex-1 truncate typography-meta text-muted-foreground",w=N.join(" · ")}e[0]=a,e[1]=v,e[2]=t,e[3]=f,e[4]=w,e[5]=d,e[6]=x}else f=e[3],w=e[4],d=e[5],x=e[6];if(x!==Symbol.for("react.early_return_sentinel"))return x;let p;e[9]!==f||e[10]!==w?(p=n.jsx("div",{className:f,children:w}),e[9]=f,e[10]=w,e[11]=p):p=e[11];let m;e[12]!==a?(m=a?n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a}):null,e[12]=a,e[13]=m):m=e[13];let b;return e[14]!==d||e[15]!==p||e[16]!==m?(b=n.jsxs("div",{className:d,children:[p,m]}),e[14]=d,e[15]=p,e[16]=m,e[17]=b):b=e[17],b};function tu(r){return r.length>0}const Vs=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";if(r<1024)return`${r} B`;const e=["KB","MB","GB"];let t=r/1024;for(const a of e){if(t<1024||a===e[e.length-1])return`${t.toFixed(t>=10?0:1)} ${a}`;t/=1024}return""},su=r=>{if(r===null||!Number.isFinite(r)||r<0)return"";const e=Math.round(r),t=Math.floor(e/3600),a=Math.floor(e%3600/60),v=e%60,f=w=>String(w).padStart(2,"0");return t>0?`${t}:${f(a)}:${f(v)}`:`${a}:${f(v)}`},Pa=r=>r&&r.width>0&&r.height>0?`${r.width} × ${r.height}`:"",nu=r=>{const e=Re.c(28),{name:t,path:a,sizeBytes:v,download:f}=r,{t:w}=at();let d,x,p,m,b,N,F;if(e[0]!==t||e[1]!==a||e[2]!==v||e[3]!==w){const o=yo(a).toUpperCase();N="flex h-full min-h-0 flex-col",F=n.jsx(Ts,{items:[o,Vs(v)]}),p="flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",e[11]!==a?(m=n.jsx(Rs,{filePath:a,className:"size-10"}),e[11]=a,e[12]=m):m=e[12],e[13]!==t?(b=n.jsx("div",{className:"max-w-full truncate typography-ui-header text-foreground",children:t}),e[13]=t,e[14]=b):b=e[14],d="max-w-md typography-ui text-muted-foreground",x=o?w("filesView.artifact.binary.descriptionWithType",{extension:o}):w("filesView.artifact.binary.description"),e[0]=t,e[1]=a,e[2]=v,e[3]=w,e[4]=d,e[5]=x,e[6]=p,e[7]=m,e[8]=b,e[9]=N,e[10]=F}else d=e[4],x=e[5],p=e[6],m=e[7],b=e[8],N=e[9],F=e[10];let S;e[15]!==d||e[16]!==x?(S=n.jsx("div",{className:d,children:x}),e[15]=d,e[16]=x,e[17]=S):S=e[17];let C;e[18]!==f||e[19]!==p||e[20]!==m||e[21]!==b||e[22]!==S?(C=n.jsxs("div",{className:p,children:[m,b,S,f]}),e[18]=f,e[19]=p,e[20]=m,e[21]=b,e[22]=S,e[23]=C):C=e[23];let g;return e[24]!==N||e[25]!==F||e[26]!==C?(g=n.jsxs("div",{className:N,children:[F,C]}),e[24]=N,e[25]=F,e[26]=C,e[27]=g):g=e[27],g},ru=[48,32,24,18,14],iu=["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz",`0123456789 .,;:!?&@#%()[]{}<>+-=/\\*"'`];let fr=0;const au=r=>{const e=Re.c(16),{src:t,name:a,sizeBytes:v}=r,{t:f}=at(),[w,d]=i.useState("loading"),[x]=i.useState(lu);let p,m;e[0]!==x||e[1]!==t?(p=()=>{let C=!1;d("loading");const g=new FontFace(x,`url("${t.replace(/"/g,"%22")}")`);return document.fonts.add(g),g.load().then(()=>{C||d("ready")}).catch(()=>{C||d("failed")}),()=>{C=!0,document.fonts.delete(g)}},m=[x,t],e[0]=x,e[1]=t,e[2]=p,e[3]=m):(p=e[2],m=e[3]),i.useEffect(p,m);let b;e[4]!==v?(b=Vs(v),e[4]=v,e[5]=b):b=e[5];let N;e[6]!==a||e[7]!==b?(N=n.jsx(Ts,{items:[a,b]}),e[6]=a,e[7]=b,e[8]=N):N=e[8];let F;e[9]!==x||e[10]!==w||e[11]!==f?(F=w==="failed"?n.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-center typography-ui text-muted-foreground",children:f("filesView.artifact.font.loadFailed")}):w==="loading"?n.jsxs("div",{className:"flex items-center gap-2 p-3 typography-ui text-muted-foreground",children:[n.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),f("common.loading")]}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",style:{fontFamily:`"${x}"`},children:n.jsxs("div",{className:"flex flex-col gap-4",children:[ru.map(C=>n.jsxs("div",{className:"flex items-baseline gap-3",children:[n.jsx("span",{className:"w-8 shrink-0 text-right font-sans typography-meta text-muted-foreground",children:C}),n.jsx("span",{className:"min-w-0 break-words leading-tight text-foreground",style:{fontSize:`${C}px`},children:f("filesView.artifact.font.sample")})]},C)),n.jsx("div",{className:"mt-2 flex flex-col gap-1 border-t border-border/40 pt-4 text-foreground",style:{fontSize:"20px"},children:iu.map(ou)})]})}),e[9]=x,e[10]=w,e[11]=f,e[12]=F):F=e[12];let S;return e[13]!==N||e[14]!==F?(S=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[N,F]}),e[13]=N,e[14]=F,e[15]=S):S=e[15],S};function lu(){return fr=fr+1,`oc-font-preview-${fr}`}function ou(r){return n.jsx("div",{className:"break-all leading-relaxed",children:r},r)}const cu=r=>{const e=Re.c(46),{src:t,name:a,sizeBytes:v}=r,{t:f}=at(),[w,d]=i.useState("fit"),[x,p]=i.useState(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{p(null),d("fit")},e[0]=m):m=e[0];let b;e[1]!==t?(b=[t],e[1]=t,e[2]=b):b=e[2],i.useEffect(m,b);let N;e[3]!==x?(N=Pa(x),e[3]=x,e[4]=N):N=e[4];let F;e[5]!==v?(F=Vs(v),e[5]=v,e[6]=F):F=e[6];let S;e[7]!==N||e[8]!==F?(S=[N,F],e[7]=N,e[8]=F,e[9]=S):S=e[9];const C=w==="fit";let g;e[10]!==f?(g=f("filesView.artifact.image.fitTitle"),e[10]=f,e[11]=g):g=e[11];let o;e[12]===Symbol.for("react.memo_cache_sentinel")?(o=()=>d("fit"),e[12]=o):o=e[12];let E;e[13]!==f?(E=f("filesView.artifact.image.fit"),e[13]=f,e[14]=E):E=e[14];let k;e[15]!==C||e[16]!==g||e[17]!==E?(k=n.jsx(I,{variant:"chip",size:"xs","aria-pressed":C,title:g,onClick:o,children:E}),e[15]=C,e[16]=g,e[17]=E,e[18]=k):k=e[18];const M=w==="actual";let D;e[19]!==f?(D=f("filesView.artifact.image.actualTitle"),e[19]=f,e[20]=D):D=e[20];let L;e[21]===Symbol.for("react.memo_cache_sentinel")?(L=()=>d("actual"),e[21]=L):L=e[21];let R;e[22]!==M||e[23]!==D?(R=n.jsx(I,{variant:"chip",size:"xs","aria-pressed":M,title:D,onClick:L,children:"1:1"}),e[22]=M,e[23]=D,e[24]=R):R=e[24];let P;e[25]!==k||e[26]!==R?(P=n.jsxs(n.Fragment,{children:[k,R]}),e[25]=k,e[26]=R,e[27]=P):P=e[27];let z;e[28]!==P||e[29]!==S?(z=n.jsx(Ts,{items:S,actions:P}),e[28]=P,e[29]=S,e[30]=z):z=e[30];const $=w==="fit"&&"flex items-center justify-center";let K;e[31]!==$?(K=U("min-h-0 flex-1 overflow-auto p-3",$),e[31]=$,e[32]=K):K=e[32];let Q;e[33]===Symbol.for("react.memo_cache_sentinel")?(Q=G=>{const ee=G.currentTarget;p({width:ee.naturalWidth,height:ee.naturalHeight})},e[33]=Q):Q=e[33];const ne=w==="fit"?"max-h-full max-w-full object-contain":"max-w-none";let te;e[34]!==ne?(te=U("rounded-md border border-border/30 bg-primary/10",ne),e[34]=ne,e[35]=te):te=e[35];let X;e[36]!==a||e[37]!==t||e[38]!==te?(X=n.jsx("img",{src:t,alt:a,draggable:!1,onLoad:Q,className:te},t),e[36]=a,e[37]=t,e[38]=te,e[39]=X):X=e[39];let J;e[40]!==K||e[41]!==X?(J=n.jsx("div",{className:K,children:X}),e[40]=K,e[41]=X,e[42]=J):J=e[42];let Y;return e[43]!==z||e[44]!==J?(Y=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[z,J]}),e[43]=z,e[44]=J,e[45]=Y):Y=e[45],Y},uu=r=>{const e=Re.c(24),{kind:t,src:a,name:v,sizeBytes:f,download:w}=r,{t:d}=at(),[x,p]=i.useState(null),[m,b]=i.useState(null),[N,F]=i.useState(!1);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{p(null),b(null),F(!1)},e[0]=S):S=e[0];let C;e[1]!==a?(C=[a],e[1]=a,e[2]=C):C=e[2],i.useEffect(S,C);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=P=>{const z=P.currentTarget;p(Number.isFinite(z.duration)?z.duration:null),z instanceof HTMLVideoElement&&b({width:z.videoWidth,height:z.videoHeight})},e[3]=g):g=e[3];const o=g;let E;e[4]!==x?(E=su(x),e[4]=x,e[5]=E):E=e[5];let k;e[6]!==m?(k=Pa(m),e[6]=m,e[7]=k):k=e[7];let M;e[8]!==f?(M=Vs(f),e[8]=f,e[9]=M):M=e[9];let D;e[10]!==E||e[11]!==k||e[12]!==M?(D=n.jsx(Ts,{items:[E,k,M]}),e[10]=E,e[11]=k,e[12]=M,e[13]=D):D=e[13];let L;e[14]!==w||e[15]!==N||e[16]!==t||e[17]!==v||e[18]!==a||e[19]!==d?(L=N?n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:d("filesView.artifact.media.unplayable")}),w]}):t==="video"?n.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-[var(--surface-background)] p-3",children:n.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",title:v,className:"max-h-full max-w-full rounded-md",onLoadedMetadata:o,onError:()=>F(!0)},a)}):n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-6",children:[n.jsx("div",{className:"typography-ui-label truncate text-foreground",children:v}),n.jsx("audio",{src:a,controls:!0,preload:"metadata",title:v,className:"w-full max-w-lg",onLoadedMetadata:o,onError:()=>F(!0)},a)]}),e[14]=w,e[15]=N,e[16]=t,e[17]=v,e[18]=a,e[19]=d,e[20]=L):L=e[20];let R;return e[21]!==D||e[22]!==L?(R=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[D,L]}),e[21]=D,e[22]=L,e[23]=R):R=e[23],R},du=2e3,fu=r=>r.toLowerCase().endsWith(".tsv")?" ":",",mu=(r,e,t=du)=>{const a=[];let v=0,f="",w=[],d=!1,x=!1;const p=()=>{w.push(f),f="",w.length===1&&w[0]===""&&!x||((v===0||a.length<=t)&&a.push(w),v+=1),w=[],x=!1},m=r.charCodeAt(0)===65279?r.slice(1):r;for(let C=0;C<m.length;C+=1){const g=m[C];if(d){g==='"'?m[C+1]==='"'?(f+='"',C+=1):d=!1:f+=g;continue}if(g==='"'){d=!0,x=!0;continue}if(g===e){w.push(f),f="",x=!0;continue}if(g===`
|
|
12
12
|
`||g==="\r"){g==="\r"&&m[C+1]===`
|
|
13
|
-
`&&(C+=1),p();continue}f+=g}(f.length>0||w.length>0||d)&&p();const b=a[0]??[],N=a.slice(1),F=a.reduce((C,g)=>Math.max(C,g.length),0),S=Math.max(0,v-1);return{header:b,rows:N,totalRows:S,columnCount:F,truncated:N.length<S}},hu=r=>{const e=Re.c(29),{path:t,content:a,sizeBytes:v}=r,{t:f}=at();let w;e[0]!==a||e[1]!==t?(w=mu(a,fu(t)),e[0]=a,e[1]=t,e[2]=w):w=e[2];const d=w;let x;e[3]!==f||e[4]!==d.columnCount||e[5]!==d.totalRows?(x=d.totalRows===1?f("filesView.artifact.table.rowsSingle",{rows:d.totalRows,columns:d.columnCount}):f("filesView.artifact.table.rowsPlural",{rows:d.totalRows,columns:d.columnCount}),e[3]=f,e[4]=d.columnCount,e[5]=d.totalRows,e[6]=x):x=e[6];const p=x;let m;e[7]!==d.columnCount?(m=Array.from({length:d.columnCount},pu),e[7]=d.columnCount,e[8]=m):m=e[8];const b=m;let N;e[9]!==f||e[10]!==d.rows||e[11]!==d.totalRows||e[12]!==d.truncated?(N=d.truncated?f("filesView.artifact.table.truncated",{shown:d.rows.length,total:d.totalRows}):"",e[9]=f,e[10]=d.rows,e[11]=d.totalRows,e[12]=d.truncated,e[13]=N):N=e[13];let F;e[14]!==v?(F=Vs(v),e[14]=v,e[15]=F):F=e[15];let S;e[16]!==p||e[17]!==N||e[18]!==F?(S=n.jsx(Ts,{items:[p,N,F]}),e[16]=p,e[17]=N,e[18]=F,e[19]=S):S=e[19];let C;e[20]!==b||e[21]!==f||e[22]!==d.columnCount||e[23]!==d.header||e[24]!==d.rows?(C=d.columnCount===0?n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:f("filesView.artifact.table.empty")}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("table",{className:"min-w-full border-separate border-spacing-0 font-mono typography-meta",children:[n.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--surface-subtle)]",children:n.jsx("tr",{children:b.map(o=>n.jsx("th",{scope:"col",className:"whitespace-nowrap border-b border-r border-border/40 px-2 py-1 text-left font-medium text-foreground last:border-r-0",children:d.header[o]??""},o))})}),n.jsx("tbody",{children:d.rows.map((o,E)=>n.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:b.map(k=>n.jsx("td",{className:"max-w-[32rem] truncate border-b border-r border-border/30 px-2 py-1 align-top text-foreground last:border-r-0",title:o[k]??"",children:o[k]??""},k))},E))})]})}),e[20]=b,e[21]=f,e[22]=d.columnCount,e[23]=d.header,e[24]=d.rows,e[25]=C):C=e[25];let g;return e[26]!==S||e[27]!==C?(g=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[S,C]}),e[26]=S,e[27]=C,e[28]=g):g=e[28],g};function pu(r,e){return e}const mr="data-oc-local-asset",gu=25*1024*1024,fa=r=>{const e=r.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},xu=r=>r.split(/[?#]/,1)[0]??"",vu=r=>r.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),wu=(r,e)=>{const t=Ma(e.replace(/^#/,"")).toLowerCase();if(!t)return!1;for(const a of Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")))if(a.id===t||vu(a.textContent??"")===t)return a.scrollIntoView({block:"start"}),!0;return!1},Ma=r=>{try{return decodeURIComponent(r)}catch{return r}},ma=({container:r,filePath:e,workspaceRoot:t,onOpenFile:a,enabled:v})=>{const f=i.useRef(a);f.current=a,i.useEffect(()=>{if(!v||!r||!e)return;const w=e.slice(0,e.lastIndexOf("/")+1)||"/",d=g=>jo(w,Ma(xu(g))),x=g=>({path:g,allowOutsideWorkspace:t&&No(g,t)?void 0:"true",directory:t||void 0});let p=!1;const m=it(),b=new Map,N=g=>{const o=b.get(g);if(o)return o;const E=(async()=>{const k=await pr("/api/fs/raw",{query:x(g),signal:AbortSignal.timeout(3e4)});if(!k.ok)throw new Error(`Image read failed (${k.status})`);const M=await k.blob();if(M.size>gu)throw new Error("Image too large for preview");if(p||it()!==m)throw new Error("Preview closed");return URL.createObjectURL(M)})();return b.set(g,E),E.catch(()=>b.delete(g)),E},F=()=>{for(const g of Array.from(r.querySelectorAll("img[src]"))){const o=g.getAttribute("src")??"";if(!fa(o))continue;const E=d(o);g.setAttribute(mr,E),N(E).then(k=>{p||g.getAttribute(mr)!==E||g.getAttribute("src")!==k&&(g.src=k)}).catch(()=>{p||g.removeAttribute(mr)})}},S=g=>{if(g.defaultPrevented||g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey)return;const o=g.target;if(!(o instanceof Element))return;const E=o.closest("a[href]");if(!(E instanceof HTMLAnchorElement)||!r.contains(E))return;const k=E.getAttribute("href")??"";if(k.startsWith("#")){g.preventDefault(),g.stopPropagation(),wu(r,k);return}fa(k)&&(g.preventDefault(),g.stopPropagation(),f.current(d(k)))};F();const C=new MutationObserver(F);return C.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src"]}),r.addEventListener("click",S,!0),()=>{p=!0,C.disconnect(),r.removeEventListener("click",S,!0);for(const g of b.values())g.then(o=>URL.revokeObjectURL(o)).catch(()=>{})}},[r,v,e,t])},bu=_o(()=>io(()=>import("./percentages-BXMCSKIN-ChsKj3Ud.js").then(r=>r.E),__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])).then(r=>({default:r.ExcalidrawEditor}))),yu=r=>{const e=Z(r);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const t=e.lastIndexOf("/");if(t<0)return e;if(t===0)return"/";const a=e.slice(0,t);return/^[A-Za-z]:$/.test(a)?`${a}/`:a},ju=r=>{const e=Re.c(8),{label:t,iconDataUrl:a}=r,[v,f]=i.useState(!1);let w;e[0]!==t?(w=t.trim().slice(0,1).toUpperCase()||"?",e[0]=t,e[1]=w):w=e[1];const d=w;if(a&&!v){let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>f(!0),e[2]=m):m=e[2];let b;return e[3]!==a?(b=n.jsx("img",{src:a,alt:"",className:"size-4 rounded-sm",onError:m}),e[3]=a,e[4]=b):b=e[4],b}let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=U("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=x):x=e[5];let p;return e[6]!==d?(p=n.jsx("span",{className:x,children:d}),e[6]=d,e[7]=p):p=e[7],p},Nu=r=>r.slice().sort((e,t)=>e.type!==t.type?e.type==="directory"?-1:1:e.name.localeCompare(t.name)),Z=r=>{if(!r)return"";const e=r.replace(/\\/g,"/"),t=e.startsWith("//");let a=e.replace(/\/+/g,"/");t&&!a.startsWith("//")&&(a=`/${a}`);const v=a==="/",f=/^[A-Za-z]:\/$/.test(a);return!v&&!f&&(a=a.replace(/\/+$/,"")),a},Su=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),cs=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,ks=(r,e)=>{const t=Z(e),a=Z(r);if(!t||!a)return!1;const v=cs(t),f=cs(a);return f===v||f.startsWith(`${v}/`)},ha=(r,e)=>{const t=Z(e),a=Z(r);if(!ks(a,t))return[];const f=a.slice(t.length).replace(/^\//,"").split("/"),w=[];let d=t;for(let x=0;x<f.length-1;x++)d=d?`${d}/${f[x]}`:f[x],w.push(d);return w},jn=(r,e)=>{if(!e)return"";const t=Z(e);if(!r||!ks(t,r))return t;const a=t.slice(r.length);return a.startsWith("/")?a.slice(1):a},Cu=new Set(["node_modules"]),Fu=r=>{const e=Re.c(3),{status:t}=r;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=a):a=e[0];const v=a[t];let f;return e[1]!==v?(f=n.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:v}}),e[1]=v,e[2]=f):f=e[2],f},pa=r=>{const e=Re.c(11),{name:t}=r,a=i.useRef(null),v=i.useRef(null),[f,w]=i.useState(!1);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const N=a.current,F=v.current;if(!N||!F)return;const S=()=>{w(F.scrollWidth>N.clientWidth+1)};S();const C=new ResizeObserver(S);return C.observe(N),C.observe(F),()=>{C.disconnect()}},e[0]=d):d=e[0];let x;e[1]!==t?(x=[t],e[1]=t,e[2]=x):x=e[2],i.useLayoutEffect(d,x);let p;e[3]!==t?(p=n.jsx("span",{ref:v,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),e[3]=t,e[4]=p):p=e[4];let m;e[5]!==t||e[6]!==f?(m=f?n.jsxs("span",{className:"open-file-name-marquee-track",children:[n.jsx("span",{className:"open-file-name-marquee-item",children:t}),n.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):n.jsx("span",{className:"block min-w-0 truncate",children:t}),e[5]=t,e[6]=f,e[7]=m):m=e[7];let b;return e[8]!==p||e[9]!==m?(b=n.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[p,m]}),e[8]=p,e[9]=m,e[10]=b):b=e[10],b},Ru=r=>Cu.has(r),ku=r=>{const e=Z(r);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Eu=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("is a directory")||t.includes("eisdir")},ga=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("file not found")||t.includes("enoent")||t.includes("no such file")||t.includes("does not exist")},Tu=2e5,Da=(r,e)=>n.jsx(Rs,{filePath:r,extension:e}),hr=r=>{if(!r)return!1;const e=r.toLowerCase();if(e.endsWith(".excalidraw.md"))return!1;const t=e.split(".").pop();return t==="md"||t==="markdown"},xa=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},bn=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Vu=r=>{const e=Re.c(78),{node:t,root:a,isExpanded:v,isActive:f,isMobile:w,isBrowserClient:d,alwaysShowActions:x,status:p,badge:m,permissions:b,downloadFile:N,contextMenuPath:F,setContextMenuPath:S,rightClickMenuPath:C,setRightClickMenuPath:g,onSelect:o,onToggle:E,onRevealPath:k,onOpenDialog:M,canUpload:D,onPickFiles:L}=r,{t:R}=at(),P=t.type==="directory",{canRename:z,canCreateFile:$,canCreateFolder:K,canDelete:Q,canReveal:ne}=b,te=!P&&!!N,X=ne&&!d,J=P&&D,Y=z||$||K||J||Q||te||X;let G;e[0]!==Y||e[1]!==t.path||e[2]!==g?(G=je=>{Y&&(je?.preventDefault(),g(t.path))},e[0]=Y,e[1]=t.path,e[2]=g,e[3]=G):G=e[3];const ee=G;let $e;e[4]!==P||e[5]!==t||e[6]!==o||e[7]!==E?($e=()=>{P?E(t.path):o(t)},e[4]=P,e[5]=t,e[6]=o,e[7]=E,e[8]=$e):$e=e[8];const re=$e;let Me;e[9]!==t.path||e[10]!==S||e[11]!==g?(Me=je=>{je.stopPropagation(),g(null),S(t.path)},e[9]=t.path,e[10]=S,e[11]=g,e[12]=Me):Me=e[12];const De=Me;let _e;e[13]!==$||e[14]!==K||e[15]!==Q||e[16]!==z||e[17]!==X||e[18]!==J||e[19]!==N||e[20]!==d||e[21]!==P||e[22]!==t||e[23]!==M||e[24]!==L||e[25]!==k||e[26]!==a||e[27]!==R?(_e=je=>{const{Item:He,Separator:Qe}=je;return n.jsxs(n.Fragment,{children:[z&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("rename",t)},children:[n.jsx(T,{name:"edit",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.rename")]}),n.jsxs(He,{onClick:le=>{le.stopPropagation(),Nn(t.path).then(et=>{if(et.ok){se.success(R("sidebarFilesTree.toast.pathCopied"));return}se.error(R("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(T,{name:"file-copy",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.copyPath")]}),n.jsxs(He,{onClick:le=>{le.stopPropagation();const et=jn(a,t.path)||t.path;Nn(et).then(Ps=>{if(Ps.ok){se.success(R("filesView.toast.relativePathCopied"));return}se.error(R("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(T,{name:"file-copy-2",className:"mr-2 size-4"})," ",R("filesView.tree.menu.copyRelativePath")]}),!P&&N&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),N(t.path).catch(et=>{console.error("Download failed:",et),se.error(R("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(T,{name:"download",className:"mr-2 size-4"})," ",R(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),X&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),k(t.path)},children:[n.jsx(T,{name:"folder-received",className:"mr-2 size-4"})," ",R(Ho())]}),P&&($||K||J)&&n.jsxs(n.Fragment,{children:[n.jsx(Qe,{}),$&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("createFile",t)},children:[n.jsx(T,{name:"file-add",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.newFile")]}),K&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("createFolder",t)},children:[n.jsx(T,{name:"folder-add",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.newFolder")]}),J&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),L(t.path)},children:[n.jsx(T,{name:"upload-2",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.uploadFiles")]})]}),Q&&n.jsxs(n.Fragment,{children:[n.jsx(Qe,{}),n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("delete",t)},className:"text-destructive focus:text-destructive",children:[n.jsx(T,{name:"delete-bin",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.delete")]})]})]})},e[13]=$,e[14]=K,e[15]=Q,e[16]=z,e[17]=X,e[18]=J,e[19]=N,e[20]=d,e[21]=P,e[22]=t,e[23]=M,e[24]=L,e[25]=k,e[26]=a,e[27]=R,e[28]=_e):_e=e[28];const _=_e,ie=C===t.path;let xe;e[29]!==t.path||e[30]!==g?(xe=je=>g(je?t.path:null),e[29]=t.path,e[30]=g,e[31]=xe):xe=e[31];const H=w?void 0:ee;let ce;e[32]!==H?(ce=n.jsx("div",{className:"group relative flex items-center",onContextMenu:H}),e[32]=H,e[33]=ce):ce=e[33];const fe=w?void 0:ee,be=f?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ue;e[34]!==be?(ue=U("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",be),e[34]=be,e[35]=ue):ue=e[35];let ze;e[36]!==P||e[37]!==v||e[38]!==t.extension||e[39]!==t.path?(ze=P?v?n.jsx(T,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):n.jsx(T,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Da(t.path,t.extension),e[36]=P,e[37]=v,e[38]=t.extension,e[39]=t.path,e[40]=ze):ze=e[40];let ae;e[41]!==t.name||e[42]!==t.path?(ae=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),e[41]=t.name,e[42]=t.path,e[43]=ae):ae=e[43];let We;e[44]!==P||e[45]!==p?(We=!P&&p&&n.jsx(Fu,{status:p}),e[44]=P,e[45]=p,e[46]=We):We=e[46];let ve;e[47]!==m||e[48]!==P?(ve=P&&m&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[m.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",m.modified]}),m.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",m.added]})]}),e[47]=m,e[48]=P,e[49]=ve):ve=e[49];let ye;e[50]!==re||e[51]!==ue||e[52]!==ze||e[53]!==ae||e[54]!==We||e[55]!==ve||e[56]!==fe?(ye=n.jsxs("button",{type:"button",onClick:re,onContextMenu:fe,className:ue,children:[ze,ae,We,ve]}),e[50]=re,e[51]=ue,e[52]=ze,e[53]=ae,e[54]=We,e[55]=ve,e[56]=fe,e[57]=ye):ye=e[57];let ke;e[58]!==x||e[59]!==F||e[60]!==De||e[61]!==Y||e[62]!==w||e[63]!==t.path||e[64]!==_||e[65]!==S?(ke=Y&&n.jsx("div",{className:U("absolute right-1 top-1/2 -translate-y-1/2",x?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:n.jsxs(gr,{open:F===t.path,onOpenChange:je=>S(je?t.path:null),children:[n.jsx(xr,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:De,children:n.jsx(T,{name:"more-2-fill",className:"size-4"})})}),n.jsx(vr,{align:"end",side:"bottom",onCloseAutoFocus:()=>S(null),children:_({Item:yn,Separator:Ko})})]})}),e[58]=x,e[59]=F,e[60]=De,e[61]=Y,e[62]=w,e[63]=t.path,e[64]=_,e[65]=S,e[66]=ke):ke=e[66];let Ue;e[67]!==ye||e[68]!==ke||e[69]!==ce?(Ue=n.jsxs(Qo,{render:ce,children:[ye,ke]}),e[67]=ye,e[68]=ke,e[69]=ce,e[70]=Ue):Ue=e[70];let Ke;e[71]!==_?(Ke=n.jsx(Jo,{className:"min-w-[180px]",children:_({Item:Zo,Separator:Yo})}),e[71]=_,e[72]=Ke):Ke=e[72];let Rt;return e[73]!==Ue||e[74]!==Ke||e[75]!==ie||e[76]!==xe?(Rt=n.jsxs(ec,{open:ie,onOpenChange:xe,children:[Ue,Ke]}),e[73]=Ue,e[74]=Ke,e[75]=ie,e[76]=xe,e[77]=Rt):Rt=e[77],Rt},Pu=r=>{const e=Re.c(83),{activeDialog:t,dialogData:a,dialogInputValue:v,onDialogInputChange:f,isDialogSubmitting:w,onDialogSubmit:d,onClose:x,inputRef:p}=r,{t:m}=at(),b=!!t;let N;e[0]!==x?(N=ee=>!ee&&x(),e[0]=x,e[1]=N):N=e[1];let F;e[2]!==t||e[3]!==m?(F=t==="createFile"&&m("filesView.dialog.createFile.title"),e[2]=t,e[3]=m,e[4]=F):F=e[4];let S;e[5]!==t||e[6]!==m?(S=t==="createFolder"&&m("filesView.dialog.createFolder.title"),e[5]=t,e[6]=m,e[7]=S):S=e[7];let C;e[8]!==t||e[9]!==m?(C=t==="rename"&&m("filesView.dialog.rename.title"),e[8]=t,e[9]=m,e[10]=C):C=e[10];let g;e[11]!==t||e[12]!==m?(g=t==="delete"&&m("filesView.dialog.delete.title"),e[11]=t,e[12]=m,e[13]=g):g=e[13];let o;e[14]!==F||e[15]!==S||e[16]!==C||e[17]!==g?(o=n.jsxs(Sa,{children:[F,S,C,g]}),e[14]=F,e[15]=S,e[16]=C,e[17]=g,e[18]=o):o=e[18];let E;e[19]!==t||e[20]!==a?.path||e[21]!==m?(E=t==="createFile"&&m("filesView.dialog.createFile.description",{path:a?.path??m("filesView.dialog.rootFallback")}),e[19]=t,e[20]=a?.path,e[21]=m,e[22]=E):E=e[22];let k;e[23]!==t||e[24]!==a?.path||e[25]!==m?(k=t==="createFolder"&&m("filesView.dialog.createFolder.description",{path:a?.path??m("filesView.dialog.rootFallback")}),e[23]=t,e[24]=a?.path,e[25]=m,e[26]=k):k=e[26];let M;e[27]!==t||e[28]!==a?.name||e[29]!==m?(M=t==="rename"&&m("filesView.dialog.rename.description",{name:a?.name??""}),e[27]=t,e[28]=a?.name,e[29]=m,e[30]=M):M=e[30];let D;e[31]!==t||e[32]!==a?.name||e[33]!==m?(D=t==="delete"&&m("filesView.dialog.delete.description",{name:a?.name??""}),e[31]=t,e[32]=a?.name,e[33]=m,e[34]=D):D=e[34];let L;e[35]!==M||e[36]!==D||e[37]!==E||e[38]!==k?(L=n.jsxs(Ca,{children:[E,k,M,D]}),e[35]=M,e[36]=D,e[37]=E,e[38]=k,e[39]=L):L=e[39];let R;e[40]!==L||e[41]!==o?(R=n.jsxs(Na,{children:[o,L]}),e[40]=L,e[41]=o,e[42]=R):R=e[42];let P;e[43]!==t||e[44]!==v||e[45]!==p||e[46]!==f||e[47]!==d||e[48]!==m?(P=t!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Es,{value:v,onChange:ee=>f(ee.target.value),placeholder:m(t==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:ee=>{ee.key==="Enter"&&d()},ref:p})}),e[43]=t,e[44]=v,e[45]=p,e[46]=f,e[47]=d,e[48]=m,e[49]=P):P=e[49];let z;e[50]!==m?(z=m("filesView.dialog.cancel"),e[50]=m,e[51]=z):z=e[51];let $;e[52]!==w||e[53]!==x||e[54]!==z?($=n.jsx(I,{variant:"outline",onClick:x,disabled:w,children:z}),e[52]=w,e[53]=x,e[54]=z,e[55]=$):$=e[55];const K=t==="delete"?"destructive":"default";let Q;e[56]!==d?(Q=()=>{d()},e[56]=d,e[57]=Q):Q=e[57];let ne;e[58]!==t||e[59]!==v||e[60]!==w?(ne=w||t!=="delete"&&!v.trim(),e[58]=t,e[59]=v,e[60]=w,e[61]=ne):ne=e[61];let te;e[62]!==t||e[63]!==w||e[64]!==m?(te=w?n.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):m(t==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=t,e[63]=w,e[64]=m,e[65]=te):te=e[65];let X;e[66]!==K||e[67]!==Q||e[68]!==ne||e[69]!==te?(X=n.jsx(I,{variant:K,onClick:Q,disabled:ne,children:te}),e[66]=K,e[67]=Q,e[68]=ne,e[69]=te,e[70]=X):X=e[70];let J;e[71]!==$||e[72]!==X?(J=n.jsxs(Fa,{children:[$,X]}),e[71]=$,e[72]=X,e[73]=J):J=e[73];let Y;e[74]!==p||e[75]!==R||e[76]!==P||e[77]!==J?(Y=n.jsxs(ja,{initialFocus:p,children:[R,P,J]}),e[74]=p,e[75]=R,e[76]=P,e[77]=J,e[78]=Y):Y=e[78];let G;return e[79]!==b||e[80]!==N||e[81]!==Y?(G=n.jsx(ya,{open:b,onOpenChange:N,children:Y}),e[79]=b,e[80]=N,e[81]=Y,e[82]=G):G=e[82],G},os=new Map,Mu=100,va=r=>{const e=Re.c(13);let t,a,v;e[0]!==r?({positionKey:a,onViewReady:t,...v}=r,e[0]=r,e[1]=t,e[2]=a,e[3]=v):(t=e[1],a=e[2],v=e[3]);const f=i.useRef(null);let w,d;e[4]!==a?(w=()=>()=>{const m=f.current;if(!m)return;const{anchor:b,head:N}=m.state.selection.main;if(os.delete(a),os.set(a,{scroll:m.scrollSnapshot(),anchor:b,head:N}),os.size>Mu){const F=os.keys().next().value;F!==void 0&&os.delete(F)}},d=[a],e[4]=a,e[5]=w,e[6]=d):(w=e[5],d=e[6]),i.useLayoutEffect(w,d);let x;e[7]!==t||e[8]!==a?(x=m=>{f.current=m;const b=os.get(a);b&&m.dispatch({selection:{anchor:Math.min(b.anchor,m.state.doc.length),head:Math.min(b.head,m.state.doc.length)},effects:b.scroll}),t?.(m)},e[7]=t,e[8]=a,e[9]=x):x=e[9];let p;return e[10]!==v||e[11]!==x?(p=n.jsx(sc,{...v,onViewReady:x}),e[10]=v,e[11]=x,e[12]=p):p=e[12],p},wa=(r,e,t)=>{const a=Re.c(8),[v,f]=i.useState(""),[w,d]=i.useState(0);let x,p;a[0]!==r||a[1]!==t||a[2]!==e?(x=()=>{if(!r){f("");return}let b=!1;f("");const N=ho(),F=po(N);go(N).then(C=>{b||!C||(f(r),e(null))}).catch(C=>{b||(e(C instanceof Error?C.message:t),f(r))});const S=xo(()=>{b||(f(r),d(zu),e(null))});return()=>{b=!0,F(),S()}},p=[r,e,t],a[0]=r,a[1]=t,a[2]=e,a[3]=x,a[4]=p):(x=a[3],p=a[4]),i.useEffect(x,p);let m;return a[5]!==w||a[6]!==v?(m={readyKey:v,nonce:w},a[5]=w,a[6]=v,a[7]=m):m=a[7],m},Du=({mode:r="full",visible:e=!0})=>{const{t}=at(),{files:a,runtime:v}=So(),{currentTheme:f,availableThemes:w,lightThemeId:d,darkThemeId:x}=Co(),{isMobile:p,isTablet:m,screenWidth:b}=Fo(),N=ao(v.platform),F=p||m,S=lo(),C=oo(),g=ba()??"",o=Z(g.trim()),E=p||r==="full",k=E&&e,M=Ro(s=>s.runtimeKey),D=JSON.stringify([M,o]),L=i.useRef(D);L.current=D;const R=JSON.stringify([M,o,S,C]),P=i.useRef(R);P.current=R;const z=r!=="editor-only",$=r==="editor-only"&&!p,K=co(s=>s.searchFiles),Q=ko(k?g:null),[ne,te]=i.useState(""),X=Eo(ne,200),J=i.useRef(null),[Y,G]=i.useState(!1),[ee,$e]=i.useState(!0),[re,Me]=i.useState(!1),De=i.useCallback(s=>{if(An.current){const l=ms.current?.getContent();l&&(ge(l.content),Tt(!1))}Me(s)},[]),[_e,_]=i.useState(!1),ie=i.useRef(0),xe=i.useCallback(s=>{ie.current=Math.max(0,ie.current+(s?1:-1))},[]),[H,ce]=i.useState("edit"),[fe,be]=i.useState("edit"),[ue,ze]=i.useState("tree"),[ae,We]=i.useState("edit"),[ve,ye]=i.useState("preview"),[ke,Ue]=i.useState("preview"),[Ke,Rt]=i.useState("preview"),[je,He]=i.useState("preview"),[Qe,le]=i.useState("table"),[et,Ps]=i.useState(null),[za,Aa]=i.useState(0),[La,Cn]=i.useState(0),Ms=i.useRef({}),Fn=i.useRef({}),Rn=i.useRef({}),br=i.useRef({}),yr=i.useRef({}),jr=i.useRef({}),kn=i.useRef({}),Ds=i.useRef({}),zs=i.useMemo(()=>w.find(s=>s.metadata.id===d)??Zi(!1),[w,d]),As=i.useMemo(()=>w.find(s=>s.metadata.id===x)??Zi(!0),[w,x]);i.useEffect(()=>{ia(zs),ia(As)},[zs,As]);const Ls=i.useMemo(()=>[],[]),Ne=Ze(s=>o?s.byRoot[o]?.openPaths??Ls:Ls),kt=Ze(s=>o?s.byRoot[o]?.selectedPath??null:null),lt=Ze(s=>o?s.byRoot[o]?.expandedPaths??Ls:Ls),Ia=i.useMemo(()=>new Set(lt),[lt]),Wt=Ze(s=>s.removeOpenPath),gt=Ze(s=>s.removeOpenPathsByPrefix),Nr=Ze(s=>s.removeExpandedPathsByPrefix),Se=Ze(s=>s.setSelectedPath),Sr=Ze(s=>s.toggleExpandedPath),Is=Ze(s=>s.expandPaths),Ut=i.useCallback(s=>{const l=Z(s),c=l.split("/"),h=c[c.length-1]||l,y=h.includes(".")?h.split(".").pop()?.toLowerCase():void 0;return{name:h,path:l,type:"file",extension:y}},[]),Kt=i.useMemo(()=>Ne.map(Ut),[Ne,Ut]),En=i.useMemo(()=>{if(kt){const s=cs(kt);if(Ne.some(l=>cs(l)===s))return kt}return Ne[0]??null},[Ne,kt]),u=i.useMemo(()=>En?Ut(En):null,[En,Ut]),Ee=u?.path??"",Tn=i.useRef(Ee);Tn.current=Ee,i.useEffect(()=>{if(!o||!kt)return;const s=cs(kt);Ne.some(c=>cs(c)===s)||Se(o,Ne[0]??null)},[Ne,o,kt,Se]);const Vn=!!(o&&Ee&&!ks(Ee,o)),Pn=i.useMemo(()=>({allowOutsideWorkspace:Vn,directory:o||void 0}),[Vn,o]),xt=i.useCallback(s=>({allowOutsideWorkspace:!!(o&&!ks(s,o))}),[o]),Mn=i.useRef(null),[Cr,Oa]=i.useState({left:!1,right:!1}),Fr=i.useCallback(()=>{const s=Mn.current;s&&Oa({left:s.scrollLeft>2,right:s.scrollLeft+s.clientWidth<s.scrollWidth-2})},[]),Rr=i.useRef(Fr);Rr.current=Fr,i.useEffect(()=>{const s=Mn.current;if(!s)return;const l=()=>Rr.current();l(),s.addEventListener("scroll",l,{passive:!0});const c=new ResizeObserver(l);return c.observe(s),()=>{s.removeEventListener("scroll",l),c.disconnect()}},[Kt.length]);const[kr,Dn]=i.useState({}),[Os,us]=i.useState({}),qe=i.useRef(new Set),Te=i.useMemo(()=>new fc,[]);i.useEffect(()=>()=>Te.clear(),[Te]);const[Er,Bs]=i.useState([]),[Ba,$s]=i.useState(!1),[O,he]=i.useState(""),{isPlaying:_s,play:$a,stop:_a}=To(),[Ce,vt]=i.useState(!1),[tt,we]=i.useState(null),[Wa,Ge]=i.useState(""),[pe,de]=i.useState(null),wt=JSON.stringify([it(),o,pe]),[W,ge]=i.useState(""),[ds,zn]=i.useState(!1),[Tr,Ua]=i.useState(`
|
|
13
|
+
`&&(C+=1),p();continue}f+=g}(f.length>0||w.length>0||d)&&p();const b=a[0]??[],N=a.slice(1),F=a.reduce((C,g)=>Math.max(C,g.length),0),S=Math.max(0,v-1);return{header:b,rows:N,totalRows:S,columnCount:F,truncated:N.length<S}},hu=r=>{const e=Re.c(29),{path:t,content:a,sizeBytes:v}=r,{t:f}=at();let w;e[0]!==a||e[1]!==t?(w=mu(a,fu(t)),e[0]=a,e[1]=t,e[2]=w):w=e[2];const d=w;let x;e[3]!==f||e[4]!==d.columnCount||e[5]!==d.totalRows?(x=d.totalRows===1?f("filesView.artifact.table.rowsSingle",{rows:d.totalRows,columns:d.columnCount}):f("filesView.artifact.table.rowsPlural",{rows:d.totalRows,columns:d.columnCount}),e[3]=f,e[4]=d.columnCount,e[5]=d.totalRows,e[6]=x):x=e[6];const p=x;let m;e[7]!==d.columnCount?(m=Array.from({length:d.columnCount},pu),e[7]=d.columnCount,e[8]=m):m=e[8];const b=m;let N;e[9]!==f||e[10]!==d.rows||e[11]!==d.totalRows||e[12]!==d.truncated?(N=d.truncated?f("filesView.artifact.table.truncated",{shown:d.rows.length,total:d.totalRows}):"",e[9]=f,e[10]=d.rows,e[11]=d.totalRows,e[12]=d.truncated,e[13]=N):N=e[13];let F;e[14]!==v?(F=Vs(v),e[14]=v,e[15]=F):F=e[15];let S;e[16]!==p||e[17]!==N||e[18]!==F?(S=n.jsx(Ts,{items:[p,N,F]}),e[16]=p,e[17]=N,e[18]=F,e[19]=S):S=e[19];let C;e[20]!==b||e[21]!==f||e[22]!==d.columnCount||e[23]!==d.header||e[24]!==d.rows?(C=d.columnCount===0?n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:f("filesView.artifact.table.empty")}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("table",{className:"min-w-full border-separate border-spacing-0 font-mono typography-meta",children:[n.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--surface-subtle)]",children:n.jsx("tr",{children:b.map(o=>n.jsx("th",{scope:"col",className:"whitespace-nowrap border-b border-r border-border/40 px-2 py-1 text-left font-medium text-foreground last:border-r-0",children:d.header[o]??""},o))})}),n.jsx("tbody",{children:d.rows.map((o,E)=>n.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:b.map(k=>n.jsx("td",{className:"max-w-[32rem] truncate border-b border-r border-border/30 px-2 py-1 align-top text-foreground last:border-r-0",title:o[k]??"",children:o[k]??""},k))},E))})]})}),e[20]=b,e[21]=f,e[22]=d.columnCount,e[23]=d.header,e[24]=d.rows,e[25]=C):C=e[25];let g;return e[26]!==S||e[27]!==C?(g=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[S,C]}),e[26]=S,e[27]=C,e[28]=g):g=e[28],g};function pu(r,e){return e}const mr="data-oc-local-asset",gu=25*1024*1024,fa=r=>{const e=r.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},xu=r=>r.split(/[?#]/,1)[0]??"",vu=r=>r.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),wu=(r,e)=>{const t=Ma(e.replace(/^#/,"")).toLowerCase();if(!t)return!1;for(const a of Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")))if(a.id===t||vu(a.textContent??"")===t)return a.scrollIntoView({block:"start"}),!0;return!1},Ma=r=>{try{return decodeURIComponent(r)}catch{return r}},ma=({container:r,filePath:e,workspaceRoot:t,onOpenFile:a,enabled:v})=>{const f=i.useRef(a);f.current=a,i.useEffect(()=>{if(!v||!r||!e)return;const w=e.slice(0,e.lastIndexOf("/")+1)||"/",d=g=>jo(w,Ma(xu(g))),x=g=>({path:g,allowOutsideWorkspace:t&&No(g,t)?void 0:"true",directory:t||void 0});let p=!1;const m=it(),b=new Map,N=g=>{const o=b.get(g);if(o)return o;const E=(async()=>{const k=await pr("/api/fs/raw",{query:x(g),signal:AbortSignal.timeout(3e4)});if(!k.ok)throw new Error(`Image read failed (${k.status})`);const M=await k.blob();if(M.size>gu)throw new Error("Image too large for preview");if(p||it()!==m)throw new Error("Preview closed");return URL.createObjectURL(M)})();return b.set(g,E),E.catch(()=>b.delete(g)),E},F=()=>{for(const g of Array.from(r.querySelectorAll("img[src]"))){const o=g.getAttribute("src")??"";if(!fa(o))continue;const E=d(o);g.setAttribute(mr,E),N(E).then(k=>{p||g.getAttribute(mr)!==E||g.getAttribute("src")!==k&&(g.src=k)}).catch(()=>{p||g.removeAttribute(mr)})}},S=g=>{if(g.defaultPrevented||g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey)return;const o=g.target;if(!(o instanceof Element))return;const E=o.closest("a[href]");if(!(E instanceof HTMLAnchorElement)||!r.contains(E))return;const k=E.getAttribute("href")??"";if(k.startsWith("#")){g.preventDefault(),g.stopPropagation(),wu(r,k);return}fa(k)&&(g.preventDefault(),g.stopPropagation(),f.current(d(k)))};F();const C=new MutationObserver(F);return C.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src"]}),r.addEventListener("click",S,!0),()=>{p=!0,C.disconnect(),r.removeEventListener("click",S,!0);for(const g of b.values())g.then(o=>URL.revokeObjectURL(o)).catch(()=>{})}},[r,v,e,t])},bu=_o(()=>io(()=>import("./percentages-BXMCSKIN-nJkK2U43.js").then(r=>r.E),__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])).then(r=>({default:r.ExcalidrawEditor}))),yu=r=>{const e=Z(r);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const t=e.lastIndexOf("/");if(t<0)return e;if(t===0)return"/";const a=e.slice(0,t);return/^[A-Za-z]:$/.test(a)?`${a}/`:a},ju=r=>{const e=Re.c(8),{label:t,iconDataUrl:a}=r,[v,f]=i.useState(!1);let w;e[0]!==t?(w=t.trim().slice(0,1).toUpperCase()||"?",e[0]=t,e[1]=w):w=e[1];const d=w;if(a&&!v){let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>f(!0),e[2]=m):m=e[2];let b;return e[3]!==a?(b=n.jsx("img",{src:a,alt:"",className:"size-4 rounded-sm",onError:m}),e[3]=a,e[4]=b):b=e[4],b}let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=U("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=x):x=e[5];let p;return e[6]!==d?(p=n.jsx("span",{className:x,children:d}),e[6]=d,e[7]=p):p=e[7],p},Nu=r=>r.slice().sort((e,t)=>e.type!==t.type?e.type==="directory"?-1:1:e.name.localeCompare(t.name)),Z=r=>{if(!r)return"";const e=r.replace(/\\/g,"/"),t=e.startsWith("//");let a=e.replace(/\/+/g,"/");t&&!a.startsWith("//")&&(a=`/${a}`);const v=a==="/",f=/^[A-Za-z]:\/$/.test(a);return!v&&!f&&(a=a.replace(/\/+$/,"")),a},Su=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),cs=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,ks=(r,e)=>{const t=Z(e),a=Z(r);if(!t||!a)return!1;const v=cs(t),f=cs(a);return f===v||f.startsWith(`${v}/`)},ha=(r,e)=>{const t=Z(e),a=Z(r);if(!ks(a,t))return[];const f=a.slice(t.length).replace(/^\//,"").split("/"),w=[];let d=t;for(let x=0;x<f.length-1;x++)d=d?`${d}/${f[x]}`:f[x],w.push(d);return w},jn=(r,e)=>{if(!e)return"";const t=Z(e);if(!r||!ks(t,r))return t;const a=t.slice(r.length);return a.startsWith("/")?a.slice(1):a},Cu=new Set(["node_modules"]),Fu=r=>{const e=Re.c(3),{status:t}=r;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=a):a=e[0];const v=a[t];let f;return e[1]!==v?(f=n.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:v}}),e[1]=v,e[2]=f):f=e[2],f},pa=r=>{const e=Re.c(11),{name:t}=r,a=i.useRef(null),v=i.useRef(null),[f,w]=i.useState(!1);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const N=a.current,F=v.current;if(!N||!F)return;const S=()=>{w(F.scrollWidth>N.clientWidth+1)};S();const C=new ResizeObserver(S);return C.observe(N),C.observe(F),()=>{C.disconnect()}},e[0]=d):d=e[0];let x;e[1]!==t?(x=[t],e[1]=t,e[2]=x):x=e[2],i.useLayoutEffect(d,x);let p;e[3]!==t?(p=n.jsx("span",{ref:v,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),e[3]=t,e[4]=p):p=e[4];let m;e[5]!==t||e[6]!==f?(m=f?n.jsxs("span",{className:"open-file-name-marquee-track",children:[n.jsx("span",{className:"open-file-name-marquee-item",children:t}),n.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):n.jsx("span",{className:"block min-w-0 truncate",children:t}),e[5]=t,e[6]=f,e[7]=m):m=e[7];let b;return e[8]!==p||e[9]!==m?(b=n.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[p,m]}),e[8]=p,e[9]=m,e[10]=b):b=e[10],b},Ru=r=>Cu.has(r),ku=r=>{const e=Z(r);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Eu=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("is a directory")||t.includes("eisdir")},ga=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("file not found")||t.includes("enoent")||t.includes("no such file")||t.includes("does not exist")},Tu=2e5,Da=(r,e)=>n.jsx(Rs,{filePath:r,extension:e}),hr=r=>{if(!r)return!1;const e=r.toLowerCase();if(e.endsWith(".excalidraw.md"))return!1;const t=e.split(".").pop();return t==="md"||t==="markdown"},xa=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},bn=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Vu=r=>{const e=Re.c(78),{node:t,root:a,isExpanded:v,isActive:f,isMobile:w,isBrowserClient:d,alwaysShowActions:x,status:p,badge:m,permissions:b,downloadFile:N,contextMenuPath:F,setContextMenuPath:S,rightClickMenuPath:C,setRightClickMenuPath:g,onSelect:o,onToggle:E,onRevealPath:k,onOpenDialog:M,canUpload:D,onPickFiles:L}=r,{t:R}=at(),P=t.type==="directory",{canRename:z,canCreateFile:$,canCreateFolder:K,canDelete:Q,canReveal:ne}=b,te=!P&&!!N,X=ne&&!d,J=P&&D,Y=z||$||K||J||Q||te||X;let G;e[0]!==Y||e[1]!==t.path||e[2]!==g?(G=je=>{Y&&(je?.preventDefault(),g(t.path))},e[0]=Y,e[1]=t.path,e[2]=g,e[3]=G):G=e[3];const ee=G;let $e;e[4]!==P||e[5]!==t||e[6]!==o||e[7]!==E?($e=()=>{P?E(t.path):o(t)},e[4]=P,e[5]=t,e[6]=o,e[7]=E,e[8]=$e):$e=e[8];const re=$e;let Me;e[9]!==t.path||e[10]!==S||e[11]!==g?(Me=je=>{je.stopPropagation(),g(null),S(t.path)},e[9]=t.path,e[10]=S,e[11]=g,e[12]=Me):Me=e[12];const De=Me;let _e;e[13]!==$||e[14]!==K||e[15]!==Q||e[16]!==z||e[17]!==X||e[18]!==J||e[19]!==N||e[20]!==d||e[21]!==P||e[22]!==t||e[23]!==M||e[24]!==L||e[25]!==k||e[26]!==a||e[27]!==R?(_e=je=>{const{Item:He,Separator:Qe}=je;return n.jsxs(n.Fragment,{children:[z&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("rename",t)},children:[n.jsx(T,{name:"edit",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.rename")]}),n.jsxs(He,{onClick:le=>{le.stopPropagation(),Nn(t.path).then(et=>{if(et.ok){se.success(R("sidebarFilesTree.toast.pathCopied"));return}se.error(R("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(T,{name:"file-copy",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.copyPath")]}),n.jsxs(He,{onClick:le=>{le.stopPropagation();const et=jn(a,t.path)||t.path;Nn(et).then(Ps=>{if(Ps.ok){se.success(R("filesView.toast.relativePathCopied"));return}se.error(R("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(T,{name:"file-copy-2",className:"mr-2 size-4"})," ",R("filesView.tree.menu.copyRelativePath")]}),!P&&N&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),N(t.path).catch(et=>{console.error("Download failed:",et),se.error(R("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(T,{name:"download",className:"mr-2 size-4"})," ",R(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),X&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),k(t.path)},children:[n.jsx(T,{name:"folder-received",className:"mr-2 size-4"})," ",R(Ho())]}),P&&($||K||J)&&n.jsxs(n.Fragment,{children:[n.jsx(Qe,{}),$&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("createFile",t)},children:[n.jsx(T,{name:"file-add",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.newFile")]}),K&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("createFolder",t)},children:[n.jsx(T,{name:"folder-add",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.newFolder")]}),J&&n.jsxs(He,{onClick:le=>{le.stopPropagation(),L(t.path)},children:[n.jsx(T,{name:"upload-2",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.uploadFiles")]})]}),Q&&n.jsxs(n.Fragment,{children:[n.jsx(Qe,{}),n.jsxs(He,{onClick:le=>{le.stopPropagation(),M("delete",t)},className:"text-destructive focus:text-destructive",children:[n.jsx(T,{name:"delete-bin",className:"mr-2 size-4"})," ",R("sidebarFilesTree.menu.delete")]})]})]})},e[13]=$,e[14]=K,e[15]=Q,e[16]=z,e[17]=X,e[18]=J,e[19]=N,e[20]=d,e[21]=P,e[22]=t,e[23]=M,e[24]=L,e[25]=k,e[26]=a,e[27]=R,e[28]=_e):_e=e[28];const _=_e,ie=C===t.path;let xe;e[29]!==t.path||e[30]!==g?(xe=je=>g(je?t.path:null),e[29]=t.path,e[30]=g,e[31]=xe):xe=e[31];const H=w?void 0:ee;let ce;e[32]!==H?(ce=n.jsx("div",{className:"group relative flex items-center",onContextMenu:H}),e[32]=H,e[33]=ce):ce=e[33];const fe=w?void 0:ee,be=f?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ue;e[34]!==be?(ue=U("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",be),e[34]=be,e[35]=ue):ue=e[35];let ze;e[36]!==P||e[37]!==v||e[38]!==t.extension||e[39]!==t.path?(ze=P?v?n.jsx(T,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):n.jsx(T,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Da(t.path,t.extension),e[36]=P,e[37]=v,e[38]=t.extension,e[39]=t.path,e[40]=ze):ze=e[40];let ae;e[41]!==t.name||e[42]!==t.path?(ae=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),e[41]=t.name,e[42]=t.path,e[43]=ae):ae=e[43];let We;e[44]!==P||e[45]!==p?(We=!P&&p&&n.jsx(Fu,{status:p}),e[44]=P,e[45]=p,e[46]=We):We=e[46];let ve;e[47]!==m||e[48]!==P?(ve=P&&m&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[m.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",m.modified]}),m.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",m.added]})]}),e[47]=m,e[48]=P,e[49]=ve):ve=e[49];let ye;e[50]!==re||e[51]!==ue||e[52]!==ze||e[53]!==ae||e[54]!==We||e[55]!==ve||e[56]!==fe?(ye=n.jsxs("button",{type:"button",onClick:re,onContextMenu:fe,className:ue,children:[ze,ae,We,ve]}),e[50]=re,e[51]=ue,e[52]=ze,e[53]=ae,e[54]=We,e[55]=ve,e[56]=fe,e[57]=ye):ye=e[57];let ke;e[58]!==x||e[59]!==F||e[60]!==De||e[61]!==Y||e[62]!==w||e[63]!==t.path||e[64]!==_||e[65]!==S?(ke=Y&&n.jsx("div",{className:U("absolute right-1 top-1/2 -translate-y-1/2",x?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:n.jsxs(gr,{open:F===t.path,onOpenChange:je=>S(je?t.path:null),children:[n.jsx(xr,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:De,children:n.jsx(T,{name:"more-2-fill",className:"size-4"})})}),n.jsx(vr,{align:"end",side:"bottom",onCloseAutoFocus:()=>S(null),children:_({Item:yn,Separator:Ko})})]})}),e[58]=x,e[59]=F,e[60]=De,e[61]=Y,e[62]=w,e[63]=t.path,e[64]=_,e[65]=S,e[66]=ke):ke=e[66];let Ue;e[67]!==ye||e[68]!==ke||e[69]!==ce?(Ue=n.jsxs(Qo,{render:ce,children:[ye,ke]}),e[67]=ye,e[68]=ke,e[69]=ce,e[70]=Ue):Ue=e[70];let Ke;e[71]!==_?(Ke=n.jsx(Jo,{className:"min-w-[180px]",children:_({Item:Zo,Separator:Yo})}),e[71]=_,e[72]=Ke):Ke=e[72];let Rt;return e[73]!==Ue||e[74]!==Ke||e[75]!==ie||e[76]!==xe?(Rt=n.jsxs(ec,{open:ie,onOpenChange:xe,children:[Ue,Ke]}),e[73]=Ue,e[74]=Ke,e[75]=ie,e[76]=xe,e[77]=Rt):Rt=e[77],Rt},Pu=r=>{const e=Re.c(83),{activeDialog:t,dialogData:a,dialogInputValue:v,onDialogInputChange:f,isDialogSubmitting:w,onDialogSubmit:d,onClose:x,inputRef:p}=r,{t:m}=at(),b=!!t;let N;e[0]!==x?(N=ee=>!ee&&x(),e[0]=x,e[1]=N):N=e[1];let F;e[2]!==t||e[3]!==m?(F=t==="createFile"&&m("filesView.dialog.createFile.title"),e[2]=t,e[3]=m,e[4]=F):F=e[4];let S;e[5]!==t||e[6]!==m?(S=t==="createFolder"&&m("filesView.dialog.createFolder.title"),e[5]=t,e[6]=m,e[7]=S):S=e[7];let C;e[8]!==t||e[9]!==m?(C=t==="rename"&&m("filesView.dialog.rename.title"),e[8]=t,e[9]=m,e[10]=C):C=e[10];let g;e[11]!==t||e[12]!==m?(g=t==="delete"&&m("filesView.dialog.delete.title"),e[11]=t,e[12]=m,e[13]=g):g=e[13];let o;e[14]!==F||e[15]!==S||e[16]!==C||e[17]!==g?(o=n.jsxs(Sa,{children:[F,S,C,g]}),e[14]=F,e[15]=S,e[16]=C,e[17]=g,e[18]=o):o=e[18];let E;e[19]!==t||e[20]!==a?.path||e[21]!==m?(E=t==="createFile"&&m("filesView.dialog.createFile.description",{path:a?.path??m("filesView.dialog.rootFallback")}),e[19]=t,e[20]=a?.path,e[21]=m,e[22]=E):E=e[22];let k;e[23]!==t||e[24]!==a?.path||e[25]!==m?(k=t==="createFolder"&&m("filesView.dialog.createFolder.description",{path:a?.path??m("filesView.dialog.rootFallback")}),e[23]=t,e[24]=a?.path,e[25]=m,e[26]=k):k=e[26];let M;e[27]!==t||e[28]!==a?.name||e[29]!==m?(M=t==="rename"&&m("filesView.dialog.rename.description",{name:a?.name??""}),e[27]=t,e[28]=a?.name,e[29]=m,e[30]=M):M=e[30];let D;e[31]!==t||e[32]!==a?.name||e[33]!==m?(D=t==="delete"&&m("filesView.dialog.delete.description",{name:a?.name??""}),e[31]=t,e[32]=a?.name,e[33]=m,e[34]=D):D=e[34];let L;e[35]!==M||e[36]!==D||e[37]!==E||e[38]!==k?(L=n.jsxs(Ca,{children:[E,k,M,D]}),e[35]=M,e[36]=D,e[37]=E,e[38]=k,e[39]=L):L=e[39];let R;e[40]!==L||e[41]!==o?(R=n.jsxs(Na,{children:[o,L]}),e[40]=L,e[41]=o,e[42]=R):R=e[42];let P;e[43]!==t||e[44]!==v||e[45]!==p||e[46]!==f||e[47]!==d||e[48]!==m?(P=t!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Es,{value:v,onChange:ee=>f(ee.target.value),placeholder:m(t==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:ee=>{ee.key==="Enter"&&d()},ref:p})}),e[43]=t,e[44]=v,e[45]=p,e[46]=f,e[47]=d,e[48]=m,e[49]=P):P=e[49];let z;e[50]!==m?(z=m("filesView.dialog.cancel"),e[50]=m,e[51]=z):z=e[51];let $;e[52]!==w||e[53]!==x||e[54]!==z?($=n.jsx(I,{variant:"outline",onClick:x,disabled:w,children:z}),e[52]=w,e[53]=x,e[54]=z,e[55]=$):$=e[55];const K=t==="delete"?"destructive":"default";let Q;e[56]!==d?(Q=()=>{d()},e[56]=d,e[57]=Q):Q=e[57];let ne;e[58]!==t||e[59]!==v||e[60]!==w?(ne=w||t!=="delete"&&!v.trim(),e[58]=t,e[59]=v,e[60]=w,e[61]=ne):ne=e[61];let te;e[62]!==t||e[63]!==w||e[64]!==m?(te=w?n.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):m(t==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=t,e[63]=w,e[64]=m,e[65]=te):te=e[65];let X;e[66]!==K||e[67]!==Q||e[68]!==ne||e[69]!==te?(X=n.jsx(I,{variant:K,onClick:Q,disabled:ne,children:te}),e[66]=K,e[67]=Q,e[68]=ne,e[69]=te,e[70]=X):X=e[70];let J;e[71]!==$||e[72]!==X?(J=n.jsxs(Fa,{children:[$,X]}),e[71]=$,e[72]=X,e[73]=J):J=e[73];let Y;e[74]!==p||e[75]!==R||e[76]!==P||e[77]!==J?(Y=n.jsxs(ja,{initialFocus:p,children:[R,P,J]}),e[74]=p,e[75]=R,e[76]=P,e[77]=J,e[78]=Y):Y=e[78];let G;return e[79]!==b||e[80]!==N||e[81]!==Y?(G=n.jsx(ya,{open:b,onOpenChange:N,children:Y}),e[79]=b,e[80]=N,e[81]=Y,e[82]=G):G=e[82],G},os=new Map,Mu=100,va=r=>{const e=Re.c(13);let t,a,v;e[0]!==r?({positionKey:a,onViewReady:t,...v}=r,e[0]=r,e[1]=t,e[2]=a,e[3]=v):(t=e[1],a=e[2],v=e[3]);const f=i.useRef(null);let w,d;e[4]!==a?(w=()=>()=>{const m=f.current;if(!m)return;const{anchor:b,head:N}=m.state.selection.main;if(os.delete(a),os.set(a,{scroll:m.scrollSnapshot(),anchor:b,head:N}),os.size>Mu){const F=os.keys().next().value;F!==void 0&&os.delete(F)}},d=[a],e[4]=a,e[5]=w,e[6]=d):(w=e[5],d=e[6]),i.useLayoutEffect(w,d);let x;e[7]!==t||e[8]!==a?(x=m=>{f.current=m;const b=os.get(a);b&&m.dispatch({selection:{anchor:Math.min(b.anchor,m.state.doc.length),head:Math.min(b.head,m.state.doc.length)},effects:b.scroll}),t?.(m)},e[7]=t,e[8]=a,e[9]=x):x=e[9];let p;return e[10]!==v||e[11]!==x?(p=n.jsx(sc,{...v,onViewReady:x}),e[10]=v,e[11]=x,e[12]=p):p=e[12],p},wa=(r,e,t)=>{const a=Re.c(8),[v,f]=i.useState(""),[w,d]=i.useState(0);let x,p;a[0]!==r||a[1]!==t||a[2]!==e?(x=()=>{if(!r){f("");return}let b=!1;f("");const N=ho(),F=po(N);go(N).then(C=>{b||!C||(f(r),e(null))}).catch(C=>{b||(e(C instanceof Error?C.message:t),f(r))});const S=xo(()=>{b||(f(r),d(zu),e(null))});return()=>{b=!0,F(),S()}},p=[r,e,t],a[0]=r,a[1]=t,a[2]=e,a[3]=x,a[4]=p):(x=a[3],p=a[4]),i.useEffect(x,p);let m;return a[5]!==w||a[6]!==v?(m={readyKey:v,nonce:w},a[5]=w,a[6]=v,a[7]=m):m=a[7],m},Du=({mode:r="full",visible:e=!0})=>{const{t}=at(),{files:a,runtime:v}=So(),{currentTheme:f,availableThemes:w,lightThemeId:d,darkThemeId:x}=Co(),{isMobile:p,isTablet:m,screenWidth:b}=Fo(),N=ao(v.platform),F=p||m,S=lo(),C=oo(),g=ba()??"",o=Z(g.trim()),E=p||r==="full",k=E&&e,M=Ro(s=>s.runtimeKey),D=JSON.stringify([M,o]),L=i.useRef(D);L.current=D;const R=JSON.stringify([M,o,S,C]),P=i.useRef(R);P.current=R;const z=r!=="editor-only",$=r==="editor-only"&&!p,K=co(s=>s.searchFiles),Q=ko(k?g:null),[ne,te]=i.useState(""),X=Eo(ne,200),J=i.useRef(null),[Y,G]=i.useState(!1),[ee,$e]=i.useState(!0),[re,Me]=i.useState(!1),De=i.useCallback(s=>{if(An.current){const l=ms.current?.getContent();l&&(ge(l.content),Tt(!1))}Me(s)},[]),[_e,_]=i.useState(!1),ie=i.useRef(0),xe=i.useCallback(s=>{ie.current=Math.max(0,ie.current+(s?1:-1))},[]),[H,ce]=i.useState("edit"),[fe,be]=i.useState("edit"),[ue,ze]=i.useState("tree"),[ae,We]=i.useState("edit"),[ve,ye]=i.useState("preview"),[ke,Ue]=i.useState("preview"),[Ke,Rt]=i.useState("preview"),[je,He]=i.useState("preview"),[Qe,le]=i.useState("table"),[et,Ps]=i.useState(null),[za,Aa]=i.useState(0),[La,Cn]=i.useState(0),Ms=i.useRef({}),Fn=i.useRef({}),Rn=i.useRef({}),br=i.useRef({}),yr=i.useRef({}),jr=i.useRef({}),kn=i.useRef({}),Ds=i.useRef({}),zs=i.useMemo(()=>w.find(s=>s.metadata.id===d)??Zi(!1),[w,d]),As=i.useMemo(()=>w.find(s=>s.metadata.id===x)??Zi(!0),[w,x]);i.useEffect(()=>{ia(zs),ia(As)},[zs,As]);const Ls=i.useMemo(()=>[],[]),Ne=Ze(s=>o?s.byRoot[o]?.openPaths??Ls:Ls),kt=Ze(s=>o?s.byRoot[o]?.selectedPath??null:null),lt=Ze(s=>o?s.byRoot[o]?.expandedPaths??Ls:Ls),Ia=i.useMemo(()=>new Set(lt),[lt]),Wt=Ze(s=>s.removeOpenPath),gt=Ze(s=>s.removeOpenPathsByPrefix),Nr=Ze(s=>s.removeExpandedPathsByPrefix),Se=Ze(s=>s.setSelectedPath),Sr=Ze(s=>s.toggleExpandedPath),Is=Ze(s=>s.expandPaths),Ut=i.useCallback(s=>{const l=Z(s),c=l.split("/"),h=c[c.length-1]||l,y=h.includes(".")?h.split(".").pop()?.toLowerCase():void 0;return{name:h,path:l,type:"file",extension:y}},[]),Kt=i.useMemo(()=>Ne.map(Ut),[Ne,Ut]),En=i.useMemo(()=>{if(kt){const s=cs(kt);if(Ne.some(l=>cs(l)===s))return kt}return Ne[0]??null},[Ne,kt]),u=i.useMemo(()=>En?Ut(En):null,[En,Ut]),Ee=u?.path??"",Tn=i.useRef(Ee);Tn.current=Ee,i.useEffect(()=>{if(!o||!kt)return;const s=cs(kt);Ne.some(c=>cs(c)===s)||Se(o,Ne[0]??null)},[Ne,o,kt,Se]);const Vn=!!(o&&Ee&&!ks(Ee,o)),Pn=i.useMemo(()=>({allowOutsideWorkspace:Vn,directory:o||void 0}),[Vn,o]),xt=i.useCallback(s=>({allowOutsideWorkspace:!!(o&&!ks(s,o))}),[o]),Mn=i.useRef(null),[Cr,Oa]=i.useState({left:!1,right:!1}),Fr=i.useCallback(()=>{const s=Mn.current;s&&Oa({left:s.scrollLeft>2,right:s.scrollLeft+s.clientWidth<s.scrollWidth-2})},[]),Rr=i.useRef(Fr);Rr.current=Fr,i.useEffect(()=>{const s=Mn.current;if(!s)return;const l=()=>Rr.current();l(),s.addEventListener("scroll",l,{passive:!0});const c=new ResizeObserver(l);return c.observe(s),()=>{s.removeEventListener("scroll",l),c.disconnect()}},[Kt.length]);const[kr,Dn]=i.useState({}),[Os,us]=i.useState({}),qe=i.useRef(new Set),Te=i.useMemo(()=>new fc,[]);i.useEffect(()=>()=>Te.clear(),[Te]);const[Er,Bs]=i.useState([]),[Ba,$s]=i.useState(!1),[O,he]=i.useState(""),{isPlaying:_s,play:$a,stop:_a}=To(),[Ce,vt]=i.useState(!1),[tt,we]=i.useState(null),[Wa,Ge]=i.useState(""),[pe,de]=i.useState(null),wt=JSON.stringify([it(),o,pe]),[W,ge]=i.useState(""),[ds,zn]=i.useState(!1),[Tr,Ua]=i.useState(`
|
|
14
14
|
`),Ka=i.useRef(null),ot=i.useRef(null),Ae=i.useRef(null),bt=i.useRef(""),fs=i.useRef(""),dt=i.useRef(null),Et=i.useRef(null),Vr=i.useRef(null),ms=i.useRef(null),[Ws,Tt]=i.useState(!1),An=i.useRef(!1);An.current=Ws;const st=i.useRef(null),Ln=i.useRef(""),In=i.useRef(0),Ht=i.useRef(0),Vt=i.useRef(null),[hs,Ha]=i.useState(0),[qa,qt]=i.useState("idle"),[Ga,Us]=i.useState(!1),[Xa,Pr]=i.useState(!1),[Pt,Mr]=i.useState(!1),Fe=ht(s=>s.autoSaveEnabled),Ja=ht(s=>s.setAutoSaveEnabled),[On,ps]=i.useState(!1),Gt=i.useRef(null),gs=i.useRef(null),xs=i.useRef(!1),vs=i.useRef(null),ws=i.useRef(null),Xe=i.useRef(null),Ks=i.useRef(null),Dr=i.useRef(null),zr=i.useRef(0),[Ya,Bn]=i.useState(0),Xt=i.useRef(null),Mt=i.useRef({key:"",attempts:0});i.useEffect(()=>()=>{Xt.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Xt.current),Xt.current=null)},[]);const[Dt,$n]=i.useState(null),[zt,Za]=i.useState(null),[yt,Ar]=i.useState(""),[Qa,_n]=i.useState(!1),[el,tl]=i.useState(null),[sl,nl]=i.useState(null),[rl,Lr]=i.useState(!1),[il,Ir]=i.useState(!1),[al,Wn]=i.useState(!1),[Or,Hs]=i.useState(!1),[Br,$r]=i.useState(0),qs=i.useRef(null),Gs=i.useCallback(s=>{const l=s?.currentTarget??qs.current;if(!l)return;const c=document.activeElement;c&&c!==document.body&&c!==l&&(Vo(c)||l.contains(c))||l.focus({preventScroll:!0})},[]),Xs=i.useRef(null),_r=!!a.writeFile,Wr=!!a.createDirectory,Ur=!!a.rename,Kr=!!a.delete,Hr=!!a.revealPath,ll=vn(s=>s.availableApps),ol=vn(s=>s.isCacheStale),qr=vn(s=>s.initialize),cl=vn(s=>s.loadInstalledApps);i.useEffect(()=>{qr()},[qr]);const ul=i.useCallback(s=>{a.revealPath&&a.revealPath(s).catch(()=>{se.error(t("sidebarFilesTree.toast.revealFailed"))})},[a,t]),dl=i.useCallback(async s=>{if(!u?.path||await uo(u.path,s.id,s.appName)||await Xi(u.path,s.appName))return;const h=yu(u.path)||o;h&&await Xi(h,s.appName)||se.error(t("filesView.toast.openInAppFailed",{app:s.appName}))},[o,u?.path,t]),Un=i.useCallback((s,l)=>{$n(s),Za(l),Ar(s==="rename"&&l.name||""),_n(!1)},[]),[q,nt]=i.useState(null),Jt=i.useRef(!1),jt=i.useRef(null),[Gr,Yt]=i.useState(!1),ct=ht(s=>s.pendingFileNavigation),Js=ht(s=>s.setPendingFileNavigation),Kn=ht(s=>s.pendingFileFocusPath),Hn=ht(s=>s.setPendingFileFocusPath),Xr=ht(s=>s.fileEditorKeymap),bs=Qi(s=>s.settingsDefaultFileViewerPreview),fl=Qi(s=>s.showMessageTTSButtons);i.useEffect(()=>{const s=()=>{Jt.current=!1,jt.current=null,Yt(!1)};return document.addEventListener("mouseup",s),()=>document.removeEventListener("mouseup",s)},[]),i.useEffect(()=>()=>{vs.current!==null&&window.clearTimeout(vs.current),ws.current!==null&&window.clearTimeout(ws.current)},[]);const ml=i.useCallback((s,l)=>{const c=s.split(`
|
|
15
15
|
`),h=Math.max(1,l.start),y=Math.min(c.length,l.end);return h>y?"":c.slice(h-1,y).join(`
|
|
16
16
|
`)},[]),Jr=i.useRef(null),hl=xc({source:"file",fileLabel:u?.path??null,language:u?.path&&ar(u.path)||"text",getCodeForRange:s=>ml(O,vc(s)),toStoreRange:s=>({startLine:s.start,endLine:s.end}),fromDraftRange:s=>({start:s.startLine,end:s.endLine})}),{drafts:Yr,commentText:Ys,setCommentText:Zr,editingDraftId:Zs,setSelection:Qr,saveComment:ei,cancel:ys,reset:ti,startEdit:si,deleteDraft:ni}=hl;i.useEffect(()=>{nt(null),ti(),ge(""),zn(!1)},[u?.path,ti]),i.useEffect(()=>{Qr(q)},[q,Qr]),i.useEffect(()=>{if(!q&&!Zs)return;const s=c=>{const h=c.target;h.closest('[data-comment-input="true"]')||h.closest('[data-comment-card="true"]')||h.closest(".cm-gutterElement")||h.closest("[data-sonner-toast]")||h.closest("[data-sonner-toaster]")||Ys.trim()||(nt(null),ys())},l=setTimeout(()=>{document.addEventListener("click",s)},100);return()=>{clearTimeout(l),document.removeEventListener("click",s)}},[ys,Ys,Zs,q]),i.useEffect(()=>{if(!p||!q)return;const s=Xe.current;if(!s)return;const l=s.state.selection.main;l.empty||s.dispatch({selection:{anchor:l.head}});const c=document.getSelection();c&&!c.isCollapsed&&c.anchorNode&&s.contentDOM.contains(c.anchorNode)&&c.removeAllRanges()},[p,q]);const ri=i.useCallback((s,l)=>{const c=l??q??void 0;l&&nt(l),ei(s,c),nt(null)},[q,ei]),ii=i.useCallback((s,l)=>{const c=[];for(const h of l){if(!(h&&typeof h.name=="string"&&h.name.length>0)||!S&&h.name.startsWith(".")||!C&&Ru(h.name))continue;const y=h.name,j=Z(h.path||""),V=j?Su(j)?j:Z(`${s}/${j}`):Z(`${s}/${y}`),B=h.isDirectory?"directory":"file",me=B==="file"&&y.includes(".")?y.split(".").pop()?.toLowerCase():void 0;c.push({name:y,path:V,type:B,extension:me})}return Nu(c)},[C,S]),Ve=i.useCallback(async(s,l=!1)=>{if(!k)return;const c=Z(s.trim());if(!c||!l&&qe.current.has(c))return;const h=P.current,y=it();return Te.run(c,async j=>{const V=()=>j()&&P.current===h&&it()===y;try{const B=a.listDirectory?(await a.listDirectory(c)).entries:await fo.listLocalDirectory(c);if(!V())return;const me=ii(c,B);qe.current=new Set(qe.current),qe.current.add(c),us(A=>{if(!A[c])return A;const oe={...A};return delete oe[c],oe}),Dn(A=>A[c]&&mc(A[c],me)?A:{...A,[c]:me})}catch(B){if(!V())return;const me=B instanceof Error?B.message:String(B??"");if(me==="Directory not found"&&o&&c!==o){Nr(o,c),us(A=>{if(!A[c])return A;const oe={...A};return delete oe[c],oe});return}console.error("Failed to load files directory:",B),us(A=>({...A,[c]:me}))}},l)},[Te,a,ii,Nr,o,k]),Qs=i.useCallback(async()=>{o&&(qe.current=new Set,Te.clear(),us({}),Dn(s=>Object.keys(s).length===0?s:{}),await Ve(o))},[Te,Ve,o]),Le=i.useCallback(async s=>{if(!s){await Qs();return}const l=Z(s);qe.current=new Set(qe.current),qe.current.delete(l),await Ve(l,!0)},[Ve,Qs]),{canUpload:ai,uploadingDirectory:pl,pickFiles:li,uploadElements:gl}=qo({root:o,refreshDirectory:Le}),en=pl!==null,oi=i.useRef(""),ci=i.useRef("");i.useEffect(()=>{if(!o)return;const s=R,l=oi.current!==D,c=ci.current!==s;!l&&!c||(l&&(oi.current=D,Ht.current+=1,Vt.current=null,he(""),we(null),Ge(""),de(null),G(!1)),c&&(ci.current=s,qe.current=new Set,Te.clear(),us({}),Dn(h=>Object.keys(h).length===0?h:{}),Ve(o)))},[Te,D,Ve,o,R]),i.useEffect(()=>{if(!k||!a.listDirectory)return;const s=()=>{if(!document.hidden&<.length>0)for(const l of lt)Te.has(l)||Le(l)};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[Te,lt,a.listDirectory,Le,k]);const ui=i.useRef(!1);i.useEffect(()=>{const s=k&&!ui.current;if(ui.current=k,!(!k||!o)&&(Ve(o),s))for(const l of lt)Te.has(l)||Le(l)},[Te,lt,Ve,Le,o,k]),i.useEffect(()=>{if(!k||!a.listDirectory||lt.length===0)return;const s=setInterval(()=>{if(!document.hidden)for(const l of lt)Te.has(l)||Le(l)},8e3);return()=>clearInterval(s)},[Te,lt,a.listDirectory,Le,k]);const xl=i.useCallback(async s=>{if(s?.preventDefault(),!zt||!Dt)return;_n(!0);const l=()=>{$n(null)},c=y=>{se.error(y)},h=()=>{_n(!1)};if(Dt==="createFile"){if(!yt.trim()){c(t("sidebarFilesTree.toast.filenameRequired")),h();return}if(!a.writeFile){c(t("sidebarFilesTree.toast.writeNotSupported")),h();return}const y=zt.path,j=y?`${y}/`:"",V=Z(`${j}${yt.trim()}`);await a.writeFile(V,"").then(async B=>{B.success&&(se.success(t("sidebarFilesTree.toast.fileCreated")),await Le(y)),l()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Dt==="createFolder"){if(!yt.trim()){c(t("sidebarFilesTree.toast.folderNameRequired")),h();return}const y=zt.path,j=y?`${y}/`:"",V=Z(`${j}${yt.trim()}`);await a.createDirectory(V).then(async B=>{B.success&&(se.success(t("sidebarFilesTree.toast.folderCreated")),await Le(y)),l()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Dt==="rename"){if(!yt.trim()){c(t("sidebarFilesTree.toast.nameRequired")),h();return}if(!a.rename){c(t("sidebarFilesTree.toast.renameNotSupported")),h();return}const y=zt.path,j=y.split("/").slice(0,-1).join("/"),V=j?`${j}/`:"",B=Z(`${V}${yt.trim()}`);await a.rename(y,B).then(async me=>{me.success&&(se.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await Le(j),o&>(o,y),(u?.path===y||u?.path.startsWith(`${y}/`))&&(o&&Se(o,null),he(""),we(null),Ge(""),de(null),p&&G(!1))),l()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Dt==="delete"){if(!a.delete){c(t("sidebarFilesTree.toast.deleteNotSupported")),h();return}const y=zt.path,j=y.split("/").slice(0,-1).join("/");await a.delete(y).then(async V=>{V.success&&(se.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await Le(j),o&>(o,y),(u?.path===y||u?.path.startsWith(`${y}/`))&&(o&&Se(o,null),he(""),we(null),Ge(""),de(null),p&&G(!1))),l()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}h()},[Dt,zt,yt,a,Le,p,gt,o,u?.path,Se,t]);i.useEffect(()=>{if(!g){Bs([]),$s(!1);return}const s=X.trim();if(!s){Bs([]),$s(!1);return}let l=!1;return $s(!0),K(g,s,150,{includeHidden:S,respectGitignore:!C,type:"file"}).then(c=>{if(l)return;const y=c.filter(j=>C||!ku(j.path)).map(j=>({name:j.name,path:Z(j.path),type:"file",extension:j.extension,relativePath:j.relativePath}));Bs(y)}).catch(()=>{l||Bs([])}).finally(()=>{l||$s(!1)}),()=>{l=!0}},[g,X,K,S,C]);const tn=i.useCallback(async(s,l)=>{const c=xt(s);if(a.readFile)return(await a.readFile(s,{...c,directory:o||void 0,...l})).content??"";const h=new URLSearchParams({path:s});c.allowOutsideWorkspace&&h.set("allowOutsideWorkspace","true"),o&&h.set("directory",o);const y=await pr(`/api/fs/read?${h.toString()}`,{cache:l?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!y.ok){const j=await y.json().catch(()=>({error:y.statusText}));throw new Error(j.error||t("filesView.error.readFileFailed"))}return y.text()},[a,xt,o,t]),ut=i.useCallback(async s=>{if(a.statFile){const l=xt(s),c=await a.statFile(s,{...l,directory:o||void 0});return{path:c.path,size:c.size,mtimeMs:c.mtimeMs}}return null},[a,xt,o]);i.useEffect(()=>{if(!o||!a.statFile||Ne.length===0)return;let s=!1;const l=[...Ne];return Promise.all(l.map(async c=>{try{const h=xt(c),y=await a.statFile?.(c,{...h,directory:o||void 0});!s&&y&&!y.isFile&>(o,c)}catch(h){!s&&ga(h)&>(o,c)}})),()=>{s=!0}},[a,Ne,gt,xt,o]);const Ie=W!==O||Ws,Nt=i.useCallback((s,l=!0)=>{const{content:c,lineEnding:h}=Uc(s);return l&&Ss(Tn.current)&&Cn(y=>y+1),Ln.current=s,In.current+=1,Ua(h),he(c),bt.current=c,fs.current=c,ge(c),c},[]),At=i.useCallback(async()=>{if(!u||!a.writeFile)return se.error(t("filesView.toast.savingNotSupported")),!1;const s=Cs(u.path)||Pt;if(!_c({selectedFilePath:u.path,loadedFilePath:pe,fileLoading:Ce,isDirty:Ie,draftContent:W,fileContent:O,isNonEditableBinary:s}))return s?console.warn(`[saveDraft] refusing to save binary file "${u.path}".`):W===""&&O!==""&&pe!==u.path&&console.warn(`[saveDraft] refusing to save empty draft for "${u.path}" (${O.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(!Ie)return!0;zn(!0);try{const c=!!(u.path&&Ss(u.path)&&Ws)?ms.current?.getContent()??null:null,h=Kc(c?c.content:W,Tr);if(!(await a.writeFile(u.path,h))?.success)return se.error(t("filesView.toast.writeFileFailed")),!1;if(c?(Nt(h,!1),ms.current?.markSaved(c.signature)):(he(W),Ln.current=h,In.current+=1),o&&ks(u.path,o)){const j=jn(o,u.path);j&&Po.requestGitRefresh({directory:o,paths:[j]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(Z(u.path))){const j=Mo.getState().projects.find(V=>Z(V.path)===Z(o));if(j)try{await hc(j.id)}catch{se.error(t("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return u?.path&&Fs(u.path)&&(bt.current=W,fs.current=W),ut(u.path).then(j=>{j&&(st.current=j)}).catch(()=>{}),!0}catch(l){return se.error(l instanceof Error?l.message:t("filesView.toast.saveFailed")),!1}finally{zn(!1)}},[Nt,Pt,W,Ws,O,Ce,a,Ie,Tr,pe,ut,o,u,t]);i.useEffect(()=>{Fe||(qt("idle"),ot.current&&(clearTimeout(ot.current),ot.current=null))},[Fe]);const sn=1500;i.useEffect(()=>{const s=!!(u&&a.writeFile),l=!!(u?.path&&(Cs(u.path)||Pt));if(!$c({autoSaveEnabled:Fe,isDirty:Ie,canWrite:s,isSaving:ds,fileLoading:Ce,selectedFilePath:u?.path,loadedFilePath:pe,isNonEditableBinary:l}))return;const c=h=>{ot.current=setTimeout(()=>{const y=Date.now()-zr.current;if(y<sn){c(sn-y);return}At().then(j=>{j&&(qt("saved"),setTimeout(()=>qt("idle"),2e3))})},h)};return c(sn),()=>{ot.current&&(clearTimeout(ot.current),ot.current=null)}},[Fe,Pt,W,Ce,Ie,pe,u,a.writeFile,ds,At]),i.useEffect(()=>{qt("idle")},[u?.path]),Do({save_file:s=>{if(!(s.target instanceof Node)||!Ks.current?.contains(s.target)&&!Dr.current?.contains(s.target))return!1;ot.current&&(clearTimeout(ot.current),ot.current=null),ds||At().then(l=>{l&&(qt("saved"),setTimeout(()=>qt("idle"),2e3))})},find_in_file:s=>{if(!(s.target instanceof Node))return!1;if(Ye&&Be()==="preview"){if(p||!(re?Xs.current:qs.current)?.contains(s.target))return!1;Hs(!0),$r(c=>c+1);return}if(!Ks.current?.contains(s.target))return!1;_(!0)}});const di=i.useCallback(async s=>{const l=Ht.current+1;Ht.current=l;const c=it(),h=L.current,y=()=>{if(!o||it()!==c||L.current!==h)return!1;const A=Ze.getState().byRoot[o],oe=A?.selectedPath??A?.openPaths[0]??null;return Ht.current===l&&oe===s.path};we(null),Ge(""),de(null),Mr(!1),vt(!0);const j=lr(s.path),V=or(s.path),B=ea(s.path),me=Cs(s.path);if(p&&G(!0),v.isDesktop&&j&&!V){he(""),ge("");return}if(!v.isDesktop&&j&&!V){he(""),ge(""),de(s.path),vt(!1);return}if(B){he(""),ge(""),de(s.path),vt(!1);return}if(me){he(""),ge(""),de(s.path),vt(!1);return}await tn(s.path).then(A=>{if(!y())return;if(ta(A)){Mr(!0),he(""),ge(""),de(s.path);return}const oe=Nt(A),Lt=hr(s.path)||bn(s.path)||xa(s.path)||Fs(s.path)||or(s.path)||sa(s.path)||na(s.path)||Ss(s.path);ce(Lt?"edit":Hc(oe,Ms.current[s.path])),de(s.path),ut(s.path).then(is=>{is&&y()&&(st.current=is)}).catch(()=>{})}).catch(A=>{if(y()){if(Eu(A)){if(vt(!1),o&&Se(o,null),we(null),he(""),ge(""),de(null),st.current=null,ne.trim().length>0&&te(""),p&&G(!1),o){const Lt=[...ha(s.path,o),s.path];Lt.length>0&&Is(o,Lt);for(const is of Lt)qe.current.has(is)||Ve(is)}return}if(ga(A)){o&>(o,s.path),he(""),ge(""),we(null),st.current=null,p&&G(!1);return}he(""),ge(""),we(A instanceof Error?A.message:t("filesView.error.readFileFailed")),st.current=null}}).finally(()=>{y()&&vt(!1)})},[Nt,Is,p,Ve,tn,ut,gt,o,v.isDesktop,ne,Se,t]),nn=i.useCallback(async(s,l)=>{if(!e||!o)return;const c=ha(s,o),h=l?[...c,s]:c;if(h.length>0&&Is(o,h),!k)return;const y=h.map(j=>{if(!qe.current.has(j))return Ve(j)}).filter(Boolean);await Promise.all(y)},[Is,Ve,o,k,e]),fi=i.useCallback((s,l)=>{const c=l.findIndex(h=>h.path===s);return c===-1||l.length<=1?null:l[c+1]??l[c-1]??null},[]),Pe=i.useCallback(async s=>{if(xs.current)xs.current=!1;else if(Ie){ps(!0),Gt.current=s;return}o&&(Se(o,s.path),nn(s.path,!1)),we(null),Ge(""),he(""),bt.current="",fs.current="",Tt(!1),ge(""),de(null),p&&G(!0)},[nn,Ie,p,o,Se]);i.useEffect(()=>{u?.path&&nn(u.path,!1)},[nn,u?.path]),i.useEffect(()=>{if(!e)return;if(!u){Ht.current+=1,Vt.current=null,vt(!1);return}if(pe===u.path||Vt.current===u.path)return;const s=u.path;Vt.current=s,di(u).finally(()=>{Vt.current===s&&(Vt.current=null)})},[hs,di,pe,u,e]);const rn=i.useRef(Ie);rn.current=Ie,i.useEffect(()=>Go(({runtimeKey:s,paths:l})=>{const c=u?.path;s!==it()||!c||rn.current||!l.includes(Z(c))||(Ht.current+=1,Vt.current=null,st.current=null,Ge(""),we(null),de(null),Ha(h=>h+1))}),[u?.path]),i.useEffect(()=>{if(!e||!u?.path||pe!==u.path)return;const s=u.path,l=it(),c=L.current,h=()=>rn.current||Fs(s)&&bt.current!==fs.current,y=!Cs(s)&&!lr(s)&&!Pt?Ac({readContent:()=>tn(s,{fresh:!0}),getLoadedContent:()=>Ln.current,getLoadedRevision:()=>In.current,isDirty:h,applyContent:A=>{if(!(j||it()!==l||L.current!==c)){if(ta(A)){de(null);return}Nt(A)}}}):null;let j=!1,V=!1;const B=()=>{document.hidden||V||(V=!0,ut(s).then(async A=>{if(j||it()!==l||L.current!==c||!A)return;const oe=st.current;if(!oe||oe.path!==s){st.current=A;return}if(Ic(oe,A)){if(y&&A.size<=Tu){await y.poll()&&!j&&(st.current=A);return}rn.current||(st.current=A,de(null))}}).catch(()=>{}).finally(()=>{V=!1}))};B();const me=window.setInterval(B,2e3);return()=>{j=!0,y?.dispose(),window.clearInterval(me)}},[Nt,Pt,pe,tn,ut,u?.path,e]);const vl=i.useCallback(()=>{const s=Gt.current,l=gs.current;if(Gt.current=null,gs.current=null,xs.current=!0,ps(!1),Tt(!1),Cn(c=>c+1),ge(O),l){o&&Wt(o,l),u?.path===l&&(s?Pe(s):(o&&Se(o,null),he(""),we(null),Ge(""),de(null),p&&G(!1)));return}if(s){Pe(s);return}},[O,Pe,p,Wt,o,u?.path,Se]),wl=i.useCallback(async()=>{const s=Gt.current,l=gs.current;if(!await At()){xs.current=!1;return}if(Gt.current=null,gs.current=null,xs.current=!0,ps(!1),l){o&&Wt(o,l),u?.path===l&&(s?await Pe(s):(o&&Se(o,null),he(""),we(null),Ge(""),de(null),p&&G(!1)));return}if(s){await Pe(s);return}},[Pe,p,Wt,o,At,u?.path,Se]),mi=i.useCallback(s=>{const l=u?.path===s,c=fi(s,Kt);if(l&&Ie){ps(!0),Gt.current=c,gs.current=s;return}if(o&&Wt(o,s),!!l){if(c){Pe(c);return}o&&Se(o,null),he(""),we(null),Ge(""),de(null),p&&G(!1)}},[fi,Pe,Ie,p,Kt,Wt,o,u?.path,Se]),hi=i.useMemo(()=>new Set(Ne),[Ne]),an=i.useMemo(()=>pc(E?Q?.files??[]:[]),[Q?.files,E]),bl=i.useCallback(s=>{if(hi.has(s))return"open";const l=s.startsWith(o+"/")?s.slice(o.length+1):s;return an.statusByPath.get(l)??null},[hi,an,o]),yl=i.useCallback(s=>{if(!Q?.files)return null;const l=s.startsWith(o+"/")?s.slice(o.length+1):s;return an.badgeByDir.get(l)??null},[Q,an,o]),jl=i.useCallback(async s=>{const l=Z(s);o&&(Sr(o,l),qe.current.has(l)||await Ve(l))},[Ve,o,Sr]),Nl=i.useMemo(()=>({canRename:Ur,canCreateFile:_r,canCreateFolder:Wr,canDelete:Kr,canReveal:Hr}),[Ur,_r,Wr,Kr,Hr]);function pi(s,l){const c=kr[s]??[];return c.map((h,y)=>{const j=h.type==="directory",V=j&&Ia.has(h.path),B=u?.path===h.path,me=y===c.length-1;return n.jsxs("li",{className:"relative",children:[l>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),me&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),n.jsx(Vu,{node:h,root:o,isExpanded:V,isActive:B,isMobile:p,isBrowserClient:N,alwaysShowActions:F,status:j?void 0:bl(h.path),badge:j?yl(h.path):void 0,permissions:Nl,downloadFile:a.downloadFile,contextMenuPath:el,setContextMenuPath:tl,rightClickMenuPath:sl,setRightClickMenuPath:nl,onSelect:Pe,onToggle:jl,onRevealPath:ul,onOpenDialog:Un,canUpload:ai&&!en,onPickFiles:li}),j&&V&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[Os[h.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:Os[h.path],children:Os[h.path]}),n.jsxs(I,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Le(h.path)},children:[n.jsx(T,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):null,pi(h.path,l+1)]})]},h.path)})}const Oe=!!(u?.path&&lr(u.path)),Je=!!(u?.path&&or(u.path)),gi=Je&&Ke==="edit",St=!!(u?.path&&ea(u.path)),xi=!!(u?.path&&zo(u.path)),qn=xi||!!(u?.path&&Ao(u.path)),Gn=!!(u?.path&&Lo(u.path)),ln=!!(u?.path&&(Cs(u.path)||Pt)),Zt=ln&&!Oe&&!St&&!qn&&!Gn,vi=ln||Oe&&!gi,wi=i.useMemo(()=>Z(ct?.path??""),[ct?.path]),Qt=!!(ct&&wi&&Ee&&Ee===wi&&!Ce&&!tt&&!vi),Ct=i.useMemo(()=>jn(o,Ee),[Ee,o]),Sl=!!(u&&(!Oe||Je)&&!St&&!Zt&&O.length>0),Cl=!!(u&&Ct.length>0),rt=!!(u&&!Vn&&!ln&&(!Oe||Je)&&a.writeFile),Ye=!!(u?.path&&hr(u.path)),es=!!(u?.path&&xa(u.path)),ts=!!(u?.path&&bn(u.path)),js=!!(u?.path&&Fs(u.path)),Ft=!!(u?.path&&Ss(u.path)),ss=!!(u?.path&&sa(u.path)),ns=!!(u?.path&&na(u.path)),Fl=!!(u&&!ln&&(!Oe||Je)),Rl=i.useMemo(()=>Ft&&wr(W),[Ft,W]),on=Fl&&!Ye&&!js&&!Ft&&!(ts&&ae==="preview")&&!(Je&&Ke==="preview")&&!(ss&&je==="preview")&&!(ns&&Qe==="table"),kl=Ye&&fe==="edit"||ts&&ae==="edit"||Ft&&(ke==="edit"||!Rl)||Je&&Ke==="edit"||ss&&je==="edit"||ns&&Qe==="text"||es&&ue==="text"||!Ye&&!ts&&!es&&!Ft&&!Je&&!ss&&!ns&&H==="edit",cn=i.useMemo(()=>Ee?Io(Ee):null,[Ee]),[bi,Xn]=i.useState(null);i.useEffect(()=>{let s=!1;const l=u?.path;if(!l||cn){Xn(null);return}return Xn(null),Oo(l).then(c=>{s||Xn(c)}),()=>{s=!0}},[u?.path,cn]),i.useEffect(()=>{!rt&&H==="edit"&&ce("view")},[rt,H]);const Jn="openchamber:files:md-viewer-mode",Yn="openchamber:files:html-viewer-mode",Zn="openchamber:files:json-viewer-mode";i.useEffect(()=>{const s=u?.path;if(!s)return;ce(Ms.current[s]??"edit");let l=bs?"preview":"edit";try{const y=localStorage.getItem(Jn);(y==="preview"||y==="edit")&&(l=y)}catch{}be(Fn.current[s]??l);let c=bs?"preview":"edit";try{const y=localStorage.getItem(Yn);(y==="preview"||y==="edit")&&(c=y)}catch{}We(Rn.current[s]??c),ye(kn.current[s]??(bs?"preview":"edit")),Ue(Ds.current[s]??"preview"),Rt(br.current[s]??"preview"),He(yr.current[s]??"preview"),le(jr.current[s]??"table");let h=bs?"tree":"text";try{const y=localStorage.getItem(Zn);(y==="tree"||y==="text")&&(h=y)}catch{}ze(h)},[u?.path,bs]);const El=i.useCallback(s=>{const l=u?.path;l&&(Ms.current[l]=s),ce(s)},[u?.path]),Tl=i.useCallback(s=>{const l=u?.path;l&&(Fn.current[l]=s),be(s);try{localStorage.setItem(Jn,s)}catch{}},[u?.path]),Be=i.useCallback(()=>fe,[fe]),Vl=i.useCallback(s=>{const l=u?.path;l&&(br.current[l]=s),Rt(s)},[u?.path]),Pl=i.useCallback(s=>{const l=u?.path;l&&(yr.current[l]=s),He(s)},[u?.path]),Ml=i.useCallback(s=>{const l=u?.path;l&&(jr.current[l]=s),le(s)},[u?.path]);i.useEffect(()=>{const s=u?.path;if(Ps(null),!s||pe!==s)return;let l=!1;return ut(s).then(c=>{!l&&c&&Ps(c.size)}).catch(()=>{}),()=>{l=!0}},[hs,pe,ut,u?.path]);const yi=u&&Ye&&Be()==="preview"&&!Ce?u.path:null;i.useEffect(()=>{!yi||p||Gs()},[Gs,re,p,yi]);const Dl=i.useCallback(s=>{ze(s);try{localStorage.setItem(Zn,s)}catch{}},[]),zl=i.useCallback(s=>{const l=u?.path;l&&(Rn.current[l]=s),We(s);try{localStorage.setItem(Yn,s)}catch{}},[u?.path]),Al=i.useCallback(s=>{const l=u?.path;if(l&&(kn.current[l]=s),Ae.current&&(clearTimeout(Ae.current),Ae.current=null),dt.current!==null&&(cancelAnimationFrame(dt.current),dt.current=null),s==="edit")ge(bt.current||O),ye(s);else{bt.current=W;const c=l;ye("edit"),dt.current=requestAnimationFrame(()=>{dt.current=requestAnimationFrame(()=>{dt.current=null,!(o&&c&&Ze.getState().byRoot[o]?.selectedPath!==c)&&(Aa(h=>h+1),ye("preview"))})});return}},[W,O,o,u?.path]),Ll=i.useCallback(s=>{const l=u?.path;if(l&&(Ds.current[l]=s),s==="edit"){An.current&&ge(ms.current?.getContent()?.content??O),Tt(!1),Ue(s);return}if(!wr(W)){se.error(t("filesView.excalidraw.invalidScene"));return}Tt(!1);const c=l;Et.current!==null&&cancelAnimationFrame(Et.current),Et.current=requestAnimationFrame(()=>{Et.current=null,!(o&&c&&Ze.getState().byRoot[o]?.selectedPath!==c)&&(Cn(h=>h+1),Ue("preview"))})},[W,O,o,u?.path,t]),Qn=i.useCallback(async(s,l)=>{if(!a.writeFile||l===fs.current)return!1;if(!(await a.writeFile(s,l))?.success)return se.error(t("filesView.toast.writeFileFailed")),!1;Nt(l);const h=await ut(s).catch(()=>null);return h&&(st.current=h),!0},[Nt,a,ut,t]);i.useEffect(()=>()=>{Ae.current&&(clearTimeout(Ae.current),Ae.current=null),dt.current!==null&&(cancelAnimationFrame(dt.current),dt.current=null)},[ve,u?.path]);const Il=i.useCallback(s=>{if(bt.current=s,!Fe||!u?.path||ve!=="preview"||!a.writeFile)return;Ae.current&&clearTimeout(Ae.current);const l=u.path;Ae.current=setTimeout(()=>{Ae.current=null,Qn(l,s).then(c=>{c&&(Us(!0),setTimeout(()=>Us(!1),1500))}).catch(c=>{se.error(c instanceof Error?c.message:t("filesView.toast.saveFailed"))})},sn)},[Fe,ve,a.writeFile,Qn,u?.path,t]),Ol=i.useMemo(()=>js&&(bt.current||W)||O,[W,O,js]),Bl=i.useCallback(()=>{const s=Tn.current;s&&(Ds.current[s]="edit"),Tt(!1),Ue("edit"),se.error(t("filesView.excalidraw.invalidScene"))},[t]);i.useEffect(()=>()=>{Et.current!==null&&(cancelAnimationFrame(Et.current),Et.current=null)},[ke,u?.path]);const ji=i.useCallback(()=>ae,[ae]);i.useEffect(()=>{const s=c=>{const h=c?"preview":"edit",y=c?"tree":"text";for(const j of Ne)Ms.current[j]="edit",hr(j)&&(Fn.current[j]=h),bn(j)&&(Rn.current[j]=h),Fs(j)&&(kn.current[j]=h),Ss(j)&&(Ds.current[j]=h);ce("edit"),be(h),We(h),ye(h),Ue(h),ze(y);try{localStorage.setItem(Jn,h),localStorage.setItem(Yn,h),localStorage.setItem(Zn,y)}catch{}},l=c=>{const h=!!c.detail?.enabled;s(h)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",l),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",l)}},[Ne]),i.useEffect(()=>{if(!ct||!o)return;const s=()=>{typeof window>"u"||Xt.current===null&&(Xt.current=window.requestAnimationFrame(()=>{Xt.current=null,Bn(mt=>mt+1)}))},l=(mt,It)=>{if(mt.state.doc.length!==It.length)return!1;if(It.length===0)return!0;const ir=Math.min(128,It.length);if(mt.state.sliceDoc(0,ir)!==It.slice(0,ir))return!1;const qi=Math.max(0,It.length-ir);return mt.state.sliceDoc(qi,It.length)===It.slice(qi)},c=Z(ct.path);if(!c){Js(null),Mt.current={key:"",attempts:0};return}const h=`${c}:${ct.line}:${ct.column??1}`;if(Mt.current.key!==h&&(Mt.current={key:h,attempts:0}),u?.path!==c){if(On)return;Pe(Ut(c));return}if(Ce||pe!==c)return;if(tt||Oe||St||Zt){Js(null),Mt.current={key:"",attempts:0};return}if(!rt)return;if(H!=="edit"){ce("edit");return}const y=Xe.current;if(!y){s();return}if(!l(y,W)){s();return}const j=Math.max(1,Math.min(ct.line,y.state.doc.lines)),V=y.state.doc.line(j),B=Math.max(1,ct.column||1),me=Math.max(0,V.to-V.from),A=Math.min(me,B-1),oe=V.from+A;if(!(y.state.selection.main.head===oe)||Mt.current.attempts===0){Mt.current.attempts+=1,y.dispatch({selection:{anchor:oe},effects:_t.scrollIntoView(oe,{y:"center"})}),y.focus(),s();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const mt=Xe.current;mt&&(mt.dispatch({selection:{anchor:oe},effects:_t.scrollIntoView(oe,{y:"center"})}),mt.focus())}),Js(null),Mt.current={key:"",attempts:0}},[rt,On,W,Ya,tt,Ce,Oe,St,Zt,pe,Pe,ct,o,u?.path,Js,H,Ut]),i.useEffect(()=>{if(!Kn||!o)return;const s=Z(Kn);if(!s){Hn(null);return}u?.path===s&&(Ce||pe!==s||(!tt&&!Oe&&!St&&!Zt&&rt&&H==="edit"&&Xe.current?.focus(),Hn(null)))},[rt,tt,Ce,Oe,St,Zt,pe,Kn,o,u?.path,Hn,H]);const rs=i.useCallback(s=>{if(!p||!s||typeof window>"u")return;const l=document.activeElement,c=!s.hasFocus&&l instanceof HTMLElement&&s.dom.contains(l)?l.closest('[data-comment-input="true"]'):null;if(!s.hasFocus&&!c)return;const h=window.visualViewport;if(!h)return;const y=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,y-(h.offsetTop+h.height))<=0)return;const V=c?c.getBoundingClientRect():s.coordsAtPos(s.state.selection.main.head);if(!V)return;const B=Math.round(h.offsetTop+h.height),A=V.bottom+20-B;A<=0||(s.scrollDOM.scrollTop+=A)},[p]);i.useEffect(()=>{if(!p||typeof window>"u")return;const s=()=>{window.requestAnimationFrame(()=>{rs(Xe.current)})},l=window.visualViewport;return l?.addEventListener("resize",s),l?.addEventListener("scroll",s,{passive:!0}),document.addEventListener("selectionchange",s),()=>{l?.removeEventListener("resize",s),l?.removeEventListener("scroll",s),document.removeEventListener("selectionchange",s)}},[p,rs]),Bo("open_go_to_line",s=>{if(!rt||H!=="edit"||p)return!1;const l=s.target;if(l?.closest('[role="dialog"]')||!(l instanceof Node)||!Ks.current?.contains(l))return!1;const c=!!l?.closest(".cm-editor");if(!!l?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!c)return!1;Wn(!0)});const un=ht(s=>s.editorFontSize),Ni=i.useMemo(()=>{if(!u?.path)return[ra(f,{fontSize:un})];const s=ar(u.path),l=[ra(f,s?{syntaxColors:!1,fontSize:un}:{fontSize:un})],c=cn??bi;return c&&l.push(c),s&&l.push(tc({language:s,themeName:f.metadata.id,theme:lc(f)})),ee&&l.push(_t.lineWrapping),p&&l.push(_t.updateListener.of(h=>{h.view.hasFocus&&(h.selectionSet||h.focusChanged||h.viewportChanged||h.geometryChanged)&&window.requestAnimationFrame(()=>{rs(h.view)})})),l},[f,u?.path,cn,bi,ee,p,rs,un]),Si=i.useMemo(()=>({light:zs.metadata.id,dark:As.metadata.id}),[zs.metadata.id,As.metadata.id]),Ci=St||qn||Gn,Ns=u?.path&&Ci?`${u.path}|${Pn.allowOutsideWorkspace?"outside":"workspace"}|${hs}`:"",dn=u?.path&&ts&&ae==="preview"&&!v.isVSCode?`${u.path}|${hs}`:"",Fi=t("filesView.error.readFileFailed"),{readyKey:Ri,nonce:$l}=wa(dn,we,Fi),{readyKey:ki,nonce:fn}=wa(Ns,we,Fi),_l=!!(dn&&Ri!==dn),er=!!(Ns&&ki!==Ns),Wl=u?.path&&Oe?Je?`data:${$o(u.path)};utf8,${encodeURIComponent(O)}`:Wa:"",mn=u?.path&&Ci&&Ns&&ki===Ns?Ji().authenticatedAsset(mo("/api/fs/raw",o),{path:u.path,allowOutsideWorkspace:Pn.allowOutsideWorkspace?"true":void 0,directory:o||void 0}):"",Ul=i.useCallback(s=>n.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:n.jsx("iframe",{src:mn,className:"h-full w-full border-0",title:s.name},fn)}),[mn,fn]),Ei=u&&a.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const s=a.downloadFile;!s||!u||s(u.path).catch(l=>{console.error("Download failed:",l),se.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(T,{name:"download",className:"mr-2 size-4"}),t("filesView.editor.saveFile")]}):null,hn=u&&!Ce&&!er&&!tt?(s=>Oe&&!gi?n.jsx(cu,{src:Wl,name:s.name,sizeBytes:et}):St?Ul(s):qn?n.jsx(uu,{kind:xi?"video":"audio",src:mn,name:s.name,sizeBytes:et,download:Ei},fn):Gn?n.jsx(au,{src:mn,name:s.name,sizeBytes:et},fn):Zt?n.jsx(nu,{name:s.name,path:s.path,sizeBytes:et,download:Ei}):ns&&Qe==="table"?n.jsx(hu,{path:s.path,content:O,sizeBytes:et}):ss&&je==="preview"?n.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:n.jsx(xn,{fallback:n.jsxs("div",{className:"m-3 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:n.jsx(ur,{content:`\`\`\`mermaid
|