@opentig/cli 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/bin.mjs +2 -2
- package/dist/chunks/{cli-BgNif2D1.mjs → cli-Bi6ET5UT.mjs} +15 -2
- package/dist/client/assets/App-BXZLGT86.js +74 -0
- package/dist/client/assets/CreatePullRequestDialog-DFonMYEx.js +2 -0
- package/dist/client/assets/{DiffWorkspace-Ca2ZUlVn.js → DiffWorkspace-RDG_Y70N.js} +5 -5
- package/dist/client/assets/{EditableFileViewer-85aEeMBK.js → EditableFileViewer-CsbifqBO.js} +1 -1
- package/dist/client/assets/{File-DTtWrbYf.js → File-CHjvYpb2.js} +1 -1
- package/dist/client/assets/FilesView-Dl8QFbFA.js +1 -0
- package/dist/client/assets/GitHubAvatar-CnBaloV0.js +1 -0
- package/dist/client/assets/HistoryView-BgCZU2JO.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-bL6T57PQ.js → HtmlFileViewer-h8ULU8Gy.js} +1 -1
- package/dist/client/assets/{IconEdit-DePJMGIi.js → IconEdit-Cg8S2wqW.js} +1 -1
- package/dist/client/assets/IconFolderSymlink-BZSLX1ez.js +1 -0
- package/dist/client/assets/{ImageFileViewer-DJaHH3hJ.js → ImageFileViewer-Cjw58ckv.js} +1 -1
- package/dist/client/assets/LocalRefsDialog-DNgrd7Qp.js +1 -0
- package/dist/client/assets/{MarkdownFileViewer-BNPb9v8u.js → MarkdownFileViewer-kLiduag6.js} +2 -2
- package/dist/client/assets/{PairingPage-D9oguvKU.js → PairingPage-C97sv-8s.js} +1 -1
- package/dist/client/assets/{PierreDiffViewer-8wTLYd5-.js → PierreDiffViewer-eAcugmoF.js} +1 -1
- package/dist/client/assets/{PierreEditBoundary-KzU3HDc2.js → PierreEditBoundary-DlGd1pqO.js} +1 -1
- package/dist/client/assets/{PierreWorkerPool-DH2jp9oe.js → PierreWorkerPool-Col4k7qz.js} +1 -1
- package/dist/client/assets/{PullRequestDiff-DK-m07ZP.js → PullRequestDiff-DhKTXyIF.js} +1 -1
- package/dist/client/assets/PullRequestViewer-BgI8HFMe.js +2 -0
- package/dist/client/assets/PullRequestsView-PYWLy8We.js +1 -0
- package/dist/client/assets/QuickOpenDialog-BFDDZVCL.js +1 -0
- package/dist/client/assets/RepositoryProjectsDialog-CvB8KcFp.js +1 -0
- package/dist/client/assets/SearchView-BwF_MsxK.js +1 -0
- package/dist/client/assets/SettingsDialog-DIcLmXSE.js +9 -0
- package/dist/client/assets/Viewer-o1hDU33O.js +3 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-CkHOGdAl.js → abnfDiagram-N423BO3Z-BvrnK_R-.js} +1 -1
- package/dist/client/assets/{arc-Dj8F8CO5.js → arc-DLa3_7ua.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-g87Y5LXk.js → architectureDiagram-T3A2C74G-BexwhnyX.js} +1 -1
- package/dist/client/assets/base-ui-CJ8ZIx3d.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-D6efB7jD.js → blockDiagram-VBNYF7ZC-CoOttUUo.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-DoZEC2xg.js → c4Diagram-5PPSVZJV-Bgp6ppUh.js} +1 -1
- package/dist/client/assets/channel-1k1AYpyV.js +1 -0
- package/dist/client/assets/{checkbox-DYwmgDPS.js → checkbox-BRH0ZNIC.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-Dr44hDNV.js → chunk-2GRJ4B5K-C_kzp38w.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-YIEyVOOL.js → chunk-2Q5K7J3B-CysYnRkJ.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-gjmGBtkE.js → chunk-5RXB4S5H-oMS6x_ag.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DCOQko4g.js → chunk-5VM5RSS4-C5-dW5wf.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-DfGlvPVm.js → chunk-6Q2QTUOP-DxahInnA.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-CCWOLPVL.js → chunk-GF5L2VYU-D7V-3eRg.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-CFRTGh8r.js → chunk-JWPE2WC7-BrLmjbVP.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-By3wsJVD.js → chunk-KBJHAD2P-CyOvijwM.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-C0wmsHmy.js → chunk-RYQCIY6F-BvEjVjQs.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-t3SnJvV_.js → chunk-XXDRQBXY-C_IY9A64.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-ChyNFpay.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-ChyNFpay.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-D3VltoVk.js → cose-bilkent-JH36ORCC-Cu7qZi7h.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-DwLwbeoe.js → cynefin-VYW2F7L2-B4M1t9lL.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-B23kuaQF.js → cynefinDiagram-MW4NZA55-CAosOLmT.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-SgMrTr2p.js → dagre-VZM6K2ZE-q354V538.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-C7cQN4aD.js → diagram-7IWD3JNH-C_CzkBPt.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-CzeI3yOw.js → diagram-B4RE2ZJO-VvvYHE9c.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-DhKm4hlI.js → diagram-LBJQPF4R-D8vRQwb5.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-BXlU6Wp3.js → diagram-Q27KOJAE-Bul4aDKg.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-BOwY_YwR.js → diagram-UB23O5K3-DNadEE58.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-CuIQuYPa.js → ebnfDiagram-BXEA7PRR-Bf-68MMZ.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-d45NhKfk.js → erDiagram-JOGREHBK-CJ-jHFsf.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-Dzq-6qo7.js → flowDiagram-UKHOOZJN-DMOdinBU.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-RVlL9mX2.js → ganttDiagram-PKOTCBZU-DzezS3Zy.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-8kEJVUFH.js → gitGraphDiagram-DS77QQ5N-Dftpvns8.js} +1 -1
- package/dist/client/assets/index-BfA4tAc1.css +1 -0
- package/dist/client/assets/{index-CQcx9aRt.js → index-DAUK3rnz.js} +4 -4
- package/dist/client/assets/{infoDiagram-6WML65LV-Co21Ql9M.js → infoDiagram-6WML65LV-DmgUBq17.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-BvPB_G97.js → ishikawaDiagram-WSZJBQD7-CL0PQhpQ.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-k7x89IE9.js → journeyDiagram-NVQOT4AX-Ck4pQx_A.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-BjrgN30t.js → kanban-definition-27J2QSJJ-DuRZxBql.js} +1 -1
- package/dist/client/assets/{linear-m158kske.js → linear-C2JDCaz4.js} +1 -1
- package/dist/client/assets/{mermaid.core-C0FKucv-.js → mermaid.core-9dt2ugQA.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-CF8noycK.js → mindmap-definition-FAOFIHXS-vy0fdDF0.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-_y7nfJFV.js → pegDiagram-VL7TDLO6-DjVJy-Gm.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-DhdWHi45.js → pieDiagram-7S7Q4E2Y-ATbd_8vw.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-BRvEIECQ.js → quadrantDiagram-CIZ2JOQS-C8o6ofcl.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-BgLZ8XU1.js → railroadDiagram-AXF67PYL-Qvij9Ubo.js} +1 -1
- package/dist/client/assets/{render-markdown-2GjhuGA-.js → render-markdown-BtCybfvQ.js} +6 -6
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-CX-gxyGF.js → requirementDiagram-LRYGKXZP-yLfrba2h.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-CLSjSU_X.js → sankeyDiagram-W5VNT64P-BTXRtTyG.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-dGlHyZRB.js → sequenceDiagram-SI44F4Z6-BN1CCZIX.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-BH3qO9T3.js → sizeCapture-X5ZJPWSS-BfXjBBYo.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-FXxo1iIM.js → stateDiagram-OKZ733FA-DMAWiBsP.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-D_ofZeaa.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-VJGIuM4S.js → swimlanes-SLNWSIFB-BD20m5cw.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-CF9m5JSB.js +8 -0
- package/dist/client/assets/{tanstack-CtfgE41X.js → tanstack-B0Sf7wNU.js} +1 -1
- package/dist/client/assets/{timeline-definition-Z64GVDOM-BXNTAanY.js → timeline-definition-Z64GVDOM-gtc0-AHB.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-D9nXAts5.js → vennDiagram-T6HMQDX7-Cdr4AXTp.js} +1 -1
- package/dist/client/assets/viewer-tabs-D-T0xQaq.js +1 -0
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-D89EaEfa.js → wardleyDiagram-T6FBY63Y-BcU4vxO8.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-B_xFDiIh.js → xychartDiagram-ELKLHX3M-B3Zuadj8.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +1 -1
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +526 -127
- package/dist/utility.mjs +1 -1
- package/package.json +2 -2
- package/dist/client/assets/App-9EfSdZB8.js +0 -74
- package/dist/client/assets/CreatePullRequestDialog-BgVrWdkH.js +0 -2
- package/dist/client/assets/FilesView-rT5hzb7y.js +0 -1
- package/dist/client/assets/GitHubAvatar-EO1TD_1z.js +0 -1
- package/dist/client/assets/HistoryView-C4c0CqMC.js +0 -1
- package/dist/client/assets/IconFolderPlus-ByGyA0Di.js +0 -1
- package/dist/client/assets/LocalRefsDialog-D9wYZWBg.js +0 -1
- package/dist/client/assets/PullRequestViewer-CpLwq4o2.js +0 -2
- package/dist/client/assets/PullRequestsView-DnvXaJ4t.js +0 -1
- package/dist/client/assets/QuickOpenDialog-DIWjfUkt.js +0 -1
- package/dist/client/assets/RepositoryProjectsDialog-BsQn5Yjr.js +0 -1
- package/dist/client/assets/SearchView-D-91dtSv.js +0 -1
- package/dist/client/assets/SettingsDialog-dJUYk2cP.js +0 -9
- package/dist/client/assets/Viewer-GH-5bJW4.js +0 -3
- package/dist/client/assets/base-ui-DT3JsyND.js +0 -1
- package/dist/client/assets/channel-Dsy2VD23.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BBQJgoWd.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BBQJgoWd.js +0 -1
- package/dist/client/assets/gh-utils-LsOSydCg.js +0 -1
- package/dist/client/assets/index-DMbFAH51.css +0 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-DqxQ14yP.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-No0dCAkd.js +0 -8
- package/dist/client/assets/viewer-tabs-DkLmDzFg.js +0 -1
package/dist/client/assets/{MarkdownFileViewer-BNPb9v8u.js → MarkdownFileViewer-kLiduag6.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
2
|
-
import{r as n,j as r,a as ae}from"./react-rd22PHbN.js";import{c as J,_ as se,w as ie,s as ce,e as le,T as H,a as $,b as q,o as ue}from"./index-CQcx9aRt.js";import{J as de,G as me}from"./App-9EfSdZB8.js";import{V as pe,a as fe,b as B}from"./viewer-tabs-DkLmDzFg.js";import{u as he,s as we,F as ge,S as ve}from"./EditableFileViewer-85aEeMBK.js";import{r as be}from"./render-markdown-2GjhuGA-.js";/* empty css */import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";import"./PierreWorkerPool-DH2jp9oe.js";import"./platform-Bqt97_Jr.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./File-DTtWrbYf.js";import"./EditContext-CvJWfVl1.js";import"./edit-ready-context-D77R8XU8.js";const ke=[["path",{d:"M3 12h7l-3 -3",key:"svg-0"}],["path",{d:"M7 15l3 -3",key:"svg-1"}],["path",{d:"M21 12h-7l3 -3",key:"svg-2"}],["path",{d:"M17 15l-3 -3",key:"svg-3"}],["path",{d:"M9 6v-1a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M9 18v1a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],ye=J("outline","viewport-narrow","ViewportNarrow",ke);const Ce=[["path",{d:"M10 12h-7l3 -3",key:"svg-0"}],["path",{d:"M6 15l-3 -3",key:"svg-1"}],["path",{d:"M14 12h7l-3 -3",key:"svg-2"}],["path",{d:"M18 15l3 -3",key:"svg-3"}],["path",{d:"M3 6v-1a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v1",key:"svg-4"}],["path",{d:"M3 18v1a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2v-1",key:"svg-5"}]],xe=J("outline","viewport-wide","ViewportWide",Ce);function F(m,s){const p=s.trim();if(!p||p.startsWith("#")||p.startsWith("//")||/^[a-z][a-z\d+.-]*:/i.test(p))return null;const h=p.split(/[?#]/,1)[0];if(!h)return null;let c;try{c=decodeURIComponent(h).replaceAll("\\","/")}catch{return null}const l=c.startsWith("/")?[]:m.replaceAll("\\","/").split("/").slice(0,-1).filter(Boolean);for(const t of c.split("/"))if(!(!t||t===".")){if(t===".."){if(l.length===0)return null;l.pop();continue}if(Me(t))return null;l.push(t)}return l.length>0?l.join("/"):null}function Me(m){return[...m].some(s=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)}function Te(m,s,p,h,c){const l=document.createElement("template");l.innerHTML=s;const t=new Map;for(const e of l.content.querySelectorAll("img[src]")){if(e.classList.contains("markdown-code-icon"))continue;const i=e.getAttribute("src").trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(i))continue;e.removeAttribute("src"),e.removeAttribute("srcset");const u=F(h,i);if(!u)continue;const v=t.get(u)??[];v.push(e),t.set(u,v)}m.replaceChildren(l.content);let g=!1;const w=[];for(const[e,i]of t)(async()=>{let u;if(de(e)){const f=await c.readFile(p,e);if(f.binary||f.tooLarge)return;u=new Blob([f.content],{type:"image/svg+xml"})}else{const f=await c.readImage(p,e);if(f.status!=="ready")return;u=new Blob([new Uint8Array(f.data)],{type:f.mimeType})}if(g)return;const v=URL.createObjectURL(u);w.push(v);for(const f of i)f.src=v})().catch(()=>{});return()=>{g=!0;for(const e of w)URL.revokeObjectURL(e)}}let Se=0;function K(){return document.documentElement.classList.contains("dark")?"dark":"default"}function Re(m,s,p){const[h,c]=n.useState(K);n.useEffect(()=>{const t=new MutationObserver(()=>c(K()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const l=n.useCallback(async t=>{if(!m.current)return;const g=Array.from(m.current.querySelectorAll(".mermaid"));if(g.length!==0)try{const{default:w}=await se(async()=>{const{default:e}=await import("./mermaid.core-C0FKucv-.js").then(i=>i.bo);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));if(t()||!m.current)return;w.initialize({startOnLoad:!1,theme:h,securityLevel:"strict"});for(const e of g){const i=e.dataset.mermaidSource;if(i){e.removeAttribute("data-mermaid-error");try{const u=decodeURIComponent(i),v=`mermaid-diagram-${Se++}`,{svg:f,bindFunctions:A}=await w.render(v,u,e);if(t()||!e.isConnected)return;e.innerHTML=f,e.dataset.processed="true",A?.(e)}catch{!t()&&e.isConnected&&(e.textContent=decodeURIComponent(i),e.dataset.mermaidError="Could not render diagram")}}}}catch{for(const w of g)!t()&&w.isConnected&&(w.dataset.mermaidError="Could not load Mermaid")}},[s,m,h]);n.useEffect(()=>{let t=!1;return l(()=>t),()=>{t=!0}},[p,l])}const X="opentig:markdown-content-width",G=/^([a-z][a-z0-9+.-]*:)?\/\//i,je={conflictTitle:"Markdown was changed outside OpenTig",successTitle:"Markdown saved",errorTitle:"Could not save Markdown"};function Ee(){try{return window.localStorage.getItem(X)==="fit"?"fit":"reading"}catch{return"reading"}}function Ae({html:m,repositoryId:s,markdownPath:p,onClick:h,onLinkHover:c}){const l=n.useRef(null),t=n.useRef(null);n.useLayoutEffect(()=>{const e=l.current?Te(l.current,m,s,p,ue.repository):void 0;return t.current=null,c(null),e},[m,s,p,c]),Re(l,!0,m);const g=n.useCallback(e=>{const i=e.target.closest("a[href]");!i||i===t.current||(t.current=i,c(i))},[c]),w=n.useCallback(e=>{const i=t.current;if(!i)return;const u=e.relatedTarget;u&&i.contains(u)||(t.current=null,c(null))},[c]);return r.jsx("div",{ref:l,className:"markdown-prose",onClick:h,onMouseOver:g,onMouseOut:w})}function Ge({repositoryId:m,file:s,initialContent:p,revision:h,themeType:c,wrapLines:l,readOnly:t,onOpenFile:g,onDirtyChange:w,onDraftChange:e,onSave:i}){const[u,v]=n.useState("preview"),[f,A]=n.useState(Ee),[T,O]=n.useState(""),[_,I]=n.useState(!0),[Y,V]=n.useState(!1),[M,k]=n.useState(null),S=n.useRef(0),C=n.useRef(null),N=n.useRef(null),L=n.useRef(null),x=n.useRef(null),R=n.useRef(null),{draft:P,updateDraft:Q,dirty:j,saving:U,save:Z}=he({file:s,initialContent:p,readOnly:t,messages:je,onDirtyChange:w,onDraftChange:e,onSave:i});n.useEffect(()=>{R.current?.(),x.current=null,v("preview")},[s.path]);const ee=n.useCallback(a=>{if(a!==u){if(R.current?.(),u==="preview"){const o=N.current,d=o?o.scrollHeight-o.clientHeight:0;x.current=o&&d>0?o.scrollTop/d:0}else x.current=L.current?.getScrollFraction()??0;v(a)}},[u]);n.useLayoutEffect(()=>{const a=x.current;if(a==null)return;if(u==="code"){x.current=null,L.current?.scrollToFraction(a);return}const o=N.current;!o||_&&!T||(x.current=null,R.current=we({getScrollRange:()=>Math.max(0,o.scrollHeight-o.clientHeight),getScrollTop:()=>o.scrollTop,getContentHeight:()=>o.scrollHeight,scrollTo:d=>{o.scrollTop=d}},a))},[T,_,u]),n.useEffect(()=>()=>R.current?.(),[]),n.useEffect(()=>{const a=++S.current;I(!0);const o=window.setTimeout(()=>{const d=window.__opentigPerformanceAutomation?performance.now():null;be(P).then(b=>{a===S.current&&(O(b),d!==null&&(window.__opentigPerformanceResults??=[],window.__opentigPerformanceResults.push({kind:"markdown-render",durationMs:Math.round((performance.now()-d)*100)/100})))}).catch(()=>{a===S.current&&O("<p>Could not render Markdown.</p>")}).finally(()=>{a===S.current&&I(!1)})},j?120:0);return()=>window.clearTimeout(o)},[j,P,s.mtimeMs,s.path,h,c]),n.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current.timer)},[]);const te=n.useCallback(async a=>{const o=a.target,d=o.closest("[data-copy-code]");if(d){const W=d.dataset.copyCode;if(!W)return;try{const ne=decodeURIComponent(W);await ie(ne);const E=C.current;E&&(window.clearTimeout(E.timer),delete E.button.dataset.copyState,E.button.setAttribute("aria-label","Copy code")),d.dataset.copyState="copied",d.setAttribute("aria-label","Copied"),V(!0);const oe=window.setTimeout(()=>{C.current?.button===d&&(delete d.dataset.copyState,d.setAttribute("aria-label","Copy code"),C.current=null,V(!1))},2e3);C.current={button:d,timer:oe}}catch{ce.error({title:"Could not copy code"})}return}const b=o.closest("a[href]"),y=b?.getAttribute("href");if(!b||!y)return;if(a.preventDefault(),y.startsWith("#")){a.currentTarget.querySelector(`#${CSS.escape(y.slice(1))}`)?.scrollIntoView({behavior:"smooth",block:"start"});return}if(G.test(y)||y.startsWith("mailto:")){try{le(y)}catch{}return}const z=F(s.path,y);z&&g(z)},[s.path,g]),re=n.useCallback(a=>{if(!a){k(null);return}const o=a.getAttribute("href");if(!o||o.startsWith("#")){k(null);return}const d=a.getBoundingClientRect(),b={top:d.bottom+6,left:d.left};if(o.startsWith("mailto:")){k({...b,label:"Open in mail app",href:o.replace(/^mailto:/,"")});return}if(G.test(o)){k({...b,label:"Open in browser",href:o});return}if(F(s.path,o)){k({...b,label:"Open file",href:o});return}k(null)},[s.path]),D=a=>{A(a);try{window.localStorage.setItem(X,a)}catch{}};return r.jsxs(pe,{value:u,onValueChange:a=>ee(a),className:"markdown-viewer","data-content-width":f,children:[r.jsxs("div",{className:"file-viewer-pill markdown-viewer-toolbar",children:[r.jsx(fe,{label:"Markdown view",className:"file-viewer-tabs markdown-viewer-tabs",items:[{value:"preview",label:"Preview"},{value:"code",label:r.jsxs(r.Fragment,{children:["Code ",j&&r.jsx("span",{className:"markdown-unsaved-dot","aria-label":"Unsaved changes"})]})}]}),r.jsx(ge,{dirty:j,saving:U,readOnly:t,onSave:()=>{Z()}}),r.jsxs("div",{className:"markdown-width-toggle",role:"group","aria-label":"Markdown content width",children:[r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Reading width","aria-pressed":f==="reading",onClick:()=>D("reading")}),children:r.jsx(ye,{"aria-hidden":"true"})}),r.jsx(q,{children:"Reading width"})]}),r.jsxs(H,{children:[r.jsx($,{render:r.jsx("button",{type:"button","aria-label":"Fit to width","aria-pressed":f==="fit",onClick:()=>D("fit")}),children:r.jsx(xe,{"aria-hidden":"true"})}),r.jsx(q,{children:"Fit to width"})]})]})]}),r.jsxs(B,{ref:N,value:"preview",className:"markdown-preview-scroll",onScroll:()=>k(null),children:[_&&!T?r.jsx("div",{className:"viewer-message",children:r.jsx(me,{text:"Rendering Markdown…"})}):r.jsx(Ae,{repositoryId:m,markdownPath:s.path,html:T,onClick:a=>{te(a)},onLinkHover:re},`${m}:${s.path}:${h}`),r.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:Y?"Code copied":""}),M?ae.createPortal(r.jsxs("div",{className:"markdown-link-tooltip",style:{top:M.top,left:M.left},role:"tooltip",children:[r.jsx("span",{className:"markdown-link-tooltip-label",children:M.label}),r.jsx("span",{className:"markdown-link-tooltip-href",children:M.href})]}),document.body):null]}),r.jsx(B,{value:"code",className:"markdown-code-view","data-theme":c,children:r.jsx(ve,{ref:L,path:s.path,cacheKey:s.path,value:P,themeType:c,wrapLines:l,readOnly:t||U,onChange:Q})})]})}export{Ge as MarkdownFileViewer};
|
|
1
|
+
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 +1 @@
|
|
|
1
|
-
import{r as o,j as e}from"./react-rd22PHbN.js";import{B as g,
|
|
1
|
+
import{r as o,j as e}from"./react-rd22PHbN.js";import{B as g,e as b,P as w}from"./index-DAUK3rnz.js";import"./tanstack-B0Sf7wNU.js";import"./base-ui-CJ8ZIx3d.js";async function v(a,i=fetch){try{const t=await i("/api/auth/descriptor",{credentials:"include",cache:"no-store",signal:a});if(!t.ok)return"unavailable";const n=await t.json();return!n||typeof n!="object"||!("authenticated"in n)?"unavailable":n.authenticated===!0?"authenticated":n.authenticated===!1?"unpaired":"unavailable"}catch{return"unavailable"}}function y(a,i){const t=a.hash;return i.replaceState(null,"",`${a.pathname}${a.search}`),new URLSearchParams(t.startsWith("#")?t.slice(1):t).get("token")??""}async function j(a,i,t=fetch){try{return(await t("/api/auth/pair",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,clientName:i})})).ok?"paired":"rejected"}catch{return"unavailable"}}function k(a){const i=[[/Edg\//,"Edge"],[/Firefox\//,"Firefox"],[/OPR\//,"Opera"],[/Chrome\//,"Chrome"],[/Safari\//,"Safari"]].find(([n])=>n.test(a))?.[1]??"Browser",t=[[/Windows NT/,"Windows"],[/Android/,"Android"],[/(?:iPhone|iPod)/,"iPhone"],[/iPad/,"iPad"],[/CrOS/,"ChromeOS"],[/Macintosh|Mac OS X/,"Mac"],[/Linux/,"Linux"]].find(([n])=>n.test(a))?.[1];return t?`${i} on ${t}`:i}const N={rejected:"This code is invalid, expired, or already used. Create a new one from OpenTig.",unavailable:"OpenTig could not complete pairing. Check the server and try again."};function O(){const[a,i]=o.useState(()=>y(window.location,window.history)),[t,n]=o.useState(()=>k(window.navigator.userAgent)),[c,m]=o.useState("idle"),[u,h]=o.useState("checking"),[p,f]=o.useState(0);o.useEffect(()=>{const r=new AbortController;let s=!0;const d=window.setTimeout(()=>r.abort(),1e4);return v(r.signal).then(l=>{s&&(l==="authenticated"&&window.location.replace("/"),h(l))}).finally(()=>window.clearTimeout(d)),()=>{s=!1,r.abort(),window.clearTimeout(d)}},[p]);const x=async r=>{r.preventDefault();const s=t.trim(),d=a.trim();if(!s||!d||s.length>64)return;m("pairing");const l=await j(d,s);l==="paired"?window.location.replace("/"):m(l)};return u!=="unpaired"?e.jsx("main",{className:"access-page pairing-page flex min-h-dvh items-center justify-center bg-background px-4 py-6 text-foreground",children:e.jsxs("section",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"text-lg font-semibold",children:u==="unavailable"?"Could not check this browser":"Checking this browser…"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",role:"status",children:u==="unavailable"?"Could not verify your saved session. Check your connection and try again.":"Checking your saved session before asking you to pair again."}),u==="unavailable"&&e.jsx(g,{className:"mt-5",onClick:()=>{h("checking"),f(r=>r+1)},children:"Try again"})]})}):e.jsx("main",{className:"access-page pairing-page flex min-h-dvh items-center justify-center bg-background px-4 py-6 text-foreground",children:e.jsxs("section",{className:"w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-sm",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Pair this browser"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Enter the one-use code shown by the ",b," desktop app or generated with the command below on the server. It expires after five minutes."]}),e.jsx(w,{}),e.jsxs("form",{className:"mt-5 grid gap-4",onSubmit:r=>{x(r)},children:[e.jsxs("label",{className:"grid gap-1.5 text-sm",htmlFor:"pairing-code",children:[e.jsx("span",{className:"font-medium",children:"Pairing code"}),e.jsx("input",{id:"pairing-code",className:"h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 font-mono text-base outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",value:a,onChange:r=>i(r.target.value),autoComplete:"off",spellCheck:!1,required:!0})]}),e.jsxs("label",{className:"grid gap-1.5 text-sm",htmlFor:"device-name",children:[e.jsx("span",{className:"font-medium",children:"Device name"}),e.jsx("input",{id:"device-name",className:"h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 text-base outline-none focus:border-ring focus:ring-2 focus:ring-ring/20",value:t,onChange:r=>n(r.target.value),maxLength:64,autoComplete:"off",required:!0})]}),e.jsx(g,{type:"submit",disabled:c==="pairing"||!a.trim()||!t.trim(),children:c==="pairing"?"Pairing…":"Pair browser"})]}),(c==="rejected"||c==="unavailable")&&e.jsx("p",{className:"mt-4 text-sm text-destructive",role:"alert",children:N[c]}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"The code is removed from the address bar immediately and is never stored by the browser."}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"This browser remembers its access and renews it automatically while you use OpenTig. Pair again after 30 days without renewal, clearing cookies, or revoking access."})]})})}export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as k,j as g}from"./react-rd22PHbN.js";import{t as w,a6 as E,n as Y,a7 as j,a8 as O,B as Z,d as M,E as ee,A as ne,a3 as te,_ as ie,a4 as R,a5 as oe,P as re,a as se,V as T,O as U,r as $}from"./PierreWorkerPool-DH2jp9oe.js";import{F as le}from"./File-DTtWrbYf.js";import{D as V,b as P,f as ce}from"./platform-Bqt97_Jr.js";import{a as de,g as J,b as Q,F as ae,p as b,c as ue,s as fe,r as he,D as pe}from"./DiffWorkspace-Ca2ZUlVn.js";import{a as H}from"./EditContext-CvJWfVl1.js";import{B as D}from"./index-CQcx9aRt.js";import"./one-light-CoLDteqg.js";import"./index-BgLrS_2D.js";import"./index-CtEztN1P.js";import"./App-9EfSdZB8.js";import"./tanstack-CtfgE41X.js";import"./base-ui-DT3JsyND.js";var _=class extends de{pendingConflictActions=[];pendingMarkerRows=[];injectedRows=new Map;options;constructor(e={theme:V},n,t){super(void 0,n,t),this.options=e}setConflictState(e,n,t){this.pendingConflictActions=e,this.pendingMarkerRows=n,this.syncInjectedRows(e,n,t)}syncInjectedRows(e,n,t){this.injectedRows.clear();for(const i of e){const r=i!=null?J(i,t):void 0;if(i==null||r==null)continue;const o={type:"actions",hunkIndex:r.hunkIndex,lineIndex:r.lineIndex,conflictIndex:i.conflictIndex};this.addInjectedRow(o)}for(const i of n)this.addInjectedRow(i)}addInjectedRow(e){const n=`${e.hunkIndex}:${e.lineIndex}`,t=this.injectedRows.get(n);t==null?this.injectedRows.set(n,[e]):t.push(e)}renderDiff(e,n=P){return e!=null&&this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.renderDiff(e,n)}async asyncRender(e,n=P){return this.syncInjectedRows(this.pendingConflictActions,this.pendingMarkerRows,e),super.asyncRender(e,n)}createPreElement(e,n){return super.createPreElement(e,n,{"data-has-merge-conflict":""})}getUnifiedLineDecoration({type:e,lineType:n}){const t=e==="change"?n==="change-deletion"?"current":"incoming":void 0;return{gutterLineType:e==="change"?"context":n,gutterProperties:B(t),contentProperties:W(e,t)}}getSplitLineDecoration({side:e,type:n}){const t=n==="change"?e==="deletions"?"current":"incoming":void 0;return{gutterLineType:n==="change"?"context":n,gutterProperties:B(t),contentProperties:W(n,t)}}getUnifiedInjectedRowsForLine=e=>{const n=this.injectedRows.get(`${e.hunkIndex}:${e.lineIndex}`);if(n==null||n.length===0)return;const{mergeConflictActionsType:t}=this.getOptionsWithDefaults(),i=[],r=[];for(const o of n){if(o.type==="actions"){i.push({content:Ce({row:o,includeDefaultActions:t==="default",includeSlot:!0}),gutter:G("action")});continue}(o.type==="marker-end"?r:i).push({content:me(o),gutter:G("marker",o.type)})}return{before:i.length>0?i:void 0,after:r.length>0?r:void 0}};getOptionsWithDefaults(){const e=super.getOptionsWithDefaults();return e.diffStyle="unified",e.lineDiffType="none",e.mergeConflictActionsType=this.options.mergeConflictActionsType??"default",e}};function B(e){return e!=null?{"data-merge-conflict":e}:void 0}function W(e,n){if(n!=null){if(e==="change")return n==="current"||n==="incoming"?{"data-line-type":"context","data-merge-conflict":n}:void 0;if(n==="marker-start"||n==="marker-base"||n==="marker-separator"||n==="marker-end")return{"data-merge-conflict":n}}}function G(e,n){const t=Y(void 0,"annotation",1);return t.properties["data-gutter-buffer"]=e==="action"?"merge-conflict-action":`merge-conflict-${n??"marker"}`,t}function Ce({row:e,includeDefaultActions:n,includeSlot:t}){const i=n?xe(e.conflictIndex):[];return i.push(w({tagName:"slot",properties:{name:Q({hunkIndex:e.hunkIndex,lineIndex:e.lineIndex,conflictIndex:e.conflictIndex}),"data-merge-conflict-action-slot":""}})),w({tagName:"div",properties:{"data-merge-conflict-actions":""},children:[w({tagName:"div",properties:{"data-merge-conflict-actions-content":""},children:i})]})}function me(e){return w({tagName:"div",properties:{"data-merge-conflict":e.type,"data-merge-conflict-marker-row":""},children:[E(e.lineText.replace(/(?:\r\n|\n|\r)$/,""))]})}function xe(e){return[y({resolution:"current",label:"Accept current change",conflictIndex:e}),K(),y({resolution:"incoming",label:"Accept incoming change",conflictIndex:e}),K(),y({resolution:"both",label:"Accept both",conflictIndex:e})]}function y({resolution:e,label:n,conflictIndex:t}){return w({tagName:"button",properties:{type:"button","data-merge-conflict-action":e,"data-merge-conflict-conflict-index":`${t}`},children:[E(n)]})}function K(){return w({tagName:"span",properties:{"data-merge-conflict-action-separator":""},children:[E("|")]})}function ge(e,n){return e.hunkIndex===n.hunkIndex&&e.startContentIndex===n.startContentIndex&&e.endContentIndex===n.endContentIndex&&e.currentContentIndex===n.currentContentIndex&&e.baseContentIndex===n.baseContentIndex&&e.incomingContentIndex===n.incomingContentIndex&&e.endMarkerContentIndex===n.endMarkerContentIndex&&e.conflictIndex===n.conflictIndex&&Le(e.conflict,n.conflict)}function Le(e,n){return e.conflictIndex===n.conflictIndex&&e.startLineIndex===n.startLineIndex&&e.startLineNumber===n.startLineNumber&&e.separatorLineIndex===n.separatorLineIndex&&e.separatorLineNumber===n.separatorLineNumber&&e.endLineIndex===n.endLineIndex&&e.endLineNumber===n.endLineNumber&&e.baseMarkerLineIndex===n.baseMarkerLineIndex&&e.baseMarkerLineNumber===n.baseMarkerLineNumber}function Ie(e){const n=typeof e=="string"?e:e.type;return n==="accept"||n==="incoming"?"additions":n==="reject"||n==="current"?"deletions":"both"}function ve(e,n){const{resolution:t,hunkIndex:i,startContentIndex:r,endContentIndex:o,indexesToDelete:s=new Set}=n,l=e.hunks[i];if(l==null)throw console.error({diff:e,hunkIndex:i}),new Error(`resolveRegion: Invalid hunk index: ${i}`);if(r<0||o>=l.hunkContent.length||r>o)throw new Error(`resolveRegion: Invalid content range, ${r}, ${o}`);const{hunks:d,additionLines:a,deletionLines:f}=e,h={...e,hunks:[],deletionLines:[],additionLines:[],splitLineCount:0,unifiedLineCount:0,cacheKey:e.cacheKey!=null?`${e.cacheKey}:${t[0]}-${i}:${r}-${o}`:void 0},u={nextAdditionLineIndex:0,nextDeletionLineIndex:0,nextAdditionStart:1,nextDeletionStart:1,splitLineCount:0,unifiedLineCount:0},L=i===d.length-1&&o===l.hunkContent.length-1,A=!e.isPartial;for(const[p,x]of d.entries()){ke(e,h,u,j(x.deletionStart,x.deletionCount)-x.collapsedBefore,j(x.additionStart,x.additionCount)-x.collapsedBefore,x.collapsedBefore,A);const c={...x,hunkContent:[],additionStart:u.nextAdditionStart,deletionStart:u.nextDeletionStart,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex,additionCount:0,deletionCount:0,deletionLines:0,additionLines:0,splitLineStart:u.splitLineCount,unifiedLineStart:u.unifiedLineCount,splitLineCount:0,unifiedLineCount:0};for(const[m,C]of x.hunkContent.entries())if(p!==i||m<r||m>o){z(C,h,f,a);const v={...C,additionLineIndex:u.nextAdditionLineIndex,deletionLineIndex:u.nextDeletionLineIndex};c.hunkContent.push(v),S(v,u,c)}else if(s.has(m))c.hunkContent.push({type:"context",lines:0,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex});else if(C.type==="context"){z(C,h,f,a);const v={...C,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}else{Ae(t,C,h,f,a);const v={type:"context",lines:t==="deletions"?C.deletions:t==="additions"?C.additions:C.deletions+C.additions,deletionLineIndex:u.nextDeletionLineIndex,additionLineIndex:u.nextAdditionLineIndex};c.hunkContent.push(v),S(v,u,c)}if(p===i&&L){const m=t==="deletions"?x.noEOFCRDeletions:x.noEOFCRAdditions;c.noEOFCRAdditions=m,c.noEOFCRDeletions=m}c.additionCount===0&&(c.additionStart--,e.isPartial||c.additionLineIndex--),c.deletionCount===0&&(c.deletionStart--,e.isPartial||c.deletionLineIndex--),h.hunks.push(c)}const I=d.at(-1);if(I!=null&&!e.isPartial){const p=O(I.deletionStart,I.deletionCount),x=O(I.additionStart,I.additionCount),c=Math.min(f.length-p,a.length-x);X(h,f,a,p,x,c),u.splitLineCount+=c,u.unifiedLineCount+=c}return h.splitLineCount=u.splitLineCount,h.unifiedLineCount=u.unifiedLineCount,h}function X(e,n,t,i,r,o){for(let s=0;s<o;s++){const l=n[i+s],d=t[r+s];if(l==null||d==null)throw new Error("pushCollapsedContextLines: missing collapsed context line");e.deletionLines.push(l),e.additionLines.push(d)}}function ke(e,n,t,i,r,o,s){o<=0||(s&&(X(n,e.deletionLines,e.additionLines,i,r,o),t.nextAdditionLineIndex+=o,t.nextDeletionLineIndex+=o),t.nextAdditionStart+=o,t.nextDeletionStart+=o,t.splitLineCount+=o,t.unifiedLineCount+=o)}function z(e,n,t,i){if(e.type==="context")for(let r=0;r<e.lines;r++){const o=i[e.additionLineIndex+r];if(o==null)throw console.error({additionLines:i,content:e,i:r}),new Error("pushContentLinesToDiff: Context line does not exist");n.deletionLines.push(o),n.additionLines.push(o)}else{const r=Math.max(e.deletions,e.additions);for(let o=0;o<r;o++){if(o<e.deletions){const s=t[e.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:t,content:e,i:o}),new Error("pushContentLinesToDiff: Deletion line does not exist");n.deletionLines.push(s)}if(o<e.additions){const s=i[e.additionLineIndex+o];if(s==null)throw console.error({additionLines:i,content:e,i:o}),new Error("pushContentLinesToDiff: Addition line does not exist");n.additionLines.push(s)}}}}function Ae(e,n,t,i,r){if(e==="deletions"||e==="both")for(let o=0;o<n.deletions;o++){const s=i[n.deletionLineIndex+o];if(s==null)throw console.error({deletionLines:i,content:n,i:o}),new Error("pushResolveLinesToDiff: Deletion line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}if(e==="additions"||e==="both")for(let o=0;o<n.additions;o++){const s=r[n.additionLineIndex+o];if(s==null)throw console.error({additionLines:r,content:n,i:o}),new Error("pushResolveLinesToDiff: Addition line does not exist");t.deletionLines.push(s),t.additionLines.push(s)}}function S(e,n,t){e.type==="context"?(n.nextAdditionLineIndex+=e.lines,n.nextDeletionLineIndex+=e.lines,n.nextAdditionStart+=e.lines,n.nextDeletionStart+=e.lines,n.splitLineCount+=e.lines,n.unifiedLineCount+=e.lines,t.additionCount+=e.lines,t.deletionCount+=e.lines,t.splitLineCount+=e.lines,t.unifiedLineCount+=e.lines):(n.nextAdditionLineIndex+=e.additions,n.nextDeletionLineIndex+=e.deletions,n.nextAdditionStart+=e.additions,n.nextDeletionStart+=e.deletions,n.splitLineCount+=Math.max(e.deletions,e.additions),n.unifiedLineCount+=e.deletions+e.additions,t.deletionCount+=e.deletions,t.deletionLines+=e.deletions,t.additionCount+=e.additions,t.additionLines+=e.additions,t.splitLineCount+=Math.max(e.deletions,e.additions),t.unifiedLineCount+=e.deletions+e.additions)}function we(e,n,t){return ve(e,{resolution:Ie(t),hunkIndex:n.hunkIndex,startContentIndex:n.startContentIndex,endContentIndex:n.endContentIndex,indexesToDelete:Re(n)})}function Re(e){const n=new Set;return e.baseContentIndex!=null&&n.add(e.baseContentIndex),e.endMarkerContentIndex!==e.endContentIndex&&n.add(e.endMarkerContentIndex),n}let De=-1;var Me=class extends ae{options;__id=`unresolved-file:${++De}`;type="unresolved-file";computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0};conflictActions=[];markerRows=[];conflictActionCache=new Map;constructor(n={theme:V},t,i=!1){super(void 0,t,i),this.options=n,this.setOptions(n)}setOptions(n){if(n!=null){if(n.onMergeConflictAction!=null&&n.onMergeConflictResolve!=null)throw new Error("UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.");this.options=n,this.hunksRenderer.setOptions(this.getHunksRendererOptions(n)),this.syncInteractionOptions()}}syncInteractionOptions(){this.interactionManager.setOptions(Z(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex,this.handleMergeConflictActionClick))}createHunksRenderer(n){return new _(this.getHunksRendererOptions(n),this.handleHighlightRender,this.workerManager)}getHunksRendererOptions(n){return Te(n,this.options)}applyPreNodeAttributes(n,t){super.applyPreNodeAttributes(n,t,{"data-has-merge-conflict":""})}cleanUp(){this.emitPostRender(!0),this.clearMergeConflictActionCache(),this.computedCache={file:void 0,fileDiff:void 0,actions:void 0,markerRows:void 0},this.conflictActions=[],super.cleanUp()}getOrComputeDiff({file:n,fileDiff:t,actions:i,markerRows:r}){const{maxContextLines:o,onMergeConflictAction:s}=this.options;e:if(s!=null){const l=t!=null;if(l!==(i!=null)||l!==(r!=null))throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");if(t!=null&&i!=null&&r!=null){this.computedCache={file:n??this.computedCache.file,fileDiff:t,actions:i,markerRows:r};break e}else if(n!=null||this.computedCache.file!=null){if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file)&&this.computedCache.fileDiff!=null&&this.computedCache.actions!=null)throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");if(n??=this.computedCache.file,n==null)throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");if(!M(n,this.computedCache.file)||this.computedCache.fileDiff==null||this.computedCache.actions==null){const d=b(n,o);this.computedCache={file:n,fileDiff:d.fileDiff,actions:d.actions,markerRows:d.markerRows}}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}else{t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}}else{if(t!=null||i!=null||r!=null)throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");if(n!=null&&this.computedCache.file!=null&&!M(n,this.computedCache.file))throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");if(this.computedCache.file??=n,this.computedCache.fileDiff==null&&this.computedCache.file!=null){const l=b(this.computedCache.file,o);this.computedCache.fileDiff=l.fileDiff,this.computedCache.actions=l.actions,this.computedCache.markerRows=l.markerRows}t=this.computedCache.fileDiff,i=this.computedCache.actions,r=this.computedCache.markerRows;break e}if(!(t==null||i==null||r==null))return{fileDiff:t,actions:i,markerRows:r}}hydrate(n){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,fileContainer:l,prerenderedHTML:d,preventEmit:a=!1}=n,f=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});f!=null&&(this.hydrateElements(l,d),this.setActiveMergeConflictState(f.actions,f.markerRows),je(this.pre,f.fileDiff,this.options.collapsed)||Oe(this.headerElement,f.fileDiff,this.options.disableFileHeader)?this.render({...n,preventEmit:!0}):(this.hydrationSetup({fileDiff:f.fileDiff,lineAnnotations:s}),this.pre!=null&&this.renderMergeConflictActionSlots()),a||this.emitPostRender())}rerender(){!this.enabled||this.fileDiff==null||this.render({forceRender:!0,renderRange:this.renderRange})}render(n={}){const{file:t,fileDiff:i,actions:r,markerRows:o,lineAnnotations:s,preventEmit:l=!1,...d}=n,a=this.getOrComputeDiff({file:t,fileDiff:i,actions:r,markerRows:o});if(a==null)return!1;this.setActiveMergeConflictState(a.actions,a.markerRows);const f=super.render({...d,fileDiff:a.fileDiff,lineAnnotations:s,preventEmit:!0});return f&&(this.renderMergeConflictActionSlots(),l||this.emitPostRender()),f}resolveConflict(n,t,i=this.computedCache.fileDiff){const r=this.conflictActions[n];if(i==null||r==null)return;if(r.conflictIndex!==n)throw console.error({conflictIndex:n,action:r}),new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");const o=we(i,r,t),s=this.computedCache.file,{file:l,actions:d,markerRows:a}=ye({fileDiff:o,previousActions:this.conflictActions,resolvedConflictIndex:n,previousFile:s,resolution:t});return{file:l,fileDiff:o,actions:d,markerRows:a}}resolveConflictAndRender(n,t){const i=this.conflictActions[n];if(i==null)return;if(i.conflictIndex!==n)throw console.error({conflictIndex:n,action:i}),new Error("UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match");const r={resolution:t,conflict:i.conflict},{file:o,fileDiff:s,actions:l,markerRows:d}=this.resolveConflict(n,t)??{};o==null||s==null||l==null||d==null||(this.computedCache={file:o,fileDiff:s,actions:l,markerRows:d},this.setActiveMergeConflictState(l,d),this.workerManager!=null?this.hunksRenderer.renderDiff(s):this.render({forceRender:!0}),this.options.onMergeConflictResolve?.(o,r))}setActiveMergeConflictState(n=this.conflictActions,t=this.markerRows){this.conflictActions=n,this.markerRows=t,this.computedCache.fileDiff!=null&&this.hunksRenderer instanceof _&&this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType==="none"?[]:n,t,this.computedCache.fileDiff)}handleMergeConflictActionClick=n=>{const t=this.conflictActions[n.conflictIndex];if(t==null)return;if(t.conflictIndex!==n.conflictIndex)throw console.error({conflictIndex:n.conflictIndex,action:t}),new Error("UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match");const i={resolution:n.resolution,conflict:t.conflict};if(this.options.onMergeConflictAction!=null){this.options.onMergeConflictAction(i,this);return}this.resolveConflictAndRender(n.conflictIndex,n.resolution)};renderMergeConflictActionSlots(){const{fileDiff:n}=this.computedCache;if(this.isContainerManaged||this.fileContainer==null||typeof this.options.mergeConflictActionsType!="function"||this.conflictActions.length===0||n==null){this.clearMergeConflictActionCache();return}const t=new Map(this.conflictActionCache);for(let i=0;i<this.conflictActions.length;i++){const r=this.conflictActions[i];if(r==null)continue;if(r.conflictIndex!==i)throw console.error({conflictIndex:i,action:r}),new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");const o=J(r,n);if(o==null)continue;const s=r.conflictIndex,l=Q({hunkIndex:o.hunkIndex,lineIndex:o.lineIndex,conflictIndex:s}),d=`${i}-${l}`;let a=this.conflictActionCache.get(d);if(a==null||!ge(a.action,r)){a?.element.remove();const f=this.renderMergeConflictAction(r);if(f==null)continue;const h=ee(l);h.appendChild(f),this.fileContainer.appendChild(h),a={element:h,action:r},this.conflictActionCache.set(d,a)}t.delete(d)}for(const[i,{element:r}]of t.entries())this.conflictActionCache.delete(i),r.remove()}renderMergeConflictAction(n){if(typeof this.options.mergeConflictActionsType!="function")return;const t=this.options.mergeConflictActionsType(n,this);if(t!=null){if(t instanceof HTMLElement)return t;if(typeof DocumentFragment<"u"&&t instanceof DocumentFragment){const i=document.createElement("div");return i.style.display="contents",i.appendChild(t),i}}}clearMergeConflictActionCache(){for(const{element:n}of this.conflictActionCache.values())n.remove();this.conflictActionCache.clear()}};function ye({fileDiff:e,previousActions:n,resolvedConflictIndex:t,previousFile:i,resolution:r}){const o=n[t];if(o==null)throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");const s=Ee(n,t,o,r),l=ue(e,s);return{file:Se({fileDiff:e,resolvedAction:o,resolvedConflictIndex:t,previousFile:i,resolution:r}),actions:s,markerRows:l}}function Se({resolvedAction:e,resolvedConflictIndex:n,previousFile:t,fileDiff:i,resolution:r}){const o=fe(t?.contents??""),{conflict:s}=e,l=be(o,s,r),d=[...o.slice(0,s.startLineIndex),...l,...o.slice(s.endLineIndex+1)].join("");return{name:t?.name??i.name,contents:d,cacheKey:t?.cacheKey!=null?`${t.cacheKey}:mc-${n}-${r}`:void 0}}function be(e,n,t){const i=e.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),r=e.slice(n.separatorLineIndex+1,n.endLineIndex);return t==="current"?i:t==="incoming"?r:[...i,...r]}function Ee(e,n,t,i){const r=Fe(t.conflict,i);return e.map((o,s)=>{if(s!==n&&o!=null)return o.conflict.startLineIndex>t.conflict.endLineIndex?{...o,conflict:Ne(o.conflict,r)}:o})}function Fe(e,n){const t=(e.baseMarkerLineIndex??e.separatorLineIndex)-e.startLineIndex-1,i=e.endLineIndex-e.separatorLineIndex-1;return(n==="current"?t:n==="incoming"?i:t+i)-(e.endLineIndex-e.startLineIndex+1)}function Ne(e,n){return{...e,startLineIndex:e.startLineIndex+n,startLineNumber:e.startLineNumber+n,separatorLineIndex:e.separatorLineIndex+n,separatorLineNumber:e.separatorLineNumber+n,endLineIndex:e.endLineIndex+n,endLineNumber:e.endLineNumber+n,baseMarkerLineIndex:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+n:void 0,baseMarkerLineNumber:e.baseMarkerLineNumber!=null?e.baseMarkerLineNumber+n:void 0}}function je(e,n,t=!1){return!t&&e==null&&n!=null}function Oe(e,n,t=!1){return e==null&&n!=null&&!t}function Te(e,n){const t={...n,...e};return{...t,useTokenTransformer:ne(t),hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,mergeConflictActionsType:typeof e?.mergeConflictActionsType=="function"?"custom":e?.mergeConflictActionsType}}const Ue=typeof window>"u"?k.useEffect:k.useLayoutEffect;function $e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:r,hasConflictUtility:o,hasGutterRenderUtility:s,hasCustomHeader:l,disableWorkerPool:d}){const[{fileDiff:a,actions:f,markerRows:h},u]=k.useState(()=>{const{fileDiff:c,actions:m,markerRows:C}=b(e,n?.maxContextLines);return{fileDiff:c,actions:m,markerRows:C}}),L=H((c,m)=>{u(C=>{const{fileDiff:v,actions:F,markerRows:N}=m.resolveConflict(c.conflict.conflictIndex,c.resolution,C.fileDiff)??{};return v==null||F==null||N==null?C:{fileDiff:v,actions:F,markerRows:N}})}),A=i!==void 0,I=k.useContext(te),p=k.useRef(null),x=H(c=>{if(c!=null){if(p.current!=null)throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");p.current=new Me(q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),d?void 0:I,!0),p.current.hydrate({fileDiff:a,actions:f,markerRows:h,fileContainer:c,lineAnnotations:t,prerenderedHTML:r})}else{if(p.current==null)throw new Error("useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting");p.current.cleanUp(),p.current=null}});return Ue(()=>{if(p.current==null)return;const c=p.current,m=q({controlledSelection:A,hasConflictUtility:o,hasCustomHeader:l,hasGutterRenderUtility:s,onMergeConflictAction:L,options:n}),C=m!==void 0&&!ie(c.options,m);c.setOptions(m),c.render({fileDiff:a,actions:f,markerRows:h,lineAnnotations:t,forceRender:C}),i!==void 0&&c.setSelectedLines(i)}),{ref:x,getHoveredLine:k.useCallback(()=>p.current?.getHoveredLine(),[]),fileDiff:a,actions:f,markerRows:h,getInstance:k.useCallback(()=>p.current??void 0,[])}}function q({options:e,controlledSelection:n,onMergeConflictAction:t,hasConflictUtility:i,hasCustomHeader:r,hasGutterRenderUtility:o}){return{...e,controlledSelection:n,onMergeConflictAction:t,hunkSeparators:e?.hunkSeparators==="custom"?R:e?.hunkSeparators,mergeConflictActionsType:i||e?.mergeConflictActionsType==="custom"?R:e?.mergeConflictActionsType,renderCustomHeader:r?R:void 0,renderGutterUtility:o?R:void 0}}function Pe({file:e,options:n,lineAnnotations:t,selectedLines:i,className:r,style:o,prerenderedHTML:s,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderGutterUtility:u,renderMergeConflictUtility:L,disableWorkerPool:A=!1}){const{ref:I,getHoveredLine:p,fileDiff:x,actions:c,getInstance:m}=$e({file:e,options:n,lineAnnotations:t,selectedLines:i,prerenderedHTML:s,hasConflictUtility:L!=null,hasGutterRenderUtility:u!=null,hasCustomHeader:d!=null,disableWorkerPool:A});return g.jsx(ce,{ref:I,className:r,style:o,children:oe(he({fileDiff:x,renderCustomHeader:d,renderHeaderPrefix:a,renderHeaderFilenameSuffix:f,renderHeaderMetadata:h,renderAnnotation:l,renderGutterUtility:u,lineAnnotations:t,getHoveredLine:p,actions:c,renderMergeConflictUtility:L,getInstance:m}),s)})}function He(e){return{draft:e,persistedContent:e,revision:0}}function _e(e,n){return n===e.draft?e:{...e,draft:n,revision:e.revision+1}}function Be(e,n){return e.persistedContent===n?e:{...e,persistedContent:n}}function We(e,n){return n===e.persistedContent?e:{draft:n,persistedContent:n,revision:e.revision+1}}function dn(e){return g.jsx(re,{children:g.jsx("div",{className:"viewer-transition",children:e.kind==="diff"?g.jsx(Ge,{...e}):g.jsx(Ke,{file:e.file,themeType:e.themeType,overflow:e.overflow,onUpdate:e.onUpdate,onResolve:e.onResolve},e.file.path)},e.contentKey)})}function Ge({contentKey:e,value:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f}){return g.jsx(pe,{contentKey:e,diff:n,diffView:t,themeType:i,wrapLines:r,initiallyCollapsed:o,compact:s,scopeControl:l,onDiffViewChange:d,onWrapLinesChange:a,onClose:f},e)}function Ke({file:e,themeType:n,overflow:t,onUpdate:i,onResolve:r}){const[o,s]=k.useState(()=>He(e.content)),[l,d]=k.useState(!1),[a,f]=k.useState(!1),h=o.draft,u=o.revision,L=ze(h);k.useEffect(()=>{s(p=>We(p,e.content))},[e.content]);const A=async(p,x)=>{if(l)return;d(!0);const c=o,m=qe(h,p,x);s(C=>_e(C,m));try{await i(e.path,m)?s(C=>Be(C,m)):s(C=>C.draft===m?c:C)}finally{d(!1)}},I=async()=>{if(!(L>0||a)){f(!0);try{await r(e.path,h)}finally{f(!1)}}};return g.jsxs("div",{className:"conflict-viewer",children:[g.jsxs("div",{className:"conflict-viewer-toolbar",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Conflict resolution"}),g.jsx("span",{children:L>0?`${L} ${L===1?"pending block":"pending blocks"}`:"All blocks are resolved"})]}),g.jsx(D,{size:"sm",disabled:L>0||a,onClick:()=>{I()},children:a?"Saving…":"Mark as resolved"})]}),g.jsx(se,{className:"viewer-scroll",contentClassName:"viewer-content",children:L>0?g.jsx(Pe,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:conflict:${u}`},disableWorkerPool:h.length>5e5,options:{themeType:n,theme:U,diffIndicators:"classic",overflow:t,mergeConflictActionsType:"none",unsafeCSS:T},renderMergeConflictUtility:p=>g.jsxs("div",{className:"conflict-actions",children:[g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"current")},children:"Accept current"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"incoming")},children:"Accept incoming"}),g.jsx(D,{size:"xs",variant:"outline",disabled:l,onClick:()=>{A(p.conflict,"both")},children:"Accept both"})]})},`${e.path}:${u}`):g.jsx(le,{file:{name:e.path,lang:$(e.path),contents:h,cacheKey:`${e.path}:resolved:${u}`},options:{themeType:n,theme:U,overflow:t,unsafeCSS:T}})})]})}function ze(e){return e.split(/\r?\n/).filter(n=>/^<{7}(?: |$)/.test(n)).length}function qe(e,n,t){const i=e.match(/[^\n]*\n|[^\n]+$/g)??[],r=i.slice(n.startLineIndex+1,n.baseMarkerLineIndex??n.separatorLineIndex),o=i.slice(n.separatorLineIndex+1,n.endLineIndex),s=t==="current"?r:t==="incoming"?o:[...r,...o];return[...i.slice(0,n.startLineIndex),...s,...i.slice(n.endLineIndex+1)].join("")}export{dn as default};
|
|
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};
|
package/dist/client/assets/{PierreEditBoundary-KzU3HDc2.js → PierreEditBoundary-DlGd1pqO.js}
RENAMED
|
@@ -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-
|
|
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};
|