@opentig/cli 0.1.6 → 0.1.8
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/bin.mjs +1 -4
- package/dist/chunks/{cli-ABzC6-gR.mjs → cli-BgNif2D1.mjs} +1 -1
- package/dist/client/assets/App-9EfSdZB8.js +74 -0
- package/dist/client/assets/CreatePullRequestDialog-BgVrWdkH.js +2 -0
- package/dist/client/assets/DiffWorkspace-Ca2ZUlVn.js +26 -0
- package/dist/client/assets/EditableFileViewer-85aEeMBK.js +1 -0
- package/dist/client/assets/File-DTtWrbYf.js +1 -0
- package/dist/client/assets/{FilesView-DIqPfRbv.js → FilesView-rT5hzb7y.js} +1 -1
- package/dist/client/assets/GitHubAvatar-EO1TD_1z.js +1 -0
- package/dist/client/assets/HistoryView-C4c0CqMC.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-BsewwJtM.js → HtmlFileViewer-bL6T57PQ.js} +1 -1
- package/dist/client/assets/{IconEdit-CxvzMyLV.js → IconEdit-DePJMGIi.js} +1 -1
- package/dist/client/assets/{IconFolderPlus-1vLDIzhC.js → IconFolderPlus-ByGyA0Di.js} +1 -1
- package/dist/client/assets/{ImageFileViewer-CoQZkgET.js → ImageFileViewer-DJaHH3hJ.js} +1 -1
- package/dist/client/assets/{LocalRefsDialog-sw-ROjfe.js → LocalRefsDialog-D9wYZWBg.js} +1 -1
- package/dist/client/assets/MarkdownFileViewer-BNPb9v8u.js +2 -0
- package/dist/client/assets/{PairingPage-CYJXzBZC.js → PairingPage-D9oguvKU.js} +1 -1
- package/dist/client/assets/PierreDiffViewer-8wTLYd5-.js +1 -0
- package/dist/client/assets/{PierreEditBoundary-Bb4dONIq.js → PierreEditBoundary-KzU3HDc2.js} +2 -2
- package/dist/client/assets/{PierreWorkerPool-BuBzE8K1.js → PierreWorkerPool-DH2jp9oe.js} +18 -18
- package/dist/client/assets/{PullRequestDiff-CgY4QIHC.js → PullRequestDiff-DK-m07ZP.js} +1 -1
- package/dist/client/assets/PullRequestViewer-CpLwq4o2.js +2 -0
- package/dist/client/assets/PullRequestsView-DnvXaJ4t.js +1 -0
- package/dist/client/assets/{QuickOpenDialog-Cn-aQRAS.js → QuickOpenDialog-DIWjfUkt.js} +1 -1
- package/dist/client/assets/RepositoryProjectsDialog-BsQn5Yjr.js +1 -0
- package/dist/client/assets/{SearchView-BtKBEJ7e.js → SearchView-D-91dtSv.js} +1 -1
- package/dist/client/assets/SettingsDialog-dJUYk2cP.js +9 -0
- package/dist/client/assets/Viewer-GH-5bJW4.js +3 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-DLBLFOdy.js → abnfDiagram-N423BO3Z-CkHOGdAl.js} +1 -1
- package/dist/client/assets/{arc-D-Yei3Vr.js → arc-Dj8F8CO5.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-BOgBvzWh.js → architectureDiagram-T3A2C74G-g87Y5LXk.js} +1 -1
- package/dist/client/assets/base-ui-DT3JsyND.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-BQXRJDyR.js → blockDiagram-VBNYF7ZC-D6efB7jD.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-DTZseD56.js → c4Diagram-5PPSVZJV-DoZEC2xg.js} +1 -1
- package/dist/client/assets/channel-Dsy2VD23.js +1 -0
- package/dist/client/assets/{checkbox-BwbxYGgK.js → checkbox-DYwmgDPS.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-spRCgfPY.js → chunk-2GRJ4B5K-Dr44hDNV.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-CLVClH0M.js → chunk-2Q5K7J3B-YIEyVOOL.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-CuQ5tYjB.js → chunk-5RXB4S5H-gjmGBtkE.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DyOEOe90.js → chunk-5VM5RSS4-DCOQko4g.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-CgMtuJIx.js → chunk-6Q2QTUOP-DfGlvPVm.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-BH63P4Vv.js → chunk-GF5L2VYU-CCWOLPVL.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-BANDbaPq.js → chunk-JWPE2WC7-CFRTGh8r.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-Bfty2upo.js → chunk-KBJHAD2P-By3wsJVD.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-Cvu8BZS9.js → chunk-RYQCIY6F-C0wmsHmy.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-bnohf1yd.js → chunk-XXDRQBXY-t3SnJvV_.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BBQJgoWd.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BBQJgoWd.js +1 -0
- package/dist/client/assets/{vb-D17OF-Vu.js → cmd-BW5THilD.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-DCTEAZwO.js → cose-bilkent-JH36ORCC-D3VltoVk.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-Bp2wXvdt.js → cynefin-VYW2F7L2-DwLwbeoe.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-DRRWzuF0.js → cynefinDiagram-MW4NZA55-B23kuaQF.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-DDvsotRK.js → dagre-VZM6K2ZE-SgMrTr2p.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-CMqhRNRq.js → diagram-7IWD3JNH-C7cQN4aD.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-D_PYI1ut.js → diagram-B4RE2ZJO-CzeI3yOw.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-BSUx7mMM.js → diagram-LBJQPF4R-DhKm4hlI.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-C8O3g6WT.js → diagram-Q27KOJAE-BXlU6Wp3.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-C5-NDsgC.js → diagram-UB23O5K3-BOwY_YwR.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-D71hx4Ww.js → ebnfDiagram-BXEA7PRR-CuIQuYPa.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-yd9B5d8I.js → erDiagram-JOGREHBK-d45NhKfk.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-CWU5VVbw.js → flowDiagram-UKHOOZJN-Dzq-6qo7.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-D2siVjfa.js → ganttDiagram-PKOTCBZU-RVlL9mX2.js} +1 -1
- package/dist/client/assets/{gh-utils-B0Nlmxep.js → gh-utils-LsOSydCg.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-CIvIFcxR.js → gitGraphDiagram-DS77QQ5N-8kEJVUFH.js} +1 -1
- package/dist/client/assets/{index-DDbUjVD9.js → index-BzmFkR37.js} +1 -1
- package/dist/client/assets/{index-BOPi2b1j.js → index-CQcx9aRt.js} +4 -4
- package/dist/client/assets/index-DMbFAH51.css +1 -0
- package/dist/client/assets/{infoDiagram-6WML65LV-DRvl8KfO.js → infoDiagram-6WML65LV-Co21Ql9M.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-H5EQq6uE.js → ishikawaDiagram-WSZJBQD7-BvPB_G97.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-CCwLmD-U.js → journeyDiagram-NVQOT4AX-k7x89IE9.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-DS--XHEu.js → kanban-definition-27J2QSJJ-BjrgN30t.js} +1 -1
- package/dist/client/assets/{linear-Q3JNM6CR.js → linear-m158kske.js} +1 -1
- package/dist/client/assets/{mermaid.core-EwS_m22C.js → mermaid.core-C0FKucv-.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-D15nrwfe.js → mindmap-definition-FAOFIHXS-CF8noycK.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-DOG19gxx.js → pegDiagram-VL7TDLO6-_y7nfJFV.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-Bstdr7Wh.js → pieDiagram-7S7Q4E2Y-DhdWHi45.js} +1 -1
- package/dist/client/assets/{platform-BMNQ8V5r.js → platform-Bqt97_Jr.js} +2 -2
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-DfKs4qZW.js → quadrantDiagram-CIZ2JOQS-BRvEIECQ.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-DJKxyuhV.js → railroadDiagram-AXF67PYL-BgLZ8XU1.js} +1 -1
- package/dist/client/assets/render-markdown-2GjhuGA-.js +280 -0
- package/dist/client/assets/repository-grammars-ixqpb0uW.js +1 -0
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-SGJWVmBV.js → requirementDiagram-LRYGKXZP-CX-gxyGF.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-CpZFct0O.js → sankeyDiagram-W5VNT64P-CLSjSU_X.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-B7plRik9.js → sequenceDiagram-SI44F4Z6-dGlHyZRB.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-CNbK285t.js → sizeCapture-X5ZJPWSS-BH3qO9T3.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-BIHk9QCC.js → stateDiagram-OKZ733FA-FXxo1iIM.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-DqxQ14yP.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-7g_XCosC.js → swimlanes-SLNWSIFB-VJGIuM4S.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-No0dCAkd.js +8 -0
- package/dist/client/assets/{tanstack-B8_amOz8.js → tanstack-CtfgE41X.js} +1 -1
- package/dist/client/assets/{timeline-definition-Z64GVDOM-B-cgSggY.js → timeline-definition-Z64GVDOM-BXNTAanY.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-Bt5-8VZ2.js → vennDiagram-T6HMQDX7-D9nXAts5.js} +1 -1
- package/dist/client/assets/{viewer-tabs-DxCOe0ut.js → viewer-tabs-DkLmDzFg.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-B5Imx6zh.js → wardleyDiagram-T6FBY63Y-D89EaEfa.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-CDaY4xFS.js → xychartDiagram-ELKLHX3M-B_xFDiIh.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +1 -4
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +791 -2553
- package/dist/utility.mjs +0 -3
- package/package.json +1 -1
- package/dist/client/assets/App-CBetJ5ZN.js +0 -74
- package/dist/client/assets/CreatePullRequestDialog-W82oHjYm.js +0 -2
- package/dist/client/assets/DiffWorkspace-BWkTIl5n.js +0 -26
- package/dist/client/assets/EditableFileViewer-Cv3aNJBN.js +0 -1
- package/dist/client/assets/File-DiOOsHOl.js +0 -1
- package/dist/client/assets/GitHubAvatar-DBc3Vxnk.js +0 -1
- package/dist/client/assets/HistoryView-DYxWYYVx.js +0 -1
- package/dist/client/assets/MarkdownFileViewer-BedKCXTI.js +0 -2
- package/dist/client/assets/PierreDiffViewer-uhTsb-F7.js +0 -1
- package/dist/client/assets/PullRequestViewer-KZl0osME.js +0 -2
- package/dist/client/assets/PullRequestsView-DkN3pW33.js +0 -1
- package/dist/client/assets/RepositoryProjectsDialog-F-EctLXx.js +0 -1
- package/dist/client/assets/SettingsDialog-wfWhEzZY.js +0 -9
- package/dist/client/assets/Viewer-D-oFua7K.js +0 -3
- package/dist/client/assets/base-ui-qeHDA5zu.js +0 -1
- package/dist/client/assets/channel-DrMuSkDK.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BKiL0hkR.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BKiL0hkR.js +0 -1
- package/dist/client/assets/index-CryuKDT3.css +0 -1
- package/dist/client/assets/render-markdown-C7X2TwRk.js +0 -280
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-Cqw0H5cq.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-BzKpdiGK.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,r as i,a as bt}from"./react-rd22PHbN.js";import{a as wt}from"./tanstack-B8_amOz8.js";import{a3 as Mt,a5 as vt,a7 as St,a8 as Ve,a9 as Nt,X as Rt,aa as It,ab as Et,ac as Ft,ad as Tt,ae as T,G as Pt,af as _t,j as zt,O as Ge,ag as $t,ah as Xe,ai as Ye,aj as Kt,ak as Lt,al as At,am as Ht,R as Bt,an as Ut,ao as Fe,ap as Vt,aq as Xt,Y as We,ar as Yt,as as Ee,at as qt,au as Ot,t as Gt,y as Wt,D as Zt,c as Jt,d as Qt,e as en}from"./App-CBetJ5ZN.js";import{c as K,d as Te,B as H,I as tn}from"./index-BOPi2b1j.js";import{m as nn,n as sn,M as on,o as rn,p as an,q as ln,S as cn}from"./base-ui-qeHDA5zu.js";import{I as Ze}from"./IconFolderPlus-1vLDIzhC.js";import{I as dn}from"./IconEdit-CxvzMyLV.js";const un=[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]],hn=K("outline","arrow-back-up","ArrowBackUp",un);const pn=[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]],fn=K("outline","arrow-forward-up","ArrowForwardUp",pn);const gn=[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",key:"svg-1"}]],Je=K("outline","clipboard","Clipboard",gn);const xn=[["path",{d:"M3 4a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-16",key:"svg-0"}],["path",{d:"M12 3v18",key:"svg-1"}]],Qe=K("outline","columns-2","Columns2",xn);const mn=[["path",{d:"M4 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-0"}],["path",{d:"M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M9.15 14.85l8.85 -10.85",key:"svg-2"}],["path",{d:"M6 4l8.85 10.85",key:"svg-3"}]],jn=K("outline","cut","Cut",mn);const yn=[["path",{d:"M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],Dn=K("outline","dots","Dots",yn);const kn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M12 11l0 6",key:"svg-2"}],["path",{d:"M9 14l6 0",key:"svg-3"}]],et=K("outline","file-plus","FilePlus",kn);const Cn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],bn=K("outline","file-text","FileText",Cn),wn=nn,Mn=sn;function vn({className:n,children:d,...u}){return t.jsx(on,{children:t.jsx(rn,{className:"isolate z-50 outline-none",children:t.jsx(an,{"data-slot":"context-menu-content",className:Te("min-w-44 origin-(--transform-origin) rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",n),...u,children:d})})})}function b({className:n,...d}){return t.jsx(ln,{"data-slot":"context-menu-item",className:Te("flex h-8 cursor-default items-center gap-2 rounded-md px-2 text-xs outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",n),...d})}function oe({className:n,...d}){return t.jsx(cn,{"data-slot":"context-menu-separator",className:Te("mx-1 my-1 h-px bg-border",n),...d})}const Sn=29,xe=6,tt="files-tree-root-drop",Nn=550,Rn={duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},qe=6,In=n=>{const d=Kt(n),u=d.length>0?d:Lt(n),g=u.find(x=>x.id!==tt);return g?[g]:u.slice(0,1)};function nt(n,d,u=0){const g=[];for(const x of n)g.push({entry:x,depth:u}),x.type==="directory"&&d.has(x.path)&&g.push(...nt(x.children,d,u+1));return g}function En(n,d,u){const g=n.findIndex(p=>p.entry.path===d),x=n.findIndex(p=>p.entry.path===u);if(g===-1||x===-1)return[u];const[l,h]=g<=x?[g,x]:[x,g];return n.slice(l,h+1).map(p=>p.entry.path)}function me(n){return n.type==="directory"?n.path:We(n.path)}function Vn({active:n,initialExpandedPaths:d,files:u,filesSnapshotRevision:g,showDotEnvFiles:x,activePath:l,readOnly:h,fileClipboardAvailable:p,revealAvailable:B,historyState:L,onQuickOpen:C,onUndo:A,onRedo:U,onOpenFile:j,onLoadDirectory:w,onPersistExpandedPaths:re,onCopyPath:je,onCopyEntries:ae,onCutEntries:ie,onCopyContents:ye,onPaste:O,onMoveEntries:De,onDeleteEntries:le,onReveal:ke,onRename:Ce,onCreate:be}){const we=Mt(),G=vt(),[P,Me]=i.useState(!1),S=G?44:Sn,ce=i.useRef(null),V=i.useRef(null),[m,R]=i.useState(new Set),[de,X]=i.useState(l),[Y,_]=i.useState(l),[N,W]=i.useState(()=>new Set(d)),[ue,Z]=i.useState([]),[M,z]=i.useState(null),[J,ve]=i.useState(null),[_e,st]=i.useState(null),[ot,rt]=i.useState(!1),[at,$]=i.useState(null),[he,it]=i.useState(0),[I,pe]=i.useState(new Map),lt=St(Ve(Ht,{activationConstraint:{distance:5}}),Ve(At)),ze=i.useRef(I),Q=i.useRef(new Set),$e=i.useRef(0),E=i.useRef(null),ee=i.useRef(null),Ke=i.useRef(d.join("\0")),fe=i.useMemo(()=>new Set(I.keys()),[I]),F=i.useMemo(()=>u===null?null:Nt(u,I),[u,I]),f=i.useMemo(()=>F===null?null:x?F:Rt(F),[F,x]);i.useEffect(()=>{ze.current=I},[I]),i.useEffect(()=>{st(document.getElementById(It))},[l]),i.useEffect(()=>{const e=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>rt(e.matches);return s(),e.addEventListener("change",s),()=>e.removeEventListener("change",s)},[]),i.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]),i.useEffect(()=>{const e=++$e.current,s=[...ze.current.keys()];s.length!==0&&Promise.all(s.map(async o=>({path:o,children:await w(o)}))).then(o=>{if(e!==$e.current)return;const r=new Map(o.map(({path:c,children:a})=>[c,a]));pe(c=>Et(c,r))})},[g,w]),i.useEffect(()=>{if(!F){Q.current.clear(),pe(e=>e.size===0?e:new Map);return}W(e=>{const s=new Set(Ft(F,e,fe).retained);return Oe(e,s)?e:s})},[fe,F]),i.useEffect(()=>{if(!F)return;const e=Tt(F,N,fe),s=e.join("\0");s!==Ke.current&&(Ke.current=s,re(e))},[N,fe,F,re]),i.useEffect(()=>{if(!n||!f)return;let e=Math.max(0,2-Q.current.size);for(const s of N){if(e===0)break;const o=T(f,s);!o||o.type!=="directory"||o.ignored!==!0||o.children.length>0||I.has(s)||Q.current.has(s)||(Q.current.add(s),e-=1,w(s).catch(()=>[]).then(r=>{pe(c=>new Map(c).set(s,r))}).finally(()=>{Q.current.delete(s)}))}},[n,N,I,w,f]),i.useEffect(()=>{n||($(null),Z([]),z(null),ve(null),E.current&&clearTimeout(E.current),E.current=null,ee.current=null)},[n]),i.useEffect(()=>{f&&(R(e=>{if(e.size===0)return e;const s=new Set([...e].filter(o=>T(f,o)));return s.size===e.size?e:s}),X(e=>e&&T(f,e)?e:null),_(e=>e&&T(f,e)?e:l&&T(f,l)?l:null))},[l,f]);const y=i.useMemo(()=>f?nt(f,N):[],[N,f]),q=wt({enabled:n,count:y.length,getScrollElement:()=>ce.current,estimateSize:()=>S,getItemKey:e=>y[e]?.entry.path??e,overscan:12,paddingStart:xe,paddingEnd:12});i.useEffect(()=>{q.measure()},[q,S]),i.useEffect(()=>{!n||!l||!f||!T(f,l)||W(e=>{const s=new Set(e);let o=!1;const r=l.split("/");let c="";for(let a=0;a<r.length-1;a+=1)c=c?`${c}/${r[a]}`:r[a],s.has(c)||(s.add(c),o=!0);return o?s:e})},[n,l,f]),i.useEffect(()=>{if(!n)return;if(!l){V.current=null;return}if(V.current===l)return;const e=y.findIndex(s=>s.entry.path===l);e>=0&&(q.scrollToIndex(e,{align:"auto"}),V.current=l)},[n,l,y]);const Le=i.useMemo(()=>{const e=new Map;for(const s of y)e.set(s.entry.path,s);return e},[y]),te=i.useMemo(()=>{const e={headers:[],push:0};if(y.length===0||!l)return e;const s=new Set,o=l.split("/");let r="";for(let k=0;k<o.length-1;k+=1)r=r?`${r}/${o[k]}`:o[k],s.add(r);if(s.size===0)return e;const c=Math.min(y.length-1,Math.max(0,Math.floor((he-xe)/S))),a=y[c];if(!a)return e;const D=a.entry.path.split("/"),v=[];let se="";for(let k=0;k<D.length-1;k+=1){if(se=se?`${se}/${D[k]}`:D[k],!s.has(se))continue;const Ie=Le.get(se);Ie&&Ie.entry.type==="directory"&&v.push(Ie)}if(v.length>qe&&v.splice(0,v.length-qe),v.length===0)return e;const Dt=v[v.length-1],Be=v.length*S;let Ue=1/0;const kt=Math.ceil((he+Be-xe)/S)+2;for(let k=c;k<y.length&&k<=kt;k+=1)if(y[k].depth<=Dt.depth){Ue=xe+k*S;break}const Ct=Math.max(0,Math.min(S,Be-(Ue-he)));return{headers:v,push:Ct}},[y,Le,he,l,S]);if(f===null)return t.jsx("div",{className:"view-loading",role:"status",hidden:!n,children:t.jsx(Pt,{text:"Loading files…"})});const ct=P||m.size>0?m:l?new Set([l]):new Set,dt=m.size>0?[...m]:l?[l]:[],Se=e=>{const s=[];for(const o of e){const r=T(f,o);r&&s.push(r)}return s},Ne=e=>{R(new Set([e])),X(e),_(e)},ut=e=>{const s=y.findIndex(o=>o.entry.path===e.path);s>=0&&q.scrollToIndex(s,{align:"start"})},ht=(e,s)=>{if(G&&P){R(o=>{const r=new Set(o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r});return}if(s.shift&&(de||Y)){const o=En(y,de??Y,e.path);R(new Set(o)),_(e.path);return}if(s.ctrl){R(o=>{const r=new Set(o.size===0&&l?[l]:o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r}),X(e.path),_(e.path),e.type==="file"&&j(e.path,"pinned");return}Ne(e.path),e.type==="file"?j(e.path):Ae(e.path)},pt=e=>{!(G&&P)&&e.type==="file"&&j(e.path,"pinned")},ft=e=>{m.has(e.path)||Ne(e.path)},ge=e=>m.has(e.path)&&m.size>0?Se(m):[e],gt=e=>{if(Vt(e.target))return;const s=Xt(e.nativeEvent,we);if(s==="undo"&&L.canUndo&&!h){e.preventDefault(),e.repeat||A();return}if(s==="redo"&&L.canRedo&&!h){e.preventDefault(),e.repeat||U();return}const o=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(o&&r==="a"){e.preventDefault(),R(new Set(y.map(D=>D.entry.path)));return}const c=Se(dt),a=Y?T(f,Y):null;if(o&&r==="c"&&c.length){e.preventDefault(),ae(c);return}if(o&&r==="x"&&c.length&&!h){e.preventDefault(),ie(c);return}if(o&&r==="v"&&!h&&p){e.preventDefault();const D=a?me(a):We(c[0]?.path??"");O(D);return}if(e.key==="F2"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h){if(m.size===1){const D=T(f,[...m][0]);D&&(e.preventDefault(),$({mode:"rename",entry:D}))}return}e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h&&c.length&&(e.preventDefault(),le(c))},xt=async(e,s)=>{const o=Se(e);o.length&&await De(o,s)},Ae=(e,s=!1)=>{const o=!s&&N.has(e),r=o&&T(f??[],e)?.ignored===!0;W(c=>{const a=new Set(c);if(s||!a.has(e)){if(a.has(e))return c;a.add(e)}else if(r)for(const D of a)Ee(e,D)&&a.delete(D);else a.delete(e);return Oe(c,a)?c:a}),o&&pe(c=>{const a=[...c.keys()].filter(v=>Ee(e,v));if(a.length===0)return c;const D=new Map(c);for(const v of a)D.delete(v);return D})},ne=()=>{E.current&&clearTimeout(E.current),E.current=null,ee.current=null},He=()=>{ne(),Z([]),z(null),ve(null)},Re=e=>{const s=e.active.data.current;return s?.entry&&Array.isArray(s.sourcePaths)?{entry:s.entry,sourcePaths:s.sourcePaths}:null},mt=e=>{const s=Re(e);s&&(m.has(s.entry.path)||Ne(s.entry.path),Z(s.sourcePaths),ve({entry:s.entry,sourcePaths:s.sourcePaths,count:s.sourcePaths.length}))},jt=e=>{const s=Re(e);if(e.over?.data.current?.openPinned===!0){z(null),ne();return}const o=e.over?.data.current?.targetDirectory;if(!s||typeof o!="string"||!Ye(s.sourcePaths,o)){z(null),ne();return}z(o);const r=e.over?.data.current?.expandPath;if(typeof r!="string"||N.has(r)){ne();return}ee.current!==r&&(ne(),ee.current=r,E.current=setTimeout(()=>{Ae(r,!0),E.current=null,ee.current=null},Nn))},yt=e=>{const s=Re(e),o=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;if(He(),s&&o&&Xe(s.entry,s.sourcePaths)){j(s.entry.path,"pinned");return}s&&typeof r=="string"&&Ye(s.sourcePaths,r)&&xt(s.sourcePaths,r)};return t.jsxs(_t,{sensors:lt,collisionDetection:In,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:mt,onDragOver:jt,onDragCancel:He,onDragEnd:yt,children:[t.jsxs("div",{className:"files-mobile-tools",children:[t.jsxs(H,{variant:"ghost",size:"sm",onClick:C,children:[t.jsx(zt,{})," Find file"]}),t.jsx(H,{variant:"ghost",size:"sm","aria-pressed":P,onClick:()=>{Me(!P),R(new Set)},children:P?`Done (${m.size})`:"Select"}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-file",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(et,{})," New file"]}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-folder",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(Ze,{})," Folder"]}),p&&t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>{O("")},children:[t.jsx(Je,{})," Paste"]})]}),t.jsxs("div",{ref:ce,className:"files-view virtual-scroll",hidden:!n,onScroll:e=>it(e.currentTarget.scrollTop),children:[te.headers.length>0&&t.jsx("div",{className:"files-sticky",children:te.headers.map((e,s)=>{const o=s===te.headers.length-1;return t.jsxs("button",{type:"button",className:"file-tree-row files-sticky-row","aria-label":`Scroll to ${e.entry.path}`,style:{top:s*S-(o?te.push:0),paddingLeft:12+e.depth*14,zIndex:te.headers.length-s},onClick:()=>ut(e.entry),children:[t.jsx(Ge,{className:"folder-chevron open"}),t.jsx(Pe,{path:e.entry.path,type:"directory",expanded:!0}),t.jsx("span",{children:e.entry.name})]},e.entry.path)})}),f.length?t.jsx(Fn,{role:"tree","aria-label":"Files",className:`files-tree ${M===""&&ue.length>0?"root-drop-target":""}`,style:{height:q.getTotalSize()},tabIndex:0,onKeyDown:gt,onPointerDown:e=>{e.target.closest(".file-tree-row, .file-touch-actions")||(R(new Set),X(null),_(null),e.currentTarget.focus())},children:q.getVirtualItems().map(e=>{const{entry:s,depth:o}=y[e.index],r=s.type==="directory"&&N.has(s.path),c=m.has(s.path)&&m.size>1;return t.jsx("div",{className:"virtual-row",style:{height:e.size,transform:`translateY(${e.start}px)`},children:t.jsx(_n,{entry:s,depth:o,expanded:r,pendingChildren:s.type==="directory"&&s.ignored===!0&&s.children.length===0&&!I.has(s.path),selected:ct.has(s.path),active:l===s.path,multiSelected:c,readOnly:h,fileClipboardAvailable:p,revealAvailable:B,historyState:L,onUndo:A,onRedo:U,draggedPaths:ue,dropTargetPath:M,onFocus:_,onRowClick:ht,onRowDoubleClick:pt,onRowContextMenu:ft,onOpen:a=>j(a.path),onOpenPinned:a=>j(a.path,"pinned"),onCopy:a=>{ae(ge(a))},onCut:a=>{ie(ge(a))},onPasteInto:a=>{O(me(a))},onCopyPath:a=>{je(ge(a))},onCopyContents:ye,onRename:a=>$({mode:"rename",entry:a}),onNewFile:a=>$({mode:"new-file",entry:a}),onNewFolder:a=>$({mode:"new-folder",entry:a}),onReveal:ke,onDelete:a=>{le(ge(a))},dragPaths:m.has(s.path)&&m.size>0?[...m]:[s.path]})},e.key)})}):t.jsx("p",{className:"empty-list",children:"No files."}),t.jsx(zn,{state:at,onClose:()=>$(null),onRename:Ce,onCreate:be})]}),t.jsx($t,{dropAnimation:ot?null:Rn,children:J&&t.jsx(Pn,{preview:J})}),_e&&bt.createPortal(t.jsx(Tn,{visible:!!(J&&Xe(J.entry,J.sourcePaths))}),_e)]})}function Fn(n){const{setNodeRef:d}=Fe({id:tt,data:{targetDirectory:"",expandPath:null}});return t.jsx("div",{ref:d,...n})}function Tn({visible:n}){const{isOver:d,setNodeRef:u}=Fe({id:"files-open-pinned-drop",data:{openPinned:!0}});return t.jsxs("div",{ref:u,className:`open-files-drop-target ${n?"visible":""} ${n&&d?"over":""}`,"aria-hidden":"true",children:[t.jsx(Qe,{}),t.jsx("span",{children:"Drop to open beside"})]})}function Pn({preview:n}){return t.jsxs("div",{className:"file-drag-overlay",children:[t.jsx(Pe,{path:n.entry.path,type:n.entry.type,expanded:!1}),t.jsx("span",{children:n.entry.name}),n.count>1&&t.jsx("strong",{children:n.count})]})}function Oe(n,d){if(n.size!==d.size)return!1;for(const u of n)if(!d.has(u))return!1;return!0}function _n({entry:n,depth:d,expanded:u,pendingChildren:g,selected:x,active:l,multiSelected:h,readOnly:p,fileClipboardAvailable:B,revealAvailable:L,historyState:C,onUndo:A,onRedo:U,draggedPaths:j,dropTargetPath:w,onFocus:re,onRowClick:je,onRowDoubleClick:ae,onRowContextMenu:ie,onOpen:ye,onOpenPinned:O,onCopy:De,onCut:le,onPasteInto:ke,onCopyPath:Ce,onCopyContents:be,onRename:we,onNewFile:G,onNewFolder:P,onReveal:Me,onDelete:S,dragPaths:ce}){const V=i.useRef(null),m=me(n),{attributes:R,listeners:de,setNodeRef:X,isDragging:Y}=Yt({id:`file-drag:${n.path}`,data:{sourcePaths:ce,entry:n},disabled:p}),{setNodeRef:_}=Fe({id:`file-drop:${n.path}`,data:{targetDirectory:m,expandPath:n.type==="directory"?n.path:null}}),N=M=>{V.current=M,X(M),_(M)},W=j.length>0&&n.type==="directory"&&w===n.path,ue=j.length>0&&w!==null&&w!==""&&w!==n.path&&Ee(w,n.path),Z=t.jsxs("button",{type:"button",ref:N,...R,role:"treeitem","aria-selected":x,"aria-current":l?"true":void 0,"aria-expanded":n.type==="directory"?u:void 0,className:["file-tree-row",n.ignored?"ignored-file":"",j.includes(n.path)||Y?"dragging":"",W?"drop-target":"",ue?"drop-target-region":""].filter(Boolean).join(" "),style:{paddingLeft:12+d*14},...de,onClick:M=>je(n,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),onDoubleClick:()=>ae(n),onFocus:()=>re(n.path),onContextMenu:()=>ie(n),children:[n.type==="directory"?t.jsx(Ge,{className:`folder-chevron ${u?"open":""} ${n.children.length===0&&!g?"empty":""}`}):t.jsx("span",{className:"tree-spacer"}),t.jsx(Pe,{path:n.path,type:n.type,expanded:u}),t.jsx("span",{children:n.name})]});return t.jsxs(wn,{children:[t.jsx(Mn,{render:Z}),t.jsx("button",{type:"button",className:"file-touch-actions","aria-label":`Actions for ${n.name}`,"aria-haspopup":"menu",onClick:M=>{M.stopPropagation();const z=M.currentTarget.getBoundingClientRect();V.current?.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:z.left,clientY:z.bottom}))},children:t.jsx(Dn,{})}),t.jsxs(vn,{children:[n.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs(b,{onClick:()=>ye(n),children:[t.jsx(qt,{"aria-hidden":"true"})," Open"]}),t.jsxs(b,{onClick:()=>O(n),children:[t.jsx(Qe,{"aria-hidden":"true"})," Open to the Side ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Click"})]}),t.jsx(oe,{})]}),t.jsxs(b,{disabled:p||!C.canUndo,onClick:()=>{A()},children:[t.jsx(hn,{"aria-hidden":"true"})," ",C.undoLabel?`Undo ${C.undoLabel}`:"Undo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Z"})]}),t.jsxs(b,{disabled:p||!C.canRedo,onClick:()=>{U()},children:[t.jsx(fn,{"aria-hidden":"true"})," ",C.redoLabel?`Redo ${C.redoLabel}`:"Redo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Shift+Z"})]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>De(n),children:[t.jsx(Ot,{"aria-hidden":"true"})," Copy ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+C"})]}),t.jsxs(b,{disabled:p,onClick:()=>le(n),children:[t.jsx(jn,{"aria-hidden":"true"})," Cut ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+X"})]}),B&&t.jsxs(b,{disabled:p,onClick:()=>ke(n),children:[t.jsx(Je,{"aria-hidden":"true"})," Paste ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+V"})]}),t.jsx(oe,{}),t.jsxs(b,{disabled:p||h,onClick:()=>we(n),children:[t.jsx(dn,{"aria-hidden":"true"})," Rename ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"F2"})]}),t.jsxs(b,{disabled:p||h,onClick:()=>G(n),children:[t.jsx(et,{"aria-hidden":"true"})," New File…"]}),t.jsxs(b,{disabled:p||h,onClick:()=>P(n),children:[t.jsx(Ze,{"aria-hidden":"true"})," New Folder…"]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>Ce(n),children:[t.jsx(bn,{"aria-hidden":"true"})," Copy path"]}),t.jsxs(b,{disabled:n.type!=="file"||h,onClick:()=>{be(n)},children:[t.jsx(tn,{"aria-hidden":"true"})," Copy contents"]}),L&&t.jsxs(b,{disabled:h,onClick:()=>{Me(n)},children:[t.jsx(Gt,{"aria-hidden":"true"})," Reveal in File Explorer"]}),t.jsx(oe,{}),t.jsxs(b,{className:"text-destructive data-highlighted:text-destructive",disabled:p,onClick:()=>S(n),children:[t.jsx(Wt,{"aria-hidden":"true"})," Delete ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Del"})]})]})]})}function zn({state:n,onClose:d,onRename:u,onCreate:g}){const[x,l]=i.useState("");if(i.useEffect(()=>{n&&l(n.mode==="rename"?n.entry.name:"")},[n]),!n)return null;const h=n.mode==="rename",p=n.mode==="new-folder"?"directory":"file",B=me(n.entry),L=h?"Rename":p==="directory"?"New Folder":"New File",C=x.trim(),A=C.length>0&&!/[\\/]/.test(C)&&!(h&&C===n.entry.name),U=()=>{A&&(h?u(n.entry,C):g(B,C,p),d())};return t.jsx(Zt,{open:!0,onOpenChange:j=>{j||d()},children:t.jsx(Jt,{className:"name-dialog",children:t.jsxs("form",{className:"name-dialog-content",onSubmit:j=>{j.preventDefault(),U()},children:[t.jsx(Qt,{children:L}),t.jsx(en,{children:h?t.jsxs(t.Fragment,{children:["Enter a new name for ",t.jsx("code",{children:n.entry.name}),"."]}):t.jsxs(t.Fragment,{children:["Create a new ",p==="directory"?"folder":"file"," in ",t.jsx("code",{children:B||"the repository root"}),"."]})}),t.jsx("input",{autoFocus:!0,className:"name-dialog-input",value:x,maxLength:255,placeholder:h?"New name":p==="directory"?"Folder name":"File name",onChange:j=>l(j.target.value),onFocus:j=>{if(!h)return;const w=n.entry.name.lastIndexOf(".");j.target.setSelectionRange(0,w>0?w:n.entry.name.length)}}),t.jsxs("div",{className:"name-dialog-actions",children:[t.jsx(H,{type:"button",variant:"ghost",onClick:d,children:"Cancel"}),t.jsx(H,{type:"submit",disabled:!A,children:h?"Rename":"Create"})]})]})})})}function Pe({path:n,type:d,expanded:u=!1}){const g=d==="file"?Bt(n):Ut(n,u);return t.jsx("img",{className:"vscode-tree-icon",src:g,alt:"","aria-hidden":"true"})}export{Vn as FilesView};
|
|
1
|
+
import{j as t,r as i,a as bt}from"./react-rd22PHbN.js";import{a as wt}from"./tanstack-CtfgE41X.js";import{a5 as Mt,a7 as vt,a9 as St,aa as Ue,ab as Nt,_ as Rt,ac as It,ad as Et,ae as Ft,af as Tt,ag as T,G as Pt,ah as _t,j as zt,V as Oe,ai as $t,aj as Ye,ak as qe,al as Kt,am as Lt,an as At,ao as Ht,Y as Vt,ap as Bt,aq as Fe,ar as Ut,as as Yt,$ as We,at as qt,au as Ee,av as Xt,aw as Gt,t as Ot,y as Wt,D as Zt,c as Jt,d as Qt,e as en}from"./App-9EfSdZB8.js";import{c as K,d as Te,B as H,I as tn}from"./index-CQcx9aRt.js";import{m as nn,n as sn,M as on,o as rn,p as an,q as ln,S as cn}from"./base-ui-DT3JsyND.js";import{I as Ze}from"./IconFolderPlus-ByGyA0Di.js";import{I as dn}from"./IconEdit-DePJMGIi.js";const un=[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]],hn=K("outline","arrow-back-up","ArrowBackUp",un);const pn=[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]],fn=K("outline","arrow-forward-up","ArrowForwardUp",pn);const gn=[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",key:"svg-1"}]],Je=K("outline","clipboard","Clipboard",gn);const xn=[["path",{d:"M3 4a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-16",key:"svg-0"}],["path",{d:"M12 3v18",key:"svg-1"}]],Qe=K("outline","columns-2","Columns2",xn);const mn=[["path",{d:"M4 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-0"}],["path",{d:"M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M9.15 14.85l8.85 -10.85",key:"svg-2"}],["path",{d:"M6 4l8.85 10.85",key:"svg-3"}]],jn=K("outline","cut","Cut",mn);const yn=[["path",{d:"M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],Dn=K("outline","dots","Dots",yn);const kn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M12 11l0 6",key:"svg-2"}],["path",{d:"M9 14l6 0",key:"svg-3"}]],et=K("outline","file-plus","FilePlus",kn);const Cn=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],bn=K("outline","file-text","FileText",Cn),wn=nn,Mn=sn;function vn({className:n,children:d,...u}){return t.jsx(on,{children:t.jsx(rn,{className:"isolate z-50 outline-none",children:t.jsx(an,{"data-slot":"context-menu-content",className:Te("min-w-44 origin-(--transform-origin) rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",n),...u,children:d})})})}function b({className:n,...d}){return t.jsx(ln,{"data-slot":"context-menu-item",className:Te("flex h-8 cursor-default items-center gap-2 rounded-md px-2 text-xs outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",n),...d})}function oe({className:n,...d}){return t.jsx(cn,{"data-slot":"context-menu-separator",className:Te("mx-1 my-1 h-px bg-border",n),...d})}const Sn=29,xe=6,tt="files-tree-root-drop",Nn=550,Rn={duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},Xe=6,In=n=>{const d=Kt(n),u=d.length>0?d:Lt(n),g=u.find(x=>x.id!==tt);return g?[g]:u.slice(0,1)};function nt(n,d,u=0){const g=[];for(const x of n)g.push({entry:x,depth:u}),x.type==="directory"&&d.has(x.path)&&g.push(...nt(x.children,d,u+1));return g}function En(n,d,u){const g=n.findIndex(p=>p.entry.path===d),x=n.findIndex(p=>p.entry.path===u);if(g===-1||x===-1)return[u];const[l,h]=g<=x?[g,x]:[x,g];return n.slice(l,h+1).map(p=>p.entry.path)}function me(n){return n.type==="directory"?n.path:We(n.path)}function Un({active:n,initialExpandedPaths:d,files:u,filesSnapshotRevision:g,showDotEnvFiles:x,activePath:l,readOnly:h,fileClipboardAvailable:p,revealAvailable:V,historyState:L,onQuickOpen:C,onUndo:A,onRedo:B,onOpenFile:j,onLoadDirectory:w,onPersistExpandedPaths:re,onCopyPath:je,onCopyEntries:ae,onCutEntries:ie,onCopyContents:ye,onPaste:G,onMoveEntries:De,onDeleteEntries:le,onReveal:ke,onRename:Ce,onCreate:be}){const we=Mt(),O=vt(),[P,Me]=i.useState(!1),S=O?44:Sn,ce=i.useRef(null),U=i.useRef(null),[m,R]=i.useState(new Set),[de,Y]=i.useState(l),[q,_]=i.useState(l),[N,W]=i.useState(()=>new Set(d)),[ue,Z]=i.useState([]),[M,z]=i.useState(null),[J,ve]=i.useState(null),[_e,st]=i.useState(null),[ot,rt]=i.useState(!1),[at,$]=i.useState(null),[he,it]=i.useState(0),[I,pe]=i.useState(new Map),lt=St(Ue(Ht,{activationConstraint:{distance:5}}),Ue(At)),ze=i.useRef(I),Q=i.useRef(new Set),$e=i.useRef(0),E=i.useRef(null),ee=i.useRef(null),Ke=i.useRef(d.join("\0")),fe=i.useMemo(()=>new Set(I.keys()),[I]),F=i.useMemo(()=>u===null?null:Nt(u,I),[u,I]),f=i.useMemo(()=>F===null?null:x?F:Rt(F),[F,x]);i.useEffect(()=>{ze.current=I},[I]),i.useEffect(()=>{st(document.getElementById(It))},[l]),i.useEffect(()=>{const e=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>rt(e.matches);return s(),e.addEventListener("change",s),()=>e.removeEventListener("change",s)},[]),i.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]),i.useEffect(()=>{const e=++$e.current,s=[...ze.current.keys()];s.length!==0&&Promise.all(s.map(async o=>({path:o,children:await w(o)}))).then(o=>{if(e!==$e.current)return;const r=new Map(o.map(({path:c,children:a})=>[c,a]));pe(c=>Et(c,r))})},[g,w]),i.useEffect(()=>{if(!F){Q.current.clear(),pe(e=>e.size===0?e:new Map);return}W(e=>{const s=new Set(Ft(F,e,fe).retained);return Ge(e,s)?e:s})},[fe,F]),i.useEffect(()=>{if(!F)return;const e=Tt(F,N,fe),s=e.join("\0");s!==Ke.current&&(Ke.current=s,re(e))},[N,fe,F,re]),i.useEffect(()=>{if(!n||!f)return;let e=Math.max(0,2-Q.current.size);for(const s of N){if(e===0)break;const o=T(f,s);!o||o.type!=="directory"||o.ignored!==!0||o.children.length>0||I.has(s)||Q.current.has(s)||(Q.current.add(s),e-=1,w(s).catch(()=>[]).then(r=>{pe(c=>new Map(c).set(s,r))}).finally(()=>{Q.current.delete(s)}))}},[n,N,I,w,f]),i.useEffect(()=>{n||($(null),Z([]),z(null),ve(null),E.current&&clearTimeout(E.current),E.current=null,ee.current=null)},[n]),i.useEffect(()=>{f&&(R(e=>{if(e.size===0)return e;const s=new Set([...e].filter(o=>T(f,o)));return s.size===e.size?e:s}),Y(e=>e&&T(f,e)?e:null),_(e=>e&&T(f,e)?e:l&&T(f,l)?l:null))},[l,f]);const y=i.useMemo(()=>f?nt(f,N):[],[N,f]),X=wt({enabled:n,count:y.length,getScrollElement:()=>ce.current,estimateSize:()=>S,getItemKey:e=>y[e]?.entry.path??e,overscan:12,paddingStart:xe,paddingEnd:12});i.useEffect(()=>{X.measure()},[X,S]),i.useEffect(()=>{!n||!l||!f||!T(f,l)||W(e=>{const s=new Set(e);let o=!1;const r=l.split("/");let c="";for(let a=0;a<r.length-1;a+=1)c=c?`${c}/${r[a]}`:r[a],s.has(c)||(s.add(c),o=!0);return o?s:e})},[n,l,f]),i.useEffect(()=>{if(!n)return;if(!l){U.current=null;return}if(U.current===l)return;const e=y.findIndex(s=>s.entry.path===l);e>=0&&(X.scrollToIndex(e,{align:"auto"}),U.current=l)},[n,l,y]);const Le=i.useMemo(()=>{const e=new Map;for(const s of y)e.set(s.entry.path,s);return e},[y]),te=i.useMemo(()=>{const e={headers:[],push:0};if(y.length===0||!l)return e;const s=new Set,o=l.split("/");let r="";for(let k=0;k<o.length-1;k+=1)r=r?`${r}/${o[k]}`:o[k],s.add(r);if(s.size===0)return e;const c=Math.min(y.length-1,Math.max(0,Math.floor((he-xe)/S))),a=y[c];if(!a)return e;const D=a.entry.path.split("/"),v=[];let se="";for(let k=0;k<D.length-1;k+=1){if(se=se?`${se}/${D[k]}`:D[k],!s.has(se))continue;const Ie=Le.get(se);Ie&&Ie.entry.type==="directory"&&v.push(Ie)}if(v.length>Xe&&v.splice(0,v.length-Xe),v.length===0)return e;const Dt=v[v.length-1],Ve=v.length*S;let Be=1/0;const kt=Math.ceil((he+Ve-xe)/S)+2;for(let k=c;k<y.length&&k<=kt;k+=1)if(y[k].depth<=Dt.depth){Be=xe+k*S;break}const Ct=Math.max(0,Math.min(S,Ve-(Be-he)));return{headers:v,push:Ct}},[y,Le,he,l,S]);if(f===null)return t.jsx("div",{className:"view-loading",role:"status",hidden:!n,children:t.jsx(Pt,{text:"Loading files…"})});const ct=P||m.size>0?m:l?new Set([l]):new Set,dt=m.size>0?[...m]:l?[l]:[],Se=e=>{const s=[];for(const o of e){const r=T(f,o);r&&s.push(r)}return s},Ne=e=>{R(new Set([e])),Y(e),_(e)},ut=e=>{const s=y.findIndex(o=>o.entry.path===e.path);s>=0&&X.scrollToIndex(s,{align:"start"})},ht=(e,s)=>{if(O&&P){R(o=>{const r=new Set(o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r});return}if(s.shift&&(de||q)){const o=En(y,de??q,e.path);R(new Set(o)),_(e.path);return}if(s.ctrl){R(o=>{const r=new Set(o.size===0&&l?[l]:o);return r.has(e.path)?r.delete(e.path):r.add(e.path),r}),Y(e.path),_(e.path),e.type==="file"&&j(e.path,"pinned");return}Ne(e.path),e.type==="file"?j(e.path):Ae(e.path)},pt=e=>{!(O&&P)&&e.type==="file"&&j(e.path,"pinned")},ft=e=>{m.has(e.path)||Ne(e.path)},ge=e=>m.has(e.path)&&m.size>0?Se(m):[e],gt=e=>{if(Ut(e.target))return;const s=Yt(e.nativeEvent,we);if(s==="undo"&&L.canUndo&&!h){e.preventDefault(),e.repeat||A();return}if(s==="redo"&&L.canRedo&&!h){e.preventDefault(),e.repeat||B();return}const o=(e.ctrlKey||e.metaKey)&&!e.altKey,r=e.key.toLowerCase();if(o&&r==="a"){e.preventDefault(),R(new Set(y.map(D=>D.entry.path)));return}const c=Se(dt),a=q?T(f,q):null;if(o&&r==="c"&&c.length){e.preventDefault(),ae(c);return}if(o&&r==="x"&&c.length&&!h){e.preventDefault(),ie(c);return}if(o&&r==="v"&&!h&&p){e.preventDefault();const D=a?me(a):We(c[0]?.path??"");G(D);return}if(e.key==="F2"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h){if(m.size===1){const D=T(f,[...m][0]);D&&(e.preventDefault(),$({mode:"rename",entry:D}))}return}e.key==="Delete"&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&!h&&c.length&&(e.preventDefault(),le(c))},xt=async(e,s)=>{const o=Se(e);o.length&&await De(o,s)},Ae=(e,s=!1)=>{const o=!s&&N.has(e),r=o&&T(f??[],e)?.ignored===!0;W(c=>{const a=new Set(c);if(s||!a.has(e)){if(a.has(e))return c;a.add(e)}else if(r)for(const D of a)Ee(e,D)&&a.delete(D);else a.delete(e);return Ge(c,a)?c:a}),o&&pe(c=>{const a=[...c.keys()].filter(v=>Ee(e,v));if(a.length===0)return c;const D=new Map(c);for(const v of a)D.delete(v);return D})},ne=()=>{E.current&&clearTimeout(E.current),E.current=null,ee.current=null},He=()=>{ne(),Z([]),z(null),ve(null)},Re=e=>{const s=e.active.data.current;return s?.entry&&Array.isArray(s.sourcePaths)?{entry:s.entry,sourcePaths:s.sourcePaths}:null},mt=e=>{const s=Re(e);s&&(m.has(s.entry.path)||Ne(s.entry.path),Z(s.sourcePaths),ve({entry:s.entry,sourcePaths:s.sourcePaths,count:s.sourcePaths.length}))},jt=e=>{const s=Re(e);if(e.over?.data.current?.openPinned===!0){z(null),ne();return}const o=e.over?.data.current?.targetDirectory;if(!s||typeof o!="string"||!qe(s.sourcePaths,o)){z(null),ne();return}z(o);const r=e.over?.data.current?.expandPath;if(typeof r!="string"||N.has(r)){ne();return}ee.current!==r&&(ne(),ee.current=r,E.current=setTimeout(()=>{Ae(r,!0),E.current=null,ee.current=null},Nn))},yt=e=>{const s=Re(e),o=e.over?.data.current?.openPinned===!0,r=e.over?.data.current?.targetDirectory;if(He(),s&&o&&Ye(s.entry,s.sourcePaths)){j(s.entry.path,"pinned");return}s&&typeof r=="string"&&qe(s.sourcePaths,r)&&xt(s.sourcePaths,r)};return t.jsxs(_t,{sensors:lt,collisionDetection:In,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:mt,onDragOver:jt,onDragCancel:He,onDragEnd:yt,children:[t.jsxs("div",{className:"files-mobile-tools",children:[t.jsxs(H,{variant:"ghost",size:"sm",onClick:C,children:[t.jsx(zt,{})," Find file"]}),t.jsx(H,{variant:"ghost",size:"sm","aria-pressed":P,onClick:()=>{Me(!P),R(new Set)},children:P?`Done (${m.size})`:"Select"}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-file",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(et,{})," New file"]}),t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>$({mode:"new-folder",entry:{type:"directory",path:"",name:"",children:[]}}),children:[t.jsx(Ze,{})," Folder"]}),p&&t.jsxs(H,{variant:"ghost",size:"sm",disabled:h,onClick:()=>{G("")},children:[t.jsx(Je,{})," Paste"]})]}),t.jsxs("div",{ref:ce,className:"files-view virtual-scroll",hidden:!n,onScroll:e=>it(e.currentTarget.scrollTop),children:[te.headers.length>0&&t.jsx("div",{className:"files-sticky",children:te.headers.map((e,s)=>{const o=s===te.headers.length-1;return t.jsxs("button",{type:"button",className:"file-tree-row files-sticky-row","aria-label":`Scroll to ${e.entry.path}`,style:{top:s*S-(o?te.push:0),paddingLeft:12+e.depth*14,zIndex:te.headers.length-s},onClick:()=>ut(e.entry),children:[t.jsx(Oe,{className:"folder-chevron open"}),t.jsx(Pe,{path:e.entry.path,type:"directory",expanded:!0}),t.jsx("span",{children:e.entry.name})]},e.entry.path)})}),f.length?t.jsx(Fn,{role:"tree","aria-label":"Files",className:`files-tree ${M===""&&ue.length>0?"root-drop-target":""}`,style:{height:X.getTotalSize()},tabIndex:0,onKeyDown:gt,onPointerDown:e=>{e.target.closest(".file-tree-row, .file-touch-actions")||(R(new Set),Y(null),_(null),e.currentTarget.focus())},children:X.getVirtualItems().map(e=>{const{entry:s,depth:o}=y[e.index],r=s.type==="directory"&&N.has(s.path),c=m.has(s.path)&&m.size>1;return t.jsx("div",{className:"virtual-row",style:{height:e.size,transform:`translateY(${e.start}px)`},children:t.jsx(_n,{entry:s,depth:o,expanded:r,pendingChildren:s.type==="directory"&&s.ignored===!0&&s.children.length===0&&!I.has(s.path),selected:ct.has(s.path),active:l===s.path,multiSelected:c,readOnly:h,fileClipboardAvailable:p,revealAvailable:V,historyState:L,onUndo:A,onRedo:B,draggedPaths:ue,dropTargetPath:M,onFocus:_,onRowClick:ht,onRowDoubleClick:pt,onRowContextMenu:ft,onOpen:a=>j(a.path),onOpenPinned:a=>j(a.path,"pinned"),onCopy:a=>{ae(ge(a))},onCut:a=>{ie(ge(a))},onPasteInto:a=>{G(me(a))},onCopyPath:a=>{je(ge(a))},onCopyContents:ye,onRename:a=>$({mode:"rename",entry:a}),onNewFile:a=>$({mode:"new-file",entry:a}),onNewFolder:a=>$({mode:"new-folder",entry:a}),onReveal:ke,onDelete:a=>{le(ge(a))},dragPaths:m.has(s.path)&&m.size>0?[...m]:[s.path]})},e.key)})}):t.jsx("p",{className:"empty-list",children:"No files."}),t.jsx(zn,{state:at,onClose:()=>$(null),onRename:Ce,onCreate:be})]}),t.jsx($t,{dropAnimation:ot?null:Rn,children:J&&t.jsx(Pn,{preview:J})}),_e&&bt.createPortal(t.jsx(Tn,{visible:!!(J&&Ye(J.entry,J.sourcePaths))}),_e)]})}function Fn(n){const{setNodeRef:d}=Fe({id:tt,data:{targetDirectory:"",expandPath:null}});return t.jsx("div",{ref:d,...n})}function Tn({visible:n}){const{isOver:d,setNodeRef:u}=Fe({id:"files-open-pinned-drop",data:{openPinned:!0}});return t.jsxs("div",{ref:u,className:`open-files-drop-target ${n?"visible":""} ${n&&d?"over":""}`,"aria-hidden":"true",children:[t.jsx(Qe,{}),t.jsx("span",{children:"Drop to open beside"})]})}function Pn({preview:n}){return t.jsxs("div",{className:"file-drag-overlay",children:[t.jsx(Pe,{path:n.entry.path,type:n.entry.type,expanded:!1}),t.jsx("span",{children:n.entry.name}),n.count>1&&t.jsx("strong",{children:n.count})]})}function Ge(n,d){if(n.size!==d.size)return!1;for(const u of n)if(!d.has(u))return!1;return!0}function _n({entry:n,depth:d,expanded:u,pendingChildren:g,selected:x,active:l,multiSelected:h,readOnly:p,fileClipboardAvailable:V,revealAvailable:L,historyState:C,onUndo:A,onRedo:B,draggedPaths:j,dropTargetPath:w,onFocus:re,onRowClick:je,onRowDoubleClick:ae,onRowContextMenu:ie,onOpen:ye,onOpenPinned:G,onCopy:De,onCut:le,onPasteInto:ke,onCopyPath:Ce,onCopyContents:be,onRename:we,onNewFile:O,onNewFolder:P,onReveal:Me,onDelete:S,dragPaths:ce}){const U=i.useRef(null),m=me(n),{attributes:R,listeners:de,setNodeRef:Y,isDragging:q}=qt({id:`file-drag:${n.path}`,data:{sourcePaths:ce,entry:n},disabled:p}),{setNodeRef:_}=Fe({id:`file-drop:${n.path}`,data:{targetDirectory:m,expandPath:n.type==="directory"?n.path:null}}),N=M=>{U.current=M,Y(M),_(M)},W=j.length>0&&n.type==="directory"&&w===n.path,ue=j.length>0&&w!==null&&w!==""&&w!==n.path&&Ee(w,n.path),Z=t.jsxs("button",{type:"button",ref:N,...R,role:"treeitem","aria-selected":x,"aria-current":l?"true":void 0,"aria-expanded":n.type==="directory"?u:void 0,className:["file-tree-row",n.ignored?"ignored-file":"",j.includes(n.path)||q?"dragging":"",W?"drop-target":"",ue?"drop-target-region":""].filter(Boolean).join(" "),style:{paddingLeft:12+d*14},...de,onClick:M=>je(n,{ctrl:M.ctrlKey||M.metaKey,shift:M.shiftKey}),onDoubleClick:()=>ae(n),onFocus:()=>re(n.path),onContextMenu:()=>ie(n),children:[n.type==="directory"?t.jsx(Oe,{className:`folder-chevron ${u?"open":""} ${n.children.length===0&&!g?"empty":""}`}):t.jsx("span",{className:"tree-spacer"}),t.jsx(Pe,{path:n.path,type:n.type,expanded:u}),t.jsx("span",{children:n.name})]});return t.jsxs(wn,{children:[t.jsx(Mn,{render:Z}),t.jsx("button",{type:"button",className:"file-touch-actions","aria-label":`Actions for ${n.name}`,"aria-haspopup":"menu",onClick:M=>{M.stopPropagation();const z=M.currentTarget.getBoundingClientRect();U.current?.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:z.left,clientY:z.bottom}))},children:t.jsx(Dn,{})}),t.jsxs(vn,{children:[n.type==="file"&&t.jsxs(t.Fragment,{children:[t.jsxs(b,{onClick:()=>ye(n),children:[t.jsx(Xt,{"aria-hidden":"true"})," Open"]}),t.jsxs(b,{onClick:()=>G(n),children:[t.jsx(Qe,{"aria-hidden":"true"})," Open to the Side ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Click"})]}),t.jsx(oe,{})]}),t.jsxs(b,{disabled:p||!C.canUndo,onClick:()=>{A()},children:[t.jsx(hn,{"aria-hidden":"true"})," ",C.undoLabel?`Undo ${C.undoLabel}`:"Undo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Z"})]}),t.jsxs(b,{disabled:p||!C.canRedo,onClick:()=>{B()},children:[t.jsx(fn,{"aria-hidden":"true"})," ",C.redoLabel?`Redo ${C.redoLabel}`:"Redo"," ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Shift+Z"})]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>De(n),children:[t.jsx(Gt,{"aria-hidden":"true"})," Copy ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+C"})]}),t.jsxs(b,{disabled:p,onClick:()=>le(n),children:[t.jsx(jn,{"aria-hidden":"true"})," Cut ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+X"})]}),V&&t.jsxs(b,{disabled:p,onClick:()=>ke(n),children:[t.jsx(Je,{"aria-hidden":"true"})," Paste ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+V"})]}),t.jsx(oe,{}),t.jsxs(b,{disabled:p||h,onClick:()=>we(n),children:[t.jsx(dn,{"aria-hidden":"true"})," Rename ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"F2"})]}),t.jsxs(b,{disabled:p||h,onClick:()=>O(n),children:[t.jsx(et,{"aria-hidden":"true"})," New File…"]}),t.jsxs(b,{disabled:p||h,onClick:()=>P(n),children:[t.jsx(Ze,{"aria-hidden":"true"})," New Folder…"]}),t.jsx(oe,{}),t.jsxs(b,{onClick:()=>Ce(n),children:[t.jsx(bn,{"aria-hidden":"true"})," Copy path"]}),t.jsxs(b,{disabled:n.type!=="file"||h,onClick:()=>{be(n)},children:[t.jsx(tn,{"aria-hidden":"true"})," Copy contents"]}),L&&t.jsxs(b,{disabled:h,onClick:()=>{Me(n)},children:[t.jsx(Ot,{"aria-hidden":"true"})," Reveal in File Explorer"]}),t.jsx(oe,{}),t.jsxs(b,{className:"text-destructive data-highlighted:text-destructive",disabled:p,onClick:()=>S(n),children:[t.jsx(Wt,{"aria-hidden":"true"})," Delete ",t.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Del"})]})]})]})}function zn({state:n,onClose:d,onRename:u,onCreate:g}){const[x,l]=i.useState("");if(i.useEffect(()=>{n&&l(n.mode==="rename"?n.entry.name:"")},[n]),!n)return null;const h=n.mode==="rename",p=n.mode==="new-folder"?"directory":"file",V=me(n.entry),L=h?"Rename":p==="directory"?"New Folder":"New File",C=x.trim(),A=C.length>0&&!/[\\/]/.test(C)&&!(h&&C===n.entry.name),B=()=>{A&&(h?u(n.entry,C):g(V,C,p),d())};return t.jsx(Zt,{open:!0,onOpenChange:j=>{j||d()},children:t.jsx(Jt,{className:"name-dialog",children:t.jsxs("form",{className:"name-dialog-content",onSubmit:j=>{j.preventDefault(),B()},children:[t.jsx(Qt,{children:L}),t.jsx(en,{children:h?t.jsxs(t.Fragment,{children:["Enter a new name for ",t.jsx("code",{children:n.entry.name}),"."]}):t.jsxs(t.Fragment,{children:["Create a new ",p==="directory"?"folder":"file"," in ",t.jsx("code",{children:V||"the repository root"}),"."]})}),t.jsx("input",{autoFocus:!0,className:"name-dialog-input",value:x,maxLength:255,placeholder:h?"New name":p==="directory"?"Folder name":"File name",onChange:j=>l(j.target.value),onFocus:j=>{if(!h)return;const w=n.entry.name.lastIndexOf(".");j.target.setSelectionRange(0,w>0?w:n.entry.name.length)}}),t.jsxs("div",{className:"name-dialog-actions",children:[t.jsx(H,{type:"button",variant:"ghost",onClick:d,children:"Cancel"}),t.jsx(H,{type:"submit",disabled:!A,children:h?"Rename":"Create"})]})]})})})}function Pe({path:n,type:d,expanded:u=!1}){const g=d==="file"?Vt(n):Bt(n,u);return t.jsx("img",{className:"vscode-tree-icon",src:g,alt:"","aria-hidden":"true"})}export{Un as FilesView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as r,T as g,a as x,b as v,B as j,o as M,q as C}from"./index-CQcx9aRt.js";import{r as m,j as e}from"./react-rd22PHbN.js";import{u as N}from"./tanstack-CtfgE41X.js";import{M as y,x as b}from"./App-9EfSdZB8.js";import{P,f as R,g as S,h as _,i as E}from"./base-ui-DT3JsyND.js";const I=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]],X=r("outline","circle-check","CircleCheck",I);const $=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 10l4 4m0 -4l-4 4",key:"svg-1"}]],A=r("outline","circle-x","CircleX",$);const q=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 7v5l3 3",key:"svg-1"}]],H=r("outline","clock","Clock",q);const T=[["path",{d:"M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8l0 8",key:"svg-3"}],["path",{d:"M7 8a4 4 0 0 0 4 4h4",key:"svg-4"}]],G=r("outline","git-merge","GitMerge",T);const F=[["path",{d:"M12 4l-8 4l8 4l8 -4l-8 -4",key:"svg-0"}],["path",{d:"M4 12l8 4l8 -4",key:"svg-1"}],["path",{d:"M4 16l8 4l8 -4",key:"svg-2"}]],O=r("outline","stack-2","Stack2",F);const z=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855",key:"svg-2"}]],D=r("outline","user-circle","UserCircle",z);function Q({repositoryId:c,number:n,membership:o,onSelect:l}){const[d,k]=m.useState(!1),a=N({queryKey:C.pullRequestStack(c,n),queryFn:()=>M.github.getPullRequestStack(c,n),enabled:d,staleTime:0}),t=a.data,h=t?t.layers.findIndex(s=>s.number===n)+1:o.position,u=t?.layers.length??o.size,i=t?.number??o.number;return a.isSuccess&&t===null&&!d?null:e.jsxs(P,{open:d,onOpenChange:k,children:[e.jsxs(g,{children:[e.jsxs(x,{render:e.jsx(R,{render:e.jsx("button",{className:"pr-stack-trigger","aria-label":`Stack ${i}, layer ${h} of ${u}`})}),children:[e.jsx(O,{"aria-hidden":"true"})," ",h,"/",u]}),e.jsxs(v,{children:["View stack #",i," · layer ",h," of ",u]})]}),e.jsx(S,{children:e.jsx(_,{side:"bottom",align:"start",sideOffset:6,className:"isolate z-50 outline-none",children:e.jsxs(E,{className:"pr-stack-popup","aria-label":`Stack #${i}`,children:[e.jsxs("div",{className:"pr-stack-heading",children:[e.jsxs("strong",{children:["Stack #",i]}),e.jsx(j,{variant:"ghost",size:"xs",disabled:a.isFetching,onClick:()=>{a.refetch()},children:"Refresh"})]}),a.isFetching&&e.jsx("p",{className:"pr-stack-notice",role:"status",children:t?"Refreshing stack…":"Loading stack…"}),a.isError&&e.jsxs("div",{className:"pr-stack-notice",role:"status",children:[e.jsx("p",{children:t?"Could not refresh. Showing saved layers.":"Could not load the stack."}),e.jsx(j,{variant:"outline",size:"xs",onClick:()=>{a.refetch()},children:"Retry"})]}),t===null&&!a.isFetching&&!a.isError&&e.jsx("p",{className:"pr-stack-notice",children:"This PR is no longer in a stack, or stack data is unavailable."}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pr-stack-layers",children:[...t.layers].reverse().map(s=>{const p=s.isDraft&&s.state==="OPEN"?"Draft":s.state==="MERGED"?"Merged":s.state==="CLOSED"?"Closed":"Open",f=s.state==="MERGED"?G:y;return e.jsxs(g,{children:[e.jsxs(x,{render:e.jsx("button",{className:"pr-stack-layer","aria-current":s.number===n?"true":void 0,onClick:()=>{k(!1),l(s.number)}}),children:[e.jsx(f,{className:`pr-stack-state ${p.toLowerCase()}`,"aria-hidden":"true"}),e.jsxs("span",{className:"pr-stack-layer-text",children:[e.jsx("strong",{children:s.title}),e.jsxs("small",{children:["#",s.number," · ",s.headRefName," · ",p]})]}),s.number===n&&e.jsx(b,{"aria-hidden":"true"})]}),e.jsxs(v,{children:[s.title," · ",s.headRefName," · ",p]})]},s.number)})}),e.jsxs("div",{className:"pr-stack-base",children:["↳ ",t.base]})]})]})})})]})}function V({src:c,className:n}){const[o,l]=m.useState(!1);return e.jsx("span",{className:n,"aria-hidden":"true",children:c&&!o?e.jsx("img",{src:c,alt:"",onError:()=>l(!0)}):e.jsx(D,{})})}export{V as G,X as I,Q as P,A as a,H as b,G as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as w,j as e}from"./react-rd22PHbN.js";import{a as te}from"./tanstack-CtfgE41X.js";import{T as N,a as y,b as C,B as _,o as ne,w as ae,s as X}from"./index-CQcx9aRt.js";import{k as Q,G as J,j as re,Q as oe,R as ie,U as le,V as ce,M as de,W as he,X as ue,Y as me}from"./App-9EfSdZB8.js";import"./base-ui-DT3JsyND.js";function pe(s){let n=[],a=s.some(i=>i.color!==void 0)?3:0,t=1;const r=new Map,j=[],l=new Map(s.map(i=>[i.oid,i])),u=new Set;let d=s[0];for(;d&&!u.has(d.oid);)u.add(d.oid),d.color!==void 0&&r.set(d.oid,d.color),d=l.get(d.parentOids[0]??"");for(const i of s){let h=n.indexOf(i.oid);const p=h>=0;h<0&&(h=n.length,n=[...n,i.oid]);const f=n,v=xe(r,i.oid,()=>i.color??a++),x=v<3?i.color??v:v;r.set(i.oid,x);const b=f.filter((g,c)=>c!==h);let M=Math.min(h,b.length);i.parentOids.forEach((g,c)=>{r.has(g)||r.set(g,c===0?x:a++),!b.includes(g)&&(b.splice(M,0,g),M+=1)});const L=[];f.forEach((g,c)=>{if(c===h){p&&L.push({fromLane:c,from:"top",toLane:h,to:"node",color:v});return}const I=b.indexOf(g);I>=0&&L.push({fromLane:c,from:"top",toLane:I,to:"bottom",color:r.get(g)??0})}),i.parentOids.forEach(g=>{const c=b.indexOf(g);c>=0&&L.push({fromLane:h,from:"node",toLane:c,to:"bottom",color:r.get(g)??x})}),t=Math.max(t,f.length,b.length),j.push({lane:h,color:x,segments:L,continuations:b.map((g,c)=>({lane:c,color:r.get(g)??0}))}),n=b}return{rows:j,laneCount:t}}function xe(s,n,a){const t=s.get(n);if(t!==void 0)return t;const r=a();return s.set(n,r),r}function je(s){const n=s.parentCount>1&&/^Merge pull request #(\d+)\b/i.exec(s.subject),a=/\(#(\d+)\)\s*$/.exec(s.subject),t=n||a;if(!t)return null;const r=Number(t[1]);return Number.isSafeInteger(r)&&r>0?{number:r,source:n?"merge":"subject"}:null}function fe(s){if(s.upstreamState==="local-only")return 0;if(s.baseState==="included")return 2;if(s.upstreamState==="published")return 1}function ge(s,n){if(!n)return s.map(l=>({commit:l,parentOids:l.parentOids,grouped:[]}));const a=new Map(s.map(l=>[l.oid,l])),t=new Map;s.forEach(l=>l.parentOids.forEach(u=>{const d=t.get(u)??new Set;d.add(l.oid),t.set(u,d)}));const r=new Set,j=[];for(const l of s){if(r.has(l.oid))continue;const u={commit:l,parentOids:l.parentOids,grouped:[]};if(j.push(u),l.parentOids.length!==2)continue;const d=new Set;let i=a.get(l.parentOids[0]);for(;i&&!d.has(i.oid);)d.add(i.oid),i=a.get(i.parentOids[0]??"");let h=l.parentOids[1];const p=[],f=new Set;for(;!d.has(h);){const x=a.get(h);if(!x||f.has(h)||r.has(h)||x.isHead||x.parentOids.length!==1)break;f.add(h),p.push(x),h=x.parentOids[0]}if(!d.has(h)||p.length===0)continue;const v=new Set([l.oid,...p.map(x=>x.oid)]);p.some(x=>[...t.get(x.oid)??[]].some(b=>!v.has(b)))||p.some(x=>j.some(b=>b.commit.oid===x.oid))||(u.grouped=p,u.parentOids=[l.parentOids[0]],p.forEach(x=>r.add(x.oid)))}return j}function K(s,n){const a=n.trim().toLocaleLowerCase();return a.length>0&&[s.subject,s.author,s.oid,...s.decorations].some(t=>t.toLocaleLowerCase().includes(a))}function Fe({repositoryId:s,upstream:n,readOnly:a,operation:t,canPublish:r,pushBusy:j,onPublish:l,commits:u,nextCursor:d,loading:i,undoing:h,baseRef:p,activeOid:f,onSelectReference:v,onSelectCommit:x,onSelectFile:b,onUndo:M,onMore:L}){const g=w.useRef(null),[c,I]=w.useState(new Set),[$,z]=w.useState(!0),[k,A]=w.useState(!1),[E,R]=w.useState(""),[V,F]=w.useState(-1),H=$?42:56,o=w.useMemo(()=>ge(u??[],k&&!E.trim()),[u,k,E]),O=w.useMemo(()=>pe(o.map(({commit:m,parentOids:S})=>({oid:m.oid,parentOids:S,color:fe(m)}))),[o]),P=w.useMemo(()=>o.flatMap(({commit:m},S)=>K(m,E)?[S]:[]),[o,E]),ee=ye(O.laneCount),T=te({count:o.length,getScrollElement:()=>g.current,estimateSize:()=>H,getItemKey:m=>o[m].commit.oid,overscan:8});w.useEffect(()=>{T.measure()},[T,$,k,E]);const B=()=>{if(!P.length)return;const m=(V+1)%P.length;F(m),T.scrollToIndex(P[m],{align:"center"})};if(u===null)return e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(Q,{className:"spinner"})," ",e.jsx(J,{text:"Loading history…"})]});const q=u.filter(m=>m.upstreamState==="local-only").length;return e.jsxs("div",{className:"history-list",style:{"--history-row-height":`${H}px`},children:[e.jsxs("div",{className:"history-toolbar",children:[e.jsxs("label",{className:"history-search",children:[e.jsx(re,{"aria-hidden":"true"}),e.jsx("input",{type:"search","aria-label":"Search loaded commits",placeholder:"Find commit…",value:E,onChange:m=>{R(m.target.value),F(-1)},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),B())}})]}),E&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-next-match",onClick:B,disabled:!P.length,"aria-label":"Next matching commit"}),children:e.jsx(oe,{})}),e.jsx(C,{children:"Next match in loaded history (Enter)"})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-option","aria-pressed":k,disabled:!u.some(m=>m.parentCount>1),onClick:()=>A(!k)}),children:"Group merges"}),e.jsx(C,{children:"Collapse complete merge branches. Searching reveals their commits."})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"history-option","aria-pressed":$,onClick:()=>z(!$)}),children:$?"Compact":"Comfortable"}),e.jsx(C,{children:"Change row density without moving the diff viewer"})]})]}),!n&&u.length>0&&e.jsxs("div",{className:"history-upstream-notice",role:"status",children:[e.jsx("span",{children:"Publish this branch to configure an upstream and distinguish local from published commits."}),r&&e.jsx(_,{variant:"outline",size:"xs",disabled:j||a||!!t,onClick:l,children:j?"Publishing…":"Publish branch"})]}),n&&q>0&&e.jsxs("div",{className:"history-local-summary",children:["↑ ",q," ",q===1?"local commit":"local commits"," in loaded history"]}),e.jsx("div",{ref:g,className:"history-scroll",role:"list","aria-label":"Commit history",children:o.length===0?e.jsx("p",{className:"empty-list",children:"This repository has no commits yet."}):e.jsxs("div",{className:"virtual-list",style:{height:T.getTotalSize()+(d?52:0)},children:[T.getVirtualItems().map(m=>{const{commit:S,grouped:W}=o[m.index];return e.jsx("div",{ref:T.measureElement,"data-index":m.index,className:"virtual-row",style:{transform:`translateY(${m.start}px)`},children:e.jsx(be,{repositoryId:s,upstream:n,baseRef:p,commit:S,graphRow:O.rows[m.index],graphWidth:ee,rowHeight:H,active:f===S.oid||W.some(U=>U.oid===f),match:K(S,E),groupedCount:W.length,onRevealGroup:()=>A(!1),onSelectReference:v,expanded:c.has(S.oid),onExpandedChange:U=>I(se=>{const Y=new Set(se);return U?Y.add(S.oid):Y.delete(S.oid),Y}),canUndo:!a&&!t&&!h&&S.upstreamState==="local-only"&&S.isHead&&S.parentCount===1,onSelectCommit:x,onSelectFile:b,onUndo:M})},m.key)}),d&&e.jsx(_,{variant:"ghost",className:"history-more",style:{top:T.getTotalSize()},disabled:i,onClick:L,children:i?"Loading…":"Load more"})]})}),u.length>0&&e.jsxs("div",{className:"history-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-color":"local"}),"Local"]}),e.jsxs("span",{children:[e.jsx("i",{"data-color":"published"}),"Published"]}),p&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("span",{className:"history-base-label"}),children:[e.jsx("i",{"data-color":"base"}),p]}),e.jsxs(C,{children:["Primary-line commits reachable from ",p,", using the latest known local refs. Side branches use the published color."]})]}),e.jsx("span",{className:"history-count",role:"status",children:E?`${P.length} matches in ${u.length} loaded`:`${u.length} loaded`})]})]})}function be({repositoryId:s,upstream:n,baseRef:a,commit:t,graphRow:r,graphWidth:j,rowHeight:l,active:u,match:d,groupedCount:i,onRevealGroup:h,onSelectReference:p,expanded:f,onExpandedChange:v,canUndo:x,onSelectCommit:b,onSelectFile:M,onUndo:L}){const g=`${s}:${t.oid}`,[c,I]=w.useState(()=>ie(g)??null),[$,z]=w.useState(null);w.useEffect(()=>{if(!f||c||$)return;let o=!0;return ne.commits.files(s,t.oid).then(O=>{o&&(le(g,O),I(O))}).catch(O=>{o&&z(Te(O))}),()=>{o=!1}},[g,t.oid,f,c,$,s]);const k=je(t),A=Se(t.decorations),E=A.slice(0,3),R=A.slice(3),V=c?.reduce((o,O)=>o+O.additions,0)??0,F=c?.reduce((o,O)=>o+O.deletions,0)??0,H=async()=>{try{await ae(t.oid),X.success({title:"Hash copied",description:t.oid})}catch{X.error({title:"Could not copy hash"})}};return e.jsxs("div",{className:`commit-item${u?" active":""}${d?" search-match":""}`,role:"listitem",children:[e.jsxs("div",{className:"commit-header",children:[e.jsx(Ce,{graph:r,width:j,height:l,merge:t.parentCount>1,head:t.isHead}),e.jsx("button",{className:"commit-expand","aria-expanded":f,"aria-label":f?"Collapse commit":"Expand commit",onClick:()=>v(!f),children:e.jsx(ce,{className:`folder-chevron ${f?"open":""}`})}),e.jsxs("div",{className:"commit-main",children:[e.jsxs("span",{className:"commit-title-row",children:[e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"commit-subject","aria-pressed":u,onClick:()=>b(t)}),children:t.subject||"(no subject)"}),e.jsxs(C,{side:"right",children:[t.subject||"(no subject)",e.jsx("br",{}),"Open the full commit diff"]})]}),k&&e.jsxs(N,{children:[e.jsxs(y,{render:p?e.jsx("button",{className:"ref-chip commit-pr",onClick:()=>p(k.number),"aria-label":`Open pull request #${k.number}`}):e.jsx("span",{className:"ref-chip commit-pr"}),children:[e.jsx(de,{"aria-hidden":"true"}),"#",k.number]}),e.jsxs(C,{children:[k.source==="merge"?"Pull request reference from the merge message.":"Reference from the commit subject; it may identify a pull request or issue.",p?" Open as a pull request in the right-hand viewer.":""," No merge method is inferred from the number."]})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"commit-date"}),children:Ee(t.date)}),e.jsx(C,{children:Oe(t.date)})]})]}),e.jsxs("span",{className:"commit-meta",children:[(A.length>0||t.parentCount>1||t.upstreamState==="local-only")&&e.jsxs("span",{className:"commit-refs",children:[t.upstreamState==="local-only"&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"ref-chip local-only"}),children:"Local"}),e.jsx(C,{children:t.isHead?`Not in ${n??"the upstream"} according to the latest known remote state.`:"Not published. To avoid rewriting multiple commits, only the latest can be undone."})]}),t.parentCount>1&&e.jsx("span",{className:"ref-chip merge",children:"merge"}),E.map(o=>e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:`ref-chip ${o.kind}`,"data-base":o.label===a||o.label.endsWith("/HEAD")&&t.baseState==="included"}),children:o.label}),e.jsx(C,{children:o.label})]},`${o.kind}:${o.label}`)),R.length>0&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("span",{className:"ref-chip more"}),children:["+",R.length]}),e.jsx(C,{children:R.map(o=>o.label).join(" · ")})]})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("button",{className:"commit-oid",onClick:()=>{H()},"aria-label":`Copiar hash ${t.shortOid}`}),children:t.shortOid}),e.jsx(C,{children:"Copy full hash"})]}),e.jsxs(N,{children:[e.jsx(y,{render:e.jsx("span",{className:"commit-author"}),children:t.author}),e.jsx(C,{children:t.author})]}),i>0&&e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("button",{className:"commit-group-count",onClick:h}),children:[i," grouped"]}),e.jsxs(C,{children:["Show the ",i," commits in this merge branch"]})]})]})]}),x&&e.jsxs(N,{children:[e.jsx(y,{render:e.jsx(_,{variant:"ghost",size:"icon-xs",className:"change-action-button commit-undo",onClick:o=>{o.stopPropagation(),L(t)},"aria-label":`Undo commit ${t.shortOid}`}),children:e.jsx(he,{})}),e.jsx(C,{children:"Undo commit and keep its changes staged"})]})]}),f&&r.continuations.length>0&&e.jsx(we,{graph:r,width:j}),f&&e.jsxs("div",{className:"commit-files",style:{paddingLeft:j+31},children:[t.body&&e.jsx("p",{className:"commit-description",children:t.body}),$&&e.jsx("div",{className:"commit-files-message error",children:$}),!c&&!$&&e.jsxs("div",{className:"commit-files-message",children:[e.jsx(Q,{className:"spinner"})," ",e.jsx(J,{text:"Loading files…"})]}),c&&c.length===0&&e.jsx("div",{className:"commit-files-message",children:"This commit does not modify its own files (merge)."}),c&&c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"commit-files-summary",children:[c.length," ",c.length===1?"file":"files",(V>0||F>0)&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"add",children:["+",V]})," ",e.jsxs("span",{className:"del",children:["−",F]})]})]}),c.map(o=>e.jsx(ve,{file:o,onSelect:()=>M(t.oid,o)},o.path))]})]})]})}const Z=14,Ne=["var(--history-local)","var(--history-published)","var(--history-base)"];function ye(s){return 14+Math.max(0,s-1)*Z}function D(s){return 7+s*Z}function G(s){return Ne[s]??"var(--history-published)"}function Ce({graph:s,width:n,height:a,merge:t,head:r}){const j=a/2;return e.jsxs("svg",{className:"commit-graph",width:n,height:a,viewBox:`0 0 ${n} ${a}`,"aria-hidden":"true",children:[s.segments.map((l,u)=>{const d=D(l.fromLane),i=D(l.toLane),h=l.from==="top"?0:j,p=l.to==="node"?j:a,f=(h+p)/2,v=d===i?`M ${d} ${h} L ${i} ${p}`:`M ${d} ${h} C ${d} ${f}, ${i} ${f}, ${i} ${p}`;return e.jsx("path",{d:v,stroke:G(l.color)},`${u}:${v}`)}),e.jsx("circle",{cx:D(s.lane),cy:j,r:t||r?4.5:3,fill:t||r?"var(--sidebar)":G(s.color),stroke:G(s.color)}),t&&e.jsx("circle",{cx:D(s.lane),cy:j,r:"1.6",fill:G(s.color)})]})}function we({graph:s,width:n}){return e.jsx("svg",{className:"commit-graph-continuation",width:n,viewBox:`0 0 ${n} 100`,preserveAspectRatio:"none","aria-hidden":"true",children:s.continuations.map(a=>e.jsx("line",{x1:D(a.lane),y1:"0",x2:D(a.lane),y2:"100",stroke:G(a.color)},a.lane))})}function ve({file:s,onSelect:n}){const a=w.useRef(null),t=s.path.lastIndexOf("/"),r=t<0?s.path:s.path.slice(t+1),j=s.oldPath?.split("/").pop();return e.jsxs("div",{ref:a,className:"commit-file-row",children:[e.jsxs(N,{children:[e.jsxs(y,{render:e.jsx("button",{className:"commit-file-label",onClick:n,"aria-label":`Ver el diff de ${s.path}`}),children:[e.jsx(Le,{path:s.path,type:"file"}),e.jsxs("span",{className:"commit-file-text",children:[e.jsx("span",{children:r}),j&&e.jsxs("small",{className:"commit-file-rename",children:[j," →"]})]})]}),e.jsx(C,{anchor:a,side:"right",sideOffset:10,children:s.oldPath?`${s.oldPath} → ${s.path}`:s.path})]}),e.jsx("span",{className:"commit-file-stats",children:s.binary?e.jsx("span",{className:"binary",children:"bin"}):e.jsxs(e.Fragment,{children:[s.additions>0&&e.jsxs("span",{className:"add",children:["+",s.additions]}),s.deletions>0&&e.jsxs("span",{className:"del",children:["−",s.deletions]})]})}),e.jsx("span",{className:"status-code","data-kind":s.kind,children:ue(s.kind)})]})}function Se(s){return s.map(n=>n.startsWith("tag: ")?{label:n.slice(5),kind:"tag"}:n.startsWith("HEAD -> ")?{label:n.slice(8),kind:"head"}:n==="HEAD"?{label:"HEAD",kind:"head"}:{label:n,kind:n.includes("/")?"remote":"branch"})}const $e=new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"narrow"}),ke=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]];function Ee(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return s;const a=Math.round((n.getTime()-Date.now())/1e3);for(const[t,r]of ke)if(Math.abs(a)>=r)return $e.format(Math.trunc(a/r),t);return"right now"}function Oe(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"}).format(n)}function Le({path:s}){return e.jsx("img",{className:"vscode-tree-icon",src:me(s),alt:"","aria-hidden":"true",draggable:!1})}function Te(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{Fe as HistoryView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as m,j as e}from"./react-rd22PHbN.js";import{V as f,a as $,b as u}from"./viewer-tabs-
|
|
1
|
+
import{r as m,j as e}from"./react-rd22PHbN.js";import{V as f,a as $,b as u}from"./viewer-tabs-DkLmDzFg.js";import{u as j,F as y,S as E}from"./EditableFileViewer-85aEeMBK.js";import"./index-CQcx9aRt.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-DH2jp9oe.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-DTtWrbYf.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";import"./App-9EfSdZB8.js";const T="data-opentig-preview-scrollbar";function S(r,i){const t=i?"255 255 255":"0 0 0",c=i?"oklch(0.13 0 0)":"oklch(0.985 0 0)",o=[`<style ${T}>`,"html {",` color-scheme: ${i?"dark":"light"} !important;`,` background-color: ${c} !important;`,"}","html, body, * {"," scrollbar-width: thin !important;",` scrollbar-color: rgb(${t} / 18%) transparent !important;`,"}","html::-webkit-scrollbar, body::-webkit-scrollbar, *::-webkit-scrollbar { width: 10px !important; height: 10px !important; }","html::-webkit-scrollbar-track, body::-webkit-scrollbar-track, *::-webkit-scrollbar-track,","html::-webkit-scrollbar-corner, body::-webkit-scrollbar-corner, *::-webkit-scrollbar-corner { background: transparent !important; }","html::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb, *::-webkit-scrollbar-thumb {",` background-color: rgb(${t} / 18%) !important;`," background-clip: content-box !important;"," border: 3px solid transparent !important;"," border-radius: 999px !important;","}",`html::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover, *::-webkit-scrollbar-thumb:hover { background-color: rgb(${t} / 28%) !important; }`,"html::-webkit-scrollbar-button, body::-webkit-scrollbar-button, *::-webkit-scrollbar-button { display: none !important; width: 0 !important; height: 0 !important; }","</style>"].join(`
|
|
2
2
|
`),s=r.search(/<\/head\s*>/i);if(s>=0)return`${r.slice(0,s)}${o}
|
|
3
3
|
${r.slice(s)}`;const l=/<head(?:\s[^>]*)?>/i.exec(r);if(l?.index!==void 0){const a=l.index+l[0].length;return`${r.slice(0,a)}
|
|
4
4
|
${o}${r.slice(a)}`}const n=/<html(?:\s[^>]*)?>/i.exec(r);if(n?.index!==void 0){const a=n.index+n[0].length;return`${r.slice(0,a)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./index-
|
|
1
|
+
import{c as t}from"./index-CQcx9aRt.js";const a=[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]],o=t("outline","edit","Edit",a);export{o as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o}from"./index-
|
|
1
|
+
import{c as o}from"./index-CQcx9aRt.js";const e=[["path",{d:"M12 19h-7a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v3.5",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]],a=o("outline","folder-plus","FolderPlus",e);export{a as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,r}from"./react-rd22PHbN.js";import{c as V,B as x,T as k,a as T,b as O}from"./index-
|
|
1
|
+
import{j as t,r}from"./react-rd22PHbN.js";import{c as V,B as x,T as k,a as T,b as O}from"./index-CQcx9aRt.js";import{V as U,b as C,a as B}from"./viewer-tabs-DkLmDzFg.js";import{u as W,S as P,F as H}from"./EditableFileViewer-85aEeMBK.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-DH2jp9oe.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-DTtWrbYf.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";import"./App-9EfSdZB8.js";const K=[["path",{d:"M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M7 10l6 0",key:"svg-1"}],["path",{d:"M10 7l0 6",key:"svg-2"}],["path",{d:"M21 21l-6 -6",key:"svg-3"}]],X=V("outline","zoom-in","ZoomIn",K);const Y=[["path",{d:"M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M7 10l6 0",key:"svg-1"}],["path",{d:"M21 21l-6 -6",key:"svg-2"}]],q=V("outline","zoom-out","ZoomOut",Y),Z=.25,S=8,D=[.25,.5,.75,1,1.25,1.5,2,3,4,6,8];function $(e){return Number.isFinite(e)?Math.min(S,Math.max(Z,e)):1}function L(e){const s=$(e);return D.find(n=>n>s+Number.EPSILON)??S}function _(e){const s=$(e);return[...D].reverse().find(n=>n<s-Number.EPSILON)??Z}const J={conflictTitle:"SVG was changed outside OpenTig",successTitle:"SVG saved",errorTitle:"Could not save SVG"};function ve({image:e}){return e.status==="unsupported"?t.jsx(y,{title:"Image format is not supported",detail:`${e.path} · ${M(e.size)}`}):e.status==="too-large"?t.jsx(y,{title:"Image is too large to preview",detail:`${e.path} · ${M(e.size)} · limit ${M(e.limit)}`}):t.jsx(Q,{path:e.path,mimeType:e.mimeType,size:e.size,data:e.data})}function Q({path:e,mimeType:s,size:n,data:d}){const c=F(d,s);return t.jsx(R,{objectUrl:c,path:e,size:n})}function fe({file:e,initialContent:s,themeType:n,wrapLines:d,readOnly:c,onDirtyChange:i,onDraftChange:o,onSave:u}){const[m,l]=r.useState("preview"),{draft:g,updateDraft:N,dirty:v,saving:f,save:j}=W({file:e,initialContent:s,readOnly:c,messages:J,onDirtyChange:i,onDraftChange:o,onSave:u}),w=F(g,"image/svg+xml");r.useEffect(()=>{l("preview")},[e.path]);const b=t.jsx(B,{label:"SVG view",className:"file-viewer-tabs image-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:t.jsxs(t.Fragment,{children:["Code ",v&&t.jsx("span",{className:"image-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),p=t.jsx(H,{dirty:v,saving:f,readOnly:c,onSave:()=>{j()}});return t.jsxs(U,{value:m,onValueChange:a=>l(a),className:"svg-file-viewer",children:[t.jsx(C,{value:"preview",className:"svg-file-panel",children:t.jsx(R,{objectUrl:w,path:e.path,size:new TextEncoder().encode(g).byteLength,toolbarStart:b,toolbarEnd:p})}),t.jsxs(C,{value:"code",className:"svg-file-panel",children:[t.jsxs("div",{className:"file-viewer-pill svg-file-toolbar",children:[b,p]}),t.jsx("div",{className:"svg-code-view",children:t.jsx(P,{path:e.path,cacheKey:e.path,value:g,themeType:n,wrapLines:d,readOnly:c||f,onChange:N})})]})]})}function R({objectUrl:e,path:s,size:n,toolbarStart:d,toolbarEnd:c}){const[i,o]=r.useState("fit"),[u,m]=r.useState(1),[l,g]=r.useState(null),[N,v]=r.useState(!1),f=r.useRef(null);r.useEffect(()=>{g(null),v(!1)},[e]),r.useEffect(()=>{const a=f.current;if(!a)return;let h=0;const z=E=>{E.preventDefault();const A=E.deltaMode===WheelEvent.DOM_DELTA_LINE?16:E.deltaMode===WheelEvent.DOM_DELTA_PAGE?100:1;if(h+=E.deltaY*A,Math.abs(h)<24)return;const G=h<0;h=0,o("actual"),m(I=>G?L(I):_(I))};return a.addEventListener("wheel",z,{passive:!1}),()=>a.removeEventListener("wheel",z)},[]);const j=l?l.width*u:void 0,w=l?l.height*u:void 0,b=[M(n),l?`${l.width} × ${l.height}`:null].filter(Boolean).join(" · "),p=a=>{o("actual"),m(h=>a==="in"?L(h):_(h))};return t.jsxs("div",{className:"image-preview-workspace",children:[t.jsxs("div",{className:"file-viewer-pill image-preview-toolbar",children:[d,t.jsx("span",{className:"image-file-details",children:b}),t.jsxs("div",{className:"image-sizing-toggle",role:"group","aria-label":"Image size",children:[t.jsx(x,{type:"button",size:"xs",variant:i==="fit"?"secondary":"ghost","aria-pressed":i==="fit",onClick:()=>o("fit"),children:"Fit"}),t.jsx(x,{type:"button",size:"xs",variant:i==="actual"&&u===1?"secondary":"ghost","aria-pressed":i==="actual"&&u===1,onClick:()=>{o("actual"),m(1)},children:"1:1"})]}),t.jsxs("div",{className:"image-zoom-controls",children:[t.jsxs(k,{children:[t.jsx(T,{render:t.jsx(x,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Zoom out",onClick:()=>p("out")}),children:t.jsx(q,{})}),t.jsx(O,{children:"Zoom out"})]}),t.jsxs(x,{type:"button",variant:"ghost",size:"xs",className:"image-zoom-value","aria-label":"Reset zoom to 100%",onClick:()=>{o("actual"),m(1)},children:[Math.round(u*100),"%"]}),t.jsxs(k,{children:[t.jsx(T,{render:t.jsx(x,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"Zoom in",onClick:()=>p("in")}),children:t.jsx(X,{})}),t.jsx(O,{children:"Zoom in"})]})]}),c]}),t.jsx("div",{ref:f,className:"image-preview-canvas","data-sizing":i,"data-zoom-limit":u>=S?"max":"normal",tabIndex:0,"aria-label":`Image preview for ${s}`,onKeyDown:a=>{if(a.key==="+"||a.key==="=")p("in");else if(a.key==="-")p("out");else if(a.key==="0")o("actual"),m(1);else if(a.key.toLowerCase()==="f")o("fit");else return;a.preventDefault()},children:e?N?t.jsx(y,{title:"Could not decode this image",detail:s}):t.jsx("img",{src:e,alt:ee(s),draggable:!1,style:i==="actual"&&j&&w?{width:j,height:w,maxWidth:"none",maxHeight:"none"}:void 0,onLoad:a=>{v(!1),g({width:a.currentTarget.naturalWidth,height:a.currentTarget.naturalHeight})},onError:()=>v(!0)}):t.jsx("span",{className:"image-preview-loading",children:"Loading image…"})})]})}function y({title:e,detail:s}){return t.jsxs("div",{className:"image-viewer-message",children:[t.jsx("strong",{children:e}),t.jsx("span",{children:s})]})}function F(e,s){const[n,d]=r.useState(null);return r.useEffect(()=>{const c=typeof e=="string"?e:new Uint8Array(e),i=URL.createObjectURL(new Blob([c],{type:s}));return d(i),()=>{URL.revokeObjectURL(i),d(o=>o===i?null:o)}},[s,e]),n}function ee(e){return e.replace(/\\/g,"/").split("/").pop()||e}function M(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}export{ve as ImageFileViewer,fe as SvgFileViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e}from"./react-rd22PHbN.js";import{u as W}from"./tanstack-B8_amOz8.js";import{f as ve,a as Ne,b as F,w as B,n as ie,D as Ce,c as De,d as Te,e as Fe,g as he,I as de,h as M,i as se,j as Be,k as H,l as Se,m as O,o as Ee,p as U,q as ue,B as Ie,r as Re,s as Ge,t as be,u as Pe,v as Ae,x as Oe,y as me,z as Le}from"./App-CBetJ5ZN.js";import{q as K,B as f,T as X,a as J,b as V,I as $e,w as ze,o as S}from"./index-BOPi2b1j.js";import{C as qe}from"./checkbox-BwbxYGgK.js";import{o as We}from"./gh-utils-B0Nlmxep.js";import"./base-ui-qeHDA5zu.js";function rr(r){const{open:n,tab:a,repositoryId:t,onMutated:b,onBusyChange:j}=r,[o,p]=l.useState(""),[k,c]=l.useState(!1),[i,w]=l.useState(null),[g,E]=l.useState(null),[v,x]=l.useState(null),[d,I]=l.useState(null),[L,N]=l.useState(null),[fe,$]=l.useState(!1),ne=l.useRef(null);l.useEffect(()=>{c(!1)},[n,t]);const D=W({queryKey:K.localRefs(t),queryFn:()=>S.refs.localRefsSnapshot(t),enabled:n}),m=D.data??null,z=D.isFetching,le=D.error?Q(D.error):null,Z=l.useMemo(()=>ve(m?.branches??[],o),[m,o]),_=l.useMemo(()=>Ne(m?.worktrees??[],o),[m,o]),R=Z.find(s=>F(s)===i)??null,G=_.find(s=>B(s)===g)??null,te=W({queryKey:K.branchDetails(t,R?.fullName??""),queryFn:()=>S.refs.branchDetails({repositoryId:t,fullName:R.fullName}),enabled:n&&a==="branches"&&R!==null}),y=te.data??null,je=W({queryKey:K.branchPullRequest(t,y?.name??""),queryFn:()=>S.github.findPullRequestForBranch(t,y.name),enabled:n&&a==="branches"&&y!==null&&(y.deletion==="unknown"||y.deletion==="unmerged")}).data??null,oe=W({queryKey:K.worktreeDetails(t,G?.path??""),queryFn:()=>S.refs.worktreeDetails({repositoryId:t,path:G.path}),enabled:n&&a==="worktrees"&&G!==null}),C=oe.data??null,ee=a==="branches"?te:oe,q=ee.isFetching,P=ee.error?Q(ee.error):null,A=l.useCallback(async()=>{await D.refetch()},[D]);l.useEffect(()=>{if(!m)return;const s=ne.current;ne.current=m,w(h=>ie(m.branches.map(F),(s?.branches??[]).map(F),h)),E(h=>ie(m.worktrees.map(B),(s?.worktrees??[]).map(B),h))},[m]),l.useEffect(()=>{n||(p(""),x(null),N(null),$(!1))},[n]),l.useEffect(()=>{x(null),N(null),$(!1)},[a,i,g]);const ce=async(s,h)=>{I(s),j(!0),N(null);try{await h()&&x(null)}catch(T){N(Q(T))}finally{I(null),j(!1)}},pe=(s,h)=>ce("delete-branch",async()=>{const T=await S.refs.deleteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,force:h});return T.status!=="deleted"?(N(He(T.status)),await A(),!1):(b(null),await A(),!0)}),we=(s,h,T)=>ce("remove-worktree",async()=>{const re=await S.refs.removeWorktree({repositoryId:t,path:s.path,expectedOid:s.oid,force:h,deleteBranch:T});return re.status!=="removed"?(N(Me(re.status)),await A(),!1):(b(re.recentRepositories),await A(),!0)}),ge=async s=>{try{await ze(s),$(!0),window.setTimeout(()=>$(!1),1600)}catch(h){N(Q(h))}},ke={branches:m?.branches.length??0,worktrees:m?.worktrees.length??0},ye=a==="branches"?Z.length===0:_.length===0;return e.jsx(Ce,{open:n,onOpenChange:r.onOpenChange,children:e.jsxs(De,{className:"local-refs-dialog",children:[e.jsxs("header",{className:"local-refs-header",children:[e.jsxs("div",{children:[e.jsx(Te,{children:"Local branches and worktrees"}),e.jsx(Fe,{children:"Inspect what this repository holds locally, and retire what Git can safely remove."})]}),e.jsx(he,{render:e.jsx(f,{variant:"ghost",size:"icon-sm","aria-label":"Close the local refs manager"}),children:e.jsx(de,{})})]}),e.jsxs("div",{className:"local-refs-toolbar",children:[e.jsx("div",{className:"local-refs-tabs",role:"tablist","aria-label":"Local refs",children:["branches","worktrees"].map(s=>e.jsxs("button",{type:"button",role:"tab",id:`local-refs-tab-${s}`,"aria-selected":a===s,"aria-controls":`local-refs-panel-${s}`,className:"local-refs-tab",onClick:()=>{r.onTabChange(s),c(!1)},children:[s==="branches"?e.jsx(M,{"aria-hidden":"true"}):e.jsx(se,{"aria-hidden":"true"}),e.jsx("span",{children:s==="branches"?"Branches":"Worktrees"}),e.jsx("small",{children:ke[s]})]},s))}),e.jsxs("div",{className:"local-refs-search",children:[e.jsx(Be,{"aria-hidden":"true"}),e.jsxs("label",{className:"sr-only",htmlFor:"local-refs-search-input",children:["Search ",a]}),e.jsx("input",{id:"local-refs-search-input",value:o,onChange:s=>p(s.target.value),placeholder:a==="branches"?"Search branches…":"Search worktrees…",autoComplete:"off",spellCheck:!1}),o&&e.jsx(f,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",onClick:()=>p(""),children:e.jsx(de,{})})]}),e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{A()},disabled:z||!!d,children:[z?e.jsx(H,{className:"animate-spin"}):e.jsx(Se,{})," Refresh"]})]}),le&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:le})]}),k&&e.jsxs("button",{type:"button",className:"local-refs-mobile-back",onClick:()=>c(!1),children:["← Back to ",a]}),e.jsxs("div",{className:"local-refs-body","data-mobile-detail":k,role:"tabpanel",id:`local-refs-panel-${a}`,"aria-labelledby":`local-refs-tab-${a}`,children:[e.jsxs("div",{className:"local-refs-list",role:"listbox","aria-label":a==="branches"?"Local branches":"Worktrees",tabIndex:-1,children:[z&&!m&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Reading the repository…"]}),!z&&ye&&e.jsx("p",{className:"local-refs-placeholder",children:o?"No matches for this search.":`This repository has no ${a==="branches"?"local branches":"worktrees"}.`}),a==="branches"&&Z.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":F(s)===i,className:"local-refs-row",onClick:()=>{w(F(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(M,{"aria-hidden":"true"}),e.jsx("strong",{children:s.name}),e.jsx(Y,{badges:Ee(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("code",{children:s.shortOid}),s.subject&&e.jsx("span",{children:s.subject}),s.date&&e.jsx("time",{dateTime:s.date,children:ae(s.date)})]})]}),e.jsxs(V,{children:[s.name,s.subject?` — ${s.subject}`:""]})]},F(s))),a==="worktrees"&&_.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":B(s)===g,className:"local-refs-row",onClick:()=>{E(B(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(se,{"aria-hidden":"true"}),e.jsx("strong",{children:U(s.path)}),e.jsx(Y,{badges:ue(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("span",{className:"local-refs-row-branch",children:s.branch?`${s.branch}`:"Detached HEAD"}),e.jsx("span",{children:s.path})]})]}),e.jsxs(V,{children:[U(s.path)," — ",s.path]})]},B(s)))]}),e.jsxs("div",{className:"local-refs-detail",children:[P&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:P})]}),q&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Loading details…"]}),!q&&!P&&a==="branches"&&y&&R&&e.jsx(Ke,{details:y,pullRequest:je,busy:d==="delete-branch",anyBusy:!!d,confirming:v==="delete-branch",actionError:L,onConfirm:()=>x("delete-branch"),onCancel:()=>x(null),onDelete:s=>{pe(y,s)}}),!q&&!P&&a==="worktrees"&&C&&G&&e.jsx(Qe,{details:C,busy:d==="remove-worktree",anyBusy:!!d,confirming:v==="remove-worktree",actionError:L,copied:fe,onConfirm:()=>x("remove-worktree"),onCancel:()=>x(null),onRemove:(s,h)=>{we(C,s,h)},onCopyPath:()=>{ge(C.path)},onOpen:()=>r.onOpenWorktree(C.path),onShowBranch:()=>{C.branch&&(w(`refs/heads/${C.branch}`),r.onTabChange("branches"))}}),!q&&!P&&!R&&!G&&e.jsxs("p",{className:"local-refs-placeholder",children:["Select a ",a==="branches"?"branch":"worktree"," to see its details."]})]})]},a),e.jsxs("footer",{className:"local-refs-footer",children:[e.jsx("small",{children:"Deleting a branch and removing a worktree are separate actions. A worktree removes its branch only when explicitly selected."}),e.jsx(he,{render:e.jsx(f,{variant:"outline",size:"sm",disabled:!!d}),children:"Done"})]})]})})}function Ke({details:r,pullRequest:n,busy:a,anyBusy:t,confirming:b,actionError:j,onConfirm:o,onCancel:p,onDelete:k}){const c=Re(r,n),i=c.forceAllowed===!0,w=c.allowed||i;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(M,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:r.name}),e.jsx(V,{children:r.name})]})]}),e.jsx(Y,{badges:Ge(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Full ref",children:e.jsx("code",{className:"local-refs-selectable",children:r.fullName})}),e.jsxs(u,{label:"Tip",children:[e.jsx("code",{children:r.shortOid})," ",r.subject]}),e.jsx(u,{label:"Author",children:r.author||"—"}),e.jsx(u,{label:"Last commit",children:r.date?ae(r.date,!0):"—"}),e.jsx(u,{label:"Upstream",children:r.upstream?`${r.upstream} · ↑${r.ahead} ↓${r.behind}`:"Not configured"}),e.jsx(u,{label:"Compared with",children:r.comparisonBase??"Not compared"}),n&&e.jsx(u,{label:"GitHub PR",children:e.jsxs("button",{type:"button",className:"local-refs-pr-link",onClick:()=>We(n.url),children:["#",n.number," · ",n.state==="MERGED"?`Merged into ${n.baseRefName}`:n.state==="OPEN"?"Open":"Closed"," ",e.jsx(be,{"aria-hidden":"true"})]})})]}),e.jsx(xe,{tone:c.allowed?"ready":"blocked",reason:c.reason,actionError:j,confirming:b,busy:a,anyBusy:t,actionLabel:i?"Force delete branch":"Delete branch",confirmLabel:a?"Deleting…":i?"Permanently delete":"Delete branch",allowed:w,confirmation:i?e.jsxs(e.Fragment,{children:["Force-delete the local branch ",e.jsx("strong",{children:r.name}),"? This keeps any remote branch and pull request, but commits found only on this local branch may become inaccessible. ",n?.state==="MERGED"?e.jsxs(e.Fragment,{children:["GitHub reports PR ",e.jsxs("strong",{children:["#",n.number]})," as merged into ",e.jsx("strong",{children:n.baseRefName}),", although local Git cannot verify the ancestry."]}):null]}):e.jsxs(e.Fragment,{children:["Delete the local branch ",e.jsx("strong",{children:r.name}),"? This removes only the local branch, keeping every worktree and any remote copy. Git confirmed it is fully merged into ",e.jsx("strong",{children:r.comparisonBase}),"."]}),onConfirm:o,onCancel:p,onAct:()=>k(i)})]})}function Qe({details:r,busy:n,anyBusy:a,confirming:t,actionError:b,copied:j,onConfirm:o,onCancel:p,onRemove:k,onCopyPath:c,onOpen:i,onShowBranch:w}){const[g,E]=l.useState(!1),v=Pe(r),x=Ae(r),d=v.forceAllowed===!0,I=v.allowed||d;return l.useEffect(()=>E(!1),[r.path]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(se,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:U(r.path)}),e.jsx(V,{children:U(r.path)})]})]}),e.jsx(Y,{badges:ue(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Folder",children:e.jsx("span",{className:"local-refs-path local-refs-selectable",children:r.path})}),e.jsx(u,{label:"Branch",children:r.branch??"Detached HEAD"}),e.jsx(u,{label:"HEAD",children:r.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:r.lastCommit.shortOid})," ",r.lastCommit.subject]}):e.jsx("code",{children:r.oid?r.oid.slice(0,7):"—"})}),e.jsx(u,{label:"Committed",children:r.lastCommit?.date?ae(r.lastCommit.date,!0):"—"}),e.jsx(u,{label:"Local changes",children:r.available?x??"None":"Not readable"})]}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:c,disabled:a,children:[j?e.jsx(Oe,{}):e.jsx($e,{})," ",j?"Copied":"Copy path"]}),!r.current&&r.available&&!r.locked&&e.jsxs(f,{variant:"outline",size:"sm",onClick:i,disabled:a,children:[e.jsx(be,{})," Open worktree"]}),r.branch&&e.jsxs(f,{variant:"ghost",size:"sm",onClick:w,disabled:a,children:[e.jsx(M,{})," Show branch"]})]}),r.branch&&I&&e.jsxs("label",{htmlFor:"remove-worktree-delete-branch",className:"local-refs-delete-branch",children:[e.jsx(qe,{id:"remove-worktree-delete-branch",checked:g,onCheckedChange:L=>E(L===!0),disabled:a}),e.jsxs("span",{children:["Also delete branch ",e.jsx("strong",{children:r.branch})]})]}),e.jsx(xe,{tone:v.allowed?"ready":"blocked",reason:v.reason,actionError:b,confirming:t,busy:n,anyBusy:a,actionLabel:d?"Force remove worktree":"Remove worktree",confirmLabel:n?"Removing…":d?"Permanently remove":"Remove worktree",allowed:I,confirmation:e.jsxs(e.Fragment,{children:[d?e.jsxs(e.Fragment,{children:["Permanently remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? ",e.jsx("strong",{children:x??`The ${r.operation??"current Git operation"}`})," and every uncommitted file will be lost. The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}):e.jsxs(e.Fragment,{children:["Remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}),g&&r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," will also be force-deleted. Commits found only on that branch may become inaccessible."]}):r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," and its commits stay in the repository."]}):"No branch is deleted."]}),onConfirm:o,onCancel:p,onAct:()=>k(d,g)})]})}function xe({tone:r,reason:n,actionError:a,confirming:t,busy:b,anyBusy:j,allowed:o,actionLabel:p,confirmLabel:k,confirmation:c,onConfirm:i,onCancel:w,onAct:g}){return e.jsxs("div",{className:`local-refs-danger ${r}`,children:[a&&e.jsxs("p",{className:"local-refs-danger-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:a})]}),t&&o?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("p",{children:c}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(f,{variant:"destructive",size:"sm",onClick:g,disabled:b,children:[b?e.jsx(H,{className:"animate-spin"}):e.jsx(me,{})," ",k]}),e.jsx(f,{variant:"ghost",size:"sm",onClick:w,disabled:b,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[r==="ready"?e.jsx(Le,{"aria-hidden":"true"}):e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:n})]}),o&&e.jsxs(f,{variant:"destructive",size:"sm",onClick:i,disabled:j,children:[e.jsx(me,{})," ",p]})]})]})}function Y({badges:r}){return r.length===0?null:e.jsx("span",{className:"local-refs-badges",children:r.map(n=>e.jsx(Ie,{variant:n.tone==="current"?"default":n.tone==="warning"?"destructive":"outline",children:n.label},n.label))})}function u({label:r,children:n}){return e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:r}),e.jsx("dd",{children:n})]})}function He(r){switch(r){case"stale":return"The branch moved since this view loaded. It was refreshed; check the new state before deleting.";case"current":return"This branch is now checked out here, so Git will not delete it.";case"checked-out":return"Another worktree now has this branch checked out.";case"unmerged":return"Git found commits that are not in the comparison base, so the branch was kept.";case"unknown":return"The comparison base is not available locally, so the branch was kept.";default:return"The branch no longer exists."}}function Me(r){switch(r){case"stale":return"The worktree moved since this view loaded. It was refreshed; check the new state before removing.";case"main":return"Git can never remove the main worktree.";case"current":return"OpenTig has this worktree open. Switch to another one first.";case"dirty":return"The worktree has local changes or an operation in progress, so it was kept.";case"locked":return"The worktree is locked. Unlock it in Git first.";case"prunable":return"Git can no longer find this worktree on disk.";case"bare":return"This entry is a bare repository, not a removable worktree.";default:return"The worktree no longer exists."}}function Q(r){return r instanceof Error?r.message:String(r)}function ae(r,n=!1){const a=new Date(r);return Number.isNaN(a.getTime())?r:new Intl.DateTimeFormat("en",n?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(a)}export{rr as LocalRefsDialog};
|
|
1
|
+
import{r as l,j as e}from"./react-rd22PHbN.js";import{u as W}from"./tanstack-CtfgE41X.js";import{f as ve,a as Ne,b as F,w as B,n as ie,D as Ce,c as De,d as Te,e as Fe,g as he,I as de,h as M,i as se,j as Be,k as H,l as Se,m as O,o as Ee,p as U,q as ue,B as Ie,r as Re,s as Ge,t as be,u as Pe,v as Ae,x as Oe,y as me,z as Le}from"./App-9EfSdZB8.js";import{q as K,B as f,T as X,a as J,b as V,I as $e,w as ze,o as S}from"./index-CQcx9aRt.js";import{C as qe}from"./checkbox-DYwmgDPS.js";import{o as We}from"./gh-utils-LsOSydCg.js";import"./base-ui-DT3JsyND.js";function rr(r){const{open:n,tab:a,repositoryId:t,onMutated:b,onBusyChange:j}=r,[o,p]=l.useState(""),[k,c]=l.useState(!1),[i,w]=l.useState(null),[g,E]=l.useState(null),[v,x]=l.useState(null),[d,I]=l.useState(null),[L,N]=l.useState(null),[fe,$]=l.useState(!1),ne=l.useRef(null);l.useEffect(()=>{c(!1)},[n,t]);const D=W({queryKey:K.localRefs(t),queryFn:()=>S.refs.localRefsSnapshot(t),enabled:n}),m=D.data??null,z=D.isFetching,le=D.error?Q(D.error):null,Z=l.useMemo(()=>ve(m?.branches??[],o),[m,o]),_=l.useMemo(()=>Ne(m?.worktrees??[],o),[m,o]),R=Z.find(s=>F(s)===i)??null,G=_.find(s=>B(s)===g)??null,te=W({queryKey:K.branchDetails(t,R?.fullName??""),queryFn:()=>S.refs.branchDetails({repositoryId:t,fullName:R.fullName}),enabled:n&&a==="branches"&&R!==null}),y=te.data??null,je=W({queryKey:K.branchPullRequest(t,y?.name??""),queryFn:()=>S.github.findPullRequestForBranch(t,y.name),enabled:n&&a==="branches"&&y!==null&&(y.deletion==="unknown"||y.deletion==="unmerged")}).data??null,oe=W({queryKey:K.worktreeDetails(t,G?.path??""),queryFn:()=>S.refs.worktreeDetails({repositoryId:t,path:G.path}),enabled:n&&a==="worktrees"&&G!==null}),C=oe.data??null,ee=a==="branches"?te:oe,q=ee.isFetching,P=ee.error?Q(ee.error):null,A=l.useCallback(async()=>{await D.refetch()},[D]);l.useEffect(()=>{if(!m)return;const s=ne.current;ne.current=m,w(h=>ie(m.branches.map(F),(s?.branches??[]).map(F),h)),E(h=>ie(m.worktrees.map(B),(s?.worktrees??[]).map(B),h))},[m]),l.useEffect(()=>{n||(p(""),x(null),N(null),$(!1))},[n]),l.useEffect(()=>{x(null),N(null),$(!1)},[a,i,g]);const ce=async(s,h)=>{I(s),j(!0),N(null);try{await h()&&x(null)}catch(T){N(Q(T))}finally{I(null),j(!1)}},pe=(s,h)=>ce("delete-branch",async()=>{const T=await S.refs.deleteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,force:h});return T.status!=="deleted"?(N(He(T.status)),await A(),!1):(b(null),await A(),!0)}),we=(s,h,T)=>ce("remove-worktree",async()=>{const re=await S.refs.removeWorktree({repositoryId:t,path:s.path,expectedOid:s.oid,force:h,deleteBranch:T});return re.status!=="removed"?(N(Me(re.status)),await A(),!1):(b(re.recentRepositories),await A(),!0)}),ge=async s=>{try{await ze(s),$(!0),window.setTimeout(()=>$(!1),1600)}catch(h){N(Q(h))}},ke={branches:m?.branches.length??0,worktrees:m?.worktrees.length??0},ye=a==="branches"?Z.length===0:_.length===0;return e.jsx(Ce,{open:n,onOpenChange:r.onOpenChange,children:e.jsxs(De,{className:"local-refs-dialog",children:[e.jsxs("header",{className:"local-refs-header",children:[e.jsxs("div",{children:[e.jsx(Te,{children:"Local branches and worktrees"}),e.jsx(Fe,{children:"Inspect what this repository holds locally, and retire what Git can safely remove."})]}),e.jsx(he,{render:e.jsx(f,{variant:"ghost",size:"icon-sm","aria-label":"Close the local refs manager"}),children:e.jsx(de,{})})]}),e.jsxs("div",{className:"local-refs-toolbar",children:[e.jsx("div",{className:"local-refs-tabs",role:"tablist","aria-label":"Local refs",children:["branches","worktrees"].map(s=>e.jsxs("button",{type:"button",role:"tab",id:`local-refs-tab-${s}`,"aria-selected":a===s,"aria-controls":`local-refs-panel-${s}`,className:"local-refs-tab",onClick:()=>{r.onTabChange(s),c(!1)},children:[s==="branches"?e.jsx(M,{"aria-hidden":"true"}):e.jsx(se,{"aria-hidden":"true"}),e.jsx("span",{children:s==="branches"?"Branches":"Worktrees"}),e.jsx("small",{children:ke[s]})]},s))}),e.jsxs("div",{className:"local-refs-search",children:[e.jsx(Be,{"aria-hidden":"true"}),e.jsxs("label",{className:"sr-only",htmlFor:"local-refs-search-input",children:["Search ",a]}),e.jsx("input",{id:"local-refs-search-input",value:o,onChange:s=>p(s.target.value),placeholder:a==="branches"?"Search branches…":"Search worktrees…",autoComplete:"off",spellCheck:!1}),o&&e.jsx(f,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",onClick:()=>p(""),children:e.jsx(de,{})})]}),e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{A()},disabled:z||!!d,children:[z?e.jsx(H,{className:"animate-spin"}):e.jsx(Se,{})," Refresh"]})]}),le&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:le})]}),k&&e.jsxs("button",{type:"button",className:"local-refs-mobile-back",onClick:()=>c(!1),children:["← Back to ",a]}),e.jsxs("div",{className:"local-refs-body","data-mobile-detail":k,role:"tabpanel",id:`local-refs-panel-${a}`,"aria-labelledby":`local-refs-tab-${a}`,children:[e.jsxs("div",{className:"local-refs-list",role:"listbox","aria-label":a==="branches"?"Local branches":"Worktrees",tabIndex:-1,children:[z&&!m&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Reading the repository…"]}),!z&&ye&&e.jsx("p",{className:"local-refs-placeholder",children:o?"No matches for this search.":`This repository has no ${a==="branches"?"local branches":"worktrees"}.`}),a==="branches"&&Z.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":F(s)===i,className:"local-refs-row",onClick:()=>{w(F(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(M,{"aria-hidden":"true"}),e.jsx("strong",{children:s.name}),e.jsx(Y,{badges:Ee(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("code",{children:s.shortOid}),s.subject&&e.jsx("span",{children:s.subject}),s.date&&e.jsx("time",{dateTime:s.date,children:ae(s.date)})]})]}),e.jsxs(V,{children:[s.name,s.subject?` — ${s.subject}`:""]})]},F(s))),a==="worktrees"&&_.map(s=>e.jsxs(X,{children:[e.jsxs(J,{render:e.jsx("button",{type:"button",role:"option","aria-selected":B(s)===g,className:"local-refs-row",onClick:()=>{E(B(s)),c(!0)}}),children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(se,{"aria-hidden":"true"}),e.jsx("strong",{children:U(s.path)}),e.jsx(Y,{badges:ue(s)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("span",{className:"local-refs-row-branch",children:s.branch?`${s.branch}`:"Detached HEAD"}),e.jsx("span",{children:s.path})]})]}),e.jsxs(V,{children:[U(s.path)," — ",s.path]})]},B(s)))]}),e.jsxs("div",{className:"local-refs-detail",children:[P&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:P})]}),q&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(H,{className:"animate-spin","aria-hidden":"true"})," Loading details…"]}),!q&&!P&&a==="branches"&&y&&R&&e.jsx(Ke,{details:y,pullRequest:je,busy:d==="delete-branch",anyBusy:!!d,confirming:v==="delete-branch",actionError:L,onConfirm:()=>x("delete-branch"),onCancel:()=>x(null),onDelete:s=>{pe(y,s)}}),!q&&!P&&a==="worktrees"&&C&&G&&e.jsx(Qe,{details:C,busy:d==="remove-worktree",anyBusy:!!d,confirming:v==="remove-worktree",actionError:L,copied:fe,onConfirm:()=>x("remove-worktree"),onCancel:()=>x(null),onRemove:(s,h)=>{we(C,s,h)},onCopyPath:()=>{ge(C.path)},onOpen:()=>r.onOpenWorktree(C.path),onShowBranch:()=>{C.branch&&(w(`refs/heads/${C.branch}`),r.onTabChange("branches"))}}),!q&&!P&&!R&&!G&&e.jsxs("p",{className:"local-refs-placeholder",children:["Select a ",a==="branches"?"branch":"worktree"," to see its details."]})]})]},a),e.jsxs("footer",{className:"local-refs-footer",children:[e.jsx("small",{children:"Deleting a branch and removing a worktree are separate actions. A worktree removes its branch only when explicitly selected."}),e.jsx(he,{render:e.jsx(f,{variant:"outline",size:"sm",disabled:!!d}),children:"Done"})]})]})})}function Ke({details:r,pullRequest:n,busy:a,anyBusy:t,confirming:b,actionError:j,onConfirm:o,onCancel:p,onDelete:k}){const c=Re(r,n),i=c.forceAllowed===!0,w=c.allowed||i;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(M,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:r.name}),e.jsx(V,{children:r.name})]})]}),e.jsx(Y,{badges:Ge(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Full ref",children:e.jsx("code",{className:"local-refs-selectable",children:r.fullName})}),e.jsxs(u,{label:"Tip",children:[e.jsx("code",{children:r.shortOid})," ",r.subject]}),e.jsx(u,{label:"Author",children:r.author||"—"}),e.jsx(u,{label:"Last commit",children:r.date?ae(r.date,!0):"—"}),e.jsx(u,{label:"Upstream",children:r.upstream?`${r.upstream} · ↑${r.ahead} ↓${r.behind}`:"Not configured"}),e.jsx(u,{label:"Compared with",children:r.comparisonBase??"Not compared"}),n&&e.jsx(u,{label:"GitHub PR",children:e.jsxs("button",{type:"button",className:"local-refs-pr-link",onClick:()=>We(n.url),children:["#",n.number," · ",n.state==="MERGED"?`Merged into ${n.baseRefName}`:n.state==="OPEN"?"Open":"Closed"," ",e.jsx(be,{"aria-hidden":"true"})]})})]}),e.jsx(xe,{tone:c.allowed?"ready":"blocked",reason:c.reason,actionError:j,confirming:b,busy:a,anyBusy:t,actionLabel:i?"Force delete branch":"Delete branch",confirmLabel:a?"Deleting…":i?"Permanently delete":"Delete branch",allowed:w,confirmation:i?e.jsxs(e.Fragment,{children:["Force-delete the local branch ",e.jsx("strong",{children:r.name}),"? This keeps any remote branch and pull request, but commits found only on this local branch may become inaccessible. ",n?.state==="MERGED"?e.jsxs(e.Fragment,{children:["GitHub reports PR ",e.jsxs("strong",{children:["#",n.number]})," as merged into ",e.jsx("strong",{children:n.baseRefName}),", although local Git cannot verify the ancestry."]}):null]}):e.jsxs(e.Fragment,{children:["Delete the local branch ",e.jsx("strong",{children:r.name}),"? This removes only the local branch, keeping every worktree and any remote copy. Git confirmed it is fully merged into ",e.jsx("strong",{children:r.comparisonBase}),"."]}),onConfirm:o,onCancel:p,onAct:()=>k(i)})]})}function Qe({details:r,busy:n,anyBusy:a,confirming:t,actionError:b,copied:j,onConfirm:o,onCancel:p,onRemove:k,onCopyPath:c,onOpen:i,onShowBranch:w}){const[g,E]=l.useState(!1),v=Pe(r),x=Ae(r),d=v.forceAllowed===!0,I=v.allowed||d;return l.useEffect(()=>E(!1),[r.path]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(se,{"aria-hidden":"true"}),e.jsxs(X,{children:[e.jsx(J,{render:e.jsx("span",{}),children:U(r.path)}),e.jsx(V,{children:U(r.path)})]})]}),e.jsx(Y,{badges:ue(r)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(u,{label:"Folder",children:e.jsx("span",{className:"local-refs-path local-refs-selectable",children:r.path})}),e.jsx(u,{label:"Branch",children:r.branch??"Detached HEAD"}),e.jsx(u,{label:"HEAD",children:r.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:r.lastCommit.shortOid})," ",r.lastCommit.subject]}):e.jsx("code",{children:r.oid?r.oid.slice(0,7):"—"})}),e.jsx(u,{label:"Committed",children:r.lastCommit?.date?ae(r.lastCommit.date,!0):"—"}),e.jsx(u,{label:"Local changes",children:r.available?x??"None":"Not readable"})]}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:c,disabled:a,children:[j?e.jsx(Oe,{}):e.jsx($e,{})," ",j?"Copied":"Copy path"]}),!r.current&&r.available&&!r.locked&&e.jsxs(f,{variant:"outline",size:"sm",onClick:i,disabled:a,children:[e.jsx(be,{})," Open worktree"]}),r.branch&&e.jsxs(f,{variant:"ghost",size:"sm",onClick:w,disabled:a,children:[e.jsx(M,{})," Show branch"]})]}),r.branch&&I&&e.jsxs("label",{htmlFor:"remove-worktree-delete-branch",className:"local-refs-delete-branch",children:[e.jsx(qe,{id:"remove-worktree-delete-branch",checked:g,onCheckedChange:L=>E(L===!0),disabled:a}),e.jsxs("span",{children:["Also delete branch ",e.jsx("strong",{children:r.branch})]})]}),e.jsx(xe,{tone:v.allowed?"ready":"blocked",reason:v.reason,actionError:b,confirming:t,busy:n,anyBusy:a,actionLabel:d?"Force remove worktree":"Remove worktree",confirmLabel:n?"Removing…":d?"Permanently remove":"Remove worktree",allowed:I,confirmation:e.jsxs(e.Fragment,{children:[d?e.jsxs(e.Fragment,{children:["Permanently remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? ",e.jsx("strong",{children:x??`The ${r.operation??"current Git operation"}`})," and every uncommitted file will be lost. The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}):e.jsxs(e.Fragment,{children:["Remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:r.path}),"? The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}),g&&r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," will also be force-deleted. Commits found only on that branch may become inaccessible."]}):r.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:r.branch})," and its commits stay in the repository."]}):"No branch is deleted."]}),onConfirm:o,onCancel:p,onAct:()=>k(d,g)})]})}function xe({tone:r,reason:n,actionError:a,confirming:t,busy:b,anyBusy:j,allowed:o,actionLabel:p,confirmLabel:k,confirmation:c,onConfirm:i,onCancel:w,onAct:g}){return e.jsxs("div",{className:`local-refs-danger ${r}`,children:[a&&e.jsxs("p",{className:"local-refs-danger-error",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:a})]}),t&&o?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(O,{"aria-hidden":"true"}),e.jsx("p",{children:c}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(f,{variant:"destructive",size:"sm",onClick:g,disabled:b,children:[b?e.jsx(H,{className:"animate-spin"}):e.jsx(me,{})," ",k]}),e.jsx(f,{variant:"ghost",size:"sm",onClick:w,disabled:b,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[r==="ready"?e.jsx(Le,{"aria-hidden":"true"}):e.jsx(O,{"aria-hidden":"true"}),e.jsx("span",{children:n})]}),o&&e.jsxs(f,{variant:"destructive",size:"sm",onClick:i,disabled:j,children:[e.jsx(me,{})," ",p]})]})]})}function Y({badges:r}){return r.length===0?null:e.jsx("span",{className:"local-refs-badges",children:r.map(n=>e.jsx(Ie,{variant:n.tone==="current"?"default":n.tone==="warning"?"destructive":"outline",children:n.label},n.label))})}function u({label:r,children:n}){return e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:r}),e.jsx("dd",{children:n})]})}function He(r){switch(r){case"stale":return"The branch moved since this view loaded. It was refreshed; check the new state before deleting.";case"current":return"This branch is now checked out here, so Git will not delete it.";case"checked-out":return"Another worktree now has this branch checked out.";case"unmerged":return"Git found commits that are not in the comparison base, so the branch was kept.";case"unknown":return"The comparison base is not available locally, so the branch was kept.";default:return"The branch no longer exists."}}function Me(r){switch(r){case"stale":return"The worktree moved since this view loaded. It was refreshed; check the new state before removing.";case"main":return"Git can never remove the main worktree.";case"current":return"OpenTig has this worktree open. Switch to another one first.";case"dirty":return"The worktree has local changes or an operation in progress, so it was kept.";case"locked":return"The worktree is locked. Unlock it in Git first.";case"prunable":return"Git can no longer find this worktree on disk.";case"bare":return"This entry is a bare repository, not a removable worktree.";default:return"The worktree no longer exists."}}function Q(r){return r instanceof Error?r.message:String(r)}function ae(r,n=!1){const a=new Date(r);return Number.isNaN(a.getTime())?r:new Intl.DateTimeFormat("en",n?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(a)}export{rr as LocalRefsDialog};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-C0FKucv-.js","assets/index-CQcx9aRt.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-DMbFAH51.css","assets/render-markdown-2GjhuGA-.js","assets/App-9EfSdZB8.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as n,j as r,a as ae}from"./react-rd22PHbN.js";import{c as J,_ as se,w as ie,s as ce,e as le,T as H,a as $,b as q,o as ue}from"./index-CQcx9aRt.js";import{J as de,G as me}from"./App-9EfSdZB8.js";import{V as pe,a as fe,b as B}from"./viewer-tabs-DkLmDzFg.js";import{u as he,s as we,F as ge,S as ve}from"./EditableFileViewer-85aEeMBK.js";import{r as be}from"./render-markdown-2GjhuGA-.js";/* empty css */import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-DH2jp9oe.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-DTtWrbYf.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ke=[["path",{d:"M3 12h7l-3 -3",key:"svg-0"}],["path",{d:"M7 15l3 -3",key:"svg-1"}],["path",{d:"M21 12h-7l3 -3",key:"svg-2"}],["path",{d:"M17 15l-3 -3",key:"svg-3"}],["path",{d:"M9 6v-1a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M9 18v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ye=J("outline","viewport-narrow","ViewportNarrow",ke);const Ce=[["path",{d:"M10 12h-7l3 -3",key:"svg-0"}],["path",{d:"M6 15l-3 -3",key:"svg-1"}],["path",{d:"M14 12h7l-3 -3",key:"svg-2"}],["path",{d:"M18 15l3 -3",key:"svg-3"}],["path",{d:"M3 6v-1a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M3 18v1a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],xe=J("outline","viewport-wide","ViewportWide",Ce);function F(m,s){const p=s.trim();if(!p||p.startsWith("#")||p.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(p))return null;const h=p.split(/[?#]/,1)[0];if(!h)return null;let c;try{c=decodeURIComponent(h).replaceAll("\\","/")}catch{return null}const l=c.startsWith("/")?[]:m.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const t of c.split("/"))if(!(!t||t===".")){if(t===".."){if(l.length===0)return null;l.pop();continue}if(Me(t))return null;l.push(t)}return l.length>0?l.join("/"):null}function Me(m){return[...m].some(s=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)}function Te(m,s,p,h,c){const l=document.createElement("template");l.innerHTML=s;const t=new Map;for(const e of l.content.querySelectorAll("img[src]")){if(e.classList.contains("markdown-code-icon"))continue;const i=e.getAttribute("src").trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(i))continue;e.removeAttribute("src"),e.removeAttribute("srcset");const u=F(h,i);if(!u)continue;const v=t.get(u)??[];v.push(e),t.set(u,v)}m.replaceChildren(l.content);let g=!1;const w=[];for(const[e,i]of t)(async()=>{let u;if(de(e)){const f=await c.readFile(p,e);if(f.binary||f.tooLarge)return;u=new Blob([f.content],{type:"image/svg+xml"})}else{const f=await c.readImage(p,e);if(f.status!=="ready")return;u=new Blob([new Uint8Array(f.data)],{type:f.mimeType})}if(g)return;const v=URL.createObjectURL(u);w.push(v);for(const f of i)f.src=v})().catch(()=>{});return()=>{g=!0;for(const e of w)URL.revokeObjectURL(e)}}let Se=0;function K(){return document.documentElement.classList.contains("dark")?"dark":"default"}function Re(m,s,p){const[h,c]=n.useState(K);n.useEffect(()=>{const t=new MutationObserver(()=>c(K()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const l=n.useCallback(async t=>{if(!m.current)return;const g=Array.from(m.current.querySelectorAll(".mermaid"));if(g.length!==0)try{const{default:w}=await se(async()=>{const{default:e}=await import("./mermaid.core-C0FKucv-.js").then(i=>i.bo);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t()||!m.current)return;w.initialize({startOnLoad:!1,theme:h,securityLevel:"strict"});for(const e of g){const i=e.dataset.mermaidSource;if(i){e.removeAttribute("data-mermaid-error");try{const u=decodeURIComponent(i),v=`mermaid-diagram-${Se++}`,{svg:f,bindFunctions:A}=await w.render(v,u,e);if(t()||!e.isConnected)return;e.innerHTML=f,e.dataset.processed="true",A?.(e)}catch{!t()&&e.isConnected&&(e.textContent=decodeURIComponent(i),e.dataset.mermaidError="Could not render diagram")}}}}catch{for(const w of g)!t()&&w.isConnected&&(w.dataset.mermaidError="Could not load Mermaid")}},[s,m,h]);n.useEffect(()=>{let t=!1;return l(()=>t),()=>{t=!0}},[p,l])}const X="opentig:markdown-content-width",G=/^([a-z][a-z0-9+.-]*:)?\/\//i,je={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Ee(){try{return window.localStorage.getItem(X)==="fit"?"fit":"reading"}catch{return"reading"}}function Ae({html:m,repositoryId:s,markdownPath:p,onClick:h,onLinkHover:c}){const l=n.useRef(null),t=n.useRef(null);n.useLayoutEffect(()=>{const e=l.current?Te(l.current,m,s,p,ue.repository):void 0;return t.current=null,c(null),e},[m,s,p,c]),Re(l,!0,m);const g=n.useCallback(e=>{const i=e.target.closest("a[href]");!i||i===t.current||(t.current=i,c(i))},[c]),w=n.useCallback(e=>{const i=t.current;if(!i)return;const u=e.relatedTarget;u&&i.contains(u)||(t.current=null,c(null))},[c]);return r.jsx("div",{ref:l,className:"markdown-prose",onClick:h,onMouseOver:g,onMouseOut:w})}function Ge({repositoryId:m,file:s,initialContent:p,revision:h,themeType:c,wrapLines:l,readOnly:t,onOpenFile:g,onDirtyChange:w,onDraftChange:e,onSave:i}){const[u,v]=n.useState("preview"),[f,A]=n.useState(Ee),[T,O]=n.useState(""),[_,I]=n.useState(!0),[Y,V]=n.useState(!1),[M,k]=n.useState(null),S=n.useRef(0),C=n.useRef(null),N=n.useRef(null),L=n.useRef(null),x=n.useRef(null),R=n.useRef(null),{draft:P,updateDraft:Q,dirty:j,saving:U,save:Z}=he({file:s,initialContent:p,readOnly:t,messages:je,onDirtyChange:w,onDraftChange:e,onSave:i});n.useEffect(()=>{R.current?.(),x.current=null,v("preview")},[s.path]);const ee=n.useCallback(a=>{if(a!==u){if(R.current?.(),u==="preview"){const o=N.current,d=o?o.scrollHeight-o.clientHeight:0;x.current=o&&d>0?o.scrollTop/d:0}else x.current=L.current?.getScrollFraction()??0;v(a)}},[u]);n.useLayoutEffect(()=>{const a=x.current;if(a==null)return;if(u==="code"){x.current=null,L.current?.scrollToFraction(a);return}const o=N.current;!o||_&&!T||(x.current=null,R.current=we({getScrollRange:()=>Math.max(0,o.scrollHeight-o.clientHeight),getScrollTop:()=>o.scrollTop,getContentHeight:()=>o.scrollHeight,scrollTo:d=>{o.scrollTop=d}},a))},[T,_,u]),n.useEffect(()=>()=>R.current?.(),[]),n.useEffect(()=>{const a=++S.current;I(!0);const o=window.setTimeout(()=>{const d=window.__opentigPerformanceAutomation?performance.now():null;be(P).then(b=>{a===S.current&&(O(b),d!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-d)*100)/100})))}).catch(()=>{a===S.current&&O("<p>Could not render Markdown.</p>")}).finally(()=>{a===S.current&&I(!1)})},j?120:0);return()=>window.clearTimeout(o)},[j,P,s.mtimeMs,s.path,h,c]),n.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current.timer)},[]);const te=n.useCallback(async a=>{const o=a.target,d=o.closest("[data-copy-code]");if(d){const W=d.dataset.copyCode;if(!W)return;try{const ne=decodeURIComponent(W);await ie(ne);const E=C.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),d.dataset.copyState="copied",d.setAttribute("aria-label","Copied"),V(!0);const oe=window.setTimeout(()=>{C.current?.button===d&&(delete d.dataset.copyState,d.setAttribute("aria-label","Copy code"),C.current=null,V(!1))},2e3);C.current={button:d,timer:oe}}catch{ce.error({title:"Could not copy code"})}return}const b=o.closest("a[href]"),y=b?.getAttribute("href");if(!b||!y)return;if(a.preventDefault(),y.startsWith("#")){a.currentTarget.querySelector(`#${CSS.escape(y.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if(G.test(y)||y.startsWith("mailto:")){try{le(y)}catch{}return}const z=F(s.path,y);z&&g(z)},[s.path,g]),re=n.useCallback(a=>{if(!a){k(null);return}const o=a.getAttribute("href");if(!o||o.startsWith("#")){k(null);return}const d=a.getBoundingClientRect(),b={top:d.bottom+6,left:d.left};if(o.startsWith("mailto:")){k({...b,label:"Open in mail app",href:o.replace(/^mailto:/,"")});return}if(G.test(o)){k({...b,label:"Open in browser",href:o});return}if(F(s.path,o)){k({...b,label:"Open file",href:o});return}k(null)},[s.path]),D=a=>{A(a);try{window.localStorage.setItem(X,a)}catch{}};return r.jsxs(pe,{value:u,onValueChange:a=>ee(a),className:"markdown-viewer","data-content-width":f,children:[r.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[r.jsx(fe,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:r.jsxs(r.Fragment,{children:["Code ",j&&r.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),r.jsx(ge,{dirty:j,saving:U,readOnly:t,onSave:()=>{Z()}}),r.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":f==="reading",onClick:()=>D("reading")}),children:r.jsx(ye,{"aria-hidden":"true"})}),r.jsx(q,{children:"Reading width"})]}),r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":f==="fit",onClick:()=>D("fit")}),children:r.jsx(xe,{"aria-hidden":"true"})}),r.jsx(q,{children:"Fit to width"})]})]})]}),r.jsxs(B,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>k(null),children:[_&&!T?r.jsx("div",{className:"viewer-message",children:r.jsx(me,{text:"Rendering Markdown…"})}):r.jsx(Ae,{repositoryId:m,markdownPath:s.path,html:T,onClick:a=>{te(a)},onLinkHover:re},`${m}:${s.path}:${h}`),r.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:Y?"Code copied":""}),M?ae.createPortal(r.jsxs("div",{className:"markdown-link-tooltip",style:{top:M.top,left:M.left},role:"tooltip",children:[r.jsx("span",{className:"markdown-link-tooltip-label",children:M.label}),r.jsx("span",{className:"markdown-link-tooltip-href",children:M.href})]}),document.body):null]}),r.jsx(B,{value:"code",className:"markdown-code-view","data-theme":c,children:r.jsx(ve,{ref:L,path:s.path,cacheKey:s.path,value:P,themeType:c,wrapLines:l,readOnly:t||U,onChange:Q})})]})}export{Ge as MarkdownFileViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as e}from"./react-rd22PHbN.js";import{B as g,f as b,P as w}from"./index-
|
|
1
|
+
import{r as o,j as e}from"./react-rd22PHbN.js";import{B as g,f as b,P as w}from"./index-CQcx9aRt.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";async function v(a,i=fetch){try{const t=await i("/api/auth/descriptor",{credentials:"include",cache:"no-store",signal:a});if(!t.ok)return"unavailable";const n=await t.json();return!n||typeof n!="object"||!("authenticated"in n)?"unavailable":n.authenticated===!0?"authenticated":n.authenticated===!1?"unpaired":"unavailable"}catch{return"unavailable"}}function y(a,i){const t=a.hash;return i.replaceState(null,"",`${a.pathname}${a.search}`),new URLSearchParams(t.startsWith("#")?t.slice(1):t).get("token")??""}async function j(a,i,t=fetch){try{return(await t("/api/auth/pair",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,clientName:i})})).ok?"paired":"rejected"}catch{return"unavailable"}}function k(a){const i=[[/Edg\//,"Edge"],[/Firefox\//,"Firefox"],[/OPR\//,"Opera"],[/Chrome\//,"Chrome"],[/Safari\//,"Safari"]].find(([n])=>n.test(a))?.[1]??"Browser",t=[[/Windows NT/,"Windows"],[/Android/,"Android"],[/(?:iPhone|iPod)/,"iPhone"],[/iPad/,"iPad"],[/CrOS/,"ChromeOS"],[/Macintosh|Mac OS X/,"Mac"],[/Linux/,"Linux"]].find(([n])=>n.test(a))?.[1];return t?`${i} on ${t}`:i}const N={rejected:"This code is invalid, expired, or already used. Create a new one from OpenTig.",unavailable:"OpenTig could not complete pairing. Check the server and try again."};function O(){const[a,i]=o.useState(()=>y(window.location,window.history)),[t,n]=o.useState(()=>k(window.navigator.userAgent)),[c,m]=o.useState("idle"),[u,h]=o.useState("checking"),[p,f]=o.useState(0);o.useEffect(()=>{const r=new AbortController;let s=!0;const d=window.setTimeout(()=>r.abort(),1e4);return v(r.signal).then(l=>{s&&(l==="authenticated"&&window.location.replace("/"),h(l))}).finally(()=>window.clearTimeout(d)),()=>{s=!1,r.abort(),window.clearTimeout(d)}},[p]);const x=async r=>{r.preventDefault();const s=t.trim(),d=a.trim();if(!s||!d||s.length>64)return;m("pairing");const l=await j(d,s);l==="paired"?window.location.replace("/"):m(l)};return u!=="unpaired"?e.jsx("main",{className:"access-page pairing-page flex min-h-dvh items-center justify-center bg-background px-4 py-6 text-foreground",children:e.jsxs("section",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"text-lg font-semibold",children:u==="unavailable"?"Could not check this browser":"Checking this browser…"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",role:"status",children:u==="unavailable"?"Could not verify your saved session. Check your connection and try again.":"Checking your saved session before asking you to pair again."}),u==="unavailable"&&e.jsx(g,{className:"mt-5",onClick:()=>{h("checking"),f(r=>r+1)},children:"Try again"})]})}):e.jsx("main",{className:"access-page pairing-page flex min-h-dvh items-center justify-center bg-background px-4 py-6 text-foreground",children:e.jsxs("section",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Pair this browser"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Enter the one-use code shown by the ",b," desktop app or generated with the command below on the server. It expires after five minutes."]}),e.jsx(w,{}),e.jsxs("form",{className:"mt-5 grid gap-4",onSubmit:r=>{x(r)},children:[e.jsxs("label",{className:"grid gap-1.5 text-sm",htmlFor:"pairing-code",children:[e.jsx("span",{className:"font-medium",children:"Pairing code"}),e.jsx("input",{id:"pairing-code",className:"h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 font-mono text-base outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",value:a,onChange:r=>i(r.target.value),autoComplete:"off",spellCheck:!1,required:!0})]}),e.jsxs("label",{className:"grid gap-1.5 text-sm",htmlFor:"device-name",children:[e.jsx("span",{className:"font-medium",children:"Device name"}),e.jsx("input",{id:"device-name",className:"h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 text-base outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",value:t,onChange:r=>n(r.target.value),maxLength:64,autoComplete:"off",required:!0})]}),e.jsx(g,{type:"submit",disabled:c==="pairing"||!a.trim()||!t.trim(),children:c==="pairing"?"Pairing…":"Pair browser"})]}),(c==="rejected"||c==="unavailable")&&e.jsx("p",{className:"mt-4 text-sm text-destructive",role:"alert",children:N[c]}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"The code is removed from the address bar immediately and is never stored by the browser."}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"This browser remembers its access and renews it automatically while you use OpenTig. Pair again after 30 days without renewal, clearing cookies, or revoking access."})]})})}export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as k,j as g}from"./react-rd22PHbN.js";import{t as w,a6 as E,n as Y,a7 as j,a8 as O,B as Z,d as M,E as ee,A as ne,a3 as te,_ as ie,a4 as R,a5 as oe,P as re,a as se,V as T,O as U,r as $}from"./PierreWorkerPool-DH2jp9oe.js";import{F as le}from"./File-DTtWrbYf.js";import{D as V,b as P,f as ce}from"./platform-Bqt97_Jr.js";import{a as de,g as J,b as Q,F as ae,p as b,c as ue,s as fe,r as he,D as pe}from"./DiffWorkspace-Ca2ZUlVn.js";import{a as H}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-CQcx9aRt.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-9EfSdZB8.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";var _=class extends de{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:V},n,t){super(void 0,n,t),this.options=e}setConflictState(e,n,t){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,t)}syncInjectedRows(e,n,t){this.injectedRows.clear();for(const i of e){const r=i!=null?J(i,t):void 0;if(i==null||r==null)continue;const o={type:"actions",hunkIndex:r.hunkIndex,lineIndex:r.lineIndex,conflictIndex:i.conflictIndex};this.addInjectedRow(o)}for(const i of n)this.addInjectedRow(i)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,t=this.injectedRows.get(n);t==null?this.injectedRows.set(n,[e]):t.push(e)}renderDiff(e,n=P){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=P){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const t=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:B(t),contentProperties:W(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:B(t),contentProperties:W(n,t)}}getUnifiedInjectedRowsForLine=e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:t}=this.getOptionsWithDefaults(),i=[],r=[];for(const o of n){if(o.type==="actions"){i.push({content:Ce({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:G("action")});continue}(o.type==="marker-end"?r:i).push({content:me(o),gutter:G("marker",o.type)})}return{before:i.length>0?i:void 0,after:r.length>0?r:void 0}};getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function B(e){return e!=null?{"data-merge-conflict":e}:void 0}function W(e,n){if(n!=null){if(e==="change")return n==="current"||n==="incoming"?{"data-line-type":"context","data-merge-conflict":n}:void 0;if(n==="marker-start"||n==="marker-base"||n==="marker-separator"||n==="marker-end")return{"data-merge-conflict":n}}}function G(e,n){const t=Y(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function Ce({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?xe(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Q({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:e.conflictIndex}),"data-merge-conflict-action-slot":""}})),w({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[w({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function me(e){return w({tagName:"div",properties:{"data-merge-conflict":e.type,"data-merge-conflict-marker-row":""},children:[E(e.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function xe(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),K(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),K(),y({resolution:"both",label:"Accept both",conflictIndex:e})]}function y({resolution:e,label:n,conflictIndex:t}){return w({tagName:"button",properties:{type:"button","data-merge-conflict-action":e,"data-merge-conflict-conflict-index":`${t}`},children:[E(n)]})}function K(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function ge(e,n){return e.hunkIndex===n.hunkIndex&&e.startContentIndex===n.startContentIndex&&e.endContentIndex===n.endContentIndex&&e.currentContentIndex===n.currentContentIndex&&e.baseContentIndex===n.baseContentIndex&&e.incomingContentIndex===n.incomingContentIndex&&e.endMarkerContentIndex===n.endMarkerContentIndex&&e.conflictIndex===n.conflictIndex&&Le(e.conflict,n.conflict)}function Le(e,n){return e.conflictIndex===n.conflictIndex&&e.startLineIndex===n.startLineIndex&&e.startLineNumber===n.startLineNumber&&e.separatorLineIndex===n.separatorLineIndex&&e.separatorLineNumber===n.separatorLineNumber&&e.endLineIndex===n.endLineIndex&&e.endLineNumber===n.endLineNumber&&e.baseMarkerLineIndex===n.baseMarkerLineIndex&&e.baseMarkerLineNumber===n.baseMarkerLineNumber}function Ie(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function ve(e,n){const{resolution:t,hunkIndex:i,startContentIndex:r,endContentIndex:o,indexesToDelete:s=new Set}=n,l=e.hunks[i];if(l==null)throw console.error({diff:e,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||o>=l.hunkContent.length||r>o)throw new Error(`resolveRegion: Invalid content range, ${r}, ${o}`);const{hunks:d,additionLines:a,deletionLines:f}=e,h={...e,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:e.cacheKey!=null?`${e.cacheKey}:${t[0]}-${i}:${r}-${o}`:void 0},u={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},L=i===d.length-1&&o===l.hunkContent.length-1,A=!e.isPartial;for(const[p,x]of d.entries()){ke(e,h,u,j(x.deletionStart,x.deletionCount)-x.collapsedBefore,j(x.additionStart,x.additionCount)-x.collapsedBefore,x.collapsedBefore,A);const c={...x,hunkContent:[],additionStart:u.nextAdditionStart,deletionStart:u.nextDeletionStart,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:u.splitLineCount,unifiedLineStart:u.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[m,C]of x.hunkContent.entries())if(p!==i||m<r||m>o){z(C,h,f,a);const v={...C,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex};c.hunkContent.push(v),S(v,u,c)}else if(s.has(m))c.hunkContent.push({type:"context",lines:0,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex});else if(C.type==="context"){z(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{Ae(t,C,h,f,a);const v={type:"context",lines:t==="deletions"?C.deletions:t==="additions"?C.additions:C.deletions+C.additions,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}if(p===i&&L){const m=t==="deletions"?x.noEOFCRDeletions:x.noEOFCRAdditions;c.noEOFCRAdditions=m,c.noEOFCRDeletions=m}c.additionCount===0&&(c.additionStart--,e.isPartial||c.additionLineIndex--),c.deletionCount===0&&(c.deletionStart--,e.isPartial||c.deletionLineIndex--),h.hunks.push(c)}const I=d.at(-1);if(I!=null&&!e.isPartial){const p=O(I.deletionStart,I.deletionCount),x=O(I.additionStart,I.additionCount),c=Math.min(f.length-p,a.length-x);X(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function X(e,n,t,i,r,o){for(let s=0;s<o;s++){const l=n[i+s],d=t[r+s];if(l==null||d==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");e.deletionLines.push(l),e.additionLines.push(d)}}function ke(e,n,t,i,r,o,s){o<=0||(s&&(X(n,e.deletionLines,e.additionLines,i,r,o),t.nextAdditionLineIndex+=o,t.nextDeletionLineIndex+=o),t.nextAdditionStart+=o,t.nextDeletionStart+=o,t.splitLineCount+=o,t.unifiedLineCount+=o)}function z(e,n,t,i){if(e.type==="context")for(let r=0;r<e.lines;r++){const o=i[e.additionLineIndex+r];if(o==null)throw console.error({additionLines:i,content:e,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}else{const r=Math.max(e.deletions,e.additions);for(let o=0;o<r;o++){if(o<e.deletions){const s=t[e.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:t,content:e,i:o}),new Error("pushContentLinesToDiff: Deletion line does not exist");n.deletionLines.push(s)}if(o<e.additions){const s=i[e.additionLineIndex+o];if(s==null)throw console.error({additionLines:i,content:e,i:o}),new Error("pushContentLinesToDiff: Addition line does not exist");n.additionLines.push(s)}}}}function Ae(e,n,t,i,r){if(e==="deletions"||e==="both")for(let o=0;o<n.deletions;o++){const s=i[n.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:i,content:n,i:o}),new Error("pushResolveLinesToDiff: Deletion line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}if(e==="additions"||e==="both")for(let o=0;o<n.additions;o++){const s=r[n.additionLineIndex+o];if(s==null)throw console.error({additionLines:r,content:n,i:o}),new Error("pushResolveLinesToDiff: Addition line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}}function S(e,n,t){e.type==="context"?(n.nextAdditionLineIndex+=e.lines,n.nextDeletionLineIndex+=e.lines,n.nextAdditionStart+=e.lines,n.nextDeletionStart+=e.lines,n.splitLineCount+=e.lines,n.unifiedLineCount+=e.lines,t.additionCount+=e.lines,t.deletionCount+=e.lines,t.splitLineCount+=e.lines,t.unifiedLineCount+=e.lines):(n.nextAdditionLineIndex+=e.additions,n.nextDeletionLineIndex+=e.deletions,n.nextAdditionStart+=e.additions,n.nextDeletionStart+=e.deletions,n.splitLineCount+=Math.max(e.deletions,e.additions),n.unifiedLineCount+=e.deletions+e.additions,t.deletionCount+=e.deletions,t.deletionLines+=e.deletions,t.additionCount+=e.additions,t.additionLines+=e.additions,t.splitLineCount+=Math.max(e.deletions,e.additions),t.unifiedLineCount+=e.deletions+e.additions)}function we(e,n,t){return ve(e,{resolution:Ie(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:Re(n)})}function Re(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let De=-1;var Me=class extends ae{options;__id=`unresolved-file:${++De}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:V},t,i=!1){super(void 0,t,i),this.options=n,this.setOptions(n)}setOptions(n){if(n!=null){if(n.onMergeConflictAction!=null&&n.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=n,this.hunksRenderer.setOptions(this.getHunksRendererOptions(n)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions(Z(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex,this.handleMergeConflictActionClick))}createHunksRenderer(n){return new _(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Te(n,this.options)}applyPreNodeAttributes(n,t){super.applyPreNodeAttributes(n,t,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:n,fileDiff:t,actions:i,markerRows:r}){const{maxContextLines:o,onMergeConflictAction:s}=this.options;e:if(s!=null){const l=t!=null;if(l!==(i!=null)||l!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(t!=null&&i!=null&&r!=null){this.computedCache={file:n??this.computedCache.file,fileDiff:t,actions:i,markerRows:r};break e}else if(n!=null||this.computedCache.file!=null){if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(n??=this.computedCache.file,n==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!M(n,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=b(n,o);this.computedCache={file:n,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(t!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if(this.computedCache.file??=n,this.computedCache.fileDiff==null&&this.computedCache.file!=null){const l=b(this.computedCache.file,o);this.computedCache.fileDiff=l.fileDiff,this.computedCache.actions=l.actions,this.computedCache.markerRows=l.markerRows}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(t==null||i==null||r==null))return{fileDiff:t,actions:i,markerRows:r}}hydrate(n){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,fileContainer:l,prerenderedHTML:d,preventEmit:a=!1}=n,f=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});f!=null&&(this.hydrateElements(l,d),this.setActiveMergeConflictState(f.actions,f.markerRows),je(this.pre,f.fileDiff,this.options.collapsed)||Oe(this.headerElement,f.fileDiff,this.options.disableFileHeader)?this.render({...n,preventEmit:!0}):(this.hydrationSetup({fileDiff:f.fileDiff,lineAnnotations:s}),this.pre!=null&&this.renderMergeConflictActionSlots()),a||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(n={}){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,preventEmit:l=!1,...d}=n,a=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});if(a==null)return!1;this.setActiveMergeConflictState(a.actions,a.markerRows);const f=super.render({...d,fileDiff:a.fileDiff,lineAnnotations:s,preventEmit:!0});return f&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),f}resolveConflict(n,t,i=this.computedCache.fileDiff){const r=this.conflictActions[n];if(i==null||r==null)return;if(r.conflictIndex!==n)throw console.error({conflictIndex:n,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const o=we(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=ye({fileDiff:o,previousActions:this.conflictActions,resolvedConflictIndex:n,previousFile:s,resolution:t});return{file:l,fileDiff:o,actions:d,markerRows:a}}resolveConflictAndRender(n,t){const i=this.conflictActions[n];if(i==null)return;if(i.conflictIndex!==n)throw console.error({conflictIndex:n,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:t,conflict:i.conflict},{file:o,fileDiff:s,actions:l,markerRows:d}=this.resolveConflict(n,t)??{};o==null||s==null||l==null||d==null||(this.computedCache={file:o,fileDiff:s,actions:l,markerRows:d},this.setActiveMergeConflictState(l,d),this.workerManager!=null?this.hunksRenderer.renderDiff(s):this.render({forceRender:!0}),this.options.onMergeConflictResolve?.(o,r))}setActiveMergeConflictState(n=this.conflictActions,t=this.markerRows){this.conflictActions=n,this.markerRows=t,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof _&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:n,t,this.computedCache.fileDiff)}handleMergeConflictActionClick=n=>{const t=this.conflictActions[n.conflictIndex];if(t==null)return;if(t.conflictIndex!==n.conflictIndex)throw console.error({conflictIndex:n.conflictIndex,action:t}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:n.resolution,conflict:t.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(n.conflictIndex,n.resolution)};renderMergeConflictActionSlots(){const{fileDiff:n}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||n==null){this.clearMergeConflictActionCache();return}const t=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const o=J(r,n);if(o==null)continue;const s=r.conflictIndex,l=Q({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!ge(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=ee(l);h.appendChild(f),this.fileContainer.appendChild(h),a={element:h,action:r},this.conflictActionCache.set(d,a)}t.delete(d)}for(const[i,{element:r}]of t.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(n){if(typeof this.options.mergeConflictActionsType!="function")return;const t=this.options.mergeConflictActionsType(n,this);if(t!=null){if(t instanceof HTMLElement)return t;if(typeof DocumentFragment<"u"&&t instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(t),i}}}clearMergeConflictActionCache(){for(const{element:n}of this.conflictActionCache.values())n.remove();this.conflictActionCache.clear()}};function ye({fileDiff:e,previousActions:n,resolvedConflictIndex:t,previousFile:i,resolution:r}){const o=n[t];if(o==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const s=Ee(n,t,o,r),l=ue(e,s);return{file:Se({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function Se({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=fe(t?.contents??""),{conflict:s}=e,l=be(o,s,r),d=[...o.slice(0,s.startLineIndex),...l,...o.slice(s.endLineIndex+1)].join("");return{name:t?.name??i.name,contents:d,cacheKey:t?.cacheKey!=null?`${t.cacheKey}:mc-${n}-${r}`:void 0}}function be(e,n,t){const i=e.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),r=e.slice(n.separatorLineIndex+1,n.endLineIndex);return t==="current"?i:t==="incoming"?r:[...i,...r]}function Ee(e,n,t,i){const r=Fe(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Ne(o.conflict,r)}:o})}function Fe(e,n){const t=(e.baseMarkerLineIndex??e.separatorLineIndex)-e.startLineIndex-1,i=e.endLineIndex-e.separatorLineIndex-1;return(n==="current"?t:n==="incoming"?i:t+i)-(e.endLineIndex-e.startLineIndex+1)}function Ne(e,n){return{...e,startLineIndex:e.startLineIndex+n,startLineNumber:e.startLineNumber+n,separatorLineIndex:e.separatorLineIndex+n,separatorLineNumber:e.separatorLineNumber+n,endLineIndex:e.endLineIndex+n,endLineNumber:e.endLineNumber+n,baseMarkerLineIndex:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+n:void 0,baseMarkerLineNumber:e.baseMarkerLineNumber!=null?e.baseMarkerLineNumber+n:void 0}}function je(e,n,t=!1){return!t&&e==null&&n!=null}function Oe(e,n,t=!1){return e==null&&n!=null&&!t}function Te(e,n){const t={...n,...e};return{...t,useTokenTransformer:ne(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Ue=typeof window>"u"?k.useEffect:k.useLayoutEffect;function $e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:r,hasConflictUtility:o,hasGutterRenderUtility:s,hasCustomHeader:l,disableWorkerPool:d}){const[{fileDiff:a,actions:f,markerRows:h},u]=k.useState(()=>{const{fileDiff:c,actions:m,markerRows:C}=b(e,n?.maxContextLines);return{fileDiff:c,actions:m,markerRows:C}}),L=H((c,m)=>{u(C=>{const{fileDiff:v,actions:F,markerRows:N}=m.resolveConflict(c.conflict.conflictIndex,c.resolution,C.fileDiff)??{};return v==null||F==null||N==null?C:{fileDiff:v,actions:F,markerRows:N}})}),A=i!==void 0,I=k.useContext(te),p=k.useRef(null),x=H(c=>{if(c!=null){if(p.current!=null)throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");p.current=new Me(q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),d?void 0:I,!0),p.current.hydrate({fileDiff:a,actions:f,markerRows:h,fileContainer:c,lineAnnotations:t,prerenderedHTML:r})}else{if(p.current==null)throw new Error("useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting");p.current.cleanUp(),p.current=null}});return Ue(()=>{if(p.current==null)return;const c=p.current,m=q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!ie(c.options,m);c.setOptions(m),c.render({fileDiff:a,actions:f,markerRows:h,lineAnnotations:t,forceRender:C}),i!==void 0&&c.setSelectedLines(i)}),{ref:x,getHoveredLine:k.useCallback(()=>p.current?.getHoveredLine(),[]),fileDiff:a,actions:f,markerRows:h,getInstance:k.useCallback(()=>p.current??void 0,[])}}function q({options:e,controlledSelection:n,onMergeConflictAction:t,hasConflictUtility:i,hasCustomHeader:r,hasGutterRenderUtility:o}){return{...e,controlledSelection:n,onMergeConflictAction:t,hunkSeparators:e?.hunkSeparators==="custom"?R:e?.hunkSeparators,mergeConflictActionsType:i||e?.mergeConflictActionsType==="custom"?R:e?.mergeConflictActionsType,renderCustomHeader:r?R:void 0,renderGutterUtility:o?R:void 0}}function Pe({file:e,options:n,lineAnnotations:t,selectedLines:i,className:r,style:o,prerenderedHTML:s,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderGutterUtility:u,renderMergeConflictUtility:L,disableWorkerPool:A=!1}){const{ref:I,getHoveredLine:p,fileDiff:x,actions:c,getInstance:m}=$e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(ce,{ref:I,className:r,style:o,children:oe(he({fileDiff:x,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderAnnotation:l,renderGutterUtility:u,lineAnnotations:t,getHoveredLine:p,actions:c,renderMergeConflictUtility:L,getInstance:m}),s)})}function He(e){return{draft:e,persistedContent:e,revision:0}}function _e(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function Be(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function We(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function dn(e){return g.jsx(re,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(Ge,{...e}):g.jsx(Ke,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function Ge({contentKey:e,value:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f}){return g.jsx(pe,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function Ke({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>He(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=ze(h);k.useEffect(()=>{s(p=>We(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=qe(h,p,x);s(C=>_e(C,m));try{await i(e.path,m)?s(C=>Be(C,m)):s(C=>C.draft===m?c:C)}finally{d(!1)}},I=async()=>{if(!(L>0||a)){f(!0);try{await r(e.path,h)}finally{f(!1)}}};return g.jsxs("div",{className:"conflict-viewer",children:[g.jsxs("div",{className:"conflict-viewer-toolbar",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Conflict resolution"}),g.jsx("span",{children:L>0?`${L} ${L===1?"pending block":"pending blocks"}`:"All blocks are resolved"})]}),g.jsx(D,{size:"sm",disabled:L>0||a,onClick:()=>{I()},children:a?"Saving…":"Mark as resolved"})]}),g.jsx(se,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx(Pe,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:conflict:${u}`},disableWorkerPool:h.length>5e5,options:{themeType:n,theme:U,diffIndicators:"classic",overflow:t,mergeConflictActionsType:"none",unsafeCSS:T},renderMergeConflictUtility:p=>g.jsxs("div",{className:"conflict-actions",children:[g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"current")},children:"Accept current"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"incoming")},children:"Accept incoming"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"both")},children:"Accept both"})]})},`${e.path}:${u}`):g.jsx(le,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function ze(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function qe(e,n,t){const i=e.match(/[^\n]*\n|[^\n]+$/g)??[],r=i.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),o=i.slice(n.separatorLineIndex+1,n.endLineIndex),s=t==="current"?r:t==="incoming"?o:[...r,...o];return[...i.slice(0,n.startLineIndex),...s,...i.slice(n.endLineIndex+1)].join("")}export{dn as default};
|
package/dist/client/assets/{PierreEditBoundary-Bb4dONIq.js → PierreEditBoundary-KzU3HDc2.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{_ as l,s as E,r as f}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BzmFkR37.js","assets/platform-Bqt97_Jr.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as l,s as E,r as f}from"./index-CQcx9aRt.js";import{r as o,j as i}from"./react-rd22PHbN.js";import{E as c}from"./EditContext-CvJWfVl1.js";import{E as d}from"./edit-ready-context-D77R8XU8.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";function C({enabled:s,children:a}){const[r,n]=o.useState(null);o.useEffect(()=>{if(!s||r)return;let e=!0;return l(()=>import("./index-BzmFkR37.js"),__vite__mapDeps([0,1,2])).then(t=>{e&&n(()=>t.Editor)}).catch(t=>{e&&E.error({title:"Could not load the code editor",description:t instanceof Error?t.message:"Unknown error"})}),()=>{e=!1}},[r,s]);const u=o.useCallback(e=>{if(!r)throw new Error("Pierre edit mode has not loaded.");return new r({clipboard:{readText:()=>f()},...e})},[r]);return r?i.jsx(c,{createEditor:u,children:i.jsx(d.Provider,{value:!0,children:a})}):i.jsx(d.Provider,{value:!1,children:a})}export{C as PierreEditBoundary};
|