@a9n-shoji/rvw 0.3.0 → 0.3.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/CHANGELOG.md +39 -0
- package/README.md +29 -10
- package/dist/cli.mjs +974 -111
- package/dist/cli.mjs.map +4 -4
- package/dist/web/assets/CommentThread-CMXtuZ98.js +33 -0
- package/dist/web/assets/DocumentViewer-D-UGIxCU.js +1417 -0
- package/dist/web/assets/MarkdownTable-7Sm_sj1E.js +7 -0
- package/dist/web/assets/MermaidExpandedView-CyWRss2q.js +4 -0
- package/dist/web/assets/MermaidSurface-Dt2_Hu6n.js +344 -0
- package/dist/web/assets/WalkthroughViewer-CuJMrKOW.js +43 -0
- package/dist/web/assets/abnfDiagram-N423BO3Z-DjhFeHQj.js +1 -0
- package/dist/web/assets/architecture-TIHT7OUA-CsHfPErM.js +1 -0
- package/dist/web/assets/architectureDiagram-T3A2C74G-4zQ-4s9L.js +36 -0
- package/dist/web/assets/{blockDiagram-VBNYF7ZC-BBG7PXeg.js → blockDiagram-VBNYF7ZC-Bh91Tm8T.js} +1 -1
- package/dist/web/assets/{c4Diagram-5PPSVZJV-oLErQeqr.js → c4Diagram-5PPSVZJV-BHgLhSdB.js} +1 -1
- package/dist/web/assets/ccount-DFmD81E1.js +1 -0
- package/dist/web/assets/channel-BmC0cAv-.js +1 -0
- package/dist/web/assets/{chunk-2GRJ4B5K-Bknsyt9u.js → chunk-2GRJ4B5K-sTPzFBtk.js} +1 -1
- package/dist/web/assets/chunk-3NCLNEKW-k0AW8Qyp.js +1 -0
- package/dist/web/assets/{chunk-4I5QYGJK-D-Icvgxq.js → chunk-4I5QYGJK-q_8xEFmv.js} +1 -1
- package/dist/web/assets/chunk-5FCAYU7R-Dh5nylU8.js +1 -0
- package/dist/web/assets/chunk-5HE753X5-Bw-yg4kO.js +1 -0
- package/dist/web/assets/chunk-5JV3BV7I-Cy5pj3QY.js +1 -0
- package/dist/web/assets/{chunk-5RXB4S5H-B1iIyQwd.js → chunk-5RXB4S5H-BcuYQqlM.js} +1 -1
- package/dist/web/assets/chunk-5TONJI2A-DQOY3q1H.js +2 -0
- package/dist/web/assets/{chunk-6Q2QTUOP-C09OFw2-.js → chunk-6Q2QTUOP-DDI96JMg.js} +1 -1
- package/dist/web/assets/{chunk-7Z6QIM7H-BqCAUqX5.js → chunk-7Z6QIM7H-B8QX_5g4.js} +1 -1
- package/dist/web/assets/chunk-BIQX33UG-DZEsGuSn.js +1 -0
- package/dist/web/assets/chunk-CQNSW5MT-B8S09OIh.js +1 -0
- package/dist/web/assets/chunk-CYSBUYHQ-C1Rf4art.js +1 -0
- package/dist/web/assets/chunk-EMLP6XTP-RLD4nXpI.js +1 -0
- package/dist/web/assets/{chunk-GF5L2VYU-BHy3jGGE.js → chunk-GF5L2VYU-CJin2HQO.js} +1 -1
- package/dist/web/assets/{chunk-I66GZJ75-BBhE3jWF.js → chunk-I66GZJ75-CEntV2nF.js} +1 -1
- package/dist/web/assets/chunk-J7OUQ5F2-XLdTvjUm.js +2 -0
- package/dist/web/assets/chunk-JG7HCLWE-BYfiSaVt.js +2 -0
- package/dist/web/assets/{chunk-JQJVKLGR-DNslGDt7.js → chunk-JQJVKLGR-Bnum3gum.js} +3 -3
- package/dist/web/assets/{chunk-KBJHAD2P-J7tWEBhK.js → chunk-KBJHAD2P-DwPs20tJ.js} +1 -1
- package/dist/web/assets/chunk-MOZMSUNE-XVucA-n6.js +1 -0
- package/dist/web/assets/{chunk-NSK5VX7P-retcSoJp.js → chunk-NSK5VX7P-AmYQxFLu.js} +1 -1
- package/dist/web/assets/chunk-OSBZ3O6U-CrKZOUOr.js +1 -0
- package/dist/web/assets/chunk-QBLGF6JB-CxAyS2mW.js +1 -0
- package/dist/web/assets/{chunk-QR6OTTB3-DvFlp4db.js → chunk-QR6OTTB3-VIu9ZqqS.js} +1 -1
- package/dist/web/assets/chunk-R7FJI6CG-Cnn3gE-Y.js +1 -0
- package/dist/web/assets/chunk-U6XO7XAA-BFxjP5U3.js +2 -0
- package/dist/web/assets/{chunk-UBXNYLIW-gyX_iwb1.js → chunk-UBXNYLIW-D4XAD8w6.js} +1 -1
- package/dist/web/assets/{chunk-W5SLKNZC-BGNgHuYL.js → chunk-W5SLKNZC-B8QG_JAG.js} +1 -1
- package/dist/web/assets/{chunk-WRU74C26-66KXN6Rn.js → chunk-WRU74C26-CS8zeNym.js} +1 -1
- package/dist/web/assets/chunk-YOTPTUD7-D0vRKqYp.js +1 -0
- package/dist/web/assets/chunk-ZIRB5QZD-O39ZBUk3.js +32 -0
- package/dist/web/assets/classDiagram-JCYQIIEL-DyY7Kt3N.js +1 -0
- package/dist/web/assets/classDiagram-v2-OCEON4UE-DyY7Kt3N.js +1 -0
- package/dist/web/assets/cynefin-VYW2F7L2-Ds2Fw2Y0.js +1 -0
- package/dist/web/assets/cynefinDiagram-MW4NZA55-DaNC4kY7.js +62 -0
- package/dist/web/assets/{dagre-VZM6K2ZE-BTedug-5.js → dagre-VZM6K2ZE-DJ845MyA.js} +1 -1
- package/dist/web/assets/{diagram-7IWD3JNH-kSc1kTCk.js → diagram-7IWD3JNH-98E00vZR.js} +3 -3
- package/dist/web/assets/diagram-B4RE2ZJO-BpMQ8ico.js +3 -0
- package/dist/web/assets/diagram-LBJQPF4R-BZ8RNQpZ.js +24 -0
- package/dist/web/assets/diagram-Q27KOJAE-Bn1wtc7g.js +24 -0
- package/dist/web/assets/diagram-UB23O5K3-B314M-wb.js +41 -0
- package/dist/web/assets/dist-DCGa16l5.js +145 -0
- package/dist/web/assets/ebnfDiagram-BXEA7PRR-CqKM-cL0.js +1 -0
- package/dist/web/assets/{erDiagram-JOGREHBK-jm3RTuJX.js → erDiagram-JOGREHBK-CVMcNMlx.js} +1 -1
- package/dist/web/assets/eventmodeling-45OFAUF4-CLEiVx5s.js +1 -0
- package/dist/web/assets/flowDiagram-UKHOOZJN-8dur6GAS.js +1 -0
- package/dist/web/assets/{ganttDiagram-PKOTCBZU--GwSY0BM.js → ganttDiagram-PKOTCBZU-DALoGLHl.js} +1 -1
- package/dist/web/assets/gitGraph-TEB2WS4Q-CZFBqwW-.js +1 -0
- package/dist/web/assets/gitGraphDiagram-DS77QQ5N-BY_jOOb-.js +106 -0
- package/dist/web/assets/index-BNcvGFlf.css +1 -0
- package/dist/web/assets/index-BwIKbLJ1.js +11 -0
- package/dist/web/assets/info-DKCQHKI2--1InqQeT.js +1 -0
- package/dist/web/assets/infoDiagram-6WML65LV-CNMbrlEJ.js +2 -0
- package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-ErnJ_7Sr.js → ishikawaDiagram-WSZJBQD7-NODY49Zb.js} +2 -2
- package/dist/web/assets/{journeyDiagram-NVQOT4AX-CWvooGdp.js → journeyDiagram-NVQOT4AX-v9CJWB8Y.js} +1 -1
- package/dist/web/assets/{kanban-definition-27J2QSJJ-DsIS6ipP.js → kanban-definition-27J2QSJJ-Cv2iL7No.js} +3 -3
- package/dist/web/assets/lib-p2IERBh0.js +9 -0
- package/dist/web/assets/{line-DCcVjraC.js → line-Dah7RomF.js} +1 -1
- package/dist/web/assets/mermaid-parser.core-BcQae2Lb.js +4 -0
- package/dist/web/assets/mermaid.core-BVyLgPb6.js +11 -0
- package/dist/web/assets/{mindmap-definition-FAOFIHXS-DdsB9lmP.js → mindmap-definition-FAOFIHXS-BD9fkU-f.js} +1 -1
- package/dist/web/assets/packet-7NZHBO7P-BGMXB0XL.js +1 -0
- package/dist/web/assets/pegDiagram-VL7TDLO6-D-HL9Pvp.js +1 -0
- package/dist/web/assets/pie-RZYD4A2V-DgYg3tCt.js +1 -0
- package/dist/web/assets/pieDiagram-7S7Q4E2Y-Sam5BEo-.js +39 -0
- package/dist/web/assets/preload-helper-Czpn1I53.js +1 -0
- package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-CryFsz7r.js → quadrantDiagram-CIZ2JOQS-BNXhvOJb.js} +1 -1
- package/dist/web/assets/radar-I7S5WNFK-Ag-zp_Rq.js +1 -0
- package/dist/web/assets/railroad-3IZDKUUU-aibJDIDV.js +1 -0
- package/dist/web/assets/railroad-abnf-AHOZXSZD-BBMEuvIl.js +1 -0
- package/dist/web/assets/railroad-ebnf-EBAXGLYW-Be1nseej.js +1 -0
- package/dist/web/assets/railroad-peg-LSFZ7HO6-DIvD-Eyb.js +1 -0
- package/dist/web/assets/railroadDiagram-AXF67PYL-C6-GuR01.js +1 -0
- package/dist/web/assets/{requirementDiagram-LRYGKXZP-D2-9KlK1.js → requirementDiagram-LRYGKXZP-Dew1VZVc.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-W5VNT64P-DSOFAzno.js → sankeyDiagram-W5VNT64P-BNlHXupx.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-SI44F4Z6-BHEKSYJt.js → sequenceDiagram-SI44F4Z6-CHZhbxWH.js} +1 -1
- package/dist/web/assets/stateDiagram-OKZ733FA-BP7TOkRY.js +1 -0
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-BoFgs-SF.js +1 -0
- package/dist/web/assets/swimlanes-SLNWSIFB-DfMga4nB.js +2 -0
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-CpfunQZj.js +8 -0
- package/dist/web/assets/{timeline-definition-Z64GVDOM-C7eeBnPC.js → timeline-definition-Z64GVDOM-DjC-PWK6.js} +1 -1
- package/dist/web/assets/treeView-QDETBFTQ-uHZ-3Fz8.js +1 -0
- package/dist/web/assets/treemap-6X3UGDF4-BnUKyy3l.js +1 -0
- package/dist/web/assets/{vennDiagram-T6HMQDX7-DTIq1ec9.js → vennDiagram-T6HMQDX7-CJzy1Vav.js} +2 -2
- package/dist/web/assets/wardley-OPB4EBWU-Da7TLC2F.js +1 -0
- package/dist/web/assets/{wardleyDiagram-T6FBY63Y-BmzhEoo_.js → wardleyDiagram-T6FBY63Y-C9BlVo6M.js} +3 -3
- package/dist/web/assets/{xychartDiagram-ELKLHX3M-CcCGC0u-.js → xychartDiagram-ELKLHX3M-B0WUxsYy.js} +3 -3
- package/dist/web/index.html +6 -2
- package/package.json +1 -1
- package/skills/rvw-walkthrough/SKILL.md +4 -4
- package/skills/rvw-walkthrough/agents/openai.yaml +1 -1
- package/skills/rvw-walkthrough/references/walkthrough-authoring.md +11 -0
- package/dist/web/assets/DocumentViewer-DtusMl0r.js +0 -1561
- package/dist/web/assets/MarkdownTable-BjwiOHQe.js +0 -15
- package/dist/web/assets/WalkthroughViewer-BNwKsKzk.js +0 -42
- package/dist/web/assets/abnfDiagram-N423BO3Z-DtH8B7Z7.js +0 -1
- package/dist/web/assets/architecture-TIHT7OUA-P_K7H_mW.js +0 -1
- package/dist/web/assets/architectureDiagram-T3A2C74G-5Fq3Xylv.js +0 -36
- package/dist/web/assets/channel-wXu0iczQ.js +0 -1
- package/dist/web/assets/classDiagram-JCYQIIEL-DOHE4q2M.js +0 -1
- package/dist/web/assets/classDiagram-v2-OCEON4UE-DOHE4q2M.js +0 -1
- package/dist/web/assets/cynefin-VYW2F7L2-Dj_jqvQa.js +0 -1
- package/dist/web/assets/cynefinDiagram-MW4NZA55-DSnUS3JS.js +0 -62
- package/dist/web/assets/diagram-B4RE2ZJO-DNtXohxd.js +0 -3
- package/dist/web/assets/diagram-LBJQPF4R-CVD-8DKW.js +0 -24
- package/dist/web/assets/diagram-Q27KOJAE-DBEnUsLJ.js +0 -24
- package/dist/web/assets/diagram-UB23O5K3-DiPHfrk7.js +0 -41
- package/dist/web/assets/ebnfDiagram-BXEA7PRR-CE06v37i.js +0 -1
- package/dist/web/assets/eventmodeling-45OFAUF4-C344zcDl.js +0 -1
- package/dist/web/assets/flowDiagram-UKHOOZJN-BAHsb6fm.js +0 -1
- package/dist/web/assets/gitGraph-TEB2WS4Q-C6oA29oA.js +0 -1
- package/dist/web/assets/gitGraphDiagram-DS77QQ5N-DR1mGQ6a.js +0 -106
- package/dist/web/assets/index-BiPhui1B.js +0 -384
- package/dist/web/assets/index-CHlqmhif.css +0 -1
- package/dist/web/assets/info-DKCQHKI2-BT4oYSnk.js +0 -1
- package/dist/web/assets/infoDiagram-6WML65LV-D0mnXRu0.js +0 -2
- package/dist/web/assets/mermaid-parser.core-BmDn4VB6.js +0 -7
- package/dist/web/assets/mermaid.core-Cus_gjGs.js +0 -42
- package/dist/web/assets/packet-7NZHBO7P-BXuujfeh.js +0 -1
- package/dist/web/assets/pegDiagram-VL7TDLO6-CBF6Uic6.js +0 -1
- package/dist/web/assets/pie-RZYD4A2V-DgssvIaB.js +0 -1
- package/dist/web/assets/pieDiagram-7S7Q4E2Y-DejhR8Wh.js +0 -39
- package/dist/web/assets/radar-I7S5WNFK-CoiIzjHC.js +0 -1
- package/dist/web/assets/railroad-3IZDKUUU-CWq6IkAh.js +0 -1
- package/dist/web/assets/railroad-abnf-AHOZXSZD-D7Iqnp88.js +0 -1
- package/dist/web/assets/railroad-ebnf-EBAXGLYW-Dp2g2TtT.js +0 -1
- package/dist/web/assets/railroad-peg-LSFZ7HO6-DTqKNJKF.js +0 -1
- package/dist/web/assets/railroadDiagram-AXF67PYL-DkePHtcR.js +0 -1
- package/dist/web/assets/stateDiagram-OKZ733FA-f1GttDrB.js +0 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-CEn2YfQh.js +0 -1
- package/dist/web/assets/swimlanes-SLNWSIFB-Dx7QlDaA.js +0 -2
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-CX2pXGLK.js +0 -8
- package/dist/web/assets/treeView-QDETBFTQ-BPsqqMsK.js +0 -1
- package/dist/web/assets/treemap-6X3UGDF4-CmBU76N7.js +0 -1
- package/dist/web/assets/wardley-OPB4EBWU-DLOnGzPl.js +0 -1
|
@@ -0,0 +1,1417 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,b as n,l as r,n as i,o as a,s as o,t as s,x as c,y as l}from"./MermaidSurface-Dt2_Hu6n.js";import{B as u,F as d,I as f,N as p,O as m,P as h,S as g,c as _,d as v,f as y,g as b,h as x,i as S,j as C,k as w,l as T,m as E,n as D,nt as O,p as k,r as A,t as j,u as ee,v as M,z as te}from"./CommentThread-CMXtuZ98.js";import{t as N}from"./lib-p2IERBh0.js";import{a as ne,i as re,n as P,o as ie,r as ae,s as oe}from"./dist-DCGa16l5.js";import{a as F,i as se,n as ce,o as le,r as ue,t as de}from"./MarkdownTable-7Sm_sj1E.js";var fe=`diffs-container`,pe=/(?=^diff --git)/gm,me=/(?<=\n)/,he=/^(---|\+\+\+)\s+([^\t\r\n]+)/,ge=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,_e=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,ve=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,ye=`header-prefix`,be=`header-filename-suffix`,I=`header-metadata`,xe=`header-custom`,L={dark:`pierre-dark`,light:`pierre-light`},Se=`data-theme-css`,Ce=`data-unsafe-css`,we=`data-diffs-scrollbar-measure`,Te=`--diffs-scrollbar-gutter-measured`,Ee=1e5,De={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8};({...De});var Oe=Object.freeze({fromStart:0,fromEnd:0}),R={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},ke={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},Ae=new Set,je=null;function Me(e){Ae.add(e),je??=requestAnimationFrame(Pe)}function Ne(e){Ae.delete(e)&&Ae.size===0&&je!=null&&(cancelAnimationFrame(je),je=null)}function Pe(e){let t=new Set(Ae);Ae.clear();for(let n of t)try{n(e)}catch(e){console.error(e)}je=Ae.size>0?requestAnimationFrame(Pe):null}function Fe(e,t,n){if(e===t||e==null||t==null)return e===t;let r=new Set(n),i=Object.keys(e),a=new Set(Object.keys(t));for(let n of i)if(a.delete(n),!r.has(n)&&(!(n in t)||e[n]!==t[n]))return!1;for(let e of Array.from(a))if(!r.has(e))return!1;return!0}function Ie(e,t){return e==null||t==null||typeof e==`string`||typeof t==`string`?e===t:e.dark===t.dark&&e.light===t.light}function Le(e,t){let n=e?.theme??L,r=t?.theme??L,i=Re(e),a=Re(t);return Ie(n,r)&&Fe(e,t,[`theme`,`parseDiffOptions`])&&Fe(i,a)}function Re(e){if(e!=null&&`parseDiffOptions`in e)return e.parseDiffOptions}function z(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function ze(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}var Be=new TextEncoder,B=new TextDecoder(`utf-8`,{ignoreBOM:!0}),Ve=/[\uD800-\uDFFF]/,V=1024,H=new Uint8Array(V);function He(){H.length!==V&&(H=new Uint8Array(V))}function U(e){if(e.length===0)return e;if(Ve.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;H.length<t&&(H=new Uint8Array(t));let{written:n}=Be.encodeInto(e,H);return B.decode(H.subarray(0,n))}function W(e,t){return e-(t===0?0:1)}function G(e,t){return W(e,t)+t}var Ue=4096,We=.5;function Ge(e){for(let t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){let r=t.hunkContent[n];if(r.type!==`change`)continue;let i=qe(e,r);i!=null&&(t.hunkContent.splice(n,1,...i),n+=i.length-1)}Ke(t,e)}}function Ke(e,t){let{hunkContent:n}=e;for(let e=1;e<n.length;e++){let r=n[e],i=n[e-1];if(r.type!==`change`||r.additions>0&&r.deletions>0||i.type!==`context`)continue;let a=r.additions>0,o=a?t.additionLines:t.deletionLines,s=a?r.additionLineIndex:r.deletionLineIndex,c=a?r.additions:r.deletions,l=o[s]??``;if(l.trim()!==``)continue;let u=!0;for(let e=1;e<c;e++)if(o[s+e]!==l){u=!1;break}if(!u)continue;let d=0;for(;d<i.lines&&t.additionLines[i.additionLineIndex+i.lines-1-d]===l;)d++;if(d===0||e===1&&d===i.lines)continue;r.additionLineIndex-=d,r.deletionLineIndex-=d;let f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,m=n[e+1];m?.type===`context`?(m.lines+=d,m.additionLineIndex=f,m.deletionLineIndex=p):n.splice(e+1,0,{type:`context`,lines:d,additionLineIndex:f,deletionLineIndex:p}),i.lines-=d,i.lines===0&&(n.splice(e-1,1),e--)}}function qe(e,t){let{deletions:n,additions:r,deletionLineIndex:i,additionLineIndex:a}=t,o=Math.min(n,r),s=Math.abs(r-n);if(o===0||s===0||o*(s+1)>Ue)return null;let c=[];for(let t=0;t<n;t++)c.push(q(e.deletionLines[i+t]??``));let l=[];for(let t=0;t<r;t++)l.push(q(e.additionLines[a+t]??``));let u=r>n,d=0,f=-1;for(let e=0;e<=s;e++){let t=0;for(let n=0;n<o;n++)t+=J(c[n+(u?0:e)],l[n+(u?e:0)]);e===0?f=t+o*We:t>f&&(f=t,d=e)}if(d===0)return null;let p=[],m=(e,t,n,r)=>{(e>0||t>0)&&p.push({type:`change`,deletions:e,additions:t,deletionLineIndex:n,additionLineIndex:r})};return u?(m(0,d,i,a),m(o,o,i,a+d),m(0,r-o-d,i+o,a+d+o)):(m(d,0,i,a),m(o,o,i+d,a),m(n-o-d,0,i+d+o,a+o)),p}var K=/\s+/g;function q(e){return e.replace(K,``)}function J(e,t){if(e===t)return 1;let n=Math.max(e.length,t.length),r=Math.min(e.length,t.length);if(r===0)return 0;let i=0;for(;i<r&&e[i]===t[i];)i++;let a=0;for(;a<r-i&&e[e.length-1-a]===t[t.length-1-a];)a++;return(i+a)/n}function Y(e,t){try{return Je(e,t)}finally{He()}}function Je(e,{cacheKey:t,isGitDiff:n=pe.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=nt(e,`@@ `),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=Xe(e),f=s[0];if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=$e(f),m=0,h=0;if(p==null||c==null){if(c!=null){if(a)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}c={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:l,additionLines:!l&&r!=null&&i!=null?Ye(i.contents):[],deletionLines:!l&&r!=null&&i!=null?Ye(r.contents):[],cacheKey:it(t)},c.additionLines.length===1&&i?.contents===``&&(c.additionLines.length=0),c.deletionLines.length===1&&r?.contents===``&&(c.deletionLines.length=0);for(let e of s){if(e.startsWith(`diff --git`)){let t=e.trim().match(_e),n=t?.[1]??t?.[2],r=t?.[3]??t?.[4];if(n==null||r==null){if(a)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}c.name=U(r.trim()),n!==r&&(c.prevName=U(n.trim()));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(n?ge:he):null;if(t!=null){let[,e,n]=t;if(e===`---`&&n!==`/dev/null`){let e=U(n.trim());c.prevName=e,c.name=e}else e===`+++`&&n!==`/dev/null`&&(c.name=U(n.trim()))}else if(n){if(e.startsWith(`new mode `)&&(c.mode=U(e.slice(8).trim())),e.startsWith(`old mode `)&&(c.prevMode=U(e.slice(8).trim())),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=U(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=U(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?c.type=`rename-pure`:c.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(ve)??[];t!=null&&(c.prevObjectId=U(t)),n!=null&&(c.newObjectId=U(n)),r!=null&&(c.mode=U(r))}e.startsWith(`rename from `)&&(c.prevName=U(e.slice(12).trim())),e.startsWith(`rename to `)&&(c.name=U(e.slice(10).trim()))}}continue}let g,_;for(;s.length>0&&(s[s.length-1]===`
|
|
2
|
+
`||s[s.length-1]===`\r`||s[s.length-1]===`\r
|
|
3
|
+
`||s[s.length-1]===``);)s.pop();let{additionStart:v,deletionStart:y}=p;u=l?u:y-1,d=l?d:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:it(p.hunkContext),hunkSpecs:U(f),noEOFCRAdditions:!1,noEOFCRDeletions:!1},x=0,S=0;for(let e=1;e<s.length;e++){let t=s[e];if(x>=b.additionCount&&S>=b.deletionCount&&!t.startsWith(`\\`)){if(a&&Ze(t)&&!Qe(t))throw Error(`parsePatchContent: hunk has more lines than expected`);break}let n=t[0];if(n!==`+`&&n!==`-`&&n!==` `&&n!==`\\`){if(a)throw Error(`parsePatchContent: invalid hunk line`);console.error(`parseLineType: Invalid firstChar: "${n}", full line: "${t}"`),console.error(`processFile: invalid rawLine:`,t);continue}let r=at(n);if(r===`addition`){if(a&&x>=b.additionCount)throw Error(`parsePatchContent: hunk has too many addition lines`);let e=ot(t);(g==null||g.type!==`change`)&&(g=st(`change`,u,d),b.hunkContent.push(g)),d++,x++,l&&c.additionLines.push(e),g.additions++,m++,_=`addition`}else if(r===`deletion`){if(a&&S>=b.deletionCount)throw Error(`parsePatchContent: hunk has too many deletion lines`);let e=ot(t);(g==null||g.type!==`change`)&&(g=st(`change`,u,d),b.hunkContent.push(g)),u++,S++,l&&c.deletionLines.push(e),g.deletions++,h++,_=`deletion`}else if(r===`context`){if(a&&(S>=b.deletionCount||x>=b.additionCount))throw Error(`parsePatchContent: hunk has too many context lines`);let e=ot(t);(g==null||g.type!==`context`)&&(g=st(`context`,u,d),b.hunkContent.push(g)),d++,u++,x++,S++,l&&(c.deletionLines.push(e),c.additionLines.push(e)),g.lines++,_=`context`}else if(r===`metadata`&&g!=null){if(g.type===`context`?(b.noEOFCRAdditions=!0,b.noEOFCRDeletions=!0):_===`deletion`?b.noEOFCRDeletions=!0:_===`addition`&&(b.noEOFCRAdditions=!0),l&&(_===`addition`||_===`context`)){let e=c.additionLines.length-1;e>=0&&(c.additionLines[e]=ze(c.additionLines[e]))}if(l&&(_===`deletion`||_===`context`)){let e=c.deletionLines.length-1;e>=0&&(c.deletionLines[e]=ze(c.deletionLines[e]))}}}if(a&&(x!==b.additionCount||S!==b.deletionCount))throw Error(`parsePatchContent: hunk line count mismatch`);b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(W(b.additionStart,b.additionCount)-o,0),c.hunks.push(b),o=G(b.additionStart,b.additionCount);for(let e of b.hunkContent)e.type===`context`?(b.splitLineCount+=e.lines,b.unifiedLineCount+=e.lines):(b.splitLineCount+=Math.max(e.additions,e.deletions),b.unifiedLineCount+=e.deletions+e.additions);b.splitLineStart=c.splitLineCount+b.collapsedBefore,b.unifiedLineStart=c.unifiedLineCount+b.collapsedBefore,c.splitLineCount+=b.collapsedBefore+b.splitLineCount,c.unifiedLineCount+=b.collapsedBefore+b.unifiedLineCount}if(c!=null){if(a&&l&&!n&&c.hunks.length===0)throw Error(`parsePatchContent: unified file has no hunks`);if(c.hunks.length>0&&!l&&c.additionLines.length>0&&c.deletionLines.length>0){let e=c.hunks[c.hunks.length-1],t=G(e.additionStart,e.additionCount),n=c.additionLines.length,r=Math.max(n-t,0);c.splitLineCount+=r,c.unifiedLineCount+=r}return n||(c.prevName!=null&&c.name!==c.prevName?c.hunks.length>0?c.type=`rename-changed`:c.type=`rename-pure`:(r==null||r.contents===``)&&i!=null&&i.contents!==``?c.type=`new`:r!=null&&r.contents!==``&&(i==null||i.contents===``)&&(c.type=`deleted`)),c.type!==`rename-pure`&&c.type!==`rename-changed`&&(c.prevName=void 0),Ge(c),c}}function Ye(e){let t=Xe(e);for(let e=0;e<t.length;e++)t[e]=U(t[e]);return t}function Xe(e){if(e.length===0)return[``];let t=[],n=0;for(;;){let r=e.indexOf(`
|
|
4
|
+
`,n);if(r===-1)break;t.push(e.slice(n,r+1)),n=r+1}return n<e.length&&t.push(e.slice(n)),t}function Ze(e){let t=e[0];return t===`+`||t===`-`||t===` `}function Qe(e){if(!e.startsWith(`--`))return!1;for(let t=2;t<e.length;t++){let n=e[t];if(n!==` `&&n!==` `&&n!==`
|
|
5
|
+
`&&n!==`\r`)return!1}return!0}function $e(e){if(!e.startsWith(`@@ -`))return;let t=4,n=et(e,t);if(n==null)return;let r=n.value;t=n.endIndex;let i=1;if(e[t]===`,`){let n=et(e,t+1);if(n==null)return;i=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`+`)return;t+=2;let a=et(e,t);if(a==null)return;let o=a.value;t=a.endIndex;let s=1;if(e[t]===`,`){let n=et(e,t+1);if(n==null)return;s=n.value,t=n.endIndex}if(e[t]!==` `||e[t+1]!==`@`||e[t+2]!==`@`)return;let c,l=t+3;return e[l]===` `&&(c=tt(e.slice(l+1))),{additionCount:s,additionStart:o,deletionCount:i,deletionStart:r,hunkContext:c}}function et(e,t){let n=t,r=0;for(;n<e.length;n++){let t=e.charCodeAt(n)-48;if(t<0||t>9)break;r=r*10+t}if(n!==t)return{value:r,endIndex:n}}function tt(e){return e.endsWith(`\r
|
|
6
|
+
`)?e.slice(0,-2):e.endsWith(`
|
|
7
|
+
`)?e.slice(0,-1):e}function nt(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.startsWith(t)?0:rt(e,n,0);if(r===-1)return[e];let i=[];r>0&&i.push(e.slice(0,r));let a=r;for(;;){let t=rt(e,n,a+1);if(t===-1)break;i.push(e.slice(a,t)),a=t}return i.push(e.slice(a)),i}function rt(e,t,n){let r=e.indexOf(t,n);return r===-1?-1:r+1}function it(e){return e==null?e:U(e)}function at(e){return e===` `?`context`:e===`\\`?`metadata`:e===`+`?`addition`:`deletion`}function ot(e){let t=e.slice(1);return U(t===``?`
|
|
8
|
+
`:t)}function st(e,t,n){return e===`change`?{type:`change`,additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:`context`,lines:0,additionLineIndex:n,deletionLineIndex:t}}var ct=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},lt=new class extends ct{};function ut(e,t,n){return lt.diff(e,t,n)}function dt(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function ft(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function pt(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function mt(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function ht(e,t){return pt(e,t,``)}function gt(e,t){return mt(e,t,``)}function _t(e,t){return t.slice(0,vt(e,t))}function vt(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function yt(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function bt(e,t){if(t)return St(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function xt(e,t){if(t)return St(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function St(e,t){if(!t)return[xt(e),bt(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=yt(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var Ct=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,wt=RegExp(`[${Ct}]+|\\s+|[^${Ct}]`,`ug`);new class extends ct{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=yt(e,r)}else n=e.match(wt)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Tt(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Tt(n,i,r,null,t.intlSegmenter),e}};function Tt(e,t,n,r,i){if(t&&n){let[a,o]=St(t.value,i),[s,c]=St(n.value,i);if(e){let r=dt(a,s);e.value=mt(e.value,s,r),t.value=ht(t.value,r),n.value=ht(n.value,r)}if(r){let e=ft(o,c);r.value=pt(r.value,c,e),t.value=gt(t.value,e),n.value=gt(n.value,e)}}else if(n){if(e){let e=xt(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=xt(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=xt(r.value,i),[a,o]=St(t.value,i),s=dt(n,a);t.value=ht(t.value,s);let c=ft(ht(n,s),o);t.value=gt(t.value,c),r.value=pt(r.value,n,c),e.value=mt(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=xt(r.value,i),n=_t(bt(t.value,i),e);t.value=gt(t.value,n)}else if(e){let n=_t(bt(e.value,i),xt(t.value,i));t.value=ht(t.value,n)}}var Et=new class extends ct{tokenize(e){let t=RegExp(`(\\r?\\n)|[${Ct}]+|[^\\S\\n\\r]+|[^${Ct}]`,`ug`);return e.match(t)||[]}};function Dt(e,t,n){return Et.diff(e,t,n)}var Ot=new class extends ct{constructor(){super(...arguments),this.tokenize=At}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
9
|
+
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
10
|
+
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
11
|
+
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
12
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function kt(e,t,n){return Ot.diff(e,t,n)}function At(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
13
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function jt(e){return e==`.`||e==`!`||e==`?`}new class extends ct{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(jt(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends ct{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends ct{constructor(){super(...arguments),this.tokenize=At}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Mt(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Mt(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Mt(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=Mt(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends ct{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function Nt(e){for(let t=0;t<e.length;t++)if(e[t]<` `||e[t]>`~`||e[t]===`"`||e[t]===`\\`)return!0;return!1}function X(e){if(!Nt(e))return e;let t=`"`,n=new TextEncoder().encode(e),r=0;for(;r<n.length;){let e=n[r];t+=e===7?`\\a`:e===8?`\\b`:e===9?`\\t`:e===10?`\\n`:e===11?`\\v`:e===12?`\\f`:e===13?`\\r`:e===34?`\\"`:e===92?`\\\\`:e>=32&&e<=126?String.fromCharCode(e):`\\`+e.toString(8).padStart(3,`0`),r++}return t+=`"`,t}var Pt={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function Ft(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;kt(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(kt(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||Rt(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s){if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
14
|
+
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function It(e,t){if(t||=Pt,Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(e=>e.isGit))throw Error(`Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)`);return e.map(e=>It(e,t)).join(`
|
|
15
|
+
`)}let n=[];if(e.isGit){if(t=Pt,!e.oldFileName)throw Error(`oldFileName must be specified for Git patches`);if(!e.newFileName)throw Error(`newFileName must be specified for Git patches`);let r=e.oldFileName,i=e.newFileName;e.isCreate&&r===`/dev/null`?r=i.replace(/^b\//,`a/`):e.isDelete&&i===`/dev/null`&&(i=r.replace(/^a\//,`b/`)),n.push(`diff --git `+X(r)+` `+X(i)),e.isDelete&&n.push(`deleted file mode `+(e.oldMode??`100644`)),e.isCreate&&n.push(`new file mode `+(e.newMode??`100644`)),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(n.push(`old mode `+e.oldMode),n.push(`new mode `+e.newMode)),e.isRename&&(n.push(`rename from `+X((e.oldFileName??``).replace(/^a\//,``))),n.push(`rename to `+X((e.newFileName??``).replace(/^b\//,``)))),e.isCopy&&(n.push(`copy from `+X((e.oldFileName??``).replace(/^a\//,``))),n.push(`copy to `+X((e.newFileName??``).replace(/^b\//,``))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&n.push(`Index: `+e.oldFileName),t.includeUnderline&&n.push(`===================================================================`);let r=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||r)&&(n.push(`--- `+X(e.oldFileName)+(e.oldHeader?` `+e.oldHeader:``)),n.push(`+++ `+X(e.newFileName)+(e.newHeader?` `+e.newHeader:``)));for(let t=0;t<e.hunks.length;t++){let r=e.hunks[t],i=r.oldLines===0?r.oldStart-1:r.oldStart,a=r.newLines===0?r.newStart-1:r.newStart;n.push(`@@ -`+i+`,`+r.oldLines+` +`+a+`,`+r.newLines+` @@`);for(let e of r.lines)n.push(e)}return n.join(`
|
|
16
|
+
`)+`
|
|
17
|
+
`}function Lt(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;Ft(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?It(e,o.headerOptions):void 0)}}))}else{let s=Ft(e,t,n,r,i,a,o);return s?It(s,o?.headerOptions):void 0}}function Rt(e){let t=e.endsWith(`
|
|
18
|
+
`),n=e.split(`
|
|
19
|
+
`).map(e=>e+`
|
|
20
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}var zt=`/dev/null`;function Bt(e,t,n,r=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let i=e??Vt(),a=t??Vt(),o=Y(Lt(i.name,a.name,i.contents,a.contents,i.header,a.header,n),{cacheKey:(()=>{let n=e?.cacheKey??e?.name,r=t?.cacheKey??t?.name;return n!=null&&r!=null?n+`:`+r:n??r})(),oldFile:i,newFile:a,throwOnError:r});if(o==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(o.type=`new`,o.prevName=void 0):t===null&&(o.type=`deleted`,o.prevName=void 0);let s=t?.lang??(t===null?e?.lang:void 0);return s!=null&&(o.lang=s),o}function Vt(){return{name:zt,contents:``}}function Ht(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function Ut(e){return{type:`text`,value:e}}function Z({tagName:e,children:t=[],properties:n={}}){return{type:`element`,tagName:e,properties:n,children:t}}function Wt({name:e,width:t=16,height:n=16,properties:r}){return Z({tagName:`svg`,properties:{width:t,height:n,viewBox:`0 0 16 16`,...r},children:[Z({tagName:`use`,properties:{href:`#${e.replace(/^#/,``)}`}})]})}function Gt(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t;t=`children`in t?t.children[0]:null}}function Kt(e){return Z({tagName:`div`,properties:{"data-gutter":``},children:e})}function qt(e,t,n,r={}){return Z({tagName:`div`,properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...r},children:t==null?void 0:[Z({tagName:`span`,properties:{"data-line-number-content":``},children:[Ut(`${t}`)]})]})}function Jt(e,t,n){return Z({tagName:`div`,properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t===`annotation`?void 0:e,style:t===`annotation`?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function Yt(){return Z({tagName:`button`,properties:{"data-utility-button":``,type:`button`},children:[Wt({name:`diffs-icon-plus`,properties:{"data-icon":``}})]})}function Xt(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function Zt(e){for(let t of e)if(t instanceof HTMLElement&&(t.hasAttribute(`data-utility-button`)||t.hasAttribute(`data-gutter-utility-slot`)||t.getAttribute(`slot`)===`gutter-utility-slot`||t.getAttribute(`name`)===`gutter-utility-slot`))return!0;return!1}var Qt=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:`idle`};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handlePointerClick),this.pre?.removeEventListener(`pointerdown`,this.handlePointerDown),this.pre?.removeEventListener(`pointermove`,this.handlePointerMove),this.pre?.removeEventListener(`pointerleave`,this.handlePointerLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),Ne(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();let{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode===`gutterSelecting`&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){let n=!(e===this.selectedRange||z(e??void 0,this.selectedRange??void 0)),r=t?.lineNumberOnly??!1,i=t?.activeLineSide!==this.selectedRangeHighlightSide||r!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!i||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=r,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){let r=e!==this.editorActiveLine,i=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!r&&!i||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{let e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode===`diff`&&e.type===`diff-line`)return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode===`file`&&e.type===`line`)return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{let{onHunkExpand:t,onLineClick:n,onLineNumberClick:r,onTokenClick:i,onMergeConflictActionClick:a}=this.options;(t!=null||n!=null||r!=null||a!=null||i!=null)&&(this.options.onGutterUtilityClick!=null&&Zt(e.composedPath())||(vn(this.options.__debugPointerEvents,`click`,`FileDiff.DEBUG.handlePointerClick:`,e),this.handlePointerEvent({eventType:`click`,event:e})))};handlePointerMove=e=>{if(e.pointerType!==`mouse`)return;let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,onTokenEnter:i,onTokenLeave:a,enableGutterUtility:o=!1}=this.options;t===`disabled`&&!o&&n==null&&r==null&&i==null&&a==null||(vn(this.options.__debugPointerEvents,`move`,`FileDiff.DEBUG.handlePointerMove:`,e),this.handlePointerEvent({eventType:`move`,event:e}))};handlePointerLeave=e=>{let{__debugPointerEvents:t}=this.options;if(vn(t,`move`,`FileDiff.DEBUG.handlePointerLeave: no event`),this.hoveredLine==null&&this.hoveredToken==null){vn(t,`move`,`FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token`);return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){let{__debugPointerEvents:n}=this.options,r=t.composedPath();vn(n,e,`FileDiff.DEBUG.handlePointerEvent:`,{eventType:e,composedPath:r});let i=this.resolvePointerTarget(r);vn(n,e,`FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onTokenClick:l,onTokenEnter:u,onTokenLeave:d,onHunkExpand:f,onMergeConflictActionClick:p}=this.options;switch(e){case`move`:{let e=rn(i)&&this.hoveredLine?.lineElement===i.lineElement;nn(i)&&this.hoveredToken?.tokenElement===i.tokenElement||(this.hoveredToken!=null&&(d?.(this.hoveredToken,t),this.clearHoveredToken()),nn(i)&&(this.setHoveredToken(this.toTokenEventBaseProps(i)),u?.(this.hoveredToken,t))),e||(this.hoveredLine!=null&&(c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),rn(i)?(this.setHoveredLine(this.toEventBaseProps(i)),this.placeUtility(),s?.({...this.hoveredLine,event:t})):this.placeUtility());break}case`click`:{if(i==null)break;if(on(i)&&p!=null){p(i);break}if(an(i)&&f!=null){f(i.hunkIndex,i.all||t.shiftKey?`both`:i.direction,i.all||t.shiftKey?1/0:void 0);break}if(!rn(i))break;nn(i)&&l!=null&&l(this.toTokenEventBaseProps(i),t);let e=this.toEventBaseProps(i);o!=null&&i.numberColumn?o({...e,event:t}):a?.({...e,event:t});break}}}syncPointerListeners(e){let{__debugPointerEvents:t,lineHoverHighlight:n=`disabled`,onLineClick:r,onLineNumberClick:i,onLineEnter:a,onLineLeave:o,onTokenClick:s,onTokenEnter:c,onTokenLeave:l,onHunkExpand:u,onMergeConflictActionClick:d,enableGutterUtility:f=!1,enableLineSelection:p=!1,onGutterUtilityClick:m}=this.options,h=m!=null,g=n!==`disabled`||r!=null||i!=null||a!=null||o!=null||s!=null||c!=null||l!=null||u!=null||d!=null||f||p||h;g&&!this.hasPointerListeners?(e.addEventListener(`click`,this.handlePointerClick),e.addEventListener(`pointerdown`,this.handlePointerDown),e.addEventListener(`pointermove`,this.handlePointerMove),e.addEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!0,vn(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(r!=null&&e.push(`onLineClick`),i!=null&&e.push(`onLineNumberClick`),u!=null&&e.push(`expandable hunk separators`),d!=null&&e.push(`merge conflict actions`)),e})()),vn(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),vn(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!g&&this.hasPointerListeners&&(e.removeEventListener(`click`,this.handlePointerClick),e.removeEventListener(`pointerdown`,this.handlePointerDown),e.removeEventListener(`pointermove`,this.handlePointerMove),e.removeEventListener(`pointerleave`,this.handlePointerLeave),this.hasPointerListeners=!1);let _=this.pointerSession.mode===`selecting`||this.pointerSession.mode===`pendingSingleLineUnselect`,v=this.pointerSession.mode===`gutterSelecting`;(!p&&_||!h&&v)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;let{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,r=e!=null,i=t!=null||n;r&&!this.interactiveLinesAttr?(this.pre.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0):!r&&this.interactiveLinesAttr&&(this.pre.removeAttribute(`data-interactive-lines`),this.interactiveLinesAttr=!1),i&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLineNumbersAttr=!0):!i&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute(`data-interactive-line-numbers`),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType===`mouse`&&e.button!==0||this.pre==null||this.pointerSession.mode!==`idle`)return;let t=e.composedPath();Zt(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!==`mouse`&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){let{enableLineSelection:t=!1}=this.options;if(!t)return;let n=this.resolveSelectionInfo(e,{source:`event-path`,requireNumberColumn:!0});if(n==null)return;let{pre:r}=this;if(r==null)return;let{lineNumber:i,eventSide:a,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){let t=this.getIndexesFromSelection(this.selectedRange,r.getAttribute(`data-diff-type`)===`split`);if(t==null)return;let n=t.start<=t.end?o>=t.start:o<=t.end;this.selectionAnchor={lineNumber:n?this.selectedRange.start:this.selectedRange.end,side:n?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===i&&this.selectedRange?.end===i){let t={lineNumber:i,side:a};this.selectionAnchor=t,this.pointerSession={mode:`pendingSingleLineUnselect`,pointerId:e.pointerId,anchor:t,pending:t},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:i,side:a},this.updateSelection(i,a,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:`selecting`,pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){let{onGutterUtilityClick:t}=this.options;if(t==null)return;let n=this.currentSelectionEnds(),r=n?.bottom??this.resolveSelectionPoint(e,{source:`event-path`,excludeUtility:!1}),i=n?.top??r;r!=null&&i!=null&&(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:`gutterSelecting`,pointerId:e.pointerId,anchor:i,current:r},this.selectionAnchor={lineNumber:i.lineNumber,side:i.side},this.updateSelection(r.lineNumber,r.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionPoint(e,{source:`coordinates-first`});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case`selecting`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case`pendingSingleLineUnselect`:{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();let t=this.resolveSelectionInfo(e,{source:`coordinates-first`,requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;let n={lineNumber:t.lineNumber,side:t.eventSide};if(Xt(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:`selecting`,pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{let{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:{let{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();let r=this.resolveSelectionPoint(e,{source:`coordinates-first`});r!=null&&(n.current=r,this.updateSelection(r.lineNumber,r.side));let i=this.buildSelectedLineRange(n.anchor,n.current);t?.({...i}),this.selectionAnchor=void 0,this.notifySelectionEnd(i),this.notifySelectionCommitted(i),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case`pendingSingleLineUnselect`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case`selecting`:if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case`idle`:return;case`gutterSelecting`:case`selecting`:case`pendingSingleLineUnselect`:if(`pointerId`in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute(`data-hovered`),this.hoveredLine.numberElement.removeAttribute(`data-hovered`),this.hoveredLine=void 0)}setHoveredLine(e){let{lineHoverHighlight:t=`disabled`}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!==`disabled`&&((t===`both`||t===`line`)&&this.hoveredLine.lineElement.setAttribute(`data-hovered`,``),(t===`both`||t===`number`)&&this.hoveredLine.numberElement.setAttribute(`data-hovered`,``))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer??(this.gutterUtilityContainer=document.createElement(`div`),this.gutterUtilityContainer.setAttribute(`data-gutter-utility-slot`,``)),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot??(this.gutterUtilitySlot=document.createElement(`slot`),this.gutterUtilitySlot.name=`gutter-utility-slot`),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){let e=document.createElement(`div`);e.innerHTML=N(Yt());let t=e.firstElementChild;if(!(t instanceof HTMLButtonElement))throw Error(`InteractionManager.ensureGutterUtilityNode: Node element should be a button`);t.remove(),this.gutterUtilityButton=t}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;let t=this.resolvePointerTarget(e);tn(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){let e=this.currentSelectionEnds();if(e==null)return!1;let t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){let e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){let t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},r=this.selectionPointRowIndex(t),i=this.selectionPointRowIndex(n);if(r!=null&&i!=null)return r>i?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){let t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;let t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;let n=this.mode===`diff`?`${t[0]},${t[1]}`:`${t[0]}`,r=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(let t of r){if(!(t instanceof HTMLElement))continue;let n=this.resolvePointerTarget(ln(t));if(tn(n)&&(this.mode!==`diff`||e.side==null||n.side===e.side))return n}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||=(document.addEventListener(`pointermove`,this.handleDocumentPointerMove),document.addEventListener(`pointerup`,this.handleDocumentPointerUp),document.addEventListener(`pointercancel`,this.handleDocumentPointerCancel),!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&=(document.removeEventListener(`pointermove`,this.handleDocumentPointerMove),document.removeEventListener(`pointerup`,this.handleDocumentPointerUp),document.removeEventListener(`pointercancel`,this.handleDocumentPointerCancel),!1)}clearPointerSession(){this.pointerSession={mode:`idle`}}clearPendingSingleLineState(){this.pointerSession.mode===`pendingSingleLineUnselect`&&(this.pointerSession={mode:`idle`})}selectionInfoFromPath(e,t){let n=this.resolvePointerTarget(e);if(tn(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode===`diff`?n.side:void 0}}resolveSelectionInfo(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionInfoFromPath(n,t.requireNumberColumn)}selectionPointFromPath(e){let t=this.resolvePointerTarget(e);if(tn(t))return{lineNumber:t.lineNumber,side:this.mode===`diff`?t.side:void 0}}resolveSelectionPoint(e,t){let n=this.resolveSelectionPath(e,t);return n==null?void 0:this.selectionPointFromPath(n)}resolveSelectionPath(e,t){let n=t.excludeUtility!==!1;switch(t.source){case`event-path`:return this.pathFromEventPath(e.composedPath(),n);case`coordinates-first`:{let t=this.pathFromCoordinates(e,n);return t===void 0?this.pathFromEventPath(e.composedPath(),n):t??void 0}}}pathFromCoordinates(e,t){let n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&Zt(e))){for(let n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){let n=ln(e);if(t&&Zt(n))return;let r=un(e);return r==null?this.pathFromAnnotationSlot(e):ln(r)}pathFromAnnotationSlot(e){let t=fn(dn(e));if(t==null)return;let n=this.targetForSelectionPoint(t);return n==null?void 0:ln(n.lineElement)}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;let t=this.pre?.getRootNode(),n=pn(t)?t:pn(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}getCurrentSelectionRange(){return this.proposedSelectedRange===void 0?this.selectedRange:this.proposedSelectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){let r=this.getCurrentSelectionRange(),i;if(e==null)i=null;else{let n=this.selectionAnchor?.side??t,r=this.selectionAnchor?.lineNumber??e;i=this.buildSelectionRange(r,e,n,t)}z(r??void 0,i??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=i:(this.selectedRange=i,Me(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;let n=this.getLineIndex(e.start,e.side),r=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&r!=null?{start:t?n[1]:n[0],end:t?r[1]:r[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;let r=this.getIndexesFromSelection(e.range,t);if(r==null)throw console.error({rowRange:r,range:e.range}),Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return r}getLineRenderColumns(e,t,n,r){if(this.pre==null||t==null&&r==null)return[];let{children:i}=this.pre;if(i.length>2)throw console.error(i),Error(`InteractionManager.renderSelection: Somehow there are more than 2 code elements...`);let a=[];for(let o of i){let i=o.hasAttribute(`data-deletions`)?`deletions`:o.hasAttribute(`data-additions`)?`additions`:void 0,s=e!=null&&t!=null&&(e.highlightSide==null||i==null||e.highlightSide===i),c=n!=null&&r!=null&&(n.highlightSide==null||i==null||n.highlightSide===i);if(!s&&!c)continue;let[l,u]=o.children;if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))throw Error(`InteractionManager.renderSelection: missing gutter or content element`);if(u.children.length!==l.children.length)throw Error(`InteractionManager.renderSelection: gutter and content children dont match, something is wrong`);a.push({content:u,gutter:l,renderEditorActiveLine:c,renderSelectedLines:s})}return a}renderSelection=()=>{Ne(this.renderSelection);let e=this.getSelectionRenderState();if(this.pre==null)return;let{editorActiveLine:t,selectedLines:n}=e,r=!hn(this.renderedSelectedLinesState,n),i=!hn(this.renderedEditorActiveLineState,t);if(!r&&!i)return;r&&(this.renderedSelectedLinesState=void 0),i&&(this.renderedEditorActiveLineState=void 0);let a=this.pre.getAttribute(`data-diff-type`)===`split`,o=r?this.resolveLineRenderRange(n,a,`selected-lines`):void 0,s=i?this.resolveLineRenderRange(t,a,`editor-active-line`):void 0,c=this.getLineRenderColumns(r?n:void 0,o,i?t:void 0,s),l=n.range==null||c.some(e=>e.renderSelectedLines),u=t.range==null||c.some(e=>e.renderEditorActiveLine);if(r)for(let e of this.pre.querySelectorAll(`[data-selected-line]`))e.removeAttribute(`data-selected-line`);if(i)for(let e of this.pre.querySelectorAll(`[data-editor-active-line]`))e.removeAttribute(`data-editor-active-line`);let d=o==null?void 0:Math.min(o.start,o.end),f=o==null?void 0:Math.max(o.start,o.end),p=d===f,m=s?.start;for(let e of c){let{content:r,gutter:i,renderEditorActiveLine:o,renderSelectedLines:s}=e,c=Math.max(s?f??-1/0:-1/0,o?m??-1/0:-1/0),l=r.children.length;for(let e=0;e<l;e++){let l=r.children[e],u=i.children[e];if(!(l instanceof HTMLElement)||!(u instanceof HTMLElement))continue;let h=this.parseLineIndex(l,a);if((h??0)>c)break;if(h!=null){if(s&&d!=null&&f!=null&&h>=d&&h<=f){let e=p?`single`:h===d?`first`:h===f?`last`:``;u.setAttribute(`data-selected-line`,e),n.lineNumberOnly||(l.setAttribute(`data-selected-line`,e),u.nextSibling instanceof HTMLElement&&l.nextSibling instanceof HTMLElement&&(l.nextSibling.hasAttribute(`data-line-annotation`)||l.nextSibling.hasAttribute(`data-merge-conflict-actions`))&&(p?(e=`last`,l.setAttribute(`data-selected-line`,`first`)):h===d?e=``:h===f&&l.setAttribute(`data-selected-line`,``),l.nextSibling.setAttribute(`data-selected-line`,e),u.nextSibling.setAttribute(`data-selected-line`,e)))}o&&h===m&&(u.setAttribute(`data-editor-active-line`,``),t.lineNumberOnly||l.setAttribute(`data-editor-active-line`,``))}}}r&&l&&(this.renderedSelectedLinesState=n),i&&u&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode===`file`?{type:`line`,lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:`diff-line`,annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}){return this.mode===`file`?{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:i,tokenText:a}:{type:`token`,lineCharEnd:e,lineCharStart:t,lineNumber:n,side:r,tokenElement:i,tokenText:a}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,r){return{start:e,end:t,...n==null?{}:{side:n},...n!==r&&r!=null?{endSide:r}:{}}}resolvePointerTarget(e){let t=!1,n,r,i,a,o,s,c,l,u,d;for(let f of e){if(!(f instanceof HTMLElement))continue;if(d==null&&f.hasAttribute(`data-merge-conflict-action`)){let e=f.getAttribute(`data-merge-conflict-action`)??void 0,t=f.getAttribute(`data-merge-conflict-conflict-index`)??void 0,n=t==null?NaN:Number.parseInt(t,10);sn(e)&&Number.isFinite(n)&&(d={kind:`merge-conflict-action`,resolution:e,conflictIndex:n})}if(s==null&&f.hasAttribute(`data-char`)){s=f;let e=f.getAttribute(`data-char`);if(e!=null){let t=Number.parseInt(e,10);if(!Number.isNaN(t)){let e=f.textContent??``,n=t+e.length;(e.trim()!==``||this.options.enableTokenInteractionsOnWhitespace===!0)&&(c={tokenElement:s,lineCharStart:t,lineCharEnd:n,tokenText:e});continue}}}let e=o==null?f.getAttribute(`data-column-number`)??void 0:void 0;if(e!=null){o=f,u=Number.parseInt(e,10),t=!0,n=_n(f),a=f.getAttribute(`data-line-index`)??void 0;continue}let p=i==null?f.getAttribute(`data-line`)??void 0:void 0;if(p!=null){i=f,u=Number.parseInt(p,10),n=_n(f),a=f.getAttribute(`data-line-index`)??void 0;continue}if(l==null&&(f.hasAttribute(`data-expand-button`)||f.hasAttribute(`data-unmodified-lines`))){l={hunkIndex:void 0,direction:f.hasAttribute(`data-expand-up`)?`up`:f.hasAttribute(`data-expand-down`)?`down`:`both`,all:f.hasAttribute(`data-expand-all-button`)};continue}let m=l==null?void 0:f.getAttribute(`data-expand-index`)??void 0;if(l!=null&&m!=null){let e=Number.parseInt(m,10);Number.isNaN(e)||(l.hunkIndex=e);continue}if(r==null&&f.hasAttribute(`data-code`)){r=f;break}}if(d!=null)return d;if(l?.hunkIndex!=null)return{type:`line-info`,hunkIndex:l.hunkIndex,direction:l.direction,all:l.all};if(i??=a==null?void 0:cn(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:cn(r,`[data-column-number][data-line-index="${a}"]`),r==null||i==null||o==null||n==null||u==null||Number.isNaN(u))return;let f=this.parseLineIndex(i,this.isSplitDiff());return c==null?this.mode===`file`?{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f}:{kind:`line`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:gn(n,r),splitLineIndex:f}:this.mode===`file`?{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:f,...c}:{kind:`token`,lineType:n,lineElement:i,lineNumber:u,numberColumn:t,numberElement:o,side:gn(n,r),splitLineIndex:f,...c}}isSplitDiff(){return this.pre?.getAttribute(`data-diff-type`)===`split`}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>Number.parseInt(e,10)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function $t({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:r,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,renderGutterUtility:d,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v},y,b,x){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:en({enableGutterUtility:t,renderGutterUtility:d,onGutterUtilityClick:r}),usesCustomGutterUtility:d!=null,lineHoverHighlight:n,onGutterUtilityClick:r,onHunkExpand:y,onMergeConflictActionClick:x,onLineClick:i,onLineEnter:a,onLineLeave:o,onLineNumberClick:s,onTokenClick:c,onTokenEnter:l,onTokenLeave:u,__debugPointerEvents:f,enableLineSelection:p,controlledSelection:m,onLineSelected:h,onLineSelectionStart:g,onLineSelectionChange:_,onLineSelectionEnd:v,getLineIndex:b}}function en({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw Error(`Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.`);return e??!1}function tn(e){return e!=null&&`kind`in e&&e.kind===`line`}function nn(e){return e!=null&&`kind`in e&&e.kind===`token`}function rn(e){return tn(e)||nn(e)}function an(e){return`type`in e&&e.type===`line-info`}function on(e){return`kind`in e&&e.kind===`merge-conflict-action`}function sn(e){return e===`current`||e===`incoming`||e===`both`}function cn(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function ln(e){let t=[],n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function un(e){let t=e.closest(`[data-line], [data-column-number]`);if(t instanceof HTMLElement)return t;let n=e.closest(`[data-line-annotation], [data-gutter-buffer="annotation"]`);if(!(n instanceof HTMLElement))return;let r=n.previousElementSibling;return r instanceof HTMLElement&&(r.hasAttribute(`data-line`)||r.hasAttribute(`data-column-number`))?r:void 0}function dn(e){let t=e.closest(`[slot^="annotation-"]`);if(t instanceof HTMLElement)return t.getAttribute(`slot`)??void 0;if(e instanceof HTMLElement){let t=e.getAttribute(`name`)??void 0;return t!=null&&t.startsWith(`annotation-`)?t:void 0}}function fn(e){if(e==null)return;let t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;let n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function pn(e){return e!=null&&typeof e.elementFromPoint==`function`}function mn(e,t){return e===t||z(e??void 0,t??void 0)}function hn(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&mn(e?.range??null,t.range)}function gn(e,t){switch(e){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return t.hasAttribute(`data-deletions`)?`deletions`:`additions`}}function _n(e){let t=e.getAttribute(`data-line-type`);if(t!=null)switch(t){case`change-deletion`:case`change-addition`:case`context`:case`context-expanded`:return t;default:return}}function vn(e=`none`,t,...n){switch(e){case`none`:return;case`both`:break;case`click`:if(t!==`click`)return;break;case`move`:if(t!==`move`)return}console.log(...n)}var yn=class e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){let t=e.resizeObserver??new ResizeObserver(e.handleSharedResizeEntries);return e.resizeObserver=t,t}static handleSharedResizeEntries(t){let n=new Map;for(let r of t){let t=e.managersByElement.get(r.target);if(t==null)continue;let i=n.get(t);i==null?n.set(t,[r]):i.push(r)}for(let[e,t]of n)e.handleResizeEntries(t)}observedNodes=new Map;setup(e,{disableAnnotations:t,columnVariables:n=`apply`}){let r=new Set,i=n===`apply`,a=0,o=new Map(this.observedNodes);this.observedNodes.clear();for(let t of e.children){if(a===2)break;let e=(()=>{if(t instanceof HTMLElement&&t.tagName===`CODE`)return t})();if(e==null)continue;a++;let n=o.get(e);if(n!=null&&n.type!==`code`)throw Error(`ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible`);let r=e.firstElementChild;r instanceof HTMLElement||(r=null),n==null?(n={type:`code`,codeElement:e,numberElement:r,codeWidth:`auto`,numberWidth:0,applyColumnVariables:i},this.observedNodes.set(e,n),this.observe(e),r!=null&&(this.observedNodes.set(r,n),this.observe(r))):(this.observedNodes.set(e,n),o.delete(e),n.numberElement===r?n.numberElement==null?n.numberWidth=0:(o.delete(n.numberElement),this.observedNodes.set(n.numberElement,n)):(n.numberElement!=null&&(this.unobserve(n.numberElement),o.delete(n.numberElement)),r!=null&&(this.observe(r),o.delete(r),this.observedNodes.set(r,n)),n.numberElement=r,n.numberWidth=0),Sn(n,i))}if(a>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.getAttribute(`data-line-annotation`)??``;if(!/^-?\d+,-?\d+$/.test(t)){console.error(`DiffFileRenderer.setupResizeObserver: Invalid element or annotation`,{lineAnnotation:t,element:e});continue}let r=n.get(t);r??(r=[],n.set(t,r)),r.push(e)}for(let[e,t]of n){if(t.length!==2){console.error(`DiffFileRenderer.setupResizeObserver: Bad Pair`,e,t);continue}let[n,i]=t,a=n.firstElementChild,s=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(s instanceof HTMLElement))continue;let c=o.get(a);if(c!=null){this.observedNodes.set(a,c),this.observedNodes.set(s,c),o.delete(a),o.delete(s);continue}let l=a.getBoundingClientRect().height,u=s.getBoundingClientRect().height;c={type:`annotations`,column1:{container:n,child:a,childHeight:l},column2:{container:i,child:s,childHeight:u},currentHeight:`auto`},r.add({child1:a,child2:s,item:c,newHeight:Math.max(l,u)})}for(let e of r)this.applyNewHeight(e.item,e.newHeight),this.observedNodes.set(e.child1,e.item),this.observedNodes.set(e.child2,e.item),this.observe(e.child1),this.observe(e.child2);r.clear()}for(let[e,t]of o)this.unobserve(e),t.type===`code`?Tn(t):En(t);o.clear()}cleanUp(){for(let e of this.observedNodes.keys())this.unobserve(e);this.observedNodes.clear()}observe(t){let{managersByElement:n}=e,r=n.get(t);if(r!==this){if(r!=null&&r!==this)throw Error(`ResizeManager.observe: element is already owned by another ResizeManager`);n.set(t,this),e.getResizeObserver().observe(t)}}unobserve(t){let{managersByElement:n,resizeObserver:r}=e,i=n.get(t);if(i!=null){if(i!==this)throw Error(`ResizeManager.unobserve: element is owned by another ResizeManager`);n.delete(t),r?.unobserve(t),r!=null&&n.size===0&&(r.disconnect(),e.resizeObserver=void 0)}}handleResizeEntries(e){let t=new Map,n=new Set;for(let r of e){let{target:e,borderBoxSize:i,contentBoxSize:a}=r;if(!(e instanceof HTMLElement)){console.error(`ResizeManager.handleResizeEntries: Invalid element for ResizeObserver`,r);continue}let o=this.observedNodes.get(e);if(o==null){console.error(`ResizeManager.handleResizeEntries: Not a valid observed node`,r);continue}if(o.type===`annotations`){let t=(()=>{if(e===o.column1.child)return o.column1;if(e===o.column2.child)return o.column2})();if(t==null){console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`,{item:o,target:e});continue}t.childHeight=i[0].blockSize,n.add(o)}else if(o.type===`code`){let n=t.get(o)??{},r=a[0].inlineSize;e===o.codeElement?n.codeInlineSize=r:e===o.numberElement&&(n.numberInlineSize=r),t.set(o,n)}}this.applyAnnotationUpdates(n),n.clear(),this.applyColumnUpdates(t),t.clear()}applyAnnotationUpdates(e){for(let t of e)this.applyNewHeight(t,Math.max(t.column1.childHeight,t.column2.childHeight))}applyColumnUpdates=e=>{for(let[t,n]of e){let e=n.codeInlineSize==null?t.codeWidth:bn(n.codeInlineSize),r=n.numberInlineSize==null?t.numberWidth:xn(n.numberInlineSize),i=e!==t.codeWidth,a=r!==t.numberWidth;!i&&!a||(t.codeWidth=e,t.numberWidth=r,t.applyColumnVariables&&Cn(t,{codeWidthChanged:i,numberWidthChanged:a}))}};applyNewHeight(e,t){t!==e.currentHeight&&(e.currentHeight=Math.max(t,0),e.column1.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`),e.column2.container.style.setProperty(`--diffs-annotation-min-height`,`${e.currentHeight}px`))}};function bn(e){let t=Math.max(Math.floor(e),0);return t===0?`auto`:t}function xn(e){return Math.max(Math.ceil(e),0)}function Sn(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?Cn(e,{codeWidthChanged:!0,numberWidthChanged:!0}):wn(e))}function Cn(e,{codeWidthChanged:t,numberWidthChanged:n}){let{codeElement:r,codeWidth:i,numberWidth:a}=e;if(t&&r.style.setProperty(`--diffs-column-width`,`${typeof i==`number`?`${i}px`:`auto`}`),n&&r.style.setProperty(`--diffs-column-number-width`,`${a===0?`auto`:`${a}px`}`),t||n&&i!==`auto`){let e=typeof i==`number`?Math.max(i-a,0):0;r.style.setProperty(`--diffs-column-content-width`,`${e>0?`${e}px`:`auto`}`)}}function wn(e){e.codeElement.style.removeProperty(`--diffs-column-content-width`),e.codeElement.style.removeProperty(`--diffs-column-number-width`),e.codeElement.style.removeProperty(`--diffs-column-width`)}function Tn(e){e.codeElement.isConnected&&wn(e)}function En(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty(`--diffs-annotation-min-height`),e.column2.container.isConnected&&e.column2.container.style.removeProperty(`--diffs-annotation-min-height`)}function Dn(e){for(let t of Array.isArray(e)?e:[e])if(t!==`text`&&t!==`ansi`&&!oe.has(t))return!1;return!0}function On(e=L){let t=[];return typeof e==`string`?t.push(e):(t.push(e.dark),t.push(e.light)),t}function kn(e){for(let t of On(e))if(!ie.has(t))return!1;return!0}function An(e){return ne.hasResolvedThemes(e)}function jn(e,t){return Ie(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function Mn(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function Nn(e){return Z({tagName:`div`,children:[Z({tagName:`div`,children:e.annotations?.map(e=>Z({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function Pn(e){switch(e){case`file`:return`diffs-icon-file-code`;case`change`:return`diffs-icon-symbol-modified`;case`new`:return`diffs-icon-symbol-added`;case`deleted`:return`diffs-icon-symbol-deleted`;case`rename-pure`:case`rename-changed`:return`diffs-icon-symbol-moved`}}function Fn({fileOrDiff:e,mode:t,stickyHeader:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":t,"data-change-type":r?.type,"data-sticky":n?``:void 0};return Z({tagName:`div`,children:[t===`custom`?Z({tagName:`slot`,properties:{name:xe}}):In({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),...t===`custom`?[]:[Ln(r)]],properties:i})}function In({name:e,prevName:t,iconType:n}){let r=[Z({tagName:`slot`,properties:{name:ye}}),Wt({name:Pn(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(Z({tagName:`div`,children:[Z({tagName:`bdi`,children:[Ut(t)]})],properties:{"data-prev-name":``}})),r.push(Wt({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(Z({tagName:`div`,children:[Z({tagName:`bdi`,children:[Ut(e)]})],properties:{"data-title":``}})),r.push(Z({tagName:`slot`,properties:{name:be}})),Z({tagName:`div`,children:r,properties:{"data-header-content":``}})}function Ln(e){let t=[];if(e!=null){let n=0,r=0;for(let t of e.hunks)n+=t.additionLines,r+=t.deletionLines;(r>0||n===0)&&t.push(Z({tagName:`span`,children:[Ut(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(Z({tagName:`span`,children:[Ut(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(Z({tagName:`slot`,properties:{name:I}})),Z({tagName:`div`,children:t,properties:{"data-metadata":``}})}function Rn(e){return Z({tagName:`pre`,properties:zn(e)})}function zn({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,totalLines:a,type:o,customProperties:s}){return{...s,"data-diff":o===`diff`?``:void 0,"data-file":o===`file`?``:void 0,"data-diff-type":o===`diff`?i?`split`:`single`:void 0,"data-overflow":r,"data-disable-line-numbers":n?``:void 0,"data-background":t?void 0:``,"data-indicators":e===`bars`||e===`classic`?e:void 0,style:`--diffs-min-number-column-width-default:${`${a}`.length}ch;`}}function Bn(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:On(t),preferredHighlighter:n}}function Vn(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}function Hn(e,t,n){let r=typeof n.lineInfo==`function`?n.lineInfo(t):n.lineInfo[t-1];if(r==null){let r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),Error(r)}return e.tagName=`div`,e.properties[`data-line`]=r.lineNumber,e.properties[`data-alt-line`]=r.altLineNumber,e.properties[`data-line-type`]=r.type,e.properties[`data-line-index`]=r.lineIndex,e.children.length===0&&e.children.push(Ut(`
|
|
21
|
+
`)),e}var Un=Symbol(`no-token`),Wn=Symbol(`multiple-tokens`);function Gn(e){let t=Kn(e);if(t!=null)return t;let n=Un,r=[],i=[],a,o=()=>{if(i.length===0||a==null){i=[],a=void 0;return}if(i.length===1){let e=i[0];if(e?.type===`element`){Jn(e,a);for(let t of e.children)qn(t)}else qn(e);r.push(e),i=[],a=void 0;return}for(let e of i)qn(e);r.push(Z({tagName:`span`,properties:{"data-char":a},children:i})),i=[],a=void 0},s=e=>{if(e!==Un){if(e===Wn){n=Wn;return}if(n===Un){n=e;return}n!==e&&(n=Wn)}};for(let t of e.children){let e=t.type===`element`?Gn(t):Un;if(s(e),typeof e!=`number`){o(),r.push(t);continue}a!=null&&a!==e&&o(),a??=e,i.push(t)}return o(),e.children=r,n}function Kn(e){let t=e.properties[`data-char`];if(typeof t==`number`)return t}function qn(e){if(e.type===`element`){e.properties[`data-char`]=void 0;for(let t of e.children)qn(t)}}function Jn(e,t){e.properties[`data-char`]=t}function Yn(e={}){let{classPrefix:t=`__shiki_`,classSuffix:n=``,classReplacer:r=e=>e}=e,i=new Map;function a(e){return Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function o(e){let o=typeof e==`string`?e:a(e),s=t+Xn(o)+n;return s=r(s),i.has(s)||i.set(s,typeof e==`string`?e:{...e}),s}return{name:`@shikijs/transformers:style-to-class`,pre(e){if(!e.properties.style)return;let t=o(e.properties.style);delete e.properties.style,this.addClassToHast(e,t)},tokens(e){for(let t of e)for(let e of t){if(!e.htmlStyle)continue;let t=o(e.htmlStyle);e.htmlStyle={},e.htmlAttrs||={},e.htmlAttrs.class?e.htmlAttrs.class+=` ${t}`:e.htmlAttrs.class=t}},getClassRegistry(){return i},getCSS(){let e=``;for(let[t,n]of i.entries())e+=`.${t}{${typeof n==`string`?n:a(n)}}`;return e},clearRegistry(){i.clear()}}}function Xn(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}function Zn(e=!1,t=!1){let n={lineInfo:[]},r=[{line(e){return delete e.properties.class,e},pre(t){let r=Gt(t),i=[];if(r!=null){let t=1;for(let a of r.children)a.type===`element`&&(e&&Gn(a),i.push(Hn(a,t,n)),t++);r.children=i}return t},...e?{tokens(e){for(let t of e){let e=0;for(let n of t){let t=n;t.__lineChar??=e,e+=n.content.length}}},preprocess(e,t){t.mergeWhitespaces=`never`},span(e,t,n,r,i){if(i?.offset!=null&&i.content!=null){let t=i.__lineChar;return t!=null&&(e.properties[`data-char`]=t),e}return e}}:null}];return t&&r.push($n,Qn),e&&r.push({line:e=>(e.type===`element`&&e.children.length===0&&e.children.push({type:`element`,tagName:`br`,properties:{},children:[]}),e)}),{state:n,transformers:r,toClass:Qn}}var Qn=Yn({classPrefix:`hl-`}),$n={name:`token-style-normalizer`,tokens(e){for(let t of e)for(let e of t){if(e.htmlStyle!=null)continue;let t={};e.color!=null&&(t.color=e.color),e.bgColor!=null&&(t[`background-color`]=e.bgColor),e.fontStyle!=null&&e.fontStyle!==0&&(e.fontStyle&1&&(t[`font-style`]=`italic`),e.fontStyle&2&&(t[`font-weight`]=`bold`),e.fontStyle&4&&(t[`text-decoration`]=`underline`)),Object.keys(t).length>0&&(e.htmlStyle=t)}}};function er(e){return`--${e===`token`?`diffs-token`:`diffs`}-`}var tr=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,nr=/^0(?:\.0+)?%?$/;function rr(e){let t=e.indexOf(`(`);if(t<=0||!e.endsWith(`)`))return;let n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;let r=e.slice(t+1,-1).trim();if(r.length===0)return;let i=r.lastIndexOf(`/`);if(i!==-1)return r.slice(i+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){let e=r.split(`,`);if(e.length===4)return e[3]?.trim()}}function ir(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;let n=t[1],r,i=1;return n.length===3?r=n.split(``).map(e=>e+e).join(``):n.length===6?r=n:(r=n.slice(0,6),i=parseInt(n.slice(6,8),16)/255),[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),i]}function ar(e){if(e==null)return null;let t=ir(e);if(t==null)return null;let n=t[0]/255,r=t[1]/255,i=t[2]/255,a=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*a(n)+.7152*a(r)+.0722*a(i)}function or(e){if(e==null)return!1;let t=e.trim().toLowerCase();if(t===`transparent`||tr.test(t))return!0;let n=rr(t);return n!=null&&nr.test(n)}function sr(e,t,n){if(t==null||n==null)return!1;let r=ar(e),i=ar(t),a=ar(n);return r==null||i==null||a==null?!1:Math.abs(r-a)<Math.abs(r-i)}var cr=new WeakMap;function lr(e){let t=cr.get(e);if(t!=null)return t;let n=e.colors??{},r={...n},i=n[`editor.background`]??e.bg,a=n[`editor.foreground`]??e.fg,o=n[`sideBar.background`]??i,s=n[`sideBar.foreground`]??a;ur(r,`editor.background`,i),ur(r,`editor.foreground`,a),ur(r,`sideBar.background`,o),ur(r,`sideBar.foreground`,s),ur(r,`input.background`,n[`input.background`]??o),ur(r,`sideBarSectionHeader.foreground`,n[`sideBarSectionHeader.foreground`]??s),ur(r,`list.activeSelectionForeground`,n[`list.activeSelectionForeground`]??s),ur(r,`gitDecoration.addedResourceForeground`,dr(n[`gitDecoration.addedResourceForeground`],n[`terminal.ansiGreen`],n[`editorGutter.addedBackground`])),ur(r,`gitDecoration.modifiedResourceForeground`,dr(n[`gitDecoration.modifiedResourceForeground`],n[`terminal.ansiBlue`],n[`editorGutter.modifiedBackground`])),ur(r,`gitDecoration.deletedResourceForeground`,dr(n[`gitDecoration.deletedResourceForeground`],n[`terminal.ansiRed`],n[`editorGutter.deletedBackground`]));let c=(or(n[`list.focusOutline`])?void 0:n[`list.focusOutline`])??(or(n.focusBorder)?void 0:n.focusBorder);c==null?delete r[`list.focusOutline`]:r[`list.focusOutline`]=c;let l=n[`list.hoverBackground`];l!=null&&(fr(l,o)||sr(l,o,s))&&delete r[`list.hoverBackground`];let u=Object.freeze({...e,colors:Object.freeze(r)});return cr.set(e,u),u}function ur(e,t,n){n!=null&&n!==``&&(e[t]=n)}function dr(...e){for(let t of e)if(t!=null&&t!==``)return t}function fr(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function pr({theme:e=L,highlighter:t,prefix:n}){let r=``;if(typeof e==`string`){let i=t.getTheme(e),a=lr(i);r+=`color:${a.fg};`,r+=`background-color:${a.bg};`,r+=`${er(`global`)}fg:${a.fg};`,r+=`${er(`global`)}bg:${a.bg};`,r+=mr(i,n)}else{let n=t.getTheme(e.dark),i=lr(n);r+=`${er(`global`)}dark:${i.fg};`,r+=`${er(`global`)}dark-bg:${i.bg};`,r+=mr(n,`dark`),n=t.getTheme(e.light),i=lr(n),r+=`${er(`global`)}light:${i.fg};`,r+=`${er(`global`)}light-bg:${i.bg};`,r+=mr(n,`light`)}return r}function mr(e,t){t=t==null?``:`${t}-`;let n=``,r=e.colors?.[`gitDecoration.addedResourceForeground`]??e.colors?.[`terminal.ansiGreen`];r!=null&&(n+=`${er(`global`)}${t}addition-color:${r};`);let i=e.colors?.[`gitDecoration.deletedResourceForeground`]??e.colors?.[`terminal.ansiRed`];i!=null&&(n+=`${er(`global`)}${t}deletion-color:${i};`);let a=e.colors?.[`gitDecoration.modifiedResourceForeground`]??e.colors?.[`terminal.ansiBlue`];return a!=null&&(n+=`${er(`global`)}${t}modified-color:${a};`),n}function hr(e){let t=e.children[0];for(;t!=null;){if(t.type===`element`&&t.tagName===`code`)return t.children;t=`children`in t?t.children[0]:null}throw console.error(e),Error(`getLineNodes: Unable to find children`)}var gr=10,_r=13,vr=4,yr=40;function br(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
|
|
22
|
+
`),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
|
|
23
|
+
`,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
|
|
24
|
+
`,o)),t.push(o),++a===vr){if(o-i<=yr){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===gr||r===_r)&&(r===_r&&n+1<e.length&&e.charCodeAt(n+1)===gr&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function xr(e){let t=br(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var Sr={forcePlainText:!1};function Cr(e,t,{theme:n=L,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:a,startingLine:o,totalLines:s,lines:c}=Sr){a?(o??=0,s??=1/0):(o=0,s=1/0);let l=o>0||s<1/0,{state:u,transformers:d}=Zn(i),f=a?`text`:e.lang??P(e.name),p=typeof n==`string`?t.getTheme(n).type:void 0,m=pr({theme:n,highlighter:t});u.lineInfo=e=>({type:`context`,lineIndex:e-1+o,lineNumber:e+o});let h=typeof n==`string`?{lang:f,theme:n,transformers:d,defaultColor:!1,cssVariablePrefix:er(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:f,themes:n,transformers:d,defaultColor:!1,cssVariablePrefix:er(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},g=hr(t.codeToHast(l?wr(c??xr(e.contents),o,s):e.contents,h)),_=l?Array(o):g;return l&&_.push(...g),{code:_,themeStyles:m,baseThemeType:p}}function wr(e,t,n){if(e.length===0)return``;let r=Math.min(t+n,e.length);return e.slice(t,r).join(``)}var Tr=`-1,-1`;function Er(e){return e?.some(e=>e.lineNumber===0)??!1}function Dr(e){let t=e[0];return t!=null&&t.length>0?t:void 0}function Or(e){return e.startingLine===0&&e.totalLines>0}function kr(e,t){return e.endsWith(`\r
|
|
25
|
+
`)?t+`\r
|
|
26
|
+
`:e.endsWith(`\r`)?t+`\r`:e.endsWith(`
|
|
27
|
+
`)?t+`
|
|
28
|
+
`:t}function Ar(e,t){return Z({tagName:`div`,children:e,properties:{"data-content":``,style:`grid-row: span ${t}`}})}function jr(e){return(e.lang??P(e.name))===`text`}function Mr(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var Nr=-1,Pr=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++Nr}`;highlighter;renderCache;computedLang=`text`;lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(e={theme:L},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=kn(e.theme??L)?ae():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}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(){let{renderCache:e,lineCache:t}=this;e?.isDirty!==!0||t==null||!Mr(t,e.file)||(e.file.contents=t.lines.join(``))}hasUnkeyedFileContentsChanged(e){let{lineCache:t}=this;return e.cacheKey==null&&t!=null&&t.file===e&&t.sourceContents!==e.contents}invalidateChangedUnkeyedFile(e){this.hasUnkeyedFileContentsChanged(e)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(e.file.cacheKey)}hydrate(e){let{options:t}=this.getRenderOptions(e),n=Fr(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!jn(t,r.options)&&(r=void 0),this.renderCache??={file:e,options:t,highlighted:!n&&!jr(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??P(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??L}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getFileRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{tokenizeMaxLineLength:e=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:e}})(),{renderCache:n}=this;return n?.result==null||!Ht(e,n.file)||!jn(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getOrCreateLineCache(e){this.invalidateChangedUnkeyedFile(e);let{lineCache:t}=this;return(t==null||!Mr(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:xr(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:r,result:i}=this.renderCache;if(i==null)return;let a=n?new Map:void 0;this.pendingStructuralRows=a;let o=this.lineCache!=null&&Mr(this.lineCache,r)?this.lineCache:void 0;for(let[t,n]of e){if(a===void 0&&o!=null&&t<o.lines.length){let e=n.map(e=>e[2]).join(``);o.lines[t]=kr(o.lines[t]??``,e)}let e={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};a===void 0?i.code[t]=e:a.set(t,e)}i.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){let t=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:n,result:r}=this.renderCache;if(r==null)return;let i=this.lineCache!=null&&Mr(this.lineCache,n)?this.lineCache.lines:xr(n.contents),a=xr(e.getText());if(i.length!==a.length){let n=Math.min(i.length,a.length),o=0;for(;o<n&&i[o]===a[o];)o++;let s=0;for(;s<n-o&&i[i.length-1-s]===a[a.length-1-s];)s++;let c=r.code;r.code=Array(a.length);for(let e=0;e<o;e++)r.code[e]=c[e];for(let e=0;e<s;e++)r.code[a.length-1-e]=c[i.length-1-e];if(t!==void 0)for(let[e,n]of t)e<a.length&&(r.code[e]=n);for(let t=o;t<a.length-s;t++)r.code[t]??={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]};for(let e=0;e<r.code.length;e++){let t=r.code[e];t?.type===`element`&&(t.properties[`data-line`]=e+1,t.properties[`data-line-index`]=e)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:n.cacheKey,file:n,sourceContents:n.contents,lines:a},this.textDocumentCache.set(n,e)}renderFile(e=this.renderCache?.file,t=R){if(e==null)return;this.invalidateChangedUnkeyedFile(e),this.renderCache?.isDirty===!0&&!Ht(e,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:n,forceHighlight:r}=this.getRenderOptions(e);this.renderCache?.isDirty===!0&&!jn(n,this.renderCache.options)&&this.clearRenderCache();let i=this.getMatchingWorkerResultCache(e,n);i!=null&&!this.hasHighlightedRenderCache(e,n)&&(this.renderCache={file:e,highlighted:!0,renderRange:void 0,...i},r=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let a=this.getOrCreateLineCache(e),o=e.contents.length>0,s=!o||jr(e)||Fr(a.length,this.getTokenizeMaxLength()),c=!Ht(e,this.renderCache.file),l=!Mn(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(s||this.renderCache.result==null||!this.renderCache.highlighted&&(c||l))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||c||l||r)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,a)),this.renderCache.renderRange=t),!s&&o&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightFileAST(this,e);else{this.computedLang=e.lang??P(e.name);let t=this.highlighter!=null&&kn(n.theme),i=this.highlighter!=null&&Dn(this.computedLang),a=!s&&i;if(this.highlighter!=null&&t&&(r||s||!this.renderCache.highlighted&&a||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,s||!i);this.renderCache={file:e,options:n,highlighted:a,result:t,renderRange:void 0}}(!t||!s&&!i)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,t,n,!s)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=R){let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=Fr(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??P(e.name);let n=this.highlighter!=null&&An(On(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&Dn(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:Cr(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=Kt(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=Or(t)?Dr(this.lineAnnotations):void 0;d!=null&&(c.children.push(Jt(`context`,`annotation`,1)),s.push(Nn({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>Vn(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(qt(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(Jt(`context`,`annotation`,1)),s.push(Nn({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>Vn(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:t=`default`,stickyHeader:n=!1}=this.options;return Fn({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return N(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(Z({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=Kt();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,Ar(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return N(t?Z({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await re(Bn(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){if(this.renderCache==null)return;let i=!Ht(e,this.renderCache.file)||!this.renderCache.highlighted||!jn(n,this.renderCache.options);this.renderCache={file:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(!(n==null||!jn(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&Ht(e,n.file)&&jn(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return Rn({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function Fr(e,t){return e>t}var Ir=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
29
|
+
<symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
|
|
30
|
+
<path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
|
|
31
|
+
</symbol>
|
|
32
|
+
<symbol id="diffs-icon-brand-github" viewBox="0 0 16 16">
|
|
33
|
+
<path d="M8 0c4.42 0 8 3.58 8 8a8.01 8.01 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27s-1.36.09-2 .27c-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8"/>
|
|
34
|
+
</symbol>
|
|
35
|
+
<symbol id="diffs-icon-chevron" viewBox="0 0 16 16">
|
|
36
|
+
<path d="M1.47 4.47a.75.75 0 0 1 1.06 0L8 9.94l5.47-5.47a.75.75 0 1 1 1.06 1.06l-6 6a.75.75 0 0 1-1.06 0l-6-6a.75.75 0 0 1 0-1.06"/>
|
|
37
|
+
</symbol>
|
|
38
|
+
<symbol id="diffs-icon-chevrons-narrow" viewBox="0 0 10 16">
|
|
39
|
+
<path d="M4.47 2.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1-1.06 1.06L5 3.81 2.28 6.53a.75.75 0 0 1-1.06-1.06zM1.22 9.47a.75.75 0 0 1 1.06 0L5 12.19l2.72-2.72a.75.75 0 0 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0l-3.25-3.25a.75.75 0 0 1 0-1.06"/>
|
|
40
|
+
</symbol>
|
|
41
|
+
<symbol id="diffs-icon-diff-split" viewBox="0 0 16 16">
|
|
42
|
+
<path d="M14 0H8.5v16H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2m-1.5 6.5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0"/><path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h5.5V0zm.5 7.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1" opacity=".3"/>
|
|
43
|
+
</symbol>
|
|
44
|
+
<symbol id="diffs-icon-diff-unified" viewBox="0 0 16 16">
|
|
45
|
+
<path fill-rule="evenodd" d="M16 14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V8.5h16zm-8-4a.5.5 0 0 0-.5.5v1h-1a.5.5 0 0 0 0 1h1v1a.5.5 0 0 0 1 0v-1h1a.5.5 0 0 0 0-1h-1v-1A.5.5 0 0 0 8 10" clip-rule="evenodd"/><path fill-rule="evenodd" d="M14 0a2 2 0 0 1 2 2v5.5H0V2a2 2 0 0 1 2-2zM6.5 3.5a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" clip-rule="evenodd" opacity=".4"/>
|
|
46
|
+
</symbol>
|
|
47
|
+
<symbol id="diffs-icon-expand" viewBox="0 0 16 16">
|
|
48
|
+
<path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06"/>
|
|
49
|
+
</symbol>
|
|
50
|
+
<symbol id="diffs-icon-expand-all" viewBox="0 0 16 16">
|
|
51
|
+
<path d="M11.47 9.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06L8 12.94zM7.526 1.418a.75.75 0 0 1 1.004.052l4 4a.75.75 0 1 1-1.06 1.06L8 3.06 4.53 6.53a.75.75 0 1 1-1.06-1.06l4-4z"/>
|
|
52
|
+
</symbol>
|
|
53
|
+
<symbol id="diffs-icon-file-code" viewBox="0 0 16 16">
|
|
54
|
+
<path d="M10.75 0c.199 0 .39.08.53.22l3.5 3.5c.14.14.22.331.22.53v9A2.75 2.75 0 0 1 12.25 16h-8.5A2.75 2.75 0 0 1 1 13.25V2.75A2.75 2.75 0 0 1 3.75 0zm-7 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h8.5c.69 0 1.25-.56 1.25-1.25V5h-1.25A2.25 2.25 0 0 1 10 2.75V1.5z"/><path d="M7.248 6.19a.75.75 0 0 1 .063 1.058L5.753 9l1.558 1.752a.75.75 0 0 1-1.122.996l-2-2.25a.75.75 0 0 1 0-.996l2-2.25a.75.75 0 0 1 1.06-.063M8.69 7.248a.75.75 0 1 1 1.12-.996l2 2.25a.75.75 0 0 1 0 .996l-2 2.25a.75.75 0 1 1-1.12-.996L10.245 9z"/>
|
|
55
|
+
</symbol>
|
|
56
|
+
<symbol id="diffs-icon-plus" viewBox="0 0 16 16">
|
|
57
|
+
<path d="M8 3a.75.75 0 0 1 .75.75v3.5h3.5a.75.75 0 0 1 0 1.5h-3.5v3.5a.75.75 0 0 1-1.5 0v-3.5h-3.5a.75.75 0 0 1 0-1.5h3.5v-3.5A.75.75 0 0 1 8 3"/>
|
|
58
|
+
</symbol>
|
|
59
|
+
<symbol id="diffs-icon-symbol-added" viewBox="0 0 16 16">
|
|
60
|
+
<path d="M8 4a.75.75 0 0 1 .75.75v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5A.75.75 0 0 1 8 4"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
|
|
61
|
+
</symbol>
|
|
62
|
+
<symbol id="diffs-icon-symbol-deleted" viewBox="0 0 16 16">
|
|
63
|
+
<path d="M4 8a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 4 8"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
|
|
64
|
+
</symbol>
|
|
65
|
+
<symbol id="diffs-icon-symbol-diffstat" viewBox="0 0 16 16">
|
|
66
|
+
<path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.75 4.296a.75.75 0 0 0-1.5 0V6.25h-2a.75.75 0 0 0 0 1.5h2v1.5h1.5v-1.5h2a.75.75 0 0 0 0-1.5h-2zM5.25 10a.75.75 0 0 0 0 1.5h5.5a.75.75 0 0 0 0-1.5z"/>
|
|
67
|
+
</symbol>
|
|
68
|
+
<symbol id="diffs-icon-symbol-ignored" viewBox="0 0 16 16">
|
|
69
|
+
<path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m11.53-2.47a.75.75 0 0 0-1.06-1.06l-6 6a.75.75 0 1 0 1.06 1.06z"/>
|
|
70
|
+
</symbol>
|
|
71
|
+
<symbol id="diffs-icon-symbol-modified" viewBox="0 0 16 16">
|
|
72
|
+
<path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m8 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6"/>
|
|
73
|
+
</symbol>
|
|
74
|
+
<symbol id="diffs-icon-symbol-moved" viewBox="0 0 16 16">
|
|
75
|
+
<path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.495 4.695a.75.75 0 0 0-.05 1.06L10.486 8l-2.041 2.246a.75.75 0 0 0 1.11 1.008l2.5-2.75a.75.75 0 0 0 0-1.008l-2.5-2.75a.75.75 0 0 0-1.06-.051m-4 0a.75.75 0 0 0-.05 1.06l2.044 2.248-1.796 1.995a.75.75 0 0 0 1.114 1.004l2.25-2.5a.75.75 0 0 0-.002-1.007l-2.5-2.75a.75.75 0 0 0-1.06-.05"/>
|
|
76
|
+
</symbol>
|
|
77
|
+
<symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
|
|
78
|
+
<path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
|
|
79
|
+
</symbol>
|
|
80
|
+
</svg>`;function Lr(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function Rr(e,t){return e==null||t==null?e===t:Br(e.customProperties,t.customProperties)&&e.type===t.type&&e.diffIndicators===t.diffIndicators&&e.disableBackground===t.disableBackground&&e.disableLineNumbers===t.disableLineNumbers&&e.overflow===t.overflow&&e.split===t.split&&e.totalLines===t.totalLines}var zr={};function Br(e=zr,t=zr){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function Vr(e){let t=document.createElement(`div`);return t.dataset.annotationSlot=``,t.slot=e,t.style.whiteSpace=`normal`,t}function Hr(){let e=document.createElement(`div`);return e.slot=`gutter-utility-slot`,e.style.position=`absolute`,e.style.top=`0`,e.style.bottom=`0`,e.style.textAlign=`center`,e.style.whiteSpace=`normal`,e.style.touchAction=`none`,e}function Ur(){let e=document.createElement(`style`);return e.setAttribute(Ce,``),e}var Wr=`@layer base {
|
|
81
|
+
:host {
|
|
82
|
+
--diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
|
|
83
|
+
"Courier New", monospace;
|
|
84
|
+
--diffs-header-font-fallback: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
|
|
85
|
+
"Noto Sans", "Liberation Sans", Arial, sans-serif;
|
|
86
|
+
--diffs-mixer: light-dark(#000, #fff);
|
|
87
|
+
--diffs-gap-fallback: 8px;
|
|
88
|
+
--diffs-scrollbar-gutter-fallback: 6px;
|
|
89
|
+
--diffs-scrollbar-gutter: var(--diffs-scrollbar-gutter-override, var(--diffs-scrollbar-gutter-measured, var(--diffs-scrollbar-gutter-fallback)));
|
|
90
|
+
--diffs-added-light: #0dbe4e;
|
|
91
|
+
--diffs-added-dark: #5ecc71;
|
|
92
|
+
--diffs-modified-light: #009fff;
|
|
93
|
+
--diffs-modified-dark: #69b1ff;
|
|
94
|
+
--diffs-deleted-light: #ff2e3f;
|
|
95
|
+
--diffs-deleted-dark: #ff6762;
|
|
96
|
+
--diffs-warning-light: #d5a910;
|
|
97
|
+
--diffs-warning-dark: #ffd452;
|
|
98
|
+
color-scheme: light dark;
|
|
99
|
+
font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
|
|
100
|
+
font-size: var(--diffs-font-size, 13px);
|
|
101
|
+
line-height: var(--diffs-line-height, 20px);
|
|
102
|
+
font-feature-settings: var(--diffs-font-features);
|
|
103
|
+
--diffs-bg: light-dark(var(--diffs-light-bg, #fff), var(--diffs-dark-bg, #000));
|
|
104
|
+
--diffs-bg-buffer: var(--diffs-bg-buffer-override, light-dark(color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer))));
|
|
105
|
+
--diffs-bg-context: var(--diffs-bg-context-override, light-dark(color-mix(in lab, var(--diffs-bg) 98.5%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 92.5%, var(--diffs-mixer))));
|
|
106
|
+
--diffs-bg-context-gutter: var(--diffs-bg-context-gutter-override, light-dark(color-mix(in lab, var(--diffs-bg-context) 90%, var(--diffs-bg)), color-mix(in lab, var(--diffs-bg-context) 45%, var(--diffs-bg))));
|
|
107
|
+
--diffs-bg-separator: var(--diffs-bg-separator-override, light-dark(color-mix(in lab, var(--diffs-bg) 96%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 85%, var(--diffs-mixer))));
|
|
108
|
+
--diffs-fg: light-dark(var(--diffs-light, #000), var(--diffs-dark, #fff));
|
|
109
|
+
--diffs-fg-number: var(--diffs-fg-number-override, light-dark(color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg)), color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg))));
|
|
110
|
+
--diffs-fg-conflict-marker: var(--diffs-fg-conflict-marker-override, var(--diffs-fg-number));
|
|
111
|
+
--diffs-deletion-base: var(--diffs-deletion-color-override, light-dark(var(--diffs-light-deletion-color, var(--diffs-deletion-color, var(--diffs-deleted-light))), var(--diffs-dark-deletion-color, var(--diffs-deletion-color, var(--diffs-deleted-dark)))));
|
|
112
|
+
--diffs-addition-base: var(--diffs-addition-color-override, light-dark(var(--diffs-light-addition-color, var(--diffs-addition-color, var(--diffs-added-light))), var(--diffs-dark-addition-color, var(--diffs-addition-color, var(--diffs-added-dark)))));
|
|
113
|
+
--diffs-modified-base: var(--diffs-modified-color-override, light-dark(var(--diffs-light-modified-color, var(--diffs-modified-color, var(--diffs-modified-light))), var(--diffs-dark-modified-color, var(--diffs-modified-color, var(--diffs-modified-dark)))));
|
|
114
|
+
--diffs-bg-deletion: var(--diffs-bg-deletion-override, light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-deletion-base)), color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-deletion-base))));
|
|
115
|
+
--diffs-bg-deletion-emphasis: var(--diffs-bg-deletion-emphasis-override, light-dark(rgb(from var(--diffs-deletion-base) r g b / .15), rgb(from var(--diffs-deletion-base) r g b / .2)));
|
|
116
|
+
--diffs-bg-addition: var(--diffs-bg-addition-override, light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-addition-base)), color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-addition-base))));
|
|
117
|
+
--diffs-bg-addition-emphasis: var(--diffs-bg-addition-emphasis-override, light-dark(rgb(from var(--diffs-addition-base) r g b / .15), rgb(from var(--diffs-addition-base) r g b / .2)));
|
|
118
|
+
--diffs-selection-base: var(--diffs-modified-base);
|
|
119
|
+
--diffs-selection-number-fg: light-dark(color-mix(in lab, var(--diffs-selection-base) 65%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-selection-base) 75%, var(--diffs-mixer)));
|
|
120
|
+
background-color: var(--diffs-bg);
|
|
121
|
+
color: var(--diffs-fg);
|
|
122
|
+
display: block;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
pre, code, [data-error-wrapper] {
|
|
126
|
+
isolation: isolate;
|
|
127
|
+
font-family: var(--diffs-font-family, var(--diffs-font-fallback));
|
|
128
|
+
outline: none;
|
|
129
|
+
margin: 0;
|
|
130
|
+
padding: 0;
|
|
131
|
+
display: block;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
pre, code {
|
|
135
|
+
background-color: var(--diffs-bg);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
code {
|
|
139
|
+
contain: content;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
input, button {
|
|
143
|
+
font-family: inherit;
|
|
144
|
+
font-size: inherit;
|
|
145
|
+
line-height: inherit;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
*, :before, :after {
|
|
149
|
+
box-sizing: border-box;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[data-icon-sprite] {
|
|
153
|
+
display: none;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
[data-diffs-header], [data-separator] {
|
|
157
|
+
font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[data-diffs-header][data-sticky] {
|
|
161
|
+
z-index: 1;
|
|
162
|
+
background-color: var(--diffs-bg);
|
|
163
|
+
position: sticky;
|
|
164
|
+
top: 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
[data-file-info] {
|
|
168
|
+
color: var(--fg);
|
|
169
|
+
background-color: color-mix(in lab, var(--bg) 98%, var(--fg));
|
|
170
|
+
border-block: 1px solid color-mix(in lab, var(--bg) 95%, var(--fg));
|
|
171
|
+
padding: 10px;
|
|
172
|
+
font-weight: 700;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
[data-diff], [data-file] {
|
|
176
|
+
--diffs-grid-number-column-width: minmax(min-content, max-content);
|
|
177
|
+
--diffs-code-grid: var(--diffs-grid-number-column-width) 1fr;
|
|
178
|
+
|
|
179
|
+
&[data-dehydrated] {
|
|
180
|
+
--diffs-code-grid: var(--diffs-grid-number-column-width) minmax(0, 1fr);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&:hover [data-code]::-webkit-scrollbar-thumb {
|
|
184
|
+
background-color: var(--diffs-bg-context);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@supports (-webkit-touch-callout: none) {
|
|
189
|
+
:host {
|
|
190
|
+
--diffs-scrollbar-gutter-fallback: 0px;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
[data-line] span {
|
|
195
|
+
color: light-dark(var(--diffs-token-light, var(--diffs-light)), var(--diffs-token-dark, var(--diffs-dark)));
|
|
196
|
+
background-color: light-dark(var(--diffs-token-light-bg, inherit), var(--diffs-token-dark-bg, inherit));
|
|
197
|
+
font-weight: light-dark(var(--diffs-token-light-font-weight, inherit), var(--diffs-token-dark-font-weight, inherit));
|
|
198
|
+
font-style: light-dark(var(--diffs-token-light-font-style, inherit), var(--diffs-token-dark-font-style, inherit));
|
|
199
|
+
text-decoration: light-dark(var(--diffs-token-light-text-decoration, inherit), var(--diffs-token-dark-text-decoration, inherit));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
[data-line], [data-gutter-buffer], [data-column-number], [data-line-annotation], [data-no-newline], [data-merge-conflict], [data-merge-conflict-actions], [data-editor-overlay] {
|
|
203
|
+
--diffs-computed-decoration-bg: var(--diffs-bg);
|
|
204
|
+
--diffs-computed-diff-line-bg: var(--diffs-computed-decoration-bg);
|
|
205
|
+
--diffs-computed-selected-line-bg: var(--diffs-computed-diff-line-bg);
|
|
206
|
+
--diffs-computed-editor-active-line-bg: var(--diffs-computed-selected-line-bg);
|
|
207
|
+
--diffs-computed-hovered-line-bg: var(--diffs-computed-editor-active-line-bg);
|
|
208
|
+
--diffs-hover-mix-target: var(--diffs-bg-hover-override, var(--diffs-mixer));
|
|
209
|
+
--diffs-line-bg: var(--diffs-computed-hovered-line-bg);
|
|
210
|
+
color: var(--diffs-fg);
|
|
211
|
+
background-color: var(--diffs-line-bg, var(--diffs-bg));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
[data-line], [data-no-newline] {
|
|
215
|
+
&[data-decoration-bg] {
|
|
216
|
+
--mix-deco-light: 92%;
|
|
217
|
+
--mix-deco-dark: 85%;
|
|
218
|
+
|
|
219
|
+
&[data-decoration-bg-depth="2"] {
|
|
220
|
+
--mix-deco-light: 88%;
|
|
221
|
+
--mix-deco-dark: 80%;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&[data-decoration-bg-depth="3"] {
|
|
225
|
+
--mix-deco-light: 85%;
|
|
226
|
+
--mix-deco-dark: 78%;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
--diffs-hover-mix-target: var(--diffs-decoration-bg);
|
|
230
|
+
--diffs-computed-decoration-bg: light-dark(color-mix(in lab,
|
|
231
|
+
var(--diffs-bg) var(--mix-deco-light),
|
|
232
|
+
var(--diffs-decoration-bg)), color-mix(in lab,
|
|
233
|
+
var(--diffs-bg) var(--mix-deco-dark),
|
|
234
|
+
var(--diffs-decoration-bg)));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
[data-line-annotation], [data-gutter-buffer="annotation"] {
|
|
239
|
+
--diffs-annotation-bg: var(--diffs-bg-context);
|
|
240
|
+
--diffs-computed-decoration-bg: var(--diffs-annotation-bg);
|
|
241
|
+
--diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
[data-merge-conflict-actions], [data-gutter-buffer="merge-conflict-action"], [data-gutter-buffer="merge-conflict-marker-base"], [data-gutter-buffer="merge-conflict-marker-separator"], [data-merge-conflict="marker-base"], [data-merge-conflict="marker-separator"] {
|
|
245
|
+
--diffs-computed-decoration-bg: var(--diffs-bg-context);
|
|
246
|
+
--diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
[data-gutter-buffer="merge-conflict-marker-start"], [data-merge-conflict="marker-start"] {
|
|
250
|
+
--diffs-computed-decoration-bg: light-dark(color-mix(in lab,
|
|
251
|
+
var(--diffs-bg) 78%,
|
|
252
|
+
var(--conflict-bg-current-header-override, var(--diffs-addition-base))), color-mix(in lab,
|
|
253
|
+
var(--diffs-bg) 68%,
|
|
254
|
+
var(--conflict-bg-current-header-override, var(--diffs-addition-base))));
|
|
255
|
+
--diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
[data-gutter-buffer="merge-conflict-marker-end"], [data-merge-conflict="marker-end"] {
|
|
259
|
+
--diffs-computed-decoration-bg: light-dark(color-mix(in lab,
|
|
260
|
+
var(--diffs-bg) 78%,
|
|
261
|
+
var(--conflict-bg-incoming-header-override, var(--diffs-modified-base))), color-mix(in lab,
|
|
262
|
+
var(--diffs-bg) 68%,
|
|
263
|
+
var(--conflict-bg-incoming-header-override, var(--diffs-modified-base))));
|
|
264
|
+
--diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
[data-has-merge-conflict] [data-line-annotation], [data-has-merge-conflict] [data-gutter-buffer="annotation"] {
|
|
268
|
+
--diffs-computed-decoration-bg: var(--diffs-bg);
|
|
269
|
+
--diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
:where([data-background]) {
|
|
273
|
+
& [data-gutter-buffer], & [data-column-number] {
|
|
274
|
+
--mix-light: 91%;
|
|
275
|
+
--mix-dark: 85%;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
& [data-line], & [data-no-newline] {
|
|
279
|
+
--mix-light: 88%;
|
|
280
|
+
--mix-dark: 80%;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
& [data-gutter-buffer], & [data-column-number], & [data-line], & [data-no-newline] {
|
|
284
|
+
--diffs-diff-line-mix-target: var(--diffs-bg);
|
|
285
|
+
|
|
286
|
+
&[data-line-type="change-deletion"] {
|
|
287
|
+
--diffs-diff-line-mix-target: var(--diffs-bg-deletion-override, var(--diffs-deletion-base));
|
|
288
|
+
--diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
|
|
289
|
+
|
|
290
|
+
&:where([data-gutter-buffer], [data-column-number]) {
|
|
291
|
+
color: var(--diffs-fg-number-deletion-override, var(--diffs-deletion-base));
|
|
292
|
+
--diffs-diff-line-mix-target: var(--diffs-bg-deletion-number-override, var(--diffs-deletion-base));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
--diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
|
|
296
|
+
var(--diffs-computed-decoration-bg) var(--mix-light),
|
|
297
|
+
var(--diffs-diff-line-mix-target)), color-mix(in lab,
|
|
298
|
+
var(--diffs-computed-decoration-bg) var(--mix-dark),
|
|
299
|
+
var(--diffs-diff-line-mix-target)));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
&[data-line-type="change-addition"] {
|
|
303
|
+
--diffs-diff-line-mix-target: var(--diffs-bg-addition-override, var(--diffs-addition-base));
|
|
304
|
+
--diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
|
|
305
|
+
|
|
306
|
+
&:where([data-gutter-buffer], [data-column-number]) {
|
|
307
|
+
color: var(--diffs-fg-number-addition-override, var(--diffs-addition-base));
|
|
308
|
+
--diffs-diff-line-mix-target: var(--diffs-bg-addition-number-override, var(--diffs-addition-base));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
--diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
|
|
312
|
+
var(--diffs-computed-decoration-bg) var(--mix-light),
|
|
313
|
+
var(--diffs-diff-line-mix-target)), color-mix(in lab,
|
|
314
|
+
var(--diffs-computed-decoration-bg) var(--mix-dark),
|
|
315
|
+
var(--diffs-diff-line-mix-target)));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
&[data-merge-conflict="current"] {
|
|
319
|
+
--diffs-diff-line-mix-target: var(--conflict-bg-current-override, var(--diffs-addition-base));
|
|
320
|
+
--diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
|
|
321
|
+
|
|
322
|
+
&:where([data-gutter-buffer], [data-column-number]) {
|
|
323
|
+
color: var(--diffs-fg-number-addition-override, var(--diffs-addition-base));
|
|
324
|
+
--diffs-diff-line-mix-target: var(--conflict-bg-current-number-override, var(--diffs-addition-base));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
--diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
|
|
328
|
+
var(--diffs-computed-decoration-bg) var(--mix-light),
|
|
329
|
+
var(--diffs-diff-line-mix-target)), color-mix(in lab,
|
|
330
|
+
var(--diffs-computed-decoration-bg) var(--mix-dark),
|
|
331
|
+
var(--diffs-diff-line-mix-target)));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
&[data-merge-conflict="incoming"] {
|
|
335
|
+
--diffs-diff-line-mix-target: var(--conflict-bg-incoming-override, var(--diffs-modified-base));
|
|
336
|
+
--diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
|
|
337
|
+
|
|
338
|
+
&:where([data-gutter-buffer], [data-column-number]) {
|
|
339
|
+
color: var(--diffs-modified-base);
|
|
340
|
+
--diffs-diff-line-mix-target: var(--conflict-bg-incoming-number-override, var(--diffs-modified-base));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
--diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
|
|
344
|
+
var(--diffs-computed-decoration-bg) var(--mix-light),
|
|
345
|
+
var(--diffs-diff-line-mix-target)), color-mix(in lab,
|
|
346
|
+
var(--diffs-computed-decoration-bg) var(--mix-dark),
|
|
347
|
+
var(--diffs-diff-line-mix-target)));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
[data-gutter-buffer], [data-column-number], [data-line], [data-line-annotation], [data-merge-conflict], [data-merge-conflict-actions], [data-no-newline], [data-editor-overlay] {
|
|
353
|
+
--diffs-selection-mix-target: var(--diffs-bg-selection-override, var(--diffs-selection-base));
|
|
354
|
+
--diffs-selection-emphasis-mix-target: var(--diffs-selection-mix-target);
|
|
355
|
+
|
|
356
|
+
&:where([data-editor-overlay]), &:where([data-line], [data-line-annotation], [data-merge-conflict], [data-merge-conflict-actions], [data-no-newline])[data-selected-line] {
|
|
357
|
+
--mix-selection-light: 82%;
|
|
358
|
+
--mix-selection-dark: 75%;
|
|
359
|
+
--diffs-hover-mix-target: var(--diffs-selection-mix-target);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
&:where([data-gutter-buffer][data-selected-line], [data-column-number]:is([data-selected-line], [data-editor-active-line])) {
|
|
363
|
+
--mix-selection-light: 75%;
|
|
364
|
+
--mix-selection-dark: 60%;
|
|
365
|
+
--diffs-selection-mix-target: var(--diffs-bg-selection-number-override, var(--diffs-selection-base));
|
|
366
|
+
--diffs-hover-mix-target: var(--diffs-selection-mix-target);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
&:where([data-line][data-selected-line]):is([data-line-type="change-addition"], [data-line-type="change-deletion"]) {
|
|
370
|
+
--diffs-selection-emphasis-mix-target: light-dark(color-mix(in lab,
|
|
371
|
+
var(--diffs-diff-line-mix-target, var(--diffs-selection-mix-target))
|
|
372
|
+
var(--mix-selection-light),
|
|
373
|
+
var(--diffs-selection-mix-target)), var(--diffs-selection-mix-target));
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
&:where([data-editor-overlay]), &[data-selected-line] {
|
|
377
|
+
--diffs-computed-selected-line-bg: light-dark(color-mix(in lab,
|
|
378
|
+
var(--diffs-computed-diff-line-bg) var(--mix-selection-light),
|
|
379
|
+
var(--diffs-selection-mix-target)), color-mix(in lab,
|
|
380
|
+
var(--diffs-computed-diff-line-bg) var(--mix-selection-dark),
|
|
381
|
+
var(--diffs-selection-mix-target)));
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
[data-line][data-editor-active-line], [data-column-number][data-editor-active-line] {
|
|
386
|
+
--diffs-computed-editor-active-line-bg: color-mix(in lab,
|
|
387
|
+
var(--diffs-computed-selected-line-bg)
|
|
388
|
+
var(--diffs-editor-active-line-source-mix, 100%),
|
|
389
|
+
var(--diffs-selection-emphasis-mix-target));
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
@media (pointer: fine) {
|
|
393
|
+
[data-line][data-hovered], [data-gutter-buffer][data-hovered], [data-column-number][data-hovered], [data-line-annotation][data-hovered], [data-no-newline][data-hovered], [data-merge-conflict][data-hovered], [data-merge-conflict-actions][data-hovered], [data-editor-overlay][data-hovered] {
|
|
394
|
+
--diffs-computed-hovered-line-bg: light-dark(color-mix(in lab,
|
|
395
|
+
var(--diffs-computed-editor-active-line-bg) 97%,
|
|
396
|
+
var(--diffs-hover-mix-target)), color-mix(in lab,
|
|
397
|
+
var(--diffs-computed-editor-active-line-bg) 91%,
|
|
398
|
+
var(--diffs-hover-mix-target)));
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
[data-gutter-buffer][data-selected-line], [data-column-number]:is([data-selected-line], [data-editor-active-line]) {
|
|
403
|
+
color: var(--diffs-selection-number-fg);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
[data-no-newline] {
|
|
407
|
+
user-select: none;
|
|
408
|
+
|
|
409
|
+
& span {
|
|
410
|
+
opacity: .6;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
[data-diff-type="split"][data-overflow="scroll"] {
|
|
415
|
+
grid-template-columns: 1fr 1fr;
|
|
416
|
+
display: grid;
|
|
417
|
+
|
|
418
|
+
& [data-additions] {
|
|
419
|
+
border-left: 1px solid var(--diffs-bg);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
& [data-deletions] {
|
|
423
|
+
border-right: 1px solid var(--diffs-bg);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
[data-code] {
|
|
428
|
+
grid-auto-flow: dense;
|
|
429
|
+
grid-template-columns: var(--diffs-code-grid);
|
|
430
|
+
overflow: var(--diffs-overflow-override, scroll) clip;
|
|
431
|
+
overscroll-behavior-x: none;
|
|
432
|
+
tab-size: var(--diffs-tab-size, 2);
|
|
433
|
+
padding-top: var(--diffs-gap-block, var(--diffs-gap-fallback));
|
|
434
|
+
padding-bottom: max(0px,
|
|
435
|
+
calc(var(--diffs-gap-block, var(--diffs-gap-fallback)) -
|
|
436
|
+
var(--diffs-scrollbar-gutter)));
|
|
437
|
+
scrollbar-gutter: stable;
|
|
438
|
+
align-self: flex-start;
|
|
439
|
+
display: grid;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
[data-diffs-scrollbar-measure] {
|
|
443
|
+
opacity: 0;
|
|
444
|
+
pointer-events: none;
|
|
445
|
+
scrollbar-gutter: auto;
|
|
446
|
+
grid-template-columns: none;
|
|
447
|
+
width: 100px;
|
|
448
|
+
height: 100px;
|
|
449
|
+
padding: 0;
|
|
450
|
+
position: absolute;
|
|
451
|
+
top: -200px;
|
|
452
|
+
left: -200px;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
[data-container-size] {
|
|
456
|
+
container-type: inline-size;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
[data-code]::-webkit-scrollbar {
|
|
460
|
+
width: 0;
|
|
461
|
+
height: var(--diffs-scrollbar-gutter);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
[data-code]::-webkit-scrollbar-track {
|
|
465
|
+
background: none;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
[data-code]::-webkit-scrollbar-thumb {
|
|
469
|
+
background-color: #0000;
|
|
470
|
+
background-clip: content-box;
|
|
471
|
+
border: 1px solid #0000;
|
|
472
|
+
border-radius: 3px;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
[data-code]::-webkit-scrollbar-corner {
|
|
476
|
+
background-color: #0000;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
@supports ((-moz-appearance: none)) {
|
|
480
|
+
[data-code] {
|
|
481
|
+
scrollbar-width: thin;
|
|
482
|
+
scrollbar-color: var(--diffs-bg-context) transparent;
|
|
483
|
+
padding-bottom: var(--diffs-gap-block, var(--diffs-gap-fallback));
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
[data-diffs-header] ~ [data-diff], [data-diffs-header] ~ [data-file] {
|
|
488
|
+
& [data-code], &[data-overflow="wrap"], &[data-dehydrated][data-diff-type="split"][data-overflow="scroll"] {
|
|
489
|
+
padding-top: 0;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
[data-gutter] {
|
|
494
|
+
grid-template-rows: subgrid;
|
|
495
|
+
grid-template-columns: subgrid;
|
|
496
|
+
z-index: 3;
|
|
497
|
+
background-color: var(--diffs-bg);
|
|
498
|
+
grid-column: 1;
|
|
499
|
+
display: grid;
|
|
500
|
+
position: relative;
|
|
501
|
+
|
|
502
|
+
& [data-gutter-buffer], & [data-column-number] {
|
|
503
|
+
border-right: var(--diffs-gap-style, 2px solid var(--diffs-bg));
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
[data-content] {
|
|
508
|
+
grid-template-rows: subgrid;
|
|
509
|
+
grid-template-columns: subgrid;
|
|
510
|
+
background-color: var(--diffs-bg);
|
|
511
|
+
grid-column: 2;
|
|
512
|
+
min-width: 0;
|
|
513
|
+
display: grid;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
[data-diff-type="split"][data-overflow="wrap"], [data-dehydrated][data-diff-type="split"][data-overflow="scroll"] {
|
|
517
|
+
grid-auto-flow: dense;
|
|
518
|
+
grid-template-columns: repeat(2, var(--diffs-code-grid));
|
|
519
|
+
padding-block: var(--diffs-gap-block, var(--diffs-gap-fallback));
|
|
520
|
+
display: grid;
|
|
521
|
+
|
|
522
|
+
& [data-code] {
|
|
523
|
+
display: contents;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
& [data-deletions] {
|
|
527
|
+
& [data-gutter] {
|
|
528
|
+
grid-column: 1;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
& [data-content] {
|
|
532
|
+
border-right: 1px solid var(--diffs-bg);
|
|
533
|
+
grid-column: 2;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
& [data-additions] {
|
|
538
|
+
& [data-gutter] {
|
|
539
|
+
border-left: 1px solid var(--diffs-bg);
|
|
540
|
+
grid-column: 3;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
& [data-content] {
|
|
544
|
+
grid-column: 4;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
[data-dehydrated][data-diff-type="split"][data-overflow="scroll"] [data-content] {
|
|
550
|
+
overflow: clip;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
[data-overflow="scroll"] [data-gutter] {
|
|
554
|
+
position: sticky;
|
|
555
|
+
left: 0;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
[data-interactive-lines] [data-line] {
|
|
559
|
+
cursor: pointer;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
[data-interactive-line-numbers] [data-column-number] {
|
|
563
|
+
cursor: pointer;
|
|
564
|
+
touch-action: none;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
[data-content-buffer], [data-gutter-buffer] {
|
|
568
|
+
user-select: none;
|
|
569
|
+
min-height: 1lh;
|
|
570
|
+
position: relative;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
[data-gutter-buffer] {
|
|
574
|
+
padding-left: 2ch;
|
|
575
|
+
padding-right: 1ch;
|
|
576
|
+
|
|
577
|
+
&:before {
|
|
578
|
+
content: "";
|
|
579
|
+
min-width: var(--diffs-min-number-column-width, var(--diffs-min-number-column-width-default, 3ch));
|
|
580
|
+
display: block;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
[data-gutter-buffer="annotation"] {
|
|
585
|
+
--diffs-annotation-bg: var(--diffs-bg-context-gutter);
|
|
586
|
+
min-height: 0;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
[data-gutter-buffer="buffer"] {
|
|
590
|
+
--diffs-line-bg: var(--diffs-bg-context-gutter);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
[data-content-buffer] {
|
|
594
|
+
background-position: 5px 0;
|
|
595
|
+
background-size: 8px 8px;
|
|
596
|
+
background-origin: border-box;
|
|
597
|
+
background-image: repeating-linear-gradient(-45deg,
|
|
598
|
+
transparent,
|
|
599
|
+
transparent calc(3px * 1.414),
|
|
600
|
+
var(--diffs-bg-buffer) calc(3px * 1.414),
|
|
601
|
+
var(--diffs-bg-buffer) calc(4px * 1.414));
|
|
602
|
+
grid-column: 1;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
[data-separator] {
|
|
606
|
+
box-sizing: content-box;
|
|
607
|
+
background-color: var(--diffs-bg);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
[data-separator="simple"] {
|
|
611
|
+
min-height: 4px;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
[data-separator="line-info"], [data-separator="line-info-basic"], [data-separator="metadata"], [data-separator="simple"] {
|
|
615
|
+
background-color: var(--diffs-bg-separator);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
[data-separator="line-info"], [data-separator="line-info-basic"], [data-separator="metadata"] {
|
|
619
|
+
height: 32px;
|
|
620
|
+
position: relative;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
[data-separator-wrapper] {
|
|
624
|
+
user-select: none;
|
|
625
|
+
fill: currentColor;
|
|
626
|
+
background-color: var(--diffs-bg);
|
|
627
|
+
align-items: center;
|
|
628
|
+
height: 100%;
|
|
629
|
+
display: flex;
|
|
630
|
+
position: absolute;
|
|
631
|
+
inset-inline: 0;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
[data-content] [data-separator-wrapper] {
|
|
635
|
+
display: none;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
[data-separator="metadata"] [data-separator-wrapper] {
|
|
639
|
+
background-color: var(--diffs-bg-separator);
|
|
640
|
+
height: 100%;
|
|
641
|
+
color: var(--diffs-fg-number);
|
|
642
|
+
white-space: nowrap;
|
|
643
|
+
text-overflow: ellipsis;
|
|
644
|
+
min-width: min-content;
|
|
645
|
+
padding-inline: 1ch;
|
|
646
|
+
inset-inline: 100% auto;
|
|
647
|
+
overflow: hidden;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
[data-separator="line-info"] {
|
|
651
|
+
margin-block: var(--diffs-gap-block, var(--diffs-gap-fallback));
|
|
652
|
+
|
|
653
|
+
& [data-separator-wrapper] {
|
|
654
|
+
min-width: 16px;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
[data-separator="line-info-basic"], [data-separator="metadata"] {
|
|
659
|
+
margin-block: 0;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
[data-separator="line-info"][data-separator-first] {
|
|
663
|
+
margin-top: 0;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
[data-separator="line-info"][data-separator-last] {
|
|
667
|
+
margin-bottom: 0;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
[data-expand-index] [data-separator-wrapper] {
|
|
671
|
+
grid-template-columns: 32px auto;
|
|
672
|
+
display: grid;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
[data-expand-index] [data-separator-wrapper][data-separator-multi-button] {
|
|
676
|
+
grid-template-columns: 32px 32px auto;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
[data-expand-button], [data-separator-content] {
|
|
680
|
+
background-color: var(--diffs-bg-separator);
|
|
681
|
+
flex: none;
|
|
682
|
+
align-items: center;
|
|
683
|
+
display: flex;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
[data-expand-index] [data-separator-content]:hover {
|
|
687
|
+
cursor: pointer;
|
|
688
|
+
text-decoration: underline;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
[data-expand-button] {
|
|
692
|
+
cursor: pointer;
|
|
693
|
+
min-width: 32px;
|
|
694
|
+
color: var(--diffs-fg-number);
|
|
695
|
+
border-right: 2px solid var(--diffs-bg);
|
|
696
|
+
flex-shrink: 0;
|
|
697
|
+
justify-content: center;
|
|
698
|
+
align-self: stretch;
|
|
699
|
+
|
|
700
|
+
&:hover {
|
|
701
|
+
color: var(--diffs-fg);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
&[data-expand-all-button] {
|
|
705
|
+
display: none;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
[data-expand-down] [data-icon] {
|
|
710
|
+
transform: scaleY(-1);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
[data-separator-content] {
|
|
714
|
+
height: 100%;
|
|
715
|
+
color: var(--diffs-fg-number);
|
|
716
|
+
flex: auto;
|
|
717
|
+
justify-content: flex-start;
|
|
718
|
+
padding: 0 1ch;
|
|
719
|
+
overflow: hidden;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
[data-separator="line-info"], [data-separator="line-info-basic"] {
|
|
723
|
+
& [data-separator-content] {
|
|
724
|
+
user-select: none;
|
|
725
|
+
height: 100%;
|
|
726
|
+
overflow: clip;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
[data-unmodified-lines] {
|
|
731
|
+
text-overflow: ellipsis;
|
|
732
|
+
white-space: nowrap;
|
|
733
|
+
flex: 0 auto;
|
|
734
|
+
min-width: 0;
|
|
735
|
+
display: block;
|
|
736
|
+
overflow: hidden;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
@supports (width: 1cqi) {
|
|
740
|
+
[data-unified] {
|
|
741
|
+
& [data-separator="line-info"] [data-separator-wrapper] {
|
|
742
|
+
padding-inline: var(--diffs-gap-inline, var(--diffs-gap-fallback));
|
|
743
|
+
width: 100cqi;
|
|
744
|
+
|
|
745
|
+
& [data-separator-content] {
|
|
746
|
+
border-radius: 6px;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
& [data-separator="line-info"][data-expand-index] [data-separator-wrapper] [data-separator-content] {
|
|
751
|
+
border-top-left-radius: unset;
|
|
752
|
+
border-bottom-left-radius: unset;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
[data-gutter] {
|
|
757
|
+
& [data-separator="line-info"] [data-separator-wrapper] {
|
|
758
|
+
padding-left: var(--diffs-gap-inline, var(--diffs-gap-fallback));
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
& [data-separator="line-info"] [data-separator-content] {
|
|
762
|
+
border-top-left-radius: 6px;
|
|
763
|
+
border-bottom-left-radius: 6px;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
& [data-separator="line-info"][data-expand-index] [data-separator-content] {
|
|
767
|
+
border-top-left-radius: unset;
|
|
768
|
+
border-bottom-left-radius: unset;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
[data-additions] {
|
|
773
|
+
& [data-content] [data-separator="line-info"] {
|
|
774
|
+
background-color: var(--diffs-bg);
|
|
775
|
+
|
|
776
|
+
& [data-separator-wrapper] {
|
|
777
|
+
display: none;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
& [data-gutter] [data-separator="line-info"] [data-separator-wrapper] {
|
|
782
|
+
background-color: var(--diffs-bg-separator);
|
|
783
|
+
border-top-right-radius: 6px;
|
|
784
|
+
border-bottom-right-radius: 6px;
|
|
785
|
+
height: 100%;
|
|
786
|
+
display: block;
|
|
787
|
+
|
|
788
|
+
& [data-separator-content], & [data-expand-button] {
|
|
789
|
+
display: none;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
[data-overflow="scroll"] [data-additions] [data-gutter] [data-separator="line-info"] [data-separator-wrapper] {
|
|
795
|
+
width: calc(100cqi - var(--diffs-gap-inline, var(--diffs-gap-fallback)));
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
[data-overflow="wrap"] [data-additions] [data-content] [data-separator="line-info"] [data-separator-wrapper] {
|
|
799
|
+
background-color: var(--diffs-bg-separator);
|
|
800
|
+
height: 100%;
|
|
801
|
+
margin-right: var(--diffs-gap-inline, var(--diffs-gap-fallback));
|
|
802
|
+
border-top-right-radius: 6px;
|
|
803
|
+
border-bottom-right-radius: 6px;
|
|
804
|
+
display: block;
|
|
805
|
+
|
|
806
|
+
& [data-separator-content], & [data-expand-button] {
|
|
807
|
+
display: none;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
[data-separator="line-info"] [data-separator-wrapper] {
|
|
812
|
+
& [data-expand-both], & [data-expand-down], & [data-expand-up] {
|
|
813
|
+
border-top-left-radius: 6px;
|
|
814
|
+
border-bottom-left-radius: 6px;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
@media (pointer: fine) {
|
|
819
|
+
[data-separator="line-info"] [data-separator-wrapper] {
|
|
820
|
+
&[data-separator-multi-button] {
|
|
821
|
+
& [data-expand-up] {
|
|
822
|
+
border-top-left-radius: 6px;
|
|
823
|
+
border-bottom-left-radius: unset;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
& [data-expand-down] {
|
|
827
|
+
border-bottom-left-radius: 6px;
|
|
828
|
+
border-top-left-radius: unset;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
@media (pointer: coarse) {
|
|
836
|
+
[data-separator="line-info-basic"] [data-separator-wrapper][data-separator-multi-button] {
|
|
837
|
+
grid-template-columns: 34px 34px auto;
|
|
838
|
+
|
|
839
|
+
& [data-separator-content] {
|
|
840
|
+
grid-column: unset;
|
|
841
|
+
grid-row: unset;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
@supports (width: 1cqi) {
|
|
846
|
+
[data-separator="line-info"] [data-separator-wrapper] {
|
|
847
|
+
& [data-expand-both], & [data-expand-down], & [data-expand-up] {
|
|
848
|
+
border-top-left-radius: 6px;
|
|
849
|
+
border-bottom-left-radius: 6px;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
&[data-separator-multi-button] {
|
|
853
|
+
& [data-expand-up] {
|
|
854
|
+
border-top-left-radius: 6px;
|
|
855
|
+
border-bottom-left-radius: 6px;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
& [data-expand-down] {
|
|
859
|
+
border-bottom-left-radius: unset;
|
|
860
|
+
border-top-left-radius: unset;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
@media (pointer: fine) {
|
|
868
|
+
[data-separator-wrapper][data-separator-multi-button] {
|
|
869
|
+
grid-template-rows: 50% 50%;
|
|
870
|
+
display: grid;
|
|
871
|
+
|
|
872
|
+
& [data-separator-content] {
|
|
873
|
+
grid-area: 1 / 2 / -1;
|
|
874
|
+
min-width: min-content;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
& [data-expand-button] {
|
|
878
|
+
grid-column: 1;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
[data-separator="line-info"] [data-separator-wrapper], [data-separator="line-info"] [data-separator-wrapper][data-separator-multi-button] {
|
|
883
|
+
grid-template-columns: 34px auto;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
[data-separator="line-info-basic"][data-expand-index] [data-separator-wrapper] {
|
|
887
|
+
grid-template-columns: 100% auto;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
[data-separator="line-info"], [data-separator="line-info-basic"] {
|
|
891
|
+
& [data-separator-multi-button] {
|
|
892
|
+
& [data-expand-up] {
|
|
893
|
+
border-bottom: 1px solid var(--diffs-bg);
|
|
894
|
+
border-right: 2px solid var(--diffs-bg);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
& [data-expand-down] {
|
|
898
|
+
border-top: 1px solid var(--diffs-bg);
|
|
899
|
+
border-right: 2px solid var(--diffs-bg);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
[data-additions] [data-gutter] [data-separator-wrapper], [data-additions] [data-separator="line-info-basic"] [data-separator-wrapper], [data-content] [data-separator-wrapper] {
|
|
906
|
+
display: none;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
[data-line-annotation] {
|
|
910
|
+
min-height: var(--diffs-annotation-min-height, 0);
|
|
911
|
+
z-index: 2;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
[data-merge-conflict-actions] {
|
|
915
|
+
z-index: 2;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
[data-separator="custom"] {
|
|
919
|
+
grid-template-columns: subgrid;
|
|
920
|
+
display: grid;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
[data-line], [data-column-number], [data-no-newline] {
|
|
924
|
+
padding-inline: 1ch;
|
|
925
|
+
position: relative;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
[data-indicators="classic"] [data-line] {
|
|
929
|
+
padding-inline-start: 2ch;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
[data-indicators="classic"] {
|
|
933
|
+
& [data-line-type="change-addition"], & [data-line-type="change-deletion"] {
|
|
934
|
+
&[data-no-newline], &[data-line] {
|
|
935
|
+
&:before {
|
|
936
|
+
user-select: none;
|
|
937
|
+
width: 1ch;
|
|
938
|
+
height: 1lh;
|
|
939
|
+
display: inline-block;
|
|
940
|
+
position: absolute;
|
|
941
|
+
top: 0;
|
|
942
|
+
left: 0;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
& [data-line-type="change-addition"] {
|
|
948
|
+
&[data-line], &[data-no-newline] {
|
|
949
|
+
&:before {
|
|
950
|
+
content: "+";
|
|
951
|
+
color: var(--diffs-addition-base);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
& [data-line-type="change-deletion"] {
|
|
957
|
+
&[data-line], &[data-no-newline] {
|
|
958
|
+
&:before {
|
|
959
|
+
content: "-";
|
|
960
|
+
color: var(--diffs-deletion-base);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
[data-indicators="bars"] {
|
|
967
|
+
& [data-line-type="change-deletion"], & [data-line-type="change-addition"] {
|
|
968
|
+
&[data-column-number] {
|
|
969
|
+
&:before {
|
|
970
|
+
content: "";
|
|
971
|
+
user-select: none;
|
|
972
|
+
contain: strict;
|
|
973
|
+
width: 4px;
|
|
974
|
+
height: 100%;
|
|
975
|
+
display: block;
|
|
976
|
+
position: absolute;
|
|
977
|
+
top: 0;
|
|
978
|
+
left: 0;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
& [data-line-type="change-deletion"] {
|
|
984
|
+
&[data-column-number] {
|
|
985
|
+
&:before {
|
|
986
|
+
background-image: linear-gradient(0deg,
|
|
987
|
+
var(--diffs-bg-deletion) 50%,
|
|
988
|
+
var(--diffs-deletion-base) 50%);
|
|
989
|
+
background-repeat: repeat;
|
|
990
|
+
background-size: 2px 2px;
|
|
991
|
+
background-size: calc(1lh / round(1lh / 2px))
|
|
992
|
+
calc(1lh / round(1lh / 2px));
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
& [data-line-type="change-addition"] {
|
|
998
|
+
&[data-column-number] {
|
|
999
|
+
&:before {
|
|
1000
|
+
background-color: var(--diffs-addition-base);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
[data-overflow="wrap"] {
|
|
1007
|
+
& [data-line] {
|
|
1008
|
+
white-space: pre-wrap;
|
|
1009
|
+
word-break: break-word;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
& [data-annotation-content] {
|
|
1013
|
+
word-break: break-word;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
[data-overflow="scroll"] [data-line] {
|
|
1018
|
+
white-space: pre;
|
|
1019
|
+
min-height: 1lh;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
[data-column-number] {
|
|
1023
|
+
box-sizing: content-box;
|
|
1024
|
+
text-align: right;
|
|
1025
|
+
user-select: none;
|
|
1026
|
+
color: var(--diffs-fg-number);
|
|
1027
|
+
padding-left: 2ch;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
[data-line-number-content] {
|
|
1031
|
+
min-width: var(--diffs-min-number-column-width, var(--diffs-min-number-column-width-default, 3ch));
|
|
1032
|
+
z-index: 1;
|
|
1033
|
+
display: inline-block;
|
|
1034
|
+
position: relative;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
[data-disable-line-numbers] {
|
|
1038
|
+
& [data-gutter-buffer], & [data-column-number] {
|
|
1039
|
+
min-width: 4px;
|
|
1040
|
+
padding: 0;
|
|
1041
|
+
|
|
1042
|
+
&:before {
|
|
1043
|
+
min-width: 0;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
& [data-line-number-content] {
|
|
1048
|
+
display: none;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
& [data-gutter-utility-slot] {
|
|
1052
|
+
right: unset;
|
|
1053
|
+
justify-content: flex-start;
|
|
1054
|
+
left: 0;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
&[data-indicators="bars"] [data-gutter-utility-slot] {
|
|
1058
|
+
left: 6px;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
[data-file][data-disable-line-numbers] {
|
|
1063
|
+
& [data-gutter-buffer], & [data-column-number] {
|
|
1064
|
+
border-right: 0;
|
|
1065
|
+
min-width: 0;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
[data-diff-span] {
|
|
1070
|
+
box-decoration-break: clone;
|
|
1071
|
+
border-radius: 3px;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
[data-line-type="change-addition"] [data-diff-span] {
|
|
1075
|
+
background-color: var(--diffs-bg-addition-emphasis);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
[data-line-type="change-deletion"] [data-diff-span] {
|
|
1079
|
+
background-color: var(--diffs-bg-deletion-emphasis);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
[data-merge-conflict="marker-start"], [data-merge-conflict="marker-base"], [data-merge-conflict="marker-separator"], [data-merge-conflict="marker-end"] {
|
|
1083
|
+
color: var(--diffs-fg);
|
|
1084
|
+
padding-left: 1ch;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
[data-merge-conflict="marker-start"], [data-merge-conflict="marker-end"] {
|
|
1088
|
+
align-items: center;
|
|
1089
|
+
display: flex;
|
|
1090
|
+
|
|
1091
|
+
&:after {
|
|
1092
|
+
color: var(--diffs-fg-conflict-marker);
|
|
1093
|
+
font-size: .75rem;
|
|
1094
|
+
font-style: normal;
|
|
1095
|
+
line-height: 1.25rem;
|
|
1096
|
+
font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
|
|
1097
|
+
padding-left: 1ch;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
[data-merge-conflict="marker-start"]:after {
|
|
1102
|
+
content: "(Current Change)";
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
[data-merge-conflict="marker-end"]:after {
|
|
1106
|
+
content: "(Incoming Change)";
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
[data-merge-conflict-actions-content] {
|
|
1110
|
+
min-height: 1.75rem;
|
|
1111
|
+
font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
|
|
1112
|
+
color: var(--diffs-fg);
|
|
1113
|
+
align-items: center;
|
|
1114
|
+
gap: .25rem;
|
|
1115
|
+
padding-inline: .5rem;
|
|
1116
|
+
font-size: .75rem;
|
|
1117
|
+
line-height: 1.2;
|
|
1118
|
+
display: flex;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
[data-merge-conflict-action] {
|
|
1122
|
+
appearance: none;
|
|
1123
|
+
color: var(--diffs-fg-number);
|
|
1124
|
+
font: inherit;
|
|
1125
|
+
cursor: pointer;
|
|
1126
|
+
background: none;
|
|
1127
|
+
border: 0;
|
|
1128
|
+
padding: 0;
|
|
1129
|
+
font-style: normal;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
[data-merge-conflict-action]:hover {
|
|
1133
|
+
color: var(--diffs-fg);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
[data-merge-conflict-action="current"]:hover {
|
|
1137
|
+
color: var(--diffs-addition-base);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
[data-merge-conflict-action="incoming"]:hover {
|
|
1141
|
+
color: var(--diffs-modified-base);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
[data-merge-conflict-action-separator] {
|
|
1145
|
+
color: var(--diffs-fg-number);
|
|
1146
|
+
opacity: .6;
|
|
1147
|
+
user-select: none;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
[data-diffs-header="default"] {
|
|
1151
|
+
background-color: var(--diffs-bg);
|
|
1152
|
+
justify-content: space-between;
|
|
1153
|
+
align-items: center;
|
|
1154
|
+
gap: var(--diffs-gap-inline, var(--diffs-gap-fallback));
|
|
1155
|
+
min-height: calc(1lh + (var(--diffs-gap-block, var(--diffs-gap-fallback)) * 3));
|
|
1156
|
+
z-index: 2;
|
|
1157
|
+
flex-direction: row;
|
|
1158
|
+
padding-inline: 16px;
|
|
1159
|
+
display: flex;
|
|
1160
|
+
position: relative;
|
|
1161
|
+
top: 0;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
[data-header-content] {
|
|
1165
|
+
align-items: center;
|
|
1166
|
+
gap: var(--diffs-gap-inline, var(--diffs-gap-fallback));
|
|
1167
|
+
white-space: nowrap;
|
|
1168
|
+
flex-direction: row;
|
|
1169
|
+
min-width: 0;
|
|
1170
|
+
display: flex;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
[data-header-content] [data-prev-name], [data-header-content] [data-title] {
|
|
1174
|
+
text-overflow: ellipsis;
|
|
1175
|
+
white-space: nowrap;
|
|
1176
|
+
direction: rtl;
|
|
1177
|
+
min-width: 0;
|
|
1178
|
+
overflow: hidden;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
[data-prev-name] {
|
|
1182
|
+
opacity: .7;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
[data-rename-icon] {
|
|
1186
|
+
fill: currentColor;
|
|
1187
|
+
flex-grow: 0;
|
|
1188
|
+
flex-shrink: 0;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
[data-diffs-header="default"] [data-metadata] {
|
|
1192
|
+
white-space: nowrap;
|
|
1193
|
+
align-items: center;
|
|
1194
|
+
gap: 1ch;
|
|
1195
|
+
display: flex;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
[data-diffs-header="default"] [data-additions-count] {
|
|
1199
|
+
font-family: var(--diffs-font-family, var(--diffs-font-fallback));
|
|
1200
|
+
color: var(--diffs-addition-base);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
[data-diffs-header="default"] [data-deletions-count] {
|
|
1204
|
+
font-family: var(--diffs-font-family, var(--diffs-font-fallback));
|
|
1205
|
+
color: var(--diffs-deletion-base);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
[data-change-icon] {
|
|
1209
|
+
fill: currentColor;
|
|
1210
|
+
flex-shrink: 0;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
[data-change-icon="change"], [data-change-icon="rename-pure"], [data-change-icon="rename-changed"] {
|
|
1214
|
+
color: var(--diffs-modified-base);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
[data-change-icon="new"] {
|
|
1218
|
+
color: var(--diffs-addition-base);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
[data-change-icon="deleted"] {
|
|
1222
|
+
color: var(--diffs-deletion-base);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
[data-change-icon="file"] {
|
|
1226
|
+
opacity: .6;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
[data-annotation-content] {
|
|
1230
|
+
z-index: 2;
|
|
1231
|
+
isolation: isolate;
|
|
1232
|
+
white-space: normal;
|
|
1233
|
+
align-self: flex-start;
|
|
1234
|
+
min-width: 0;
|
|
1235
|
+
display: flow-root;
|
|
1236
|
+
position: relative;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
[data-overflow="scroll"] [data-annotation-content], [data-overflow="scroll"] [data-merge-conflict-actions-content] {
|
|
1240
|
+
width: var(--diffs-column-content-width, auto);
|
|
1241
|
+
left: var(--diffs-column-number-width, 0);
|
|
1242
|
+
position: sticky;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
[data-annotation-slot] {
|
|
1246
|
+
text-wrap-mode: wrap;
|
|
1247
|
+
word-break: normal;
|
|
1248
|
+
white-space-collapse: collapse;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
[data-gutter-utility-slot] {
|
|
1252
|
+
touch-action: none;
|
|
1253
|
+
justify-content: flex-end;
|
|
1254
|
+
display: flex;
|
|
1255
|
+
position: absolute;
|
|
1256
|
+
top: 0;
|
|
1257
|
+
bottom: 0;
|
|
1258
|
+
right: 0;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
[data-utility-button] {
|
|
1262
|
+
appearance: none;
|
|
1263
|
+
cursor: pointer;
|
|
1264
|
+
width: 1lh;
|
|
1265
|
+
height: 1lh;
|
|
1266
|
+
font-size: var(--diffs-font-size, 13px);
|
|
1267
|
+
line-height: var(--diffs-line-height, 20px);
|
|
1268
|
+
background-color: var(--diffs-modified-base);
|
|
1269
|
+
color: var(--diffs-bg);
|
|
1270
|
+
fill: currentColor;
|
|
1271
|
+
z-index: 4;
|
|
1272
|
+
touch-action: none;
|
|
1273
|
+
border: none;
|
|
1274
|
+
border-radius: 4px;
|
|
1275
|
+
justify-content: center;
|
|
1276
|
+
align-items: center;
|
|
1277
|
+
margin-right: calc(-1lh + 1ch);
|
|
1278
|
+
padding: 0;
|
|
1279
|
+
display: flex;
|
|
1280
|
+
position: relative;
|
|
1281
|
+
|
|
1282
|
+
&:before {
|
|
1283
|
+
content: "";
|
|
1284
|
+
display: block;
|
|
1285
|
+
position: absolute;
|
|
1286
|
+
inset: 0 0 0 -4px;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
[data-decoration-bar-stack] {
|
|
1291
|
+
pointer-events: none;
|
|
1292
|
+
isolation: isolate;
|
|
1293
|
+
z-index: 1;
|
|
1294
|
+
background-color: var(--diffs-decoration-bar-color, transparent);
|
|
1295
|
+
box-sizing: content-box;
|
|
1296
|
+
border-left: 2px solid var(--diffs-bg);
|
|
1297
|
+
border-right: 2px solid var(--diffs-bg);
|
|
1298
|
+
width: 6px;
|
|
1299
|
+
position: absolute;
|
|
1300
|
+
top: 0;
|
|
1301
|
+
bottom: 0;
|
|
1302
|
+
right: -2px;
|
|
1303
|
+
|
|
1304
|
+
[data-decoration-bar-depth="1"] & {
|
|
1305
|
+
background-color: color-mix(in lab,
|
|
1306
|
+
var(--diffs-bg) 20%,
|
|
1307
|
+
var(--diffs-decoration-bar-color, transparent));
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
[data-decoration-bar-depth="2"] & {
|
|
1311
|
+
background-color: color-mix(in lab,
|
|
1312
|
+
var(--diffs-bg) 45%,
|
|
1313
|
+
var(--diffs-decoration-bar-color, transparent));
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
[data-decoration-bar-depth="3"] & {
|
|
1317
|
+
background-color: color-mix(in lab,
|
|
1318
|
+
var(--diffs-bg) 65%,
|
|
1319
|
+
var(--diffs-decoration-bar-color, transparent));
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
[data-decoration-bar-start] & {
|
|
1323
|
+
border-top-left-radius: 5px;
|
|
1324
|
+
border-top-right-radius: 5px;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
[data-decoration-bar-end] & {
|
|
1328
|
+
z-index: 3;
|
|
1329
|
+
border-bottom-right-radius: 5px;
|
|
1330
|
+
border-bottom-left-radius: 5px;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
[data-placeholder] {
|
|
1335
|
+
contain: strict;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
[data-error-wrapper] {
|
|
1339
|
+
padding: var(--diffs-gap-block, var(--diffs-gap-fallback))
|
|
1340
|
+
var(--diffs-gap-inline, var(--diffs-gap-fallback));
|
|
1341
|
+
scrollbar-width: none;
|
|
1342
|
+
max-height: 400px;
|
|
1343
|
+
overflow: auto;
|
|
1344
|
+
|
|
1345
|
+
& [data-error-message] {
|
|
1346
|
+
color: var(--diffs-deletion-base);
|
|
1347
|
+
font-size: 18px;
|
|
1348
|
+
font-weight: bold;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
& [data-error-stack] {
|
|
1352
|
+
color: var(--diffs-fg-number);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
@layer theme, rendered, unsafe;
|
|
1358
|
+
`,Gr;function Kr(e){if(Gr!=null)return Gr;let t=e.host;if(typeof HTMLElement<`u`&&t instanceof HTMLElement&&!t.isConnected)return;let n=document.createElement(`div`);n.setAttribute(`data-code`,``),n.setAttribute(we,`true`);let r=document.createElement(`div`);return r.style.position=`relative`,r.style.width=`200%`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n),Gr=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),Gr}function qr(e){return`${Te}: ${e==null?`var(--diffs-scrollbar-gutter-fallback)`:`${e}px`};`}var Jr=`@layer base, theme, rendered, unsafe;`,Yr=RegExp(`${$r(Te)}\\s*:\\s*[^;]+;`);function Xr(e){return`${Jr}
|
|
1359
|
+
@layer unsafe {
|
|
1360
|
+
${e}
|
|
1361
|
+
}`}function Zr(e,t=`system`,n){return`${Jr}
|
|
1362
|
+
@layer rendered {
|
|
1363
|
+
:host {${t===`system`?``:`
|
|
1364
|
+
color-scheme: ${t};`}
|
|
1365
|
+
${qr(n)}
|
|
1366
|
+
${e}
|
|
1367
|
+
}
|
|
1368
|
+
}`}function Qr(e,t){let n=qr(t);return e.replace(Yr,n)}function $r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ei({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function ti(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function ni(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`)}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}function ri(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function ii(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function ai(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:ii(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function oi(e,t){let n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=``}}function si({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=ci(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function ci(){let e=document.createElement(`style`);return e.setAttribute(Se,``),e}var li=void 0;function ui(){return li??=`safari`in window&&`pushNotification`in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(Wr)),t.adoptedStyleSheets=[e]}connectedCallback(){Kr(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(fe,t)}var di=[``],fi=-1,pi=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++fi}`;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:L},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Pr(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new yn,this.interactionManager=new Qt(`file`,$t(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($t(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;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ie(this.appliedThemeCSS.theme,this.options.theme??L)}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}let{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){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n),mi(this.pre,i,this.options.collapsed)||hi(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),ti(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,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(ai(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?di:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,i=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(a,t,n,r,i)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();let 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 Error(`File.render: attempting to call render after cleaned up`);let 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:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:c=!1,themeType:l=`system`}=this.options,u=c?void 0:s,d=this.renderRange,f=this.hasThemeChanged(),p=o!=null&&(o.length>0||this.lineAnnotations.length>0)&&o!==this.lineAnnotations,m=!Ht(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!c&&!n&&Mn(u,this.renderRange)&&!m&&!p&&!f)return this.applyCachedThemeState(l);this.renderRange=u,m&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(ai(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:h=!1,disableFileHeader:g=!1}=this.options;if(g&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(l),c){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,ke);n!=null&&this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,p,m||f)||!this.applyPartialRender(d,u)){let n=this.fileRenderer.renderFile(e,u);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,u),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,a||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{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;let 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(let{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){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||jr(e))return;let n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(e=>{console.error(e)})}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(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${Vn(r)}`,a=this.annotationCache.get(i);if(a==null||!Lr(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:Vr(Vn(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=Hr();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{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??=Ur(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Xr(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??L,s=typeof o==`string`?o:{...o},c=Kr(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=si({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Zr(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Qr(this.themeCSSStyle.textContent??``,Kr(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&ui()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=ei({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let e=0;e<2;e++){let t=n.children[e],i=r[e];t.innerHTML=N(i.children),t.style.cssText=i.properties.style}else n.innerHTML=N(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?oi(t,i):i(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l)return!1;if(!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))throw Error(`File.applyPartialRender: failed to trim to overlap`);let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let 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){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let 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??(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??(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){let{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??N(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:i,renderHeaderFilenameSuffix:a,renderCustomHeader:o,renderHeaderMetadata:s}=this.options;if(o!=null){let e=o(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,xe,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=i?.(n)??void 0,r=a?.(n)??void 0,o=s?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ye,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,be,r),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,I,o),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}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:ri(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):ri(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=Ir;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let 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(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};Rr(i,this.appliedPreAttributes)||(ni(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function mi(e,t,n=!1){return!n&&e==null&&t!=null}function hi(e,t,n=!1){return e==null&&t!=null&&!n}function gi(e){return{...De,...e}}function _i(e,t){let n=vi(e,t);return t?n:e.diffHeaderHeight+n}function vi(e,t){return e.paddingTop??(t?e.spacing:0)}function yi(e){return e.paddingBottom??e.spacing}function bi(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}var xi=5e3,Si=-1;function Ci(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var wi=class extends pi{virtualizer;metrics;__id=`virtualized-file:${++Si}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=De,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=gi(e);!t&&Fe(this.metrics,n)||(this.metrics=n,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache()}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}hasLineAnnotations(){return this.lineAnnotations.some(e=>e.lineNumber>0)}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Le(t,e),r=Ci(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!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&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;let r=Er(this.lineAnnotations);if(this.renderRange!=null&&r&&Or(this.renderRange)){let t=Ti(n)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}else!r&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,e=!0);for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n,r){let i=this.syncLineAnnotations(r),a=!Ht(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),o=n?.resetFileLayoutCache===!0||a||i;n?.metrics!=null&&(this.metrics=n.metrics,o=!0);let{collapsed:s=!1}=this.options;return this.currentCollapsed!==s&&(this.currentCollapsed=s,o=!0),o&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null||e<1)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=this.fileRenderer.getLineCount(this.file)-1,i=_i(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(i+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(this.file)-1;if(i<0)return;let a=_i(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(r===`scroll`&&!this.hasLineAnnotations()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1,t=this.file){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1,overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(t),l=_i(this.metrics,i),u=yi(this.metrics);if(this.height+=l,a){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())this.height+=c*s;else for(let e=0;e<c;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(c>0&&(this.height+=u),this.fileContainer!=null&&n&&!r){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:t.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!==void 0&&this.file!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.file,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=this.file==null||!Ht(this.file,t)||this.fileRenderer.hasUnkeyedFileContentsChanged(t),{forceRenderOverride:o,isSetup:s}=this;this.forceRenderOverride=void 0;let c=this.syncLineAnnotations(r);if(c&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),t==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(s)this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,t));else{this.computeApproximateSize(!1,t);let n=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(n==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);n.connect(e,this),this.isVisible=n.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!a||!s))return this.file=t,a&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let l=this.virtualizer.getWindowSpecs(),u=this.top??0,d=this.computeRenderRangeFromWindow(t,u,l),f=super.renderPreparedFile({file:t,fileContainer:e,renderRange:d,lineAnnotations:r,forceRender:(o??n)||c||a,...i});return this.isSimpleMode()&&f&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),f}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(e,t){e%xi===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}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(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(e),l=this.height,u=_i(this.metrics,i),d=c>0?yi(this.metrics):0,{fileAnnotationHeight:f}=this.cache,p=u+f,m=Math.max(0,l-u-f-d),h=Er(this.lineAnnotations),g=t+u,_=f>0&&h&&g<r&&g+f>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};if(c<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let v=Math.ceil(Math.max(r-n,0)/s),y=Math.ceil(v/o)*o+o,b=y/o,x=(n+r)/2;if(a===`scroll`&&!this.hasLineAnnotations()){let e=t+p,i=e+m;if(!_&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};let a=Math.floor(_&&x<t+p?0:(x-(t+p))/s),h=Math.floor(a/o)-Math.floor(b/2),g=Math.ceil(c/o),v=Math.max(0,Math.min(h,g))*o,S=h<0?y+h*o:y,C=v===0?0:f+v*s,w=Math.min(S,c-v);return{startingLine:v,totalLines:S,bufferBefore:C,bufferAfter:Math.max(0,(c-v-w)*s)}}let S=b,C=[],w=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-y*s*2),o),T=t+(w?.top??p),E=w?.lineIndex??0,D,O,k,A=w?.lineIndex??0;for(let e=A;e<c;e++){let i=E%o===0,a=Math.floor(E/o);if(i&&(C[a]=T-(t+p),k!=null)){if(k<=0)break;k--}let s=this.getLineHeight(e,!1);T>n-s&&T<r&&(D??=a),T+s>x&&(O??=a),k==null&&T>=r&&i&&(k=S),E++,T+=s}if(D==null){if(_)D=0,O=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d}}O??=D;let j=Math.round(O-b/2),ee=Math.max(0,Math.ceil(c/o)-b),M=Math.max(0,Math.min(j,ee)),te=M*o,N=j<0?y+j*o:y,ne=C[M]??0,re=te===0?0:f+ne,P=M+N/o,ie=P<C.length?m-C[P]:m-(T-t-p);return{startingLine:te,totalLines:N,bufferBefore:re,bufferAfter:Math.max(0,ie)}}};function Ti(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===Tr&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}function Ei(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function Di(e){return{...e,hunks:e.hunks.map(e=>({...e,hunkContent:e.hunkContent.map(e=>({...e}))})),deletionLines:[...e.deletionLines],additionLines:[...e.additionLines]}}function Oi(e){return e===``?[]:e.split(me)}function ki(e,t,n){let r=e===`clone`?Di(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return Ai(r,Mi(r,n),Ni(r,n));case`rename-pure`:{let e=Ni(r,n);Pi(r,n);let t=Oi(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Ii(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function Ai(e,t,n){let r=Oi(t.contents),i=Oi(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=ji(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Ii(e,t,n),e}function ji(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent){if(e.type===`context`){p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines;continue}p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions}let m=Math.max(W(t.additionStart,t.additionCount)-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=G(t.additionStart,t.additionCount)}if(a.length>0){let e=a[a.length-1],i=G(e.additionStart,e.additionCount),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Mi(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Ni(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Pi(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function Fi(e,t,n){return e.cacheKey==null?Li(t,n):`${e.cacheKey}:hydrated`}function Ii(e,t,n){let r=Fi(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Li(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?`${e.cacheKey}:${t.cacheKey}`:void 0:e?.cacheKey??t?.cacheKey}var Ri=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function zi(e,t){return Ie(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function Bi(e){return Z({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Vi(e){return Z({tagName:`div`,children:[Z({tagName:`span`,children:[Ut(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function Hi(e){return Z({tagName:`div`,children:[Wt({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{role:`button`,"data-expand-button":``,"data-expand-both":e===`both`?``:void 0,"data-expand-up":e===`up`?``:void 0,"data-expand-down":e===`down`?``:void 0}})}function Ui({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(Z({tagName:`div`,children:[Ut(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(Hi(`up`)),s++),o||(e.push(Hi(`down`)),s++)):(e.push(Hi(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(Z({tagName:`div`,children:[Z({tagName:`span`,children:[Ut(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(Z({tagName:`div`,children:[Ut(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(Z({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(Z({tagName:`slot`,properties:{name:i}})),Z({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function Wi(e,t){return`hunk-separator-${e}-${t}`}function Gi(e){let t=e.at(-1);return t==null?0:Math.max(G(t.additionStart,t.additionCount),G(t.deletionStart,t.deletionCount))}function Ki(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function qi({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function Ji({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}function Yi(e){return[W(e.additionStart,e.additionCount)+1,G(e.additionStart,e.additionCount)+1]}function Xi({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function Zi(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-G(t.additionStart,t.additionCount),r=e.deletionLines.length-G(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function Qi({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-G(n.additionStart,n.additionCount),i=e.deletionLines.length-G(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function $i({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=Qi({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function ea({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=Yi(a);if(t<o){let s=Xi({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=$i({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=Yi(a);return t<o+i.fromStart||t>=o+i.rangeSize}function ta({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=Yi(n),l=Xi({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=$i({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t);return}for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function na({type:e,metrics:t}){return t.hunkSeparatorHeight??bi(e)}function ra({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function ia({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function aa(e){return e!==`simple`&&e!==`metadata`}function oa({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!ia({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=na({type:e,metrics:t}),a=ra({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function sa({type:e,metrics:t}){if(!aa(e))return;let n=na({type:e,metrics:t}),r=ra({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function ca({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=la({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=W(r.deletionStart,r.deletionCount),s=W(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=Xi({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?$i({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(fa(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,fa(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,S=s+1,C=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===C;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(fa(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:S+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,S+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=pa(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(ma({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:S,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,S+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(fa(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:S+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function la({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=ua({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function ua({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=Xi({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?$i({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function da(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function fa(e,t,n,r,i,a){let[o,s]=da(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function pa(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function ma({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,S=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,C=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,w=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,T=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:C,unifiedLineIndex:g,splitLineIndex:v}:void 0,E=x!=null&&S!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:S,noEOFCR:w}:void 0;if(T==null&&E!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:E};if(T!=null&&E==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:void 0};if(T==null||E==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:E}}var ha={forcePlainText:!1};function ga(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=ha){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=pr({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??va();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}ca({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:!c||h,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&_a({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=ya({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function _a({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=ze(e),t=ze(t),e.length>s||t.length>s))return;let c=o===`char`?ut(e,t):Dt(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(Ji({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),Ji({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?Ji({item:e,arr:l,enableJoin:d,isLastItem:t}):Ji({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(qi({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(qi({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function va(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function ya({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=L,...l}}){let u=s??P(e.name),d=s??P(t.name),{state:f,transformers:p}=Zn(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:er(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:er(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,hr(i.codeToHast(ze(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,hr(i.codeToHast(ze(t.contents),m)))}}function ba(e,t){let n=Bt({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function xa(e,t){let n=Math.max(e,1),r=Array.from({length:n},(e,t)=>`${` `.repeat(t+1)}\n`).join(``);return r===t&&(r=Array.from({length:n},(e,t)=>`\u0000${` `.repeat(t)}\n`).join(``)),r}function Sa(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function Ca(e,t){return t.length>0&&t.length<e.deletionLines.length&&Sa(t)}function wa(e,t,n){let r=e.deletionLines.join(``),i=xa(t.length,r),a=Bt({name:e.prevName??e.name,contents:r},{name:e.name,contents:i,lang:e.lang},n);return{hunks:a.hunks,splitLineCount:a.splitLineCount,unifiedLineCount:a.unifiedLineCount,additionLines:t,deletionLines:a.deletionLines,type:a.type}}function Ta(e,t){return wa(e,[``],t)}function Ea(e,t){if(e.additionLines.length===0)return Ta(e,t);if(Ca(e,e.additionLines))return wa(e,e.additionLines,t);let n=e.additionLines,r=ba(e,t);return Oa(r,n),r}function Da(e){return e.length>1&&e.at(-1)===``}function Oa(e,t){if(!Da(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i!=null&&G(i.additionStart,i.additionCount)===r){for(let a of i.hunkContent)if(a.type===`change`&&a.additions<a.deletions&&a.additionLineIndex+a.additions===r){e.additionLines=t,a.additions+=n,i.additionCount+=n,i.additionLines+=n,Ra(e);return}}}function ka(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return Aa(e,ba(e,n));let r=Array.from(t);if(r.length===0)return Aa(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let t of r){let r=e.additionLines[t],i=e.deletionLines[t];if(r==null||i==null||ze(r)===ze(i))return Aa(e,ba(e,n))}let i=ja(e,r);if(i.size===0)return Aa(e,ba(e,n));for(let t of i)if(!Na(e,t,n))return Aa(e,ba(e,n));return Ra(e),Zi(e)?Aa(e,ba(e,n)):Aa(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Aa(e,t){return Object.assign(e,t),t}function ja(e,t){let n=new Set;for(let r of t){let t=Ma(e,r);if(t==null)return new Set;n.add(t)}return n}function Ma(e,t){for(let[n,r]of e.hunks.entries()){let e=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<e)return n}}function Na(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),a=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),o=Bt({name:e.prevName??e.name,contents:i.join(``)},{name:e.name,contents:a.join(``),lang:e.lang},{...n,context:0}),s=o.hunks[0];return s==null||o.hunks.length!==1?!1:(Fa(r,s),Pa(e,t),!0)}function Pa(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==``&&!r.endsWith(`
|
|
1369
|
+
`),n.noEOFCRDeletions=i!=null&&i!==``&&!i.endsWith(`
|
|
1370
|
+
`)}function Fa(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>Ia(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,La(e)}function Ia(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function La(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function Ra(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(W(i.additionStart,i.additionCount)-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,La(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=G(i.additionStart,i.additionCount);if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-G(r.additionStart,r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}var za=new WeakMap;function Ba(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function Va(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(r!==i||r!==a)return{start:r,deletionEnd:i,additionEnd:a}}function Ha(e,t){let n=e.hunks,r=e.additionLines,i=Ba(r),a=i===r?e:{...e,additionLines:i},o=Qa(n,Za(a,t),e.deletionLines.length),s=to(a,o);if(e.additionLines=i,e.hunks=s,e.editSessionDirty=!0,fo(e),Oa(e,r),io(n,e.hunks))return{regions:o.map(e=>e.previousSpan)}}function Ua(e,t,n,r){let i=Array.from(new Set(t)).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(i.length===0)return;let{hunks:a}=e,o,s=0;for(let t of i){for(;s<a.length;){let e=a[s];if(t<so(e)+e.additionCount)break;s++}let r=a[s],i=r==null?void 0:so(r);if(i==null||t<i||o!=null&&o!==s)return Ha(e,n);o=s}if(o!=null){if(Wa(e,i,o,r,n)){e.editSessionDirty=!0;return}return Ha(e,n)}}function Wa(e,t,n,r,i){if(r==null||i?.ignoreWhitespace===!0||i?.stripTrailingCr===!0)return!1;let a=Ga(e),o=e.hunks[n];if(o.hunkContent.some(Ka))return!1;for(let n of t){let t=r.get(n),i=e.additionLines[n];if(t==null||i==null||a.has(t)||a.has(i))return!1;let s=!1;for(let e of o.hunkContent)if(e.type===`change`&&e.additions===e.deletions&&n>=e.additionLineIndex&&n<e.additionLineIndex+e.additions){s=!0;break}if(!s)return!1}return!0}function Ga(e){let t=za.get(e);if(t?.lines===e.deletionLines)return t.set;let n=new Set(e.deletionLines);return za.set(e,{lines:e.deletionLines,set:n}),n}function Ka(e){return e?.type===`change`&&(e.additions===0||e.deletions===0)}function qa(e,t){let n=new Map,{regions:r}=t;for(let t=0;t<=r.length;t++){let i=r[t-1],a=r[t],o=t===0?e.get(0):i==null?void 0:e.get(i.lastIndex+1),s=a==null?void 0:e.get(a.firstIndex),c=o?.fromStart??0,l=s?.fromEnd??0;(c>0||l>0)&&n.set(t,{fromStart:c,fromEnd:l})}return n}function Ja(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=Xi({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=co(a),c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=$i({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=co(t)+t.deletionCount;r.push([n,n+i.fromStart])}return r}function Ya(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries()){let e=co(n);r(t,e-Math.max(n.collapsedBefore,0),e)}let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,co(i)+i.deletionCount,e.deletionLines.length),n}function Xa(e,t){return e.editSessionDirty===!0&&(e.editSessionDirty=void 0,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join(``)===``?ba(e,t):Ea(e,t)),!0)}function Za(e,t){if(Va(e.deletionLines,e.additionLines)==null)return[];let n=Bt({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t),r=[],i=0,a=0;for(let e of n.hunks){let t=e.additionCount>0?e.additionLineIndex-i:e.deletionLineIndex-a;i+=t,a+=t;for(let t of e.hunkContent){if(t.type===`context`){i+=t.lines,a+=t.lines;continue}let e=Ia(t,0,0);e.additions===0&&(e.additionLineIndex=i),e.deletions===0&&(e.deletionLineIndex=a),r.push(e),i+=e.additions,a+=e.deletions}}return r}function Qa(e,t,n){let r=e.map((e,t)=>{let n=co(e);return{deletionStart:n,deletionEnd:n+e.deletionCount,blocks:[],previousSpan:{firstIndex:t,lastIndex:t}}}),i=[],a=0;for(let e of t){let t=e.deletionLineIndex,o=t+e.deletions;for(;a<r.length&&r[a].deletionEnd<t;)i.push(r[a]),a++;let s=i.length>0&&$a(t,o,i[i.length-1])?i.pop():void 0;for(;a<r.length&&r[a].deletionStart<=o;)s=eo(s,r[a]),a++;if(s==null){let c=t,l=o;if((e.deletions===0||e.additions===0)&&n>e.deletions){let e=i[i.length-1]?.deletionEnd??0,s=r[a]?.deletionStart??n;t>e?c--:o<s&&l++}s={deletionStart:c,deletionEnd:l,blocks:[],previousSpan:void 0}}s.deletionStart=Math.min(s.deletionStart,t),s.deletionEnd=Math.max(s.deletionEnd,o),s.blocks.push(e),i.push(s)}for(;a<r.length;)i.push(r[a]),a++;return i}function $a(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function eo(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function to(e,t){let n=[],r=0,i=0;for(let a of t){let t=a.deletionStart-r;if(t<0)throw Error(`buildRegionHunks: overlapping old-side regions`);r+=t,i+=t;let o=i,s=[];for(let e of a.blocks){let t=e.deletionLineIndex-r,n=e.additionLineIndex-i;if(t<0||t!==n)throw Error(`buildRegionHunks: canonical block context mismatch`);ro(s,t,i,r),r+=t,i+=n,s.push({...e}),r+=e.deletions,i+=e.additions}let c=a.deletionEnd-r;if(c<0)throw Error(`buildRegionHunks: block exceeds its old-side region`);ro(s,c,i,r),r+=c,i+=c,n.push(no(e,{additionStart:o,additionEnd:i,deletionStart:a.deletionStart,deletionEnd:a.deletionEnd},s))}if(e.deletionLines.length-r!==e.additionLines.length-i)throw Error(`buildRegionHunks: trailing context mismatch`);return n}function no(e,t,n){let r=t.additionEnd-t.additionStart,i=t.deletionEnd-t.deletionStart,a=0,o=0;for(let e of n)e.type===`change`&&(a+=e.additions,o+=e.deletions);let s={collapsedBefore:0,additionStart:lo(t.additionStart,r),additionCount:r,additionLines:a,additionLineIndex:uo(t.additionStart,r),deletionStart:lo(t.deletionStart,i),deletionCount:i,deletionLines:o,deletionLineIndex:uo(t.deletionStart,i),hunkContent:n,hunkSpecs:`@@ -${lo(t.deletionStart,i)},${i} +${lo(t.additionStart,r)},${r} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return La(s),s}function ro(e,t,n,r){t>0&&e.push({type:`context`,lines:t,additionLineIndex:n,deletionLineIndex:r})}function io(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(co(r)!==co(i)||r.deletionCount!==i.deletionCount||so(r)!==so(i)||r.additionCount!==i.additionCount||r.splitLineCount!==i.splitLineCount||!ao(r,i))return!0}return!1}function ao(e,t){let n=oo(e),r=oo(t);for(;;){let e=n.next(),t=r.next();if(e.done===!0||t.done===!0)return e.done===t.done;if(e.value[0]!==t.value[0]||e.value[1]!==t.value[1])return!1}}function*oo(e){for(let t of e.hunkContent){if(t.type===`context`){for(let e=0;e<t.lines;e++)yield[t.deletionLineIndex+e,t.additionLineIndex+e];continue}let e=Math.max(t.deletions,t.additions);for(let n=0;n<e;n++)yield[n<t.deletions?t.deletionLineIndex+n:void 0,n<t.additions?t.additionLineIndex+n:void 0]}}function so(e){return W(e.additionStart,e.additionCount)}function co(e){return W(e.deletionStart,e.deletionCount)}function lo(e,t){return t===0?e:e+1}function uo(e,t){return t===0?e-1:e}function fo(e){Ra(e);for(let t=0;t<e.hunks.length;t++)Pa(e,t)}function po(e){let t=e.lang??P(e.name),n=e.lang??(e.prevName==null?`text`:P(e.prevName));return t===`text`&&n===`text`}var mo=-1,ho=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++mo}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;editSessionActive=!1;constructor(e={theme:L},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=kn(e.theme??L)?ae():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(){this.editSessionActive=!0;let e=this.diffCache;e!=null&&!e.isPartial&&e.additionLines.length===0&&(Object.assign(e,Ta(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache())}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){let{renderCache:e}=this;if(e==null||po(e.diff)||Ao(e.diff,this.getTokenizeMaxLength()))return Promise.resolve();let{diff:t}=e,{workerManager:n}=this;return!this.editSessionActive&&n?.isWorkingPool()===!0&&t.cacheKey!=null?(n.evictDiffFromCache(t.cacheKey),n.primeDiffHighlightCache(t).then(()=>{this.applyRefreshedResult(t,n.getDiffResultCache(t))}).catch(e=>this.onHighlightError(e))):this.asyncHighlight(t).then(e=>this.applyRefreshedResult(t,e)).catch(e=>this.onHighlightError(e))}applyRefreshedResult(e,t){if(t==null||this.renderCache==null||this.renderCache.diff!==e||this.editSessionActive)return;let{options:n}=this.getRenderOptions(e);zi(n,t.options)&&(this.renderCache={diff:e,options:t.options,highlighted:!0,result:t.result,renderRange:void 0},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??Oe}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1){if(this.renderCache==null)return!1;let{result:r,diff:i}=this.renderCache;if(r==null)return!1;if(i.isPartial)throw Error(`Could not update render cache for partial diff`);let a=r.code.additionLines,o=[],s=new Map;for(let[t,n]of e){let e=a[t]?.properties??{},r=n.map(e=>e[2]).join(``),c=t<i.additionLines.length,l=c?i.additionLines[t]??``:``,u=ze(l);c&&(i.additionLines[t]=kr(l,r),u!==r&&(o.push(t),s.set(t,l))),a[t]={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})}}let c=!1;if(o.length>0){if(this.editSessionActive&&!i.isPartial){if(!n){if(i.additionLines.length<=1&&i.additionLines.join(``)===``)Object.assign(i,Ta(i,this.options.parseDiffOptions)),this.markEditSessionPass(i),c=!0;else if(Ca(i,i.additionLines))Object.assign(i,wa(i,i.additionLines,this.options.parseDiffOptions)),this.markEditSessionPass(i),c=!0;else{let e=Ua(i,o,this.options.parseDiffOptions,s);this.applyExpansionRemap(e),c=e!=null}}}else Object.assign(i,ka(i,o,this.options.parseDiffOptions))}return r.baseThemeType=t,this.renderCache.isDirty=!0,c}applyExpansionRemap(e){e!=null&&(this.expandedHunks=qa(this.expandedHunks,e))}applyDocumentChange(e){if(this.renderCache==null)return;let{diff:t,result:n}=this.renderCache;if(n==null)return;if(t.isPartial)throw Error(`Could not apply document change for partial diff`);let{additionLines:r}=t;t.additionLines=Do(e,r),n.code.additionLines=To(r,t.additionLines,n.code.additionLines,e),t.additionLines.length<=1&&t.additionLines.join(``)===``?(Object.assign(t,Ta(t,this.options.parseDiffOptions)),n.code.additionLines[0]=Eo(0,e.getLineText(0)),this.markEditSessionPass(t)):this.editSessionActive?this.applySessionDocumentChange(t):Object.assign(t,Ea(t,this.options.parseDiffOptions)),this.renderCache.isDirty=!0}applySessionDocumentChange(e){let{parseDiffOptions:t}=this.options,n=e.additionLines;if(Ca(e,n)){Object.assign(e,wa(e,n,t)),this.markEditSessionPass(e);return}this.applyExpansionRemap(Ha(e,t))}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>Nn(e);getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=L,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=Ee,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}async initializeHighlighter(){return this.highlighter=await re(Bn(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=Ao(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!zi(t,r.options)&&(r=void 0),this.renderCache??={diff:e,highlighted:!n&&!po(e),options:t,result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLang=e.lang??P(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??L}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!Ei(e,n.diff)||!zi(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=R){if(e==null)return;let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getMatchingWorkerResultCache(e,i);o!=null&&!this.hasHighlightedRenderCache(e,i)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||po(e)||Ao(e,this.getTokenizeMaxLength()),l=!Ei(e,this.renderCache.diff),u=!Mn(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){let o=this.renderCache.result==null&&this.renderCache.highlighted&&!c&&!l&&Ki(t);o&&(this.renderCache.highlightPending=!0),!o&&(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Ki(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLang=e.lang??P(e.name);let t=this.highlighter!=null&&kn(i.theme),n=this.highlighter!=null&&Dn(this.computedLang),r=!c&&n;if(this.highlighter!=null&&t&&(a||c||!this.renderCache.highlighted&&r||this.renderCache.result==null)){let{result:t,options:i}=this.renderDiffWithHighlighter(e,this.highlighter,c||!n);this.renderCache={diff:e,options:i,highlighted:r,result:t,renderRange:void 0}}(!t||!c&&!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=R){let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return Rn({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=Ao(e,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??P(e.name);let n=this.highlighter!=null&&kn(this.getLocalHighlightTheme()),r=t||this.highlighter!=null&&Dn(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults(),a=ga(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===``&&a.code.additionLines[0]==null){let t;if(ca({diff:e,diffStyle:`both`,expandedHunks:n?!0:void 0,collapsedContextThreshold:i,callback:({additionLine:e})=>{if(e?.lineIndex===0)return t=e,!0}}),t==null)throw Error(`DiffHunksRenderer: missing empty addition line`);a.code.additionLines[0]=Eo(0,``,t.unifiedLineIndex,t.splitLineIndex)}return{result:a,options:r}}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){if(this.renderCache==null)return;let i=this.renderCache.highlightPending===!0||!this.renderCache.highlighted||!zi(this.renderCache.options,n)||!Ei(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!zi(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&Ei(e,n.diff)&&zi(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1;this.diff=e;let f=a===`unified`,p=jo(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:Kt(),deletionsGutterAST:Kt(),additionsGutterAST:Kt(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t)}}},S=Qi({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!==`unified`){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side===`additions`?(x.pushToGutter(`additions`,Jt(void 0,`buffer`,this.size)),h?.push(Bi(this.size))):(x.pushToGutter(`deletions`,Jt(void 0,`buffer`,this.size)),g?.push(Bi(this.size))),this.size=0,this.side=void 0}}},w=(e,t,n,r,i)=>{x.pushToGutter(e,qt(t,n,r,i))};function T(e){C.flush(),a===`unified`?So(`unified`,e,x):(So(`deletions`,e,x),So(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),ca({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,f=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let h=a===`unified`?f:l,g={type:c,hunkIndex:t,lineIndex:h,unifiedLineIndex:f,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(g);n?.before!=null&&yo(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${f},${l}`,u.gutterProperties),i==null?r!=null&&(r=Co(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${f},${l}`}:void 0)):i=Co(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${f},${l}`}:void 0),xo({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,h),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&yo(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(g);n?.before!=null&&bo(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,h);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=Co(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=Co(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}xo({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&bo(n.after,x,C)}let _=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,v=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:f===n.unifiedLineStart+n.unifiedLineCount-1),E=_?n.noEOFCRDeletions:!1,D=_?n.noEOFCRAdditions:!1,O=(s?.noEOFCR??!1)||E,k=(o?.noEOFCR??!1)||D;if(k||O){if(a===`split`&&C.flush(),O){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push(Vi(e)),x.pushToGutter(`unified`,Jt(e,`metadata`,1))):(x.deletionsContentAST.push(Vi(e)),x.pushToGutter(`deletions`,Jt(e,`metadata`,1)),k||(x.pushToGutter(`additions`,Jt(void 0,`buffer`,1)),x.additionsContentAST.push(Bi(1))))}if(k){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push(Vi(e)),x.pushToGutter(`unified`,Jt(e,`metadata`,1))):(x.additionsContentAST.push(Vi(e)),x.pushToGutter(`additions`,Jt(e,`metadata`,1)),O||(x.pushToGutter(`deletions`,Jt(void 0,`buffer`,1)),x.deletionsContentAST.push(Bi(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||v&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:v&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(Gi(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),D=t.bufferBefore>0||t.bufferAfter>0,O=!f&&e.type!==`deleted`,k=!f&&e.type!==`new`,A=x.rowCount>0||D;h=O&&A?h:void 0,g=k&&A?g:void 0,_=f&&A?_:void 0;let j=this.createPreElement(g!=null&&h!=null,E);return{unifiedGutterAST:f&&A?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:k&&A?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:O&&A?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:j,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=Kt(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Ar(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(Z({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(Z({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(Z({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return N(this.renderFullAST(e,t))}renderPartialHTML(e,t){return N(t==null?e:Z({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!Or(n))return;let i=e.type===`new`?[]:go(Dr(this.deletionAnnotations)),a=e.type===`deleted`?[]:go(Dr(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;if(t===`unified`){xo({diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r});return}xo({diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(Vn(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(Vn(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(o.annotations.length!==0||a.annotations.length!==0)return{deletionSpan:a,additionSpan:o}}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Fn({fileOrDiff:e,mode:t,stickyHeader:n})}};function go(e){return e?.map(e=>Vn(e))??[]}var _o=new Intl.PluralRules(`en-US`);function vo(e){return`${e} unmodified line${_o.select(e)===`one`?``:`s`}`}function yo(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function bo(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function xo({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,Jt(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,Jt(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,Jt(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function So(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,Ui({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Ui({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Ui({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Ui({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=Wi(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?vo(n):`More unchanged context may be available`;c.pushToGutter(e,Ui({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Ui({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function Co(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function wo(e){return e.length>0&&e[e.length-1]===``?e.length-1:e.length}function To(e,t,n,r){let i=wo(e),a=wo(t),o=Math.min(i,a),s=0;for(;s<o&&e[s]===t[s];)s++;let c=0;for(;c<o-s&&e[i-1-c]===t[a-1-c];)c++;let l=Array(t.length);for(let e=0;e<s;e++)l[e]=n[e];for(let e=0;e<c;e++)l[a-1-e]=n[i-1-e];i<e.length&&a<t.length&&(l[t.length-1]=n[e.length-1]);for(let r=e.length;r<t.length;r++)l[r]??=n[r];for(let e=s;e<t.length;e++)l[e]??=Eo(e,r.getLineText(e));return l}function Eo(e,t,n=e,r=e){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${n},${r}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t}]}]}}function Do(e,t){let n=[],r=ko(t);for(let t=0;t<e.lineCount;t++){let i=e.getLineText(t,!0);n.push(t<e.lineCount-1&&!Oo(i)?i+r:i)}return n}function Oo(e){return e.endsWith(`
|
|
1371
|
+
`)||e.endsWith(`\r`)}function ko(e){for(let t of e){if(t.endsWith(`\r
|
|
1372
|
+
`))return`\r
|
|
1373
|
+
`;if(t.endsWith(`
|
|
1374
|
+
`))return`
|
|
1375
|
+
`;if(t.endsWith(`\r`))return`\r`}return`
|
|
1376
|
+
`}function Ao(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function jo(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Mo(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function No(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}async function Po(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Fo({oldFile:e,newFile:t},n){if(e!==void 0||t!==void 0){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function Io(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:ii(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function Lo(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}var Ro=-1,zo=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++Ro}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;pendingFiles;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:L},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new yn,this.scrollSyncManager=new Ri,this.interactionManager=new Qt(`diff`,$t(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return Io(e)}createHunksRenderer(e){return new ho(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>{let n=this.fileDiffCache;if(n==null)return;let r=n.hunks.at(-1),i,a;hunkIterator:for(let o of n.hunks){let n=t===`deletions`?o.deletionStart:o.additionStart,s=t===`deletions`?o.deletionCount:o.additionCount,c=W(n,s)+1,l=o.splitLineStart,u=o.unifiedLineStart;if(e<c){let t=c-e;i=Math.max(u-t,0),a=Math.max(l-t,0);break hunkIterator}if(e>=c+s){if(o===r){let t=e-(c+s);i=u+o.unifiedLineCount+t,a=l+o.splitLineCount+t;break hunkIterator}continue}for(let n of o.hunkContent)if(n.type===`context`){if(e<c+n.lines){let t=e-c;a=l+t,i=u+t;break hunkIterator}c+=n.lines,l+=n.lines,u+=n.lines}else{let r=t===`deletions`?n.deletions:n.additions;if(e<c+r){let r=e-c;i=u+(t===`additions`?n.deletions:0)+r,a=l+r;break hunkIterator}c+=r,l+=Math.max(n.deletions,n.additions),u+=n.deletions+n.additions}break hunkIterator}if(i!=null&&a!=null)return[i,a]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions($t(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}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;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ie(this.appliedThemeCSS.theme,this.options.theme??L)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}flushDeferredLineState(){let{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`||e===`scroll`&&(this.lineAnnotations.length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){Ne(this.handleEditSessionRender),this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.pendingFiles=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=Fo(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t),Uo(this.pre,Vo({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||Wo(this.headerElement,Ho({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),ti(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)!(e instanceof HTMLElement)||e.tagName.toLowerCase()!==`code`||(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Bt(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.applyHunkExpansionPlan([{hunkIndex:e,direction:t,expansionLineCountOverride:n}])};applyHunkExpansionPlan(e){if(e.length!==0){for(let t of e)this.hunksRenderer.expandHunk(t.hunkIndex,t.direction,t.expansionLineCountOverride);this.loadFilesIfNecessary(),this.rerender()}}loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;e==null||t==null||!Lo(e)||this.pendingFiles?.fileDiff===e||(this.pendingFiles={fileDiff:e,promise:this.loadFilesForDiff(e,t)})}async loadFilesForDiff(e,t){try{let n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}finally{this.pendingFiles?.fileDiff===e&&(this.pendingFiles=void 0)}}async handleFilesLoaded(e,t){this.fileDiff!==e||!e.isPartial||(ki(`merge`,e,t),this.setHydratedState(t),await Po(()=>this.primeHighlightCache(e)),!(!this.enabled||this.fileDiff!==e)&&this.rerender())}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){let l=Fo(c,`FileDiff.render`),u=l?.oldFile,d=l?.newFile;if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);e!=null&&e.cacheKey===void 0&&(e.cacheKey=e.prevName==null?e.name:e.prevName+`:`+e.name),this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:f=!1,themeType:p=`system`,expandUnchanged:m=!1}=this.options,h=f?void 0:s,g=this.hasThemeChanged(),_=l!=null,v=_&&(!Bo(u,this.deletionFile)||!Bo(d,this.additionFile)),y=e!=null&&e!==this.fileDiff,b=i!=null&&(i.length>0||this.lineAnnotations.length>0)&&i!==this.lineAnnotations;if(!f&&Mn(h,this.renderRange)&&!n&&!b&&!g&&(e!=null&&e===this.fileDiff||e==null&&!v))return this.applyCachedThemeState(p);let x;e==null&&_&&(v||this.fileDiff==null)&&(x=Bt(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:S}=this;if(this.renderRange=h,_?(this.deletionFile=u,this.additionFile=d):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e==null?x!=null&&(y=!0,this.fileDiff=x):this.fileDiff=e,y&&(this.cachedHeaderHTML=void 0),i!=null&&this.setLineAnnotations(i),this.fileDiff==null)return!1;this.fileDiff.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(Xa(this.fileDiff,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),m&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:C=!1,disableFileHeader:w=!1}=this.options;if(w&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(p),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(this.fileDiff,ke);e!=null&&this.applyThemeState(a,e.themeStyles,p,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(e){if(C)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,b,v||y||g)&&this.applyPartialRender({previousRenderRange:S,renderRange:h}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,h);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,p,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,h),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(C)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}get fileDiffCache(){return this.hunksRenderer.diffCache??this.fileDiff}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.fileDiffCache,r=this.lineAnnotations,i=this.computeEditorRenderRange(this.renderRange);e!=null&&t!=null&&n!=null&&!n.isPartial&&this.hunksRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.fileDiffCache!==n||e.__syncRenderView(a,t,n,r,i)})}computeEditorRenderRange(e){let t=this.fileDiffCache;if(e==null||t==null||Ki(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return ca({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}attachEditor(e){if(this.type!==`file-diff`)throw Error(`FileDiff.attachEditor: cannot attach an editor to a "${this.type}" diff`);return this.editor?.cleanUp(),this.editor=e,this.hunksRenderer.beginEditSession(),this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary(),this.hunksRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),e=>{this.editor=void 0,e!==!0&&this.finishEditSession()}}finishEditSession(){this.hunksRenderer.endEditSession(),this.completeEditSession()}completeEditSession(){let e=this.fileDiffCache;if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=Ja(e,this.hunksRenderer.getExpandedHunksMap(),t);return Xa(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Ya(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);let n=this.hunksRenderer.diffCache;if(n!=null){let e=this.fileDiff?.cacheKey;e!=null&&n.cacheKey==null&&(n.cacheKey=e),this.fileDiff=n}t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations()),this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){let{shouldRefreshDiffsView:r,lineCountChangeInFlight:i}=n;if(this.hunksRenderer.updateRenderCache(e,t,i)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}r===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}getHunkExpansionState(){return this.hunksRenderer.getExpandedHunksMap()}isLineRenderable(e){let t=this.fileDiffCache;if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return ea({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.getHunkExpansionState(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.fileDiffCache;if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return ta({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.getHunkExpansionState(),collapsedContextThreshold:i})}revealRange(e,t,n=0){let r=this.fileDiffCache,{expandUnchanged:i=!1,collapsedContextThreshold:a=1}=this.options;if(r==null||r.isPartial||i||!Number.isFinite(e)||!Number.isFinite(t))return!1;let o=Number.isFinite(n)?Math.max(0,Math.floor(n)):0,s=Math.max(1,Math.floor(Math.min(e,t))-o),c=Math.floor(Math.max(e,t))+o+1,l=this.getHunkExpansionState(),u=[],d=(e,t,n,r)=>{if(n.renderAll||n.rangeSize<=0)return;let i=t+n.rangeSize,a=t+n.fromStart,o=i-n.fromEnd,l=Math.max(s,a),d=Math.min(c,o);if(l>=d)return;let f=d-a,p=r?o-l:1/0;f<=p?u.push({hunkIndex:e,direction:`up`,expansionLineCountOverride:f}):u.push({hunkIndex:e,direction:`down`,expansionLineCountOverride:p})};for(let[e,t]of r.hunks.entries()){let[n]=Yi(t),i=Xi({isPartial:r.isPartial,rangeSize:t.collapsedBefore,expandedHunks:l,hunkIndex:e,collapsedContextThreshold:a});d(e,n-i.rangeSize,i,!0)}let f=$i({fileDiff:r,hunkIndex:r.hunks.length-1,expandedHunks:l,collapsedContextThreshold:a,errorPrefix:`FileDiff.revealRange`});if(f!=null){let e=r.hunks.at(-1);if(e!=null){let[,t]=Yi(e);d(r.hunks.length,t,f,!1)}}return u.length!==0&&(this.applyHunkExpansionPlan(u),!0)}revealLine(e){let t=this.fileDiffCache,{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.getHunkExpansionState();for(let[n,o]of t.hunks.entries()){let[s,c]=Yi(o);if(e<s){let c=Xi({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),l=s-c.rangeSize;if(c.renderAll||e<l+c.fromStart||e>=s-c.fromEnd)return!1;let u=e-(l+c.fromStart)+1,d=s-c.fromEnd-e;return u<=d?this.expandHunk(n,`up`,u+i):this.expandHunk(n,`down`,d+i),!0}if(e<c)return!1}let o=$i({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],[,c]=Yi(s);return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){Me(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||po(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.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.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=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}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!No(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${Vn(r)}`,a=this.annotationCache.get(i);if(a==null||!Mo(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:Vr(Vn(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=Hr();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:ri(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):ri(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=Ir;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:n}=this,r=this.cachedHeaderHTML??N(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;let{renderCustomHeader:i,renderHeaderPrefix:a,renderHeaderFilenameSuffix:o,renderHeaderMetadata:s}=this.options;if(i!=null){let e=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,xe,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let c=a?.(n)??void 0,l=o?.(n)??void 0,u=s?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,ye,c),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,be,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,I,u),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}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{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??=Ur(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Xr(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??L,s=typeof o==`string`?o:{...o},c=Kr(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=si({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Zr(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=Qr(this.themeCSSStyle.textContent??``,Kr(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&ui()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?oi(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){let r=this.getColumnPair(e);if(r==null)return!1;let i=Go(t[0]),a=Go(t[1]);return i==null||a==null?!1:(r.gutter.innerHTML=N(i),r.content.innerHTML=N(a),n!==this.lastRowCount&&(r.gutter.style.setProperty(`grid-row`,`span ${n}`),r.content.style.setProperty(`grid-row`,`span ${n}`)),!0)}replaceCodeColumns(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);this.editor?.__captureFocusForDOMReplacement(),s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=ei({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeDeletions,c,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c)),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=ei({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeAdditions,l,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=ei({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.applyCodeColumnsInPlace(this.codeUnified,s,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s)),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:a,options:{diffStyle:o=`split`}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(o,r,a,i);if(s==null)return!1;let c=e.startingLine,l=t.startingLine,u=c+e.totalLines,d=l+t.totalLines,f=Math.max(c,l),p=Math.min(u,d);if(p<=f)return!1;let m=Math.max(0,f-c),h=Math.max(0,u-p),g=this.trimColumns({columns:s,trimStart:m,trimEnd:h,previousStart:c,overlapStart:f,overlapEnd:p,diffStyle:o});if(g<0)throw Error(`FileDiff.applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`FileDiff.applyPartialRender: trimmed beyond DOM row count`);let _=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},y=v(l,Math.max(f-l,0));if(y==null&&l<f)return!1;let b=v(p,Math.max(d-p,0));if(b==null&&d>p)return!1;let x=(e,t)=>{if(e!=null){if(o===`unified`&&!Array.isArray(s))this.insertPartialHTML(o,s,e,t);else if(o===`split`&&Array.isArray(s))this.insertPartialHTML(o,s,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);_+=e.rowCount}};return this.cleanupErrorWrapper(),x(y,`afterbegin`),x(b,`beforeend`),this.lastRowCount!==_&&(this.applyRowSpan(o,s,_),this.lastRowCount=_),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){if(this.options.diffStyle!==`split`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;let n=(t,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(t,e),i=Go(r?.[0]),a=Go(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};n(`deletions`,t[0]),n(`additions`,t[1])}refreshUnifiedDiffView(){if(this.options.diffStyle!==`unified`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null||Array.isArray(t))return;let n=this.hunksRenderer.renderCodeAST(`unified`,e),r=Go(n?.[0]),i=Go(n?.[1]),a=()=>{for(let[e,n]of[[t.gutter,r],[t.content,i]])n!=null&&(e.innerHTML=N(n));e.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,t,e.rowCount),this.lastRowCount=e.rowCount)};this.shouldGuardRebuildScroll()?oi(this.pre,a):a(),this.renderSeparators(e.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Go(t[0]),i=Go(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;let 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}}getCodeColumns(e,t,n,r){if(e===`unified`)return this.getColumnPair(t);{let e=this.getColumnPair(n),t=this.getColumnPair(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}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??(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??(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}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l!==`unified`&&t!=null&&n!=null,totalLines:r,customProperties:i};Rr(u,this.appliedPreAttributes)||(ni(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Bo(e,t){return e==null||t==null?e==null&&t==null:Ht(e,t)}function Vo({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function Ho({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function Uo(e,t,n=!1){return!n&&e==null&&t}function Wo(e,t,n=!1){return e==null&&t&&!n}function Go(e){if(e!=null&&e.type===`element`)return e.children??[]}function Ko({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=_i(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=Xi({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=oa({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=qo(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?$i({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=sa({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=sa({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=yi(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function qo(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return Jo(e,t)}function Jo(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}var Yo=3e3,Xo=-1,Zo=class extends zo{__id=`little-virtualized-file-diff:${++Xo}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;currentExpandUnchanged;pendingHydratedDiff;pendingExpansions;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=gi(n)}setMetrics(e,t=!1){let n=gi(e);!t&&Fe(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e!==t&&(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!Er(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type!==`deleted`||t.side===`deletions`:!1)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Le(t,e),r=n&&as(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:os(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}reconcileHeights(){let e=!1,{overflow:t=`scroll`}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;let n=this.getDiffStyle(),r=n===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],i=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&i&&Or(this.renderRange)){let t=Qo(r)??0;this.setFileAnnotationHeight(t)&&(e=!0)}else!i&&this.setFileAnnotationHeight(0)&&(e=!0);for(let t of r){if(t==null)continue;let r=t.children[1];if(r instanceof HTMLElement)for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let i=us(r,n),a=t.getBoundingClientRect().height,o=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(o=!0),a+=t.nextElementSibling.getBoundingClientRect().height);let s=this.getEstimatedLineHeight(o),c=this.cache.heightDeltas.get(i)??0,l=a-s;l!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=l-c,l===0?this.cache.heightDeltas.delete(i):this.cache.heightDeltas.set(i,l))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer!=null&&(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}prepareCodeViewItem(e,t,n,r){let i=!Ei(this.fileDiff,e),a=this.syncLineAnnotations(r),o=n?.resetDiffLayoutCache===!0||i||a,s=i||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=gi(n.metrics),o=!0,s=!0);let{collapsed:c=!1,expandUnchanged:l=!1}=this.options;return this.currentCollapsed!==c&&(this.currentCollapsed=c,o=!0),this.currentExpandUnchanged!==l&&(this.currentExpandUnchanged=l,o=!0,s=!0),o&&this.resetLayoutCache({includeEstimatedHeights:s}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t=`additions`){if(this.fileDiff==null||e<1)return;let n=this.getLineIndex(e,t);if(n==null)return;let{disableFileHeader:r=!1,expandUnchanged:i=!1,collapsed:a=!1,collapsedContextThreshold:o=1}=this.options,s=this.getDiffStyle(),c=this.getHunkSeparatorType(),l=s===`split`?n[1]:n[0];this.approximateLayoutCheckpoints();let u=_i(this.metrics,r),d=this.getLayoutCheckpointBeforeLineIndex(l),f=d?.top??u+this.cache.fileAnnotationHeight;if(a)return{top:u,height:0};let p;return ca({diff:this.fileDiff,diffStyle:s,startingLine:d?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=s===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=oa({type:c,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(f+=r.gapBefore,l>=o-n&&l<o)return p={top:f,height:r.height},!0;f+=r.height+r.gapAfter}}let u=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===l)return p={top:f,height:u},!0;if(f+=u,r>0){let e=sa({type:c,metrics:this.metrics});if(e!=null){if(l>o&&l<=o+r)return p={top:f+e.gapBefore,height:e.height},!0;f+=e.totalHeight}}return!1}}),p}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.fileDiff==null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1}=this.options;if(r)return;let a=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();let s=this.getLayoutCheckpointBeforeTop(e),c=s?.top??_i(this.metrics,t)+this.cache.fileAnnotationHeight,l;return ca({diff:this.fileDiff,diffStyle:a,startingLine:s?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:s,additionLine:u})=>{let d=a===`split`?u?.splitLineIndex??s?.splitLineIndex:u?.unifiedLineIndex??s?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=oa({type:o,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(c+=e.totalHeight)}if(c>=e&&(s==null?u!=null&&(l={lineNumber:u.lineNumber,side:`additions`,top:c}):l={lineNumber:s.lineNumber,side:`deletions`,top:c},l!=null))return!0;let f=this.getLineHeight(d,(u?.noEOFCR??!1)||(s?.noEOFCR??!1));if(c+=f,i>0){let e=sa({type:o,metrics:this.metrics});e!=null&&(c+=e.totalHeight)}return!1}}),l}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.fileDiff,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.applyHunkExpansionPlan([{hunkIndex:e,direction:t,expansionLineCountOverride:n}])};applyHunkExpansionPlan(e){if(this.fileDiff!=null&&e.length!==0){if(this.isAdvancedMode())this.pendingExpansions??=[],this.pendingExpansions.push(...e);else{for(let t of e)this.hunksRenderer.expandHunk(t.hunkIndex,t.direction,t.expansionLineCountOverride);this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}async handleFilesLoaded(e,t){if(!(this.fileDiff!==e||!e.isPartial)){if(this.isAdvancedMode()){let n=ki(`clone`,e,t);if(await Po(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(ki(`merge`,e,t),this.setHydratedState(t),await Po(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}consumeCodeViewLayoutChanges(e){let t=!1,n,{pendingExpansions:r,pendingHydratedDiff:i}=this;if(r!=null){this.pendingExpansions=void 0;for(let e of r)this.hunksRenderer.expandHunk(e.hunkIndex,e.direction,e.expansionLineCountOverride),t=!0}return i!=null&&(this.pendingHydratedDiff=void 0,i.expectedDiff===e&&(this.setHydratedState(i.files),n=i.nextDiff)),n==null?t&&(this.forceRenderOverride=!0,this.invalidateDerivedLayoutCache(!0)):(this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0})),n}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}getHunkExpansionState(){let e=super.getHunkExpansionState(),{pendingExpansions:t}=this;if(t==null||t.length===0)return e;let{expansionLineCount:n=100}=this.options,r=new Map(e);for(let e of t){let t={...r.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},i=e.expansionLineCountOverride??n;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=i),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=i),r.set(e.hunkIndex,t)}return r}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),!(!this.enabled||this.fileDiff==null)&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!==void 0&&this.fileDiff!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.fileDiff){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1}=this.options,o=_i(this.metrics,i);if(this.height+=o,a){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1}getActiveEstimatedHeight(e=this.fileDiff){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.fileDiff){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=Ko({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:ss(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.fileDiff){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=Fo(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!ls(s,this.deletionFile)||!ls(c,this.additionFile)),u=t??this.fileDiff;t==null&&o&&(l||this.fileDiff==null)&&(u=Bt(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=this.syncLineAnnotations(r);p&&this.resetLayoutCache({includeEstimatedHeights:!1});let m=t!=null&&t!==this.fileDiff,h=u!=null&&!Ei(this.fileDiff,u),g=m||l;if(h&&this.resetLayoutCache({includeEstimatedHeights:!0}),e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(f)this.top??=this.getVirtualizedTop(),h&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,u));else{this.computeApproximateSize(!1,u);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!g||!f))return this.fileDiff=u,a!=null&&(this.deletionFile=s,this.additionFile=c),h&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let _=this.virtualizer.getWindowSpecs(),v=this.top??0,y=this.computeRenderRangeFromWindow(u,v,_),b=super.render({fileDiff:u,fileContainer:e,renderRange:y,lineAnnotations:r,forceRender:(d??n)||p||h,...a,...i});return this.isSimpleMode()&&b&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),b}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`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}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}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return cs(this.options.hunkSeparators)}approximateLayoutCheckpoints(e=this.fileDiff){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e==null||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=ss(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=$o(this.cache.heightDeltas),u=_i(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=ns(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+rs(i,e)*this.metrics.lineHeight+es(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=Yo}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+es(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=Xi({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?oa({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?$i({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?sa({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:is({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=Xi({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=$i({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=ss(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=_i(this.metrics,i),h=e.hunks.length>0?yi(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,ee,M;if(ca({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?oa({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),M!=null)){if(M<=0)return!0;M--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),ee==null&&k+S>D&&(ee=x),M==null&&k>=r&&b&&(M=T),A++,k+=S,c>0||v&&d){let e=sa({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),ee==null&&k+e.totalHeight>D&&(ee=x),k+=e.totalHeight)}return!1}}),j==null){if(x)j=0,ee=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h}}ee??=j;let te=Math.round(ee-w/2),N=Math.max(0,Math.ceil(p/s)-w),ne=Math.max(0,Math.min(te,N)),re=ne*s,P=te<0?C+te*s:C,ie=E[ne]??0,ae=re===0?0:g+ie,oe=ne+P/s,F=oe<E.length?v-E[oe]:v-(k-t-_);return{startingLine:re,totalLines:P,bufferBefore:ae,bufferAfter:Math.max(0,F)}}};function Qo(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===Tr&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function $o(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function es({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=ts(e,n);return(t[ts(e,r)]??0)-(t[i]??0)}function ts(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function ns(e){return Math.ceil(e/Yo)*Yo}function rs(e,t){let n=0;for(let r of e)r<t&&n++;return n}function is({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function as(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function os(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function ss(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function cs(e){return typeof e==`function`?`custom`:e??`line-info`}function ls(e,t){return e==null||t==null?e==null&&t==null:Ht(e,t)}function us(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function ds({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function fs(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:ps(n,e.startContentIndex)}}function ps(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}var Q=e(c(),1);function ms(e){let t=(0,Q.useRef)(e);return(0,Q.useInsertionEffect)(()=>void(t.current=e)),(0,Q.useCallback)((...e)=>t.current(...e),[])}var $=n(),hs=(0,Q.createContext)(void 0);function gs(){return(0,Q.useContext)(hs)}var _s={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},vs={display:`contents`};function ys(){return null}function bs({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d}){let f=n?.(e),p=r?.(e),m=i?.(e),h=a?.(e);return(0,$.jsxs)($.Fragment,{children:[f==null?(0,$.jsxs)($.Fragment,{children:[p!=null&&(0,$.jsx)(`div`,{slot:`header-prefix`,children:p}),m!=null&&(0,$.jsx)(`div`,{slot:`header-filename-suffix`,children:m}),h!=null&&(0,$.jsx)(`div`,{slot:`header-metadata`,children:h})]}):(0,$.jsx)(`div`,{slot:xe,children:f}),o!=null&&l?.map((e,t)=>(0,$.jsx)(`div`,{slot:Vn(e),children:o(e)},t)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=xs(t,e);return(0,$.jsx)(`div`,{slot:n,style:vs,children:c(t,d)},n)}),s!=null&&(0,$.jsx)(`div`,{slot:`gutter-utility-slot`,style:_s,children:s(u)})]})}function xs(e,t){let n=fs(e,t);return n==null?void 0:ds({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function Ss({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,lineAnnotations:o,renderGutterUtility:s,getHoveredLine:c}){let l=t?.(e),u=n?.(e),d=r?.(e),f=i?.(e);return(0,$.jsxs)($.Fragment,{children:[l==null?(0,$.jsxs)($.Fragment,{children:[u!=null&&(0,$.jsx)(`div`,{slot:`header-prefix`,children:u}),d!=null&&(0,$.jsx)(`div`,{slot:`header-filename-suffix`,children:d}),f!=null&&(0,$.jsx)(`div`,{slot:`header-metadata`,children:f})]}):(0,$.jsx)(`div`,{slot:xe,children:l}),a!=null&&o?.map((e,t)=>(0,$.jsx)(`div`,{slot:Vn(e),children:a(e)},t)),s!=null&&(0,$.jsx)(`div`,{slot:`gutter-utility-slot`,style:_s,children:s(c)})]})}var Cs=(0,Q.createContext)(void 0);function ws(e,t){return typeof window>`u`&&t!=null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,$.jsx)($.Fragment,{children:e})}var Ts=(0,Q.createContext)(void 0);function Es(){return(0,Q.useContext)(Ts)}var Ds=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Os({file:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=Es(),f=i!==void 0,p=(0,Q.useContext)(Cs),m=gs(),h=(0,Q.useRef)(null),g=ms(n=>{if(n!=null){if(h.current!=null)throw Error(`File: An instance should not already exist when a node is created`);d==null?h.current=new pi(ks({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new wi(ks({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({file:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`File: A File instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return Ds(()=>{if(h.current==null)return;let n=ks({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),a=n!==void 0&&!Le(h.current.options,n);h.current.setOptions(n),h.current.render({file:e,lineAnnotations:r,forceRender:a}),i!==void 0&&h.current.setSelectedLines(i)}),Ds(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`File: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`File: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,Q.useCallback)(()=>h.current?.getHoveredLine(),[])}}function ks({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?ys:e?.renderCustomHeader,renderGutterUtility:r?ys:e?.renderGutterUtility}:e}function As({file:e,lineAnnotations:t,selectedLines:n,options:r,editorOptions:i,metrics:a,className:o,style:s,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:f,prerenderedHTML:p,renderGutterUtility:m,disableWorkerPool:h=!1,edit:g=!1}){let{ref:_,getHoveredLine:v}=Os({file:e,options:r,editorOptions:i,metrics:a,lineAnnotations:t,selectedLines:n,prerenderedHTML:p,hasGutterRenderUtility:m!=null,hasCustomHeader:l!=null,disableWorkerPool:h,edit:g});return(0,$.jsx)(fe,{ref:_,className:o,style:s,children:ws(Ss({file:e,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:f,renderGutterUtility:m,lineAnnotations:t,getHoveredLine:v}),p)})}var js=typeof window>`u`?Q.useEffect:Q.useLayoutEffect;function Ms({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=Es(),f=i!==void 0,p=(0,Q.useContext)(Cs),m=gs(),h=(0,Q.useRef)(null),g=ms(n=>{if(n!=null){if(h.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?h.current=new zo(Ns({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new Zo(Ns({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return js(()=>{let{current:n}=h;if(n==null)return;let a=Ns({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!Le(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),js(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,Q.useCallback)(()=>h.current?.getHoveredLine(),[])}}function Ns({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?ys:e?.renderCustomHeader,renderGutterUtility:r?ys:e?.renderGutterUtility}:e}function Ps({oldFile:e,newFile:t,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:g=!1,edit:_=!1}){let v=(0,Q.useMemo)(()=>Bt(e,t,n?.parseDiffOptions),[e,t,n?.parseDiffOptions]),{ref:y,getHoveredLine:b}=Ms({fileDiff:v,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:g,edit:_});return(0,$.jsx)(fe,{ref:y,className:s,style:c,children:ws(bs({fileDiff:v,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,lineAnnotations:a,renderGutterUtility:h,getHoveredLine:b}),l)})}function Fs(e,t,n){return{name:e,contents:t,lang:P(e),...n===void 0?{}:{cacheKey:n}}}function Is({side:e}){let[t,n]=(0,Q.useState)(e.sourceUrl?`checking`:`error`);if((0,Q.useEffect)(()=>{if(!e.sourceUrl)return;let t=new AbortController,r=!0;return n(`checking`),fetch(e.sourceUrl,{method:`HEAD`,signal:t.signal}).then(e=>{r&&(e.status===413?n(`too-large`):e.status===415?n(`unsupported`):e.ok?n(`loading`):n(`error`))}).catch(()=>{r&&!t.signal.aborted&&n(`error`)}),()=>{r=!1,t.abort()}},[e.sourceUrl]),!e.sourceUrl)return(0,$.jsx)(`div`,{className:`repository-image-empty`,children:e.emptyMessage??`画像がありません。`});let r=t===`too-large`?`5 MiBを超えるため画像を表示できません。`:t===`unsupported`?`画像形式が未対応か、内容が破損しています。`:t===`error`?`画像を読み込めませんでした。`:null;return(0,$.jsxs)(`div`,{className:`repository-image-asset`,children:[t===`checking`&&(0,$.jsx)(`div`,{className:`repository-image-status`,children:`画像を確認しています…`}),t===`loading`&&(0,$.jsx)(`div`,{className:`repository-image-status`,children:`画像を読み込んでいます…`}),r&&(0,$.jsx)(`div`,{className:`repository-image-status repository-image-status--error`,role:`alert`,children:r}),(t===`loading`||t===`loaded`)&&(0,$.jsx)(`img`,{src:e.sourceUrl,alt:`${e.label}: ${e.path??`画像`}`,onLoad:()=>n(`loaded`),onError:()=>n(`error`)})]})}function Ls({side:e}){return(0,$.jsxs)(`section`,{className:`repository-image-pane`,"aria-label":e.label,children:[(0,$.jsxs)(`header`,{children:[(0,$.jsx)(`strong`,{children:e.label}),(0,$.jsx)(`code`,{children:e.path??`—`}),e.action]}),(0,$.jsx)(Is,{side:e}),e.comments]})}function Rs({mode:e,oldSide:t,newSide:n}){return(0,$.jsx)(`div`,{className:`repository-image-viewer repository-image-viewer--${e}`,children:(0,$.jsxs)(`div`,{className:`repository-image-grid`,children:[t&&(0,$.jsx)(Ls,{side:t}),(0,$.jsx)(Ls,{side:n})]})})}var zs=new Map;function Bs(e){return e.kind===`pull-request-markdown`?`pull-request-markdown`:e.kind===`walkthrough`?`walkthrough:${e.id}`:`repository-file:${e.path}`}var Vs=`
|
|
1377
|
+
:host {
|
|
1378
|
+
--diffs-bg: light-dark(var(--diffs-light-bg, #fff), #000);
|
|
1379
|
+
--diffs-bg-addition-override: light-dark(
|
|
1380
|
+
color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-addition-base)),
|
|
1381
|
+
color-mix(in lab, var(--diffs-bg) 86%, var(--diffs-addition-base))
|
|
1382
|
+
);
|
|
1383
|
+
--diffs-bg-deletion-override: light-dark(
|
|
1384
|
+
color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-deletion-base)),
|
|
1385
|
+
color-mix(in lab, var(--diffs-bg) 86%, var(--diffs-deletion-base))
|
|
1386
|
+
);
|
|
1387
|
+
--diffs-bg-addition-emphasis-override: light-dark(
|
|
1388
|
+
rgb(from var(--diffs-addition-base) r g b / 0.15),
|
|
1389
|
+
rgb(from var(--diffs-addition-base) r g b / 0.14)
|
|
1390
|
+
);
|
|
1391
|
+
--diffs-bg-deletion-emphasis-override: light-dark(
|
|
1392
|
+
rgb(from var(--diffs-deletion-base) r g b / 0.15),
|
|
1393
|
+
rgb(from var(--diffs-deletion-base) r g b / 0.14)
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
[data-change-icon="file"] {
|
|
1397
|
+
display: none;
|
|
1398
|
+
}
|
|
1399
|
+
[data-diffs-header][data-sticky] {
|
|
1400
|
+
top: 40px;
|
|
1401
|
+
}
|
|
1402
|
+
[data-line] {
|
|
1403
|
+
padding-inline-start: calc(1ch + 8px);
|
|
1404
|
+
}
|
|
1405
|
+
[data-line][data-editor-active-line] {
|
|
1406
|
+
background: color-mix(in srgb, var(--diffs-modified-base) 28%, transparent) !important;
|
|
1407
|
+
}
|
|
1408
|
+
::highlight(rvw-pane-find-left-match),
|
|
1409
|
+
::highlight(rvw-pane-find-right-match) {
|
|
1410
|
+
background-color: light-dark(rgb(234 179 8 / 0.42), rgb(250 204 21 / 0.38));
|
|
1411
|
+
}
|
|
1412
|
+
::highlight(rvw-pane-find-left-current),
|
|
1413
|
+
::highlight(rvw-pane-find-right-current) {
|
|
1414
|
+
background-color: light-dark(rgb(245 139 10 / 0.82), rgb(249 115 22 / 0.78));
|
|
1415
|
+
color: light-dark(#17120a, #fff);
|
|
1416
|
+
}
|
|
1417
|
+
`;function Hs(e,t,n,r,i){let a=0,o=()=>{window.requestAnimationFrame(()=>{a+=1;let s=e.shadowRoot;if(!s){a<4&&o();return}let c=[...s.querySelectorAll(`[data-line="${t}"]`)],l=c.find(e=>e.hasAttribute(`data-editor-active-line`)),u=n?c.find(e=>e.closest(`[data-additions]`)!==null||e.dataset.lineType!==`change-deletion`):void 0,d=l??u??c[0],f=e.closest(`.document-pane`);if(!d||!f||!e.isConnected||f.clientHeight===0){a<4&&o();return}let p=d.closest(`code`),m=p?.scrollLeft??0;if(d.scrollIntoView({behavior:`auto`,block:`center`,inline:`nearest`}),p){let e=r?0:m;p.scrollLeft=e,window.requestAnimationFrame(()=>{p.scrollLeft=e})}let h=f.getBoundingClientRect(),g=d.getBoundingClientRect(),_=(Us(f)+h.bottom)/2,v=(g.top+g.bottom)/2;if(!(Math.abs(v-_)<=Math.max(g.height*2,24))&&a<4){o();return}i()})};window.requestAnimationFrame(o)}function Us(e){let t=e.getBoundingClientRect().top;return[...e.querySelectorAll(`.document-tabs-shell, .markdown-view-toolbar`)].map(e=>e.getBoundingClientRect()).filter(e=>e.bottom>t&&e.top<=t+1).reduce((e,t)=>Math.max(e,t.bottom),t)}function Ws(e,t,n){let r=e.host.getBoundingClientRect(),i=t.getBoundingClientRect(),a=Math.max(r.left,i.left),o=Math.min(r.right,i.right),s=Math.max(r.top,n),c=Math.min(r.bottom,i.bottom),l=[a+(o-a)*.25,a+(o-a)*.75,(a+o)/2];for(let t=s+1;t<c;t+=6)for(let n of l){let r=e.elementFromPoint(n,t)?.closest(`[data-line]`);if(r)return r}return null}function Gs(e,t){return[...e.querySelectorAll(`[data-line="${CSS.escape(t)}"]`)]}function Ks(e){let t=e?.closest(`.document-pane`),n=e?.querySelector(`diffs-container`)?.shadowRoot;if(!t||!n)return null;let r=Us(t),i=Ws(n,t,r),a=i?.dataset.line;if(!i||a===void 0)return null;let o=Gs(n,a);return{line:a,occurrence:Math.max(0,o.indexOf(i)),topOffset:i.getBoundingClientRect().top-r,fallbackScrollTop:t.scrollTop}}function qs(e,t){let n=e?.closest(`.document-pane`),r=e?.querySelector(`diffs-container`)?.shadowRoot;if(!n||!r)return;let i=Gs(r,t.line),a=i[t.occurrence]??i[0];if(!a){n.scrollTop=t.fallbackScrollTop;return}let o=a.getBoundingClientRect().top-Us(n);n.scrollTop+=o-t.topOffset}function Js(e){let t=new URLSearchParams({kind:e.kind,pullRequestId:e.pullRequestId});return e.kind===`repository-file`&&(t.set(`sourceOid`,e.sourceOid),t.set(`path`,e.path)),t.toString()}function Ys(e){return Q.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):(0,Q.isValidElement)(e)?Ys(e.props.children):``).join(``)}function Xs(e,t){let n=Ys(e).trim().toLowerCase().replace(/[^\p{L}\p{N}_ -]/gu,``).replace(/\s+/g,`-`)||`section`,r=t.get(n)??0;return t.set(n,r+1),r===0?n:`${n}-${r}`}function Zs(e,t){let n;try{n=decodeURIComponent(t.slice(1))}catch{return null}let r=[...e.closest(`.document-pane`)?.querySelectorAll(`[id]`)??[]].find(e=>e.id===n);if(!r)return null;let i=Number(r.dataset.rvwSourceStartLine);return Number.isInteger(i)&&i>0?i:null}function Qs(e,t){return!!(e&&t&&e.startLine<=t.endLine&&e.endLine>=t.startLine)}function $s(e,t){if(!e)return null;let n=e.querySelector(`[data-rvw-source-start-line="${t}"]`);if(n)return n;let r=null;for(let n of e.querySelectorAll(`[data-rvw-source-start-line][data-rvw-source-end-line]`)){let e=Number(n.dataset.rvwSourceStartLine),i=Number(n.dataset.rvwSourceEndLine);if(!Number.isInteger(e)||!Number.isInteger(i)||e>t||i<t)continue;let a=i-e,o=n.dataset.rvwSourceLeaf===`true`;(!r||a<r.span||a===r.span&&o&&!r.leaf)&&(r={element:n,span:a,leaf:o})}return r?.element??null}function ec(e,t){return!!(e&&t&&e.startLine===t.startLine&&e.endLine===t.endLine)}function tc({source:e,sourceRange:t,sourceAttributes:n,sourceHighlighted:r,sourceSelected:i,sourceOid:a,pullRequestId:o,placedComments:c,replyDraftScope:l,themePreference:u,onCommentActiveChange:d,onOpenCodeReference:f,onOpenRepositoryLink:p,onCreateComment:h,createPending:g,createError:_,onResetCreate:v}){let[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(``),C=t?c.filter(({placement:e})=>ec(e.range,t)):[],T=t?{pullRequestId:o,commentCount:C.length,onOpenCodeReference:f,renderComments:e=>(0,$.jsxs)(`div`,{className:`mermaid-diagram-comments`,children:[C.length===0&&!y&&(0,$.jsx)(`p`,{className:`mermaid-comments-empty`,children:`この diagram へのコメントはありません。`}),C.map(({comment:n,placement:r})=>(0,$.jsx)(j,{comment:n,variant:`sidebar`,draftScope:`${l}:mermaid:${t.startLine}-${t.endLine}`,placement:r,markdownSourceOid:a,themePreference:u,cancelDraftOnEscape:!0,onActiveChange:d,onOpenCodeReference:e,onOpenRepositoryLink:p},n.id)),y?(0,$.jsx)(w,{body:x,label:`Comment on diagram`,pending:g,error:_,validationError:void 0,placement:`line`,onBodyChange:S,onCancel:()=>{S(``),b(!1),v()},onSubmit:()=>{h(t,x).then(()=>{S(``),b(!1)}).catch(()=>void 0)}}):(0,$.jsxs)(`button`,{className:`mermaid-comment-action`,onClick:()=>{v(),b(!0)},children:[(0,$.jsx)(m,{}),`Comment on diagram`]})]})}:void 0;return(0,$.jsx)(D,{source:e,themePreference:u,renderIdPrefix:`rvwMarkdown`,review:T,renderInline:t=>(0,$.jsxs)(`div`,{className:`markdown-mermaid-shell${r?` is-source-highlighted`:``}${i?` is-source-selected`:``}`,"data-rvw-source-leaf":`true`,...n,children:[(0,$.jsxs)(`div`,{className:`markdown-mermaid-toolbar`,children:[(0,$.jsx)(`span`,{children:`Mermaid diagram`}),t]}),(0,$.jsx)(s,{className:`markdown-mermaid`,role:`img`,"aria-label":`Mermaid diagram`,source:e,themePreference:u,renderIdPrefix:`rvwMarkdown`,errorClassName:`markdown-mermaid-error`})]})})}var nc=(0,Q.createContext)(null),rc=({children:e,node:t,...n})=>{let r=(0,Q.useContext)(nc),i=Q.Children.toArray(e),a=i.length===1?i[0]:null;if(!r||!(0,Q.isValidElement)(a)||!a.props.className?.split(/\s+/u).includes(`language-mermaid`))return(0,$.jsx)(`pre`,{...n,children:e});let o=se(t),s=Qs(o,r.navigationRange)||!!(r.activeCommentId&&r.annotations.some(e=>e.id===r.activeCommentId&&Qs(o,e.range)));return(0,$.jsx)(tc,{source:Ys(a.props.children).trim(),sourceRange:o,sourceAttributes:F(t),sourceHighlighted:s,sourceSelected:Qs(o,r.selectedRange),sourceOid:r.sourceRef.kind===`repository-file`?r.sourceRef.sourceOid:r.selectedOid,pullRequestId:r.pullRequestId,placedComments:r.placedComments,replyDraftScope:r.replyDraftScope,themePreference:r.themePreference,onCommentActiveChange:r.onCommentActiveChange,onOpenCodeReference:r.onOpenCodeReference,onOpenRepositoryLink:r.onOpenRepositoryLink,onCreateComment:r.onCreateDiagramComment,createPending:r.diagramCommentPending,createError:r.diagramCommentError,onResetCreate:r.onResetDiagramComment})};function ic({text:e,pullRequestMarkdown:t,annotations:n,activeCommentId:r,selectedRange:i,navigationRange:a,composerOpen:o,markdownDiv:s,sourceRef:c,selectedOid:l,pullRequestId:u,themePreference:d,placedComments:f,replyDraftScope:p,linkPointerStart:m,onCommentActiveChange:h,onOpenCodeReference:C,onCreateDiagramComment:w,diagramCommentPending:D,diagramCommentError:O,onResetDiagramComment:k,onOpenRepositoryLink:j,onOpenMarkdownFragment:te}){let N=new Map,ne={annotations:n,activeCommentId:r,selectedRange:i,navigationRange:a,sourceRef:c,selectedOid:l,pullRequestId:u,themePreference:d,placedComments:f,replyDraftScope:p,onCommentActiveChange:h,onOpenCodeReference:C,onCreateDiagramComment:w,diagramCommentPending:D,diagramCommentError:O,onResetDiagramComment:k,onOpenRepositoryLink:j},re=(0,$.jsx)(g,{rehypePlugins:[M,b,[le,{annotations:n,activeCommentId:r,selectedRange:i,navigationRange:a,composerOpen:o}]],remarkPlugins:t?[E,x]:[E],components:{div:s,table:de,h1:({children:e,node:t,...n})=>(0,$.jsx)(`h1`,{...F(t),...n,id:Xs(e,N),children:e}),h2:({children:e,node:t,...n})=>(0,$.jsx)(`h2`,{...F(t),...n,id:Xs(e,N),children:e}),h3:({children:e,node:t,...n})=>(0,$.jsx)(`h3`,{...F(t),...n,id:Xs(e,N),children:e}),h4:({children:e,node:t,...n})=>(0,$.jsx)(`h4`,{...F(t),...n,id:Xs(e,N),children:e}),h5:({children:e,node:t,...n})=>(0,$.jsx)(`h5`,{...F(t),...n,id:Xs(e,N),children:e}),h6:({children:e,node:t,...n})=>(0,$.jsx)(`h6`,{...F(t),...n,id:Xs(e,N),children:e}),a:({href:e,children:t,node:n,...r})=>{let i=c.kind===`repository-file`?c.path:null,a=y(e,i);if(!a){let i=T(e);return(0,$.jsx)(`a`,{...F(n),...r,href:e,target:i?`_blank`:void 0,rel:i?`noopener noreferrer`:void 0,onPointerDown:e=>{m.current={x:e.clientX,y:e.clientY}},onPointerUp:t=>{let n=v(m.current,{x:t.clientX,y:t.clientY});if(m.current=null,n&&(t.currentTarget.dataset.rvwLinkDragged=`true`),!n&&e?.startsWith(`#`)){let n=Zs(t.currentTarget,e);n!==null&&te(n,e)}},onClick:t=>{if(t.currentTarget.dataset.rvwLinkDragged===`true`){delete t.currentTarget.dataset.rvwLinkDragged,t.preventDefault();return}if(e?.startsWith(`#`)&&(t.preventDefault(),t.detail===0)){let n=Zs(t.currentTarget,e);n!==null&&te(n,e)}},children:t})}let o=c.kind===`repository-file`?c.sourceOid:l;return(0,$.jsx)(`a`,{...F(n),...r,href:e,onPointerDown:e=>{m.current={x:e.clientX,y:e.clientY}},onPointerUp:e=>{let t=v(m.current,{x:e.clientX,y:e.clientY});m.current=null,!t&&j(a,o,e.metaKey||e.ctrlKey)},onClick:e=>{e.preventDefault(),e.detail===0&&j(a,o,!1)},onContextMenu:e=>{(e.ctrlKey||e.metaKey)&&e.preventDefault()},children:t})},img:({src:e,alt:t,title:n,node:r,...i})=>{let a=F(r);if(c.kind===`pull-request-markdown`){let r=_(u,e);return r?(0,$.jsx)(A,{...i,src:r,alt:t,title:n,sourceAttributes:a}):(0,$.jsx)(S,{alt:t,title:n,sourceAttributes:a})}if(c.kind!==`repository-file`)return(0,$.jsx)(S,{alt:t,title:n,sourceAttributes:a});let o=y(e,c.path);return o?(0,$.jsx)(A,{...i,src:ee(u,c.sourceOid,o),alt:t,title:n,sourceAttributes:a}):(0,$.jsx)(S,{alt:t,title:n,sourceAttributes:a})},pre:rc},children:e});return(0,$.jsx)(nc.Provider,{value:ne,children:re})}function ac(e,t){return`/api/comments/${e}/placement?${Js(t)}`}function oc(e,t){return!e||e.availability!==`available`?null:Fs(e.ref.kind===`repository-file`?e.ref.path:t,e.text??``,e.ref.kind===`repository-file`?`${e.ref.sourceOid}:${e.ref.path}`:void 0)}function sc({document:e,fileCommentAction:t=null}){let n=e?e.availability===`binary`?`非UTF-8またはbinaryのため本文を表示できません。`:e.availability===`too-large`?`1 MiBを超えるため本文を表示できません。`:`文書が見つかりません。`:`この比較側には文書がありません。`;return(0,$.jsxs)(`div`,{className:`viewer-unavailable`,children:[(0,$.jsx)(`span`,{children:`FILE`}),(0,$.jsx)(`p`,{children:n}),e&&e.availability!==`missing`?t:null]})}function cc({pullRequestId:e,paneId:n,latestHeadOid:s,selectedOid:c,oldOid:g,activeDocument:_,displayMode:v,diffStyle:y,comments:b,activeCommentId:x,fullViewNotice:S=null,fullViewUnavailableMessage:T=null,referenceStaleness:E,themePreference:D,onCommentActiveChange:A,navigationTarget:M=null,onNavigationApplied:N,onOpenMarkdownFragment:ne,onOpenCodeReference:re,onOpenRepositoryLink:P,onOpenLatestReferenceFile:ie,onReresolveWalkthroughReference:ae}){if(_.kind===`walkthrough`)throw Error(`walkthroughはWalkthroughViewerで表示してください。`);let oe=l(),F=_.kind===`pull-request-markdown`||_.path.toLowerCase().endsWith(`.md`)||_.path.toLowerCase().endsWith(`.markdown`),se=Bs(_),[le,de]=(0,Q.useState)(()=>zs.get(se)??`preview`),[fe,pe]=(0,Q.useState)(!1),[me,he]=(0,Q.useState)(null),ge=e=>{zs.set(se,e),de(e)},_e=p({activeDocument:_,pane:n,selectedOid:c,oldOid:g,displayMode:v}),ve=h(n,_),ye=(0,Q.useRef)(d(e)).current,be=te(e,_e),[I,xe]=(0,Q.useState)(be?.selection??null),[L,Se]=(0,Q.useState)(null),[Ce,we]=(0,Q.useState)(be?.markdownComposerOpen??!1),[Te,Ee]=(0,Q.useState)(be?.fileComposerOpen??!1),[De,Oe]=(0,Q.useState)(be?.body??``),[R,ke]=(0,Q.useState)(null);(0,Q.useLayoutEffect)(()=>{if(Te||Ce||I){u(e,_e,ye,{body:De,selection:I,markdownComposerOpen:Ce,fileComposerOpen:Te});return}f(e,_e,ye)},[De,_e,ye,Te,Ce,e,I]);let Ae=(0,Q.useRef)(null),je=(0,Q.useRef)(null),Me=(0,Q.useRef)(N),Ne=(0,Q.useRef)(ne),Pe=(0,Q.useRef)(P);Me.current=N,Ne.current=ne,Pe.current=P;let Fe=(0,Q.useCallback)((e,t)=>Ne.current(e,t),[]),Ie=(0,Q.useCallback)((e,t,n)=>Pe.current(e,t,n),[]),Le=(0,Q.useRef)(null),Re=(0,Q.useRef)(null),z=(0,Q.useRef)(null),ze=(0,Q.useCallback)((e,t,n)=>{if(n!==`unmount`){if(!M||M.line===null){let n=M?.requestId??null;if(z.current===n)return;t.setEditorActiveLine(null),delete e.dataset.searchTargetLine,z.current=n;return}z.current!==M.requestId&&(z.current=M.requestId,e.dataset.searchTargetLine=String(M.line),t.setEditorActiveLine(M.line),Hs(e,M.line,!1,M.resetHorizontal,()=>Me.current(M.requestId)))}},[M]),Be=(0,Q.useCallback)((e,t,n)=>{if(n!==`unmount`){if(!M||M.line===null){let n=M?.requestId??null;if(z.current===n)return;t.setEditorActiveLine(null),delete e.dataset.searchTargetLine,z.current=n;return}z.current!==M.requestId&&(M.endLine!==void 0&&t.revealRange(M.line,M.endLine,5)||!t.isLineRenderable(M.line)&&t.revealLine(M.line)||(z.current=M.requestId,e.dataset.searchTargetLine=String(M.line),t.setEditorActiveLine(M.line,{side:`additions`}),Hs(e,M.line,!0,M.resetHorizontal,()=>Me.current(M.requestId))))}},[M]),B=_.kind===`pull-request-markdown`?`full`:v,Ve=F&&B===`full`&&le===`preview`,V=(0,Q.useMemo)(()=>_.kind===`pull-request-markdown`?{kind:`pull-request-markdown`,pullRequestId:e}:{kind:`repository-file`,pullRequestId:e,sourceOid:_.sourceOid??c,path:_.path},[_.kind,_.kind===`repository-file`?_.path:null,_.kind===`repository-file`?_.sourceOid:null,e,c]),H=_.kind===`repository-file`?_.oldPath===void 0?_.path:_.oldPath:null,He=_.kind===`repository-file`?_.newPath===void 0?_.path:_.newPath:null,U=_.kind===`repository-file`&&(B===`full`?k(_.path):!!(H&&k(H)||He&&k(He))),W=r({queryKey:[`document`,V],queryFn:async()=>(await t(a(V))).document,enabled:B===`full`&&!U&&!T,staleTime:V.kind===`repository-file`?1/0:0}),G=new URLSearchParams({kind:_.kind});_.kind===`repository-file`&&(g&&G.set(`oldOid`,g),G.set(`newOid`,c),H&&G.set(`oldPath`,H),He&&G.set(`newPath`,He));let Ue=r({queryKey:[`diff`,e,g,c,_],queryFn:async()=>(await t(`/api/pull-requests/${e}/diff?${G.toString()}`)).diff,enabled:B!==`full`&&!U&&_.kind===`repository-file`&&!!g&&g!==c}),We=(0,Q.useMemo)(()=>oc(W.data??null,`Pull Request.md`),[W.data]),Ge=(0,Q.useMemo)(()=>oc(Ue.data?.old??null,`Pull Request.md`),[Ue.data?.old]),Ke=(0,Q.useMemo)(()=>oc(Ue.data?.new??null,`Pull Request.md`),[Ue.data?.new]),qe=(0,Q.useMemo)(()=>Ge?Ke?{oldFile:Ge,newFile:Ke}:{oldFile:Ge,newFile:null}:Ke?{oldFile:null,newFile:Ke}:null,[Ke,Ge]),K=(0,Q.useMemo)(()=>!U||_.kind!==`repository-file`?null:B===`full`?{old:null,new:V.kind===`repository-file`?V:null}:{old:g&&H?{kind:`repository-file`,pullRequestId:e,sourceOid:g,path:H}:null,new:He?{kind:`repository-file`,pullRequestId:e,sourceOid:c,path:He}:null},[_.kind,B,V,He,g,H,e,U,c]),q=(0,Q.useMemo)(()=>K||(B===`full`?{old:null,new:V}:{old:Ue.data?.old?.ref??null,new:Ue.data?.new?.ref??null}),[B,V,Ue.data,K]),J=r({queryKey:[`annotations`,b.map(e=>`${e.id}:${e.updatedAt}`),q,q.new?.kind===`pull-request-markdown`?W.data?.text:null],queryFn:async()=>{let e=[],n=[],r=[],i={old:[],new:[]};if(K){for(let e of b){let n=e.target.kind===`document`&&e.target.documentKind===`repository-file`&&K.old?.kind===`repository-file`&&e.target.sourceOid===K.old.sourceOid&&e.target.path===K.old.path?[{side:`old`,ref:K.old},{side:`new`,ref:K.new}]:[{side:`new`,ref:K.new},{side:`old`,ref:K.old}];for(let r of n){if(!r.ref)continue;let{placement:n}=await t(ac(e.id,r.ref));if(!n.outdated&&n.path===r.ref.path){i[r.side].push({comment:e,placement:n});break}}}return{fileAnnotations:e,diffAnnotations:n,markdownComments:r,imageComments:i}}for(let i of b){let a=!1;if(q.new){let{placement:o}=await t(ac(i.id,q.new));if(!o.outdated&&o.path===(q.new.kind===`repository-file`?q.new.path:`Pull Request.md`)){let t=o.range?.endLine??0,s={kind:`comment`,comment:i,placement:o};B===`full`?(e.push({lineNumber:t,metadata:s}),r.push({comment:i,placement:o})):n.push({side:`additions`,lineNumber:t,metadata:s}),a=!0}}if(!a&&q.old){let{placement:e}=await t(ac(i.id,q.old));!e.outdated&&e.path===(q.old.kind===`repository-file`?q.old.path:`Pull Request.md`)&&n.push({side:`deletions`,lineNumber:e.range?.endLine??0,metadata:{kind:`comment`,comment:i,placement:e}})}}return{fileAnnotations:e,diffAnnotations:n,markdownComments:r,imageComments:i}},enabled:!!(q.new||q.old),placeholderData:e=>e}),Y=O({mutationFn:async({target:n,body:r})=>await t(`/api/comments`,o({pullRequestId:e,target:n,body:r,authorLabel:`You`})),onSuccess:async({comment:e},{target:t,location:n})=>{window.getSelection()?.removeAllRanges();let r=t.kind===`document`&&t.startLine!==null&&t.endLine!==null?{startLine:t.startLine,endLine:t.endLine}:null,i=t.kind===`document`?t.documentKind===`pull-request-markdown`?`Pull Request.md`:t.path:null;Ae.current=null,ke({comment:e,placement:{outdated:!1,range:r,path:i},location:n}),Oe(``),xe(null),Se(null),we(!1),Ee(!1),await oe.invalidateQueries({queryKey:[`comments`]}),await oe.invalidateQueries({queryKey:[`change-sequence`]})}}),Je=M?.requestId??null;(0,Q.useLayoutEffect)(()=>{Je!==null&&(Oe(``),xe(null),Se(null),we(!1),Ee(!1),ke(null))},[Je]),(0,Q.useLayoutEffect)(()=>{if(!M||M.line!==null)return;let e=M.requestId,t=window.requestAnimationFrame(()=>{Le.current?.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`}),Me.current(e)});return()=>window.cancelAnimationFrame(t)},[M]),(0,Q.useLayoutEffect)(()=>{if(!K||!M||M.line===null||z.current===M.requestId)return;let e=M.requestId,t=window.requestAnimationFrame(()=>{Le.current?.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`}),z.current=e,Me.current(e)});return()=>window.cancelAnimationFrame(t)},[M,K]);let Ye=B===`full`?V:I?.side===`deletions`||I?.endSide===`deletions`?q.old:q.new,Xe=B===`full`?V:q.new??q.old??null,Ze=I!==null&&Ye!=null&&(!I.side||!I.endSide||I.side===I.endSide),Qe=e=>{let t=e===`file`?Xe:Ye;if(!t||e===`line`&&!I)return;let n=e===`file`?null:Math.min(I.start,I.end),r=e===`file`?null:Math.max(I.start,I.end),i=t.kind===`pull-request-markdown`?{kind:`document`,documentKind:`pull-request-markdown`,startLine:n,endLine:r}:{kind:`document`,documentKind:`repository-file`,sourceOid:t.sourceOid,path:t.path,startLine:n,endLine:r},a=r??0,o=B===`full`?{mode:`full`,lineNumber:a}:{mode:`diff`,side:t.kind===`repository-file`&&q.old?.kind===`repository-file`&&t.sourceOid===q.old.sourceOid&&t.path===q.old.path?`deletions`:`additions`,lineNumber:a};Y.mutate({target:i,location:o,body:De})},$e=(0,Q.useCallback)(async(e,t)=>{let n=V.kind===`pull-request-markdown`?{kind:`document`,documentKind:`pull-request-markdown`,startLine:e.startLine,endLine:e.endLine}:{kind:`document`,documentKind:`repository-file`,sourceOid:V.sourceOid,path:V.path,startLine:e.startLine,endLine:e.endLine};await Y.mutateAsync({target:n,body:t,location:{mode:`full`,lineNumber:e.endLine}})},[Y.mutateAsync,V]),et=()=>{Y.reset(),Oe(``),xe(null),Se(null),we(!1),Ee(!1)},tt=Y.reset,nt=(0,Q.useCallback)(e=>{tt(),Oe(``),xe(null),Se(e),we(!1),e&&Ee(!1)},[tt]),rt=(0,Q.useCallback)(e=>{tt(),Oe(``),xe(e),Se(null),we(!1),e&&Ee(!1)},[tt]),{fileAnnotations:it,diffAnnotations:at}=(0,Q.useMemo)(()=>{let e=[...J.data?.fileAnnotations??[]],t=[...J.data?.diffAnnotations??[]],n=[...e,...t].some(e=>e.metadata?.kind===`comment`&&e.metadata.comment.id===R?.comment.id)||J.data?.markdownComments.some(({comment:e})=>e.id===R?.comment.id);if(R&&!n&&Ae.current!==R.comment.id){let n={kind:`comment`,comment:R.comment,placement:R.placement};R.location.mode===`full`?e.push({lineNumber:R.location.lineNumber,metadata:n}):t.push({side:R.location.side,lineNumber:R.location.lineNumber,metadata:n})}if(I){if(B===`full`)e.push({lineNumber:Math.max(I.start,I.end),metadata:{kind:`line-composer`}});else{let e=I.side&&I.endSide&&I.side!==I.endSide;t.push({side:I.endSide??I.side??`additions`,lineNumber:e?I.end:Math.max(I.start,I.end),metadata:{kind:`line-composer`}})}}return{fileAnnotations:e,diffAnnotations:t}},[J.data,B,R,I]),ot=(0,Q.useMemo)(()=>{let e=[...J.data?.markdownComments??[]];return R&&!e.some(({comment:e})=>e.id===R.comment.id)&&e.push({comment:R.comment,placement:R.placement}),e},[J.data?.markdownComments,R]),st=(0,Q.useMemo)(()=>{let e={old:[...J.data?.imageComments.old??[]],new:[...J.data?.imageComments.new??[]]};return R&&![...e.old,...e.new].some(({comment:e})=>e.id===R.comment.id)&&e[R.location.mode===`diff`&&R.location.side===`deletions`?`old`:`new`].push({comment:R.comment,placement:R.placement}),e},[J.data?.imageComments,R]),ct=(0,Q.useMemo)(()=>ot.map(({comment:e,placement:t})=>({id:e.id,range:t.range})),[ot]),lt=(0,Q.useMemo)(()=>new Map(ot.map(({comment:e,placement:t})=>[e.id,{comment:e,placement:t}])),[ot]),ut=R?.comment.id,dt=(0,Q.useCallback)(({node:e,children:t,...n})=>{let r=ue(e);return r.length===0?(0,$.jsx)(`div`,{...n,children:t}):(0,$.jsx)(`div`,{className:`markdown-inline-comments`,children:r.map(e=>{let t=lt.get(e);return t?(0,$.jsx)(j,{comment:t.comment,variant:`inline`,draftScope:ve,placement:t.placement,themePreference:D,onActiveChange:A,onOpenCodeReference:re,onOpenRepositoryLink:Ie,...t.comment.id===ut?{onDeleted:()=>ke(null)}:{}},e):null})})},[lt,A,re,Ie,ut,ve,D]);(0,Q.useLayoutEffect)(()=>{R&&([...J.data?.fileAnnotations??[],...J.data?.diffAnnotations??[]].some(e=>e.metadata?.kind===`comment`&&e.metadata.comment.id===R.comment.id)||J.data?.markdownComments.some(({comment:e})=>e.id===R.comment.id))&&(Ae.current=R.comment.id)},[J.data,R]),(0,Q.useLayoutEffect)(()=>{let e=Re.current;return Re.current=null,e&&qs(Le.current,e),()=>{Re.current=Ks(Le.current)}},[at,it]);let ft=M&&M.line!==null&&M.endLine!==void 0?{start:M.line,end:M.endLine,...B===`full`?{}:{side:`additions`,endSide:`additions`}}:null,pt=M?.line??null,mt=M?.endLine,ht=(0,Q.useMemo)(()=>pt===null?null:{startLine:pt,endLine:mt??pt},[mt,pt]),gt=W.data?.availability===`available`?W.data.text??``:null,_t=I?{startLine:Math.min(I.start,I.end),endLine:Math.max(I.start,I.end)}:null,vt=Ce?_t?.startLine??null:null,yt=Ce?_t?.endLine??null:null,bt=(0,Q.useMemo)(()=>gt===null?null:ic({text:gt,pullRequestMarkdown:_.kind===`pull-request-markdown`,annotations:ct,activeCommentId:x,selectedRange:vt===null||yt===null?null:{startLine:vt,endLine:yt},navigationRange:ht,composerOpen:Ce,markdownDiv:dt,sourceRef:V,selectedOid:c,pullRequestId:e,themePreference:D,placedComments:ot,replyDraftScope:ve,linkPointerStart:je,onCommentActiveChange:A,onOpenCodeReference:re,onCreateDiagramComment:$e,diagramCommentPending:Y.isPending,diagramCommentError:Y.error,onResetDiagramComment:Y.reset,onOpenRepositoryLink:Ie,onOpenMarkdownFragment:Fe}),[x,_.kind,yt,vt,$e,Y.error,Y.isPending,Y.reset,V,ct,Ce,ht,dt,ot,gt,A,re,Fe,Ie,e,ve,c,D]);(0,Q.useLayoutEffect)(()=>{if(!Ve||!M||M.line===null||z.current===M.requestId||bt===null)return;let e=M.requestId,t=M.line,n=window.requestAnimationFrame(()=>{let n=$s(Le.current,t);n&&(n.scrollIntoView({behavior:`auto`,block:`center`,inline:`nearest`}),z.current=e,Me.current(e))});return()=>window.cancelAnimationFrame(n)},[M,bt,Ve]);let xt=Te?null:L??I??ft,St=(0,$.jsx)(`button`,{className:`comment-icon-button diff-header-comment-button`,"aria-label":`ファイル全体へコメント`,title:`ファイル全体へコメント`,"aria-pressed":Te,disabled:!Xe,onClick:()=>{Y.reset(),xe(null),Se(null),we(!1),Oe(``),Ee(e=>!e)},children:(0,$.jsx)(m,{})}),Ct=(0,$.jsxs)($.Fragment,{children:[S&&(0,$.jsx)(`span`,{className:`diff-fallback-badge`,children:S}),St]});if(B===`full`&&T)return(0,$.jsx)(`div`,{className:`document-viewer`,children:(0,$.jsxs)(`div`,{className:`viewer-unavailable`,children:[(0,$.jsx)(`span`,{children:`FILE`}),(0,$.jsx)(`p`,{children:T})]})});if(B!==`full`&&(!g||g===c))return(0,$.jsx)(`div`,{className:`document-viewer`,children:(0,$.jsxs)(`div`,{className:`viewer-unavailable`,children:[(0,$.jsx)(`span`,{children:`DIFF`}),(0,$.jsx)(`p`,{children:`比較可能なcommit範囲がありません。`})]})});if(!K&&(B===`full`?W.isLoading:Ue.isLoading))return(0,$.jsx)(`div`,{className:`document-viewer`,children:(0,$.jsx)(`div`,{className:`viewer-loading`,children:`文書を準備しています…`})});let wt=K?null:B===`full`?W.error:Ue.error;if(wt)return(0,$.jsx)(`div`,{className:`document-viewer`,children:(0,$.jsx)(`div`,{className:`viewer-error`,children:(0,$.jsx)(C,{error:wt})})});let Tt=I?`L${Math.min(I.start,I.end)}${I.start===I.end?``:`–${Math.max(I.start,I.end)}`}`:null,Et=Ye?.kind===`repository-file`?Ye.path:`Pull Request.md`,Dt=B===`full`?null:I?.side===`deletions`||I?.endSide===`deletions`?`変更前`:`変更後`,Ot=I?`${[Et,Dt,Tt].filter(Boolean).join(` · `)}へコメント`:`選択範囲へコメント`,kt=e=>{if(!e.metadata)return null;if(e.metadata.kind===`comment`){let t=`side`in e?e.side:null;return(0,$.jsx)(j,{comment:e.metadata.comment,variant:`inline`,draftScope:ve,placement:e.metadata.placement,side:t??null,themePreference:D,onActiveChange:A,onOpenCodeReference:re,onOpenRepositoryLink:Ie,...e.metadata.comment.id===R?.comment.id?{onDeleted:()=>ke(null)}:{}})}return(0,$.jsx)(w,{body:De,label:Ot,disabled:!Ze,pending:Y.isPending,error:Y.error,validationError:I?.side&&I.endSide&&I.side!==I.endSide?`old/newをまたぐ選択にはコメントできません。`:void 0,placement:`line`,onBodyChange:Oe,onCancel:et,onSubmit:()=>Qe(`line`)})},At=_.kind===`repository-file`?_.path:`Pull Request.md`,jt=(e,t)=>{let n=st[e];return n.length>0?(0,$.jsx)(`div`,{className:`repository-image-comments`,children:n.map(({comment:e,placement:n})=>(0,$.jsx)(j,{comment:e,variant:`inline`,draftScope:ve,placement:n,side:t,themePreference:D,onActiveChange:A,onOpenCodeReference:re,onOpenRepositoryLink:Ie,...e.id===R?.comment.id?{onDeleted:()=>ke(null)}:{}},e.id))}):null},Mt=K&&_.kind===`repository-file`?(0,$.jsx)(Rs,{mode:B===`full`?`full`:`split`,oldSide:B===`full`?null:{label:`変更前`,path:H,sourceUrl:K.old?.kind===`repository-file`&&k(K.old.path)?ee(e,K.old.sourceOid,K.old.path):null,emptyMessage:H?`変更前は対応画像ではありません。`:`変更前の画像はありません。`,action:K.new?null:St,comments:jt(`old`,`deletions`)},newSide:{label:B===`full`?`全文`:`変更後`,path:B===`full`?_.path:He,sourceUrl:K.new?.kind===`repository-file`&&k(K.new.path)?ee(e,K.new.sourceOid,K.new.path):null,emptyMessage:B===`full`?`画像を表示できません。`:He?`変更後は対応画像ではありません。`:`変更後の画像はありません。`,action:K.new?St:null,comments:jt(`new`,B===`full`?null:`additions`)}}):null,Nt=_.kind===`repository-file`&&_.referenceContext?.outcome===`source-fallback`?_.referenceContext:null,X=_.kind===`repository-file`&&_.referenceContext&&E?_.referenceContext:null,Pt=async e=>{pe(!0),he(null);let t=await ae(e);pe(!1),he(t)};return(0,$.jsxs)(`div`,{className:`document-viewer`,children:[(0,$.jsx)(C,{error:J.error}),X&&E&&(0,$.jsxs)(`div`,{className:`reference-fallback-banner reference-stale-banner`,role:`status`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{children:E.walkthroughChanged?`Walkthroughが更新されています${E.headChanged?` · 解決時 ${X.latestHeadOid.slice(0,8)} → 現在 ${s.slice(0,8)}`:``}`:`解決時 ${X.latestHeadOid.slice(0,8)} → 現在 ${s.slice(0,8)}`}),(0,$.jsxs)(`span`,{children:[Nt?`参照時点のコード · ${Nt.anchorSourceOid.slice(0,8)} を表示中。`:``,E.walkthroughChanged?E.headChanged?`このコード参照はWalkthroughとPRの更新前に解決されています。`:`このコード参照はWalkthroughの更新前に解決されています。`:`このコード参照はPR更新前に解決されています。`,me?` ${me}`:``]})]}),(0,$.jsx)(`button`,{type:`button`,disabled:fe,onClick:()=>void Pt(X),children:fe?`再解決中…`:`最新へ再解決`})]}),Nt&&!X&&(0,$.jsxs)(`div`,{className:`reference-fallback-banner reference-anchor-fallback-banner`,role:`status`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`strong`,{children:[`参照時点のコード · `,Nt.anchorSourceOid.slice(0,8)]}),(0,$.jsx)(`span`,{children:`最新コード上の対応位置を確実に特定できませんでした。`})]}),Nt.latestFile&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ie(Nt.latestFile),children:`最新のファイルを見る`})]}),F&&B===`full`&&(0,$.jsxs)(`div`,{className:`markdown-view-toolbar`,"aria-label":`Markdown表示`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(i,{path:At,kind:`file`}),(0,$.jsx)(`code`,{children:At})]}),(0,$.jsxs)(`div`,{className:`segmented markdown-view-modes`,children:[(0,$.jsx)(`button`,{className:le===`source`?`active`:``,"aria-pressed":le===`source`,onClick:()=>ge(`source`),children:`Source`}),(0,$.jsx)(`button`,{className:le===`preview`?`active`:``,"aria-pressed":le===`preview`,onClick:()=>ge(`preview`),children:`Preview`})]})]}),Te&&(0,$.jsx)(w,{body:De,label:`ファイル全体へコメント`,pending:Y.isPending,error:Y.error,validationError:void 0,placement:`file`,onBodyChange:Oe,onCancel:et,onSubmit:()=>Qe(`file`)}),(0,$.jsx)(`div`,{className:`diff-surface`,ref:Le,"data-pane-find-surface":!0,children:Mt||(Ve?gt===null?(0,$.jsx)(sc,{document:W.data??null,fileCommentAction:St}):(0,$.jsxs)(`div`,{className:`markdown-preview`,children:[(0,$.jsxs)(`header`,{children:[(0,$.jsx)(`span`,{children:`Rendered Markdown`}),(0,$.jsx)(`span`,{children:`テキストを選択して行コメント`}),S&&(0,$.jsx)(`span`,{className:`diff-fallback-badge`,children:S}),St]}),(0,$.jsx)(ce,{selectedRange:_t,composerOpen:Ce,onSelection:e=>{Y.reset(),Oe(``),xe(e?{start:e.startLine,end:e.endLine}:null),Se(null),we(!1),e&&Ee(!1)},onOpenComposer:()=>we(!0),composer:(0,$.jsx)(w,{body:De,label:Ot,pending:Y.isPending,error:Y.error,validationError:void 0,placement:`line`,onBodyChange:Oe,onCancel:et,onSubmit:()=>Qe(`line`)}),children:(0,$.jsx)(`article`,{"data-pane-find-text":!0,children:bt})})]}):B===`full`?We?(0,$.jsx)(As,{file:We,disableWorkerPool:!0,lineAnnotations:it,selectedLines:xt,renderAnnotation:kt,renderHeaderPrefix:e=>(0,$.jsx)(i,{path:e.name,kind:`file`}),renderHeaderMetadata:()=>Ct,options:{stickyHeader:!0,enableGutterUtility:!0,enableLineSelection:!0,lineHoverHighlight:`both`,onGutterUtilityClick:Se,onLineSelectionChange:Se,onLineSelectionEnd:rt,onLineSelectionStart:nt,overflow:`scroll`,theme:{light:`github-light`,dark:`github-dark`},themeType:D,unsafeCSS:Vs,onPostRender:ze}}):(0,$.jsx)(sc,{document:W.data??null,fileCommentAction:St}):qe?(0,$.jsx)(Ps,{...qe,disableWorkerPool:!0,lineAnnotations:at,selectedLines:xt,renderAnnotation:kt,renderHeaderPrefix:e=>(0,$.jsx)(i,{path:e.name,kind:`file`}),renderHeaderMetadata:()=>Ct,options:{stickyHeader:!0,diffStyle:y,enableGutterUtility:!0,enableLineSelection:!0,lineHoverHighlight:`both`,onGutterUtilityClick:Se,onLineSelectionChange:Se,onLineSelectionEnd:rt,onLineSelectionStart:nt,overflow:`scroll`,theme:{light:`github-light`,dark:`github-dark`},themeType:D,unsafeCSS:Vs,onPostRender:Be}}):(0,$.jsx)(sc,{document:Ue.data?.new??Ue.data?.old??null,fileCommentAction:St}))})]})}export{cc as DocumentViewer};
|