@opentig/cli 0.1.6 → 0.1.7
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 -1
- package/dist/chunks/{cli-ABzC6-gR.mjs → cli-DCPhUVBb.mjs} +1 -1
- package/dist/client/assets/App-CGiS2z40.js +74 -0
- package/dist/client/assets/{CreatePullRequestDialog-W82oHjYm.js → CreatePullRequestDialog-dNbTTo9i.js} +2 -2
- package/dist/client/assets/{DiffWorkspace-BWkTIl5n.js → DiffWorkspace-XS025gbZ.js} +1 -1
- package/dist/client/assets/{EditableFileViewer-Cv3aNJBN.js → EditableFileViewer-Cve4V9RS.js} +1 -1
- package/dist/client/assets/{File-DiOOsHOl.js → File-BJuBDans.js} +1 -1
- package/dist/client/assets/{FilesView-DIqPfRbv.js → FilesView-BUAz46Qa.js} +1 -1
- package/dist/client/assets/GitHubAvatar-Depnd_JA.js +1 -0
- package/dist/client/assets/HistoryView-Dd4Kr4KN.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-BsewwJtM.js → HtmlFileViewer-C3Qylr9B.js} +1 -1
- package/dist/client/assets/{IconEdit-CxvzMyLV.js → IconEdit-BHqlqze_.js} +1 -1
- package/dist/client/assets/{IconFolderPlus-1vLDIzhC.js → IconFolderPlus-BJIo1hfe.js} +1 -1
- package/dist/client/assets/{ImageFileViewer-CoQZkgET.js → ImageFileViewer-BJy0ptmR.js} +1 -1
- package/dist/client/assets/{LocalRefsDialog-sw-ROjfe.js → LocalRefsDialog-C1MWMkv1.js} +1 -1
- package/dist/client/assets/{MarkdownFileViewer-BedKCXTI.js → MarkdownFileViewer-pagMxv2y.js} +2 -2
- package/dist/client/assets/{PairingPage-CYJXzBZC.js → PairingPage-DOPAXy3a.js} +1 -1
- package/dist/client/assets/{PierreDiffViewer-uhTsb-F7.js → PierreDiffViewer-FmgbHdls.js} +1 -1
- package/dist/client/assets/{PierreEditBoundary-Bb4dONIq.js → PierreEditBoundary-mxtF7x3F.js} +1 -1
- package/dist/client/assets/{PierreWorkerPool-BuBzE8K1.js → PierreWorkerPool-B_NFnwU-.js} +1 -1
- package/dist/client/assets/{PullRequestDiff-CgY4QIHC.js → PullRequestDiff-Bcu8Gmrf.js} +1 -1
- package/dist/client/assets/PullRequestViewer-oeDoq-3g.js +2 -0
- package/dist/client/assets/PullRequestsView-DpTtagTX.js +1 -0
- package/dist/client/assets/{QuickOpenDialog-Cn-aQRAS.js → QuickOpenDialog-rjeV0l_J.js} +1 -1
- package/dist/client/assets/RepositoryProjectsDialog-QYXEt7Lg.js +1 -0
- package/dist/client/assets/{SearchView-BtKBEJ7e.js → SearchView-C-c6oCil.js} +1 -1
- package/dist/client/assets/{SettingsDialog-wfWhEzZY.js → SettingsDialog-DHmWkKYV.js} +2 -2
- package/dist/client/assets/Viewer-B6qUr83C.js +3 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-DLBLFOdy.js → abnfDiagram-N423BO3Z-BxGW6tGd.js} +1 -1
- package/dist/client/assets/{arc-D-Yei3Vr.js → arc-CphVLv_F.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-BOgBvzWh.js → architectureDiagram-T3A2C74G-D9IDzZ6u.js} +1 -1
- package/dist/client/assets/base-ui-DT3JsyND.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-BQXRJDyR.js → blockDiagram-VBNYF7ZC-CzCatff9.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-DTZseD56.js → c4Diagram-5PPSVZJV-jvC7ACDE.js} +1 -1
- package/dist/client/assets/channel-BGbncBYv.js +1 -0
- package/dist/client/assets/{checkbox-BwbxYGgK.js → checkbox-DDpujnre.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-spRCgfPY.js → chunk-2GRJ4B5K-CNRn3w2y.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-CLVClH0M.js → chunk-2Q5K7J3B-CnTjXDS8.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-CuQ5tYjB.js → chunk-5RXB4S5H-8QZZSU3J.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DyOEOe90.js → chunk-5VM5RSS4-B2MFN1L0.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-CgMtuJIx.js → chunk-6Q2QTUOP-BRGuFKSr.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-BH63P4Vv.js → chunk-GF5L2VYU-CWTKyD7U.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-BANDbaPq.js → chunk-JWPE2WC7-rGurufZY.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-Bfty2upo.js → chunk-KBJHAD2P-DOwIHyo0.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-Cvu8BZS9.js → chunk-RYQCIY6F-qrVd0AV3.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-bnohf1yd.js → chunk-XXDRQBXY-BGvaybJK.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BoYriqPM.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BoYriqPM.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-DCTEAZwO.js → cose-bilkent-JH36ORCC-CHgOt-vq.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-Bp2wXvdt.js → cynefin-VYW2F7L2-DX7Kb3Ft.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-DRRWzuF0.js → cynefinDiagram-MW4NZA55-B4MgYgbV.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-DDvsotRK.js → dagre-VZM6K2ZE-xG9l95NU.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-CMqhRNRq.js → diagram-7IWD3JNH-BQKb8ivh.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-D_PYI1ut.js → diagram-B4RE2ZJO-CyIMrtDr.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-BSUx7mMM.js → diagram-LBJQPF4R-WuCMu4WW.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-C8O3g6WT.js → diagram-Q27KOJAE--Oi1nRrR.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-C5-NDsgC.js → diagram-UB23O5K3-CP1DXsa_.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-D71hx4Ww.js → ebnfDiagram-BXEA7PRR-C-7jJg9C.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-yd9B5d8I.js → erDiagram-JOGREHBK-FSyqgO_9.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-CWU5VVbw.js → flowDiagram-UKHOOZJN-y2e2HZHu.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-D2siVjfa.js → ganttDiagram-PKOTCBZU-kZ3m3wwW.js} +1 -1
- package/dist/client/assets/{gh-utils-B0Nlmxep.js → gh-utils-DxPHIkD8.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-CIvIFcxR.js → gitGraphDiagram-DS77QQ5N-3Z9e4WPi.js} +1 -1
- package/dist/client/assets/{index-BOPi2b1j.js → index-ChKJF4C_.js} +3 -3
- package/dist/client/assets/index-WwGOu_aM.css +1 -0
- package/dist/client/assets/{infoDiagram-6WML65LV-DRvl8KfO.js → infoDiagram-6WML65LV-TfCo0Rhw.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-H5EQq6uE.js → ishikawaDiagram-WSZJBQD7-DaXI89rw.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-CCwLmD-U.js → journeyDiagram-NVQOT4AX-C4jS6BVn.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-DS--XHEu.js → kanban-definition-27J2QSJJ-bwOtQiC8.js} +1 -1
- package/dist/client/assets/{linear-Q3JNM6CR.js → linear-DfZM9J6Z.js} +1 -1
- package/dist/client/assets/{mermaid.core-EwS_m22C.js → mermaid.core-B-iLnCqi.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-D15nrwfe.js → mindmap-definition-FAOFIHXS-DAdKdypB.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-DOG19gxx.js → pegDiagram-VL7TDLO6-Bl95_ELH.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-Bstdr7Wh.js → pieDiagram-7S7Q4E2Y-DXf4GTLI.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-DfKs4qZW.js → quadrantDiagram-CIZ2JOQS-CDiwouFY.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-DJKxyuhV.js → railroadDiagram-AXF67PYL-CZAR7rja.js} +1 -1
- package/dist/client/assets/{render-markdown-C7X2TwRk.js → render-markdown-BiKX2Zdv.js} +1 -1
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-SGJWVmBV.js → requirementDiagram-LRYGKXZP-BklWtcnl.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-CpZFct0O.js → sankeyDiagram-W5VNT64P-CpD7cM5j.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-B7plRik9.js → sequenceDiagram-SI44F4Z6-BnHPNl9l.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-CNbK285t.js → sizeCapture-X5ZJPWSS-D1eo0r-2.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-BIHk9QCC.js → stateDiagram-OKZ733FA-ClTacl-d.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-DAo7Tfh9.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-7g_XCosC.js → swimlanes-SLNWSIFB-_PLbkM5u.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DHeOpgR_.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-C9U6VikV.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-Bt5-8VZ2.js → vennDiagram-T6HMQDX7-Desj7KFU.js} +1 -1
- package/dist/client/assets/{viewer-tabs-DxCOe0ut.js → viewer-tabs-BwMhis6Q.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-B5Imx6zh.js → wardleyDiagram-T6FBY63Y-rlMEd5tV.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-CDaY4xFS.js → xychartDiagram-ELKLHX3M-CzFgA0NM.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +1 -1
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +506 -212
- package/package.json +1 -1
- package/dist/client/assets/App-CBetJ5ZN.js +0 -74
- package/dist/client/assets/GitHubAvatar-DBc3Vxnk.js +0 -1
- package/dist/client/assets/HistoryView-DYxWYYVx.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/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/stateDiagram-v2-UEYNNEHI-Cqw0H5cq.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-BzKpdiGK.js +0 -8
|
@@ -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-BwMhis6Q.js";import{u as j,F as y,S as E}from"./EditableFileViewer-Cve4V9RS.js";import"./index-ChKJF4C_.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-B_NFnwU-.js";import"./platform-BMNQ8V5r.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-BJuBDans.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";import"./App-CGiS2z40.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-ChKJF4C_.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-ChKJF4C_.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-ChKJF4C_.js";import{V as U,b as C,a as B}from"./viewer-tabs-BwMhis6Q.js";import{u as W,S as P,F as H}from"./EditableFileViewer-Cve4V9RS.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-B_NFnwU-.js";import"./platform-BMNQ8V5r.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-BJuBDans.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";import"./App-CGiS2z40.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-CGiS2z40.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-ChKJF4C_.js";import{C as qe}from"./checkbox-DDpujnre.js";import{o as We}from"./gh-utils-DxPHIkD8.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};
|
package/dist/client/assets/{MarkdownFileViewer-BedKCXTI.js → MarkdownFileViewer-pagMxv2y.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
2
|
-
import{r as t,j as e,a as oe}from"./react-rd22PHbN.js";import{c as B,_ as ae,w as se,s as ie,e as le,T as H,a as U,b as z}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B-iLnCqi.js","assets/index-ChKJF4C_.js","assets/react-rd22PHbN.js","assets/tanstack-CtfgE41X.js","assets/base-ui-DT3JsyND.js","assets/index-WwGOu_aM.css","assets/render-markdown-BiKX2Zdv.js","assets/App-CGiS2z40.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as t,j as e,a as oe}from"./react-rd22PHbN.js";import{c as B,_ as ae,w as se,s as ie,e as le,T as H,a as U,b as z}from"./index-ChKJF4C_.js";import{G as ce}from"./App-CGiS2z40.js";import{V as ue,a as de,b as K}from"./viewer-tabs-BwMhis6Q.js";import{u as pe,s as me,F as fe,S as he}from"./EditableFileViewer-Cve4V9RS.js";import{r as we}from"./render-markdown-BiKX2Zdv.js";/* empty css */import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-B_NFnwU-.js";import"./platform-BMNQ8V5r.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-BJuBDans.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ge=[["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"}]],ve=B("outline","viewport-narrow","ViewportNarrow",ge);const be=[["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"}]],ke=B("outline","viewport-wide","ViewportWide",be);function q(o,f){const l=f.trim();if(!l||l.startsWith("#")||l.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(l))return null;const u=l.split(/[?#]/,1)[0];if(!u)return null;let p;try{p=decodeURIComponent(u).replaceAll("\\","/")}catch{return null}const d=p.startsWith("/")?[]:o.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const a of p.split("/"))if(!(!a||a===".")){if(a===".."){if(d.length===0)return null;d.pop();continue}if(Ce(a))return null;d.push(a)}return d.length>0?d.join("/"):null}function Ce(o){return[...o].some(f=>f.charCodeAt(0)<32||f.charCodeAt(0)===127)}let ye=0;function G(){return document.documentElement.classList.contains("dark")?"dark":"default"}function xe(o,f,l){const[u,p]=t.useState(G);t.useEffect(()=>{const a=new MutationObserver(()=>p(G()));return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]);const d=t.useCallback(async a=>{if(!o.current)return;const h=Array.from(o.current.querySelectorAll(".mermaid"));if(h.length!==0)try{const{default:c}=await ae(async()=>{const{default:i}=await import("./mermaid.core-B-iLnCqi.js").then(m=>m.bo);return{default:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(a()||!o.current)return;c.initialize({startOnLoad:!1,theme:u,securityLevel:"strict"});for(const i of h){const m=i.dataset.mermaidSource;if(m){i.removeAttribute("data-mermaid-error");try{const T=decodeURIComponent(m),y=`mermaid-diagram-${ye++}`,{svg:R,bindFunctions:b}=await c.render(y,T,i);if(a()||!i.isConnected)return;i.innerHTML=R,i.dataset.processed="true",b?.(i)}catch{!a()&&i.isConnected&&(i.textContent=decodeURIComponent(m),i.dataset.mermaidError="Could not render diagram")}}}}catch{for(const c of h)!a()&&c.isConnected&&(c.dataset.mermaidError="Could not load Mermaid")}},[f,o,u]);t.useEffect(()=>{let a=!1;return d(()=>a),()=>{a=!0}},[l,d])}const X="opentig:markdown-content-width",$=/^([a-z][a-z0-9+.-]*:)?\/\//i,Te={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Me(){try{return window.localStorage.getItem(X)==="fit"?"fit":"reading"}catch{return"reading"}}function Se({html:o,onClick:f,onLinkHover:l}){const u=t.useRef(null),p=t.useRef(null);t.useLayoutEffect(()=>{u.current&&(u.current.innerHTML=o),p.current=null,l(null)},[o,l]),xe(u,!0,o);const d=t.useCallback(h=>{const c=h.target.closest("a[href]");!c||c===p.current||(p.current=c,l(c))},[l]),a=t.useCallback(h=>{const c=p.current;if(!c)return;const i=h.relatedTarget;i&&c.contains(i)||(p.current=null,l(null))},[l]);return e.jsx("div",{ref:u,className:"markdown-prose",onClick:f,onMouseOver:d,onMouseOut:a})}function Ke({file:o,initialContent:f,revision:l,themeType:u,wrapLines:p,readOnly:d,onOpenFile:a,onDirtyChange:h,onDraftChange:c,onSave:i}){const[m,T]=t.useState("preview"),[y,R]=t.useState(Me),[b,I]=t.useState(""),[_,F]=t.useState(!0),[Y,V]=t.useState(!1),[x,g]=t.useState(null),M=t.useRef(0),k=t.useRef(null),N=t.useRef(null),A=t.useRef(null),C=t.useRef(null),S=t.useRef(null),{draft:P,updateDraft:J,dirty:j,saving:O,save:Q}=pe({file:o,initialContent:f,readOnly:d,messages:Te,onDirtyChange:h,onDraftChange:c,onSave:i});t.useEffect(()=>{S.current?.(),C.current=null,T("preview")},[o.path]);const Z=t.useCallback(n=>{if(n!==m){if(S.current?.(),m==="preview"){const r=N.current,s=r?r.scrollHeight-r.clientHeight:0;C.current=r&&s>0?r.scrollTop/s:0}else C.current=A.current?.getScrollFraction()??0;T(n)}},[m]);t.useLayoutEffect(()=>{const n=C.current;if(n==null)return;if(m==="code"){C.current=null,A.current?.scrollToFraction(n);return}const r=N.current;!r||_&&!b||(C.current=null,S.current=me({getScrollRange:()=>Math.max(0,r.scrollHeight-r.clientHeight),getScrollTop:()=>r.scrollTop,getContentHeight:()=>r.scrollHeight,scrollTo:s=>{r.scrollTop=s}},n))},[b,_,m]),t.useEffect(()=>()=>S.current?.(),[]),t.useEffect(()=>{const n=++M.current;F(!0);const r=window.setTimeout(()=>{const s=window.__opentigPerformanceAutomation?performance.now():null;we(P).then(w=>{n===M.current&&(I(w),s!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-s)*100)/100})))}).catch(()=>{n===M.current&&I("<p>Could not render Markdown.</p>")}).finally(()=>{n===M.current&&F(!1)})},j?120:0);return()=>window.clearTimeout(r)},[j,P,o.mtimeMs,o.path,l,u]),t.useEffect(()=>()=>{k.current&&window.clearTimeout(k.current.timer)},[]);const ee=t.useCallback(async n=>{const r=n.target,s=r.closest("[data-copy-code]");if(s){const W=s.dataset.copyCode;if(!W)return;try{const re=decodeURIComponent(W);await se(re);const E=k.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),s.dataset.copyState="copied",s.setAttribute("aria-label","Copied"),V(!0);const ne=window.setTimeout(()=>{k.current?.button===s&&(delete s.dataset.copyState,s.setAttribute("aria-label","Copy code"),k.current=null,V(!1))},2e3);k.current={button:s,timer:ne}}catch{ie.error({title:"Could not copy code"})}return}const w=r.closest("a[href]"),v=w?.getAttribute("href");if(!w||!v)return;if(n.preventDefault(),v.startsWith("#")){n.currentTarget.querySelector(`#${CSS.escape(v.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if($.test(v)||v.startsWith("mailto:")){try{le(v)}catch{}return}const D=q(o.path,v);D&&a(D)},[o.path,a]),te=t.useCallback(n=>{if(!n){g(null);return}const r=n.getAttribute("href");if(!r||r.startsWith("#")){g(null);return}const s=n.getBoundingClientRect(),w={top:s.bottom+6,left:s.left};if(r.startsWith("mailto:")){g({...w,label:"Open in mail app",href:r.replace(/^mailto:/,"")});return}if($.test(r)){g({...w,label:"Open in browser",href:r});return}if(q(o.path,r)){g({...w,label:"Open file",href:r});return}g(null)},[o.path]),L=n=>{R(n);try{window.localStorage.setItem(X,n)}catch{}};return e.jsxs(ue,{value:m,onValueChange:n=>Z(n),className:"markdown-viewer","data-content-width":y,children:[e.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[e.jsx(de,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:e.jsxs(e.Fragment,{children:["Code ",j&&e.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),e.jsx(fe,{dirty:j,saving:O,readOnly:d,onSave:()=>{Q()}}),e.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[e.jsxs(H,{children:[e.jsx(U,{render:e.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":y==="reading",onClick:()=>L("reading")}),children:e.jsx(ve,{"aria-hidden":"true"})}),e.jsx(z,{children:"Reading width"})]}),e.jsxs(H,{children:[e.jsx(U,{render:e.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":y==="fit",onClick:()=>L("fit")}),children:e.jsx(ke,{"aria-hidden":"true"})}),e.jsx(z,{children:"Fit to width"})]})]})]}),e.jsxs(K,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>g(null),children:[_&&!b?e.jsx("div",{className:"viewer-message",children:e.jsx(ce,{text:"Rendering Markdown…"})}):e.jsx(Se,{html:b,onClick:n=>{ee(n)},onLinkHover:te}),e.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:Y?"Code copied":""}),x?oe.createPortal(e.jsxs("div",{className:"markdown-link-tooltip",style:{top:x.top,left:x.left},role:"tooltip",children:[e.jsx("span",{className:"markdown-link-tooltip-label",children:x.label}),e.jsx("span",{className:"markdown-link-tooltip-href",children:x.href})]}),document.body):null]}),e.jsx(K,{value:"code",className:"markdown-code-view","data-theme":u,children:e.jsx(he,{ref:A,path:o.path,cacheKey:o.path,value:P,themeType:u,wrapLines:p,readOnly:d||O,onChange:J})})]})}export{Ke 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-ChKJF4C_.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as k,j as g}from"./react-rd22PHbN.js";import{q as w,a5 as E,m as Q,a6 as j,a7 as O,A as X,d as M,D as Y,z as ee,a2 as ne,Z as te,a3 as R,a4 as ie,P as oe,a as re,V as T,O as U}from"./PierreWorkerPool-BuBzE8K1.js";import{F as se}from"./File-DiOOsHOl.js";import{D as q,b as $,f as le}from"./platform-BMNQ8V5r.js";import{a as ce,g as V,b as Z,F as de,p as b,c as ae,s as ue,r as fe,D as he}from"./DiffWorkspace-BWkTIl5n.js";import{a as P}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-BOPi2b1j.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-CBetJ5ZN.js";import"./tanstack-B8_amOz8.js";import"./base-ui-qeHDA5zu.js";var H=class extends ce{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:q},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?V(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=$){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=$){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:_(t),contentProperties:B(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:_(t),contentProperties:B(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:pe({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:W("action")});continue}(o.type==="marker-end"?r:i).push({content:Ce(o),gutter:W("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 _(e){return e!=null?{"data-merge-conflict":e}:void 0}function B(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 W(e,n){const t=Q(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function pe({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?me(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Z({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 Ce(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 me(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),z(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),z(),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 z(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function xe(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&&ge(e.conflict,n.conflict)}function ge(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 Le(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function Ie(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()){ve(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){G(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"){G(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{ke(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);J(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function J(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 ve(e,n,t,i,r,o,s){o<=0||(s&&(J(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 G(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 ke(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 Ae(e,n,t){return Ie(e,{resolution:Le(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:we(n)})}function we(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let Re=-1;var De=class extends de{options;__id=`unresolved-file:${++Re}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:q},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(X(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 H(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Oe(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),Ne(this.pre,f.fileDiff,this.options.collapsed)||je(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=Ae(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=Me({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 H&&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=V(r,n);if(o==null)continue;const s=r.conflictIndex,l=Z({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!xe(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=Y(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 Me({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=be(n,t,o,r),l=ae(e,s);return{file:ye({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function ye({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=ue(t?.contents??""),{conflict:s}=e,l=Se(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 Se(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 be(e,n,t,i){const r=Ee(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Fe(o.conflict,r)}:o})}function Ee(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 Fe(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 Ne(e,n,t=!1){return!t&&e==null&&n!=null}function je(e,n,t=!1){return e==null&&n!=null&&!t}function Oe(e,n){const t={...n,...e};return{...t,useTokenTransformer:ee(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Te=typeof window>"u"?k.useEffect:k.useLayoutEffect;function Ue({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=P((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(ne),p=k.useRef(null),x=P(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 De(K({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 Te(()=>{if(p.current==null)return;const c=p.current,m=K({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!te(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 K({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 $e({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}=Ue({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(le,{ref:I,className:r,style:o,children:ie(fe({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 Pe(e){return{draft:e,persistedContent:e,revision:0}}function He(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function _e(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function Be(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function cn(e){return g.jsx(oe,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(We,{...e}):g.jsx(ze,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function We({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(he,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function ze({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>Pe(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=Ge(h);k.useEffect(()=>{s(p=>Be(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=Ke(h,p,x);s(C=>He(C,m));try{await i(e.path,m)?s(C=>_e(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(re,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx($e,{file:{name: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(se,{file:{name:e.path,contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function Ge(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function Ke(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{cn as default};
|
|
1
|
+
import{r as k,j as g}from"./react-rd22PHbN.js";import{q as w,a5 as E,m as Q,a6 as j,a7 as O,A as X,d as M,D as Y,z as ee,a2 as ne,Z as te,a3 as R,a4 as ie,P as oe,a as re,V as T,O as U}from"./PierreWorkerPool-B_NFnwU-.js";import{F as se}from"./File-BJuBDans.js";import{D as q,b as $,f as le}from"./platform-BMNQ8V5r.js";import{a as ce,g as V,b as Z,F as de,p as b,c as ae,s as ue,r as fe,D as he}from"./DiffWorkspace-XS025gbZ.js";import{a as P}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-ChKJF4C_.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-CGiS2z40.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";var H=class extends ce{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:q},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?V(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=$){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=$){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:_(t),contentProperties:B(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:_(t),contentProperties:B(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:pe({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:W("action")});continue}(o.type==="marker-end"?r:i).push({content:Ce(o),gutter:W("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 _(e){return e!=null?{"data-merge-conflict":e}:void 0}function B(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 W(e,n){const t=Q(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function pe({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?me(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Z({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 Ce(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 me(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),z(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),z(),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 z(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function xe(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&&ge(e.conflict,n.conflict)}function ge(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 Le(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function Ie(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()){ve(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){G(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"){G(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{ke(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);J(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function J(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 ve(e,n,t,i,r,o,s){o<=0||(s&&(J(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 G(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 ke(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 Ae(e,n,t){return Ie(e,{resolution:Le(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:we(n)})}function we(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let Re=-1;var De=class extends de{options;__id=`unresolved-file:${++Re}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:q},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(X(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 H(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Oe(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),Ne(this.pre,f.fileDiff,this.options.collapsed)||je(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=Ae(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=Me({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 H&&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=V(r,n);if(o==null)continue;const s=r.conflictIndex,l=Z({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!xe(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=Y(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 Me({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=be(n,t,o,r),l=ae(e,s);return{file:ye({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function ye({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=ue(t?.contents??""),{conflict:s}=e,l=Se(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 Se(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 be(e,n,t,i){const r=Ee(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Fe(o.conflict,r)}:o})}function Ee(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 Fe(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 Ne(e,n,t=!1){return!t&&e==null&&n!=null}function je(e,n,t=!1){return e==null&&n!=null&&!t}function Oe(e,n){const t={...n,...e};return{...t,useTokenTransformer:ee(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Te=typeof window>"u"?k.useEffect:k.useLayoutEffect;function Ue({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=P((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(ne),p=k.useRef(null),x=P(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 De(K({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 Te(()=>{if(p.current==null)return;const c=p.current,m=K({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!te(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 K({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 $e({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}=Ue({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(le,{ref:I,className:r,style:o,children:ie(fe({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 Pe(e){return{draft:e,persistedContent:e,revision:0}}function He(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function _e(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function Be(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function cn(e){return g.jsx(oe,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(We,{...e}):g.jsx(ze,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function We({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(he,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function ze({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>Pe(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=Ge(h);k.useEffect(()=>{s(p=>Be(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=Ke(h,p,x);s(C=>He(C,m));try{await i(e.path,m)?s(C=>_e(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(re,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx($e,{file:{name: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(se,{file:{name:e.path,contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function Ge(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function Ke(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{cn as default};
|
package/dist/client/assets/{PierreEditBoundary-Bb4dONIq.js → PierreEditBoundary-mxtF7x3F.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DDbUjVD9.js","assets/platform-BMNQ8V5r.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as l,s as E,r as f}from"./index-
|
|
2
|
+
import{_ as l,s as E,r as f}from"./index-ChKJF4C_.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-DDbUjVD9.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};
|