@opentig/cli 0.2.1 → 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.
- package/dist/bin.mjs +2 -1
- package/dist/chunks/{cli-B6JTojx_.mjs → cli-DNzGBqmL.mjs} +1 -1
- package/dist/client/assets/App-BbT5H97Z.js +138 -0
- package/dist/client/assets/{CreatePullRequestDialog-CAeykZ72.js → CreatePullRequestDialog-DRLeMY4e.js} +2 -2
- package/dist/client/assets/{DiffWorkspace-BRicWHvw.js → DiffWorkspace-DJX00otP.js} +1 -1
- package/dist/client/assets/{EditableFileViewer-DWeSDnZn.js → EditableFileViewer-Cmbomx5y.js} +1 -1
- package/dist/client/assets/{File-D65shwRR.js → File-4o4egqlz.js} +1 -1
- package/dist/client/assets/FilesView-TmUF-VLr.js +1 -0
- package/dist/client/assets/{GitHubAvatar-C8R3iNoM.js → GitHubAvatar-azKPrTMv.js} +1 -1
- package/dist/client/assets/HistoryView-Go6rXO0P.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-JXLHTNPm.js → HtmlFileViewer-WpYnLdMW.js} +1 -1
- package/dist/client/assets/{IconEdit-3fgBTCQ4.js → IconEdit-B8LZHB8l.js} +1 -1
- package/dist/client/assets/{IconFolderSymlink-C4ydD1eS.js → IconFolderSymlink-D29EhQPC.js} +1 -1
- package/dist/client/assets/{ImageFileViewer-YH2xhkkk.js → ImageFileViewer-1ObUacJu.js} +1 -1
- package/dist/client/assets/LocalRefsDialog-VcrlFgxR.js +1 -0
- package/dist/client/assets/{MarkdownFileViewer-BsB8WkIH.js → MarkdownFileViewer-CvsKPnvF.js} +2 -2
- package/dist/client/assets/{PairingPage-DXRyAYHn.js → PairingPage-cSoKZi8t.js} +1 -1
- package/dist/client/assets/{PierreDiffViewer-DoV3V0IW.js → PierreDiffViewer-DVTrOwX4.js} +1 -1
- package/dist/client/assets/{PierreEditBoundary-BnYZbHfi.js → PierreEditBoundary-DPtaTiUB.js} +1 -1
- package/dist/client/assets/{PierreWorkerPool-Cg9zdxiI.js → PierreWorkerPool-BxP-s6jD.js} +1 -1
- package/dist/client/assets/PullRequestDiff-DeQznd9n.js +1 -0
- package/dist/client/assets/PullRequestViewer-IhGZZs_A.js +2 -0
- package/dist/client/assets/{PullRequestsView-GStKxG7k.js → PullRequestsView-BG0xrok4.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-DpmcAzTx.js +1 -0
- package/dist/client/assets/RepositoryProjectsDialog-DAzbUB3X.js +1 -0
- package/dist/client/assets/{SearchView-D5XB6wdu.js → SearchView-HoiWKG8z.js} +1 -1
- package/dist/client/assets/SettingsDialog-pmJKOaiK.js +9 -0
- package/dist/client/assets/{Viewer-Gfy3Ejyo.js → Viewer-BCk8FHrc.js} +3 -3
- package/dist/client/assets/{abnfDiagram-N423BO3Z-DdAfHevw.js → abnfDiagram-N423BO3Z-BvfKOanh.js} +1 -1
- package/dist/client/assets/{arc-C43uoeEi.js → arc-DB2nIH2Y.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-C7q0hhRO.js → architectureDiagram-T3A2C74G-Bqh4uY3R.js} +1 -1
- package/dist/client/assets/base-ui-DIP2rZxz.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-C1x9Iap4.js → blockDiagram-VBNYF7ZC-DMW415Ms.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-BmKaVW6q.js → c4Diagram-5PPSVZJV-BSNPes7l.js} +1 -1
- package/dist/client/assets/channel-VcDernYy.js +1 -0
- package/dist/client/assets/{checkbox-XfIUFPxh.js → checkbox-Dta4gqy2.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-kzy_H3BQ.js → chunk-2GRJ4B5K-D-86JbWu.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-BMj-FT4X.js → chunk-2Q5K7J3B-BNI-SD-k.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-DmPGiCCb.js → chunk-5RXB4S5H-OFFYyML8.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DYFL8__L.js → chunk-5VM5RSS4-DpE1dtnL.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-CI98oVdT.js → chunk-6Q2QTUOP-DxAnzBXJ.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-D9JiiMlX.js → chunk-GF5L2VYU-DNrTNRgr.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-D0THYpZl.js → chunk-JWPE2WC7-D-jfKyIh.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-Z1tJfyAr.js → chunk-KBJHAD2P-CIyQl_ts.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-31aS4cD3.js → chunk-RYQCIY6F-CgCYQccM.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-ClWDHmEp.js → chunk-XXDRQBXY-B31oXtqU.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-CUuEGRCt.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-CUuEGRCt.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-Btg2MYLh.js → cose-bilkent-JH36ORCC-CrX-LDNw.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-Cbh4Pk6j.js → cynefin-VYW2F7L2-DnkWlsqW.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-BBqorl0u.js → cynefinDiagram-MW4NZA55-bUDQ9ElF.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-DugEItZ0.js → dagre-VZM6K2ZE-BW5Kni4n.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-Biu7dmH8.js → diagram-7IWD3JNH-1EXGwguC.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-UDm4DXFS.js → diagram-B4RE2ZJO-CzpH5ieN.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-Bcku4gb-.js → diagram-LBJQPF4R-BnKszJ_B.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-DFRjglV-.js → diagram-Q27KOJAE-DbQlD3OM.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-CgfMWtd0.js → diagram-UB23O5K3-BqZ-RSlm.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-CZzYOqs0.js → ebnfDiagram-BXEA7PRR-B2iPWDvr.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-Cdlbxgs6.js → erDiagram-JOGREHBK-aMqHrKCk.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-BgImDwpP.js → flowDiagram-UKHOOZJN-ivrTsn4D.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-SFhtiyL4.js → ganttDiagram-PKOTCBZU-IMfIqkXw.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-Bkm5ueys.js → gitGraphDiagram-DS77QQ5N-BNURRh2N.js} +1 -1
- package/dist/client/assets/{index-B5RC4THs.js → index-B3QJsvjR.js} +4 -4
- package/dist/client/assets/index-Cx9LaJW8.css +1 -0
- package/dist/client/assets/{infoDiagram-6WML65LV-pCYc-VX2.js → infoDiagram-6WML65LV-BKEENkUQ.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-BtNbG3Y6.js → ishikawaDiagram-WSZJBQD7-HrCSmiTr.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-CPW2qT3y.js → journeyDiagram-NVQOT4AX-CQIuWA6F.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-wD6JXQFs.js → kanban-definition-27J2QSJJ-h4fSAkel.js} +1 -1
- package/dist/client/assets/{linear-sj8MOkmS.js → linear-BAdz-uC9.js} +1 -1
- package/dist/client/assets/{mermaid.core-CGJtfmwb.js → mermaid.core-vLn7mMZB.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-BQwLHBVs.js → mindmap-definition-FAOFIHXS-DOrZl827.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-DtDsb-Z8.js → pegDiagram-VL7TDLO6-_Vs7p633.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-B3WhqNuS.js → pieDiagram-7S7Q4E2Y-7qbB_Z16.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-CPi38pp_.js → quadrantDiagram-CIZ2JOQS-DNH8SosA.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-Btac44Ux.js → railroadDiagram-AXF67PYL-Ctazrrpa.js} +1 -1
- package/dist/client/assets/{render-markdown-hAIWRfn0.js → render-markdown-dvHhHbC0.js} +1 -1
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-CHJgDNdg.js → requirementDiagram-LRYGKXZP-BAH8dYer.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-OYJHfmtd.js → sankeyDiagram-W5VNT64P-CuffrpdF.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-9ypa9W08.js → sequenceDiagram-SI44F4Z6-CaO4fJnS.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-5ZDUTERI.js → sizeCapture-X5ZJPWSS-B_LramBU.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-nGHE1hN7.js → stateDiagram-OKZ733FA-bc7zBYHn.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-C-UGmA2d.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-BZFv9Zp8.js → swimlanes-SLNWSIFB-DQzg1IPn.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DnopIiWa.js +8 -0
- package/dist/client/assets/{tanstack-CcfAJoQ7.js → tanstack-BysN2Oew.js} +1 -1
- package/dist/client/assets/{timeline-definition-Z64GVDOM-pUIcaCIE.js → timeline-definition-Z64GVDOM-CtbuIB6K.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-D6dEIJmP.js → vennDiagram-T6HMQDX7-pYJ0ZfFS.js} +1 -1
- package/dist/client/assets/{viewer-tabs-BjG3oKQ9.js → viewer-tabs-Cnfyd6rg.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-DZ8ro_-y.js → wardleyDiagram-T6FBY63Y-DYl_Oi-Y.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-WJ2Zfmlk.js → xychartDiagram-ELKLHX3M-Cj5YUfP5.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +2 -1
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +779 -211
- package/dist/utility.mjs +1 -0
- package/package.json +1 -1
- package/dist/client/assets/App-Dfm5F199.js +0 -74
- package/dist/client/assets/FilesView-EfoU7sF-.js +0 -1
- package/dist/client/assets/HistoryView-C6T2dsBC.js +0 -1
- package/dist/client/assets/LocalRefsDialog--1NiYKYj.js +0 -1
- package/dist/client/assets/PullRequestDiff-D6QG5Anx.js +0 -1
- package/dist/client/assets/PullRequestViewer-jC3LVmiO.js +0 -2
- package/dist/client/assets/QuickOpenDialog-HvslpGQl.js +0 -1
- package/dist/client/assets/RepositoryProjectsDialog-Biqv5GO_.js +0 -1
- package/dist/client/assets/SettingsDialog-DWAunOQB.js +0 -72
- package/dist/client/assets/base-ui-CJ8ZIx3d.js +0 -1
- package/dist/client/assets/channel-Diwpee6E.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BDuo9kiS.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BDuo9kiS.js +0 -1
- package/dist/client/assets/index-Dc9xVluy.css +0 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-CkCpE1Yu.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-Dxlb7bju.js +0 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/render-markdown-
|
|
2
|
-
import{c as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/render-markdown-dvHhHbC0.js","assets/App-BbT5H97Z.js","assets/index-B3QJsvjR.js","assets/react-rd22PHbN.js","assets/tanstack-BysN2Oew.js","assets/base-ui-DIP2rZxz.js","assets/index-Cx9LaJW8.css","assets/one-light-CoLDteqg.js","assets/index-BgLrS_2D.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as Q,_ as J,o as C,B as b,s as x}from"./index-B3QJsvjR.js";import{r,j as t}from"./react-rd22PHbN.js";import{u as K,D as X,v as Y,w as Z,p as q,x as ee,f as I,y as te,z as ae,T as se,A as ne,B as ie,g as re,s as ce,C as le,E as oe}from"./App-BbT5H97Z.js";import{C as de}from"./checkbox-Dta4gqy2.js";import{V as ue,a as he,b as A}from"./viewer-tabs-Cnfyd6rg.js";/* empty css */import"./tanstack-BysN2Oew.js";import"./base-ui-DIP2rZxz.js";const me=[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]],L=Q("outline","upload","Upload",me);function ke(e){const n=K(e.open?e.repositoryId:null),i=n.data,[o,y]=r.useState(""),[v,N]=r.useState(""),[d,S]=r.useState(""),[w,T]=r.useState(!1),[k,_]=r.useState("edit"),[V,E]=r.useState(""),[c,G]=r.useState(!1),[l,H]=r.useState(null),h=r.useRef(null),D=r.useRef(0),j=e.status?.branch??null,f=e.preferences.commitMessageHarness,O=e.preferences.commitMessageModels[f]??"default",U=fe(e.aiProviders,f,O),m=r.useMemo(()=>e.branches.filter(a=>a.remote&&!a.fullName.endsWith("/HEAD")&&a.name!==`origin/${j??""}`).map(a=>a.name),[j,e.branches]);r.useEffect(()=>{e.open&&S(a=>a&&m.includes(a)?a:be(m))},[m,e.open]),r.useEffect(()=>{if(!e.open||k!=="preview")return;const a=++D.current;J(async()=>{const{renderMarkdown:s}=await import("./render-markdown-dvHhHbC0.js").then(p=>p.a);return{renderMarkdown:s}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(({renderMarkdown:s})=>s(v||"_No description._")).then(s=>{a===D.current&&E(s)}).catch(()=>{a===D.current&&E("<p>Could not render the preview.</p>")})},[v,k,e.open]),r.useEffect(()=>{if(e.open)return;const a=h.current;a&&C.github.cancelDraft(a).catch(()=>{})},[e.open]);const P=e.status!==null&&!e.status.upstream,B=e.status!==null&&!!e.status.upstream&&e.status.ahead>0,g=e.status!==null&&(e.status.detached||e.status.unborn||!e.status.branch),u=e.status===null||P||B||g||m.length===0,z=async()=>{const a=h.current;a&&await C.github.cancelDraft(a).catch(()=>{})},W=async()=>{if(u||l||c||!d)return;const a=crypto.randomUUID();h.current=a,H(a);try{const s=await C.github.generateDraft({repositoryId:e.repositoryId,base:d,harness:f,model:O,requestId:a});if(h.current!==a)return;y(s.title),N(s.body),_("edit"),x.success({title:`Draft generated with ${M(s.harness)}`,description:s.contextWasTruncated?"A truncated version of the branch diff was used. Review before publishing.":"Review and edit before publishing."})}catch(s){const p=ge(s);p?.code==="AI_CANCELLED"?x.info({title:"Generation canceled"}):x.error({title:"Could not generate the draft",description:p?.message??F(s),duration:1e4})}finally{h.current===a&&(h.current=null),H(s=>s===a?null:s)}},$=async()=>{if(!(u||c||l||!o.trim()||!d||i?.state!=="ready"||!i.login)){G(!0);try{const a=await C.github.createPullRequest({repositoryId:e.repositoryId,title:o.trim(),body:v,base:d,draft:w,expectedAccount:{login:i.login,revision:i.revision}});y(""),N(""),T(!1),x.success({title:w?"Draft pull request created":"Pull request created",description:a.url,button:{title:"Open",onClick:()=>ce(a.url)}}),e.onCreated(a.number)}catch(a){const s=le(a);s?.code==="GH_ACCOUNT_UNRESOLVED"&&n.refetch(),x.error({title:oe(s),description:s?.message??F(a),duration:1e4})}finally{G(!1)}}};return t.jsx(X,{open:e.open,onOpenChange:a=>{c||e.onOpenChange(a)},children:t.jsxs(Y,{className:"create-pr-dialog",children:[t.jsxs("div",{className:"create-pr-content",children:[t.jsxs(Z,{children:[t.jsx(q,{"aria-hidden":"true"})," Create pull request"]}),t.jsx(ee,{children:j?t.jsxs(t.Fragment,{children:["From ",t.jsx("code",{children:j})," into the selected base branch on GitHub."]}):"Check out a branch to create a pull request."}),t.jsxs("div",{className:"github-operation-account",children:[t.jsxs("div",{children:[t.jsx("strong",{children:i?.state==="ready"?`Publish as @${i.login}`:n.isFetching?"Checking GitHub identity…":"GitHub account needs attention"}),t.jsxs("small",{children:[i?.message??(i?.source==="ssh"?"Automatic · identity verified through SSH":i?.source==="environment"?"Credentials from the backend environment":i?.source==="explicit"?"Chosen for this repository":"Active GitHub CLI credentials"),n.error?" · Could not check the account.":""]})]}),t.jsx(b,{variant:"ghost",size:"sm",onClick:e.onOpenGitHubSettings,disabled:c,children:"Change"})]}),P&&t.jsxs("div",{className:"create-pr-notice",children:[t.jsx("span",{children:g?"Check out a branch with at least one commit before publishing.":"Publish this branch before creating a pull request."}),t.jsxs(b,{variant:"outline",size:"xs",disabled:e.pushBusy||g||!!e.status?.readOnly,onClick:e.onPush,children:[e.pushBusy?t.jsx(I,{className:"animate-spin"}):t.jsx(L,{})," Publish branch"]})]}),B&&t.jsxs("div",{className:"create-pr-notice",children:[t.jsxs("span",{children:["The branch has ",e.status?.ahead," unpushed ",e.status?.ahead===1?"commit":"commits",". Push them so the pull request includes your work."]}),t.jsxs(b,{variant:"outline",size:"xs",disabled:e.pushBusy,onClick:e.onPush,children:[e.pushBusy?t.jsx(I,{className:"animate-spin"}):t.jsx(L,{})," Push"]})]}),!P&&!B&&g&&t.jsx("div",{className:"create-pr-notice",children:t.jsx("span",{children:"Pull requests need a checked-out branch with commits."})}),m.length===0&&!g&&t.jsx("div",{className:"create-pr-notice",children:t.jsx("span",{children:"No remote branches are available to use as a base. Fetch the remote first."})}),t.jsxs("div",{className:"create-pr-base-row",children:[t.jsxs("div",{className:"create-pr-field",children:[t.jsx("label",{htmlFor:"create-pr-base",children:"Base branch"}),t.jsx(te,{groups:[{id:"branches",label:"",items:m.map(a=>({value:a,label:R(a),search:a,icon:t.jsx(ae,{})}))}],value:d,onValueChange:S,label:"Base branch",triggerId:"create-pr-base",triggerLabel:d?R(d):"Select a base",triggerClassName:"create-pr-base",size:"default",align:"start",placeholder:"Search base branches…",disabled:u||c||!!l})]}),t.jsxs("label",{className:"create-pr-draft",children:[t.jsx(de,{checked:w,onCheckedChange:a=>T(a===!0),disabled:u||c||!!l}),t.jsx("span",{children:"Create as draft"})]})]}),t.jsxs("div",{className:"create-pr-field",children:[t.jsx("label",{htmlFor:"create-pr-title",children:"Title"}),t.jsx("input",{id:"create-pr-title",className:"create-pr-title",value:o,maxLength:300,placeholder:"Pull request title",disabled:u||c||!!l,onChange:a=>y(a.target.value)})]}),t.jsxs(ue,{value:k,onValueChange:a=>_(a),className:"create-pr-field create-pr-body-field",children:[t.jsxs("div",{className:"create-pr-body-header",children:[t.jsx("label",{htmlFor:"create-pr-body",children:"Description"}),t.jsx(he,{label:"Description view",className:"markdown-viewer-tabs",items:[{value:"edit",label:"Edit"},{value:"preview",label:"Preview"}]})]}),t.jsx(A,{value:"edit",className:"create-pr-body-panel",children:t.jsx(se,{id:"create-pr-body",value:v,rows:10,placeholder:"Describe the change (GitHub Markdown)",disabled:u||c||!!l,onChange:a=>N(a.target.value)})}),t.jsx(A,{value:"preview",className:"create-pr-preview markdown-prose",dangerouslySetInnerHTML:{__html:V}})]})]}),t.jsxs("div",{className:"create-pr-actions",children:[t.jsxs(b,{variant:"outline",className:"create-pr-generate commit-composer-generate",disabled:u||c,"aria-label":l?"Cancel generation":void 0,onClick:()=>l?void z():void W(),children:[l?t.jsx(ne,{className:"text-destructive"}):t.jsx(ie,{harness:f}),l?t.jsx(re,{text:"Generating draft…"}):t.jsxs("span",{className:"commit-composer-provider",children:["Generate with ",t.jsx("span",{className:"commit-composer-harness",children:M(f)}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{className:"commit-composer-model",children:U})]})]}),t.jsxs("div",{className:"create-pr-submit-actions",children:[t.jsx(b,{variant:"ghost",onClick:()=>e.onOpenChange(!1),disabled:c,children:"Cancel"}),t.jsxs(b,{onClick:()=>{$()},disabled:u||c||!!l||!o.trim()||!d||i?.state!=="ready"||n.isFetching,children:[c?t.jsx(I,{className:"animate-spin"}):t.jsx(q,{})," ",c?"Creating…":"Create pull request"]})]})]})]})})}function be(e){return e.find(n=>n==="origin/main")??e.find(n=>n==="origin/master")??e[0]??""}function R(e){return e.replace(/^origin\//,"")}function M(e){return e==="codex"?"Codex":e==="claude"?"Claude Code":"OpenCode"}function fe(e,n,i){return e?.find(o=>o.id===n)?.models.find(o=>o.id===i)?.label??(i==="default"?"Default (CLI)":i)}function ge(e){if(!(e instanceof Error)||!("detail"in e)||!e.detail||typeof e.detail!="object")return null;const n=e.detail;return typeof n.code=="string"&&n.code.startsWith("AI_")&&typeof n.message=="string"?n:null}function F(e){return e instanceof Error?e.message:"An unexpected error occurred."}export{ke as CreatePullRequestDialog};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as k,r as oe}from"./react-rd22PHbN.js";import{a8 as q,a7 as Le,a9 as cn,G as fn,aa as pn,ab as gn,ac as Ze,ad as mn,ae as ye,af as He,a0 as me,ag as ve,ah as ie,a1 as qt,t as N,a6 as Pe,ai as Cn,b as $e,g as Sn,aj as ze,ak as fe,e as xn,o as Ln,w as kn,x as vn,al as Ce,f as Xt,h as ut,y as yn,am as Hn,an as Se,ao as wn,n as j,v as En,s as Yt,m as ct,q as An,z as Re,p as Rn,A as bn,R as Tn,I as Mn,B as ft,C as Dn,D as In,ap as Zt,aq as Fn,ar as pt,E as Nn,F as Pn,S as gt,T as zn,H as Bn,J as On,K as mt,L as Un,M as Vn,Q as Ct,N as Ge,U as jn,W as $n,d as Qt,X as Gn,Y as We,Z as Wn,$ as _n,_ as Jt,a2 as Kn,u as qn,a3 as Xn,a4 as St,a5 as Yn,as as Zn,a as Qn,V as Jn,O as ei}from"./PierreWorkerPool-
|
|
1
|
+
import{j as k,r as oe}from"./react-rd22PHbN.js";import{a8 as q,a7 as Le,a9 as cn,G as fn,aa as pn,ab as gn,ac as Ze,ad as mn,ae as ye,af as He,a0 as me,ag as ve,ah as ie,a1 as qt,t as N,a6 as Pe,ai as Cn,b as $e,g as Sn,aj as ze,ak as fe,e as xn,o as Ln,w as kn,x as vn,al as Ce,f as Xt,h as ut,y as yn,am as Hn,an as Se,ao as wn,n as j,v as En,s as Yt,m as ct,q as An,z as Re,p as Rn,A as bn,R as Tn,I as Mn,B as ft,C as Dn,D as In,ap as Zt,aq as Fn,ar as pt,E as Nn,F as Pn,S as gt,T as zn,H as Bn,J as On,K as mt,L as Un,M as Vn,Q as Ct,N as Ge,U as jn,W as $n,d as Qt,X as Gn,Y as We,Z as Wn,$ as _n,_ as Jt,a2 as Kn,u as qn,a3 as Xn,a4 as St,a5 as Yn,as as Zn,a as Qn,V as Jn,O as ei}from"./PierreWorkerPool-BxP-s6jD.js";import{C as en,g as xe,S as ti,D as se,y as ni,z as ii,a as _e,b as xt,v as si,E as ri,w as oi,H as ai,c as li,d as di,i as hi,f as ui}from"./platform-Bqt97_Jr.js";import{t as re}from"./one-light-CoLDteqg.js";import{u as ci,a as fi}from"./EditContext-CvJWfVl1.js";import{c as we,T as pi,b as gi,B as mi,d as Ci}from"./index-B3QJsvjR.js";import{U as Lt,P as Si,az as xi,aa as Li}from"./App-BbT5H97Z.js";const ki=[["path",{d:"M16 4l4 0l0 4",key:"svg-0"}],["path",{d:"M14 10l6 -6",key:"svg-1"}],["path",{d:"M8 20l-4 0l0 -4",key:"svg-2"}],["path",{d:"M4 20l6 -6",key:"svg-3"}],["path",{d:"M16 20l4 0l0 -4",key:"svg-4"}],["path",{d:"M14 14l6 6",key:"svg-5"}],["path",{d:"M8 4l-4 0l0 4",key:"svg-6"}],["path",{d:"M4 4l6 6",key:"svg-7"}]],vi=we("outline","arrows-maximize","ArrowsMaximize",ki);const yi=[["path",{d:"M5 9l4 0l0 -4",key:"svg-0"}],["path",{d:"M3 3l6 6",key:"svg-1"}],["path",{d:"M5 15l4 0l0 4",key:"svg-2"}],["path",{d:"M3 21l6 -6",key:"svg-3"}],["path",{d:"M19 9l-4 0l0 -4",key:"svg-4"}],["path",{d:"M15 9l6 -6",key:"svg-5"}],["path",{d:"M19 15l-4 0l0 4",key:"svg-6"}],["path",{d:"M15 15l6 6",key:"svg-7"}]],Hi=we("outline","arrows-minimize","ArrowsMinimize",yi);const wi=[["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-0"}],["path",{d:"M12 4l0 16",key:"svg-1"}]],Ei=we("outline","layout-columns","LayoutColumns",wi);const Ai=[["path",{d:"M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12",key:"svg-0"}],["path",{d:"M4 12l16 0",key:"svg-1"}]],Ri=we("outline","layout-rows","LayoutRows",Ai);const bi=[["path",{d:"M4 6l16 0",key:"svg-0"}],["path",{d:"M4 18l5 0",key:"svg-1"}],["path",{d:"M4 12h13a3 3 0 0 1 0 6h-4l2 -2m0 4l-2 -2",key:"svg-2"}]],Ti=we("outline","text-wrap","TextWrap",bi);function Mi({hunkIndex:t,lineIndex:e,conflictIndex:n}){return`merge-conflict-action-${t}-${e}-${n}`}function Di(t,e){const n=e.hunks[t.hunkIndex];if(n!=null)return{hunkIndex:t.hunkIndex,lineIndex:Oi(n,t.startContentIndex)}}function xr(t,e=6){e=Math.max(e,1);const n={deletionLines:[],additionLines:[],conflictStack:[],conflictBuilders:[],actions:[],hunks:[],nextConflictIndex:0,splitLineCount:0,unifiedLineCount:0,lastHunkEnd:0,activeHunk:void 0,maxContextLines:e,maxContextLines2:e*2},i=t.contents,s=i.length;if(s>0){let u=0,c=0,f=i.indexOf(`
|
|
2
2
|
`,u);for(;f!==-1;)kt(n,i.slice(u,f+1),c),u=f+1,c++,f=i.indexOf(`
|
|
3
3
|
`,u);u<s&&kt(n,i.slice(u),c)}if(n.conflictStack.length>0)throw new Error("parseMergeConflictDiffFromFile: unfinished merge conflict marker stack");n.activeHunk!=null&&n.activeHunk.hunkContent.length>0&&(lt(n,n.activeHunk,"trailing"),sn(n));for(let u=0;u<n.conflictBuilders.length;u++){const c=n.conflictBuilders[u];if(c==null||!c.completed)throw new Error(`parseMergeConflictDiffFromFile: failed to build merge conflict action ${u}`)}if(n.hunks.length>0&&n.additionLines.length>0&&n.deletionLines.length>0){const u=n.hunks[n.hunks.length-1],c=Math.max(n.additionLines.length-q(u.additionStart,u.additionCount),0);n.splitLineCount+=c,n.unifiedLineCount+=c}const r=n.deletionLines.join(""),o=n.additionLines.join(""),a=At(t,"current",r),l=At(t,"incoming",o);let d="change";o===""?d="deleted":r===""&&(d="new");const h={name:t.name,prevName:void 0,type:d,hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,isPartial:!1,deletionLines:n.deletionLines,additionLines:n.additionLines,cacheKey:t.cacheKey!=null?`${t.cacheKey}:merge-conflict-diff`:void 0};return{fileDiff:h,currentFile:a,incomingFile:l,actions:n.actions,markerRows:Bi(h,n.actions)}}function kt(t,e,n){const i=t.conflictStack[t.conflictStack.length-1];if(i==null){if(e.length>=7&&e.charCodeAt(0)===60&&Et(e)==="start"){Ht(t,e,n);return}vt(t,e);return}const s=Et(e);if(s==="start"){Ht(t,e,n);return}if(s==="base"){i.stage="base",i.baseMarkerLineIndex=n,i.markerLines.base=e;return}if(s==="separator"){i.stage="incoming",i.separatorLineIndex=n,i.markerLines.separator=e;return}if(s==="end"){const r=t.conflictStack.pop();if(r==null)throw new Error("parseMergeConflictDiffFromFile: encountered end marker before start marker");Ni(t,r,n,e);return}i.stage==="current"?yt(t,"deletion",e,i.conflictIndex,"current"):i.stage==="base"?vt(t,e,i.conflictIndex):yt(t,"addition",e,i.conflictIndex,"incoming")}function tn(t){return t.activeHunk??=rn(t.additionLines.length+1,t.deletionLines.length+1),t.activeHunk}function nn(t,e,n,i){const s=t.conflictBuilders[e];if(s==null)throw new Error(`parseMergeConflictDiffFromFile: failed to locate conflict action ${e}`);const r=s.action,o=t.hunks.length;if(r.hunkIndex<0)r.hunkIndex=o;else if(r.hunkIndex!==o)throw new Error(`parseMergeConflictDiffFromFile: conflict ${e} spans multiple hunks and cannot be anchored`);if(r.startContentIndex<0&&(r.startContentIndex=i),r.endContentIndex=i,r.endMarkerContentIndex=i,n==="current"){r.currentContentIndex??=i;return}if(n==="base"){r.baseContentIndex??=i;return}r.incomingContentIndex=i}function Ii(t,e,n,i){const s=t.hunkContent,r=s[s.length-1];return r?.type==="change"?(e==="addition"?r.additions++:r.deletions++,s.length-1):(s.push({type:"change",additions:e==="addition"?1:0,deletions:e==="deletion"?1:0,additionLineIndex:n,deletionLineIndex:i}),s.length-1)}function lt(t,e,n){let i=e.contextBufferCount,s=e.contextBufferAdditionStart,r=e.contextBufferDeletionStart;if(n==="leading"&&i>t.maxContextLines){const h=i-t.maxContextLines;s+=h,r+=h,i=t.maxContextLines,e.additionStart+=h,e.deletionStart+=h,e.additionLineIndex+=h,e.deletionLineIndex+=h}if(n==="trailing"&&i>t.maxContextLines&&(i=t.maxContextLines),i===0){e.contextBufferCount=0,e.contextBufferBaseConflicts=void 0;return}const o=e.hunkContent,a=o[o.length-1];let l;a?.type==="context"?(a.lines+=i,l=o.length-1):(o.push({type:"context",lines:i,additionLineIndex:s,deletionLineIndex:r}),l=o.length-1),e.additionCount+=i,e.deletionCount+=i;const d=e.contextBufferBaseConflicts;if(d!=null){const h=s-e.contextBufferAdditionStart;for(const[u,c]of d)u>=h&&u<h+i&&nn(t,c,"base",l)}e.contextBufferCount=0,e.contextBufferBaseConflicts=void 0}function sn(t){if(t.activeHunk==null)return;const e=t.activeHunk;if(t.activeHunk=void 0,e.hunkContent.length===0)return;let n=0,i=0;for(const l of e.hunkContent)l.type==="context"?(n+=l.lines,i+=l.lines):(n+=Math.max(l.additions,l.deletions),i+=l.additions+l.deletions);const s=e.additionCount===0?e.additionStart-1:e.additionStart,r=e.deletionCount===0?e.deletionStart-1:e.deletionStart,o=Math.max(Le(s,e.additionCount)-t.lastHunkEnd,0),a={collapsedBefore:o,additionStart:s,additionCount:e.additionCount,additionLines:e.additionLines,additionLineIndex:e.additionLineIndex,deletionStart:r,deletionCount:e.deletionCount,deletionLines:e.deletionLines,deletionLineIndex:e.deletionLineIndex,hunkContent:e.hunkContent,hunkContext:void 0,hunkSpecs:`@@ -${wt(r,e.deletionCount)} +${wt(s,e.additionCount)} @@
|
|
4
4
|
`,splitLineStart:t.splitLineCount+o,splitLineCount:n,unifiedLineStart:t.unifiedLineCount+o,unifiedLineCount:i,noEOFCRAdditions:!1,noEOFCRDeletions:!1};t.hunks.push(a),t.splitLineCount+=o+n,t.unifiedLineCount+=o+i,t.lastHunkEnd=q(s,e.additionCount)}function Fi(t){if(t.activeHunk==null)return;const e=t.activeHunk,n=e.contextBufferCount,i=n-t.maxContextLines2,s=e.contextBufferAdditionStart+n-t.maxContextLines,r=e.contextBufferDeletionStart+n-t.maxContextLines;let o;if(e.contextBufferBaseConflicts!=null){const d=n-t.maxContextLines;for(const[h,u]of e.contextBufferBaseConflicts)h>=d&&(o??=new Map,o.set(h-d,u))}lt(t,e,"trailing");const a=e.additionCount,l=e.deletionCount;sn(t),t.activeHunk=rn(e.additionStart+a+i,e.deletionStart+l+i),t.activeHunk.contextBufferAdditionStart=s,t.activeHunk.contextBufferDeletionStart=r,t.activeHunk.contextBufferCount=t.maxContextLines,t.activeHunk.contextBufferBaseConflicts=o}function vt(t,e,n=-1){const i=tn(t);i.contextBufferCount===0&&(i.contextBufferAdditionStart=t.additionLines.length,i.contextBufferDeletionStart=t.deletionLines.length),t.additionLines.push(e),t.deletionLines.push(e),n>=0&&(i.contextBufferBaseConflicts??=new Map,i.contextBufferBaseConflicts.set(i.contextBufferCount,n)),i.contextBufferCount++}function yt(t,e,n,i,s){let r=tn(t);r.hunkContent.length>0&&r.contextBufferCount>t.maxContextLines2&&(Fi(t),r=t.activeHunk),lt(t,r,r.hunkContent.length===0?"leading":"before-change");const o=t.additionLines.length,a=t.deletionLines.length;e==="addition"?t.additionLines.push(n):t.deletionLines.push(n);const l=Ii(r,e,o,a);e==="addition"?(r.additionCount++,r.additionLines++):(r.deletionCount++,r.deletionLines++),nn(t,i,s,l)}function Ni(t,e,n,i){if(e.separatorLineIndex==null||e.markerLines.separator==null)throw new Error(`parseMergeConflictDiffFromFile: conflict ${e.conflictIndex} is missing a separator marker`);const s=t.conflictBuilders[e.conflictIndex];if(s==null)throw new Error(`parseMergeConflictDiffFromFile: failed to finalize conflict ${e.conflictIndex}`);const r=s.action;r.markerLines.separator=e.markerLines.separator,r.markerLines.end=i,e.markerLines.base!=null&&(r.markerLines.base=e.markerLines.base),r.conflict={conflictIndex:e.conflictIndex,startLineIndex:e.startLineIndex,startLineNumber:e.startLineIndex+1,separatorLineIndex:e.separatorLineIndex,separatorLineNumber:e.separatorLineIndex+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:e.baseMarkerLineIndex,baseMarkerLineNumber:e.baseMarkerLineIndex!=null?e.baseMarkerLineIndex+1:void 0};const o=r.currentContentIndex??r.incomingContentIndex;if(r.currentContentIndex??=o,r.incomingContentIndex??=o,r.startContentIndex<0&&o!=null&&(r.startContentIndex=o),r.endContentIndex<0&&o!=null&&(r.endContentIndex=o),r.endMarkerContentIndex<0&&o!=null&&(r.endMarkerContentIndex=o),r.hunkIndex<0||r.startContentIndex<0||r.endContentIndex<0||r.endMarkerContentIndex<0)throw new Error(`parseMergeConflictDiffFromFile: failed to anchor merge conflict ${e.conflictIndex}`);t.actions[r.conflictIndex]=r,s.completed=!0}function Ht(t,e,n){const i=t.nextConflictIndex;t.nextConflictIndex++,t.conflictStack.push({conflictIndex:i,stage:"current",startLineIndex:n,markerLines:{start:e}}),t.conflictBuilders[i]={completed:!1,action:{conflict:{conflictIndex:i,startLineIndex:n,startLineNumber:n+1,separatorLineIndex:n,separatorLineNumber:n+1,endLineIndex:n,endLineNumber:n+1,baseMarkerLineIndex:void 0,baseMarkerLineNumber:void 0},conflictIndex:i,hunkIndex:-1,startContentIndex:-1,endContentIndex:-1,endMarkerContentIndex:-1,markerLines:{start:e,separator:"",end:""}}}}function rn(t,e){return{additionStart:t,deletionStart:e,additionCount:0,deletionCount:0,additionLines:0,deletionLines:0,additionLineIndex:Math.max(t-1,0),deletionLineIndex:Math.max(e-1,0),hunkContent:[],contextBufferAdditionStart:Math.max(t-1,0),contextBufferDeletionStart:Math.max(e-1,0),contextBufferCount:0,contextBufferBaseConflicts:void 0}}function wt(t,e){return e===1?`${t}`:`${t},${e}`}function Et(t){if(t.length<7)return;const e=t.charCodeAt(0);if(e!==60&&e!==62&&e!==61&&e!==124)return;const n=Pi(t);if(n<7)return;let i=1;for(;i<n&&t.charCodeAt(i)===e;)i++;if(!(i<7)){if(e===61)return i===n?"separator":void 0;if(!(i!==n&&!zi(t.charCodeAt(i))))return e===60?"start":e===62?"end":"base"}}function Pi(t){let e=t.length;return e>0&&t.charCodeAt(e-1)===10&&e--,e>0&&t.charCodeAt(e-1)===13&&e--,e}function zi(t){return t===9||t===10||t===11||t===12||t===13||t===32}function At(t,e,n){return{...t,contents:n,cacheKey:t.cacheKey!=null?`${t.cacheKey}:merge-conflict-${e}`:void 0}}function Bi(t,e){const n=[],i=new Array(t.hunks.length),s=(o,a)=>{const l=t.hunks[o];if(l==null)return 0;let d=i[o];if(d==null){d=new Array(l.hunkContent.length+1);let h=l.unifiedLineStart;d[0]=h;for(let u=0;u<l.hunkContent.length;u++){const c=l.hunkContent[u];h+=c.type==="context"?c.lines:c.deletions+c.additions,d[u+1]=h}i[o]=d}return d[Math.max(a,0)]??l.unifiedLineStart},r=(o,a)=>{const l=s(o,a),d=i[o]?.[Math.max(a+1,0)]??s(o,a+1);return Math.max(l,d-1)};for(const o of e){if(o==null)continue;const a=t.hunks[o.hunkIndex];if(a==null)continue;const l=s(o.hunkIndex,o.startContentIndex);if(n.push(pe(o,"marker-start",o.startContentIndex,o.markerLines.start,l)),o.baseContentIndex!=null){const f=o.currentContentIndex,p=o.incomingContentIndex;if(f==null||p==null)continue;const g=o.markerLines.base;if(g==null)continue;const L=a.hunkContent[f],m=a.hunkContent[o.baseContentIndex],x=a.hunkContent[p];if(L?.type!=="change"||m?.type!=="context"||x?.type!=="change")continue;const v=s(o.hunkIndex,f),C=s(o.hunkIndex,p);n.push(pe(o,"marker-base",o.baseContentIndex,g,v+L.deletions)),n.push(pe(o,"marker-separator",o.baseContentIndex,o.markerLines.separator,C),pe(o,"marker-end",o.endMarkerContentIndex,o.markerLines.end,r(o.hunkIndex,o.endMarkerContentIndex)));continue}const d=o.currentContentIndex;if(d==null)continue;const h=a.hunkContent[d];if(h?.type!=="change")continue;const u=s(o.hunkIndex,d),c=h.deletions>0?u+h.deletions:l;n.push(pe(o,"marker-separator",d,o.markerLines.separator,c),pe(o,"marker-end",o.endMarkerContentIndex,o.markerLines.end,r(o.hunkIndex,o.endMarkerContentIndex)))}return n}function pe(t,e,n,i,s){return{type:e,hunkIndex:t.hunkIndex,contentIndex:n,conflictIndex:t.conflictIndex,lineText:i,lineIndex:s}}function Oi(t,e){let n=t.unifiedLineStart;for(let i=0;i<e;i++){const s=t.hunkContent[i];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function Ui({fileDiff:t,actions:e,renderCustomHeader:n,renderHeaderPrefix:i,renderHeaderFilenameSuffix:s,renderHeaderMetadata:r,renderAnnotation:o,renderGutterUtility:a,renderMergeConflictUtility:l,lineAnnotations:d,getHoveredLine:h,getInstance:u}){const c=n?.(t),f=i?.(t),p=s?.(t),g=r?.(t);return k.jsxs(k.Fragment,{children:[c!=null?k.jsx("div",{slot:en,children:c}):k.jsxs(k.Fragment,{children:[f!=null&&k.jsx("div",{slot:"header-prefix",children:f}),p!=null&&k.jsx("div",{slot:"header-filename-suffix",children:p}),g!=null&&k.jsx("div",{slot:"header-metadata",children:g})]}),o!=null&&d?.map((L,m)=>k.jsx("div",{slot:xe(L),children:o(L)},m)),e!=null&&l!=null&&u!=null&&e.map(L=>{if(L==null)return;const m=Vi(L,t);return k.jsx("div",{slot:m,style:cn,children:l(L,u)},m)}),a!=null&&k.jsx("div",{slot:"gutter-utility-slot",style:fn,children:a(h)})]})}function Vi(t,e){const n=Di(t,e);return n!=null?Mi({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:t.conflictIndex}):void 0}class ji extends pn{constructor(){super(...arguments),this.tokenize=Gi}equals(e,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!e.includes(`
|
package/dist/client/assets/{EditableFileViewer-DWeSDnZn.js → EditableFileViewer-Cmbomx5y.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as l}from"./react-rd22PHbN.js";import{r as
|
|
1
|
+
import{r as n,j as l}from"./react-rd22PHbN.js";import{r as _,V as k,O as j,P as N,a as A,u as O}from"./PierreWorkerPool-BxP-s6jD.js";import{F as I}from"./File-4o4egqlz.js";import{c as V,s as x,T as z,b as K,d as P}from"./index-B3QJsvjR.js";import{E as D}from"./edit-ready-context-D77R8XU8.js";import{aw as M,ax as C,ay as U}from"./App-BbT5H97Z.js";const q=[["path",{d:"M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2",key:"svg-0"}],["path",{d:"M10 14a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M14 4l0 4l-6 0l0 -4",key:"svg-2"}]],B=V("outline","device-floppy","DeviceFloppy",q),b={stableFrames:3,maxFrames:60,userScrollTolerance:2};function G(e,t,r={}){const o=r.stableFrames??b.stableFrames,s=r.maxFrames??b.maxFrames,p=r.userScrollTolerance??b.userScrollTolerance,E=r.requestFrame??(i=>requestAnimationFrame(i)),T=r.cancelFrame??(i=>cancelAnimationFrame(i)),S=Number.isFinite(t)?Math.min(1,Math.max(0,t)):0;let f=null,v=0,m=0,c=null,a=null,y=!1;const g=()=>{y=!0,f!==null&&T(f),f=null},F=()=>{if(f=null,y)return;v+=1;const i=e.getContentHeight();if(a!==null&&c===i&&Math.abs(e.getScrollTop()-a)>p){g();return}const u=e.getScrollRange(),h=u>0?S*u:0;if(e.scrollTo(h),a=h,m=i>0&&c===i?m+1:0,c=i,m>=o||v>=s){g();return}f=E(F)};return F(),g}function W(e){const t=e.split("+"),r=t.pop().toLowerCase();return[...t.map(s=>s==="Ctrl"?"cmdOrCtrl":s.toLowerCase()),r].join("+")}function H(e){return[{bindings:{[W(e)]:"openSearchReplacePanel"}}]}H(M.editorSearch);const $=2e3;function Y(e,t=$){let r=1;for(let o=0;o<e.length;o+=1)if(e.charCodeAt(o)===10&&(r+=1,r>t))return!0;return!1}function Z(e,t,r=M.saveFile){return U({key:e.key,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey??!1,altKey:e.altKey??!1},r)?(e.preventDefault(),t(),!0):!1}async function J(e){if(!e.dirty||e.readOnly||!e.claim())return"skipped";try{return(await e.persist()).status==="conflict"?(e.onConflict(),"conflict"):(e.onSuccess(),"saved")}catch(t){return e.onError(t),"error"}finally{e.release()}}function Q({file:e,initialContent:t,readOnly:r,messages:o,onDirtyChange:s,onDraftChange:p,onSave:E}){const T=C(),[S,f]=n.useState(t),[v,m]=n.useState(!1),c=n.useRef(!1),a=S!==e.content,y=n.useRef(e.content);n.useLayoutEffect(()=>{S===y.current&&e.content!==y.current&&f(e.content),y.current=e.content},[e.content,S]),n.useEffect(()=>{s(a)},[a,s]),n.useEffect(()=>()=>s(!1),[s]);const g=n.useCallback(u=>{f(u),s(u!==e.content),p(u)},[e.content,s,p]),F=n.useCallback(async()=>{await J({dirty:a,readOnly:r,claim:()=>c.current?!1:(c.current=!0,m(!0),!0),release:()=>{c.current=!1,m(!1)},persist:()=>E(e.path,S,e.content),onConflict:()=>x.error({title:o.conflictTitle,description:"Your draft is still open. Copy it or reload the file before saving again.",duration:1e4}),onSuccess:()=>x.success({title:o.successTitle,description:e.path}),onError:u=>x.error({title:o.errorTitle,description:u instanceof Error?u.message:"Unknown error",duration:1e4})})},[a,S,e.content,e.path,o,E,r]),i=n.useRef(F);return n.useEffect(()=>{i.current=F},[F]),n.useEffect(()=>{const u=h=>{Z(h,()=>{i.current()},T.saveFile)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[T.saveFile]),{draft:S,updateDraft:g,dirty:a,saving:v,save:F}}function L({dirty:e,saving:t,readOnly:r,onSave:o}){const s=C();if(!e&&!t)return null;const p=r?"Read only":t?"Saving…":`Save file (${s.saveFile})`;return l.jsxs(z,{children:[l.jsx(K,{render:l.jsx("button",{type:"button",className:"file-save-button","data-state":r?"readonly":t?"saving":"dirty",disabled:t||r,onClick:o,"aria-label":p}),children:l.jsx(B,{"aria-hidden":"true"})}),l.jsx(P,{children:p})]})}function X({handleRef:e}){const t=O();return n.useLayoutEffect(()=>{e.current=t},[t,e]),null}function w({path:e,cacheKey:t,value:r,themeType:o,wrapLines:s,readOnly:p,onChange:E,ref:T}){const S=n.useContext(D),f=C(),[v]=n.useState(()=>Y(r)),m=n.useRef(E);n.useEffect(()=>{m.current=E},[E]);const c=n.useRef(void 0),a=n.useRef(null),y=n.useMemo(()=>({name:e,lang:_(e),contents:r,cacheKey:t}),[t,e,r]),g=n.useMemo(()=>({disableFileHeader:!0,themeType:o,theme:j,overflow:s?"wrap":"scroll",unsafeCSS:k}),[o,s]),F=n.useMemo(()=>({historyMaxEntries:500,keymap:H(f.editorSearch),onChange(h){m.current(h.contents)}}),[f.editorSearch]),i=n.useRef(null);n.useEffect(()=>()=>i.current?.(),[]),n.useImperativeHandle(T,()=>({getScrollFraction(){const h=c.current?.getRoot()??a.current;if(!(h instanceof HTMLElement))return 0;const d=h.scrollHeight-h.clientHeight;return d>0?h.scrollTop/d:0},scrollToFraction(h){i.current?.(),i.current=G({getScrollRange(){const d=c.current?.getRoot()??a.current;return d instanceof HTMLElement?Math.max(0,d.scrollHeight-d.clientHeight):0},getScrollTop(){const d=c.current?.getRoot()??a.current;return d instanceof HTMLElement?d.scrollTop:0},getContentHeight(){const d=c.current?.getRoot()??a.current;return d instanceof HTMLElement?d.scrollHeight:0},scrollTo(d){const R=c.current;R&&R.getRoot()instanceof HTMLElement?R.scrollTo({top:d}):a.current?.scrollTo({top:d})}},h)}}),[]);const u=l.jsx(I,{file:y,options:g,editorOptions:F,edit:S&&!p});return l.jsx(N,{theme:j,children:v?l.jsxs(A,{className:"source-code-editor",contentClassName:"source-code-editor-content",children:[l.jsx(X,{handleRef:c}),u]}):l.jsx("div",{ref:a,className:"source-code-editor",children:l.jsx("div",{className:"source-code-editor-content",children:u})})})}const ee={conflictTitle:"File was changed outside OpenTig",successTitle:"File saved",errorTitle:"Could not save file"};function te({file:e,initialContent:t,themeType:r,wrapLines:o,readOnly:s,onDirtyChange:p,onDraftChange:E,onSave:T}){const{draft:S,updateDraft:f,dirty:v,saving:m,save:c}=Q({file:e,initialContent:t,readOnly:s,messages:ee,onDirtyChange:p,onDraftChange:E,onSave:T});return l.jsxs("div",{className:"source-file-viewer",children:[(v||m)&&l.jsx("div",{className:"source-file-toolbar",children:l.jsx(L,{dirty:v,saving:m,readOnly:s,onSave:()=>{c()}})}),l.jsx("div",{className:"source-editor-scroll",children:l.jsx(w,{path:e.path,cacheKey:e.path,value:S,themeType:r,wrapLines:o,readOnly:s||m,onChange:f})})]})}const le=Object.freeze(Object.defineProperty({__proto__:null,EditableFileViewer:te,FileSaveControls:L,SourceCodeEditor:w},Symbol.toStringTag,{value:"Module"}));export{le as E,L as F,w as S,G as s,Q as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as ge,g as k,D as H,a as j,l as $,b as ee,E as xe,i as Ee,H as Fe,c as ke,d as ze,e as Ie,f as Oe}from"./platform-Bqt97_Jr.js";import{G as Pe,b as te,g as Ne,c as A,i as Y,d as R,e as Ve,f as me,h as ie,j as De,k as Be,l as Ue,s as Ce,m as _e,n as ne,o as re,p as We,q as Ge,t as se,v as je,w as $e,x as Ke,y as qe,z as oe,A as Ye,R as Xe,I as Je,B as ae,C as Qe,D as Ze,E as et,F as tt,H as it,J as nt,K as he,L as rt,M as st,N as ot,Q as at,S as le,T as ht,U as lt,W as dt,X as ct,Y as ut,Z as ft,_ as Se,$ as de,a0 as V,a1 as ce,a2 as pt,u as gt,a3 as mt,a4 as ue,a5 as Ct}from"./PierreWorkerPool-Cg9zdxiI.js";import{j as y,r as F}from"./react-rd22PHbN.js";import{t as b}from"./one-light-CoLDteqg.js";import{u as St,a as vt}from"./EditContext-CvJWfVl1.js";function yt({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:o,renderGutterUtility:a,getHoveredLine:l}){const d=e?.(i),h=t?.(i),c=n?.(i),u=r?.(i);return y.jsxs(y.Fragment,{children:[d!=null?y.jsx("div",{slot:ge,children:d}):y.jsxs(y.Fragment,{children:[h!=null&&y.jsx("div",{slot:"header-prefix",children:h}),c!=null&&y.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&y.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&o?.map((f,m)=>y.jsx("div",{slot:k(f),children:s(f)},m)),a!=null&&y.jsx("div",{slot:"gutter-utility-slot",style:Pe,children:a(l)})]})}function D(i,e){return e.cacheKey==null?i.file===e&&i.sourceContents===e.contents:i.cacheKey===e.cacheKey}let Rt=-1;var Tt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++Rt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(i={theme:H},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=te(i.theme??H)?Ne():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){const{renderCache:i,lineCache:e}=this;i?.isDirty!==!0||e==null||!D(e,i.file)||(i.file.contents=e.lines.join(""))}hasUnkeyedFileContentsChanged(i){const{lineCache:e}=this;return i.cacheKey==null&&e!=null&&e.file===i&&e.sourceContents!==i.contents}invalidateChangedUnkeyedFile(i){this.hasUnkeyedFileContentsChanged(i)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!A(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!Y(i),result:t?void 0:n?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??H}getEffectiveCodeOptions(){const i=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:i?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0){const r=this.workerManager.getFileRenderOptions();return this.editSessionActive&&r.useTokenTransformer!==!0?{...r,useTokenTransformer:!0}:r}const{tokenizeMaxLineLength:n=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:n}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!R(i,t.file)||!A(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){this.invalidateChangedUnkeyedFile(i);let{lineCache:e}=this;return(e==null||!D(e,i))&&(e={cacheKey:i.cacheKey,file:i,sourceContents:i.contents,lines:$(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){const e=this.getOrCreateLineCache(i);return this.textDocumentCache.get(i)?.lineCount??e.length}updateRenderCache(i,e,t=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:n,result:r}=this.renderCache;if(r==null)return;const s=t?new Map:void 0;this.pendingStructuralRows=s;const o=this.lineCache!=null&&D(this.lineCache,n)?this.lineCache:void 0;for(const[a,l]of i){if(s===void 0&&o!=null&&a<o.lines.length){const h=l.map(c=>c[2]).join("");o.lines[a]=Ve(o.lines[a]??"",h)}const d={type:"element",tagName:"div",properties:{"data-line":a+1,"data-line-type":"context","data-line-index":a},children:l.map(([h,c,u])=>h===0&&c===""?u===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:u}:{type:"element",tagName:"span",properties:{"data-char":h,style:`color:${c};`},children:[{type:"text",value:u}]})};s!==void 0?s.set(a,d):r.code[a]=d}r.baseThemeType=e,this.renderCache.isDirty=!0}applyDocumentChange(i){const e=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:t,result:n}=this.renderCache;if(n==null)return;const r=this.lineCache!=null&&D(this.lineCache,t)?this.lineCache.lines:$(t.contents),s=$(i.getText());if(r.length!==s.length){const o=Math.min(r.length,s.length);let a=0;for(;a<o&&r[a]===s[a];)a++;let l=0;for(;l<o-a&&r[r.length-1-l]===s[s.length-1-l];)l++;const d=n.code;n.code=new Array(s.length);for(let h=0;h<a;h++)n.code[h]=d[h];for(let h=0;h<l;h++)n.code[s.length-1-h]=d[r.length-1-h];if(e!==void 0)for(const[h,c]of e)h<s.length&&(n.code[h]=c);for(let h=a;h<s.length-l;h++)n.code[h]??={type:"element",tagName:"div",properties:{"data-line":h+1,"data-line-type":"context","data-line-index":h},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(h)}]}]};for(let h=0;h<n.code.length;h++){const c=n.code[h];c?.type==="element"&&(c.properties["data-line"]=h+1,c.properties["data-line-index"]=h)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:t.cacheKey,file:t,sourceContents:t.contents,lines:s},this.textDocumentCache.set(t,i)}renderFile(i=this.renderCache?.file,e=ee){if(i==null)return;this.invalidateChangedUnkeyedFile(i),this.renderCache?.isDirty===!0&&!R(i,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:t,forceHighlight:n}=this.getRenderOptions(i);this.renderCache?.isDirty===!0&&!A(t,this.renderCache.options)&&this.clearRenderCache();const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),o=i.contents.length>0,a=!o||Y(i)||K(s.length,this.getTokenizeMaxLength()),l=!R(i,this.renderCache.file),d=!me(this.renderCache.renderRange,e);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(a||this.renderCache.result==null||!this.renderCache.highlighted&&(l||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!a&&o&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const h=this.highlighter!=null&&te(t.theme),c=this.highlighter!=null&&ie(this.computedLang),u=!a&&c;if(this.highlighter!=null&&h&&(n||a||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:f,options:m}=this.renderFileWithHighlighter(i,this.highlighter,a||!c);this.renderCache={file:i,options:m,highlighted:u,result:f,renderRange:void 0}}(!h||!a&&!c)&&this.asyncHighlight(i).then(({result:f,options:m})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(i,f,m,!a)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=ee){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&De(Be(this.getLocalHighlightTheme())),n=e||this.highlighter!=null&&ie(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:Ue(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:o=!1}=this.options,a=[],l=oe(),d=Math.min(e.startingLine+e.totalLines,s);let h=0;const c=Ce(e)?_e(this.lineAnnotations):void 0;c!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>k(u))})),h++);for(let u=e.startingLine;u<d;u++){const f=u+1,m=t[u];if(m==null){const C="FileRenderer.processFileResult: Line doesnt exist";throw console.error(C,{name:i.name,lineIndex:u,lineNumber:f}),new Error(C)}l.children.push(We("context",f,`${u}`)),a.push(m),h++;const g=this.lineAnnotations[f];g!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:0,lineIndex:f,annotations:g.map(C=>k(C))})),h++)}return l.properties.style=`grid-row: span ${h}`,{gutterAST:l.children??[],contentAST:a,preAST:this.createPreElement(s),headerAST:o?void 0:this.renderHeader(i),totalLines:s,rowCount:h,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return Ge({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return b(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(se({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=oe();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,je(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?b(se({tagName:"code",children:i,properties:{"data-code":""}})):b(i)}async initializeHighlighter(){return this.highlighter=await $e(Ke(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(i,e,t,n=!0){this.editSessionActive||this.applyHighlightResult(i,e,t,n)}applyHighlightResult(i,e,t,n=!0){if(this.renderCache==null)return;const r=!R(i,this.renderCache.file)||!this.renderCache.highlighted||!A(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){if(this.editSessionActive)return;const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!A(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&R(i,t.file)&&A(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return qe({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function K(i,e){return i>e}function Lt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function fe(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:Ye(i),tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const Mt=[""];let At=-1;var ve=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++At}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:H},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Tt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Xe,this.interactionManager=new Je("file",ae(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ae(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Qe(this.appliedThemeCSS.theme,this.options.theme??H)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e==="scroll"&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:o}=e;if(!this.enabled)throw new Error("File.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw new Error("File.hydrate: hydrate can only be called before the instance has rendered or hydrated");this.hydrateElements(t,n),Ht(this.pre,s,this.options.collapsed)||bt(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:o}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ze(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):Mt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,s=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(o=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(o,t,n,r,s)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();const t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");const t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:o=!1,lineAnnotations:a,renderRange:l}){this.editor?.__postponeBgTokenizeToNextFrame();const{collapsed:d=!1,themeType:h="system"}=this.options,c=d?void 0:l,u=this.renderRange,f=this.hasThemeChanged(),m=a!=null&&(a.length>0||this.lineAnnotations.length>0)?a!==this.lineAnnotations:!1,g=!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!d&&!n&&me(c,this.renderRange)&&!g&&!m&&!f)return this.applyCachedThemeState(h);this.renderRange=c,g&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),a!=null&&this.setLineAnnotations(a),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:C=!1,disableFileHeader:S=!1}=this.options;if(S&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(h),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const p=this.fileRenderer.renderFile(e,xe);p!=null&&this.applyThemeState(t,p.themeStyles,h,p.baseThemeType),p?.headerAST!=null&&this.applyHeaderToDOM(p.headerAST,t),this.injectUnsafeCSS()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}try{const p=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,m,g||f)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,h,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,p)}this.applyBuffers(p,c),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,o||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.file){const{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Y(e))return;const n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(r=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${k(r)}`;let o=this.annotationCache.get(s);if(o==null||!Lt(r,o.annotation)){o?.element.remove();const a=t(r);if(a==null)continue;o={element:et(k(r)),annotation:r},o.element.appendChild(a),this.fileContainer.appendChild(o.element),this.annotationCache.set(s,o)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=tt();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=it(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=nt(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,a=this.options.theme??H,l=typeof a=="string"?a:{...a},d=he(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=l;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=rt({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:ct(t,o,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=st(this.themeCSSStyle.textContent??"",he(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&Ee()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);const n=this.code=ot({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();const s=()=>{if(n.childElementCount>=2)for(let o=0;o<2;o++){const a=n.children[o],l=r[o];a.innerHTML=b(l.children),a.style.cssText=l.properties.style}else n.innerHTML=b(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?at(t,s):s(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const o=e.startingLine,a=t.startingLine,l=e.totalLines===1/0?Number.POSITIVE_INFINITY:o+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:a+t.totalLines,h=Math.max(o,a),c=Math.min(l,d);if(c<=h)return!1;if(!this.trimDOMToOverlap(s.gutter,h,c)||!this.trimDOMToOverlap(s.content,h,c))throw new Error("File.applyPartialRender: failed to trim to overlap");let{length:u}=s.content.children;const f=(S,p)=>{if(!(p<=0))return this.fileRenderer.renderFile(n,{startingLine:S,totalLines:p,bufferBefore:0,bufferAfter:0})},m=a<h?f(a,h-a):void 0;if(m===void 0&&a<h)return!1;const g=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),C=d>c?f(c,g):void 0;return C===void 0&&d>c?!1:(this.cleanupErrorWrapper(),m!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.contentAST)),u+=m.rowCount),C!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.contentAST)),u+=C.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,o=r.get(n)??e.children.length;if(s>o)return!1;for(let a=e.children.length-1;a>=o;a-=1)e.children[a]?.remove();for(let a=s-1;a>=0;a-=1)e.children[a]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((l,d)=>l-d),r=new Map;if(n.length===0)return r;let s=0,o=n[s];const{children:a}=e;o===0&&(r.set(0,0),s+=1,o=n[s]);for(let l=0;l<a.length;l+=1){const d=a[l];if(!(d instanceof HTMLElement))continue;const h=this.getLineIndexFromDOMNode(d);if(h!=null){for(;o!=null&&h>=o;)r.set(o,l),s+=1,o=n[s];if(s>=n.length)break}}for(const l of n)r.has(l)||r.set(l,a.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??b(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const h=d.firstElementChild;if(!(h instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(h,this.headerElement):t.shadowRoot?.prepend(h),this.headerElement=h,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:o,renderCustomHeader:a,renderHeaderMetadata:l}=this.options;if(a!=null){const d=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,ge,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,h=o?.(n)??void 0,c=l?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Fe,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,ke,h),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return n!=null&&s&&this.editor?.__captureFocusForDOMReplacement(),s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:le(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):le(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=ht;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};lt(s,this.appliedPreAttributes)||(dt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ht(i,e,t=!1){return!t&&i==null&&e!=null}function bt(i,e,t=!1){return i==null&&e!=null&&!t}const wt=5e3;let xt=-1;function Et(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var Ft=class extends ve{virtualizer;metrics;__id=`virtualized-file:${++xt}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ie,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){const t=ut(i);!e&&ft(this.metrics,t)||(this.metrics=t,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!Se(e,i),n=Et(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1,e=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&e&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=de(this.lineAnnotations);if(this.renderRange!=null&&n&&Ce(this.renderRange)){const r=kt(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const o=Number(s);let a=r.getBoundingClientRect().height,l=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(l=!0),a+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(o,l);a!==d&&(i=!0,a===this.metrics.lineHeight*(l?2:1)?this.cache.heights.delete(o):this.cache.heights.set(o,a))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n),s=!R(this.file,i)||this.fileRenderer.hasUnkeyedFileContentsChanged(i);let o=t?.resetFileLayoutCache===!0||s||r;t?.metrics!=null&&(this.metrics=t.metrics,o=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,o=!0),o&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=V(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics;if(r+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())return{top:r+s*a,height:a};const l=this.getLayoutCheckpointBeforeLineIndex(s);r=l?.top??r;for(let d=l?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=V(this.metrics,e),o=Math.min(this.renderRange.startingLine,r),a=Math.min(o+this.renderRange.totalLines-1,r);if(a<o)return;const{fileAnnotationHeight:l}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:h}=this.metrics,c=s+(o===0?l:this.renderRange.bufferBefore),u=o+Math.max(Math.ceil((i-c)/h),0);return u>a?void 0:{lineNumber:u+1,top:s+l+u*h}}let d=s+(o===0?l:this.renderRange.bufferBefore);for(let h=o;h<=a;h++){if(d>=i)return{lineNumber:h+1,top:d};d+=this.getLineHeight(h)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const o=i??this.virtualizer.getWindowSpecs();this.top<o.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1,e=this.file){const t=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!t)return;const n=this.height===0;if(this.height=0,this.cache.checkpoints=[],e==null){this.layoutDirty=!1;return}const{disableFileHeader:r=!1,collapsed:s=!1,overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(e),d=V(this.metrics,r),h=ce(this.metrics);if(this.height+=d,s){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())this.height+=l*a;else for(let c=0;c<l;c++)this.addLayoutCheckpoint(c,this.height),this.height+=this.getLineHeight(c,!1);if(l>0&&(this.height+=h),this.fileContainer!=null&&t&&!n){const c=this.fileContainer.getBoundingClientRect();c.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:c.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{renderRange:n}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(t&&n!==void 0&&this.file!==void 0){const r=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.file,this.top??0,r);s.bufferAfter!==n.bufferAfter&&this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),{forceRenderOverride:o,isSetup:a}=this;this.forceRenderOverride=void 0;const l=this.syncLineAnnotations(n);if(l&&this.resetLayoutCache(),i=this.getOrCreateFileContainerNode(i),e==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(a)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,e));else{this.computeApproximateSize(!1,e);const f=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(f==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");f.connect(i,this),this.isVisible=f.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!s||!a))return this.file=e,s&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),h=this.top??0,c=this.computeRenderRangeFromWindow(e,h,d),u=super.renderPreparedFile({file:e,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(o??t)||l||s,...r});return this.isSimpleMode()&&u&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),u}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%wt===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");o.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(o.lineIndex%e===0)return o}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:o,lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(i),d=this.height,h=V(this.metrics,r),c=l>0?ce(this.metrics):0,{fileAnnotationHeight:u}=this.cache,f=h+u,m=Math.max(0,d-h-u-c),g=de(this.lineAnnotations),C=e+h,S=u>0&&g&&C<n&&C+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};if(l<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};const p=Math.ceil(Math.max(n-t,0)/a),v=Math.ceil(p/o)*o+o,z=v/o,B=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const M=e+f,N=M+m;if(!S&&!(M<n&&N>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};const x=Math.floor(S&&B<e+f?0:(B-(e+f))/a),L=Math.floor(x/o)-Math.floor(z/2),He=Math.ceil(l/o),E=Math.max(0,Math.min(L,He))*o,Z=L<0?v+L*o:v,be=E===0?0:u+E*a,we=Math.min(Z,l-E);return{startingLine:E,totalLines:Z,bufferBefore:be,bufferAfter:Math.max(0,(l-E-we)*a)}}const ye=z,I=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*a*2),o);let T=e+(U?.top??f),_=U?.lineIndex??0,O,P,w;const Re=U?.lineIndex??0;for(let M=Re;M<l;M++){const N=_%o===0,x=Math.floor(_/o);if(N&&(I[x]=T-(e+f),w!=null)){if(w<=0)break;w--}const L=this.getLineHeight(M,!1);T>t-L&&T<n&&(O??=x),T+L>B&&(P??=x),w==null&&T>=n&&N&&(w=ye),_++,T+=L}if(O==null)if(S)O=0,P=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};P??=O;const W=Math.round(P-z/2),Te=Math.max(0,Math.ceil(l/o)-z),G=Math.max(0,Math.min(W,Te)),X=G*o,J=W<0?v+W*o:v,Le=I[G]??0,Me=X===0?0:u+Le,Q=G+J/o,Ae=Q<I.length?m-I[Q]:m-(T-e-f);return{startingLine:X,totalLines:J,bufferBefore:Me,bufferAfter:Math.max(0,Ae)}}};function kt(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===pt&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}const pe=typeof window>"u"?F.useEffect:F.useLayoutEffect;function zt({file:i,options:e,editorOptions:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:s,metrics:o,hasGutterRenderUtility:a,hasCustomHeader:l,disableWorkerPool:d,edit:h}){const c=gt(),u=r!==void 0,f=F.useContext(mt),m=St(),g=F.useRef(null),C=vt(S=>{if(S!=null){if(g.current!=null)throw new Error("File: An instance should not already exist when a node is created");c!=null?g.current=new Ft(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),c,o,d?void 0:f,!0):g.current=new ve(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),d?void 0:f,!0),g.current.hydrate({file:i,fileContainer:S,lineAnnotations:n,prerenderedHTML:s})}else{if(g.current==null)throw new Error("File: A File instance should exist when unmounting");g.current.cleanUp(),g.current=null}});return pe(()=>{if(g.current==null)return;const S=q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),p=S!==void 0&&!Se(g.current.options,S);g.current.setOptions(S),g.current.render({file:i,lineAnnotations:n,forceRender:p}),r!==void 0&&g.current.setSelectedLines(r)}),pe(()=>{if(h&&g.current!=null){if(m===void 0)throw new Error("File: EditContext is not attached");const S=m(t??{});if(S==null)throw new Error("File: EditProvider.createEditor must return an editor instance");try{return S.edit(g.current)}catch(p){throw S.cleanUp(),p}}},[h]),{ref:C,getHoveredLine:F.useCallback(()=>g.current?.getHoveredLine(),[])}}function q({options:i,controlledSelection:e,hasCustomHeader:t,hasGutterRenderUtility:n}){return e||n||t?{...i,controlledSelection:e,renderCustomHeader:t?ue:i?.renderCustomHeader,renderGutterUtility:n?ue:i?.renderGutterUtility}:i}function Bt({file:i,lineAnnotations:e,selectedLines:t,options:n,editorOptions:r,metrics:s,className:o,style:a,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,prerenderedHTML:f,renderGutterUtility:m,disableWorkerPool:g=!1,edit:C=!1}){const{ref:S,getHoveredLine:p}=zt({file:i,options:n,editorOptions:r,metrics:s,lineAnnotations:e,selectedLines:t,prerenderedHTML:f,hasGutterRenderUtility:m!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:C});return y.jsx(Oe,{ref:S,className:o,style:a,children:Ct(yt({file:i,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,renderGutterUtility:m,lineAnnotations:e,getHoveredLine:p}),f)})}export{Bt as F};
|
|
1
|
+
import{C as ge,g as k,D as H,a as j,l as $,b as ee,E as xe,i as Ee,H as Fe,c as ke,d as ze,e as Ie,f as Oe}from"./platform-Bqt97_Jr.js";import{G as Pe,b as te,g as Ne,c as A,i as Y,d as R,e as Ve,f as me,h as ie,j as De,k as Be,l as Ue,s as Ce,m as _e,n as ne,o as re,p as We,q as Ge,t as se,v as je,w as $e,x as Ke,y as qe,z as oe,A as Ye,R as Xe,I as Je,B as ae,C as Qe,D as Ze,E as et,F as tt,H as it,J as nt,K as he,L as rt,M as st,N as ot,Q as at,S as le,T as ht,U as lt,W as dt,X as ct,Y as ut,Z as ft,_ as Se,$ as de,a0 as V,a1 as ce,a2 as pt,u as gt,a3 as mt,a4 as ue,a5 as Ct}from"./PierreWorkerPool-BxP-s6jD.js";import{j as y,r as F}from"./react-rd22PHbN.js";import{t as b}from"./one-light-CoLDteqg.js";import{u as St,a as vt}from"./EditContext-CvJWfVl1.js";function yt({file:i,renderCustomHeader:e,renderHeaderPrefix:t,renderHeaderFilenameSuffix:n,renderHeaderMetadata:r,renderAnnotation:s,lineAnnotations:o,renderGutterUtility:a,getHoveredLine:l}){const d=e?.(i),h=t?.(i),c=n?.(i),u=r?.(i);return y.jsxs(y.Fragment,{children:[d!=null?y.jsx("div",{slot:ge,children:d}):y.jsxs(y.Fragment,{children:[h!=null&&y.jsx("div",{slot:"header-prefix",children:h}),c!=null&&y.jsx("div",{slot:"header-filename-suffix",children:c}),u!=null&&y.jsx("div",{slot:"header-metadata",children:u})]}),s!=null&&o?.map((f,m)=>y.jsx("div",{slot:k(f),children:s(f)},m)),a!=null&&y.jsx("div",{slot:"gutter-utility-slot",style:Pe,children:a(l)})]})}function D(i,e){return e.cacheKey==null?i.file===e&&i.sourceContents===e.contents:i.cacheKey===e.cacheKey}let Rt=-1;var Tt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++Rt}`;highlighter;renderCache;computedLang="text";lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(i={theme:H},e,t){this.options=i,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=te(i.theme??H)?Ne():void 0)}setOptions(i){this.options=i}mergeOptions(i){this.options={...this.options,...i}}setLineAnnotations(i){this.lineAnnotations={};for(const e of i){const t=this.lineAnnotations[e.lineNumber]??[];this.lineAnnotations[e.lineNumber]=t,t.push(e)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){const{renderCache:i,lineCache:e}=this;i?.isDirty!==!0||e==null||!D(e,i.file)||(i.file.contents=e.lines.join(""))}hasUnkeyedFileContentsChanged(i){const{lineCache:e}=this;return i.cacheKey==null&&e!=null&&e.file===i&&e.sourceContents!==i.contents}invalidateChangedUnkeyedFile(i){this.hasUnkeyedFileContentsChanged(i)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;const i=this.renderCache;this.renderCache=void 0,i!=null&&i.isDirty===!0&&i.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(i.file.cacheKey)}hydrate(i){const{options:e}=this.getRenderOptions(i),t=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());let n=this.workerManager?.getFileResultCache(i);n!=null&&!A(e,n.options)&&(n=void 0),this.renderCache??={file:i,options:e,highlighted:!t&&!Y(i),result:t?void 0:n?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightFileAST(this,i):this.highlighter==null&&(this.computedLang=i.lang??j(i.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??H}getEffectiveCodeOptions(){const i=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:i?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(i){const e=(()=>{if(this.workerManager?.isWorkingPool()===!0){const r=this.workerManager.getFileRenderOptions();return this.editSessionActive&&r.useTokenTransformer!==!0?{...r,useTokenTransformer:!0}:r}const{tokenizeMaxLineLength:n=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:n}})(),{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!R(i,t.file)||!A(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}getOrCreateLineCache(i){this.invalidateChangedUnkeyedFile(i);let{lineCache:e}=this;return(e==null||!D(e,i))&&(e={cacheKey:i.cacheKey,file:i,sourceContents:i.contents,lines:$(i.contents)}),this.lineCache=e,e.lines}getLineCount(i){const e=this.getOrCreateLineCache(i);return this.textDocumentCache.get(i)?.lineCount??e.length}updateRenderCache(i,e,t=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:n,result:r}=this.renderCache;if(r==null)return;const s=t?new Map:void 0;this.pendingStructuralRows=s;const o=this.lineCache!=null&&D(this.lineCache,n)?this.lineCache:void 0;for(const[a,l]of i){if(s===void 0&&o!=null&&a<o.lines.length){const h=l.map(c=>c[2]).join("");o.lines[a]=Ve(o.lines[a]??"",h)}const d={type:"element",tagName:"div",properties:{"data-line":a+1,"data-line-type":"context","data-line-index":a},children:l.map(([h,c,u])=>h===0&&c===""?u===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:u}:{type:"element",tagName:"span",properties:{"data-char":h,style:`color:${c};`},children:[{type:"text",value:u}]})};s!==void 0?s.set(a,d):r.code[a]=d}r.baseThemeType=e,this.renderCache.isDirty=!0}applyDocumentChange(i){const e=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;const{file:t,result:n}=this.renderCache;if(n==null)return;const r=this.lineCache!=null&&D(this.lineCache,t)?this.lineCache.lines:$(t.contents),s=$(i.getText());if(r.length!==s.length){const o=Math.min(r.length,s.length);let a=0;for(;a<o&&r[a]===s[a];)a++;let l=0;for(;l<o-a&&r[r.length-1-l]===s[s.length-1-l];)l++;const d=n.code;n.code=new Array(s.length);for(let h=0;h<a;h++)n.code[h]=d[h];for(let h=0;h<l;h++)n.code[s.length-1-h]=d[r.length-1-h];if(e!==void 0)for(const[h,c]of e)h<s.length&&(n.code[h]=c);for(let h=a;h<s.length-l;h++)n.code[h]??={type:"element",tagName:"div",properties:{"data-line":h+1,"data-line-type":"context","data-line-index":h},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:i.getLineText(h)}]}]};for(let h=0;h<n.code.length;h++){const c=n.code[h];c?.type==="element"&&(c.properties["data-line"]=h+1,c.properties["data-line-index"]=h)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:t.cacheKey,file:t,sourceContents:t.contents,lines:s},this.textDocumentCache.set(t,i)}renderFile(i=this.renderCache?.file,e=ee){if(i==null)return;this.invalidateChangedUnkeyedFile(i),this.renderCache?.isDirty===!0&&!R(i,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:t,forceHighlight:n}=this.getRenderOptions(i);this.renderCache?.isDirty===!0&&!A(t,this.renderCache.options)&&this.clearRenderCache();const r=this.getMatchingWorkerResultCache(i,t);r!=null&&!this.hasHighlightedRenderCache(i,t)&&(this.renderCache={file:i,highlighted:!0,renderRange:void 0,...r},n=!1),this.renderCache??={file:i,highlighted:!1,options:t,result:void 0,renderRange:void 0};const s=this.getOrCreateLineCache(i),o=i.contents.length>0,a=!o||Y(i)||K(s.length,this.getTokenizeMaxLength()),l=!R(i,this.renderCache.file),d=!me(this.renderCache.renderRange,e);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(a||this.renderCache.result==null||!this.renderCache.highlighted&&(l||d))&&(this.renderCache.file=i,this.renderCache.options=t,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||d||n)&&(this.renderCache.result=this.workerManager.getPlainFileAST(i,e.startingLine,e.totalLines,s)),this.renderCache.renderRange=e),!a&&o&&(!this.renderCache.highlighted||n)&&this.workerManager.highlightFileAST(this,i);else{this.computedLang=i.lang??j(i.name);const h=this.highlighter!=null&&te(t.theme),c=this.highlighter!=null&&ie(this.computedLang),u=!a&&c;if(this.highlighter!=null&&h&&(n||a||!this.renderCache.highlighted&&u||this.renderCache.result==null)){const{result:f,options:m}=this.renderFileWithHighlighter(i,this.highlighter,a||!c);this.renderCache={file:i,options:m,highlighted:u,result:f,renderRange:void 0}}(!h||!a&&!c)&&this.asyncHighlight(i).then(({result:f,options:m})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(i,f,m,!a)})}return this.renderCache.result!=null?this.processFileResult(this.renderCache.file,e,this.renderCache.result):void 0}async asyncRender(i,e=ee){const{result:t}=await this.asyncHighlight(i);return this.processFileResult(i,e,t)}async asyncHighlight(i){const e=K(this.getOrCreateLineCache(i).length,this.getTokenizeMaxLength());this.computedLang=e?"text":i.lang??j(i.name);const t=this.highlighter!=null&&De(Be(this.getLocalHighlightTheme())),n=e||this.highlighter!=null&&ie(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(i,this.highlighter,e)}renderFileWithHighlighter(i,e,t=!1){const{options:n}=this.getRenderOptions(i);return{result:Ue(i,e,n,{forcePlainText:t}),options:n}}processFileResult(i,e,{code:t,themeStyles:n,baseThemeType:r}){const s=this.getLineCount(i),{disableFileHeader:o=!1}=this.options,a=[],l=oe(),d=Math.min(e.startingLine+e.totalLines,s);let h=0;const c=Ce(e)?_e(this.lineAnnotations):void 0;c!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:-1,lineIndex:-1,annotations:c.map(u=>k(u))})),h++);for(let u=e.startingLine;u<d;u++){const f=u+1,m=t[u];if(m==null){const C="FileRenderer.processFileResult: Line doesnt exist";throw console.error(C,{name:i.name,lineIndex:u,lineNumber:f}),new Error(C)}l.children.push(We("context",f,`${u}`)),a.push(m),h++;const g=this.lineAnnotations[f];g!=null&&(l.children.push(ne("context","annotation",1)),a.push(re({hunkIndex:0,lineIndex:f,annotations:g.map(C=>k(C))})),h++)}return l.properties.style=`grid-row: span ${h}`,{gutterAST:l.children??[],contentAST:a,preAST:this.createPreElement(s),headerAST:o?void 0:this.renderHeader(i),totalLines:s,rowCount:h,themeStyles:n,baseThemeType:r,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderHeader(i){const{headerRenderMode:e="default",stickyHeader:t=!1}=this.options;return Ge({fileOrDiff:i,mode:e,stickyHeader:t})}renderFullHTML(i){return b(this.renderFullAST(i))}renderFullAST(i,e=[]){return e.push(se({tagName:"code",children:this.renderCodeAST(i),properties:{"data-code":""}})),{...i.preAST,children:e}}renderCodeAST(i){const e=oe();return e.children=i.gutterAST,e.properties.style=`grid-row: span ${i.rowCount}`,[e,je(i.contentAST,i.rowCount)]}renderPartialHTML(i,e=!1){return e?b(se({tagName:"code",children:i,properties:{"data-code":""}})):b(i)}async initializeHighlighter(){return this.highlighter=await $e(Ke(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(i,e,t,n=!0){this.editSessionActive||this.applyHighlightResult(i,e,t,n)}applyHighlightResult(i,e,t,n=!0){if(this.renderCache==null)return;const r=!R(i,this.renderCache.file)||!this.renderCache.highlighted||!A(t,this.renderCache.options);this.renderCache={file:i,options:t,highlighted:n,result:e,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(i,e){if(this.editSessionActive)return;const t=this.workerManager?.getFileResultCache(i);if(!(t==null||!A(e,t.options)))return t}hasHighlightedRenderCache(i,e){const{renderCache:t}=this;return t?.result!=null&&t.highlighted&&R(i,t.file)&&A(e,t.options)}onHighlightError(i){console.error(i)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(i){const{disableLineNumbers:e=!1,overflow:t="scroll"}=this.options;return qe({type:"file",diffIndicators:"none",disableBackground:!0,disableLineNumbers:e,overflow:t,split:!1,totalLines:i})}};function K(i,e){return i>e}function Lt(i,e){return i.lineNumber===e.lineNumber&&i.metadata===e.metadata}function fe(i){return{theme:i?.theme,disableLineNumbers:i?.disableLineNumbers,overflow:i?.overflow,themeType:i?.themeType,collapsed:i?.collapsed,disableFileHeader:i?.disableFileHeader,disableVirtualizationBuffers:i?.disableVirtualizationBuffers,stickyHeader:i?.stickyHeader,preferredHighlighter:i?.preferredHighlighter,useCSSClasses:i?.useCSSClasses,useTokenTransformer:Ye(i),tokenizeMaxLineLength:i?.tokenizeMaxLineLength,tokenizeMaxLength:i?.tokenizeMaxLength,unsafeCSS:i?.unsafeCSS,headerRenderMode:i?.renderCustomHeader!=null?"custom":"default"}}const Mt=[""];let At=-1;var ve=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++At}`;type="file";fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:H},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Tt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new Xe,this.interactionManager=new Je("file",ae(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ae(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Qe(this.appliedThemeCSS.theme,this.options.theme??H)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e==="wrap",columnVariables:this.shouldApplyColumnVariables(e)?"apply":"measure"}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e==="scroll"&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:s,lineAnnotations:o}=e;if(!this.enabled)throw new Error("File.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw new Error("File.hydrate: hydrate can only be called before the instance has rendered or hydrated");this.hydrateElements(t,n),Ht(this.pre,s,this.options.collapsed)||bt(this.headerElement,s,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:s,lineAnnotations:o}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ze(e,t);for(const n of Array.from(e.shadowRoot?.children??[])){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n,this.appliedPreAttributes=void 0;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}if("diffsHeader"in n.dataset){this.headerElement=n,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e!=null?this.fileRenderer.getOrCreateLineCache(e):Mt}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,s=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(o=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(o,t,n,r,s)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();const t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw new Error("File.render: attempting to call render after cleaned up");const t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:s,deferManagers:o=!1,lineAnnotations:a,renderRange:l}){this.editor?.__postponeBgTokenizeToNextFrame();const{collapsed:d=!1,themeType:h="system"}=this.options,c=d?void 0:l,u=this.renderRange,f=this.hasThemeChanged(),m=a!=null&&(a.length>0||this.lineAnnotations.length>0)?a!==this.lineAnnotations:!1,g=!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!d&&!n&&me(c,this.renderRange)&&!g&&!m&&!f)return this.applyCachedThemeState(h);this.renderRange=c,g&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(fe(this.options)),this.syncInteractionOptions(),a!=null&&this.setLineAnnotations(a),this.fileRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:C=!1,disableFileHeader:S=!1}=this.options;if(S&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,s),this.applyCachedThemeState(h),d){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const p=this.fileRenderer.renderFile(e,xe);p!=null&&this.applyThemeState(t,p.themeStyles,h,p.baseThemeType),p?.headerAST!=null&&this.applyHeaderToDOM(p.headerAST,t),this.injectUnsafeCSS()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}try{const p=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,m,g||f)||!this.applyPartialRender(u,c)){const v=this.fileRenderer.renderFile(e,c);if(v==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,v.themeStyles,h,v.baseThemeType),v.headerAST!=null&&this.applyHeaderToDOM(v.headerAST,t),this.applyFullRender(v,p)}this.applyBuffers(p,c),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,o||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(p){if(C)throw p;console.error(p),p instanceof Error&&this.applyErrorToDOM(p,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,"unmount");return}if(t==null)return;const r=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.file){const{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Y(e))return;const n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(r=>{console.error(r)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,r]of this.lineAnnotations.entries()){const s=`${n}-${k(r)}`;let o=this.annotationCache.get(s);if(o==null||!Lt(r,o.annotation)){o?.element.remove();const a=t(r);if(a==null)continue;o={element:et(k(r)),annotation:r},o.element.appendChild(a),this.fileContainer.appendChild(o.element),this.annotationCache.set(s,o)}e.delete(s)}for(const[n,{element:r}]of e.entries())this.annotationCache.delete(n),r.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=tt();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=it(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=nt(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){const s=e.shadowRoot??e.attachShadow({mode:"open"}),o=r??n,a=this.options.theme??H,l=typeof a=="string"?a:{...a},d=he(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===o&&this.appliedThemeCSS.scrollbarGutter===d){this.appliedThemeCSS.theme=l;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d};return}this.themeCSSStyle=rt({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:ct(t,o,d)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:t,themeType:o,baseThemeType:r,scrollbarGutter:d}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=st(this.themeCSSStyle.textContent??"",he(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&Ee()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);const n=this.code=ot({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();const s=()=>{if(n.childElementCount>=2)for(let o=0;o<2;o++){const a=n.children[o],l=r[o];a.innerHTML=b(l.children),a.style.cssText=l.properties.style}else n.innerHTML=b(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?at(t,s):s(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;const{file:n,code:r}=this,s=r!=null?this.getColumns(r):void 0;if(n==null||r==null||s==null)return!1;const o=e.startingLine,a=t.startingLine,l=e.totalLines===1/0?Number.POSITIVE_INFINITY:o+e.totalLines,d=t.totalLines===1/0?Number.POSITIVE_INFINITY:a+t.totalLines,h=Math.max(o,a),c=Math.min(l,d);if(c<=h)return!1;if(!this.trimDOMToOverlap(s.gutter,h,c)||!this.trimDOMToOverlap(s.content,h,c))throw new Error("File.applyPartialRender: failed to trim to overlap");let{length:u}=s.content.children;const f=(S,p)=>{if(!(p<=0))return this.fileRenderer.renderFile(n,{startingLine:S,totalLines:p,bufferBefore:0,bufferAfter:0})},m=a<h?f(a,h-a):void 0;if(m===void 0&&a<h)return!1;const g=d===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.max(0,d-c),C=d>c?f(c,g):void 0;return C===void 0&&d>c?!1:(this.cleanupErrorWrapper(),m!=null&&(s.gutter.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.gutterAST)),s.content.insertAdjacentHTML("afterbegin",this.fileRenderer.renderPartialHTML(m.contentAST)),u+=m.rowCount),C!=null&&(s.gutter.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.gutterAST)),s.content.insertAdjacentHTML("beforeend",this.fileRenderer.renderPartialHTML(C.contentAST)),u+=C.rowCount),this.lastRowCount!==u&&(s.gutter.style.setProperty("grid-row",`span ${u}`),s.content.style.setProperty("grid-row",`span ${u}`),this.lastRowCount=u),!0)}getColumns(e){const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){const r=this.getDOMBoundaryIndices(e,[t,n]),s=r.get(t)??e.children.length,o=r.get(n)??e.children.length;if(s>o)return!1;for(let a=e.children.length-1;a>=o;a-=1)e.children[a]?.remove();for(let a=s-1;a>=0;a-=1)e.children[a]?.remove();return!0}getDOMBoundaryIndices(e,t){const n=[...new Set(t)].sort((l,d)=>l-d),r=new Map;if(n.length===0)return r;let s=0,o=n[s];const{children:a}=e;o===0&&(r.set(0,0),s+=1,o=n[s]);for(let l=0;l<a.length;l+=1){const d=a[l];if(!(d instanceof HTMLElement))continue;const h=this.getLineIndexFromDOMNode(d);if(h!=null){for(;o!=null&&h>=o;)r.set(o,l),s+=1,o=n[s];if(s>=n.length)break}}for(const l of n)r.has(l)||r.set(l,a.length);return r}getLineIndexFromDOMNode(e){const t=e.dataset.lineIndex;if(t==null)return;const n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){const{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const r=this.cachedHeaderHTML??b(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){const d=document.createElement("div");d.innerHTML=r;const h=d.firstElementChild;if(!(h instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(h,this.headerElement):t.shadowRoot?.prepend(h),this.headerElement=h,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;const{renderHeaderPrefix:s,renderHeaderFilenameSuffix:o,renderCustomHeader:a,renderHeaderMetadata:l}=this.options;if(a!=null){const d=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,ge,d),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{const d=s?.(n)??void 0,h=o?.(n)??void 0,c=l?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Fe,d),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,ke,h),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ze,c),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}const s=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,r),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}getOrCreateFileContainerNode(e,t){const{fileContainer:n}=this,r=e??n??document.createElement("diffs-container"),s=n!==r;return n!=null&&s&&this.editor?.__captureFocusForDOMReplacement(),s&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:le(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):le(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=ht;const r=n.firstChild;r instanceof SVGElement&&(this.spriteSVG=r)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(const t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute("data-code")){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){const{overflow:n="scroll",disableLineNumbers:r=!1}=this.options,s={type:"file",split:!1,overflow:n,disableLineNumbers:r,diffIndicators:"none",disableBackground:!0,totalLines:t};lt(s,this.appliedPreAttributes)||(dt(e,s),this.appliedPreAttributes=s)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const r=document.createElement("div");r.dataset.errorMessage="",r.innerText=e.message,this.errorWrapper.appendChild(r);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Ht(i,e,t=!1){return!t&&i==null&&e!=null}function bt(i,e,t=!1){return i==null&&e!=null&&!t}const wt=5e3;let xt=-1;function Et(i,e){return(i.overflow??"scroll")!==(e.overflow??"scroll")||(i.collapsed??!1)!==(e.collapsed??!1)||(i.disableLineNumbers??!1)!==(e.disableLineNumbers??!1)||(i.disableFileHeader??!1)!==(e.disableFileHeader??!1)||i.unsafeCSS!==e.unsafeCSS}var Ft=class extends ve{virtualizer;metrics;__id=`virtualized-file:${++xt}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(i,e,t=Ie,n,r=!1){super(i,n,r),this.virtualizer=e,this.metrics=t}setMetrics(i,e=!1){const t=ut(i);!e&&ft(this.metrics,t)||(this.metrics=t,this.resetLayoutCache())}setLineAnnotations(i){this.syncLineAnnotations(i)&&this.resetLayoutCache()}syncLineAnnotations(i){return i==null||i===this.lineAnnotations||i.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(i),!0)}hasLineAnnotations(){return this.lineAnnotations.some(i=>i.lineNumber>0)}getLineHeight(i,e=!1){const t=this.cache.heights.get(i);if(t!=null)return t;const n=e?2:1;return this.metrics.lineHeight*n}setOptions(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(i==null)return;const{options:e}=this,t=!Se(e,i),n=Et(e,i);super.setOptions(i),n&&this.resetLayoutCache(!0),t&&(this.forceRenderOverride=!0),t&&this.virtualizer.instanceChanged(this,n)}setThemeType(i){if(this.isAdvancedMode())throw new Error("VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(i)}resetLayoutCache(i=!1,e=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&e&&(this.renderRange=void 0),i&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let i=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(i=!0),this.height=0,i;const{overflow:e="scroll"}=this.options;if(this.top=this.getVirtualizedTop(),e==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return i;const t=this.code.children[1];if(!(t instanceof HTMLElement))return i;const n=de(this.lineAnnotations);if(this.renderRange!=null&&n&&Ce(this.renderRange)){const r=kt(t)??0;r!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=r,i=!0)}else!n&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,i=!0);for(const r of t.children){if(!(r instanceof HTMLElement))continue;const s=r.dataset.lineIndex;if(s==null)continue;const o=Number(s);let a=r.getBoundingClientRect().height,l=!1;r.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in r.nextElementSibling.dataset||"noNewline"in r.nextElementSibling.dataset)&&("noNewline"in r.nextElementSibling.dataset&&(l=!0),a+=r.nextElementSibling.getBoundingClientRect().height);const d=this.getLineHeight(o,l);a!==d&&(i=!0,a===this.metrics.lineHeight*(l?2:1)?this.cache.heights.delete(o):this.cache.heights.set(o,a))}return(i||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),i}onRender=i=>this.fileContainer==null||this.file==null?!1:(i&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(i,e,t,n){const r=this.syncLineAnnotations(n),s=!R(this.file,i)||this.fileRenderer.hasUnkeyedFileContentsChanged(i);let o=t?.resetFileLayoutCache===!0||s||r;t?.metrics!=null&&(this.metrics=t.metrics,o=!0);const{collapsed:a=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,o=!0),o&&this.resetLayoutCache(),this.file!==i&&(this.layoutDirty=!0),this.file=i,this.top=e,this.computeApproximateSize(),this.height}getLinePosition(i){if(this.file==null||i<1)return;const{disableFileHeader:e=!1,collapsed:t=!1}=this.options,n=this.fileRenderer.getLineCount(this.file)-1;let r=V(this.metrics,e);if(t||n<0)return{top:r,height:0};const s=Math.min(Math.max(i-1,0),n),{overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics;if(r+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())return{top:r+s*a,height:a};const l=this.getLayoutCheckpointBeforeLineIndex(s);r=l?.top??r;for(let d=l?.lineIndex??0;d<s;d++)r+=this.getLineHeight(d,!1);return{top:r,height:this.getLineHeight(s,!1)}}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(i){if(this.file==null||this.renderRange==null)return;const{disableFileHeader:e=!1,collapsed:t=!1,overflow:n="scroll"}=this.options;if(t||this.renderRange.totalLines<=0)return;const r=this.fileRenderer.getLineCount(this.file)-1;if(r<0)return;const s=V(this.metrics,e),o=Math.min(this.renderRange.startingLine,r),a=Math.min(o+this.renderRange.totalLines-1,r);if(a<o)return;const{fileAnnotationHeight:l}=this.cache;if(n==="scroll"&&!this.hasLineAnnotations()){const{lineHeight:h}=this.metrics,c=s+(o===0?l:this.renderRange.bufferBefore),u=o+Math.max(Math.ceil((i-c)/h),0);return u>a?void 0:{lineNumber:u+1,top:s+l+u*h}}let d=s+(o===0?l:this.renderRange.bufferBefore);for(let h=o;h<=a;h++){if(d>=i)return{lineNumber:h+1,top:d};d+=this.getLineHeight(h)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(i){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const e=i!=null?this.computeRenderRangeFromWindow(this.file,this.top,i):this.renderRange;if(e==null)return;const{bufferBefore:t,bufferAfter:n,totalLines:r}=e;let s=0;if(r===0){const o=i??this.virtualizer.getWindowSpecs();this.top<o.top&&(s=n)}return{topOffset:this.top+t+s,height:this.height-(t+n)}}cleanUp(i=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),i||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(i)}computeApproximateSize(i=!1,e=this.file){const t=this.isResizeDebuggingEnabled();if(!i&&!this.layoutDirty&&!t)return;const n=this.height===0;if(this.height=0,this.cache.checkpoints=[],e==null){this.layoutDirty=!1;return}const{disableFileHeader:r=!1,collapsed:s=!1,overflow:o="scroll"}=this.options,{lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(e),d=V(this.metrics,r),h=ce(this.metrics);if(this.height+=d,s){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o==="scroll"&&!this.hasLineAnnotations())this.height+=l*a;else for(let c=0;c<l;c++)this.addLayoutCheckpoint(c,this.height),this.height+=this.getLineHeight(c,!1);if(l>0&&(this.height+=h),this.fileContainer!=null&&t&&!n){const c=this.fileContainer.getBoundingClientRect();c.height!==this.height?console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:c.height,computedHeight:this.height}):console.log("VirtualizedFile.computeApproximateSize: computed height IS CORRECT")}this.layoutDirty=!1}setVisibility(i){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,i&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!i&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(i,e,t=!1){const{renderRange:n}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(i,e),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(t&&n!==void 0&&this.file!==void 0){const r=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.file,this.top??0,r);s.bufferAfter!==n.bufferAfter&&this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:i,file:e,forceRender:t=!1,lineAnnotations:n,...r}){const s=this.file==null||!R(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),{forceRenderOverride:o,isSetup:a}=this;this.forceRenderOverride=void 0;const l=this.syncLineAnnotations(n);if(l&&this.resetLayoutCache(),i=this.getOrCreateFileContainerNode(i),e==null)return console.error("VirtualizedFile.render: attempting to virtually render when we dont have file"),!1;if(a)this.top??=this.getVirtualizedTop(),s&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,e));else{this.computeApproximateSize(!1,e);const f=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(f==null)throw new Error("VirtualizedFile.render: simple virtualizer is not available");f.connect(i,this),this.isVisible=f.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!s||!a))return this.file=e,s&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);const d=this.virtualizer.getWindowSpecs(),h=this.top??0,c=this.computeRenderRangeFromWindow(e,h,d),u=super.renderPreparedFile({file:e,fileContainer:i,renderRange:c,lineAnnotations:n,forceRender:(o??t)||l||s,...r});return this.isSimpleMode()&&u&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),u}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}addLayoutCheckpoint(i,e){i%wt===0&&this.cache.checkpoints.push({lineIndex:i,top:e})}getLayoutCheckpointBeforeLineIndex(i){if(i<=0||this.cache.checkpoints.length===0)return;let e=0,t=this.cache.checkpoints.length-1,n;for(;e<=t;){const r=e+t>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFile: invalid checkpoint index");s.lineIndex<=i?(n=s,e=r+1):t=r-1}return n}getLayoutCheckpointBeforeTop(i,e){let t=0,n=this.cache.checkpoints.length-1,r=-1;for(;t<=n;){const s=t+n>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");o.top<=i?(r=s,t=s+1):n=s-1}if(e==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFile: invalid checkpoint index");if(o.lineIndex%e===0)return o}}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(i,e,{top:t,bottom:n}){const{disableFileHeader:r=!1,overflow:s="scroll"}=this.options,{hunkLineCount:o,lineHeight:a}=this.metrics,l=this.fileRenderer.getLineCount(i),d=this.height,h=V(this.metrics,r),c=l>0?ce(this.metrics):0,{fileAnnotationHeight:u}=this.cache,f=h+u,m=Math.max(0,d-h-u-c),g=de(this.lineAnnotations),C=e+h,S=u>0&&g&&C<n&&C+u>t;if(e<t-d||e>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};if(l<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};const p=Math.ceil(Math.max(n-t,0)/a),v=Math.ceil(p/o)*o+o,z=v/o,B=(t+n)/2;if(s==="scroll"&&!this.hasLineAnnotations()){const M=e+f,N=M+m;if(!S&&!(M<n&&N>t))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};const x=Math.floor(S&&B<e+f?0:(B-(e+f))/a),L=Math.floor(x/o)-Math.floor(z/2),He=Math.ceil(l/o),E=Math.max(0,Math.min(L,He))*o,Z=L<0?v+L*o:v,be=E===0?0:u+E*a,we=Math.min(Z,l-E);return{startingLine:E,totalLines:Z,bufferBefore:be,bufferAfter:Math.max(0,(l-E-we)*a)}}const ye=z,I=[],U=this.getLayoutCheckpointBeforeTop(Math.max(0,t-e-v*a*2),o);let T=e+(U?.top??f),_=U?.lineIndex??0,O,P,w;const Re=U?.lineIndex??0;for(let M=Re;M<l;M++){const N=_%o===0,x=Math.floor(_/o);if(N&&(I[x]=T-(e+f),w!=null)){if(w<=0)break;w--}const L=this.getLineHeight(M,!1);T>t-L&&T<n&&(O??=x),T+L>B&&(P??=x),w==null&&T>=n&&N&&(w=ye),_++,T+=L}if(O==null)if(S)O=0,P=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-h-c};P??=O;const W=Math.round(P-z/2),Te=Math.max(0,Math.ceil(l/o)-z),G=Math.max(0,Math.min(W,Te)),X=G*o,J=W<0?v+W*o:v,Le=I[G]??0,Me=X===0?0:u+Le,Q=G+J/o,Ae=Q<I.length?m-I[Q]:m-(T-e-f);return{startingLine:X,totalLines:J,bufferBefore:Me,bufferAfter:Math.max(0,Ae)}}};function kt(i){let e;for(const t of i.children)t instanceof HTMLElement&&t.dataset.lineAnnotation===pt&&(e=Math.max(e??0,t.getBoundingClientRect().height));return e}const pe=typeof window>"u"?F.useEffect:F.useLayoutEffect;function zt({file:i,options:e,editorOptions:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:s,metrics:o,hasGutterRenderUtility:a,hasCustomHeader:l,disableWorkerPool:d,edit:h}){const c=gt(),u=r!==void 0,f=F.useContext(mt),m=St(),g=F.useRef(null),C=vt(S=>{if(S!=null){if(g.current!=null)throw new Error("File: An instance should not already exist when a node is created");c!=null?g.current=new Ft(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),c,o,d?void 0:f,!0):g.current=new ve(q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),d?void 0:f,!0),g.current.hydrate({file:i,fileContainer:S,lineAnnotations:n,prerenderedHTML:s})}else{if(g.current==null)throw new Error("File: A File instance should exist when unmounting");g.current.cleanUp(),g.current=null}});return pe(()=>{if(g.current==null)return;const S=q({controlledSelection:u,hasCustomHeader:l,hasGutterRenderUtility:a,options:e}),p=S!==void 0&&!Se(g.current.options,S);g.current.setOptions(S),g.current.render({file:i,lineAnnotations:n,forceRender:p}),r!==void 0&&g.current.setSelectedLines(r)}),pe(()=>{if(h&&g.current!=null){if(m===void 0)throw new Error("File: EditContext is not attached");const S=m(t??{});if(S==null)throw new Error("File: EditProvider.createEditor must return an editor instance");try{return S.edit(g.current)}catch(p){throw S.cleanUp(),p}}},[h]),{ref:C,getHoveredLine:F.useCallback(()=>g.current?.getHoveredLine(),[])}}function q({options:i,controlledSelection:e,hasCustomHeader:t,hasGutterRenderUtility:n}){return e||n||t?{...i,controlledSelection:e,renderCustomHeader:t?ue:i?.renderCustomHeader,renderGutterUtility:n?ue:i?.renderGutterUtility}:i}function Bt({file:i,lineAnnotations:e,selectedLines:t,options:n,editorOptions:r,metrics:s,className:o,style:a,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,prerenderedHTML:f,renderGutterUtility:m,disableWorkerPool:g=!1,edit:C=!1}){const{ref:S,getHoveredLine:p}=zt({file:i,options:n,editorOptions:r,metrics:s,lineAnnotations:e,selectedLines:t,prerenderedHTML:f,hasGutterRenderUtility:m!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:C});return y.jsx(Oe,{ref:S,className:o,style:a,children:Ct(yt({file:i,renderAnnotation:l,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderFilenameSuffix:c,renderHeaderMetadata:u,renderGutterUtility:m,lineAnnotations:e,getHoveredLine:p}),f)})}export{Bt as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as a,a as Ht}from"./react-rd22PHbN.js";import{a as dt}from"./tanstack-BysN2Oew.js";import{W as Q,D as Vt,v as Bt,w as Yt,x as Xt,aC as Me,aD as Le,aE as ut,aF as Wt,f as nt,aG as Ue,P as ye,aH as st,aI as $e,L as _e,ad as at,I as qt,U as ht,af as Ae,r as ft,K as mt,ax as Gt,X as Qt,Y as it,_ as Zt,aJ as Jt,aK as en,V as tn,aL as nn,aM as sn,aN as an,aO as on,aP as X,g as ln,a0 as rn,aQ as cn,aR as ot,aS as dn,a1 as un,aT as He,aU as hn,aV as fn,aW as mn,aX as xn,aY as pn,aZ as gn}from"./App-BbT5H97Z.js";import{c as re,a as Ve,B as R,I as be}from"./index-B3QJsvjR.js";import{m as jn,n as bn,M as yn,o as vn,p as Cn,q as kn,S as Nn}from"./base-ui-DIP2rZxz.js";import{a as lt,I as Be}from"./IconFolderSymlink-D29EhQPC.js";import{I as xt}from"./IconEdit-B8LZHB8l.js";const wn=[["path",{d:"M9 14l-4 -4l4 -4",key:"svg-0"}],["path",{d:"M5 10h11a4 4 0 1 1 0 8h-1",key:"svg-1"}]],pt=re("outline","arrow-back-up","ArrowBackUp",wn);const Dn=[["path",{d:"M15 14l4 -4l-4 -4",key:"svg-0"}],["path",{d:"M19 10h-11a4 4 0 1 0 0 8h1",key:"svg-1"}]],gt=re("outline","arrow-forward-up","ArrowForwardUp",Dn);const Sn=[["path",{d:"M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2",key:"svg-0"}],["path",{d:"M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2",key:"svg-1"}]],Re=re("outline","clipboard","Clipboard",Sn);const Mn=[["path",{d:"M3 4a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-16",key:"svg-0"}],["path",{d:"M12 3v18",key:"svg-1"}]],jt=re("outline","columns-2","Columns2",Mn);const Rn=[["path",{d:"M4 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-0"}],["path",{d:"M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M9.15 14.85l8.85 -10.85",key:"svg-2"}],["path",{d:"M6 4l8.85 10.85",key:"svg-3"}]],Oe=re("outline","cut","Cut",Rn);const En=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M12 11l0 6",key:"svg-2"}],["path",{d:"M9 14l6 0",key:"svg-3"}]],Ee=re("outline","file-plus","FilePlus",En),In=jn,Fn=bn;function Pn({className:t,children:i,...f}){return e.jsx(yn,{children:e.jsx(vn,{className:"isolate z-50 outline-none",children:e.jsx(Cn,{"data-slot":"context-menu-content",className:Ve("min-w-44 origin-(--transform-origin) rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...f,children:i})})})}function z({className:t,...i}){return e.jsx(kn,{"data-slot":"context-menu-item",className:Ve("flex h-8 cursor-default items-center gap-2 rounded-md px-2 text-xs outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",t),...i})}function je({className:t,...i}){return e.jsx(Nn,{"data-slot":"context-menu-separator",className:Ve("mx-1 my-1 h-px bg-border",t),...i})}function bt({state:t,onClose:i,onRename:f,onCreate:g}){const[p,o]=a.useState("");if(a.useEffect(()=>{t&&o(t.mode==="rename"?t.entry.name:"")},[t]),!t)return null;const h=t.mode==="rename",d=t.mode==="new-folder"?"directory":"file",M=t.entry.type==="directory"?t.entry.path:Q(t.entry.path),D=h?"Rename":d==="directory"?"New Folder":"New File",k=p.trim(),T=k.length>0&&!/[\\/]/.test(k)&&!(h&&k===t.entry.name),P=()=>{T&&(h?f(t.entry,k):g(M,k,d),i())};return e.jsx(Vt,{open:!0,onOpenChange:y=>{y||i()},children:e.jsx(Bt,{className:"name-dialog",children:e.jsxs("form",{className:"name-dialog-content",onSubmit:y=>{y.preventDefault(),P()},children:[e.jsx(Yt,{children:D}),e.jsx(Xt,{children:h?e.jsxs(e.Fragment,{children:["Enter a new name for ",e.jsx("code",{children:t.entry.name}),"."]}):e.jsxs(e.Fragment,{children:["Create a new ",d==="directory"?"folder":"file"," in ",e.jsx("code",{children:M||"the repository root"}),"."]})}),e.jsx("input",{autoFocus:!0,className:"name-dialog-input",value:p,maxLength:255,placeholder:h?"New name":d==="directory"?"Folder name":"File name",onChange:y=>o(y.target.value),onFocus:y=>{if(!h)return;const w=t.entry.name.lastIndexOf(".");y.target.setSelectionRange(0,w>0?w:t.entry.name.length)}}),e.jsxs("div",{className:"name-dialog-actions",children:[e.jsx(R,{type:"button",variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(R,{type:"submit",disabled:!T,children:h?"Rename":"Create"})]})]})})})}function yt(t,i,f,g=!0){const[p,o]=a.useState(null);a.useEffect(()=>{if(!g)return;let d=!1;return f(t).then(M=>{d||o({path:t,revision:i,entries:M,failed:!1})},()=>{d||o({path:t,revision:i,entries:[],failed:!0})}),()=>{d=!0}},[t,i,f,g]);const h=g&&p?.path===t;return{entries:h?p.entries:null,failed:h&&p.failed,refreshing:!h||p.revision!==i}}function zn({entries:t,initialDirectory:i,revision:f,readOnly:g,onLoadDirectory:p,onMove:o,onClose:h}){const[d,M]=a.useState(i),[D,k]=a.useState(!1),{entries:T,failed:P,refreshing:y}=yt(d,f,p),w=t.map(j=>j.path),L=T?.filter(j=>j.type==="directory"&&!w.some(te=>Me(te,j.path)))??[],O=!g&&!D&&!y&&T!==null&&!P&&Le(w,d),W=async()=>{if(O){k(!0);try{await o(t,d),h()}finally{k(!1)}}};return e.jsxs(ut,{open:!0,onOpenChange:j=>{!j&&!D&&h()},title:"Move to…",description:`${t.length} selected ${t.length===1?"item":"items"}. Choose a destination folder.`,children:[e.jsxs("div",{className:"mobile-folder-location",children:[d&&e.jsx(R,{variant:"ghost",size:"icon","aria-label":"Parent folder",disabled:D,onClick:()=>M(Q(d)),children:e.jsx(Wt,{})}),e.jsx("span",{children:d||"Repository root"})]}),e.jsx("div",{className:"mobile-destination-list",children:T===null?e.jsxs("p",{className:"mobile-list-message",role:"status",children:[e.jsx(nt,{className:"animate-spin"})," Loading folders…"]}):P?e.jsx("p",{className:"mobile-list-message",role:"alert",children:"Could not read this folder."}):L.length===0?e.jsx("p",{className:"mobile-list-message",children:"No subfolders. You can choose this folder below."}):L.map(j=>e.jsxs("button",{className:"mobile-sheet-action",disabled:D,onClick:()=>M(j.path),children:[e.jsx("img",{src:Ue(j.path,!1),alt:"","aria-hidden":"true",draggable:!1}),e.jsx("span",{children:j.name}),e.jsx(ye,{})]},j.path))}),e.jsxs("div",{className:"mobile-sheet-footer",children:[e.jsx(R,{variant:"ghost",disabled:D,onClick:h,children:"Cancel"}),e.jsxs(R,{disabled:!O,onClick:()=>{W()},children:[D&&e.jsx(nt,{className:"animate-spin"})," Move here"]})]})]})}const Tn=56;function Ln(t){const[i,f]=a.useState(()=>Q(t.activePath??"")),[g,p]=a.useState(""),[o,h]=a.useState(!1),[d,M]=a.useState(new Map),[D,k]=a.useState(null),[T,P]=a.useState(null),[y,w]=a.useState(null),L=a.useRef(null),O=a.useRef(new Map),W=a.useRef(t.activePath),{entries:j,failed:te}=yt(i,t.filesSnapshotRevision,t.onLoadDirectory,t.active),K=a.useMemo(()=>(j??[]).filter(u=>(t.showDotEnvFiles||!u.ignored)&&u.name.toLocaleLowerCase().includes(g.toLocaleLowerCase())),[j,t.showDotEnvFiles,g]),ne=dt({count:K.length,enabled:t.active&&j!==null,getScrollElement:()=>L.current,estimateSize:()=>Tn,getItemKey:u=>K[u].path,overscan:8,paddingEnd:12});a.useEffect(()=>{t.activePath!==W.current&&(W.current=t.activePath,t.activePath&&(f(Q(t.activePath)),p("")))},[t.activePath]),a.useEffect(()=>{if(!j)return;const u=new Set(j.map(x=>x.path));M(x=>{const b=new Map([...x].filter(([U])=>u.has(U)));return b.size===x.size?x:b})},[j]),a.useEffect(()=>{j&&L.current&&(L.current.scrollTop=O.current.get(i)??0)},[i,j]),a.useEffect(()=>{if(!t.files||!i||st(t.files,i)!=="missing")return;let u=Q(i);for(;u&&st(t.files,u)==="missing";)u=Q(u);f(u),p(""),M(new Map)},[t.files,i]);const q=u=>{f(u),p(""),M(new Map)},ce=u=>M(x=>{const b=new Map(x);return b.has(u.path)?b.delete(u.path):b.set(u.path,u),b}),se={type:"directory",path:i,name:i.split("/").pop()??"",children:[]},G=[...d.values()],v=D&&D!=="tools"?D:null,C=u=>{k(null),u()};return e.jsxs("div",{className:"mobile-files-view",children:[e.jsxs("div",{className:"mobile-view-heading",children:[e.jsxs("h2",{children:[o?"Select items":"Files",o&&e.jsx("small",{children:d.size})]}),e.jsxs("div",{children:[e.jsx(R,{variant:"ghost",size:"sm","aria-pressed":o,onClick:()=>{h(!o),M(new Map)},children:o?"Cancel":"Select"}),e.jsx(R,{variant:"ghost",size:"icon","aria-label":"File browser actions",onClick:()=>k("tools"),children:e.jsx($e,{})})]})]}),e.jsxs("label",{className:"mobile-file-filter",children:[e.jsx(_e,{"aria-hidden":"true"}),e.jsx("input",{type:"search",value:g,placeholder:"Filter this folder…","aria-label":"Filter this folder",onChange:u=>{p(u.target.value),O.current.set(i,0),L.current?.scrollTo({top:0})}})]}),e.jsxs("nav",{className:"mobile-file-breadcrumb","aria-label":"Folder location",children:[e.jsxs("button",{onClick:()=>q(""),"aria-current":i===""?"location":void 0,children:[e.jsx(at,{"aria-hidden":"true"})," Root"]}),i.split("/").filter(Boolean).map((u,x,b)=>{const U=b.slice(0,x+1).join("/");return e.jsxs("span",{children:[e.jsx(ye,{"aria-hidden":"true"}),e.jsx("button",{"aria-current":U===i?"location":void 0,onClick:()=>q(U),children:u})]},U)})]}),e.jsx("div",{className:"mobile-files-scroll",ref:L,onScroll:u=>O.current.set(i,u.currentTarget.scrollTop),children:j===null?e.jsx("p",{className:"mobile-list-message",role:"status",children:"Loading files…"}):te?e.jsx("p",{className:"mobile-list-message",role:"alert",children:"Could not read this folder."}):K.length===0?e.jsx("p",{className:"mobile-list-message",children:g?"No matching files in this folder.":"This folder is empty."}):e.jsx("div",{className:"virtual-list",role:"list","aria-label":"Files in this folder",style:{height:ne.getTotalSize()},children:ne.getVirtualItems().map(u=>{const x=K[u.index],b=d.has(x.path);return e.jsxs("div",{role:"listitem",className:`mobile-file-row ${b?"selected":""}`,style:{height:u.size,transform:`translateY(${u.start}px)`},children:[e.jsxs("button",{className:"mobile-file-open","aria-pressed":o?b:void 0,"aria-current":t.activePath===x.path?"true":void 0,onClick:()=>o?ce(x):x.type==="directory"?q(x.path):t.onOpenFile(x.path),children:[o?e.jsx("span",{className:`mobile-file-check ${b?"checked":""}`,children:b&&e.jsx(qt,{"aria-hidden":"true"})}):e.jsx("img",{src:x.type==="directory"?Ue(x.path,!1):ht(x.path),alt:"","aria-hidden":"true",draggable:!1}),e.jsxs("span",{className:"mobile-file-copy",children:[e.jsx("strong",{children:x.name}),e.jsx("small",{children:x.type==="directory"?x.ignored?"Ignored folder":"Folder":`${x.ignored?"Ignored · ":""}${Math.max(1,Math.ceil(x.size/1024))} KB`})]}),!o&&x.type==="directory"&&e.jsx(ye,{"aria-hidden":"true"})]}),!o&&e.jsx(R,{variant:"ghost",size:"icon",className:"mobile-file-menu","aria-label":`Actions for ${x.name}`,onClick:()=>k(x),children:e.jsx($e,{})})]},x.path)})})}),o&&e.jsxs("div",{className:"mobile-file-selection-actions",children:[e.jsxs(R,{variant:"ghost",size:"sm",disabled:t.readOnly||d.size===0,onClick:()=>w(G),children:[e.jsx(lt,{})," Move to…"]}),e.jsxs(R,{variant:"ghost",size:"sm",disabled:d.size===0,onClick:()=>{t.fileClipboardAvailable?t.onCopyEntries(G):t.onCopyPath(G)},children:[e.jsx(be,{})," ",t.fileClipboardAvailable?"Copy":"Copy paths"]}),t.fileClipboardAvailable&&e.jsx(R,{variant:"ghost",size:"icon","aria-label":"Cut selected items",disabled:t.readOnly||d.size===0,onClick:()=>{t.onCutEntries(G)},children:e.jsx(Oe,{})}),e.jsx(R,{variant:"ghost",size:"icon","aria-label":"Delete selected items",disabled:t.readOnly||d.size===0,onClick:()=>{t.onDeleteEntries(G)},children:e.jsx(Ae,{})})]}),e.jsx(ut,{open:D!==null,onOpenChange:u=>{u||k(null)},title:v?.name??"File browser actions",description:v?.path??"Actions for the current folder.",children:v?e.jsxs(e.Fragment,{children:[v.type==="file"&&e.jsxs("button",{className:"mobile-sheet-action",onClick:()=>C(()=>t.onOpenFile(v.path,"pinned")),children:[e.jsx(Ee,{}),e.jsx("span",{children:"Keep file open"})]}),v.type==="directory"&&e.jsxs("button",{className:"mobile-sheet-action",onClick:()=>C(()=>q(v.path)),children:[e.jsx(at,{}),e.jsx("span",{children:"Open folder"})]}),e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly,onClick:()=>C(()=>w([v])),children:[e.jsx(lt,{}),e.jsx("span",{children:"Move to…"})]}),e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly,onClick:()=>C(()=>P({mode:"rename",entry:v})),children:[e.jsx(xt,{}),e.jsx("span",{children:"Rename"})]}),t.fileClipboardAvailable&&e.jsxs("button",{className:"mobile-sheet-action",onClick:()=>C(()=>{t.onCopyEntries([v])}),children:[e.jsx(be,{}),e.jsx("span",{children:"Copy"})]}),t.fileClipboardAvailable&&e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly,onClick:()=>C(()=>{t.onCutEntries([v])}),children:[e.jsx(Oe,{}),e.jsx("span",{children:"Cut"})]}),e.jsxs("button",{className:"mobile-sheet-action",onClick:()=>C(()=>{t.onCopyPath([v])}),children:[e.jsx(be,{}),e.jsx("span",{children:"Copy path"})]}),v.type==="file"&&e.jsxs("button",{className:"mobile-sheet-action",onClick:()=>C(()=>{t.onCopyContents(v)}),children:[e.jsx(be,{}),e.jsx("span",{children:"Copy contents"})]}),t.revealAvailable&&e.jsxs("button",{className:"mobile-sheet-action",onClick:()=>C(()=>{t.onReveal(v)}),children:[e.jsx(ft,{}),e.jsx("span",{children:"Reveal in file manager"})]}),t.fileClipboardAvailable&&e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly,onClick:()=>C(()=>{t.onPaste(v.type==="directory"?v.path:Q(v.path))}),children:[e.jsx(Re,{}),e.jsx("span",{children:"Paste here"})]}),e.jsxs("button",{className:"mobile-sheet-action destructive",disabled:t.readOnly,onClick:()=>C(()=>{t.onDeleteEntries([v])}),children:[e.jsx(Ae,{}),e.jsx("span",{children:"Delete"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"mobile-sheet-action",onClick:()=>C(t.onQuickOpen),children:[e.jsx(_e,{}),e.jsx("span",{children:"Find file in repository"})]}),e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly,onClick:()=>C(()=>P({mode:"new-file",entry:se})),children:[e.jsx(Ee,{}),e.jsx("span",{children:"New file"})]}),e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly,onClick:()=>C(()=>P({mode:"new-folder",entry:se})),children:[e.jsx(Be,{}),e.jsx("span",{children:"New folder"})]}),t.fileClipboardAvailable&&e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly,onClick:()=>C(()=>{t.onPaste(i)}),children:[e.jsx(Re,{}),e.jsx("span",{children:"Paste here"})]}),e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly||!t.historyState.canUndo,onClick:()=>C(()=>{t.onUndo()}),children:[e.jsx(pt,{}),e.jsx("span",{children:t.historyState.undoLabel?`Undo ${t.historyState.undoLabel}`:"Undo"})]}),e.jsxs("button",{className:"mobile-sheet-action",disabled:t.readOnly||!t.historyState.canRedo,onClick:()=>C(()=>{t.onRedo()}),children:[e.jsx(gt,{}),e.jsx("span",{children:t.historyState.redoLabel?`Redo ${t.historyState.redoLabel}`:"Redo"})]})]})}),e.jsx(bt,{state:T,onClose:()=>P(null),onRename:t.onRename,onCreate:t.onCreate}),y&&e.jsx(zn,{entries:y,initialDirectory:i,revision:t.filesSnapshotRevision,readOnly:t.readOnly,onLoadDirectory:t.onLoadDirectory,onMove:t.onMoveEntries,onClose:()=>{w(null),M(new Map)}})]})}function es(t){return mt()?e.jsx(Ln,{...t}):e.jsx(Un,{...t})}const $n=29,Se=6,vt="files-tree-root-drop",_n=550,An={duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},rt=6,On=t=>{const i=dn(t),f=i.length>0?i:un(t),g=f.find(p=>p.id!==vt);return g?[g]:f.slice(0,1)};function Ct(t,i,f=0){const g=[];for(const p of t)g.push({entry:p,depth:f}),p.type==="directory"&&i.has(p.path)&&g.push(...Ct(p.children,i,f+1));return g}function Kn(t,i,f){const g=t.findIndex(d=>d.entry.path===i),p=t.findIndex(d=>d.entry.path===f);if(g===-1||p===-1)return[f];const[o,h]=g<=p?[g,p]:[p,g];return t.slice(o,h+1).map(d=>d.entry.path)}function Ke(t){return t.type==="directory"?t.path:Q(t.path)}function Un({active:t,initialExpandedPaths:i,files:f,filesSnapshotRevision:g,showDotEnvFiles:p,activePath:o,readOnly:h,fileClipboardAvailable:d,revealAvailable:M,historyState:D,onQuickOpen:k,onUndo:T,onRedo:P,onOpenFile:y,onLoadDirectory:w,onPersistExpandedPaths:L,onCopyPath:O,onCopyEntries:W,onCutEntries:j,onCopyContents:te,onPaste:K,onMoveEntries:ne,onDeleteEntries:q,onReveal:ce,onRename:se,onCreate:G}){const v=Gt(),C=mt(),[u,x]=a.useState(!1),b=C?44:$n,U=a.useRef(null),ae=a.useRef(null),[S,H]=a.useState(new Set),[ve,ie]=a.useState(o),[oe,Z]=a.useState(o),[A,de]=a.useState(()=>new Set(i)),[Ce,ue]=a.useState([]),[$,J]=a.useState(null),[he,Ie]=a.useState(null),[Xe,kt]=a.useState(null),[Nt,wt]=a.useState(!1),[Dt,ee]=a.useState(null),[ke,St]=a.useState(0),[V,Ne]=a.useState(new Map),Mt=Qt(it(Jt,{activationConstraint:{distance:5}}),it(Zt)),We=a.useRef(V),fe=a.useRef(new Set),qe=a.useRef(0),B=a.useRef(null),me=a.useRef(null),Ge=a.useRef(i.join("\0")),we=a.useMemo(()=>new Set(V.keys()),[V]),Y=a.useMemo(()=>f===null?null:en(f,V),[f,V]),N=a.useMemo(()=>Y===null?null:p?Y:tn(Y),[Y,p]);a.useEffect(()=>{We.current=V},[V]),a.useEffect(()=>{kt(document.getElementById(nn))},[o]),a.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>wt(n.matches);return s(),n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),a.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]),a.useEffect(()=>{const n=++qe.current,s=[...We.current.keys()];s.length!==0&&Promise.all(s.map(async l=>({path:l,children:await w(l)}))).then(l=>{if(n!==qe.current)return;const r=new Map(l.map(({path:m,children:c})=>[m,c]));Ne(m=>sn(m,r))})},[g,w]),a.useEffect(()=>{if(!Y){fe.current.clear(),Ne(n=>n.size===0?n:new Map);return}de(n=>{const s=new Set(an(Y,n,we).retained);return ct(n,s)?n:s})},[we,Y]),a.useEffect(()=>{if(!Y)return;const n=on(Y,A,we),s=n.join("\0");s!==Ge.current&&(Ge.current=s,L(n))},[A,we,Y,L]),a.useEffect(()=>{if(!t||!N)return;let n=Math.max(0,2-fe.current.size);for(const s of A){if(n===0)break;const l=X(N,s);!l||l.type!=="directory"||l.ignored!==!0||l.children.length>0||V.has(s)||fe.current.has(s)||(fe.current.add(s),n-=1,w(s).catch(()=>[]).then(r=>{Ne(m=>new Map(m).set(s,r))}).finally(()=>{fe.current.delete(s)}))}},[t,A,V,w,N]),a.useEffect(()=>{t||(ee(null),ue([]),J(null),Ie(null),B.current&&clearTimeout(B.current),B.current=null,me.current=null)},[t]),a.useEffect(()=>{N&&(H(n=>{if(n.size===0)return n;const s=new Set([...n].filter(l=>X(N,l)));return s.size===n.size?n:s}),ie(n=>n&&X(N,n)?n:null),Z(n=>n&&X(N,n)?n:o&&X(N,o)?o:null))},[o,N]);const E=a.useMemo(()=>N?Ct(N,A):[],[A,N]),le=dt({enabled:t,count:E.length,getScrollElement:()=>U.current,estimateSize:()=>b,getItemKey:n=>E[n]?.entry.path??n,overscan:12,paddingStart:Se,paddingEnd:12});a.useEffect(()=>{le.measure()},[le,b]),a.useEffect(()=>{!t||!o||!N||!X(N,o)||de(n=>{const s=new Set(n);let l=!1;const r=o.split("/");let m="";for(let c=0;c<r.length-1;c+=1)m=m?`${m}/${r[c]}`:r[c],s.has(m)||(s.add(m),l=!0);return l?s:n})},[t,o,N]),a.useEffect(()=>{if(!t)return;if(!o){ae.current=null;return}if(ae.current===o)return;const n=E.findIndex(s=>s.entry.path===o);n>=0&&(le.scrollToIndex(n,{align:"auto"}),ae.current=o)},[t,o,E]);const Qe=a.useMemo(()=>{const n=new Map;for(const s of E)n.set(s.entry.path,s);return n},[E]),xe=a.useMemo(()=>{const n={headers:[],push:0};if(E.length===0||!o)return n;const s=new Set,l=o.split("/");let r="";for(let F=0;F<l.length-1;F+=1)r=r?`${r}/${l[F]}`:l[F],s.add(r);if(s.size===0)return n;const m=Math.min(E.length-1,Math.max(0,Math.floor((ke-Se)/b))),c=E[m];if(!c)return n;const I=c.entry.path.split("/"),_=[];let ge="";for(let F=0;F<I.length-1;F+=1){if(ge=ge?`${ge}/${I[F]}`:I[F],!s.has(ge))continue;const Te=Qe.get(ge);Te&&Te.entry.type==="directory"&&_.push(Te)}if(_.length>rt&&_.splice(0,_.length-rt),_.length===0)return n;const Ot=_[_.length-1],et=_.length*b;let tt=1/0;const Kt=Math.ceil((ke+et-Se)/b)+2;for(let F=m;F<E.length&&F<=Kt;F+=1)if(E[F].depth<=Ot.depth){tt=Se+F*b;break}const Ut=Math.max(0,Math.min(b,et-(tt-ke)));return{headers:_,push:Ut}},[E,Qe,ke,o,b]);if(N===null)return e.jsx("div",{className:"view-loading",role:"status",hidden:!t,children:e.jsx(ln,{text:"Loading files…"})});const Rt=u||S.size>0?S:o?new Set([o]):new Set,Et=S.size>0?[...S]:o?[o]:[],Fe=n=>{const s=[];for(const l of n){const r=X(N,l);r&&s.push(r)}return s},Pe=n=>{H(new Set([n])),ie(n),Z(n)},It=n=>{const s=E.findIndex(l=>l.entry.path===n.path);s>=0&&le.scrollToIndex(s,{align:"start"})},Ft=(n,s)=>{if(C&&u){H(l=>{const r=new Set(l);return r.has(n.path)?r.delete(n.path):r.add(n.path),r});return}if(s.shift&&(ve||oe)){const l=Kn(E,ve??oe,n.path);H(new Set(l)),Z(n.path);return}if(s.ctrl){H(l=>{const r=new Set(l.size===0&&o?[o]:l);return r.has(n.path)?r.delete(n.path):r.add(n.path),r}),ie(n.path),Z(n.path),n.type==="file"&&y(n.path,"pinned");return}Pe(n.path),n.type==="file"?y(n.path):Ze(n.path)},Pt=n=>{!(C&&u)&&n.type==="file"&&y(n.path,"pinned")},zt=n=>{S.has(n.path)||Pe(n.path)},De=n=>S.has(n.path)&&S.size>0?Fe(S):[n],Tt=n=>{if(hn(n.target))return;const s=fn(n.nativeEvent,v);if(s==="undo"&&D.canUndo&&!h){n.preventDefault(),n.repeat||T();return}if(s==="redo"&&D.canRedo&&!h){n.preventDefault(),n.repeat||P();return}const l=(n.ctrlKey||n.metaKey)&&!n.altKey,r=n.key.toLowerCase();if(l&&r==="a"){n.preventDefault(),H(new Set(E.map(I=>I.entry.path)));return}const m=Fe(Et),c=oe?X(N,oe):null;if(l&&r==="c"&&m.length){n.preventDefault(),W(m);return}if(l&&r==="x"&&m.length&&!h){n.preventDefault(),j(m);return}if(l&&r==="v"&&!h&&d){n.preventDefault();const I=c?Ke(c):Q(m[0]?.path??"");K(I);return}if(n.key==="F2"&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&!n.shiftKey&&!h){if(S.size===1){const I=X(N,[...S][0]);I&&(n.preventDefault(),ee({mode:"rename",entry:I}))}return}n.key==="Delete"&&!n.ctrlKey&&!n.metaKey&&!n.altKey&&!n.shiftKey&&!h&&m.length&&(n.preventDefault(),q(m))},Lt=async(n,s)=>{const l=Fe(n);l.length&&await ne(l,s)},Ze=(n,s=!1)=>{const l=!s&&A.has(n),r=l&&X(N??[],n)?.ignored===!0;de(m=>{const c=new Set(m);if(s||!c.has(n)){if(c.has(n))return m;c.add(n)}else if(r)for(const I of c)Me(n,I)&&c.delete(I);else c.delete(n);return ct(m,c)?m:c}),l&&Ne(m=>{const c=[...m.keys()].filter(_=>Me(n,_));if(c.length===0)return m;const I=new Map(m);for(const _ of c)I.delete(_);return I})},pe=()=>{B.current&&clearTimeout(B.current),B.current=null,me.current=null},Je=()=>{pe(),ue([]),J(null),Ie(null)},ze=n=>{const s=n.active.data.current;return s?.entry&&Array.isArray(s.sourcePaths)?{entry:s.entry,sourcePaths:s.sourcePaths}:null},$t=n=>{const s=ze(n);s&&(S.has(s.entry.path)||Pe(s.entry.path),ue(s.sourcePaths),Ie({entry:s.entry,sourcePaths:s.sourcePaths,count:s.sourcePaths.length}))},_t=n=>{const s=ze(n);if(n.over?.data.current?.openPinned===!0){J(null),pe();return}const l=n.over?.data.current?.targetDirectory;if(!s||typeof l!="string"||!Le(s.sourcePaths,l)){J(null),pe();return}J(l);const r=n.over?.data.current?.expandPath;if(typeof r!="string"||A.has(r)){pe();return}me.current!==r&&(pe(),me.current=r,B.current=setTimeout(()=>{Ze(r,!0),B.current=null,me.current=null},_n))},At=n=>{const s=ze(n),l=n.over?.data.current?.openPinned===!0,r=n.over?.data.current?.targetDirectory;if(Je(),s&&l&&ot(s.entry,s.sourcePaths)){y(s.entry.path,"pinned");return}s&&typeof r=="string"&&Le(s.sourcePaths,r)&&Lt(s.sourcePaths,r)};return e.jsxs(rn,{sensors:Mt,collisionDetection:On,autoScroll:{enabled:!0,threshold:{x:.1,y:.16},acceleration:12},onDragStart:$t,onDragOver:_t,onDragCancel:Je,onDragEnd:At,children:[e.jsxs("div",{className:"files-mobile-tools",children:[e.jsxs(R,{variant:"ghost",size:"sm",onClick:k,children:[e.jsx(_e,{})," Find file"]}),e.jsx(R,{variant:"ghost",size:"sm","aria-pressed":u,onClick:()=>{x(!u),H(new Set)},children:u?`Done (${S.size})`:"Select"}),e.jsxs(R,{variant:"ghost",size:"sm",disabled:h,onClick:()=>ee({mode:"new-file",entry:{type:"directory",path:"",name:"",children:[]}}),children:[e.jsx(Ee,{})," New file"]}),e.jsxs(R,{variant:"ghost",size:"sm",disabled:h,onClick:()=>ee({mode:"new-folder",entry:{type:"directory",path:"",name:"",children:[]}}),children:[e.jsx(Be,{})," Folder"]}),d&&e.jsxs(R,{variant:"ghost",size:"sm",disabled:h,onClick:()=>{K("")},children:[e.jsx(Re,{})," Paste"]})]}),e.jsxs("div",{ref:U,className:"files-view virtual-scroll",hidden:!t,onScroll:n=>St(n.currentTarget.scrollTop),children:[xe.headers.length>0&&e.jsx("div",{className:"files-sticky",children:xe.headers.map((n,s)=>{const l=s===xe.headers.length-1;return e.jsxs("button",{type:"button",className:"file-tree-row files-sticky-row","aria-label":`Scroll to ${n.entry.path}`,style:{top:s*b-(l?xe.push:0),paddingLeft:12+n.depth*14,zIndex:xe.headers.length-s},onClick:()=>It(n.entry),children:[e.jsx(ye,{className:"folder-chevron open"}),e.jsx(Ye,{path:n.entry.path,type:"directory",expanded:!0}),e.jsx("span",{children:n.entry.name})]},n.entry.path)})}),N.length?e.jsx(Hn,{role:"tree","aria-label":"Files",className:`files-tree ${$===""&&Ce.length>0?"root-drop-target":""}`,style:{height:le.getTotalSize()},tabIndex:0,onKeyDown:Tt,onPointerDown:n=>{n.target.closest(".file-tree-row, .file-touch-actions")||(H(new Set),ie(null),Z(null),n.currentTarget.focus())},children:le.getVirtualItems().map(n=>{const{entry:s,depth:l}=E[n.index],r=s.type==="directory"&&A.has(s.path),m=S.has(s.path)&&S.size>1;return e.jsx("div",{className:"virtual-row",style:{height:n.size,transform:`translateY(${n.start}px)`},children:e.jsx(Yn,{entry:s,depth:l,expanded:r,pendingChildren:s.type==="directory"&&s.ignored===!0&&s.children.length===0&&!V.has(s.path),selected:Rt.has(s.path),active:o===s.path,multiSelected:m,readOnly:h,fileClipboardAvailable:d,revealAvailable:M,historyState:D,onUndo:T,onRedo:P,draggedPaths:Ce,dropTargetPath:$,onFocus:Z,onRowClick:Ft,onRowDoubleClick:Pt,onRowContextMenu:zt,onOpen:c=>y(c.path),onOpenPinned:c=>y(c.path,"pinned"),onCopy:c=>{W(De(c))},onCut:c=>{j(De(c))},onPasteInto:c=>{K(Ke(c))},onCopyPath:c=>{O(De(c))},onCopyContents:te,onRename:c=>ee({mode:"rename",entry:c}),onNewFile:c=>ee({mode:"new-file",entry:c}),onNewFolder:c=>ee({mode:"new-folder",entry:c}),onReveal:ce,onDelete:c=>{q(De(c))},dragPaths:S.has(s.path)&&S.size>0?[...S]:[s.path]})},n.key)})}):e.jsx("p",{className:"empty-list",children:"No files."}),e.jsx(bt,{state:Dt,onClose:()=>ee(null),onRename:se,onCreate:G})]}),e.jsx(cn,{dropAnimation:Nt?null:An,children:he&&e.jsx(Bn,{preview:he})}),Xe&&Ht.createPortal(e.jsx(Vn,{visible:!!(he&&ot(he.entry,he.sourcePaths))}),Xe)]})}function Hn(t){const{setNodeRef:i}=He({id:vt,data:{targetDirectory:"",expandPath:null}});return e.jsx("div",{ref:i,...t})}function Vn({visible:t}){const{isOver:i,setNodeRef:f}=He({id:"files-open-pinned-drop",data:{openPinned:!0}});return e.jsxs("div",{ref:f,className:`open-files-drop-target ${t?"visible":""} ${t&&i?"over":""}`,"aria-hidden":"true",children:[e.jsx(jt,{}),e.jsx("span",{children:"Drop to open beside"})]})}function Bn({preview:t}){return e.jsxs("div",{className:"file-drag-overlay",children:[e.jsx(Ye,{path:t.entry.path,type:t.entry.type,expanded:!1}),e.jsx("span",{children:t.entry.name}),t.count>1&&e.jsx("strong",{children:t.count})]})}function ct(t,i){if(t.size!==i.size)return!1;for(const f of t)if(!i.has(f))return!1;return!0}function Yn({entry:t,depth:i,expanded:f,pendingChildren:g,selected:p,active:o,multiSelected:h,readOnly:d,fileClipboardAvailable:M,revealAvailable:D,historyState:k,onUndo:T,onRedo:P,draggedPaths:y,dropTargetPath:w,onFocus:L,onRowClick:O,onRowDoubleClick:W,onRowContextMenu:j,onOpen:te,onOpenPinned:K,onCopy:ne,onCut:q,onPasteInto:ce,onCopyPath:se,onCopyContents:G,onRename:v,onNewFile:C,onNewFolder:u,onReveal:x,onDelete:b,dragPaths:U}){const ae=a.useRef(null),S=Ke(t),{attributes:H,listeners:ve,setNodeRef:ie,isDragging:oe}=mn({id:`file-drag:${t.path}`,data:{sourcePaths:U,entry:t},disabled:d}),{setNodeRef:Z}=He({id:`file-drop:${t.path}`,data:{targetDirectory:S,expandPath:t.type==="directory"?t.path:null}}),A=$=>{ae.current=$,ie($),Z($)},de=y.length>0&&t.type==="directory"&&w===t.path,Ce=y.length>0&&w!==null&&w!==""&&w!==t.path&&Me(w,t.path),ue=e.jsxs("button",{type:"button",ref:A,...H,role:"treeitem","aria-selected":p,"aria-current":o?"true":void 0,"aria-expanded":t.type==="directory"?f:void 0,className:["file-tree-row",t.ignored?"ignored-file":"",y.includes(t.path)||oe?"dragging":"",de?"drop-target":"",Ce?"drop-target-region":""].filter(Boolean).join(" "),style:{paddingLeft:12+i*14},...ve,onClick:$=>O(t,{ctrl:$.ctrlKey||$.metaKey,shift:$.shiftKey}),onDoubleClick:()=>W(t),onFocus:()=>L(t.path),onContextMenu:()=>j(t),children:[t.type==="directory"?e.jsx(ye,{className:`folder-chevron ${f?"open":""} ${t.children.length===0&&!g?"empty":""}`}):e.jsx("span",{className:"tree-spacer"}),e.jsx(Ye,{path:t.path,type:t.type,expanded:f}),e.jsx("span",{children:t.name})]});return e.jsxs(In,{children:[e.jsx(Fn,{render:ue}),e.jsx("button",{type:"button",className:"file-touch-actions","aria-label":`Actions for ${t.name}`,"aria-haspopup":"menu",onClick:$=>{$.stopPropagation();const J=$.currentTarget.getBoundingClientRect();ae.current?.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:J.left,clientY:J.bottom}))},children:e.jsx($e,{})}),e.jsxs(Pn,{children:[t.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsxs(z,{onClick:()=>te(t),children:[e.jsx(xn,{"aria-hidden":"true"})," Open"]}),e.jsxs(z,{onClick:()=>K(t),children:[e.jsx(jt,{"aria-hidden":"true"})," Open to the Side ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Click"})]}),e.jsx(je,{})]}),e.jsxs(z,{disabled:d||!k.canUndo,onClick:()=>{T()},children:[e.jsx(pt,{"aria-hidden":"true"})," ",k.undoLabel?`Undo ${k.undoLabel}`:"Undo"," ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Z"})]}),e.jsxs(z,{disabled:d||!k.canRedo,onClick:()=>{P()},children:[e.jsx(gt,{"aria-hidden":"true"})," ",k.redoLabel?`Redo ${k.redoLabel}`:"Redo"," ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+Shift+Z"})]}),e.jsx(je,{}),e.jsxs(z,{onClick:()=>ne(t),children:[e.jsx(pn,{"aria-hidden":"true"})," Copy ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+C"})]}),e.jsxs(z,{disabled:d,onClick:()=>q(t),children:[e.jsx(Oe,{"aria-hidden":"true"})," Cut ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+X"})]}),M&&e.jsxs(z,{disabled:d,onClick:()=>ce(t),children:[e.jsx(Re,{"aria-hidden":"true"})," Paste ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Ctrl+V"})]}),e.jsx(je,{}),e.jsxs(z,{disabled:d||h,onClick:()=>v(t),children:[e.jsx(xt,{"aria-hidden":"true"})," Rename ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"F2"})]}),e.jsxs(z,{disabled:d||h,onClick:()=>C(t),children:[e.jsx(Ee,{"aria-hidden":"true"})," New File…"]}),e.jsxs(z,{disabled:d||h,onClick:()=>u(t),children:[e.jsx(Be,{"aria-hidden":"true"})," New Folder…"]}),e.jsx(je,{}),e.jsxs(z,{onClick:()=>se(t),children:[e.jsx(gn,{"aria-hidden":"true"})," Copy path"]}),e.jsxs(z,{disabled:t.type!=="file"||h,onClick:()=>{G(t)},children:[e.jsx(be,{"aria-hidden":"true"})," Copy contents"]}),D&&e.jsxs(z,{disabled:h,onClick:()=>{x(t)},children:[e.jsx(ft,{"aria-hidden":"true"})," Reveal in File Explorer"]}),e.jsx(je,{}),e.jsxs(z,{className:"text-destructive data-highlighted:text-destructive",disabled:d,onClick:()=>b(t),children:[e.jsx(Ae,{"aria-hidden":"true"})," Delete ",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Del"})]})]})]})}function Ye({path:t,type:i,expanded:f=!1}){const g=i==="file"?ht(t):Ue(t,f);return e.jsx("img",{className:"vscode-tree-icon",src:g,alt:"","aria-hidden":"true"})}export{es as FilesView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o,T as x,b as g,d as j,B as m,o as C,q as N}from"./index-
|
|
1
|
+
import{c as o,T as x,b as g,d as j,B as m,o as C,q as N}from"./index-B3QJsvjR.js";import{r as v,j as e}from"./react-rd22PHbN.js";import{u as b}from"./tanstack-BysN2Oew.js";import{o as M,p as P,I as R}from"./App-BbT5H97Z.js";import{P as y,b as S,c as E,d as I,e as q}from"./base-ui-DIP2rZxz.js";const T=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]],K=o("outline","circle-check","CircleCheck",T);const _=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M10 10l4 4m0 -4l-4 4",key:"svg-1"}]],U=o("outline","circle-x","CircleX",_);const $=[["path",{d:"M12 4l-8 4l8 4l8 -4l-8 -4",key:"svg-0"}],["path",{d:"M4 12l8 4l8 -4",key:"svg-1"}],["path",{d:"M4 16l8 4l8 -4",key:"svg-2"}]],F=o("outline","stack-2","Stack2",$);const G=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0",key:"svg-1"}],["path",{d:"M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855",key:"svg-2"}]],O=o("outline","user-circle","UserCircle",G);function X({repositoryId:n,number:r,membership:c,onSelect:l}){const[d,k]=v.useState(!1),a=b({queryKey:N.pullRequestStack(n,r),queryFn:()=>C.github.getPullRequestStack(n,r),enabled:d,staleTime:0}),t=a.data,h=t?t.layers.findIndex(s=>s.number===r)+1:c.position,u=t?.layers.length??c.size,i=t?.number??c.number;return a.isSuccess&&t===null&&!d?null:e.jsxs(y,{open:d,onOpenChange:k,children:[e.jsxs(x,{children:[e.jsxs(g,{render:e.jsx(S,{render:e.jsx("button",{className:"pr-stack-trigger","aria-label":`Stack ${i}, layer ${h} of ${u}`})}),children:[e.jsx(F,{"aria-hidden":"true"})," ",h,"/",u]}),e.jsxs(j,{children:["View stack #",i," · layer ",h," of ",u]})]}),e.jsx(E,{children:e.jsx(I,{side:"bottom",align:"start",sideOffset:6,className:"isolate z-50 outline-none",children:e.jsxs(q,{className:"pr-stack-popup","aria-label":`Stack #${i}`,children:[e.jsxs("div",{className:"pr-stack-heading",children:[e.jsxs("strong",{children:["Stack #",i]}),e.jsx(m,{variant:"ghost",size:"xs",disabled:a.isFetching,onClick:()=>{a.refetch()},children:"Refresh"})]}),a.isFetching&&e.jsx("p",{className:"pr-stack-notice",role:"status",children:t?"Refreshing stack…":"Loading stack…"}),a.isError&&e.jsxs("div",{className:"pr-stack-notice",role:"status",children:[e.jsx("p",{children:t?"Could not refresh. Showing saved layers.":"Could not load the stack."}),e.jsx(m,{variant:"outline",size:"xs",onClick:()=>{a.refetch()},children:"Retry"})]}),t===null&&!a.isFetching&&!a.isError&&e.jsx("p",{className:"pr-stack-notice",children:"This PR is no longer in a stack, or stack data is unavailable."}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pr-stack-layers",children:[...t.layers].reverse().map(s=>{const p=s.isDraft&&s.state==="OPEN"?"Draft":s.state==="MERGED"?"Merged":s.state==="CLOSED"?"Closed":"Open",f=s.state==="MERGED"?M:P;return e.jsxs(x,{children:[e.jsxs(g,{render:e.jsx("button",{className:"pr-stack-layer","aria-current":s.number===r?"true":void 0,onClick:()=>{k(!1),l(s.number)}}),children:[e.jsx(f,{className:`pr-stack-state ${p.toLowerCase()}`,"aria-hidden":"true"}),e.jsxs("span",{className:"pr-stack-layer-text",children:[e.jsx("strong",{children:s.title}),e.jsxs("small",{children:["#",s.number," · ",s.headRefName," · ",p]})]}),s.number===r&&e.jsx(R,{"aria-hidden":"true"})]}),e.jsxs(j,{children:[s.title," · ",s.headRefName," · ",p]})]},s.number)})}),e.jsxs("div",{className:"pr-stack-base",children:["↳ ",t.base]})]})]})})})]})}function A({src:n,className:r}){const[c,l]=v.useState(!1);return e.jsx("span",{className:r,"aria-hidden":"true",children:n&&!c?e.jsx("img",{src:n,alt:"",onError:()=>l(!0)}):e.jsx(O,{})})}export{A as G,K as I,X as P,U as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as w,j as e}from"./react-rd22PHbN.js";import{K as ne,f as J,g as Z,L as ae,M as re,N as oe,O as ie,P as le,p as ce,q as de,l as he,Q as ue,R as me,U as pe}from"./App-BbT5H97Z.js";import{a as xe}from"./tanstack-BysN2Oew.js";import{T as N,b as C,d as v,B,o as je,w as fe,s as X}from"./index-B3QJsvjR.js";import"./base-ui-DIP2rZxz.js";function ge(s){let n=[],a=s.some(r=>r.color!==void 0)?3:0,t=1;const o=new Map,j=[],i=new Map(s.map(r=>[r.oid,r])),u=new Set;let d=s[0];for(;d&&!u.has(d.oid);)u.add(d.oid),d.color!==void 0&&o.set(d.oid,d.color),d=i.get(d.parentOids[0]??"");for(const r of s){let h=n.indexOf(r.oid);const p=h>=0;h<0&&(h=n.length,n=[...n,r.oid]);const f=n,$=be(o,r.oid,()=>r.color??a++),x=$<3?r.color??$:$;o.set(r.oid,x);const y=f.filter((g,l)=>l!==h);let H=Math.min(h,y.length);r.parentOids.forEach((g,l)=>{o.has(g)||o.set(g,l===0?x:a++),!y.includes(g)&&(y.splice(H,0,g),H+=1)});const E=[];f.forEach((g,l)=>{if(l===h){p&&E.push({fromLane:l,from:"top",toLane:h,to:"node",color:$});return}const I=y.indexOf(g);I>=0&&E.push({fromLane:l,from:"top",toLane:I,to:"bottom",color:o.get(g)??0})}),r.parentOids.forEach(g=>{const l=y.indexOf(g);l>=0&&E.push({fromLane:h,from:"node",toLane:l,to:"bottom",color:o.get(g)??x})}),t=Math.max(t,f.length,y.length),j.push({lane:h,color:x,segments:E,continuations:y.map((g,l)=>({lane:l,color:o.get(g)??0}))}),n=y}return{rows:j,laneCount:t}}function be(s,n,a){const t=s.get(n);if(t!==void 0)return t;const o=a();return s.set(n,o),o}function ye(s){const n=s.parentCount>1&&/^Merge pull request #(\d+)\b/i.exec(s.subject),a=/\(#(\d+)\)\s*$/.exec(s.subject),t=n||a;if(!t)return null;const o=Number(t[1]);return Number.isSafeInteger(o)&&o>0?{number:o,source:n?"merge":"subject"}:null}function Ne(s){if(s.upstreamState==="local-only")return 0;if(s.baseState==="included")return 2;if(s.upstreamState==="published")return 1}function Ce(s,n){if(!n)return s.map(i=>({commit:i,parentOids:i.parentOids,grouped:[]}));const a=new Map(s.map(i=>[i.oid,i])),t=new Map;s.forEach(i=>i.parentOids.forEach(u=>{const d=t.get(u)??new Set;d.add(i.oid),t.set(u,d)}));const o=new Set,j=[];for(const i of s){if(o.has(i.oid))continue;const u={commit:i,parentOids:i.parentOids,grouped:[]};if(j.push(u),i.parentOids.length!==2)continue;const d=new Set;let r=a.get(i.parentOids[0]);for(;r&&!d.has(r.oid);)d.add(r.oid),r=a.get(r.parentOids[0]??"");let h=i.parentOids[1];const p=[],f=new Set;for(;!d.has(h);){const x=a.get(h);if(!x||f.has(h)||o.has(h)||x.isHead||x.parentOids.length!==1)break;f.add(h),p.push(x),h=x.parentOids[0]}if(!d.has(h)||p.length===0)continue;const $=new Set([i.oid,...p.map(x=>x.oid)]);p.some(x=>[...t.get(x.oid)??[]].some(y=>!$.has(y)))||p.some(x=>j.some(y=>y.commit.oid===x.oid))||(u.grouped=p,u.parentOids=[i.parentOids[0]],p.forEach(x=>o.add(x.oid)))}return j}function Q(s,n){const a=n.trim().toLocaleLowerCase();return a.length>0&&[s.subject,s.author,s.oid,...s.decorations].some(t=>t.toLocaleLowerCase().includes(a))}function Fe({repositoryId:s,upstream:n,readOnly:a,operation:t,canPublish:o,pushBusy:j,onPublish:i,commits:u,nextCursor:d,loading:r,undoing:h,baseRef:p,activeOid:f,onSelectReference:$,onSelectCommit:x,onSelectFile:y,onUndo:H,onMore:E}){const g=ne(),l=w.useRef(null),[I,L]=w.useState(new Set),[M,T]=w.useState(!0),[O,D]=w.useState(!1),[S,G]=w.useState(""),[q,z]=w.useState(-1),c=g?52:M?42:56,b=w.useMemo(()=>Ce(u??[],O&&!S.trim()),[u,O,S]),K=w.useMemo(()=>ge(b.map(({commit:m,parentOids:k})=>({oid:m.oid,parentOids:k,color:Ne(m)}))),[b]),F=w.useMemo(()=>b.flatMap(({commit:m},k)=>Q(m,S)?[k]:[]),[b,S]),se=$e(K.laneCount),P=xe({count:b.length,getScrollElement:()=>l.current,estimateSize:()=>c,getItemKey:m=>b[m].commit.oid,overscan:8});w.useEffect(()=>{P.measure()},[P,M,O,S,g]);const _=()=>{if(!F.length)return;const m=(q+1)%F.length;z(m),P.scrollToIndex(F[m],{align:"center"})};if(u===null)return e.jsxs("div",{className:"view-loading",role:"status",children:[e.jsx(J,{className:"spinner"})," ",e.jsx(Z,{text:"Loading history…"})]});const V=u.filter(m=>m.upstreamState==="local-only").length;return e.jsxs("div",{className:"history-list",style:{"--history-row-height":`${c}px`},children:[e.jsxs("div",{className:"history-toolbar",children:[e.jsxs("label",{className:"history-search",children:[e.jsx(ae,{"aria-hidden":"true"}),e.jsx("input",{type:"search","aria-label":"Search loaded commits",placeholder:"Find commit…",value:S,onChange:m=>{G(m.target.value),z(-1)},onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),_())}})]}),S&&e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("button",{className:"history-next-match",onClick:_,disabled:!F.length,"aria-label":"Next matching commit"}),children:e.jsx(re,{})}),e.jsx(v,{children:"Next match in loaded history (Enter)"})]}),e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("button",{className:"history-option","aria-pressed":O,disabled:!u.some(m=>m.parentCount>1),onClick:()=>D(!O)}),children:"Group merges"}),e.jsx(v,{children:"Collapse complete merge branches. Searching reveals their commits."})]}),!g&&e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("button",{className:"history-option","aria-pressed":M,onClick:()=>T(!M)}),children:M?"Compact":"Comfortable"}),e.jsx(v,{children:"Change row density without moving the diff viewer"})]})]}),!n&&u.length>0&&e.jsxs("div",{className:"history-upstream-notice",role:"status",children:[e.jsx("span",{children:"Publish this branch to configure an upstream and distinguish local from published commits."}),o&&e.jsx(B,{variant:"outline",size:"xs",disabled:j||a||!!t,onClick:i,children:j?"Publishing…":"Publish branch"})]}),n&&V>0&&e.jsxs("div",{className:"history-local-summary",children:["↑ ",V," ",V===1?"local commit":"local commits"," in loaded history"]}),e.jsx("div",{ref:l,className:"history-scroll",role:"list","aria-label":"Commit history",children:b.length===0?e.jsx("p",{className:"empty-list",children:"This repository has no commits yet."}):e.jsxs("div",{className:"virtual-list",style:{height:P.getTotalSize()+(d?52:0)},children:[P.getVirtualItems().map(m=>{const{commit:k,grouped:W}=b[m.index];return e.jsx("div",{ref:P.measureElement,"data-index":m.index,className:"virtual-row",style:{transform:`translateY(${m.start}px)`},children:e.jsx(ve,{repositoryId:s,upstream:n,baseRef:p,commit:k,graphRow:K.rows[m.index],graphWidth:se,rowHeight:c,active:f===k.oid||W.some(U=>U.oid===f),match:Q(k,S),groupedCount:W.length,onRevealGroup:()=>D(!1),onSelectReference:$,expanded:I.has(k.oid),onExpandedChange:U=>L(te=>{const Y=new Set(te);return U?Y.add(k.oid):Y.delete(k.oid),Y}),canUndo:!a&&!t&&!h&&k.upstreamState==="local-only"&&k.isHead&&k.parentCount===1,onSelectCommit:x,onSelectFile:y,onUndo:H})},m.key)}),d&&e.jsx(B,{variant:"ghost",className:"history-more",style:{top:P.getTotalSize()},disabled:r,onClick:E,children:r?"Loading…":"Load more"})]})}),u.length>0&&e.jsxs("div",{className:"history-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-color":"local"}),"Local"]}),e.jsxs("span",{children:[e.jsx("i",{"data-color":"published"}),"Published"]}),p&&e.jsxs(N,{children:[e.jsxs(C,{render:e.jsx("span",{className:"history-base-label"}),children:[e.jsx("i",{"data-color":"base"}),p]}),e.jsxs(v,{children:["Primary-line commits reachable from ",p,", using the latest known local refs. Side branches use the published color."]})]}),e.jsx("span",{className:"history-count",role:"status",children:S?`${F.length} matches in ${u.length} loaded`:`${u.length} loaded`})]})]})}function ve({repositoryId:s,upstream:n,baseRef:a,commit:t,graphRow:o,graphWidth:j,rowHeight:i,active:u,match:d,groupedCount:r,onRevealGroup:h,onSelectReference:p,expanded:f,onExpandedChange:$,canUndo:x,onSelectCommit:y,onSelectFile:H,onUndo:E}){const g=`${s}:${t.oid}`,[l,I]=w.useState(()=>oe(g)??null),[L,M]=w.useState(null);w.useEffect(()=>{if(!f||l||L)return;let c=!0;return je.commits.files(s,t.oid).then(b=>{c&&(ie(g,b),I(b))}).catch(b=>{c&&M(Me(b))}),()=>{c=!1}},[g,t.oid,f,l,L,s]);const T=ye(t),O=Ee(t.decorations),D=O.slice(0,3),S=O.slice(3),G=l?.reduce((c,b)=>c+b.additions,0)??0,q=l?.reduce((c,b)=>c+b.deletions,0)??0,z=async()=>{try{await fe(t.oid),X.success({title:"Hash copied",description:t.oid})}catch{X.error({title:"Could not copy hash"})}};return e.jsxs("div",{className:`commit-item${u?" active":""}${d?" search-match":""}`,role:"listitem",children:[e.jsxs("div",{className:"commit-header",children:[e.jsx(Se,{graph:o,width:j,height:i,merge:t.parentCount>1,head:t.isHead}),e.jsx("button",{className:"commit-expand","aria-expanded":f,"aria-label":f?"Collapse commit":"Expand commit",onClick:()=>$(!f),children:e.jsx(le,{className:`folder-chevron ${f?"open":""}`})}),e.jsxs("div",{className:"commit-main",children:[e.jsxs("span",{className:"commit-title-row",children:[e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("button",{className:"commit-subject","aria-pressed":u,onClick:()=>y(t)}),children:t.subject||"(no subject)"}),e.jsxs(v,{side:"right",children:[t.subject||"(no subject)",e.jsx("br",{}),"Open the full commit diff"]})]}),T&&e.jsxs(N,{children:[e.jsxs(C,{render:p?e.jsx("button",{className:"ref-chip commit-pr",onClick:()=>p(T.number),"aria-label":`Open pull request #${T.number}`}):e.jsx("span",{className:"ref-chip commit-pr"}),children:[e.jsx(ce,{"aria-hidden":"true"}),"#",T.number]}),e.jsxs(v,{children:[T.source==="merge"?"Pull request reference from the merge message.":"Reference from the commit subject; it may identify a pull request or issue.",p?" Open as a pull request in the right-hand viewer.":""," No merge method is inferred from the number."]})]}),e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("time",{className:"commit-date",dateTime:t.date}),children:de(t.date)}),e.jsx(v,{children:he(t.date)})]})]}),e.jsxs("span",{className:"commit-meta",children:[(O.length>0||t.parentCount>1||t.upstreamState==="local-only")&&e.jsxs("span",{className:"commit-refs",children:[t.upstreamState==="local-only"&&e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("span",{className:"ref-chip local-only"}),children:"Local"}),e.jsx(v,{children:t.isHead?`Not in ${n??"the upstream"} according to the latest known remote state.`:"Not published. To avoid rewriting multiple commits, only the latest can be undone."})]}),t.parentCount>1&&e.jsx("span",{className:"ref-chip merge",children:"merge"}),D.map(c=>e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("span",{className:`ref-chip ${c.kind}`,"data-base":c.label===a||c.label.endsWith("/HEAD")&&t.baseState==="included"}),children:c.label}),e.jsx(v,{children:c.label})]},`${c.kind}:${c.label}`)),S.length>0&&e.jsxs(N,{children:[e.jsxs(C,{render:e.jsx("span",{className:"ref-chip more"}),children:["+",S.length]}),e.jsx(v,{children:S.map(c=>c.label).join(" · ")})]})]}),e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("button",{className:"commit-oid",onClick:()=>{z()},"aria-label":`Copiar hash ${t.shortOid}`}),children:t.shortOid}),e.jsx(v,{children:"Copy full hash"})]}),e.jsxs(N,{children:[e.jsx(C,{render:e.jsx("span",{className:"commit-author"}),children:t.author}),e.jsx(v,{children:t.author})]}),r>0&&e.jsxs(N,{children:[e.jsxs(C,{render:e.jsx("button",{className:"commit-group-count",onClick:h}),children:[r," grouped"]}),e.jsxs(v,{children:["Show the ",r," commits in this merge branch"]})]})]})]}),x&&e.jsxs(N,{children:[e.jsx(C,{render:e.jsx(B,{variant:"ghost",size:"icon-xs",className:"change-action-button commit-undo",onClick:c=>{c.stopPropagation(),E(t)},"aria-label":`Undo commit ${t.shortOid}`}),children:e.jsx(ue,{})}),e.jsx(v,{children:"Undo commit and keep its changes staged"})]})]}),f&&o.continuations.length>0&&e.jsx(ke,{graph:o,width:j}),f&&e.jsxs("div",{className:"commit-files",style:{paddingLeft:j+31},children:[t.body&&e.jsx("p",{className:"commit-description",children:t.body}),L&&e.jsx("div",{className:"commit-files-message error",children:L}),!l&&!L&&e.jsxs("div",{className:"commit-files-message",children:[e.jsx(J,{className:"spinner"})," ",e.jsx(Z,{text:"Loading files…"})]}),l&&l.length===0&&e.jsx("div",{className:"commit-files-message",children:"This commit does not modify its own files (merge)."}),l&&l.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"commit-files-summary",children:[l.length," ",l.length===1?"file":"files",(G>0||q>0)&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"add",children:["+",G]})," ",e.jsxs("span",{className:"del",children:["−",q]})]})]}),l.map(c=>e.jsx(Oe,{file:c,onSelect:()=>H(t.oid,c)},c.path))]})]})]})}const ee=14,we=["var(--history-local)","var(--history-published)","var(--history-base)"];function $e(s){return 14+Math.max(0,s-1)*ee}function A(s){return 7+s*ee}function R(s){return we[s]??"var(--history-published)"}function Se({graph:s,width:n,height:a,merge:t,head:o}){const j=a/2;return e.jsxs("svg",{className:"commit-graph",width:n,height:a,viewBox:`0 0 ${n} ${a}`,"aria-hidden":"true",children:[s.segments.map((i,u)=>{const d=A(i.fromLane),r=A(i.toLane),h=i.from==="top"?0:j,p=i.to==="node"?j:a,f=(h+p)/2,$=d===r?`M ${d} ${h} L ${r} ${p}`:`M ${d} ${h} C ${d} ${f}, ${r} ${f}, ${r} ${p}`;return e.jsx("path",{d:$,stroke:R(i.color)},`${u}:${$}`)}),e.jsx("circle",{cx:A(s.lane),cy:j,r:t||o?4.5:3,fill:t||o?"var(--sidebar)":R(s.color),stroke:R(s.color)}),t&&e.jsx("circle",{cx:A(s.lane),cy:j,r:"1.6",fill:R(s.color)})]})}function ke({graph:s,width:n}){return e.jsx("svg",{className:"commit-graph-continuation",width:n,viewBox:`0 0 ${n} 100`,preserveAspectRatio:"none","aria-hidden":"true",children:s.continuations.map(a=>e.jsx("line",{x1:A(a.lane),y1:"0",x2:A(a.lane),y2:"100",stroke:R(a.color)},a.lane))})}function Oe({file:s,onSelect:n}){const a=w.useRef(null),t=s.path.lastIndexOf("/"),o=t<0?s.path:s.path.slice(t+1),j=s.oldPath?.split("/").pop();return e.jsxs("div",{ref:a,className:"commit-file-row",children:[e.jsxs(N,{children:[e.jsxs(C,{render:e.jsx("button",{className:"commit-file-label",onClick:n,"aria-label":`Ver el diff de ${s.path}`}),children:[e.jsx(Le,{path:s.path,type:"file"}),e.jsxs("span",{className:"commit-file-text",children:[e.jsx("span",{children:o}),j&&e.jsxs("small",{className:"commit-file-rename",children:[j," →"]})]})]}),e.jsx(v,{anchor:a,side:"right",sideOffset:10,children:s.oldPath?`${s.oldPath} → ${s.path}`:s.path})]}),e.jsx("span",{className:"commit-file-stats",children:s.binary?e.jsx("span",{className:"binary",children:"bin"}):e.jsxs(e.Fragment,{children:[s.additions>0&&e.jsxs("span",{className:"add",children:["+",s.additions]}),s.deletions>0&&e.jsxs("span",{className:"del",children:["−",s.deletions]})]})}),e.jsx("span",{className:"status-code","data-kind":s.kind,children:me(s.kind)})]})}function Ee(s){return s.map(n=>n.startsWith("tag: ")?{label:n.slice(5),kind:"tag"}:n.startsWith("HEAD -> ")?{label:n.slice(8),kind:"head"}:n==="HEAD"?{label:"HEAD",kind:"head"}:{label:n,kind:n.includes("/")?"remote":"branch"})}function Le({path:s}){return e.jsx("img",{className:"vscode-tree-icon",src:pe(s),alt:"","aria-hidden":"true",draggable:!1})}function Me(s){return s instanceof Error?s.message:"An unexpected error occurred."}export{Fe as HistoryView};
|