@opentig/cli 0.2.0 → 0.2.2

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.
Files changed (118) hide show
  1. package/dist/bin.mjs +2 -1
  2. package/dist/chunks/{cli-Bi6ET5UT.mjs → cli-DNzGBqmL.mjs} +1 -1
  3. package/dist/client/assets/App-BbT5H97Z.js +138 -0
  4. package/dist/client/assets/CreatePullRequestDialog-DRLeMY4e.js +2 -0
  5. package/dist/client/assets/{DiffWorkspace-RDG_Y70N.js → DiffWorkspace-DJX00otP.js} +13 -13
  6. package/dist/client/assets/{EditableFileViewer-CsbifqBO.js → EditableFileViewer-Cmbomx5y.js} +1 -1
  7. package/dist/client/assets/{File-CHjvYpb2.js → File-4o4egqlz.js} +1 -1
  8. package/dist/client/assets/FilesView-TmUF-VLr.js +1 -0
  9. package/dist/client/assets/GitHubAvatar-azKPrTMv.js +1 -0
  10. package/dist/client/assets/HistoryView-Go6rXO0P.js +1 -0
  11. package/dist/client/assets/{HtmlFileViewer-h8ULU8Gy.js → HtmlFileViewer-WpYnLdMW.js} +1 -1
  12. package/dist/client/assets/{IconEdit-Cg8S2wqW.js → IconEdit-B8LZHB8l.js} +1 -1
  13. package/dist/client/assets/{IconFolderSymlink-BZSLX1ez.js → IconFolderSymlink-D29EhQPC.js} +1 -1
  14. package/dist/client/assets/{ImageFileViewer-Cjw58ckv.js → ImageFileViewer-1ObUacJu.js} +1 -1
  15. package/dist/client/assets/LocalRefsDialog-VcrlFgxR.js +1 -0
  16. package/dist/client/assets/{MarkdownFileViewer-kLiduag6.js → MarkdownFileViewer-CvsKPnvF.js} +2 -2
  17. package/dist/client/assets/PairingPage-cSoKZi8t.js +1 -0
  18. package/dist/client/assets/{PierreDiffViewer-eAcugmoF.js → PierreDiffViewer-DVTrOwX4.js} +1 -1
  19. package/dist/client/assets/{PierreEditBoundary-DlGd1pqO.js → PierreEditBoundary-DPtaTiUB.js} +1 -1
  20. package/dist/client/assets/{PierreWorkerPool-Col4k7qz.js → PierreWorkerPool-BxP-s6jD.js} +1 -1
  21. package/dist/client/assets/{PullRequestDiff-DhKTXyIF.js → PullRequestDiff-DeQznd9n.js} +1 -1
  22. package/dist/client/assets/PullRequestViewer-IhGZZs_A.js +2 -0
  23. package/dist/client/assets/PullRequestsView-BG0xrok4.js +1 -0
  24. package/dist/client/assets/QuickOpenDialog-DpmcAzTx.js +1 -0
  25. package/dist/client/assets/RepositoryProjectsDialog-DAzbUB3X.js +1 -0
  26. package/dist/client/assets/SearchView-HoiWKG8z.js +1 -0
  27. package/dist/client/assets/SettingsDialog-pmJKOaiK.js +9 -0
  28. package/dist/client/assets/{Viewer-o1hDU33O.js → Viewer-BCk8FHrc.js} +3 -3
  29. package/dist/client/assets/{abnfDiagram-N423BO3Z-BvrnK_R-.js → abnfDiagram-N423BO3Z-BvfKOanh.js} +1 -1
  30. package/dist/client/assets/{arc-DLa3_7ua.js → arc-DB2nIH2Y.js} +1 -1
  31. package/dist/client/assets/{architectureDiagram-T3A2C74G-BexwhnyX.js → architectureDiagram-T3A2C74G-Bqh4uY3R.js} +1 -1
  32. package/dist/client/assets/base-ui-DIP2rZxz.js +1 -0
  33. package/dist/client/assets/{blockDiagram-VBNYF7ZC-CoOttUUo.js → blockDiagram-VBNYF7ZC-DMW415Ms.js} +1 -1
  34. package/dist/client/assets/{c4Diagram-5PPSVZJV-Bgp6ppUh.js → c4Diagram-5PPSVZJV-BSNPes7l.js} +1 -1
  35. package/dist/client/assets/channel-VcDernYy.js +1 -0
  36. package/dist/client/assets/checkbox-Dta4gqy2.js +1 -0
  37. package/dist/client/assets/{chunk-2GRJ4B5K-C_kzp38w.js → chunk-2GRJ4B5K-D-86JbWu.js} +1 -1
  38. package/dist/client/assets/{chunk-2Q5K7J3B-CysYnRkJ.js → chunk-2Q5K7J3B-BNI-SD-k.js} +1 -1
  39. package/dist/client/assets/{chunk-5RXB4S5H-oMS6x_ag.js → chunk-5RXB4S5H-OFFYyML8.js} +1 -1
  40. package/dist/client/assets/{chunk-5VM5RSS4-C5-dW5wf.js → chunk-5VM5RSS4-DpE1dtnL.js} +1 -1
  41. package/dist/client/assets/{chunk-6Q2QTUOP-DxahInnA.js → chunk-6Q2QTUOP-DxAnzBXJ.js} +1 -1
  42. package/dist/client/assets/{chunk-GF5L2VYU-D7V-3eRg.js → chunk-GF5L2VYU-DNrTNRgr.js} +1 -1
  43. package/dist/client/assets/{chunk-JWPE2WC7-BrLmjbVP.js → chunk-JWPE2WC7-D-jfKyIh.js} +1 -1
  44. package/dist/client/assets/{chunk-KBJHAD2P-CyOvijwM.js → chunk-KBJHAD2P-CIyQl_ts.js} +1 -1
  45. package/dist/client/assets/{chunk-RYQCIY6F-BvEjVjQs.js → chunk-RYQCIY6F-CgCYQccM.js} +1 -1
  46. package/dist/client/assets/{chunk-XXDRQBXY-C_IY9A64.js → chunk-XXDRQBXY-B31oXtqU.js} +1 -1
  47. package/dist/client/assets/classDiagram-JCYQIIEL-CUuEGRCt.js +1 -0
  48. package/dist/client/assets/classDiagram-v2-OCEON4UE-CUuEGRCt.js +1 -0
  49. package/dist/client/assets/{cose-bilkent-JH36ORCC-Cu7qZi7h.js → cose-bilkent-JH36ORCC-CrX-LDNw.js} +1 -1
  50. package/dist/client/assets/{cynefin-VYW2F7L2-B4M1t9lL.js → cynefin-VYW2F7L2-DnkWlsqW.js} +1 -1
  51. package/dist/client/assets/{cynefinDiagram-MW4NZA55-CAosOLmT.js → cynefinDiagram-MW4NZA55-bUDQ9ElF.js} +1 -1
  52. package/dist/client/assets/{dagre-VZM6K2ZE-q354V538.js → dagre-VZM6K2ZE-BW5Kni4n.js} +1 -1
  53. package/dist/client/assets/{diagram-7IWD3JNH-C_CzkBPt.js → diagram-7IWD3JNH-1EXGwguC.js} +1 -1
  54. package/dist/client/assets/{diagram-B4RE2ZJO-VvvYHE9c.js → diagram-B4RE2ZJO-CzpH5ieN.js} +1 -1
  55. package/dist/client/assets/{diagram-LBJQPF4R-D8vRQwb5.js → diagram-LBJQPF4R-BnKszJ_B.js} +1 -1
  56. package/dist/client/assets/{diagram-Q27KOJAE-Bul4aDKg.js → diagram-Q27KOJAE-DbQlD3OM.js} +1 -1
  57. package/dist/client/assets/{diagram-UB23O5K3-DNadEE58.js → diagram-UB23O5K3-BqZ-RSlm.js} +1 -1
  58. package/dist/client/assets/{ebnfDiagram-BXEA7PRR-Bf-68MMZ.js → ebnfDiagram-BXEA7PRR-B2iPWDvr.js} +1 -1
  59. package/dist/client/assets/{erDiagram-JOGREHBK-CJ-jHFsf.js → erDiagram-JOGREHBK-aMqHrKCk.js} +1 -1
  60. package/dist/client/assets/{flowDiagram-UKHOOZJN-DMOdinBU.js → flowDiagram-UKHOOZJN-ivrTsn4D.js} +1 -1
  61. package/dist/client/assets/{ganttDiagram-PKOTCBZU-DzezS3Zy.js → ganttDiagram-PKOTCBZU-IMfIqkXw.js} +1 -1
  62. package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-Dftpvns8.js → gitGraphDiagram-DS77QQ5N-BNURRh2N.js} +1 -1
  63. package/dist/client/assets/{index-DAUK3rnz.js → index-B3QJsvjR.js} +4 -4
  64. package/dist/client/assets/index-Cx9LaJW8.css +1 -0
  65. package/dist/client/assets/{infoDiagram-6WML65LV-DmgUBq17.js → infoDiagram-6WML65LV-BKEENkUQ.js} +1 -1
  66. package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-CL0PQhpQ.js → ishikawaDiagram-WSZJBQD7-HrCSmiTr.js} +1 -1
  67. package/dist/client/assets/{journeyDiagram-NVQOT4AX-Ck4pQx_A.js → journeyDiagram-NVQOT4AX-CQIuWA6F.js} +1 -1
  68. package/dist/client/assets/{kanban-definition-27J2QSJJ-DuRZxBql.js → kanban-definition-27J2QSJJ-h4fSAkel.js} +1 -1
  69. package/dist/client/assets/{linear-C2JDCaz4.js → linear-BAdz-uC9.js} +1 -1
  70. package/dist/client/assets/{mermaid.core-9dt2ugQA.js → mermaid.core-vLn7mMZB.js} +4 -4
  71. package/dist/client/assets/{mindmap-definition-FAOFIHXS-vy0fdDF0.js → mindmap-definition-FAOFIHXS-DOrZl827.js} +1 -1
  72. package/dist/client/assets/{pegDiagram-VL7TDLO6-DjVJy-Gm.js → pegDiagram-VL7TDLO6-_Vs7p633.js} +1 -1
  73. package/dist/client/assets/{pieDiagram-7S7Q4E2Y-ATbd_8vw.js → pieDiagram-7S7Q4E2Y-7qbB_Z16.js} +1 -1
  74. package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-C8o6ofcl.js → quadrantDiagram-CIZ2JOQS-DNH8SosA.js} +1 -1
  75. package/dist/client/assets/{railroadDiagram-AXF67PYL-Qvij9Ubo.js → railroadDiagram-AXF67PYL-Ctazrrpa.js} +1 -1
  76. package/dist/client/assets/{render-markdown-BtCybfvQ.js → render-markdown-dvHhHbC0.js} +6 -6
  77. package/dist/client/assets/{requirementDiagram-LRYGKXZP-yLfrba2h.js → requirementDiagram-LRYGKXZP-BAH8dYer.js} +1 -1
  78. package/dist/client/assets/{sankeyDiagram-W5VNT64P-BTXRtTyG.js → sankeyDiagram-W5VNT64P-CuffrpdF.js} +1 -1
  79. package/dist/client/assets/{sequenceDiagram-SI44F4Z6-BN1CCZIX.js → sequenceDiagram-SI44F4Z6-CaO4fJnS.js} +1 -1
  80. package/dist/client/assets/{sizeCapture-X5ZJPWSS-BfXjBBYo.js → sizeCapture-X5ZJPWSS-B_LramBU.js} +1 -1
  81. package/dist/client/assets/{stateDiagram-OKZ733FA-DMAWiBsP.js → stateDiagram-OKZ733FA-bc7zBYHn.js} +1 -1
  82. package/dist/client/assets/stateDiagram-v2-UEYNNEHI-C-UGmA2d.js +1 -0
  83. package/dist/client/assets/{swimlanes-SLNWSIFB-BD20m5cw.js → swimlanes-SLNWSIFB-DQzg1IPn.js} +2 -2
  84. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DnopIiWa.js +8 -0
  85. package/dist/client/assets/tanstack-BysN2Oew.js +1 -0
  86. package/dist/client/assets/{timeline-definition-Z64GVDOM-gtc0-AHB.js → timeline-definition-Z64GVDOM-CtbuIB6K.js} +1 -1
  87. package/dist/client/assets/{vennDiagram-T6HMQDX7-Cdr4AXTp.js → vennDiagram-T6HMQDX7-pYJ0ZfFS.js} +1 -1
  88. package/dist/client/assets/{viewer-tabs-D-T0xQaq.js → viewer-tabs-Cnfyd6rg.js} +1 -1
  89. package/dist/client/assets/{wardleyDiagram-T6FBY63Y-BcU4vxO8.js → wardleyDiagram-T6FBY63Y-DYl_Oi-Y.js} +1 -1
  90. package/dist/client/assets/{xychartDiagram-ELKLHX3M-B3Zuadj8.js → xychartDiagram-ELKLHX3M-Cj5YUfP5.js} +1 -1
  91. package/dist/client/index.html +4 -4
  92. package/dist/dev.mjs +3 -2
  93. package/dist/manifest.json +2 -2
  94. package/dist/server.mjs +2219 -508
  95. package/dist/utility.mjs +12 -5
  96. package/package.json +1 -1
  97. package/dist/client/assets/App-BXZLGT86.js +0 -74
  98. package/dist/client/assets/CreatePullRequestDialog-DFonMYEx.js +0 -2
  99. package/dist/client/assets/FilesView-Dl8QFbFA.js +0 -1
  100. package/dist/client/assets/GitHubAvatar-CnBaloV0.js +0 -1
  101. package/dist/client/assets/HistoryView-BgCZU2JO.js +0 -1
  102. package/dist/client/assets/LocalRefsDialog-DNgrd7Qp.js +0 -1
  103. package/dist/client/assets/PairingPage-C97sv-8s.js +0 -1
  104. package/dist/client/assets/PullRequestViewer-BgI8HFMe.js +0 -2
  105. package/dist/client/assets/PullRequestsView-PYWLy8We.js +0 -1
  106. package/dist/client/assets/QuickOpenDialog-BFDDZVCL.js +0 -1
  107. package/dist/client/assets/RepositoryProjectsDialog-CvB8KcFp.js +0 -1
  108. package/dist/client/assets/SearchView-BwF_MsxK.js +0 -1
  109. package/dist/client/assets/SettingsDialog-DIcLmXSE.js +0 -9
  110. package/dist/client/assets/base-ui-CJ8ZIx3d.js +0 -1
  111. package/dist/client/assets/channel-1k1AYpyV.js +0 -1
  112. package/dist/client/assets/checkbox-BRH0ZNIC.js +0 -1
  113. package/dist/client/assets/classDiagram-JCYQIIEL-ChyNFpay.js +0 -1
  114. package/dist/client/assets/classDiagram-v2-OCEON4UE-ChyNFpay.js +0 -1
  115. package/dist/client/assets/index-BfA4tAc1.css +0 -1
  116. package/dist/client/assets/stateDiagram-v2-UEYNNEHI-D_ofZeaa.js +0 -1
  117. package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-CF9m5JSB.js +0 -8
  118. package/dist/client/assets/tanstack-B0Sf7wNU.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as o,j as e}from"./react-rd22PHbN.js";import{l as ie,z as I,o as Ae,p as ze,F as Ke,r as de,s as Be,f as L,ab as q,e as De,af as Z,aj as Qe,ak as We,al as M,am as A,an as ye,D as He,v as Ue,w as _e,x as Ye,a9 as Ne,aa as ve,ao as te,L as Je,y as Ve,ap as Xe,q as Ze,aq as ce,ar as Fe,H as ea,as as aa,at as sa,au as ra,av as la,I as na,J as ta}from"./App-BbT5H97Z.js";import{b as ca,u as H}from"./tanstack-BysN2Oew.js";import{c as Te,B as b,q as U,T as he,b as me,d as ue,I as oa,w as ia,o as B}from"./index-B3QJsvjR.js";import{C as da}from"./checkbox-Dta4gqy2.js";import"./base-ui-DIP2rZxz.js";const ha=[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]],oe=Te("outline","cloud","Cloud",ha);const ma=[["path",{d:"M4 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M4 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M16 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M6 8v8",key:"svg-3"}],["path",{d:"M18 11v5",key:"svg-4"}],["path",{d:"M16 4l4 4m0 -4l-4 4",key:"svg-5"}]],ua=Te("outline","git-pull-request-closed","GitPullRequestClosed",ma);function ba(a){const{details:r,pullRequest:l,anyBusy:t}=a,d=r.remoteState==="missing",[p,m]=o.useState(!1),[h,f]=o.useState(r.branchName);return o.useEffect(()=>{m(!1),f(r.branchName)},[r.fullName,r.branchName]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(oe,{"aria-hidden":"true"}),e.jsxs("span",{children:[r.remote,"/",r.branchName]})]}),e.jsx("small",{className:"local-refs-remote-label",children:d?"Deleted on remote · Cached reference":`Remote branch${r.defaultBranch===r.branchName?" · Default":""}`})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Remote"}),e.jsx("dd",{children:r.remote})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Full ref"}),e.jsx("dd",{children:e.jsx("code",{className:"local-refs-selectable",children:r.fullName})})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Fetched tip"}),e.jsxs("dd",{children:[e.jsx("code",{children:r.shortOid})," ",r.subject]})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Author"}),e.jsx("dd",{children:r.author||"—"})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Last commit"}),e.jsx("dd",{children:r.date?ie(r.date):"—"})]}),e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"Local branches"}),e.jsxs("dd",{children:[r.localBranches.length?r.localBranches.map(c=>e.jsxs("button",{type:"button",className:"local-refs-local-link",disabled:t,onClick:()=>a.onShowLocal(c.fullName),children:[e.jsx(I,{"aria-hidden":"true"}),c.name,c.worktreePath?" · In a worktree":""]},c.fullName)):"No local tracking branch",!d&&!p&&e.jsxs("div",{className:"local-refs-tracking-action",children:[e.jsxs("button",{type:"button",className:"local-refs-local-link",disabled:t,onClick:()=>m(!0),children:[e.jsx(I,{"aria-hidden":"true"}),r.localBranches.length?"Create another local tracking branch…":"Create local tracking branch…"]}),e.jsx("small",{children:"Work on this branch locally without switching your checkout."})]})]})]}),l&&e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:"GitHub PR"}),e.jsx("dd",{children:e.jsxs("button",{type:"button",className:`local-refs-pr-link ${l.state.toLowerCase()}${l.state==="OPEN"&&l.isDraft?" draft":""}`,onClick:()=>Be(l.url),children:[l.state==="MERGED"?e.jsx(Ae,{"aria-hidden":"true"}):l.state==="CLOSED"?e.jsx(ua,{"aria-hidden":"true"}):e.jsx(ze,{"aria-hidden":"true"}),"#",l.number," · ",l.state==="MERGED"?`Merged into ${l.baseRefName}`:Ke(l),e.jsx(de,{"aria-hidden":"true"})]})})]})]}),p&&!d&&e.jsxs("form",{className:"local-refs-create-branch",onSubmit:c=>{c.preventDefault(),!t&&h.trim()&&a.onCreate(h.trim())},children:[e.jsx("label",{htmlFor:"tracking-branch-name",children:"Local branch name"}),e.jsx("input",{id:"tracking-branch-name",value:h,onChange:c=>f(c.target.value),disabled:t,autoFocus:!0,autoComplete:"off",spellCheck:!1}),e.jsx("p",{children:"Creates a tracking branch at the fetched tip. Your checkout and uncommitted changes stay intact."}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(b,{type:"submit",variant:"outline",size:"sm",disabled:t||!h.trim(),children:[a.creating?e.jsx(L,{className:"animate-spin"}):e.jsx(I,{})," ",a.creating?"Creating…":"Create local branch"]}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>m(!1),children:"Cancel"})]})]}),e.jsx("div",{className:`local-refs-danger ${r.deletionBlockedReason?"blocked":"ready"}`,children:r.deletionBlockedReason?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:d?`This branch was already deleted from ${r.remote}. Only its cached reference remains; there is no remote branch to delete.`:r.deletionBlockedReason})]}),d&&e.jsxs(b,{variant:"outline",size:"sm",disabled:t,onClick:a.onFetch,children:[a.fetching?e.jsx(L,{className:"animate-spin"}):e.jsx(De,{}),a.fetching?"Fetching…":"Fetch and clean up"]})]}):a.confirming?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsxs("p",{children:["Delete ",e.jsx("strong",{children:r.branchName})," from ",e.jsx("strong",{children:r.remote}),"? This removes the branch on the remote server. Your local branches, commits and worktrees stay intact."]}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(b,{variant:"destructive",size:"sm",disabled:t,onClick:a.onDelete,children:[a.deleting?e.jsx(L,{className:"animate-spin"}):e.jsx(Z,{}),a.deleting?"Deleting…":`Delete from ${r.remote}`]}),e.jsx(b,{variant:"ghost",size:"sm",disabled:t,onClick:a.onCancel,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[e.jsx(oe,{"aria-hidden":"true"}),e.jsxs("span",{children:["Delete only this branch from ",r.remote,". Local branches and worktrees are kept."]})]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:t,onClick:a.onConfirm,children:[e.jsx(Z,{}),"Delete from ",r.remote]})]})})]})}function Ca(a){const{open:r,tab:l,repositoryId:t,onMutated:d,onBusyChange:p}=a,m=ca(),[h,f]=o.useState(""),[c,x]=o.useState("all"),[g,N]=o.useState(""),[z,k]=o.useState(!1),[P,v]=o.useState(null),[G,_]=o.useState(null),[ae,F]=o.useState(null),[i,be]=o.useState(null),[Y,C]=o.useState(null),[Se,J]=o.useState(!1),fe=o.useRef(null);o.useEffect(()=>{k(!1)},[r,t]);const O=H({queryKey:U.localRefs(t),queryFn:()=>B.refs.localRefsSnapshot(t),enabled:r}),w=O.data??null,V=O.isFetching,xe=O.error?X(O.error):null,T=o.useMemo(()=>Qe(w?.branches??[],h).filter(s=>(c==="all"||s.remote===(c==="remote"))&&(!s.remote||!g||s.remoteName===g)),[w,h,c,g]),Ee=o.useMemo(()=>{const s=[...new Set(T.filter(n=>n.remote).map(n=>n.remoteName??"Unmapped references"))];return[{label:"Local",branches:T.filter(n=>!n.remote)},...s.map(n=>({label:n,branches:T.filter(u=>u.remote&&(u.remoteName??"Unmapped references")===n)}))].filter(n=>n.branches.length>0)},[T]),se=o.useMemo(()=>We(w?.worktrees??[],h),[w,h]),j=T.find(s=>M(s)===P)??null,K=se.find(s=>A(s)===G)??null,je=H({queryKey:U.branchDetails(t,j?.fullName??""),queryFn:()=>B.refs.branchDetails({repositoryId:t,fullName:j.fullName}),enabled:r&&l==="branches"&&j!==null&&!j.remote}),R=je.data??null,pe=H({queryKey:U.remoteBranchDetails(t,j?.fullName??""),queryFn:()=>B.refs.remoteBranchDetails({repositoryId:t,fullName:j.fullName}),enabled:r&&l==="branches"&&j?.remote===!0,staleTime:3e4}),S=pe.data??null,re=j?.remote?S?.branchName:R?.name,Ie=H({queryKey:U.branchPullRequest(t,re??""),queryFn:()=>B.github.findPullRequestForBranch(t,re),enabled:r&&l==="branches"&&!!re&&(j?.remote?S?.remote==="origin":R!==null&&(R.deletion==="unknown"||R.deletion==="unmerged"))}),ge=j?.remote&&S?.remote!=="origin"?null:Ie.data??null,ke=H({queryKey:U.worktreeDetails(t,K?.path??""),queryFn:()=>B.refs.worktreeDetails({repositoryId:t,path:K.path}),enabled:r&&l==="worktrees"&&K!==null}),E=ke.data??null,le=l==="branches"?j?.remote?pe:je:ke,Q=le.isFetching,$=le.error?X(le.error):null,D=o.useCallback(async()=>{await O.refetch(),await Promise.all([m.invalidateQueries({queryKey:["repository",t,"branch-details"]}),m.invalidateQueries({queryKey:["repository",t,"remote-branch-details"]}),m.invalidateQueries({queryKey:["repository",t,"worktree-details"]}),m.invalidateQueries({queryKey:["repository",t,"branch-pull-request"]})])},[m,t,O]);o.useEffect(()=>{if(!w)return;const s=fe.current;fe.current=w,v(n=>ye(T.map(M),(s?.branches??[]).map(M),n)),_(n=>ye(w.worktrees.map(A),(s?.worktrees??[]).map(A),n))},[w,T]),o.useEffect(()=>{r||(f(""),x("all"),N(""),F(null),C(null),J(!1))},[r]),o.useEffect(()=>{F(null),C(null),J(!1)},[l,P,G]);const W=async(s,n)=>{be(s),p(!0),C(null);try{await n()&&F(null)}catch(u){C(X(u))}finally{be(null),p(!1)}},Le=(s,n)=>W("delete-branch",async()=>{const u=await B.refs.deleteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,force:n});return u.status!=="deleted"?(C(ja(u.status)),await D(),!1):(d(null),await D(),!0)}),qe=s=>W("delete-remote-branch",async()=>{const n=await B.refs.deleteRemoteBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,destinationId:s.destinationId});if(n.status!=="deleted")return C(n.status==="rejected"?n.message:Ce(n.status)),await D(),!1;const u=await B.refs.fetchBranches(t);return d(null),await D(),u.status==="failed"&&C("The remote branch was deleted, but fetching failed. Fetch again to update the list."),!0}),Pe=(s,n)=>W("create-tracking-branch",async()=>{const u=await B.refs.createTrackingBranch({repositoryId:t,fullName:s.fullName,expectedOid:s.oid,localName:n});return u.status!=="created"?(C(u.status==="exists"?"That local branch already exists. Choose another name.":Ce(u.status)),await D(),!1):(d(null),await D(),f(""),x("local"),N(""),v(u.fullName),!0)}),we=()=>W("fetch-branches",async()=>{const s=await B.refs.fetchBranches(t);return d(null),await D(),s.status==="failed"&&C(s.message),s.status==="success"}),Ge=(s,n,u)=>W("remove-worktree",async()=>{const ne=await B.refs.removeWorktree({repositoryId:t,path:s.path,expectedOid:s.oid,force:n,deleteBranch:u});return ne.status!=="removed"?(C(pa(ne.status)),await D(),!1):(d(ne.recentRepositories),await D(),!0)}),Oe=async s=>{try{await ia(s),J(!0),window.setTimeout(()=>J(!1),1600)}catch(n){C(X(n))}},$e={branches:w?.branches.length??0,worktrees:w?.worktrees.length??0},Me=l==="branches"?T.length===0:se.length===0;return e.jsx(He,{open:r,onOpenChange:s=>{i||a.onOpenChange(s)},children:e.jsxs(Ue,{className:"local-refs-dialog",children:[e.jsxs("header",{className:"local-refs-header",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Branches and worktrees"}),e.jsx(Ye,{children:"Inspect local and remote branches, and manage this repository’s worktrees."})]}),e.jsx(Ne,{render:e.jsx(b,{variant:"ghost",size:"icon-sm","aria-label":"Close the refs manager",disabled:!!i}),children:e.jsx(ve,{})})]}),e.jsxs("div",{className:"local-refs-toolbar",children:[e.jsx("div",{className:"local-refs-tabs",role:"tablist","aria-label":"Branches and worktrees",children:["branches","worktrees"].map(s=>e.jsxs("button",{type:"button",role:"tab",id:`local-refs-tab-${s}`,"aria-selected":l===s,"aria-controls":`local-refs-panel-${s}`,className:"local-refs-tab",disabled:!!i,onClick:()=>{a.onTabChange(s),k(!1)},children:[s==="branches"?e.jsx(I,{"aria-hidden":"true"}):e.jsx(te,{"aria-hidden":"true"}),e.jsx("span",{children:s==="branches"?"Branches":"Worktrees"}),e.jsx("small",{children:$e[s]})]},s))}),e.jsxs("div",{className:"local-refs-search",children:[e.jsx(Je,{"aria-hidden":"true"}),e.jsxs("label",{className:"sr-only",htmlFor:"local-refs-search-input",children:["Search ",l]}),e.jsx("input",{id:"local-refs-search-input",value:h,disabled:!!i,onChange:s=>f(s.target.value),placeholder:l==="branches"?"Search branches…":"Search worktrees…",autoComplete:"off",spellCheck:!1}),h&&e.jsx(b,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",disabled:!!i,onClick:()=>f(""),children:e.jsx(ve,{})})]}),e.jsxs(he,{children:[e.jsxs(me,{render:e.jsx(b,{variant:"outline",size:"sm",onClick:()=>l==="branches"?void we():void D(),disabled:V||!!i}),children:[V||i==="fetch-branches"?e.jsx(L,{className:"animate-spin"}):e.jsx(De,{})," ",l==="branches"?"Fetch":"Refresh"]}),e.jsx(ue,{children:l==="branches"?"Fetch branches from all remotes and remove obsolete remote references":"Refresh local worktrees"})]})]}),l==="branches"&&e.jsxs("div",{className:"local-refs-branch-filters",children:[e.jsx("div",{className:"local-refs-tabs",role:"group","aria-label":"Branch scope",children:["all","local","remote"].map(s=>e.jsx("button",{type:"button",className:"local-refs-tab","aria-pressed":c===s,disabled:!!i,onClick:()=>{x(s),k(!1)},children:s==="all"?"All":s==="local"?"Local":"Remote"},s))}),c!=="local"&&e.jsx(Ve,{label:"Filter by remote",placeholder:"Search remotes…",value:g,triggerLabel:g||"All remotes",onValueChange:s=>{N(s),k(!1)},disabled:!!i,groups:[{id:"remotes",label:"Remotes",items:[{value:"",label:"All remotes",pinned:!0},...(w?.remotes??[]).map(s=>({value:s,label:s}))]}]}),e.jsx("small",{children:"Remote refs reflect the last fetch."})]}),(xe||Y)&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:xe??Y})]}),z&&e.jsxs("button",{type:"button",className:"local-refs-mobile-back",onClick:()=>k(!1),children:["← Back to ",l]}),e.jsxs("div",{className:"local-refs-body","data-mobile-detail":z,role:"tabpanel",id:`local-refs-panel-${l}`,"aria-labelledby":`local-refs-tab-${l}`,children:[e.jsxs("div",{className:"local-refs-list",role:"listbox","aria-label":l==="branches"?"Branches":"Worktrees",tabIndex:-1,children:[V&&!w&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(L,{className:"animate-spin","aria-hidden":"true"})," Reading the repository…"]}),!V&&Me&&e.jsx("p",{className:"local-refs-placeholder",children:h||g?"No matches for these filters.":`This repository has no ${l==="branches"?`${c==="all"?"":`${c} `}branches`:"worktrees"}.`}),l==="branches"&&Ee.map(s=>e.jsxs("div",{className:"local-refs-branch-group",role:"group","aria-label":s.label,children:[e.jsxs("div",{className:"local-refs-group-heading",children:[e.jsx("span",{children:s.label}),e.jsx("small",{children:s.branches.length})]}),s.branches.map(n=>e.jsxs("button",{type:"button",role:"option","aria-selected":M(n)===P,className:"local-refs-row",disabled:!!i,onClick:()=>{v(M(n)),k(!0)},children:[e.jsxs("span",{className:"local-refs-row-head",children:[n.remote?e.jsx(oe,{"aria-hidden":"true"}):e.jsx(I,{"aria-hidden":"true"}),e.jsx("strong",{children:n.remoteBranchName??n.name}),e.jsx(ee,{badges:Xe(n)})]}),e.jsxs("small",{className:"local-refs-row-meta",children:[e.jsx("code",{children:n.shortOid}),n.subject&&e.jsx("span",{children:n.subject}),n.date&&e.jsx("time",{dateTime:n.date,children:Ze(n.date)})]})]},M(n)))]},s.label)),l==="worktrees"&&se.map(s=>e.jsxs("button",{type:"button",role:"option","aria-selected":A(s)===G,className:"local-refs-row",disabled:!!i,onClick:()=>{_(A(s)),k(!0)},children:[e.jsxs("span",{className:"local-refs-row-head",children:[e.jsx(te,{"aria-hidden":"true"}),e.jsx("strong",{children:ce(s.path)}),e.jsx(ee,{badges:Fe(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})]})]},A(s)))]}),e.jsxs("div",{className:"local-refs-detail",children:[$&&e.jsxs("div",{className:"local-refs-error",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:$})]}),Q&&e.jsxs("p",{className:"local-refs-placeholder",children:[e.jsx(L,{className:"animate-spin","aria-hidden":"true"})," Loading details…"]}),!Q&&!$&&l==="branches"&&S&&j?.remote&&e.jsx(ba,{details:S,pullRequest:ge,anyBusy:!!i,deleting:i==="delete-remote-branch",creating:i==="create-tracking-branch",confirming:ae==="delete-remote-branch",onConfirm:()=>F("delete-remote-branch"),onCancel:()=>F(null),onDelete:()=>{qe(S)},onCreate:s=>{Pe(S,s)},onFetch:()=>{we()},fetching:i==="fetch-branches",onShowLocal:s=>{f(""),x("local"),N(""),v(s)}}),!Q&&!$&&l==="branches"&&R&&j&&!j.remote&&e.jsx(fa,{details:R,pullRequest:ge,busy:i==="delete-branch",anyBusy:!!i,confirming:ae==="delete-branch",actionError:Y,onConfirm:()=>F("delete-branch"),onCancel:()=>F(null),onDelete:s=>{Le(R,s)}}),!Q&&!$&&l==="worktrees"&&E&&K&&e.jsx(xa,{details:E,busy:i==="remove-worktree",anyBusy:!!i,confirming:ae==="remove-worktree",actionError:Y,copied:Se,onConfirm:()=>F("remove-worktree"),onCancel:()=>F(null),onRemove:(s,n)=>{Ge(E,s,n)},onCopyPath:()=>{Oe(E.path)},onOpen:()=>a.onOpenWorktree(E.path),onShowBranch:()=>{E.branch&&(v(`refs/heads/${E.branch}`),f(""),x("local"),N(""),a.onTabChange("branches"))}}),!Q&&!$&&!j&&!K&&e.jsxs("p",{className:"local-refs-placeholder",children:["Select a ",l==="branches"?"branch":"worktree"," to see its details."]})]})]},l),e.jsxs("footer",{className:"local-refs-footer",children:[e.jsx("small",{children:"Deleting a remote branch keeps local branches and worktrees. Removing a worktree deletes its branch only when explicitly selected."}),e.jsx(Ne,{render:e.jsx(b,{variant:"outline",size:"sm",disabled:!!i}),children:"Done"})]})]})})}function fa({details:a,pullRequest:r,busy:l,anyBusy:t,confirming:d,actionError:p,onConfirm:m,onCancel:h,onDelete:f}){const c=aa(a,r),x=c.forceAllowed===!0,g=c.allowed||x;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(I,{"aria-hidden":"true"}),e.jsxs(he,{children:[e.jsx(me,{render:e.jsx("span",{}),children:a.name}),e.jsx(ue,{children:a.name})]})]}),e.jsx(ee,{badges:sa(a)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(y,{label:"Full ref",children:e.jsx("code",{className:"local-refs-selectable",children:a.fullName})}),e.jsxs(y,{label:"Tip",children:[e.jsx("code",{children:a.shortOid})," ",a.subject]}),e.jsx(y,{label:"Author",children:a.author||"—"}),e.jsx(y,{label:"Last commit",children:a.date?ie(a.date):"—"}),e.jsx(y,{label:"Upstream",children:a.upstream?`${a.upstream} · ↑${a.ahead} ↓${a.behind}`:"Not configured"}),e.jsx(y,{label:"Compared with",children:a.comparisonBase??"Not compared"}),r&&e.jsx(y,{label:"GitHub PR",children:e.jsxs("button",{type:"button",className:"local-refs-pr-link",onClick:()=>Be(r.url),children:["#",r.number," · ",r.state==="MERGED"?`Merged into ${r.baseRefName}`:r.state==="OPEN"?"Open":"Closed"," ",e.jsx(de,{"aria-hidden":"true"})]})})]}),e.jsx(Re,{tone:c.allowed?"ready":"blocked",reason:c.reason,actionError:p,confirming:d,busy:l,anyBusy:t,actionLabel:x?"Force delete branch":"Delete branch",confirmLabel:l?"Deleting…":x?"Permanently delete":"Delete branch",allowed:g,confirmation:x?e.jsxs(e.Fragment,{children:["Force-delete the local branch ",e.jsx("strong",{children:a.name}),"? This keeps any remote branch and pull request, but commits found only on this local branch may become inaccessible. ",r?.state==="MERGED"?e.jsxs(e.Fragment,{children:["GitHub reports PR ",e.jsxs("strong",{children:["#",r.number]})," as merged into ",e.jsx("strong",{children:r.baseRefName}),", although local Git cannot verify the ancestry."]}):null]}):e.jsxs(e.Fragment,{children:["Delete the local branch ",e.jsx("strong",{children:a.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:a.comparisonBase}),"."]}),onConfirm:m,onCancel:h,onAct:()=>f(x)})]})}function xa({details:a,busy:r,anyBusy:l,confirming:t,actionError:d,copied:p,onConfirm:m,onCancel:h,onRemove:f,onCopyPath:c,onOpen:x,onShowBranch:g}){const[N,z]=o.useState(!1),k=ra(a),P=la(a),v=k.forceAllowed===!0,G=k.allowed||v;return o.useEffect(()=>z(!1),[a.path]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"local-refs-detail-head",children:[e.jsxs("h3",{children:[e.jsx(te,{"aria-hidden":"true"}),e.jsxs(he,{children:[e.jsx(me,{render:e.jsx("span",{}),children:ce(a.path)}),e.jsx(ue,{children:ce(a.path)})]})]}),e.jsx(ee,{badges:Fe(a)})]}),e.jsxs("dl",{className:"local-refs-facts",children:[e.jsx(y,{label:"Folder",children:e.jsx("span",{className:"local-refs-path local-refs-selectable",children:a.path})}),e.jsx(y,{label:"Branch",children:a.branch??"Detached HEAD"}),e.jsx(y,{label:"HEAD",children:a.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:a.lastCommit.shortOid})," ",a.lastCommit.subject]}):e.jsx("code",{children:a.oid?a.oid.slice(0,7):"—"})}),e.jsx(y,{label:"Committed",children:a.lastCommit?.date?ie(a.lastCommit.date):"—"}),e.jsx(y,{label:"Local changes",children:a.available?P??"None":"Not readable"})]}),e.jsxs("div",{className:"local-refs-detail-actions",children:[e.jsxs(b,{variant:"outline",size:"sm",onClick:c,disabled:l,children:[p?e.jsx(na,{}):e.jsx(oa,{})," ",p?"Copied":"Copy path"]}),!a.current&&a.available&&!a.locked&&e.jsxs(b,{variant:"outline",size:"sm",onClick:x,disabled:l,children:[e.jsx(de,{})," Open worktree"]}),a.branch&&e.jsxs(b,{variant:"ghost",size:"sm",onClick:g,disabled:l,children:[e.jsx(I,{})," Show branch"]})]}),a.branch&&G&&e.jsxs("label",{htmlFor:"remove-worktree-delete-branch",className:"local-refs-delete-branch",children:[e.jsx(da,{id:"remove-worktree-delete-branch",checked:N,onCheckedChange:_=>z(_===!0),disabled:l}),e.jsxs("span",{children:["Also delete branch ",e.jsx("strong",{children:a.branch})]})]}),e.jsx(Re,{tone:k.allowed?"ready":"blocked",reason:k.reason,actionError:d,confirming:t,busy:r,anyBusy:l,actionLabel:v?"Force remove worktree":"Remove worktree",confirmLabel:r?"Removing…":v?"Permanently remove":"Remove worktree",allowed:G,confirmation:e.jsxs(e.Fragment,{children:[v?e.jsxs(e.Fragment,{children:["Permanently remove the worktree at ",e.jsx("strong",{className:"local-refs-path",children:a.path}),"? ",e.jsx("strong",{children:P??`The ${a.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:a.path}),"? The folder is deleted from disk and is ",e.jsx("strong",{children:"not"})," moved to system Trash. "]}),N&&a.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:a.branch})," will also be force-deleted. Commits found only on that branch may become inaccessible."]}):a.branch?e.jsxs(e.Fragment,{children:["The branch ",e.jsx("strong",{children:a.branch})," and its commits stay in the repository."]}):"No branch is deleted."]}),onConfirm:m,onCancel:h,onAct:()=>f(v,N)})]})}function Re({tone:a,reason:r,actionError:l,confirming:t,busy:d,anyBusy:p,allowed:m,actionLabel:h,confirmLabel:f,confirmation:c,onConfirm:x,onCancel:g,onAct:N}){return e.jsxs("div",{className:`local-refs-danger ${a}`,children:[l&&e.jsxs("p",{className:"local-refs-danger-error",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:l})]}),t&&m?e.jsxs("div",{className:"local-refs-confirm",role:"alert",children:[e.jsx(q,{"aria-hidden":"true"}),e.jsx("p",{children:c}),e.jsxs("span",{className:"local-refs-confirm-actions",children:[e.jsxs(b,{variant:"destructive",size:"sm",onClick:N,disabled:d,children:[d?e.jsx(L,{className:"animate-spin"}):e.jsx(Z,{})," ",f]}),e.jsx(b,{variant:"ghost",size:"sm",onClick:g,disabled:d,children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"local-refs-reason",children:[a==="ready"?e.jsx(ta,{"aria-hidden":"true"}):e.jsx(q,{"aria-hidden":"true"}),e.jsx("span",{children:r})]}),m&&e.jsxs(b,{variant:"destructive",size:"sm",onClick:x,disabled:p,children:[e.jsx(Z,{})," ",h]})]})]})}function ee({badges:a}){return a.length===0?null:e.jsx("span",{className:"local-refs-badges",children:a.map(r=>e.jsx(ea,{variant:r.tone==="current"?"default":r.tone==="warning"?"destructive":"outline",children:r.label},r.label))})}function y({label:a,children:r}){return e.jsxs("div",{className:"local-refs-fact",children:[e.jsx("dt",{children:a}),e.jsx("dd",{children:r})]})}function ja(a){switch(a){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 Ce(a){switch(a){case"stale":return"The branch changed since this view loaded. Fetch and review its new tip before trying again.";case"default":return"This is now the remote’s default branch. It was kept.";case"destination-changed":return"The remote destination changed. Review the refreshed details before trying again.";default:return"The remote branch no longer exists. Fetch to update the list."}}function pa(a){switch(a){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 X(a){return a instanceof Error?a.message:String(a)}export{Ca as LocalRefsDialog};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-9dt2ugQA.js","assets/index-DAUK3rnz.js","assets/react-rd22PHbN.js","assets/tanstack-B0Sf7wNU.js","assets/base-ui-CJ8ZIx3d.js","assets/index-BfA4tAc1.css","assets/render-markdown-BtCybfvQ.js","assets/App-BXZLGT86.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
2
- import{r as n,j as r,a as ae}from"./react-rd22PHbN.js";import{c as Q,_ as se,w as ie,s as ce,f as le,T as H,a as $,b as q,o as ue}from"./index-DAUK3rnz.js";import{T as de,Q as me}from"./App-BXZLGT86.js";import{V as pe,a as fe,b as B}from"./viewer-tabs-D-T0xQaq.js";import{u as he,s as we,F as ge,S as ve}from"./EditableFileViewer-CsbifqBO.js";import{r as be}from"./render-markdown-BtCybfvQ.js";/* empty css */import"./tanstack-B0Sf7wNU.js";import"./base-ui-CJ8ZIx3d.js";import"./PierreWorkerPool-Col4k7qz.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-CHjvYpb2.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ke=[["path",{d:"M3 12h7l-3 -3",key:"svg-0"}],["path",{d:"M7 15l3 -3",key:"svg-1"}],["path",{d:"M21 12h-7l3 -3",key:"svg-2"}],["path",{d:"M17 15l-3 -3",key:"svg-3"}],["path",{d:"M9 6v-1a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M9 18v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ye=Q("outline","viewport-narrow","ViewportNarrow",ke);const Ce=[["path",{d:"M10 12h-7l3 -3",key:"svg-0"}],["path",{d:"M6 15l-3 -3",key:"svg-1"}],["path",{d:"M14 12h7l-3 -3",key:"svg-2"}],["path",{d:"M18 15l3 -3",key:"svg-3"}],["path",{d:"M3 6v-1a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M3 18v1a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],xe=Q("outline","viewport-wide","ViewportWide",Ce);function F(m,s){const p=s.trim();if(!p||p.startsWith("#")||p.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(p))return null;const h=p.split(/[?#]/,1)[0];if(!h)return null;let c;try{c=decodeURIComponent(h).replaceAll("\\","/")}catch{return null}const l=c.startsWith("/")?[]:m.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const t of c.split("/"))if(!(!t||t===".")){if(t===".."){if(l.length===0)return null;l.pop();continue}if(Te(t))return null;l.push(t)}return l.length>0?l.join("/"):null}function Te(m){return[...m].some(s=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)}function Me(m,s,p,h,c){const l=document.createElement("template");l.innerHTML=s;const t=new Map;for(const e of l.content.querySelectorAll("img[src]")){if(e.classList.contains("markdown-code-icon"))continue;const i=e.getAttribute("src").trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(i))continue;e.removeAttribute("src"),e.removeAttribute("srcset");const u=F(h,i);if(!u)continue;const v=t.get(u)??[];v.push(e),t.set(u,v)}m.replaceChildren(l.content);let g=!1;const w=[];for(const[e,i]of t)(async()=>{let u;if(de(e)){const f=await c.readFile(p,e);if(f.binary||f.tooLarge)return;u=new Blob([f.content],{type:"image/svg+xml"})}else{const f=await c.readImage(p,e);if(f.status!=="ready")return;u=new Blob([new Uint8Array(f.data)],{type:f.mimeType})}if(g)return;const v=URL.createObjectURL(u);w.push(v);for(const f of i)f.src=v})().catch(()=>{});return()=>{g=!0;for(const e of w)URL.revokeObjectURL(e)}}let Se=0;function K(){return document.documentElement.classList.contains("dark")?"dark":"default"}function Re(m,s,p){const[h,c]=n.useState(K);n.useEffect(()=>{const t=new MutationObserver(()=>c(K()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const l=n.useCallback(async t=>{if(!m.current)return;const g=Array.from(m.current.querySelectorAll(".mermaid"));if(g.length!==0)try{const{default:w}=await se(async()=>{const{default:e}=await import("./mermaid.core-9dt2ugQA.js").then(i=>i.bo);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t()||!m.current)return;w.initialize({startOnLoad:!1,theme:h,securityLevel:"strict"});for(const e of g){const i=e.dataset.mermaidSource;if(i){e.removeAttribute("data-mermaid-error");try{const u=decodeURIComponent(i),v=`mermaid-diagram-${Se++}`,{svg:f,bindFunctions:A}=await w.render(v,u,e);if(t()||!e.isConnected)return;e.innerHTML=f,e.dataset.processed="true",A?.(e)}catch{!t()&&e.isConnected&&(e.textContent=decodeURIComponent(i),e.dataset.mermaidError="Could not render diagram")}}}}catch{for(const w of g)!t()&&w.isConnected&&(w.dataset.mermaidError="Could not load Mermaid")}},[s,m,h]);n.useEffect(()=>{let t=!1;return l(()=>t),()=>{t=!0}},[p,l])}const X="opentig:markdown-content-width",G=/^([a-z][a-z0-9+.-]*:)?\/\//i,je={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Ee(){try{return window.localStorage.getItem(X)==="fit"?"fit":"reading"}catch{return"reading"}}function Ae({html:m,repositoryId:s,markdownPath:p,onClick:h,onLinkHover:c}){const l=n.useRef(null),t=n.useRef(null);n.useLayoutEffect(()=>{const e=l.current?Me(l.current,m,s,p,ue.repository):void 0;return t.current=null,c(null),e},[m,s,p,c]),Re(l,!0,m);const g=n.useCallback(e=>{const i=e.target.closest("a[href]");!i||i===t.current||(t.current=i,c(i))},[c]),w=n.useCallback(e=>{const i=t.current;if(!i)return;const u=e.relatedTarget;u&&i.contains(u)||(t.current=null,c(null))},[c]);return r.jsx("div",{ref:l,className:"markdown-prose",onClick:h,onMouseOver:g,onMouseOut:w})}function Ge({repositoryId:m,file:s,initialContent:p,revision:h,themeType:c,wrapLines:l,readOnly:t,onOpenFile:g,onDirtyChange:w,onDraftChange:e,onSave:i}){const[u,v]=n.useState("preview"),[f,A]=n.useState(Ee),[M,O]=n.useState(""),[_,I]=n.useState(!0),[Y,V]=n.useState(!1),[T,k]=n.useState(null),S=n.useRef(0),C=n.useRef(null),N=n.useRef(null),L=n.useRef(null),x=n.useRef(null),R=n.useRef(null),{draft:P,updateDraft:J,dirty:j,saving:U,save:Z}=he({file:s,initialContent:p,readOnly:t,messages:je,onDirtyChange:w,onDraftChange:e,onSave:i});n.useEffect(()=>{R.current?.(),x.current=null,v("preview")},[s.path]);const ee=n.useCallback(a=>{if(a!==u){if(R.current?.(),u==="preview"){const o=N.current,d=o?o.scrollHeight-o.clientHeight:0;x.current=o&&d>0?o.scrollTop/d:0}else x.current=L.current?.getScrollFraction()??0;v(a)}},[u]);n.useLayoutEffect(()=>{const a=x.current;if(a==null)return;if(u==="code"){x.current=null,L.current?.scrollToFraction(a);return}const o=N.current;!o||_&&!M||(x.current=null,R.current=we({getScrollRange:()=>Math.max(0,o.scrollHeight-o.clientHeight),getScrollTop:()=>o.scrollTop,getContentHeight:()=>o.scrollHeight,scrollTo:d=>{o.scrollTop=d}},a))},[M,_,u]),n.useEffect(()=>()=>R.current?.(),[]),n.useEffect(()=>{const a=++S.current;I(!0);const o=window.setTimeout(()=>{const d=window.__opentigPerformanceAutomation?performance.now():null;be(P).then(b=>{a===S.current&&(O(b),d!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-d)*100)/100})))}).catch(()=>{a===S.current&&O("<p>Could not render Markdown.</p>")}).finally(()=>{a===S.current&&I(!1)})},j?120:0);return()=>window.clearTimeout(o)},[j,P,s.mtimeMs,s.path,h,c]),n.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current.timer)},[]);const te=n.useCallback(async a=>{const o=a.target,d=o.closest("[data-copy-code]");if(d){const W=d.dataset.copyCode;if(!W)return;try{const ne=decodeURIComponent(W);await ie(ne);const E=C.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),d.dataset.copyState="copied",d.setAttribute("aria-label","Copied"),V(!0);const oe=window.setTimeout(()=>{C.current?.button===d&&(delete d.dataset.copyState,d.setAttribute("aria-label","Copy code"),C.current=null,V(!1))},2e3);C.current={button:d,timer:oe}}catch{ce.error({title:"Could not copy code"})}return}const b=o.closest("a[href]"),y=b?.getAttribute("href");if(!b||!y)return;if(a.preventDefault(),y.startsWith("#")){a.currentTarget.querySelector(`#${CSS.escape(y.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if(G.test(y)||y.startsWith("mailto:")){try{le(y)}catch{}return}const z=F(s.path,y);z&&g(z)},[s.path,g]),re=n.useCallback(a=>{if(!a){k(null);return}const o=a.getAttribute("href");if(!o||o.startsWith("#")){k(null);return}const d=a.getBoundingClientRect(),b={top:d.bottom+6,left:d.left};if(o.startsWith("mailto:")){k({...b,label:"Open in mail app",href:o.replace(/^mailto:/,"")});return}if(G.test(o)){k({...b,label:"Open in browser",href:o});return}if(F(s.path,o)){k({...b,label:"Open file",href:o});return}k(null)},[s.path]),D=a=>{A(a);try{window.localStorage.setItem(X,a)}catch{}};return r.jsxs(pe,{value:u,onValueChange:a=>ee(a),className:"markdown-viewer","data-content-width":f,children:[r.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[r.jsx(fe,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:r.jsxs(r.Fragment,{children:["Code ",j&&r.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),r.jsx(ge,{dirty:j,saving:U,readOnly:t,onSave:()=>{Z()}}),r.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":f==="reading",onClick:()=>D("reading")}),children:r.jsx(ye,{"aria-hidden":"true"})}),r.jsx(q,{children:"Reading width"})]}),r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":f==="fit",onClick:()=>D("fit")}),children:r.jsx(xe,{"aria-hidden":"true"})}),r.jsx(q,{children:"Fit to width"})]})]})]}),r.jsxs(B,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>k(null),children:[_&&!M?r.jsx("div",{className:"viewer-message",children:r.jsx(me,{text:"Rendering Markdown…"})}):r.jsx(Ae,{repositoryId:m,markdownPath:s.path,html:M,onClick:a=>{te(a)},onLinkHover:re},`${m}:${s.path}:${h}`),r.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:Y?"Code copied":""}),T?ae.createPortal(r.jsxs("div",{className:"markdown-link-tooltip",style:{top:T.top,left:T.left},role:"tooltip",children:[r.jsx("span",{className:"markdown-link-tooltip-label",children:T.label}),r.jsx("span",{className:"markdown-link-tooltip-href",children:T.href})]}),document.body):null]}),r.jsx(B,{value:"code",className:"markdown-code-view","data-theme":c,children:r.jsx(ve,{ref:L,path:s.path,cacheKey:s.path,value:P,themeType:c,wrapLines:l,readOnly:t||U,onChange:J})})]})}export{Ge as MarkdownFileViewer};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-vLn7mMZB.js","assets/index-B3QJsvjR.js","assets/react-rd22PHbN.js","assets/tanstack-BysN2Oew.js","assets/base-ui-DIP2rZxz.js","assets/index-Cx9LaJW8.css","assets/render-markdown-dvHhHbC0.js","assets/App-BbT5H97Z.js","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
2
+ import{r as n,j as r,a as ae}from"./react-rd22PHbN.js";import{c as X,_ as se,w as ie,s as ce,f as le,T as H,b as $,d as q,o as ue}from"./index-B3QJsvjR.js";import{h as de,g as me}from"./App-BbT5H97Z.js";import{V as pe,a as fe,b as B}from"./viewer-tabs-Cnfyd6rg.js";import{u as he,s as we,F as ge,S as ve}from"./EditableFileViewer-Cmbomx5y.js";import{r as be}from"./render-markdown-dvHhHbC0.js";/* empty css */import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";import"./PierreWorkerPool-BxP-s6jD.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-4o4egqlz.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ke=[["path",{d:"M3 12h7l-3 -3",key:"svg-0"}],["path",{d:"M7 15l3 -3",key:"svg-1"}],["path",{d:"M21 12h-7l3 -3",key:"svg-2"}],["path",{d:"M17 15l-3 -3",key:"svg-3"}],["path",{d:"M9 6v-1a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M9 18v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ye=X("outline","viewport-narrow","ViewportNarrow",ke);const Ce=[["path",{d:"M10 12h-7l3 -3",key:"svg-0"}],["path",{d:"M6 15l-3 -3",key:"svg-1"}],["path",{d:"M14 12h7l-3 -3",key:"svg-2"}],["path",{d:"M18 15l3 -3",key:"svg-3"}],["path",{d:"M3 6v-1a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M3 18v1a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],xe=X("outline","viewport-wide","ViewportWide",Ce);function F(m,s){const p=s.trim();if(!p||p.startsWith("#")||p.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(p))return null;const h=p.split(/[?#]/,1)[0];if(!h)return null;let c;try{c=decodeURIComponent(h).replaceAll("\\","/")}catch{return null}const l=c.startsWith("/")?[]:m.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const t of c.split("/"))if(!(!t||t===".")){if(t===".."){if(l.length===0)return null;l.pop();continue}if(Me(t))return null;l.push(t)}return l.length>0?l.join("/"):null}function Me(m){return[...m].some(s=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)}function Te(m,s,p,h,c){const l=document.createElement("template");l.innerHTML=s;const t=new Map;for(const e of l.content.querySelectorAll("img[src]")){if(e.classList.contains("markdown-code-icon"))continue;const i=e.getAttribute("src").trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(i))continue;e.removeAttribute("src"),e.removeAttribute("srcset");const u=F(h,i);if(!u)continue;const v=t.get(u)??[];v.push(e),t.set(u,v)}m.replaceChildren(l.content);let g=!1;const w=[];for(const[e,i]of t)(async()=>{let u;if(de(e)){const f=await c.readFile(p,e);if(f.binary||f.tooLarge)return;u=new Blob([f.content],{type:"image/svg+xml"})}else{const f=await c.readImage(p,e);if(f.status!=="ready")return;u=new Blob([new Uint8Array(f.data)],{type:f.mimeType})}if(g)return;const v=URL.createObjectURL(u);w.push(v);for(const f of i)f.src=v})().catch(()=>{});return()=>{g=!0;for(const e of w)URL.revokeObjectURL(e)}}let Se=0;function K(){return document.documentElement.classList.contains("dark")?"dark":"default"}function Re(m,s,p){const[h,c]=n.useState(K);n.useEffect(()=>{const t=new MutationObserver(()=>c(K()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const l=n.useCallback(async t=>{if(!m.current)return;const g=Array.from(m.current.querySelectorAll(".mermaid"));if(g.length!==0)try{const{default:w}=await se(async()=>{const{default:e}=await import("./mermaid.core-vLn7mMZB.js").then(i=>i.bo);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t()||!m.current)return;w.initialize({startOnLoad:!1,theme:h,securityLevel:"strict"});for(const e of g){const i=e.dataset.mermaidSource;if(i){e.removeAttribute("data-mermaid-error");try{const u=decodeURIComponent(i),v=`mermaid-diagram-${Se++}`,{svg:f,bindFunctions:A}=await w.render(v,u,e);if(t()||!e.isConnected)return;e.innerHTML=f,e.dataset.processed="true",A?.(e)}catch{!t()&&e.isConnected&&(e.textContent=decodeURIComponent(i),e.dataset.mermaidError="Could not render diagram")}}}}catch{for(const w of g)!t()&&w.isConnected&&(w.dataset.mermaidError="Could not load Mermaid")}},[s,m,h]);n.useEffect(()=>{let t=!1;return l(()=>t),()=>{t=!0}},[p,l])}const Y="opentig:markdown-content-width",G=/^([a-z][a-z0-9+.-]*:)?\/\//i,je={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Ee(){try{return window.localStorage.getItem(Y)==="fit"?"fit":"reading"}catch{return"reading"}}function Ae({html:m,repositoryId:s,markdownPath:p,onClick:h,onLinkHover:c}){const l=n.useRef(null),t=n.useRef(null);n.useLayoutEffect(()=>{const e=l.current?Te(l.current,m,s,p,ue.repository):void 0;return t.current=null,c(null),e},[m,s,p,c]),Re(l,!0,m);const g=n.useCallback(e=>{const i=e.target.closest("a[href]");!i||i===t.current||(t.current=i,c(i))},[c]),w=n.useCallback(e=>{const i=t.current;if(!i)return;const u=e.relatedTarget;u&&i.contains(u)||(t.current=null,c(null))},[c]);return r.jsx("div",{ref:l,className:"markdown-prose",onClick:h,onMouseOver:g,onMouseOut:w})}function Ge({repositoryId:m,file:s,initialContent:p,revision:h,themeType:c,wrapLines:l,readOnly:t,onOpenFile:g,onDirtyChange:w,onDraftChange:e,onSave:i}){const[u,v]=n.useState("preview"),[f,A]=n.useState(Ee),[T,O]=n.useState(""),[_,I]=n.useState(!0),[J,V]=n.useState(!1),[M,k]=n.useState(null),S=n.useRef(0),C=n.useRef(null),N=n.useRef(null),L=n.useRef(null),x=n.useRef(null),R=n.useRef(null),{draft:P,updateDraft:Q,dirty:j,saving:U,save:Z}=he({file:s,initialContent:p,readOnly:t,messages:je,onDirtyChange:w,onDraftChange:e,onSave:i});n.useEffect(()=>{R.current?.(),x.current=null,v("preview")},[s.path]);const ee=n.useCallback(a=>{if(a!==u){if(R.current?.(),u==="preview"){const o=N.current,d=o?o.scrollHeight-o.clientHeight:0;x.current=o&&d>0?o.scrollTop/d:0}else x.current=L.current?.getScrollFraction()??0;v(a)}},[u]);n.useLayoutEffect(()=>{const a=x.current;if(a==null)return;if(u==="code"){x.current=null,L.current?.scrollToFraction(a);return}const o=N.current;!o||_&&!T||(x.current=null,R.current=we({getScrollRange:()=>Math.max(0,o.scrollHeight-o.clientHeight),getScrollTop:()=>o.scrollTop,getContentHeight:()=>o.scrollHeight,scrollTo:d=>{o.scrollTop=d}},a))},[T,_,u]),n.useEffect(()=>()=>R.current?.(),[]),n.useEffect(()=>{const a=++S.current;I(!0);const o=window.setTimeout(()=>{const d=window.__opentigPerformanceAutomation?performance.now():null;be(P).then(b=>{a===S.current&&(O(b),d!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-d)*100)/100})))}).catch(()=>{a===S.current&&O("<p>Could not render Markdown.</p>")}).finally(()=>{a===S.current&&I(!1)})},j?120:0);return()=>window.clearTimeout(o)},[j,P,s.mtimeMs,s.path,h,c]),n.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current.timer)},[]);const te=n.useCallback(async a=>{const o=a.target,d=o.closest("[data-copy-code]");if(d){const W=d.dataset.copyCode;if(!W)return;try{const ne=decodeURIComponent(W);await ie(ne);const E=C.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),d.dataset.copyState="copied",d.setAttribute("aria-label","Copied"),V(!0);const oe=window.setTimeout(()=>{C.current?.button===d&&(delete d.dataset.copyState,d.setAttribute("aria-label","Copy code"),C.current=null,V(!1))},2e3);C.current={button:d,timer:oe}}catch{ce.error({title:"Could not copy code"})}return}const b=o.closest("a[href]"),y=b?.getAttribute("href");if(!b||!y)return;if(a.preventDefault(),y.startsWith("#")){a.currentTarget.querySelector(`#${CSS.escape(y.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if(G.test(y)||y.startsWith("mailto:")){try{le(y)}catch{}return}const z=F(s.path,y);z&&g(z)},[s.path,g]),re=n.useCallback(a=>{if(!a){k(null);return}const o=a.getAttribute("href");if(!o||o.startsWith("#")){k(null);return}const d=a.getBoundingClientRect(),b={top:d.bottom+6,left:d.left};if(o.startsWith("mailto:")){k({...b,label:"Open in mail app",href:o.replace(/^mailto:/,"")});return}if(G.test(o)){k({...b,label:"Open in browser",href:o});return}if(F(s.path,o)){k({...b,label:"Open file",href:o});return}k(null)},[s.path]),D=a=>{A(a);try{window.localStorage.setItem(Y,a)}catch{}};return r.jsxs(pe,{value:u,onValueChange:a=>ee(a),className:"markdown-viewer","data-content-width":f,children:[r.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[r.jsx(fe,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:r.jsxs(r.Fragment,{children:["Code ",j&&r.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),r.jsx(ge,{dirty:j,saving:U,readOnly:t,onSave:()=>{Z()}}),r.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":f==="reading",onClick:()=>D("reading")}),children:r.jsx(ye,{"aria-hidden":"true"})}),r.jsx(q,{children:"Reading width"})]}),r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":f==="fit",onClick:()=>D("fit")}),children:r.jsx(xe,{"aria-hidden":"true"})}),r.jsx(q,{children:"Fit to width"})]})]})]}),r.jsxs(B,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>k(null),children:[_&&!T?r.jsx("div",{className:"viewer-message",children:r.jsx(me,{text:"Rendering Markdown…"})}):r.jsx(Ae,{repositoryId:m,markdownPath:s.path,html:T,onClick:a=>{te(a)},onLinkHover:re},`${m}:${s.path}:${h}`),r.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:J?"Code copied":""}),M?ae.createPortal(r.jsxs("div",{className:"markdown-link-tooltip",style:{top:M.top,left:M.left},role:"tooltip",children:[r.jsx("span",{className:"markdown-link-tooltip-label",children:M.label}),r.jsx("span",{className:"markdown-link-tooltip-href",children:M.href})]}),document.body):null]}),r.jsx(B,{value:"code",className:"markdown-code-view","data-theme":c,children:r.jsx(ve,{ref:L,path:s.path,cacheKey:s.path,value:P,themeType:c,wrapLines:l,readOnly:t||U,onChange:Q})})]})}export{Ge as MarkdownFileViewer};
@@ -0,0 +1 @@
1
+ import{r as c,j as e}from"./react-rd22PHbN.js";import{B as g,e as w,P as j}from"./index-B3QJsvjR.js";import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";async function v(r,i=fetch){try{const a=await i("/api/auth/descriptor",{credentials:"include",cache:"no-store",signal:r});if(!a.ok)return"unavailable";const t=await a.json();return!t||typeof t!="object"||!("authenticated"in t)?"unavailable":t.authenticated===!0?"authenticated":"browserAccessEnabled"in t&&t.browserAccessEnabled===!1?"disabled":t.authenticated===!1?"unpaired":"unavailable"}catch{return"unavailable"}}function y(r,i){const a=r.hash;return i.replaceState(null,"",`${r.pathname}${r.search}`),new URLSearchParams(a.startsWith("#")?a.slice(1):a).get("token")??""}async function k(r,i,a=fetch){try{const t=await a("/api/auth/pair",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r,clientName:i})});if(t.ok)return"paired";if(t.status===403&&t.json){const n=await t.json();if(n&&typeof n=="object"&&"code"in n&&n.code==="WEB_ACCESS_DISABLED")return"disabled"}return"rejected"}catch{return"unavailable"}}function N(r){const i=[[/Edg\//,"Edge"],[/Firefox\//,"Firefox"],[/OPR\//,"Opera"],[/Chrome\//,"Chrome"],[/Safari\//,"Safari"]].find(([t])=>t.test(r))?.[1]??"Browser",a=[[/Windows NT/,"Windows"],[/Android/,"Android"],[/(?:iPhone|iPod)/,"iPhone"],[/iPad/,"iPad"],[/CrOS/,"ChromeOS"],[/Macintosh|Mac OS X/,"Mac"],[/Linux/,"Linux"]].find(([t])=>t.test(r))?.[1];return a?`${i} on ${a}`:i}const f={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.",disabled:"Web access is paused. Enable it in Settings → Web access in the desktop app, then reload. Previously paired browsers keep their access while their session is valid; new devices need a pairing link."};function E(){const[r,i]=c.useState(()=>y(window.location,window.history)),[a,t]=c.useState(()=>N(window.navigator.userAgent)),[n,m]=c.useState("idle"),[d,h]=c.useState("checking"),[b,p]=c.useState(0);c.useEffect(()=>{const s=new AbortController;let o=!0;const l=window.setTimeout(()=>s.abort(),1e4);return v(s.signal).then(u=>{o&&(u==="authenticated"&&window.location.replace("/"),h(u))}).finally(()=>window.clearTimeout(l)),()=>{o=!1,s.abort(),window.clearTimeout(l)}},[b]);const x=async s=>{s.preventDefault();const o=a.trim(),l=r.trim();if(!o||!l||o.length>64)return;m("pairing");const u=await k(l,o);u==="paired"?window.location.replace("/"):m(u)};return d==="disabled"||n==="disabled"?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:"Web access is paused"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",role:"status",children:f.disabled}),e.jsx(g,{className:"mt-5",onClick:()=>{m("idle"),h("checking"),p(s=>s+1)},children:"Check again"})]})}):d!=="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:d==="unavailable"?"Could not check this browser":"Checking this browser…"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",role:"status",children:d==="unavailable"?"Could not verify your saved session. Check your connection and try again.":"Checking your saved session before asking you to pair again."}),d==="unavailable"&&e.jsx(g,{className:"mt-5",onClick:()=>{h("checking"),p(s=>s+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 ",w," desktop app or generated with the command below on the server. It expires after five minutes."]}),e.jsx(j,{}),e.jsxs("form",{className:"mt-5 grid gap-4",onSubmit:s=>{x(s)},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:r,onChange:s=>i(s.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:a,onChange:s=>t(s.target.value),maxLength:64,autoComplete:"off",required:!0})]}),e.jsx(g,{type:"submit",disabled:n==="pairing"||!r.trim()||!a.trim(),children:n==="pairing"?"Pairing…":"Pair browser"})]}),(n==="rejected"||n==="unavailable")&&e.jsx("p",{className:"mt-4 text-sm text-destructive",role:"alert",children:f[n]}),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{E as default};
@@ -1 +1 @@
1
- import{r as k,j as g}from"./react-rd22PHbN.js";import{t as w,a6 as E,n as Y,a7 as j,a8 as O,B as Z,d as M,E as ee,A as ne,a3 as te,_ as ie,a4 as R,a5 as oe,P as re,a as se,V as T,O as U,r as $}from"./PierreWorkerPool-Col4k7qz.js";import{F as le}from"./File-CHjvYpb2.js";import{D as V,b as P,f as ce}from"./platform-Bqt97_Jr.js";import{a as de,g as J,b as Q,F as ae,p as b,c as ue,s as fe,r as he,D as pe}from"./DiffWorkspace-RDG_Y70N.js";import{a as H}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-DAUK3rnz.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-BXZLGT86.js";import"./tanstack-B0Sf7wNU.js";import"./base-ui-CJ8ZIx3d.js";var _=class extends de{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:V},n,t){super(void 0,n,t),this.options=e}setConflictState(e,n,t){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,t)}syncInjectedRows(e,n,t){this.injectedRows.clear();for(const i of e){const r=i!=null?J(i,t):void 0;if(i==null||r==null)continue;const o={type:"actions",hunkIndex:r.hunkIndex,lineIndex:r.lineIndex,conflictIndex:i.conflictIndex};this.addInjectedRow(o)}for(const i of n)this.addInjectedRow(i)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,t=this.injectedRows.get(n);t==null?this.injectedRows.set(n,[e]):t.push(e)}renderDiff(e,n=P){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=P){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const t=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:B(t),contentProperties:W(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:B(t),contentProperties:W(n,t)}}getUnifiedInjectedRowsForLine=e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:t}=this.getOptionsWithDefaults(),i=[],r=[];for(const o of n){if(o.type==="actions"){i.push({content:Ce({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:G("action")});continue}(o.type==="marker-end"?r:i).push({content:me(o),gutter:G("marker",o.type)})}return{before:i.length>0?i:void 0,after:r.length>0?r:void 0}};getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function B(e){return e!=null?{"data-merge-conflict":e}:void 0}function W(e,n){if(n!=null){if(e==="change")return n==="current"||n==="incoming"?{"data-line-type":"context","data-merge-conflict":n}:void 0;if(n==="marker-start"||n==="marker-base"||n==="marker-separator"||n==="marker-end")return{"data-merge-conflict":n}}}function G(e,n){const t=Y(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function Ce({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?xe(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Q({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:e.conflictIndex}),"data-merge-conflict-action-slot":""}})),w({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[w({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function me(e){return w({tagName:"div",properties:{"data-merge-conflict":e.type,"data-merge-conflict-marker-row":""},children:[E(e.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function xe(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),K(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),K(),y({resolution:"both",label:"Accept both",conflictIndex:e})]}function y({resolution:e,label:n,conflictIndex:t}){return w({tagName:"button",properties:{type:"button","data-merge-conflict-action":e,"data-merge-conflict-conflict-index":`${t}`},children:[E(n)]})}function K(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function ge(e,n){return e.hunkIndex===n.hunkIndex&&e.startContentIndex===n.startContentIndex&&e.endContentIndex===n.endContentIndex&&e.currentContentIndex===n.currentContentIndex&&e.baseContentIndex===n.baseContentIndex&&e.incomingContentIndex===n.incomingContentIndex&&e.endMarkerContentIndex===n.endMarkerContentIndex&&e.conflictIndex===n.conflictIndex&&Le(e.conflict,n.conflict)}function Le(e,n){return e.conflictIndex===n.conflictIndex&&e.startLineIndex===n.startLineIndex&&e.startLineNumber===n.startLineNumber&&e.separatorLineIndex===n.separatorLineIndex&&e.separatorLineNumber===n.separatorLineNumber&&e.endLineIndex===n.endLineIndex&&e.endLineNumber===n.endLineNumber&&e.baseMarkerLineIndex===n.baseMarkerLineIndex&&e.baseMarkerLineNumber===n.baseMarkerLineNumber}function Ie(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function ve(e,n){const{resolution:t,hunkIndex:i,startContentIndex:r,endContentIndex:o,indexesToDelete:s=new Set}=n,l=e.hunks[i];if(l==null)throw console.error({diff:e,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||o>=l.hunkContent.length||r>o)throw new Error(`resolveRegion: Invalid content range, ${r}, ${o}`);const{hunks:d,additionLines:a,deletionLines:f}=e,h={...e,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:e.cacheKey!=null?`${e.cacheKey}:${t[0]}-${i}:${r}-${o}`:void 0},u={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},L=i===d.length-1&&o===l.hunkContent.length-1,A=!e.isPartial;for(const[p,x]of d.entries()){ke(e,h,u,j(x.deletionStart,x.deletionCount)-x.collapsedBefore,j(x.additionStart,x.additionCount)-x.collapsedBefore,x.collapsedBefore,A);const c={...x,hunkContent:[],additionStart:u.nextAdditionStart,deletionStart:u.nextDeletionStart,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:u.splitLineCount,unifiedLineStart:u.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[m,C]of x.hunkContent.entries())if(p!==i||m<r||m>o){z(C,h,f,a);const v={...C,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex};c.hunkContent.push(v),S(v,u,c)}else if(s.has(m))c.hunkContent.push({type:"context",lines:0,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex});else if(C.type==="context"){z(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{Ae(t,C,h,f,a);const v={type:"context",lines:t==="deletions"?C.deletions:t==="additions"?C.additions:C.deletions+C.additions,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}if(p===i&&L){const m=t==="deletions"?x.noEOFCRDeletions:x.noEOFCRAdditions;c.noEOFCRAdditions=m,c.noEOFCRDeletions=m}c.additionCount===0&&(c.additionStart--,e.isPartial||c.additionLineIndex--),c.deletionCount===0&&(c.deletionStart--,e.isPartial||c.deletionLineIndex--),h.hunks.push(c)}const I=d.at(-1);if(I!=null&&!e.isPartial){const p=O(I.deletionStart,I.deletionCount),x=O(I.additionStart,I.additionCount),c=Math.min(f.length-p,a.length-x);X(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function X(e,n,t,i,r,o){for(let s=0;s<o;s++){const l=n[i+s],d=t[r+s];if(l==null||d==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");e.deletionLines.push(l),e.additionLines.push(d)}}function ke(e,n,t,i,r,o,s){o<=0||(s&&(X(n,e.deletionLines,e.additionLines,i,r,o),t.nextAdditionLineIndex+=o,t.nextDeletionLineIndex+=o),t.nextAdditionStart+=o,t.nextDeletionStart+=o,t.splitLineCount+=o,t.unifiedLineCount+=o)}function z(e,n,t,i){if(e.type==="context")for(let r=0;r<e.lines;r++){const o=i[e.additionLineIndex+r];if(o==null)throw console.error({additionLines:i,content:e,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}else{const r=Math.max(e.deletions,e.additions);for(let o=0;o<r;o++){if(o<e.deletions){const s=t[e.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:t,content:e,i:o}),new Error("pushContentLinesToDiff: Deletion line does not exist");n.deletionLines.push(s)}if(o<e.additions){const s=i[e.additionLineIndex+o];if(s==null)throw console.error({additionLines:i,content:e,i:o}),new Error("pushContentLinesToDiff: Addition line does not exist");n.additionLines.push(s)}}}}function Ae(e,n,t,i,r){if(e==="deletions"||e==="both")for(let o=0;o<n.deletions;o++){const s=i[n.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:i,content:n,i:o}),new Error("pushResolveLinesToDiff: Deletion line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}if(e==="additions"||e==="both")for(let o=0;o<n.additions;o++){const s=r[n.additionLineIndex+o];if(s==null)throw console.error({additionLines:r,content:n,i:o}),new Error("pushResolveLinesToDiff: Addition line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}}function S(e,n,t){e.type==="context"?(n.nextAdditionLineIndex+=e.lines,n.nextDeletionLineIndex+=e.lines,n.nextAdditionStart+=e.lines,n.nextDeletionStart+=e.lines,n.splitLineCount+=e.lines,n.unifiedLineCount+=e.lines,t.additionCount+=e.lines,t.deletionCount+=e.lines,t.splitLineCount+=e.lines,t.unifiedLineCount+=e.lines):(n.nextAdditionLineIndex+=e.additions,n.nextDeletionLineIndex+=e.deletions,n.nextAdditionStart+=e.additions,n.nextDeletionStart+=e.deletions,n.splitLineCount+=Math.max(e.deletions,e.additions),n.unifiedLineCount+=e.deletions+e.additions,t.deletionCount+=e.deletions,t.deletionLines+=e.deletions,t.additionCount+=e.additions,t.additionLines+=e.additions,t.splitLineCount+=Math.max(e.deletions,e.additions),t.unifiedLineCount+=e.deletions+e.additions)}function we(e,n,t){return ve(e,{resolution:Ie(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:Re(n)})}function Re(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let De=-1;var Me=class extends ae{options;__id=`unresolved-file:${++De}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:V},t,i=!1){super(void 0,t,i),this.options=n,this.setOptions(n)}setOptions(n){if(n!=null){if(n.onMergeConflictAction!=null&&n.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=n,this.hunksRenderer.setOptions(this.getHunksRendererOptions(n)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions(Z(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex,this.handleMergeConflictActionClick))}createHunksRenderer(n){return new _(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Te(n,this.options)}applyPreNodeAttributes(n,t){super.applyPreNodeAttributes(n,t,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:n,fileDiff:t,actions:i,markerRows:r}){const{maxContextLines:o,onMergeConflictAction:s}=this.options;e:if(s!=null){const l=t!=null;if(l!==(i!=null)||l!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(t!=null&&i!=null&&r!=null){this.computedCache={file:n??this.computedCache.file,fileDiff:t,actions:i,markerRows:r};break e}else if(n!=null||this.computedCache.file!=null){if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(n??=this.computedCache.file,n==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!M(n,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=b(n,o);this.computedCache={file:n,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(t!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if(this.computedCache.file??=n,this.computedCache.fileDiff==null&&this.computedCache.file!=null){const l=b(this.computedCache.file,o);this.computedCache.fileDiff=l.fileDiff,this.computedCache.actions=l.actions,this.computedCache.markerRows=l.markerRows}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(t==null||i==null||r==null))return{fileDiff:t,actions:i,markerRows:r}}hydrate(n){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,fileContainer:l,prerenderedHTML:d,preventEmit:a=!1}=n,f=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});f!=null&&(this.hydrateElements(l,d),this.setActiveMergeConflictState(f.actions,f.markerRows),je(this.pre,f.fileDiff,this.options.collapsed)||Oe(this.headerElement,f.fileDiff,this.options.disableFileHeader)?this.render({...n,preventEmit:!0}):(this.hydrationSetup({fileDiff:f.fileDiff,lineAnnotations:s}),this.pre!=null&&this.renderMergeConflictActionSlots()),a||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(n={}){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,preventEmit:l=!1,...d}=n,a=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});if(a==null)return!1;this.setActiveMergeConflictState(a.actions,a.markerRows);const f=super.render({...d,fileDiff:a.fileDiff,lineAnnotations:s,preventEmit:!0});return f&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),f}resolveConflict(n,t,i=this.computedCache.fileDiff){const r=this.conflictActions[n];if(i==null||r==null)return;if(r.conflictIndex!==n)throw console.error({conflictIndex:n,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const o=we(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=ye({fileDiff:o,previousActions:this.conflictActions,resolvedConflictIndex:n,previousFile:s,resolution:t});return{file:l,fileDiff:o,actions:d,markerRows:a}}resolveConflictAndRender(n,t){const i=this.conflictActions[n];if(i==null)return;if(i.conflictIndex!==n)throw console.error({conflictIndex:n,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:t,conflict:i.conflict},{file:o,fileDiff:s,actions:l,markerRows:d}=this.resolveConflict(n,t)??{};o==null||s==null||l==null||d==null||(this.computedCache={file:o,fileDiff:s,actions:l,markerRows:d},this.setActiveMergeConflictState(l,d),this.workerManager!=null?this.hunksRenderer.renderDiff(s):this.render({forceRender:!0}),this.options.onMergeConflictResolve?.(o,r))}setActiveMergeConflictState(n=this.conflictActions,t=this.markerRows){this.conflictActions=n,this.markerRows=t,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof _&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:n,t,this.computedCache.fileDiff)}handleMergeConflictActionClick=n=>{const t=this.conflictActions[n.conflictIndex];if(t==null)return;if(t.conflictIndex!==n.conflictIndex)throw console.error({conflictIndex:n.conflictIndex,action:t}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:n.resolution,conflict:t.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(n.conflictIndex,n.resolution)};renderMergeConflictActionSlots(){const{fileDiff:n}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||n==null){this.clearMergeConflictActionCache();return}const t=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const o=J(r,n);if(o==null)continue;const s=r.conflictIndex,l=Q({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!ge(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=ee(l);h.appendChild(f),this.fileContainer.appendChild(h),a={element:h,action:r},this.conflictActionCache.set(d,a)}t.delete(d)}for(const[i,{element:r}]of t.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(n){if(typeof this.options.mergeConflictActionsType!="function")return;const t=this.options.mergeConflictActionsType(n,this);if(t!=null){if(t instanceof HTMLElement)return t;if(typeof DocumentFragment<"u"&&t instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(t),i}}}clearMergeConflictActionCache(){for(const{element:n}of this.conflictActionCache.values())n.remove();this.conflictActionCache.clear()}};function ye({fileDiff:e,previousActions:n,resolvedConflictIndex:t,previousFile:i,resolution:r}){const o=n[t];if(o==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const s=Ee(n,t,o,r),l=ue(e,s);return{file:Se({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function Se({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=fe(t?.contents??""),{conflict:s}=e,l=be(o,s,r),d=[...o.slice(0,s.startLineIndex),...l,...o.slice(s.endLineIndex+1)].join("");return{name:t?.name??i.name,contents:d,cacheKey:t?.cacheKey!=null?`${t.cacheKey}:mc-${n}-${r}`:void 0}}function be(e,n,t){const i=e.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),r=e.slice(n.separatorLineIndex+1,n.endLineIndex);return t==="current"?i:t==="incoming"?r:[...i,...r]}function Ee(e,n,t,i){const r=Fe(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Ne(o.conflict,r)}:o})}function Fe(e,n){const t=(e.baseMarkerLineIndex??e.separatorLineIndex)-e.startLineIndex-1,i=e.endLineIndex-e.separatorLineIndex-1;return(n==="current"?t:n==="incoming"?i:t+i)-(e.endLineIndex-e.startLineIndex+1)}function Ne(e,n){return{...e,startLineIndex:e.startLineIndex+n,startLineNumber:e.startLineNumber+n,separatorLineIndex:e.separatorLineIndex+n,separatorLineNumber:e.separatorLineNumber+n,endLineIndex:e.endLineIndex+n,endLineNumber:e.endLineNumber+n,baseMarkerLineIndex:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+n:void 0,baseMarkerLineNumber:e.baseMarkerLineNumber!=null?e.baseMarkerLineNumber+n:void 0}}function je(e,n,t=!1){return!t&&e==null&&n!=null}function Oe(e,n,t=!1){return e==null&&n!=null&&!t}function Te(e,n){const t={...n,...e};return{...t,useTokenTransformer:ne(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Ue=typeof window>"u"?k.useEffect:k.useLayoutEffect;function $e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:r,hasConflictUtility:o,hasGutterRenderUtility:s,hasCustomHeader:l,disableWorkerPool:d}){const[{fileDiff:a,actions:f,markerRows:h},u]=k.useState(()=>{const{fileDiff:c,actions:m,markerRows:C}=b(e,n?.maxContextLines);return{fileDiff:c,actions:m,markerRows:C}}),L=H((c,m)=>{u(C=>{const{fileDiff:v,actions:F,markerRows:N}=m.resolveConflict(c.conflict.conflictIndex,c.resolution,C.fileDiff)??{};return v==null||F==null||N==null?C:{fileDiff:v,actions:F,markerRows:N}})}),A=i!==void 0,I=k.useContext(te),p=k.useRef(null),x=H(c=>{if(c!=null){if(p.current!=null)throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");p.current=new Me(q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),d?void 0:I,!0),p.current.hydrate({fileDiff:a,actions:f,markerRows:h,fileContainer:c,lineAnnotations:t,prerenderedHTML:r})}else{if(p.current==null)throw new Error("useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting");p.current.cleanUp(),p.current=null}});return Ue(()=>{if(p.current==null)return;const c=p.current,m=q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!ie(c.options,m);c.setOptions(m),c.render({fileDiff:a,actions:f,markerRows:h,lineAnnotations:t,forceRender:C}),i!==void 0&&c.setSelectedLines(i)}),{ref:x,getHoveredLine:k.useCallback(()=>p.current?.getHoveredLine(),[]),fileDiff:a,actions:f,markerRows:h,getInstance:k.useCallback(()=>p.current??void 0,[])}}function q({options:e,controlledSelection:n,onMergeConflictAction:t,hasConflictUtility:i,hasCustomHeader:r,hasGutterRenderUtility:o}){return{...e,controlledSelection:n,onMergeConflictAction:t,hunkSeparators:e?.hunkSeparators==="custom"?R:e?.hunkSeparators,mergeConflictActionsType:i||e?.mergeConflictActionsType==="custom"?R:e?.mergeConflictActionsType,renderCustomHeader:r?R:void 0,renderGutterUtility:o?R:void 0}}function Pe({file:e,options:n,lineAnnotations:t,selectedLines:i,className:r,style:o,prerenderedHTML:s,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderGutterUtility:u,renderMergeConflictUtility:L,disableWorkerPool:A=!1}){const{ref:I,getHoveredLine:p,fileDiff:x,actions:c,getInstance:m}=$e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(ce,{ref:I,className:r,style:o,children:oe(he({fileDiff:x,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderAnnotation:l,renderGutterUtility:u,lineAnnotations:t,getHoveredLine:p,actions:c,renderMergeConflictUtility:L,getInstance:m}),s)})}function He(e){return{draft:e,persistedContent:e,revision:0}}function _e(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function Be(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function We(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function dn(e){return g.jsx(re,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(Ge,{...e}):g.jsx(Ke,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function Ge({contentKey:e,value:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f}){return g.jsx(pe,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function Ke({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>He(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=ze(h);k.useEffect(()=>{s(p=>We(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=qe(h,p,x);s(C=>_e(C,m));try{await i(e.path,m)?s(C=>Be(C,m)):s(C=>C.draft===m?c:C)}finally{d(!1)}},I=async()=>{if(!(L>0||a)){f(!0);try{await r(e.path,h)}finally{f(!1)}}};return g.jsxs("div",{className:"conflict-viewer",children:[g.jsxs("div",{className:"conflict-viewer-toolbar",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Conflict resolution"}),g.jsx("span",{children:L>0?`${L} ${L===1?"pending block":"pending blocks"}`:"All blocks are resolved"})]}),g.jsx(D,{size:"sm",disabled:L>0||a,onClick:()=>{I()},children:a?"Saving…":"Mark as resolved"})]}),g.jsx(se,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx(Pe,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:conflict:${u}`},disableWorkerPool:h.length>5e5,options:{themeType:n,theme:U,diffIndicators:"classic",overflow:t,mergeConflictActionsType:"none",unsafeCSS:T},renderMergeConflictUtility:p=>g.jsxs("div",{className:"conflict-actions",children:[g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"current")},children:"Accept current"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"incoming")},children:"Accept incoming"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"both")},children:"Accept both"})]})},`${e.path}:${u}`):g.jsx(le,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function ze(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function qe(e,n,t){const i=e.match(/[^\n]*\n|[^\n]+$/g)??[],r=i.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),o=i.slice(n.separatorLineIndex+1,n.endLineIndex),s=t==="current"?r:t==="incoming"?o:[...r,...o];return[...i.slice(0,n.startLineIndex),...s,...i.slice(n.endLineIndex+1)].join("")}export{dn as default};
1
+ import{r as k,j as g}from"./react-rd22PHbN.js";import{t as w,a6 as E,n as Y,a7 as j,a8 as O,B as Z,d as M,E as ee,A as ne,a3 as te,_ as ie,a4 as R,a5 as oe,P as re,a as se,V as T,O as U,r as $}from"./PierreWorkerPool-BxP-s6jD.js";import{F as le}from"./File-4o4egqlz.js";import{D as V,b as P,f as ce}from"./platform-Bqt97_Jr.js";import{a as de,g as J,b as Q,F as ae,p as b,c as ue,s as fe,r as he,D as pe}from"./DiffWorkspace-DJX00otP.js";import{a as H}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-B3QJsvjR.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-BbT5H97Z.js";import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";var _=class extends de{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:V},n,t){super(void 0,n,t),this.options=e}setConflictState(e,n,t){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,t)}syncInjectedRows(e,n,t){this.injectedRows.clear();for(const i of e){const r=i!=null?J(i,t):void 0;if(i==null||r==null)continue;const o={type:"actions",hunkIndex:r.hunkIndex,lineIndex:r.lineIndex,conflictIndex:i.conflictIndex};this.addInjectedRow(o)}for(const i of n)this.addInjectedRow(i)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,t=this.injectedRows.get(n);t==null?this.injectedRows.set(n,[e]):t.push(e)}renderDiff(e,n=P){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=P){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const t=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:B(t),contentProperties:W(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:B(t),contentProperties:W(n,t)}}getUnifiedInjectedRowsForLine=e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:t}=this.getOptionsWithDefaults(),i=[],r=[];for(const o of n){if(o.type==="actions"){i.push({content:Ce({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:G("action")});continue}(o.type==="marker-end"?r:i).push({content:me(o),gutter:G("marker",o.type)})}return{before:i.length>0?i:void 0,after:r.length>0?r:void 0}};getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function B(e){return e!=null?{"data-merge-conflict":e}:void 0}function W(e,n){if(n!=null){if(e==="change")return n==="current"||n==="incoming"?{"data-line-type":"context","data-merge-conflict":n}:void 0;if(n==="marker-start"||n==="marker-base"||n==="marker-separator"||n==="marker-end")return{"data-merge-conflict":n}}}function G(e,n){const t=Y(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function Ce({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?xe(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Q({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:e.conflictIndex}),"data-merge-conflict-action-slot":""}})),w({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[w({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function me(e){return w({tagName:"div",properties:{"data-merge-conflict":e.type,"data-merge-conflict-marker-row":""},children:[E(e.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function xe(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),K(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),K(),y({resolution:"both",label:"Accept both",conflictIndex:e})]}function y({resolution:e,label:n,conflictIndex:t}){return w({tagName:"button",properties:{type:"button","data-merge-conflict-action":e,"data-merge-conflict-conflict-index":`${t}`},children:[E(n)]})}function K(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function ge(e,n){return e.hunkIndex===n.hunkIndex&&e.startContentIndex===n.startContentIndex&&e.endContentIndex===n.endContentIndex&&e.currentContentIndex===n.currentContentIndex&&e.baseContentIndex===n.baseContentIndex&&e.incomingContentIndex===n.incomingContentIndex&&e.endMarkerContentIndex===n.endMarkerContentIndex&&e.conflictIndex===n.conflictIndex&&Le(e.conflict,n.conflict)}function Le(e,n){return e.conflictIndex===n.conflictIndex&&e.startLineIndex===n.startLineIndex&&e.startLineNumber===n.startLineNumber&&e.separatorLineIndex===n.separatorLineIndex&&e.separatorLineNumber===n.separatorLineNumber&&e.endLineIndex===n.endLineIndex&&e.endLineNumber===n.endLineNumber&&e.baseMarkerLineIndex===n.baseMarkerLineIndex&&e.baseMarkerLineNumber===n.baseMarkerLineNumber}function Ie(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function ve(e,n){const{resolution:t,hunkIndex:i,startContentIndex:r,endContentIndex:o,indexesToDelete:s=new Set}=n,l=e.hunks[i];if(l==null)throw console.error({diff:e,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||o>=l.hunkContent.length||r>o)throw new Error(`resolveRegion: Invalid content range, ${r}, ${o}`);const{hunks:d,additionLines:a,deletionLines:f}=e,h={...e,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:e.cacheKey!=null?`${e.cacheKey}:${t[0]}-${i}:${r}-${o}`:void 0},u={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},L=i===d.length-1&&o===l.hunkContent.length-1,A=!e.isPartial;for(const[p,x]of d.entries()){ke(e,h,u,j(x.deletionStart,x.deletionCount)-x.collapsedBefore,j(x.additionStart,x.additionCount)-x.collapsedBefore,x.collapsedBefore,A);const c={...x,hunkContent:[],additionStart:u.nextAdditionStart,deletionStart:u.nextDeletionStart,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:u.splitLineCount,unifiedLineStart:u.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[m,C]of x.hunkContent.entries())if(p!==i||m<r||m>o){z(C,h,f,a);const v={...C,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex};c.hunkContent.push(v),S(v,u,c)}else if(s.has(m))c.hunkContent.push({type:"context",lines:0,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex});else if(C.type==="context"){z(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{Ae(t,C,h,f,a);const v={type:"context",lines:t==="deletions"?C.deletions:t==="additions"?C.additions:C.deletions+C.additions,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}if(p===i&&L){const m=t==="deletions"?x.noEOFCRDeletions:x.noEOFCRAdditions;c.noEOFCRAdditions=m,c.noEOFCRDeletions=m}c.additionCount===0&&(c.additionStart--,e.isPartial||c.additionLineIndex--),c.deletionCount===0&&(c.deletionStart--,e.isPartial||c.deletionLineIndex--),h.hunks.push(c)}const I=d.at(-1);if(I!=null&&!e.isPartial){const p=O(I.deletionStart,I.deletionCount),x=O(I.additionStart,I.additionCount),c=Math.min(f.length-p,a.length-x);X(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function X(e,n,t,i,r,o){for(let s=0;s<o;s++){const l=n[i+s],d=t[r+s];if(l==null||d==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");e.deletionLines.push(l),e.additionLines.push(d)}}function ke(e,n,t,i,r,o,s){o<=0||(s&&(X(n,e.deletionLines,e.additionLines,i,r,o),t.nextAdditionLineIndex+=o,t.nextDeletionLineIndex+=o),t.nextAdditionStart+=o,t.nextDeletionStart+=o,t.splitLineCount+=o,t.unifiedLineCount+=o)}function z(e,n,t,i){if(e.type==="context")for(let r=0;r<e.lines;r++){const o=i[e.additionLineIndex+r];if(o==null)throw console.error({additionLines:i,content:e,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}else{const r=Math.max(e.deletions,e.additions);for(let o=0;o<r;o++){if(o<e.deletions){const s=t[e.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:t,content:e,i:o}),new Error("pushContentLinesToDiff: Deletion line does not exist");n.deletionLines.push(s)}if(o<e.additions){const s=i[e.additionLineIndex+o];if(s==null)throw console.error({additionLines:i,content:e,i:o}),new Error("pushContentLinesToDiff: Addition line does not exist");n.additionLines.push(s)}}}}function Ae(e,n,t,i,r){if(e==="deletions"||e==="both")for(let o=0;o<n.deletions;o++){const s=i[n.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:i,content:n,i:o}),new Error("pushResolveLinesToDiff: Deletion line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}if(e==="additions"||e==="both")for(let o=0;o<n.additions;o++){const s=r[n.additionLineIndex+o];if(s==null)throw console.error({additionLines:r,content:n,i:o}),new Error("pushResolveLinesToDiff: Addition line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}}function S(e,n,t){e.type==="context"?(n.nextAdditionLineIndex+=e.lines,n.nextDeletionLineIndex+=e.lines,n.nextAdditionStart+=e.lines,n.nextDeletionStart+=e.lines,n.splitLineCount+=e.lines,n.unifiedLineCount+=e.lines,t.additionCount+=e.lines,t.deletionCount+=e.lines,t.splitLineCount+=e.lines,t.unifiedLineCount+=e.lines):(n.nextAdditionLineIndex+=e.additions,n.nextDeletionLineIndex+=e.deletions,n.nextAdditionStart+=e.additions,n.nextDeletionStart+=e.deletions,n.splitLineCount+=Math.max(e.deletions,e.additions),n.unifiedLineCount+=e.deletions+e.additions,t.deletionCount+=e.deletions,t.deletionLines+=e.deletions,t.additionCount+=e.additions,t.additionLines+=e.additions,t.splitLineCount+=Math.max(e.deletions,e.additions),t.unifiedLineCount+=e.deletions+e.additions)}function we(e,n,t){return ve(e,{resolution:Ie(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:Re(n)})}function Re(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let De=-1;var Me=class extends ae{options;__id=`unresolved-file:${++De}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:V},t,i=!1){super(void 0,t,i),this.options=n,this.setOptions(n)}setOptions(n){if(n!=null){if(n.onMergeConflictAction!=null&&n.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=n,this.hunksRenderer.setOptions(this.getHunksRendererOptions(n)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions(Z(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex,this.handleMergeConflictActionClick))}createHunksRenderer(n){return new _(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Te(n,this.options)}applyPreNodeAttributes(n,t){super.applyPreNodeAttributes(n,t,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:n,fileDiff:t,actions:i,markerRows:r}){const{maxContextLines:o,onMergeConflictAction:s}=this.options;e:if(s!=null){const l=t!=null;if(l!==(i!=null)||l!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(t!=null&&i!=null&&r!=null){this.computedCache={file:n??this.computedCache.file,fileDiff:t,actions:i,markerRows:r};break e}else if(n!=null||this.computedCache.file!=null){if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(n??=this.computedCache.file,n==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!M(n,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=b(n,o);this.computedCache={file:n,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(t!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if(this.computedCache.file??=n,this.computedCache.fileDiff==null&&this.computedCache.file!=null){const l=b(this.computedCache.file,o);this.computedCache.fileDiff=l.fileDiff,this.computedCache.actions=l.actions,this.computedCache.markerRows=l.markerRows}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(t==null||i==null||r==null))return{fileDiff:t,actions:i,markerRows:r}}hydrate(n){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,fileContainer:l,prerenderedHTML:d,preventEmit:a=!1}=n,f=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});f!=null&&(this.hydrateElements(l,d),this.setActiveMergeConflictState(f.actions,f.markerRows),je(this.pre,f.fileDiff,this.options.collapsed)||Oe(this.headerElement,f.fileDiff,this.options.disableFileHeader)?this.render({...n,preventEmit:!0}):(this.hydrationSetup({fileDiff:f.fileDiff,lineAnnotations:s}),this.pre!=null&&this.renderMergeConflictActionSlots()),a||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(n={}){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,preventEmit:l=!1,...d}=n,a=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});if(a==null)return!1;this.setActiveMergeConflictState(a.actions,a.markerRows);const f=super.render({...d,fileDiff:a.fileDiff,lineAnnotations:s,preventEmit:!0});return f&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),f}resolveConflict(n,t,i=this.computedCache.fileDiff){const r=this.conflictActions[n];if(i==null||r==null)return;if(r.conflictIndex!==n)throw console.error({conflictIndex:n,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const o=we(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=ye({fileDiff:o,previousActions:this.conflictActions,resolvedConflictIndex:n,previousFile:s,resolution:t});return{file:l,fileDiff:o,actions:d,markerRows:a}}resolveConflictAndRender(n,t){const i=this.conflictActions[n];if(i==null)return;if(i.conflictIndex!==n)throw console.error({conflictIndex:n,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:t,conflict:i.conflict},{file:o,fileDiff:s,actions:l,markerRows:d}=this.resolveConflict(n,t)??{};o==null||s==null||l==null||d==null||(this.computedCache={file:o,fileDiff:s,actions:l,markerRows:d},this.setActiveMergeConflictState(l,d),this.workerManager!=null?this.hunksRenderer.renderDiff(s):this.render({forceRender:!0}),this.options.onMergeConflictResolve?.(o,r))}setActiveMergeConflictState(n=this.conflictActions,t=this.markerRows){this.conflictActions=n,this.markerRows=t,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof _&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:n,t,this.computedCache.fileDiff)}handleMergeConflictActionClick=n=>{const t=this.conflictActions[n.conflictIndex];if(t==null)return;if(t.conflictIndex!==n.conflictIndex)throw console.error({conflictIndex:n.conflictIndex,action:t}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:n.resolution,conflict:t.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(n.conflictIndex,n.resolution)};renderMergeConflictActionSlots(){const{fileDiff:n}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||n==null){this.clearMergeConflictActionCache();return}const t=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const o=J(r,n);if(o==null)continue;const s=r.conflictIndex,l=Q({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!ge(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=ee(l);h.appendChild(f),this.fileContainer.appendChild(h),a={element:h,action:r},this.conflictActionCache.set(d,a)}t.delete(d)}for(const[i,{element:r}]of t.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(n){if(typeof this.options.mergeConflictActionsType!="function")return;const t=this.options.mergeConflictActionsType(n,this);if(t!=null){if(t instanceof HTMLElement)return t;if(typeof DocumentFragment<"u"&&t instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(t),i}}}clearMergeConflictActionCache(){for(const{element:n}of this.conflictActionCache.values())n.remove();this.conflictActionCache.clear()}};function ye({fileDiff:e,previousActions:n,resolvedConflictIndex:t,previousFile:i,resolution:r}){const o=n[t];if(o==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const s=Ee(n,t,o,r),l=ue(e,s);return{file:Se({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function Se({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=fe(t?.contents??""),{conflict:s}=e,l=be(o,s,r),d=[...o.slice(0,s.startLineIndex),...l,...o.slice(s.endLineIndex+1)].join("");return{name:t?.name??i.name,contents:d,cacheKey:t?.cacheKey!=null?`${t.cacheKey}:mc-${n}-${r}`:void 0}}function be(e,n,t){const i=e.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),r=e.slice(n.separatorLineIndex+1,n.endLineIndex);return t==="current"?i:t==="incoming"?r:[...i,...r]}function Ee(e,n,t,i){const r=Fe(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Ne(o.conflict,r)}:o})}function Fe(e,n){const t=(e.baseMarkerLineIndex??e.separatorLineIndex)-e.startLineIndex-1,i=e.endLineIndex-e.separatorLineIndex-1;return(n==="current"?t:n==="incoming"?i:t+i)-(e.endLineIndex-e.startLineIndex+1)}function Ne(e,n){return{...e,startLineIndex:e.startLineIndex+n,startLineNumber:e.startLineNumber+n,separatorLineIndex:e.separatorLineIndex+n,separatorLineNumber:e.separatorLineNumber+n,endLineIndex:e.endLineIndex+n,endLineNumber:e.endLineNumber+n,baseMarkerLineIndex:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+n:void 0,baseMarkerLineNumber:e.baseMarkerLineNumber!=null?e.baseMarkerLineNumber+n:void 0}}function je(e,n,t=!1){return!t&&e==null&&n!=null}function Oe(e,n,t=!1){return e==null&&n!=null&&!t}function Te(e,n){const t={...n,...e};return{...t,useTokenTransformer:ne(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Ue=typeof window>"u"?k.useEffect:k.useLayoutEffect;function $e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:r,hasConflictUtility:o,hasGutterRenderUtility:s,hasCustomHeader:l,disableWorkerPool:d}){const[{fileDiff:a,actions:f,markerRows:h},u]=k.useState(()=>{const{fileDiff:c,actions:m,markerRows:C}=b(e,n?.maxContextLines);return{fileDiff:c,actions:m,markerRows:C}}),L=H((c,m)=>{u(C=>{const{fileDiff:v,actions:F,markerRows:N}=m.resolveConflict(c.conflict.conflictIndex,c.resolution,C.fileDiff)??{};return v==null||F==null||N==null?C:{fileDiff:v,actions:F,markerRows:N}})}),A=i!==void 0,I=k.useContext(te),p=k.useRef(null),x=H(c=>{if(c!=null){if(p.current!=null)throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");p.current=new Me(q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),d?void 0:I,!0),p.current.hydrate({fileDiff:a,actions:f,markerRows:h,fileContainer:c,lineAnnotations:t,prerenderedHTML:r})}else{if(p.current==null)throw new Error("useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting");p.current.cleanUp(),p.current=null}});return Ue(()=>{if(p.current==null)return;const c=p.current,m=q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!ie(c.options,m);c.setOptions(m),c.render({fileDiff:a,actions:f,markerRows:h,lineAnnotations:t,forceRender:C}),i!==void 0&&c.setSelectedLines(i)}),{ref:x,getHoveredLine:k.useCallback(()=>p.current?.getHoveredLine(),[]),fileDiff:a,actions:f,markerRows:h,getInstance:k.useCallback(()=>p.current??void 0,[])}}function q({options:e,controlledSelection:n,onMergeConflictAction:t,hasConflictUtility:i,hasCustomHeader:r,hasGutterRenderUtility:o}){return{...e,controlledSelection:n,onMergeConflictAction:t,hunkSeparators:e?.hunkSeparators==="custom"?R:e?.hunkSeparators,mergeConflictActionsType:i||e?.mergeConflictActionsType==="custom"?R:e?.mergeConflictActionsType,renderCustomHeader:r?R:void 0,renderGutterUtility:o?R:void 0}}function Pe({file:e,options:n,lineAnnotations:t,selectedLines:i,className:r,style:o,prerenderedHTML:s,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderGutterUtility:u,renderMergeConflictUtility:L,disableWorkerPool:A=!1}){const{ref:I,getHoveredLine:p,fileDiff:x,actions:c,getInstance:m}=$e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(ce,{ref:I,className:r,style:o,children:oe(he({fileDiff:x,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderAnnotation:l,renderGutterUtility:u,lineAnnotations:t,getHoveredLine:p,actions:c,renderMergeConflictUtility:L,getInstance:m}),s)})}function He(e){return{draft:e,persistedContent:e,revision:0}}function _e(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function Be(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function We(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function dn(e){return g.jsx(re,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(Ge,{...e}):g.jsx(Ke,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function Ge({contentKey:e,value:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f}){return g.jsx(pe,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function Ke({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>He(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=ze(h);k.useEffect(()=>{s(p=>We(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=qe(h,p,x);s(C=>_e(C,m));try{await i(e.path,m)?s(C=>Be(C,m)):s(C=>C.draft===m?c:C)}finally{d(!1)}},I=async()=>{if(!(L>0||a)){f(!0);try{await r(e.path,h)}finally{f(!1)}}};return g.jsxs("div",{className:"conflict-viewer",children:[g.jsxs("div",{className:"conflict-viewer-toolbar",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Conflict resolution"}),g.jsx("span",{children:L>0?`${L} ${L===1?"pending block":"pending blocks"}`:"All blocks are resolved"})]}),g.jsx(D,{size:"sm",disabled:L>0||a,onClick:()=>{I()},children:a?"Saving…":"Mark as resolved"})]}),g.jsx(se,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx(Pe,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:conflict:${u}`},disableWorkerPool:h.length>5e5,options:{themeType:n,theme:U,diffIndicators:"classic",overflow:t,mergeConflictActionsType:"none",unsafeCSS:T},renderMergeConflictUtility:p=>g.jsxs("div",{className:"conflict-actions",children:[g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"current")},children:"Accept current"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"incoming")},children:"Accept incoming"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"both")},children:"Accept both"})]})},`${e.path}:${u}`):g.jsx(le,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function ze(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function qe(e,n,t){const i=e.match(/[^\n]*\n|[^\n]+$/g)??[],r=i.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),o=i.slice(n.separatorLineIndex+1,n.endLineIndex),s=t==="current"?r:t==="incoming"?o:[...r,...o];return[...i.slice(0,n.startLineIndex),...s,...i.slice(n.endLineIndex+1)].join("")}export{dn as default};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BzmFkR37.js","assets/platform-Bqt97_Jr.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
2
- import{_ as l,s as E,r as f}from"./index-DAUK3rnz.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-B0Sf7wNU.js";import"./base-ui-CJ8ZIx3d.js";function C({enabled:s,children:a}){const[r,n]=o.useState(null);o.useEffect(()=>{if(!s||r)return;let e=!0;return l(()=>import("./index-BzmFkR37.js"),__vite__mapDeps([0,1,2])).then(t=>{e&&n(()=>t.Editor)}).catch(t=>{e&&E.error({title:"Could not load the code editor",description:t instanceof Error?t.message:"Unknown error"})}),()=>{e=!1}},[r,s]);const u=o.useCallback(e=>{if(!r)throw new Error("Pierre edit mode has not loaded.");return new r({clipboard:{readText:()=>f()},...e})},[r]);return r?i.jsx(c,{createEditor:u,children:i.jsx(d.Provider,{value:!0,children:a})}):i.jsx(d.Provider,{value:!1,children:a})}export{C as PierreEditBoundary};
2
+ import{_ as l,s as E,r as f}from"./index-B3QJsvjR.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-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";function C({enabled:s,children:a}){const[r,n]=o.useState(null);o.useEffect(()=>{if(!s||r)return;let e=!0;return l(()=>import("./index-BzmFkR37.js"),__vite__mapDeps([0,1,2])).then(t=>{e&&n(()=>t.Editor)}).catch(t=>{e&&E.error({title:"Could not load the code editor",description:t instanceof Error?t.message:"Unknown error"})}),()=>{e=!1}},[r,s]);const u=o.useCallback(e=>{if(!r)throw new Error("Pierre edit mode has not loaded.");return new r({clipboard:{readText:()=>f()},...e})},[r]);return r?i.jsx(c,{createEditor:u,children:i.jsx(d.Provider,{value:!0,children:a})}):i.jsx(d.Provider,{value:!1,children:a})}export{C as PierreEditBoundary};