t3 0.0.0-alpha.19 → 0.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{DiffPanel-Bc1OLiPP.js → DiffPanel-D9rEOsE2.js} +7 -7
- package/dist/client/assets/{angular-html-CRjrfS04.js → angular-html-CpuZW5Ea.js} +1 -1
- package/dist/client/assets/{angular-ts-BGir_rwD.js → angular-ts-W8Bu6z2k.js} +1 -1
- package/dist/client/assets/{apl-5DDqv_Oo.js → apl-CcpxpCrP.js} +1 -1
- package/dist/client/assets/{astro-Dj01mIak.js → astro-YdCZU42E.js} +1 -1
- package/dist/client/assets/{blade-gr3X876m.js → blade-BthXPVEf.js} +1 -1
- package/dist/client/assets/{c-ukqYSIuV.js → c-DmGnoXx0.js} +1 -1
- package/dist/client/assets/{cobol-D-LW7mEK.js → cobol-D4dt8yi7.js} +1 -1
- package/dist/client/assets/{coffee-BtOiMwvf.js → coffee-D27kWmBH.js} +1 -1
- package/dist/client/assets/{cpp-DdhpR3Xz.js → cpp-DM8bUlHG.js} +1 -1
- package/dist/client/assets/{crystal-BIZwHTrP.js → crystal-BGIso-3f.js} +1 -1
- package/dist/client/assets/{css--rVQ7YVz.js → css-CMiGXy8R.js} +1 -1
- package/dist/client/assets/{edge-BqBSxWBs.js → edge-RJ8498Uo.js} +1 -1
- package/dist/client/assets/{elixir-BCxeIuRr.js → elixir-CPt2mV7_.js} +1 -1
- package/dist/client/assets/{elm-Br0Ps4DN.js → elm-BRpQuQMU.js} +1 -1
- package/dist/client/assets/{erb-DI5DcsWO.js → erb-tKoaTw1s.js} +1 -1
- package/dist/client/assets/{git-rebase-M-t077u7.js → git-rebase-C4iVfAIK.js} +1 -1
- package/dist/client/assets/{glimmer-js-BxIJl1p-.js → glimmer-js-ZXp8Qinj.js} +1 -1
- package/dist/client/assets/{glimmer-ts-C6BWznIz.js → glimmer-ts-LWKowVG7.js} +1 -1
- package/dist/client/assets/{glsl-BNL0PbqG.js → glsl-BW0C_3sa.js} +1 -1
- package/dist/client/assets/{graphql-Cwh0hNz7.js → graphql-DYwctpiQ.js} +1 -1
- package/dist/client/assets/{hack-CGsdxQl7.js → hack-BgGuG1qx.js} +1 -1
- package/dist/client/assets/{haml-DKQbVBrQ.js → haml-IzncgXNJ.js} +1 -1
- package/dist/client/assets/{handlebars-DJUTV2Bd.js → handlebars-3Q73qXlr.js} +1 -1
- package/dist/client/assets/{html-Dq2tQ5cT.js → html-BE78FVHd.js} +1 -1
- package/dist/client/assets/{html-derivative-BHw55ltK.js → html-derivative-cK6jNlbV.js} +1 -1
- package/dist/client/assets/{http-DHYaWiuY.js → http-ZDSqKdoz.js} +1 -1
- package/dist/client/assets/{hurl-CBOFMB1n.js → hurl-CLJOuBC6.js} +1 -1
- package/dist/client/assets/index-DY72HmVo.js +285 -0
- package/dist/client/assets/index-afsjCzQq.css +1 -0
- package/dist/client/assets/{java-Bkw9w1Kj.js → java-DiIW5dfK.js} +1 -1
- package/dist/client/assets/{javascript-3p0gOkx9.js → javascript-Br3rOIM5.js} +1 -1
- package/dist/client/assets/{jinja-BrH57TTL.js → jinja-B4aSfbYM.js} +1 -1
- package/dist/client/assets/{jison-nfLCKLpF.js → jison-DdUHLXsY.js} +1 -1
- package/dist/client/assets/{json-DVcKLnVO.js → json-kSQj4Vnr.js} +1 -1
- package/dist/client/assets/{jsx-BN3u6ocj.js → jsx-DF7362Hu.js} +1 -1
- package/dist/client/assets/{julia-DrkOG3u9.js → julia-C3C1qdAp.js} +1 -1
- package/dist/client/assets/{latex-DJ1TFIZI.js → latex-C8dhGjMo.js} +1 -1
- package/dist/client/assets/{liquid-D_wIcjBo.js → liquid-oMyhW7EH.js} +1 -1
- package/dist/client/assets/{lua-CY6wjnMh.js → lua-CwYxKYdU.js} +1 -1
- package/dist/client/assets/{marko-C5g-itwz.js → marko-CTx7ct7Y.js} +1 -1
- package/dist/client/assets/{mdc-Nazlt0Nx.js → mdc-DugnbkcR.js} +1 -1
- package/dist/client/assets/{nginx-BUMTJPV_.js → nginx-CJPRx5Yx.js} +1 -1
- package/dist/client/assets/{nim-DtKYGNYb.js → nim-DrnsQJuW.js} +1 -1
- package/dist/client/assets/{perl-CyjT5Sei.js → perl-h4KXTAsZ.js} +1 -1
- package/dist/client/assets/{php-DAgEMv29.js → php-TJIBBkXs.js} +1 -1
- package/dist/client/assets/{pug-00AZHPeY.js → pug-CslHQA5X.js} +1 -1
- package/dist/client/assets/{qml-BpxdA4n1.js → qml-Dn2dJMtT.js} +1 -1
- package/dist/client/assets/{r-DL8yUest.js → r-7WNIAFSt.js} +1 -1
- package/dist/client/assets/{razor-CeIHKSSV.js → razor-PJY-EbSx.js} +1 -1
- package/dist/client/assets/{regexp-C9rwDX3c.js → regexp-CYwE1wN2.js} +1 -1
- package/dist/client/assets/{rst-BqCGy89b.js → rst-BB1WnRT-.js} +1 -1
- package/dist/client/assets/{ruby-BNUbX397.js → ruby-DSFfn1pD.js} +1 -1
- package/dist/client/assets/{sas-ChR2HvHn.js → sas-wIWguG8K.js} +1 -1
- package/dist/client/assets/{scss-G3HdI6Do.js → scss-D9swBBVZ.js} +1 -1
- package/dist/client/assets/{shellscript-Cr900R6t.js → shellscript-CDyMnLJe.js} +1 -1
- package/dist/client/assets/{shellsession-Zhbrj7H8.js → shellsession-KI2plDh0.js} +1 -1
- package/dist/client/assets/{soy-2rSc87-m.js → soy-BFtmFzMA.js} +1 -1
- package/dist/client/assets/{sql-LybXCoD_.js → sql-DM6jiFcy.js} +1 -1
- package/dist/client/assets/{stata-Cu6wmu-A.js → stata-iLLes9gz.js} +1 -1
- package/dist/client/assets/{surrealql-CksTdaGB.js → surrealql-BZI-pKkA.js} +1 -1
- package/dist/client/assets/{svelte-DJhiqzcz.js → svelte-Dk0i8qWf.js} +1 -1
- package/dist/client/assets/{templ-q5bDY6Go.js → templ-PankK25u.js} +1 -1
- package/dist/client/assets/{tex-DGn-1ixE.js → tex-o0jYMwg8.js} +1 -1
- package/dist/client/assets/{ts-tags-BjxVDKqw.js → ts-tags-s0OLYH-l.js} +1 -1
- package/dist/client/assets/{tsx-CbCYKwP6.js → tsx-C44lMQrJ.js} +1 -1
- package/dist/client/assets/{twig-Djv0sXYh.js → twig-DtIEtY0h.js} +1 -1
- package/dist/client/assets/{typescript-aDgn_wpV.js → typescript-DWSd0SNH.js} +1 -1
- package/dist/client/assets/{vue-0agY6UI2.js → vue-B0dFYLOi.js} +1 -1
- package/dist/client/assets/{vue-html-CxSbOcNP.js → vue-html-CJeK5EU2.js} +1 -1
- package/dist/client/assets/{vue-vine-DYARpsH-.js → vue-vine-CGzyC385.js} +1 -1
- package/dist/client/assets/{xml-7Yawd7Do.js → xml-be_gzwRU.js} +1 -1
- package/dist/client/assets/{xsl-COcuSGq0.js → xsl-BaF0ivyH.js} +1 -1
- package/dist/client/assets/{yaml-Ba5yu-B2.js → yaml-DJCOo0hO.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/mockServiceWorker.js +349 -0
- package/package.json +9 -1
- package/dist/client/assets/index-BVEkkLN1.css +0 -1
- package/dist/client/assets/index-XENPR9M4.js +0 -285
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,Ft as f,G as p,Gt as m,H as h,Ht as g,I as _,It as v,J as y,K as b,L as x,Lt as S,M as C,Mt as w,N as T,Nt as E,O as D,Ot as O,P as k,Pt as A,Q as j,R as M,Rt as N,S as P,St as F,T as ee,Tt as I,U as te,Ut as ne,V as re,Vt as ie,W as L,X as R,Y as ae,Z as z,_ as oe,_t as se,a as ce,at as le,b as ue,bt as B,c as de,ct as fe,d as V,dt as pe,et as me,f as H,ft as he,g as ge,gt as _e,h as ve,ht as ye,i as be,it as xe,j as Se,jt as Ce,k as we,kt as U,l as Te,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,r as Ie,rt as W,s as Le,st as Re,t as ze,tt as Be,u as Ve,ut as He,v as Ue,vt as We,w as Ge,wt as Ke,x as qe,xt as Je,y as Ye,yt as Xe,z as Ze,zt as Qe}from"./index-XENPR9M4.js";var $e=_e(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),et=_e(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),tt={position:`absolute`,top:0,bottom:0,textAlign:`center`};function G(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}var K=g();function nt(e,t){return typeof window>`u`&&t!=null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,K.jsx)(K.Fragment,{children:e})}var q=new Set,rt=new Set,it=null,at=!1;function J(e){if(at){q.add(e);return}rt.add(e),it??=requestAnimationFrame(ot)}function ot(e){at=!0;for(let t of rt)try{t(e)}catch(e){console.error(e)}rt.clear(),q.size>0?(rt=new Set(q),q.clear(),it=requestAnimationFrame(ot)):it=null,at=!1}function st(e,t){return e==null||t==null?e===t:e.top===t.top&&e.bottom===t.bottom}function ct({scrollTop:e,scrollHeight:t,height:n,containerOffset:r=0,fitPerfectly:i,overscrollSize:a}){let o=n+a*2,s=i?n:o;if(t=Math.max(t,s),o>=t||i){let n=Math.max(e-r,0),i=Math.min(e+s,t)-r;return{top:n,bottom:Math.max(i,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c-r,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t)-r,c))}}var lt=1e3,ut=lt*4,dt=[0,1e-6,.99999,1],ft={overscrollSize:lt,intersectionObserverMargin:ut,resizeDebugging:!1},pt=0,mt=-1,ht=class e{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++mt}`;config;type=`basic`;intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...ft,...e}}setup(t,n){if(this.root==null){this.root=t,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:dt,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),t instanceof Document?this.setupWindow():this.setupElement(n),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:e.__lastScrollPosition}),J(this.computeRenderRangeAndEmit)):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)};for(let[e,t]of this.connectQueue.entries())this.connect(e,t);this.connectQueue.clear(),this.markDOMDirty(),J(this.computeRenderRangeAndEmit)}}instanceChanged(e){this.instancesChanged.add(e),J(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ct({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){let n=this.getScrollTop(),r=this.getHeight(),i=this.config.intersectionObserverMargin,a=n-i,o=n+r+i;return!(e<a-t||e>o)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(let n of e){let e=n.borderBoxSize[0].blockSize;this.root instanceof Document?e!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: content size change`,this.__id,{sizeChange:e-pt,newSize:e}),pt=e)):n.target===this.root?e!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: scroller size change`,this.__id,{sizeChange:e-pt,newSize:e}),pt=e))}t&&J(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw Error(`Virtualizer.setupWindow: Invalid setup method`);window.addEventListener(`scroll`,this.handleWindowScroll,{passive:!0}),window.addEventListener(`resize`,this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw Error(`Virtualizer.setupElement: Invalid setup method`);this.root.addEventListener(`scroll`,this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleElementScroll),window.removeEventListener(`scroll`,this.handleWindowScroll),window.removeEventListener(`resize`,this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+Y(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw Error(`Virtualizer.connect: instance is already connected...`);return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),J(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){let t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),J(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{e.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,J(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{e.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,J(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{e.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,J(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(e.__STOP)return;let t=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;if(this.instancesChanged.size===0){let e=ct({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize});if(st(this.windowSpecs,e)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;this.windowSpecs=e}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;let n=this.getScrollAnchor(this.height),r=new Set;for(let e of this.visibleInstances.values())e.onRender(t)&&r.add(e);for(let e of this.instancesChanged)r.has(e)||e.onRender(t)&&r.add(e);this.scrollFix(n),this.instancesChanged.size>0&&this.markDOMDirty();for(let e of r)e.reconcileHeights();(this.instancesChanged.size>0||t)&&J(this.computeRenderRangeAndEmit),r.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;let t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:i,fileOffset:a,fileTypeOffset:o}=e;if(n!=null&&r!=null){let e=i.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(e instanceof HTMLElement){let n=Y(e,t);if(n!==r){let e=n-r;this.applyScrollFix(e)}return}}let s=Y(i,t);if(o===`top`)s!==a&&this.applyScrollFix(s-a);else{let e=s+i.getBoundingClientRect().height;e!==a&&this.applyScrollFix(e-a)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:`instant`}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:`instant`}),this.markDOMDirty()}getScrollAnchor(e){let t=this.getScrollContainerElement(),n;for(let[r]of this.visibleInstances.entries()){let i=Y(r,t),a=i+r.offsetHeight,o,s;a<=0?(o=a,s=`bottom`):(o=i,s=`top`);let c,l;if(a>0&&i<e)for(let e of r.shadowRoot?.querySelectorAll(`[data-line][data-line-index]`)??[]){if(!(e instanceof HTMLElement))continue;let n=e.dataset.lineIndex;if(n==null)continue;let r=Y(e,t);if(!(r<0)){c=n,l=r;break}}if(n?.lineOffset!=null&&l==null)continue;let u=!1;(n==null||l!=null&&(n.lineOffset==null||l<n.lineOffset)||l==null&&n.lineOffset==null&&(o>=0&&(n.fileOffset<0||o<n.fileOffset)||o<0&&n.fileOffset<0&&o>n.fileOffset))&&(u=!0),u&&(n={fileElement:r,fileTypeOffset:s,fileOffset:o,lineIndex:c,lineOffset:l})}return n}handleIntersectionChange=e=>{this.scrollDirty=!0;for(let{target:t,isIntersecting:n}of e){if(!(t instanceof HTMLElement))throw Error(`Virtualizer.handleIntersectionChange: target not an HTMLElement`);let e=this.observers.get(t);if(e==null)throw Error(`Virtualizer.handleIntersectionChange: no instance for target`);n&&!this.visibleInstances.has(t)?(e.setVisibility(!0),this.visibleInstances.set(t,e),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(e.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0)}this.visibleInstancesDirty&&J(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function Y(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect().top??0;return n.top-r}var X=m(ne(),1),gt=(0,X.createContext)(void 0);function _t({children:e,config:t,className:n,style:r,contentClassName:i,contentStyle:a}){let[o]=(0,X.useState)(()=>typeof window<`u`?new ht(t):void 0),s=(0,X.useCallback)(e=>{e==null?o?.cleanUp():o?.setup(e)},[o]);return(0,K.jsx)(gt.Provider,{value:o,children:(0,K.jsx)(`div`,{className:n,style:r,ref:s,children:(0,K.jsx)(`div`,{className:i,style:a,children:e})})})}function vt(){return(0,X.useContext)(gt)}function yt(e){let t=(0,X.useRef)(e);return(0,X.useInsertionEffect)(()=>void(t.current=e)),(0,X.useCallback)((...e)=>t.current(...e),[])}function bt(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}var xt=class{pre;selectedRange=null;renderedSelectionRange;anchor;_queuedRender;constructor(e={}){this.options=e}setOptions(e){this.options={...this.options,...e},this.removeEventListeners(),this.options.enableLineSelection===!0&&this.attachEventListeners()}cleanUp(){this.removeEventListeners(),this._queuedRender!=null&&(cancelAnimationFrame(this._queuedRender),this._queuedRender=void 0),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0}setup(e){if(this.setDirty(),this.pre!==e){this.cleanUp(),this.pre=e;let{enableLineSelection:t=!1}=this.options;t?this.attachEventListeners():this.removeEventListeners()}this.setSelection(this.selectedRange)}setDirty(){this.renderedSelectionRange=void 0}isDirty(){return this.renderedSelectionRange===void 0}setSelection(e){let t=!(e===this.selectedRange||bt(e??void 0,this.selectedRange??void 0));!this.isDirty()&&!t||(this.selectedRange=e,this.renderSelection(),t&&this.notifySelectionChange())}getSelection(){return this.selectedRange}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}attachEventListeners(){this.pre!=null&&(this.removeEventListeners(),this.pre.setAttribute(`data-interactive-line-numbers`,``),this.pre.addEventListener(`pointerdown`,this.handleMouseDown))}removeEventListeners(){this.pre!=null&&(this.pre.removeEventListener(`pointerdown`,this.handleMouseDown),document.removeEventListener(`pointermove`,this.handleMouseMove),document.removeEventListener(`pointerup`,this.handleMouseUp),this.pre.removeAttribute(`data-interactive-line-numbers`))}handleMouseDown=e=>{let t=e.button===0?this.getMouseEventDataForPath(e.composedPath(),`click`):void 0;if(t==null||this.pre==null)return;e.preventDefault();let{lineNumber:n,eventSide:r,lineIndex:i}=t;if(e.shiftKey&&this.selectedRange!=null){let e=this.getIndexesFromSelection(this.selectedRange,this.pre.getAttribute(`data-diff-type`)===`split`);if(e==null)return;let t=e.start<=e.end?i>=e.start:i<=e.end;this.anchor={line:t?this.selectedRange.start:this.selectedRange.end,side:(t?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side)??`additions`},this.updateSelection(n,r),this.notifySelectionStart(this.selectedRange)}else{if(this.selectedRange?.start===n&&this.selectedRange?.end===n){this.updateSelection(null),this.notifySelectionEnd(null),this.notifySelectionChange();return}this.selectedRange=null,this.anchor={line:n,side:r},this.updateSelection(n,r),this.notifySelectionStart(this.selectedRange)}document.addEventListener(`pointermove`,this.handleMouseMove),document.addEventListener(`pointerup`,this.handleMouseUp)};handleMouseMove=e=>{let t=this.getMouseEventDataForPath(e.composedPath(),`move`);if(t==null||this.anchor==null)return;let{lineNumber:n,eventSide:r}=t;this.updateSelection(n,r)};handleMouseUp=()=>{this.anchor=void 0,document.removeEventListener(`pointermove`,this.handleMouseMove),document.removeEventListener(`pointerup`,this.handleMouseUp),this.notifySelectionEnd(this.selectedRange),this.notifySelectionChange()};updateSelection(e,t){if(e==null)this.selectedRange=null;else{let n=this.anchor?.side??t;this.selectedRange={start:this.anchor?.line??e,end:e,side:n,endSide:n===t?void 0:t}}this._queuedRender??=requestAnimationFrame(this.renderSelection)}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}renderSelection=()=>{if(this._queuedRender!=null&&(cancelAnimationFrame(this._queuedRender),this._queuedRender=void 0),this.pre==null||this.renderedSelectionRange===this.selectedRange)return;let e=this.pre.querySelectorAll(`[data-selected-line]`);for(let t of e)t.removeAttribute(`data-selected-line`);if(this.renderedSelectionRange=this.selectedRange,this.selectedRange==null)return;let{children:t}=this.pre;if(t.length===0)return;if(t.length>2)throw console.error(t),Error(`LineSelectionManager.applySelectionToDOM: Somehow there are more than 2 code elements...`);let n=this.pre.getAttribute(`data-diff-type`)===`split`,r=this.getIndexesFromSelection(this.selectedRange,n);if(r==null)throw console.error({rowRange:r,selectedRange:this.selectedRange}),Error(`LineSelectionManager.renderSelection: No valid rowRange`);let i=r.start===r.end,a=Math.min(r.start,r.end),o=Math.max(r.start,r.end);for(let e of t){let[t,r]=e.children,s=r.children.length;if(s!==t.children.length)throw Error(`LineSelectionManager.renderSelection: gutter and content children dont match, something is wrong`);for(let e=0;e<s;e++){let s=r.children[e],c=t.children[e];if(!(s instanceof HTMLElement)||!(c instanceof HTMLElement))continue;let l=this.parseLineIndex(s,n);if((l??0)>o)break;if(l==null||l<a)continue;let u=i?`single`:l===a?`first`:l===o?`last`:``;s.setAttribute(`data-selected-line`,u),c.setAttribute(`data-selected-line`,u),c.nextSibling instanceof HTMLElement&&s.nextSibling instanceof HTMLElement&&s.nextSibling.hasAttribute(`data-line-annotation`)&&(i?(u=`last`,s.setAttribute(`data-selected-line`,`first`)):l===a?u=``:l===o&&s.setAttribute(`data-selected-line`,``),s.nextSibling.setAttribute(`data-selected-line`,u),c.nextSibling.setAttribute(`data-selected-line`,u))}}};notifySelectionChange(){let{onLineSelected:e}=this.options;e?.(this.selectedRange??null)}notifySelectionStart(e){let{onLineSelectionStart:t}=this.options;t?.(e)}notifySelectionEnd(e){let{onLineSelectionEnd:t}=this.options;t?.(e)}getMouseEventDataForPath(e,t){if(this.pre==null)return;let n,r,i=!1,a;for(let t of e){if(n!=null&&r!=null&&a!=null)break;if(t instanceof HTMLElement){if(t.hasAttribute(`data-line-index`)){i=t.hasAttribute(`data-column-number`),n=this.getLineNumber(t),r=this.parseLineIndex(t,this.pre.getAttribute(`data-diff-type`)===`split`);let e=t.getAttribute(`data-line-type`);e===`change-deletion`?a=`deletions`:e===`change-additions`&&(a=`additions`);continue}if(a==null&&t.hasAttribute(`data-code`)){a=t.hasAttribute(`data-deletions`)?`deletions`:t.hasAttribute(`data-additions`)?`additions`:void 0;break}}}if(!(t===`click`&&!i||r==null||n==null))return{lineIndex:r,lineNumber:n,eventSide:a??`additions`}}getLineNumber(e){let t=parseInt(e.getAttribute(`data-column-number`)??e.getAttribute(`data-line`)??``,10);return Number.isNaN(t)?void 0:t}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>parseInt(e)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function St({enableLineSelection:e,onLineSelected:t,onLineSelectionStart:n,onLineSelectionEnd:r},i){return{enableLineSelection:e,onLineSelected:t,onLineSelectionStart:n,onLineSelectionEnd:r,getLineIndex:i}}function Ct(e,t){return e==null?!1:t===`file`?e.type===`line`:e.type===`diff-line`}function wt(e){return e?.type===`line-info`}var Tt=class{hoveredLine;pre;hoverSlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasEventListeners=!1;constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handleMouseClick),this.pre?.removeEventListener(`pointermove`,this.handleMouseMove),this.pre?.removeEventListener(`pointerleave`,this.handleMouseLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.clearHoveredLine(),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasEventListeners=!1,this.pre=void 0}setup(e){let{__debugMouseEvents:t,onLineClick:n,onLineNumberClick:r,onLineEnter:i,onLineLeave:a,onHunkExpand:o,enableHoverUtility:s=!1,lineHoverHighlight:c=`disabled`}=this.options,l=this.pre!==e;if(l&&(this.cleanUp(),this.pre=e,this.hasEventListeners=!1),s&&this.hoverSlot==null){this.hoverSlot=document.createElement(`div`),this.hoverSlot.setAttribute(`data-hover-slot`,``);let e=document.createElement(`slot`);e.name=`hover-slot`,this.hoverSlot.appendChild(e)}else !s&&this.hoverSlot!=null&&(this.hoverSlot.parentNode?.removeChild(this.hoverSlot),this.hoverSlot=void 0);let u=c!==`disabled`||n!=null||r!=null||o!=null||i!=null||a!=null||s;(l||!this.hasEventListeners)&&u?(this.hasEventListeners=!0,e.addEventListener(`click`,this.handleMouseClick),n==null?r!=null&&(e.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!0):(e.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0,this.interactiveLineNumbersAttr=!1),Z(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(n!=null&&e.push(`onLineClick`),r!=null&&e.push(`onLineNumberClick`),o!=null&&e.push(`expandable hunk separators`)),e})()),e.addEventListener(`pointermove`,this.handleMouseMove),Z(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),e.addEventListener(`pointerleave`,this.handleMouseLeave),Z(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!u&&this.hasEventListeners&&(this.pre?.removeEventListener(`click`,this.handleMouseClick),this.pre?.removeEventListener(`pointermove`,this.handleMouseMove),this.pre?.removeEventListener(`pointerleave`,this.handleMouseLeave),this.hasEventListeners=!1),l||(n==null?r==null?(this.interactiveLinesAttr&&=(e.removeAttribute(`data-interactive-lines`),!1),this.interactiveLineNumbersAttr&&=(e.removeAttribute(`data-interactive-line-numbers`),!1)):(this.interactiveLinesAttr&&=(e.removeAttribute(`data-interactive-lines`),!1),this.interactiveLineNumbersAttr||=(e.setAttribute(`data-interactive-line-numbers`,``),!0)):(this.interactiveLineNumbersAttr&&=(e.removeAttribute(`data-interactive-line-numbers`),!1),this.interactiveLinesAttr||=(e.setAttribute(`data-interactive-lines`,``),!0)))}getHoveredLine=()=>{if(this.hoveredLine!=null){if(this.mode===`diff`&&this.hoveredLine.type===`diff-line`)return{lineNumber:this.hoveredLine.lineNumber,side:this.hoveredLine.annotationSide};if(this.mode===`file`&&this.hoveredLine.type===`line`)return{lineNumber:this.hoveredLine.lineNumber}}};handleMouseClick=e=>{let{onLineClick:t,onLineNumberClick:n,onHunkExpand:r}=this.options;t==null&&n==null&&r==null||(Z(this.options.__debugMouseEvents,`click`,`FileDiff.DEBUG.handleMouseClick:`,e),this.handleMouseEvent({eventType:`click`,event:e}))};handleMouseMove=e=>{let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,enableHoverUtility:i=!1}=this.options;t===`disabled`&&!i&&n==null&&r==null||(Z(this.options.__debugMouseEvents,`move`,`FileDiff.DEBUG.handleMouseMove:`,e),this.handleMouseEvent({eventType:`move`,event:e}))};handleMouseLeave=e=>{let{__debugMouseEvents:t}=this.options;if(Z(t,`move`,`FileDiff.DEBUG.handleMouseLeave: no event`),this.hoveredLine==null){Z(t,`move`,`FileDiff.DEBUG.handleMouseLeave: returned early, no .hoveredLine`);return}this.hoverSlot?.parentElement?.removeChild(this.hoverSlot),this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()};handleMouseEvent({eventType:e,event:t}){let{__debugMouseEvents:n}=this.options,r=t.composedPath();Z(n,e,`FileDiff.DEBUG.handleMouseEvent:`,{eventType:e,composedPath:r});let i=this.getLineData(r);Z(n,e,`FileDiff.DEBUG.handleMouseEvent: getLineData result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onHunkExpand:l}=this.options;switch(e){case`move`:if(Ct(i,this.mode)&&this.hoveredLine?.lineElement===i.lineElement){Z(n,`move`,`FileDiff.DEBUG.handleMouseEvent: switch, 'move', returned early because same line`);break}this.hoveredLine!=null&&(Z(n,`move`,`FileDiff.DEBUG.handleMouseEvent: switch, 'move', clearing an existing hovered line and firing onLineLeave`),this.hoverSlot?.parentElement?.removeChild(this.hoverSlot),c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),Ct(i,this.mode)&&(Z(n,`move`,`FileDiff.DEBUG.handleMouseEvent: switch, 'move', setting up a new hoveredLine and firing onLineEnter`),this.setHoveredLine(i),this.hoverSlot!=null&&i.numberElement?.appendChild(this.hoverSlot),s?.({...this.hoveredLine,event:t}));break;case`click`:if(Z(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', with data:`,i),i==null)break;if(wt(i)&&l!=null){Z(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', expanding a hunk`),l(i.hunkIndex,i.direction);break}Ct(i,this.mode)&&(o!=null&&i.numberColumn?(Z(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', firing 'onLineNumberClick'`),o({...i,event:t})):a==null?Z(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', fell through, no event to fire`):(Z(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', firing 'onLineClick'`),a({...i,event:t})));break}}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`,``))}getLineData(e){let t=!1,n,r,i,a,o,s,c;for(let l of e){if(!(l instanceof HTMLElement))continue;let e=o==null?l.getAttribute(`data-column-number`)??void 0:void 0;if(e){o=l,c=Number.parseInt(e,10),t=!0,n=Ot(l),a=l.getAttribute(`data-line-index`)??void 0;continue}let u=i==null?l.getAttribute(`data-line`)??void 0:void 0;if(u){i=l,c=Number.parseInt(u,10),n=Ot(l),a=l.getAttribute(`data-line-index`)??void 0;continue}if(s==null&&l.hasAttribute(`data-expand-button`)){s={hunkIndex:void 0,direction:l.hasAttribute(`data-expand-up`)?`up`:l.hasAttribute(`data-expand-down`)?`down`:`both`};continue}let d=s==null?void 0:l.getAttribute(`data-expand-index`)??void 0;if(s!=null&&d!=null){let e=Number.parseInt(d,10);Number.isNaN(e)||(s.hunkIndex=e);continue}if(r==null&&l.hasAttribute(`data-code`)){r=l;break}}if(s?.hunkIndex!=null){let{hunkIndex:e,direction:t}=s;return{type:`line-info`,hunkIndex:e,direction:t}}if(i??=a==null?void 0:Dt(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:Dt(r,`[data-column-number][data-line-index="${a}"]`),!(r==null||i==null||o==null||n==null))return this.mode===`file`?{type:`line`,lineElement:i,lineNumber:c,numberElement:o,numberColumn:t}:{type:`diff-line`,annotationSide:(()=>{switch(n){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return r.hasAttribute(`data-deletions`)?`deletions`:`additions`}})(),lineType:n,lineElement:i,numberElement:o,lineNumber:c,numberColumn:t}}};function Z(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;break}console.log(...n)}function Et({lineHoverHighlight:e,onLineClick:t,onLineNumberClick:n,onLineEnter:r,onLineLeave:i,enableHoverUtility:a,__debugMouseEvents:o},s){return{lineHoverHighlight:e,onLineClick:t,onLineNumberClick:n,onLineEnter:r,onLineLeave:i,enableHoverUtility:a,__debugMouseEvents:o,onHunkExpand:s}}function Dt(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function Ot(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}}var kt=class{observedNodes=new Map;timeoutID;queuedUpdates=new Map;cleanUp(){this.resizeObserver?.disconnect(),this.observedNodes.clear(),this.timeoutID!=null&&clearTimeout(this.timeoutID)}resizeObserver;setup(e,t){this.resizeObserver??=new ResizeObserver(this.handleResizeObserver);let n=e.querySelectorAll(`code`),r=new Map(this.observedNodes);this.observedNodes.clear();for(let e of n){let t=r.get(e);if(t!=null){this.observedNodes.set(e,t),r.delete(e);continue}let n=e.querySelector(`[data-gutter]`);n instanceof HTMLElement||(n=null),t={type:`code`,codeElement:e,numberElement:n,codeWidth:`auto`,numberWidth:0},this.observedNodes.set(e,t),this.resizeObserver.observe(e),n!=null&&(this.observedNodes.set(n,t),this.resizeObserver.observe(n))}if(n.length>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let{lineAnnotation:t=``}=e.dataset;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,o=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(o instanceof HTMLElement))continue;let s=r.get(a);if(s!=null){this.observedNodes.set(a,s),this.observedNodes.set(o,s),r.delete(a),r.delete(o);continue}s={type:`annotations`,column1:{container:n,child:a,childHeight:a.getBoundingClientRect().height},column2:{container:i,child:o,childHeight:o.getBoundingClientRect().height},currentHeight:`auto`};let c=Math.max(s.column1.childHeight,s.column2.childHeight);this.applyNewHeight(s,c),this.observedNodes.set(a,s),this.observedNodes.set(o,s),this.resizeObserver.observe(a),this.resizeObserver.observe(o)}}for(let e of r.keys())e.isConnected&&(e.style.removeProperty(`--diffs-column-content-width`),e.style.removeProperty(`--diffs-column-number-width`),e.style.removeProperty(`--diffs-column-width`),e.parentElement instanceof HTMLElement&&e.parentElement.style.removeProperty(`--diffs-annotation-min-height`)),this.resizeObserver.unobserve(e);r.clear()}handleResizeObserver=e=>{for(let t of e){let{target:e,borderBoxSize:n}=t;if(!(e instanceof HTMLElement)){console.error(`FileDiff.handleResizeObserver: Invalid element for ResizeObserver`,t);continue}let r=this.observedNodes.get(e);if(r==null){console.error(`FileDiff.handleResizeObserver: Not a valid observed node`,t);continue}let i=n[0];if(r.type===`annotations`){let t=(()=>{if(e===r.column1.child)return r.column1;if(e===r.column2.child)return r.column2})();if(t==null){console.error(`FileDiff.handleResizeObserver: Couldn't find a column for`,{item:r,target:e});continue}t.childHeight=i.blockSize;let n=Math.max(r.column1.childHeight,r.column2.childHeight);this.applyNewHeight(r,n)}else r.type===`code`&&(this.queuedUpdates.set(e,[r,i]),this.queueColumnUpdate())}};queueColumnUpdate(){this.timeoutID!=null&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout(this.handleColumnChange,1e3/30)}handleColumnChange=()=>{this.timeoutID=void 0;for(let[e,[t,n]]of this.queuedUpdates)if(e===t.codeElement){let e=Math.max(Math.floor(n.inlineSize),0);if(e!==t.codeWidth){t.codeWidth=e;let n=Math.max(t.codeWidth-t.numberWidth,0);t.codeElement.style.setProperty(`--diffs-column-content-width`,`${n===0?`auto`:`${n}px`}`),t.codeElement.style.setProperty(`--diffs-column-width`,`${t.codeWidth===0?`auto`:`${t.codeWidth}px`}`)}}else if(e===t.numberElement){let e=Math.max(Math.ceil(n.inlineSize),0);if(e!==t.numberWidth&&(t.numberWidth=e,t.codeElement.style.setProperty(`--diffs-column-number-width`,`${t.numberWidth===0?`auto`:`${t.numberWidth}px`}`),t.codeWidth!==`auto`)){let e=Math.max(t.codeWidth-t.numberWidth,0);t.codeElement.style.setProperty(`--diffs-column-content-width`,`${e===0?`auto`:`${e}px`}`)}}this.queuedUpdates.clear()};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 At(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 jt(e){for(let t of Array.isArray(e)?e:[e])if(!p.has(t))return!1;return!0}function Mt(e){for(let t of re(e))if(!b.has(t))return!1;return!0}function Nt(e){return d({tagName:`div`,children:[d({tagName:`div`,children:e.annotations?.map(e=>d({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function Pt(e,t){return d({tagName:`div`,children:e,properties:{"data-content":``,style:`grid-row: span ${t}`}})}function Ft(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 It({fileOrDiff:e,themeStyles:t,themeType:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":``,"data-change-type":r?.type,"data-theme-type":n===`system`?void 0:n,style:t};return d({tagName:`div`,children:[Lt({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),Rt(r)],properties:i})}function Lt({name:e,prevName:t,iconType:n}){let r=[_({name:Ft(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(d({tagName:`div`,children:[x(t)],properties:{"data-prev-name":``}})),r.push(_({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(d({tagName:`div`,children:[x(e)],properties:{"data-title":``}})),d({tagName:`div`,children:r,properties:{"data-header-content":``}})}function Rt(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(d({tagName:`span`,children:[x(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(d({tagName:`span`,children:[x(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(d({tagName:`slot`,properties:{name:xe}})),d({tagName:`div`,children:t,properties:{"data-metadata":``}})}function zt(e){return d({tagName:`pre`,properties:Bt(e)})}function Bt({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,themeType:a,themeStyles:o,totalLines:s,type:c}){let l={"data-diff":c===`diff`?``:void 0,"data-file":c===`file`?``:void 0,"data-diff-type":c===`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,"data-theme-type":a===`system`?void 0:a,style:o,tabIndex:0};return l.style+=`--diffs-min-number-column-width-default:${`${s}`.length}ch;`,l}function Vt(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:re(t),preferredHighlighter:n}}var Ht=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
1
|
+
import{$ as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,Ft as f,G as p,Gt as m,H as h,Ht as g,I as _,It as v,J as y,K as b,L as x,Lt as S,M as C,Mt as w,N as T,Nt as E,O as D,Ot as O,P as k,Pt as A,Q as j,R as M,Rt as N,S as P,St as F,T as ee,Tt as I,U as te,Ut as ne,V as re,Vt as ie,W as L,X as R,Y as ae,Z as z,_ as oe,_t as se,a as ce,at as le,b as ue,bt as B,c as de,ct as fe,d as V,dt as pe,et as me,f as H,ft as he,g as ge,gt as _e,h as ve,ht as ye,i as be,it as xe,j as Se,jt as Ce,k as we,kt as Te,l as Ee,lt as De,m as Oe,mt as ke,n as Ae,nt as je,o as Me,ot as Ne,p as Pe,pt as Fe,q as Ie,r as Le,rt as U,s as Re,st as ze,t as Be,tt as Ve,u as He,ut as Ue,v as We,vt as Ge,w as Ke,wt as qe,x as Je,xt as Ye,y as Xe,yt as Ze,z as Qe,zt as $e}from"./index-DY72HmVo.js";var et=se(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),tt=se(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),nt={position:`absolute`,top:0,bottom:0,textAlign:`center`};function W(e){return`annotation-${`side`in e?`${e.side}-`:``}${e.lineNumber}`}var G=g();function rt(e,t){return typeof window>`u`&&t!=null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,G.jsx)(G.Fragment,{children:e})}var K=new Set,q=new Set,it=null,at=!1;function J(e){if(at){K.add(e);return}q.add(e),it??=requestAnimationFrame(ot)}function ot(e){at=!0;for(let t of q)try{t(e)}catch(e){console.error(e)}q.clear(),K.size>0?(q=new Set(K),K.clear(),it=requestAnimationFrame(ot)):it=null,at=!1}function st(e,t){return e==null||t==null?e===t:e.top===t.top&&e.bottom===t.bottom}function ct({scrollTop:e,scrollHeight:t,height:n,containerOffset:r=0,fitPerfectly:i,overscrollSize:a}){let o=n+a*2,s=i?n:o;if(t=Math.max(t,s),o>=t||i){let n=Math.max(e-r,0),i=Math.min(e+s,t)-r;return{top:n,bottom:Math.max(i,n)}}let c=e+n/2-o/2,l=c+o;return c<0&&(c=0),l>t&&(l=t),c=Math.floor(Math.max(c-r,0)),{top:c,bottom:Math.ceil(Math.max(Math.min(l,t)-r,c))}}var lt=1e3,ut=lt*4,dt=[0,1e-6,.99999,1],ft={overscrollSize:lt,intersectionObserverMargin:ut,resizeDebugging:!1},Y=0,pt=-1,mt=class e{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++pt}`;config;type=`basic`;intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...ft,...e}}setup(t,n){if(this.root==null){this.root=t,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:dt,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),t instanceof Document?this.setupWindow():this.setupElement(n),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:e.__lastScrollPosition}),J(this.computeRenderRangeAndEmit)):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)};for(let[e,t]of this.connectQueue.entries())this.connect(e,t);this.connectQueue.clear(),this.markDOMDirty(),J(this.computeRenderRangeAndEmit)}}instanceChanged(e){this.instancesChanged.add(e),J(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=ct({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){let n=this.getScrollTop(),r=this.getHeight(),i=this.config.intersectionObserverMargin,a=n-i,o=n+r+i;return!(e<a-t||e>o)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(let n of e){let e=n.borderBoxSize[0].blockSize;this.root instanceof Document?e!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: content size change`,this.__id,{sizeChange:e-Y,newSize:e}),Y=e)):n.target===this.root?e!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: scroller size change`,this.__id,{sizeChange:e-Y,newSize:e}),Y=e))}t&&J(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw Error(`Virtualizer.setupWindow: Invalid setup method`);window.addEventListener(`scroll`,this.handleWindowScroll,{passive:!0}),window.addEventListener(`resize`,this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw Error(`Virtualizer.setupElement: Invalid setup method`);this.root.addEventListener(`scroll`,this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleElementScroll),window.removeEventListener(`scroll`,this.handleWindowScroll),window.removeEventListener(`resize`,this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+X(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw Error(`Virtualizer.connect: instance is already connected...`);return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),J(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){let t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),J(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{e.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,J(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{e.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,J(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{e.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,J(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(e.__STOP)return;let t=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;if(this.instancesChanged.size===0){let e=ct({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),fitPerfectly:!1,overscrollSize:this.config.overscrollSize});if(st(this.windowSpecs,e)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;this.windowSpecs=e}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;let n=this.getScrollAnchor(this.height),r=new Set;for(let e of this.visibleInstances.values())e.onRender(t)&&r.add(e);for(let e of this.instancesChanged)r.has(e)||e.onRender(t)&&r.add(e);this.scrollFix(n),this.instancesChanged.size>0&&this.markDOMDirty();for(let e of r)e.reconcileHeights();(this.instancesChanged.size>0||t)&&J(this.computeRenderRangeAndEmit),r.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;let t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:i,fileOffset:a,fileTypeOffset:o}=e;if(n!=null&&r!=null){let e=i.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(e instanceof HTMLElement){let n=X(e,t);if(n!==r){let e=n-r;this.applyScrollFix(e)}return}}let s=X(i,t);if(o===`top`)s!==a&&this.applyScrollFix(s-a);else{let e=s+i.getBoundingClientRect().height;e!==a&&this.applyScrollFix(e-a)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:`instant`}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:`instant`}),this.markDOMDirty()}getScrollAnchor(e){let t=this.getScrollContainerElement(),n;for(let[r]of this.visibleInstances.entries()){let i=X(r,t),a=i+r.offsetHeight,o,s;a<=0?(o=a,s=`bottom`):(o=i,s=`top`);let c,l;if(a>0&&i<e)for(let e of r.shadowRoot?.querySelectorAll(`[data-line][data-line-index]`)??[]){if(!(e instanceof HTMLElement))continue;let n=e.dataset.lineIndex;if(n==null)continue;let r=X(e,t);if(!(r<0)){c=n,l=r;break}}if(n?.lineOffset!=null&&l==null)continue;let u=!1;(n==null||l!=null&&(n.lineOffset==null||l<n.lineOffset)||l==null&&n.lineOffset==null&&(o>=0&&(n.fileOffset<0||o<n.fileOffset)||o<0&&n.fileOffset<0&&o>n.fileOffset))&&(u=!0),u&&(n={fileElement:r,fileTypeOffset:s,fileOffset:o,lineIndex:c,lineOffset:l})}return n}handleIntersectionChange=e=>{this.scrollDirty=!0;for(let{target:t,isIntersecting:n}of e){if(!(t instanceof HTMLElement))throw Error(`Virtualizer.handleIntersectionChange: target not an HTMLElement`);let e=this.observers.get(t);if(e==null)throw Error(`Virtualizer.handleIntersectionChange: no instance for target`);n&&!this.visibleInstances.has(t)?(e.setVisibility(!0),this.visibleInstances.set(t,e),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(e.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0)}this.visibleInstancesDirty&&J(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function X(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect().top??0;return n.top-r}var Z=m(ne(),1),ht=(0,Z.createContext)(void 0);function gt({children:e,config:t,className:n,style:r,contentClassName:i,contentStyle:a}){let[o]=(0,Z.useState)(()=>typeof window<`u`?new mt(t):void 0),s=(0,Z.useCallback)(e=>{e==null?o?.cleanUp():o?.setup(e)},[o]);return(0,G.jsx)(ht.Provider,{value:o,children:(0,G.jsx)(`div`,{className:n,style:r,ref:s,children:(0,G.jsx)(`div`,{className:i,style:a,children:e})})})}function _t(){return(0,Z.useContext)(ht)}function vt(e){let t=(0,Z.useRef)(e);return(0,Z.useInsertionEffect)(()=>void(t.current=e)),(0,Z.useCallback)((...e)=>t.current(...e),[])}function yt(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}var bt=class{pre;selectedRange=null;renderedSelectionRange;anchor;_queuedRender;constructor(e={}){this.options=e}setOptions(e){this.options={...this.options,...e},this.removeEventListeners(),this.options.enableLineSelection===!0&&this.attachEventListeners()}cleanUp(){this.removeEventListeners(),this._queuedRender!=null&&(cancelAnimationFrame(this._queuedRender),this._queuedRender=void 0),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.pre=void 0}setup(e){if(this.setDirty(),this.pre!==e){this.cleanUp(),this.pre=e;let{enableLineSelection:t=!1}=this.options;t?this.attachEventListeners():this.removeEventListeners()}this.setSelection(this.selectedRange)}setDirty(){this.renderedSelectionRange=void 0}isDirty(){return this.renderedSelectionRange===void 0}setSelection(e){let t=!(e===this.selectedRange||yt(e??void 0,this.selectedRange??void 0));!this.isDirty()&&!t||(this.selectedRange=e,this.renderSelection(),t&&this.notifySelectionChange())}getSelection(){return this.selectedRange}getLineIndex(e,t){let{getLineIndex:n}=this.options;return n==null?[e-1,e-1]:n(e,t)}attachEventListeners(){this.pre!=null&&(this.removeEventListeners(),this.pre.setAttribute(`data-interactive-line-numbers`,``),this.pre.addEventListener(`pointerdown`,this.handleMouseDown))}removeEventListeners(){this.pre!=null&&(this.pre.removeEventListener(`pointerdown`,this.handleMouseDown),document.removeEventListener(`pointermove`,this.handleMouseMove),document.removeEventListener(`pointerup`,this.handleMouseUp),this.pre.removeAttribute(`data-interactive-line-numbers`))}handleMouseDown=e=>{let t=e.button===0?this.getMouseEventDataForPath(e.composedPath(),`click`):void 0;if(t==null||this.pre==null)return;e.preventDefault();let{lineNumber:n,eventSide:r,lineIndex:i}=t;if(e.shiftKey&&this.selectedRange!=null){let e=this.getIndexesFromSelection(this.selectedRange,this.pre.getAttribute(`data-diff-type`)===`split`);if(e==null)return;let t=e.start<=e.end?i>=e.start:i<=e.end;this.anchor={line:t?this.selectedRange.start:this.selectedRange.end,side:(t?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side)??`additions`},this.updateSelection(n,r),this.notifySelectionStart(this.selectedRange)}else{if(this.selectedRange?.start===n&&this.selectedRange?.end===n){this.updateSelection(null),this.notifySelectionEnd(null),this.notifySelectionChange();return}this.selectedRange=null,this.anchor={line:n,side:r},this.updateSelection(n,r),this.notifySelectionStart(this.selectedRange)}document.addEventListener(`pointermove`,this.handleMouseMove),document.addEventListener(`pointerup`,this.handleMouseUp)};handleMouseMove=e=>{let t=this.getMouseEventDataForPath(e.composedPath(),`move`);if(t==null||this.anchor==null)return;let{lineNumber:n,eventSide:r}=t;this.updateSelection(n,r)};handleMouseUp=()=>{this.anchor=void 0,document.removeEventListener(`pointermove`,this.handleMouseMove),document.removeEventListener(`pointerup`,this.handleMouseUp),this.notifySelectionEnd(this.selectedRange),this.notifySelectionChange()};updateSelection(e,t){if(e==null)this.selectedRange=null;else{let n=this.anchor?.side??t;this.selectedRange={start:this.anchor?.line??e,end:e,side:n,endSide:n===t?void 0:t}}this._queuedRender??=requestAnimationFrame(this.renderSelection)}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}renderSelection=()=>{if(this._queuedRender!=null&&(cancelAnimationFrame(this._queuedRender),this._queuedRender=void 0),this.pre==null||this.renderedSelectionRange===this.selectedRange)return;let e=this.pre.querySelectorAll(`[data-selected-line]`);for(let t of e)t.removeAttribute(`data-selected-line`);if(this.renderedSelectionRange=this.selectedRange,this.selectedRange==null)return;let{children:t}=this.pre;if(t.length===0)return;if(t.length>2)throw console.error(t),Error(`LineSelectionManager.applySelectionToDOM: Somehow there are more than 2 code elements...`);let n=this.pre.getAttribute(`data-diff-type`)===`split`,r=this.getIndexesFromSelection(this.selectedRange,n);if(r==null)throw console.error({rowRange:r,selectedRange:this.selectedRange}),Error(`LineSelectionManager.renderSelection: No valid rowRange`);let i=r.start===r.end,a=Math.min(r.start,r.end),o=Math.max(r.start,r.end);for(let e of t){let[t,r]=e.children,s=r.children.length;if(s!==t.children.length)throw Error(`LineSelectionManager.renderSelection: gutter and content children dont match, something is wrong`);for(let e=0;e<s;e++){let s=r.children[e],c=t.children[e];if(!(s instanceof HTMLElement)||!(c instanceof HTMLElement))continue;let l=this.parseLineIndex(s,n);if((l??0)>o)break;if(l==null||l<a)continue;let u=i?`single`:l===a?`first`:l===o?`last`:``;s.setAttribute(`data-selected-line`,u),c.setAttribute(`data-selected-line`,u),c.nextSibling instanceof HTMLElement&&s.nextSibling instanceof HTMLElement&&s.nextSibling.hasAttribute(`data-line-annotation`)&&(i?(u=`last`,s.setAttribute(`data-selected-line`,`first`)):l===a?u=``:l===o&&s.setAttribute(`data-selected-line`,``),s.nextSibling.setAttribute(`data-selected-line`,u),c.nextSibling.setAttribute(`data-selected-line`,u))}}};notifySelectionChange(){let{onLineSelected:e}=this.options;e?.(this.selectedRange??null)}notifySelectionStart(e){let{onLineSelectionStart:t}=this.options;t?.(e)}notifySelectionEnd(e){let{onLineSelectionEnd:t}=this.options;t?.(e)}getMouseEventDataForPath(e,t){if(this.pre==null)return;let n,r,i=!1,a;for(let t of e){if(n!=null&&r!=null&&a!=null)break;if(t instanceof HTMLElement){if(t.hasAttribute(`data-line-index`)){i=t.hasAttribute(`data-column-number`),n=this.getLineNumber(t),r=this.parseLineIndex(t,this.pre.getAttribute(`data-diff-type`)===`split`);let e=t.getAttribute(`data-line-type`);e===`change-deletion`?a=`deletions`:e===`change-additions`&&(a=`additions`);continue}if(a==null&&t.hasAttribute(`data-code`)){a=t.hasAttribute(`data-deletions`)?`deletions`:t.hasAttribute(`data-additions`)?`additions`:void 0;break}}}if(!(t===`click`&&!i||r==null||n==null))return{lineIndex:r,lineNumber:n,eventSide:a??`additions`}}getLineNumber(e){let t=parseInt(e.getAttribute(`data-column-number`)??e.getAttribute(`data-line`)??``,10);return Number.isNaN(t)?void 0:t}parseLineIndex(e,t){let n=(e.getAttribute(`data-line-index`)??``).split(`,`).map(e=>parseInt(e)).filter(e=>!Number.isNaN(e));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function xt({enableLineSelection:e,onLineSelected:t,onLineSelectionStart:n,onLineSelectionEnd:r},i){return{enableLineSelection:e,onLineSelected:t,onLineSelectionStart:n,onLineSelectionEnd:r,getLineIndex:i}}function St(e,t){return e==null?!1:t===`file`?e.type===`line`:e.type===`diff-line`}function Ct(e){return e?.type===`line-info`}var wt=class{hoveredLine;pre;hoverSlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasEventListeners=!1;constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener(`click`,this.handleMouseClick),this.pre?.removeEventListener(`pointermove`,this.handleMouseMove),this.pre?.removeEventListener(`pointerleave`,this.handleMouseLeave),this.pre?.removeAttribute(`data-interactive-lines`),this.pre?.removeAttribute(`data-interactive-line-numbers`),this.clearHoveredLine(),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasEventListeners=!1,this.pre=void 0}setup(e){let{__debugMouseEvents:t,onLineClick:n,onLineNumberClick:r,onLineEnter:i,onLineLeave:a,onHunkExpand:o,enableHoverUtility:s=!1,lineHoverHighlight:c=`disabled`}=this.options,l=this.pre!==e;if(l&&(this.cleanUp(),this.pre=e,this.hasEventListeners=!1),s&&this.hoverSlot==null){this.hoverSlot=document.createElement(`div`),this.hoverSlot.setAttribute(`data-hover-slot`,``);let e=document.createElement(`slot`);e.name=`hover-slot`,this.hoverSlot.appendChild(e)}else !s&&this.hoverSlot!=null&&(this.hoverSlot.parentNode?.removeChild(this.hoverSlot),this.hoverSlot=void 0);let u=c!==`disabled`||n!=null||r!=null||o!=null||i!=null||a!=null||s;(l||!this.hasEventListeners)&&u?(this.hasEventListeners=!0,e.addEventListener(`click`,this.handleMouseClick),n==null?r!=null&&(e.setAttribute(`data-interactive-line-numbers`,``),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!0):(e.setAttribute(`data-interactive-lines`,``),this.interactiveLinesAttr=!0,this.interactiveLineNumbersAttr=!1),Q(t,`click`,`FileDiff.DEBUG.attachEventListeners: Attaching click events for:`,(()=>{let e=[];return(t===`both`||t===`click`)&&(n!=null&&e.push(`onLineClick`),r!=null&&e.push(`onLineNumberClick`),o!=null&&e.push(`expandable hunk separators`)),e})()),e.addEventListener(`pointermove`,this.handleMouseMove),Q(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer move event`),e.addEventListener(`pointerleave`,this.handleMouseLeave),Q(t,`move`,`FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event`)):!u&&this.hasEventListeners&&(this.pre?.removeEventListener(`click`,this.handleMouseClick),this.pre?.removeEventListener(`pointermove`,this.handleMouseMove),this.pre?.removeEventListener(`pointerleave`,this.handleMouseLeave),this.hasEventListeners=!1),l||(n==null?r==null?(this.interactiveLinesAttr&&=(e.removeAttribute(`data-interactive-lines`),!1),this.interactiveLineNumbersAttr&&=(e.removeAttribute(`data-interactive-line-numbers`),!1)):(this.interactiveLinesAttr&&=(e.removeAttribute(`data-interactive-lines`),!1),this.interactiveLineNumbersAttr||=(e.setAttribute(`data-interactive-line-numbers`,``),!0)):(this.interactiveLineNumbersAttr&&=(e.removeAttribute(`data-interactive-line-numbers`),!1),this.interactiveLinesAttr||=(e.setAttribute(`data-interactive-lines`,``),!0)))}getHoveredLine=()=>{if(this.hoveredLine!=null){if(this.mode===`diff`&&this.hoveredLine.type===`diff-line`)return{lineNumber:this.hoveredLine.lineNumber,side:this.hoveredLine.annotationSide};if(this.mode===`file`&&this.hoveredLine.type===`line`)return{lineNumber:this.hoveredLine.lineNumber}}};handleMouseClick=e=>{let{onLineClick:t,onLineNumberClick:n,onHunkExpand:r}=this.options;t==null&&n==null&&r==null||(Q(this.options.__debugMouseEvents,`click`,`FileDiff.DEBUG.handleMouseClick:`,e),this.handleMouseEvent({eventType:`click`,event:e}))};handleMouseMove=e=>{let{lineHoverHighlight:t=`disabled`,onLineEnter:n,onLineLeave:r,enableHoverUtility:i=!1}=this.options;t===`disabled`&&!i&&n==null&&r==null||(Q(this.options.__debugMouseEvents,`move`,`FileDiff.DEBUG.handleMouseMove:`,e),this.handleMouseEvent({eventType:`move`,event:e}))};handleMouseLeave=e=>{let{__debugMouseEvents:t}=this.options;if(Q(t,`move`,`FileDiff.DEBUG.handleMouseLeave: no event`),this.hoveredLine==null){Q(t,`move`,`FileDiff.DEBUG.handleMouseLeave: returned early, no .hoveredLine`);return}this.hoverSlot?.parentElement?.removeChild(this.hoverSlot),this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()};handleMouseEvent({eventType:e,event:t}){let{__debugMouseEvents:n}=this.options,r=t.composedPath();Q(n,e,`FileDiff.DEBUG.handleMouseEvent:`,{eventType:e,composedPath:r});let i=this.getLineData(r);Q(n,e,`FileDiff.DEBUG.handleMouseEvent: getLineData result:`,i);let{onLineClick:a,onLineNumberClick:o,onLineEnter:s,onLineLeave:c,onHunkExpand:l}=this.options;switch(e){case`move`:if(St(i,this.mode)&&this.hoveredLine?.lineElement===i.lineElement){Q(n,`move`,`FileDiff.DEBUG.handleMouseEvent: switch, 'move', returned early because same line`);break}this.hoveredLine!=null&&(Q(n,`move`,`FileDiff.DEBUG.handleMouseEvent: switch, 'move', clearing an existing hovered line and firing onLineLeave`),this.hoverSlot?.parentElement?.removeChild(this.hoverSlot),c?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),St(i,this.mode)&&(Q(n,`move`,`FileDiff.DEBUG.handleMouseEvent: switch, 'move', setting up a new hoveredLine and firing onLineEnter`),this.setHoveredLine(i),this.hoverSlot!=null&&i.numberElement?.appendChild(this.hoverSlot),s?.({...this.hoveredLine,event:t}));break;case`click`:if(Q(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', with data:`,i),i==null)break;if(Ct(i)&&l!=null){Q(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', expanding a hunk`),l(i.hunkIndex,i.direction);break}St(i,this.mode)&&(o!=null&&i.numberColumn?(Q(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', firing 'onLineNumberClick'`),o({...i,event:t})):a==null?Q(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', fell through, no event to fire`):(Q(n,`click`,`FileDiff.DEBUG.handleMouseEvent: switch, 'click', firing 'onLineClick'`),a({...i,event:t})));break}}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`,``))}getLineData(e){let t=!1,n,r,i,a,o,s,c;for(let l of e){if(!(l instanceof HTMLElement))continue;let e=o==null?l.getAttribute(`data-column-number`)??void 0:void 0;if(e){o=l,c=Number.parseInt(e,10),t=!0,n=Dt(l),a=l.getAttribute(`data-line-index`)??void 0;continue}let u=i==null?l.getAttribute(`data-line`)??void 0:void 0;if(u){i=l,c=Number.parseInt(u,10),n=Dt(l),a=l.getAttribute(`data-line-index`)??void 0;continue}if(s==null&&l.hasAttribute(`data-expand-button`)){s={hunkIndex:void 0,direction:l.hasAttribute(`data-expand-up`)?`up`:l.hasAttribute(`data-expand-down`)?`down`:`both`};continue}let d=s==null?void 0:l.getAttribute(`data-expand-index`)??void 0;if(s!=null&&d!=null){let e=Number.parseInt(d,10);Number.isNaN(e)||(s.hunkIndex=e);continue}if(r==null&&l.hasAttribute(`data-code`)){r=l;break}}if(s?.hunkIndex!=null){let{hunkIndex:e,direction:t}=s;return{type:`line-info`,hunkIndex:e,direction:t}}if(i??=a==null?void 0:Et(r,`[data-line][data-line-index="${a}"]`),o??=a==null?void 0:Et(r,`[data-column-number][data-line-index="${a}"]`),!(r==null||i==null||o==null||n==null))return this.mode===`file`?{type:`line`,lineElement:i,lineNumber:c,numberElement:o,numberColumn:t}:{type:`diff-line`,annotationSide:(()=>{switch(n){case`change-deletion`:return`deletions`;case`change-addition`:return`additions`;default:return r.hasAttribute(`data-deletions`)?`deletions`:`additions`}})(),lineType:n,lineElement:i,numberElement:o,lineNumber:c,numberColumn:t}}};function Q(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;break}console.log(...n)}function Tt({lineHoverHighlight:e,onLineClick:t,onLineNumberClick:n,onLineEnter:r,onLineLeave:i,enableHoverUtility:a,__debugMouseEvents:o},s){return{lineHoverHighlight:e,onLineClick:t,onLineNumberClick:n,onLineEnter:r,onLineLeave:i,enableHoverUtility:a,__debugMouseEvents:o,onHunkExpand:s}}function Et(e,t){let n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function Dt(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}}var Ot=class{observedNodes=new Map;timeoutID;queuedUpdates=new Map;cleanUp(){this.resizeObserver?.disconnect(),this.observedNodes.clear(),this.timeoutID!=null&&clearTimeout(this.timeoutID)}resizeObserver;setup(e,t){this.resizeObserver??=new ResizeObserver(this.handleResizeObserver);let n=e.querySelectorAll(`code`),r=new Map(this.observedNodes);this.observedNodes.clear();for(let e of n){let t=r.get(e);if(t!=null){this.observedNodes.set(e,t),r.delete(e);continue}let n=e.querySelector(`[data-gutter]`);n instanceof HTMLElement||(n=null),t={type:`code`,codeElement:e,numberElement:n,codeWidth:`auto`,numberWidth:0},this.observedNodes.set(e,t),this.resizeObserver.observe(e),n!=null&&(this.observedNodes.set(n,t),this.resizeObserver.observe(n))}if(n.length>1&&!t){let t=e.querySelectorAll(`[data-line-annotation*=","]`),n=new Map;for(let e of t){if(!(e instanceof HTMLElement))continue;let{lineAnnotation:t=``}=e.dataset;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,o=i.firstElementChild;if(!(n instanceof HTMLElement)||!(i instanceof HTMLElement)||!(a instanceof HTMLElement)||!(o instanceof HTMLElement))continue;let s=r.get(a);if(s!=null){this.observedNodes.set(a,s),this.observedNodes.set(o,s),r.delete(a),r.delete(o);continue}s={type:`annotations`,column1:{container:n,child:a,childHeight:a.getBoundingClientRect().height},column2:{container:i,child:o,childHeight:o.getBoundingClientRect().height},currentHeight:`auto`};let c=Math.max(s.column1.childHeight,s.column2.childHeight);this.applyNewHeight(s,c),this.observedNodes.set(a,s),this.observedNodes.set(o,s),this.resizeObserver.observe(a),this.resizeObserver.observe(o)}}for(let e of r.keys())e.isConnected&&(e.style.removeProperty(`--diffs-column-content-width`),e.style.removeProperty(`--diffs-column-number-width`),e.style.removeProperty(`--diffs-column-width`),e.parentElement instanceof HTMLElement&&e.parentElement.style.removeProperty(`--diffs-annotation-min-height`)),this.resizeObserver.unobserve(e);r.clear()}handleResizeObserver=e=>{for(let t of e){let{target:e,borderBoxSize:n}=t;if(!(e instanceof HTMLElement)){console.error(`FileDiff.handleResizeObserver: Invalid element for ResizeObserver`,t);continue}let r=this.observedNodes.get(e);if(r==null){console.error(`FileDiff.handleResizeObserver: Not a valid observed node`,t);continue}let i=n[0];if(r.type===`annotations`){let t=(()=>{if(e===r.column1.child)return r.column1;if(e===r.column2.child)return r.column2})();if(t==null){console.error(`FileDiff.handleResizeObserver: Couldn't find a column for`,{item:r,target:e});continue}t.childHeight=i.blockSize;let n=Math.max(r.column1.childHeight,r.column2.childHeight);this.applyNewHeight(r,n)}else r.type===`code`&&(this.queuedUpdates.set(e,[r,i]),this.queueColumnUpdate())}};queueColumnUpdate(){this.timeoutID!=null&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout(this.handleColumnChange,1e3/30)}handleColumnChange=()=>{this.timeoutID=void 0;for(let[e,[t,n]]of this.queuedUpdates)if(e===t.codeElement){let e=Math.max(Math.floor(n.inlineSize),0);if(e!==t.codeWidth){t.codeWidth=e;let n=Math.max(t.codeWidth-t.numberWidth,0);t.codeElement.style.setProperty(`--diffs-column-content-width`,`${n===0?`auto`:`${n}px`}`),t.codeElement.style.setProperty(`--diffs-column-width`,`${t.codeWidth===0?`auto`:`${t.codeWidth}px`}`)}}else if(e===t.numberElement){let e=Math.max(Math.ceil(n.inlineSize),0);if(e!==t.numberWidth&&(t.numberWidth=e,t.codeElement.style.setProperty(`--diffs-column-number-width`,`${t.numberWidth===0?`auto`:`${t.numberWidth}px`}`),t.codeWidth!==`auto`)){let e=Math.max(t.codeWidth-t.numberWidth,0);t.codeElement.style.setProperty(`--diffs-column-content-width`,`${e===0?`auto`:`${e}px`}`)}}this.queuedUpdates.clear()};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 kt(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 At(e){for(let t of Array.isArray(e)?e:[e])if(!p.has(t))return!1;return!0}function jt(e){for(let t of re(e))if(!b.has(t))return!1;return!0}function Mt(e){return d({tagName:`div`,children:[d({tagName:`div`,children:e.annotations?.map(e=>d({tagName:`slot`,properties:{name:e}})),properties:{"data-annotation-content":``}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function Nt(e,t){return d({tagName:`div`,children:e,properties:{"data-content":``,style:`grid-row: span ${t}`}})}function Pt(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 Ft({fileOrDiff:e,themeStyles:t,themeType:n}){let r=`type`in e?e:void 0,i={"data-diffs-header":``,"data-change-type":r?.type,"data-theme-type":n===`system`?void 0:n,style:t};return d({tagName:`div`,children:[It({name:e.name,prevName:`prevName`in e?e.prevName:void 0,iconType:r?.type??`file`}),Lt(r)],properties:i})}function It({name:e,prevName:t,iconType:n}){let r=[_({name:Pt(n),properties:{"data-change-icon":n}})];return t!=null&&(r.push(d({tagName:`div`,children:[x(t)],properties:{"data-prev-name":``}})),r.push(_({name:`diffs-icon-arrow-right-short`,properties:{"data-rename-icon":``}}))),r.push(d({tagName:`div`,children:[x(e)],properties:{"data-title":``}})),d({tagName:`div`,children:r,properties:{"data-header-content":``}})}function Lt(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(d({tagName:`span`,children:[x(`-${r}`)],properties:{"data-deletions-count":``}})),(n>0||r===0)&&t.push(d({tagName:`span`,children:[x(`+${n}`)],properties:{"data-additions-count":``}}))}return t.push(d({tagName:`slot`,properties:{name:xe}})),d({tagName:`div`,children:t,properties:{"data-metadata":``}})}function Rt(e){return d({tagName:`pre`,properties:zt(e)})}function zt({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:r,split:i,themeType:a,themeStyles:o,totalLines:s,type:c}){let l={"data-diff":c===`diff`?``:void 0,"data-file":c===`file`?``:void 0,"data-diff-type":c===`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,"data-theme-type":a===`system`?void 0:a,style:o,tabIndex:0};return l.style+=`--diffs-min-number-column-width-default:${`${s}`.length}ch;`,l}function Bt(e,{theme:t,preferredHighlighter:n=`shiki-js`}){return{langs:[e??`text`],themes:re(t),preferredHighlighter:n}}var Vt=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
2
2
|
<symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
|
|
3
3
|
<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"/>
|
|
4
4
|
</symbol>
|
|
@@ -47,7 +47,7 @@ import{$ as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l
|
|
|
47
47
|
<symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
|
|
48
48
|
<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"/>
|
|
49
49
|
</symbol>
|
|
50
|
-
</svg>`;function
|
|
50
|
+
</svg>`;function Ht(e,t){return e==null||t==null?e===t: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.themeStyles===t.themeStyles&&e.themeType===t.themeType&&e.totalLines===t.totalLines}function Ut(e){let t=document.createElement(`div`);return t.dataset.annotationSlot=``,t.slot=e,t.style.whiteSpace=`normal`,t}function Wt(){let e=document.createElement(`div`);return e.slot=`hover-slot`,e.style.position=`absolute`,e.style.top=`0`,e.style.bottom=`0`,e.style.textAlign=`center`,e.style.whiteSpace=`normal`,e}function Gt(){let e=document.createElement(`style`);return e.setAttribute(De,``),e}var Kt=`@layer base, theme, unsafe;
|
|
51
51
|
|
|
52
52
|
@layer base {
|
|
53
53
|
:host {
|
|
@@ -1396,13 +1396,13 @@ import{$ as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l
|
|
|
1396
1396
|
contain: strict;
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
`,
|
|
1399
|
+
`,qt=`@layer base, theme, unsafe;`;function Jt(e){return`${qt}
|
|
1400
1400
|
@layer unsafe {
|
|
1401
1401
|
${e}
|
|
1402
|
-
}`}function Xt({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 Zt(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function Qt(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,themeStyles:s,themeType:c,totalLines:l}){switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),c===`system`?e.removeAttribute(`data-theme-type`):e.setAttribute(`data-theme-type`,c),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`);break}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.tabIndex=0,e.style=s,e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${l}`.length}ch`),e}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let t;class n extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let e=this.attachShadow({mode:`open`});t??(t=new CSSStyleSheet,t.replaceSync(qt)),e.adoptedStyleSheets=[t]}}customElements.define(e,n)}function $t(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 en(e,t){return r(e?.theme??z,t?.theme??z)&&$t(e,t,[`theme`])}function tn({fileDiff:e,deletionFile:t,additionFile:n,renderHeaderMetadata:r,renderAnnotation:i,renderHoverUtility:a,lineAnnotations:o,getHoveredLine:s}){let c=r?.({fileDiff:e,deletionFile:t,additionFile:n});return(0,K.jsxs)(K.Fragment,{children:[c!=null&&(0,K.jsx)(`div`,{slot:`header-metadata`,children:c}),i!=null&&o?.map((e,t)=>(0,K.jsx)(`div`,{slot:G(e),children:i(e)},t)),a!=null&&(0,K.jsx)(`div`,{slot:`hover-slot`,style:tt,children:a(s)})]})}var nn=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 rn(e){return d({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function Q(e){return d({tagName:`div`,children:[d({tagName:`span`,children:[x(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function an(e){return d({tagName:`div`,children:[_({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{"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 $({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=[];if(e===`metadata`&&t!=null&&s.push(d({tagName:`div`,children:[x(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||e.push(an(`up`)),o||e.push(an(`down`))):e.push(an(!a&&!o?`both`:a?`down`:`up`))),e.push(d({tagName:`div`,children:[d({tagName:`span`,children:[x(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),s.push(d({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":e.length>2?``:void 0}}))}return e===`custom`&&i!=null&&s.push(d({tagName:`slot`,properties:{name:i}})),d({tagName:`div`,children:s,properties:{"data-separator":s.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function on(e,t){return`hunk-separator-${e}-${t}`}function sn(e){let t=e.at(-1);return t==null?0:Math.max(t.additionStart+t.additionCount,t.deletionStart+t.deletionCount)}function cn(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}var ln=-1,un=class{__id=`diff-hunks-renderer:${++ln}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;constructor(e={theme:z},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=Mt(e.theme??z)?h():void 0)}cleanUp(){this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,this.workerManager?.cleanUpPendingTasks(this),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,this.workerManager?.cleanUpPendingTasks(this)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){this.getOptionsWithDefaults().themeType!==e&&this.mergeOptions({themeType:e})}expandHunk(e,t){let{expansionLineCount:n}=this.getOptionsWithDefaults(),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.renderCache=void 0),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??ae}getExpandedHunksMap(){return this.expandedHunks}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)}}getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,expandUnchanged:o=!1,collapsedContextThreshold:s=1,expansionLineCount:c=100,hunkSeparators:l=`line-info`,lineDiffType:u=`word-alt`,maxLineDiffLength:d=1e3,overflow:f=`scroll`,theme:p=z,themeType:m=`system`,tokenizeMaxLineLength:h=1e3,useCSSClasses:g=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,expandUnchanged:o,collapsedContextThreshold:s,expansionLineCount:c,hunkSeparators:l,lineDiffType:u,maxLineDiffLength:d,overflow:f,theme:this.workerManager?.getDiffRenderOptions().theme??p,themeType:m,tokenizeMaxLineLength:h,useCSSClasses:g}}async initializeHighlighter(){return this.highlighter=await te(Vt(this.computedLang,this.options)),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=this.workerManager?.getDiffResultCache(e);n!=null&&!dn(t,n.options)&&(n=void 0),this.renderCache??={diff:e,highlighted:!0,options:t,result:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0&&this.renderCache.result==null?this.workerManager.highlightDiffAST(this,this.diff):this.asyncHighlight(e).then(({result:t,options:n})=>{this.onHighlightSuccess(e,t,n)})}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n}=this.getOptionsWithDefaults();return{theme:e,tokenizeMaxLineLength:t,lineDiffType:n}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||e!==n.diff||!dn(t,n.options)?{options:t,forceRender:!0}:{options:t,forceRender:!1}}renderDiff(e=this.renderCache?.diff,t=R){if(e==null)return;let{expandUnchanged:n=!1,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),i=this.workerManager?.getDiffResultCache(e);i!=null&&this.renderCache==null&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...i});let{options:a,forceRender:o}=this.getRenderOptions(e);if(this.renderCache??={diff:e,highlighted:!1,options:a,result:void 0,renderRange:void 0},this.workerManager?.isWorkingPool()===!0)(this.renderCache.result==null||!this.renderCache.highlighted&&!At(this.renderCache.renderRange,t))&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,cn(t)||n?!0:this.expandedHunks,r),this.renderCache.renderRange=t),t.totalLines>0&&(!this.renderCache.highlighted||o)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??Ze(e.name);let t=this.highlighter!=null&&Mt(a.theme),n=this.highlighter!=null&&jt(this.computedLang);if(this.highlighter!=null&&t&&(o||!this.renderCache.highlighted&&n||this.renderCache.result==null)){let{result:t,options:r}=this.renderDiffWithHighlighter(e,this.highlighter,!n);this.renderCache={diff:e,options:r,highlighted:n,result:t,renderRange:void 0}}(!t||!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.onHighlightSuccess(e,t,n)})}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,r){let{diffIndicators:i,disableBackground:a,disableLineNumbers:o,overflow:s,themeType:c}=this.getOptionsWithDefaults();return zt({type:`diff`,diffIndicators:i,disableBackground:a,disableLineNumbers:o,overflow:s,themeStyles:n,split:e,themeType:r??c,totalLines:t})}async asyncHighlight(e){this.computedLang=e.lang??Ze(e.name);let t=this.highlighter!=null&&Mt(this.options.theme??z),n=this.highlighter!=null&&jt(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults();return{result:D(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i}),options:r}}onHighlightSuccess(e,t,n){if(this.renderCache==null)return;let r=this.renderCache.diff!==e||!this.renderCache.highlighted||!dn(this.renderCache.options,n);this.renderCache={diff:e,options:n,highlighted:!0,result:t,renderRange:void 0},r&&this.onRenderUpdate?.()}onHighlightError(e){console.error(e)}processDiffResult(e,n,{code:r,themeStyles:i,baseThemeType:a}){let{diffStyle:o,disableFileHeader:s,expandUnchanged:c,expansionLineCount:l,collapsedContextThreshold:u,hunkSeparators:d}=this.getOptionsWithDefaults();this.diff=e;let f=o===`unified`,p=[],m=[],h=[],g=[],{additionLines:_,deletionLines:v}=r,y={rowCount:0,hunkSeparators:d,additionsContentAST:p,deletionsContentAST:m,unifiedContentAST:h,unifiedGutterAST:k(),deletionsGutterAST:k(),additionsGutterAST:k(),expansionLineCount:l,hunkData:g,incrementRowCount(e=1){y.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:y.unifiedGutterAST.children.push(t);break;case`deletions`:y.deletionsGutterAST.children.push(t);break;case`additions`:y.additionsGutterAST.children.push(t);break}}},b=hn(e),x=0,S;function w(e,t,n,r){y.pushToGutter(e,T(t,n,r))}function E(){if(o!==`unified`){if(x<=0||S==null){x=0,S=void 0;return}S===`additions`?(y.pushToGutter(`additions`,C(void 0,`buffer`,x)),p?.push(rn(x))):(y.pushToGutter(`deletions`,C(void 0,`buffer`,x)),m?.push(rn(x))),x=0,S=void 0}}function D(e){E(),o===`unified`?mn(`unified`,e,y):(mn(`deletions`,e,y),mn(`additions`,e,y))}t({diff:e,diffStyle:o,startingLine:n.startingLine,totalLines:n.totalLines,expandedHunks:c?!0:this.expandedHunks,collapsedContextThreshold:u,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:a,deletionLine:s,type:c})=>{let l=s==null?a.splitLineIndex:s.splitLineIndex,u=a==null?s.unifiedLineIndex:a.unifiedLineIndex;o===`split`&&c!==`change`&&E(),r>0&&D({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:!e.isPartial});let f=o===`unified`?u:l;if(o===`unified`){let n=s==null?void 0:v[s.lineIndex],r=a==null?void 0:_[a.lineIndex];if(n==null&&r==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}w(`unified`,c===`change`?a==null?`change-deletion`:`change-addition`:c,a==null?s.lineNumber:a.lineNumber,`${u},${l}`),pn({diffStyle:`unified`,type:c,deletionLine:n,additionLine:r,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,a?.lineNumber,t,f),context:y})}else{let n=s==null?void 0:v[s.lineIndex],r=a==null?void 0:_[a.lineIndex];if(n==null&&r==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let i=(()=>{if(c===`change`){if(r==null)return`additions`;if(n==null)return`deletions`}})();if(i!=null){if(S!=null&&S!==i)throw Error(`DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits`);S=i,x++}let o=this.getAnnotations(`split`,s?.lineNumber,a?.lineNumber,t,f);o!=null&&x>0&&E(),s!=null&&w(`deletions`,c===`change`?`change-deletion`:c,s.lineNumber,`${s.unifiedLineIndex},${l}`),a!=null&&w(`additions`,c===`change`?`change-addition`:c,a.lineNumber,`${a.unifiedLineIndex},${l}`),pn({diffStyle:`split`,type:c,additionLine:r,deletionLine:n,...o,context:y})}let p=s?.noEOFCR??!1,m=a?.noEOFCR??!1;if(m||p){if(p){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;o===`unified`?(y.unifiedContentAST.push(Q(e)),y.pushToGutter(`unified`,C(e,`metadata`,1))):(y.deletionsContentAST.push(Q(e)),y.pushToGutter(`deletions`,C(e,`metadata`,1)),m||(y.pushToGutter(`additions`,C(void 0,`buffer`,1)),y.additionsContentAST.push(rn(1))))}if(m){let e=c===`context`||c===`context-expanded`?c:`change-addition`;o===`unified`?(y.unifiedContentAST.push(Q(e)),y.pushToGutter(`unified`,C(e,`metadata`,1))):(y.additionsContentAST.push(Q(e)),y.pushToGutter(`additions`,C(e,`metadata`,1)),p||(y.pushToGutter(`deletions`,C(void 0,`buffer`,1)),y.deletionsContentAST.push(rn(1))))}y.incrementRowCount(1)}i>0&&d!==`simple`&&D({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:i,rangeSize:b,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),y.incrementRowCount(1)}}),o===`split`&&E();let O=Math.max(sn(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),A=n.bufferBefore>0||n.bufferAfter>0,j=!f&&e.type!==`deleted`,M=!f&&e.type!==`new`,N=y.rowCount>0||A;p=j&&N?p:void 0,m=M&&N?m:void 0,h=f&&N?h:void 0;let P=this.createPreElement(m!=null&&p!=null,O,i,a);return{unifiedGutterAST:f&&N?y.unifiedGutterAST.children:void 0,unifiedContentAST:h,deletionsGutterAST:M&&N?y.deletionsGutterAST.children:void 0,deletionsContentAST:m,additionsGutterAST:j&&N?y.additionsGutterAST.children:void 0,additionsContentAST:p,hunkData:g,preNode:P,themeStyles:i,baseThemeType:a,headerElement:s?void 0:this.renderHeader(this.diff,i,a),totalLines:O,rowCount:y.rowCount,bufferBefore:n.bufferBefore,bufferAfter:n.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=k(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Pt(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(d({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(d({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(d({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return L(this.renderFullAST(e,t))}renderPartialHTML(e,t){return L(t==null?e:d({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}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(G(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(G(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,t,n){let{themeType:r}=this.getOptionsWithDefaults();return It({fileOrDiff:e,themeStyles:t,themeType:n??r})}};function dn(e,t){return r(e.theme,t.theme)&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType}function fn(e){return`${e} unmodified line${e>1?`s`:``}`}function pn({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,context:s}){let c=!1;if(e===`unified`){if(r==null?n!=null&&s.unifiedContentAST.push(n):s.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;s.unifiedContentAST.push(Nt(i)),s.pushToGutter(`unified`,C(e,`annotation`,1)),c=!0}}else if(e===`split`){if(n!=null&&s.deletionsContentAST.push(n),r!=null&&s.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;s.deletionsContentAST.push(Nt(a)),s.pushToGutter(`deletions`,C(e,`annotation`,1)),c=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;s.additionsContentAST.push(Nt(o)),s.pushToGutter(`additions`,C(e,`annotation`,1)),c=!0}}c&&s.incrementRowCount(1)}function mn(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,$({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push($({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,$({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push($({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=on(e,t),d=r>c.expansionLineCount,f=s?t:void 0;c.pushToGutter(e,$({type:c.hunkSeparators,content:fn(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push($({type:c.hunkSeparators,content:fn(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:n,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function hn(e){let t=e.hunks.at(-1);if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}function gn(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function _n(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function vn(e){let t=e[0];if(t!==`+`&&t!==`-`&&t!==` `&&t!==`\\`){console.error(`parseLineType: Invalid firstChar: "${t}", full line: "${e}"`);return}let n=e.substring(1);return{line:n===``?`
|
|
1403
|
-
`:n,type:t===` `?`context`:t===`\\`?`metadata`:t===`+`?`addition`:`deletion`}}function yn(e,t,n=!1){let r=
|
|
1402
|
+
}`}function Yt({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 Xt(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function Zt(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,themeStyles:s,themeType:c,totalLines:l}){switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),c===`system`?e.removeAttribute(`data-theme-type`):e.setAttribute(`data-theme-type`,c),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`);break}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.tabIndex=0,e.style=s,e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${l}`.length}ch`),e}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let t;class n extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let e=this.attachShadow({mode:`open`});t??(t=new CSSStyleSheet,t.replaceSync(Kt)),e.adoptedStyleSheets=[t]}}customElements.define(e,n)}function Qt(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 $t(e,t){return r(e?.theme??z,t?.theme??z)&&Qt(e,t,[`theme`])}function en({fileDiff:e,deletionFile:t,additionFile:n,renderHeaderMetadata:r,renderAnnotation:i,renderHoverUtility:a,lineAnnotations:o,getHoveredLine:s}){let c=r?.({fileDiff:e,deletionFile:t,additionFile:n});return(0,G.jsxs)(G.Fragment,{children:[c!=null&&(0,G.jsx)(`div`,{slot:`header-metadata`,children:c}),i!=null&&o?.map((e,t)=>(0,G.jsx)(`div`,{slot:W(e),children:i(e)},t)),a!=null&&(0,G.jsx)(`div`,{slot:`hover-slot`,style:nt,children:a(s)})]})}var tn=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 nn(e){return d({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function rn(e){return d({tagName:`div`,children:[d({tagName:`span`,children:[x(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function an(e){return d({tagName:`div`,children:[_({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{"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 $({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=[];if(e===`metadata`&&t!=null&&s.push(d({tagName:`div`,children:[x(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||e.push(an(`up`)),o||e.push(an(`down`))):e.push(an(!a&&!o?`both`:a?`down`:`up`))),e.push(d({tagName:`div`,children:[d({tagName:`span`,children:[x(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),s.push(d({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":e.length>2?``:void 0}}))}return e===`custom`&&i!=null&&s.push(d({tagName:`slot`,properties:{name:i}})),d({tagName:`div`,children:s,properties:{"data-separator":s.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function on(e,t){return`hunk-separator-${e}-${t}`}function sn(e){let t=e.at(-1);return t==null?0:Math.max(t.additionStart+t.additionCount,t.deletionStart+t.deletionCount)}function cn(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}var ln=-1,un=class{__id=`diff-hunks-renderer:${++ln}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;constructor(e={theme:z},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=jt(e.theme??z)?h():void 0)}cleanUp(){this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,this.workerManager?.cleanUpPendingTasks(this),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.renderCache=void 0,this.workerManager?.cleanUpPendingTasks(this)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){this.getOptionsWithDefaults().themeType!==e&&this.mergeOptions({themeType:e})}expandHunk(e,t){let{expansionLineCount:n}=this.getOptionsWithDefaults(),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.renderCache=void 0),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??ae}getExpandedHunksMap(){return this.expandedHunks}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)}}getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,expandUnchanged:o=!1,collapsedContextThreshold:s=1,expansionLineCount:c=100,hunkSeparators:l=`line-info`,lineDiffType:u=`word-alt`,maxLineDiffLength:d=1e3,overflow:f=`scroll`,theme:p=z,themeType:m=`system`,tokenizeMaxLineLength:h=1e3,useCSSClasses:g=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,expandUnchanged:o,collapsedContextThreshold:s,expansionLineCount:c,hunkSeparators:l,lineDiffType:u,maxLineDiffLength:d,overflow:f,theme:this.workerManager?.getDiffRenderOptions().theme??p,themeType:m,tokenizeMaxLineLength:h,useCSSClasses:g}}async initializeHighlighter(){return this.highlighter=await te(Bt(this.computedLang,this.options)),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=this.workerManager?.getDiffResultCache(e);n!=null&&!dn(t,n.options)&&(n=void 0),this.renderCache??={diff:e,highlighted:!0,options:t,result:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0&&this.renderCache.result==null?this.workerManager.highlightDiffAST(this,this.diff):this.asyncHighlight(e).then(({result:t,options:n})=>{this.onHighlightSuccess(e,t,n)})}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n}=this.getOptionsWithDefaults();return{theme:e,tokenizeMaxLineLength:t,lineDiffType:n}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||e!==n.diff||!dn(t,n.options)?{options:t,forceRender:!0}:{options:t,forceRender:!1}}renderDiff(e=this.renderCache?.diff,t=R){if(e==null)return;let{expandUnchanged:n=!1,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),i=this.workerManager?.getDiffResultCache(e);i!=null&&this.renderCache==null&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...i});let{options:a,forceRender:o}=this.getRenderOptions(e);if(this.renderCache??={diff:e,highlighted:!1,options:a,result:void 0,renderRange:void 0},this.workerManager?.isWorkingPool()===!0)(this.renderCache.result==null||!this.renderCache.highlighted&&!kt(this.renderCache.renderRange,t))&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,cn(t)||n?!0:this.expandedHunks,r),this.renderCache.renderRange=t),t.totalLines>0&&(!this.renderCache.highlighted||o)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??Qe(e.name);let t=this.highlighter!=null&&jt(a.theme),n=this.highlighter!=null&&At(this.computedLang);if(this.highlighter!=null&&t&&(o||!this.renderCache.highlighted&&n||this.renderCache.result==null)){let{result:t,options:r}=this.renderDiffWithHighlighter(e,this.highlighter,!n);this.renderCache={diff:e,options:r,highlighted:n,result:t,renderRange:void 0}}(!t||!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.onHighlightSuccess(e,t,n)})}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,r){let{diffIndicators:i,disableBackground:a,disableLineNumbers:o,overflow:s,themeType:c}=this.getOptionsWithDefaults();return Rt({type:`diff`,diffIndicators:i,disableBackground:a,disableLineNumbers:o,overflow:s,themeStyles:n,split:e,themeType:r??c,totalLines:t})}async asyncHighlight(e){this.computedLang=e.lang??Qe(e.name);let t=this.highlighter!=null&&jt(this.options.theme??z),n=this.highlighter!=null&&At(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults();return{result:D(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i}),options:r}}onHighlightSuccess(e,t,n){if(this.renderCache==null)return;let r=this.renderCache.diff!==e||!this.renderCache.highlighted||!dn(this.renderCache.options,n);this.renderCache={diff:e,options:n,highlighted:!0,result:t,renderRange:void 0},r&&this.onRenderUpdate?.()}onHighlightError(e){console.error(e)}processDiffResult(e,n,{code:r,themeStyles:i,baseThemeType:a}){let{diffStyle:o,disableFileHeader:s,expandUnchanged:c,expansionLineCount:l,collapsedContextThreshold:u,hunkSeparators:d}=this.getOptionsWithDefaults();this.diff=e;let f=o===`unified`,p=[],m=[],h=[],g=[],{additionLines:_,deletionLines:v}=r,y={rowCount:0,hunkSeparators:d,additionsContentAST:p,deletionsContentAST:m,unifiedContentAST:h,unifiedGutterAST:k(),deletionsGutterAST:k(),additionsGutterAST:k(),expansionLineCount:l,hunkData:g,incrementRowCount(e=1){y.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:y.unifiedGutterAST.children.push(t);break;case`deletions`:y.deletionsGutterAST.children.push(t);break;case`additions`:y.additionsGutterAST.children.push(t);break}}},b=hn(e),x=0,S;function w(e,t,n,r){y.pushToGutter(e,T(t,n,r))}function E(){if(o!==`unified`){if(x<=0||S==null){x=0,S=void 0;return}S===`additions`?(y.pushToGutter(`additions`,C(void 0,`buffer`,x)),p?.push(nn(x))):(y.pushToGutter(`deletions`,C(void 0,`buffer`,x)),m?.push(nn(x))),x=0,S=void 0}}function D(e){E(),o===`unified`?mn(`unified`,e,y):(mn(`deletions`,e,y),mn(`additions`,e,y))}t({diff:e,diffStyle:o,startingLine:n.startingLine,totalLines:n.totalLines,expandedHunks:c?!0:this.expandedHunks,collapsedContextThreshold:u,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:a,deletionLine:s,type:c})=>{let l=s==null?a.splitLineIndex:s.splitLineIndex,u=a==null?s.unifiedLineIndex:a.unifiedLineIndex;o===`split`&&c!==`change`&&E(),r>0&&D({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:!e.isPartial});let f=o===`unified`?u:l;if(o===`unified`){let n=s==null?void 0:v[s.lineIndex],r=a==null?void 0:_[a.lineIndex];if(n==null&&r==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}w(`unified`,c===`change`?a==null?`change-deletion`:`change-addition`:c,a==null?s.lineNumber:a.lineNumber,`${u},${l}`),pn({diffStyle:`unified`,type:c,deletionLine:n,additionLine:r,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,a?.lineNumber,t,f),context:y})}else{let n=s==null?void 0:v[s.lineIndex],r=a==null?void 0:_[a.lineIndex];if(n==null&&r==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let i=(()=>{if(c===`change`){if(r==null)return`additions`;if(n==null)return`deletions`}})();if(i!=null){if(S!=null&&S!==i)throw Error(`DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits`);S=i,x++}let o=this.getAnnotations(`split`,s?.lineNumber,a?.lineNumber,t,f);o!=null&&x>0&&E(),s!=null&&w(`deletions`,c===`change`?`change-deletion`:c,s.lineNumber,`${s.unifiedLineIndex},${l}`),a!=null&&w(`additions`,c===`change`?`change-addition`:c,a.lineNumber,`${a.unifiedLineIndex},${l}`),pn({diffStyle:`split`,type:c,additionLine:r,deletionLine:n,...o,context:y})}let p=s?.noEOFCR??!1,m=a?.noEOFCR??!1;if(m||p){if(p){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;o===`unified`?(y.unifiedContentAST.push(rn(e)),y.pushToGutter(`unified`,C(e,`metadata`,1))):(y.deletionsContentAST.push(rn(e)),y.pushToGutter(`deletions`,C(e,`metadata`,1)),m||(y.pushToGutter(`additions`,C(void 0,`buffer`,1)),y.additionsContentAST.push(nn(1))))}if(m){let e=c===`context`||c===`context-expanded`?c:`change-addition`;o===`unified`?(y.unifiedContentAST.push(rn(e)),y.pushToGutter(`unified`,C(e,`metadata`,1))):(y.additionsContentAST.push(rn(e)),y.pushToGutter(`additions`,C(e,`metadata`,1)),p||(y.pushToGutter(`deletions`,C(void 0,`buffer`,1)),y.deletionsContentAST.push(nn(1))))}y.incrementRowCount(1)}i>0&&d!==`simple`&&D({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:i,rangeSize:b,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),y.incrementRowCount(1)}}),o===`split`&&E();let O=Math.max(sn(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),A=n.bufferBefore>0||n.bufferAfter>0,j=!f&&e.type!==`deleted`,M=!f&&e.type!==`new`,N=y.rowCount>0||A;p=j&&N?p:void 0,m=M&&N?m:void 0,h=f&&N?h:void 0;let P=this.createPreElement(m!=null&&p!=null,O,i,a);return{unifiedGutterAST:f&&N?y.unifiedGutterAST.children:void 0,unifiedContentAST:h,deletionsGutterAST:M&&N?y.deletionsGutterAST.children:void 0,deletionsContentAST:m,additionsGutterAST:j&&N?y.additionsGutterAST.children:void 0,additionsContentAST:p,hunkData:g,preNode:P,themeStyles:i,baseThemeType:a,headerElement:s?void 0:this.renderHeader(this.diff,i,a),totalLines:O,rowCount:y.rowCount,bufferBefore:n.bufferBefore,bufferAfter:n.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=k(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Nt(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(d({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(d({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(d({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return L(this.renderFullAST(e,t))}renderPartialHTML(e,t){return L(t==null?e:d({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}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(W(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(W(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,t,n){let{themeType:r}=this.getOptionsWithDefaults();return Ft({fileOrDiff:e,themeStyles:t,themeType:n??r})}};function dn(e,t){return r(e.theme,t.theme)&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType}function fn(e){return`${e} unmodified line${e>1?`s`:``}`}function pn({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,context:s}){let c=!1;if(e===`unified`){if(r==null?n!=null&&s.unifiedContentAST.push(n):s.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;s.unifiedContentAST.push(Mt(i)),s.pushToGutter(`unified`,C(e,`annotation`,1)),c=!0}}else if(e===`split`){if(n!=null&&s.deletionsContentAST.push(n),r!=null&&s.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;s.deletionsContentAST.push(Mt(a)),s.pushToGutter(`deletions`,C(e,`annotation`,1)),c=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;s.additionsContentAST.push(Mt(o)),s.pushToGutter(`additions`,C(e,`annotation`,1)),c=!0}}c&&s.incrementRowCount(1)}function mn(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,$({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push($({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,$({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push($({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=on(e,t),d=r>c.expansionLineCount,f=s?t:void 0;c.pushToGutter(e,$({type:c.hunkSeparators,content:fn(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push($({type:c.hunkSeparators,content:fn(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:n,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function hn(e){let t=e.hunks.at(-1);if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}function gn(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function _n(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function vn(e){let t=e[0];if(t!==`+`&&t!==`-`&&t!==` `&&t!==`\\`){console.error(`parseLineType: Invalid firstChar: "${t}", full line: "${e}"`);return}let n=e.substring(1);return{line:n===``?`
|
|
1403
|
+
`:n,type:t===` `?`context`:t===`\\`?`metadata`:t===`+`?`addition`:`deletion`}}function yn(e,t,n=!1){let r=U.test(e),i=e.split(r?U:fe),a,o=[];for(let e of i){if(r&&!U.test(e)){if(a==null)a=e;else if(n)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}else if(!r&&!fe.test(e)){if(a==null)a=e;else if(n)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}let i=bn(e,{cacheKey:t==null?void 0:`${t}-${o.length}`,isGitDiff:r,throwOnError:n});i!=null&&o.push(i)}return{patchMetadata:a,files:o}}function bn(e,{cacheKey:t,isGitDiff:n=U.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=e.split(je),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=e.split(ze),f=s.shift();if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=f.match(le),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?i.contents.split(ze):[],deletionLines:!l&&r!=null&&i!=null?r.contents.split(ze):[],cacheKey:t},c.additionLines.length===1&&i?.contents===``&&(c.additionLines.length=0),c.deletionLines.length===1&&r?.contents===``&&(c.deletionLines.length=0),s.unshift(f);for(let e of s){let t=e.match(n?Ve:me);if(e.startsWith(`diff --git`)){let[,,t,,n]=e.trim().match(Ie)??[];c.name=n.trim(),t!==n&&(c.prevName=t.trim())}else if(t!=null){let[,e,n]=t;e===`---`&&n!==`/dev/null`?(c.prevName=n.trim(),c.name=n.trim()):e===`+++`&&n!==`/dev/null`&&(c.name=n.trim())}else if(n){if(e.startsWith(`new mode `)&&(c.mode=e.replace(`new mode`,``).trim()),e.startsWith(`old mode `)&&(c.prevMode=e.replace(`old mode`,``).trim()),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=e.replace(`new file mode`,``).trim()),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=e.replace(`deleted file mode`,``).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(Ne)??[];t!=null&&(c.prevObjectId=t),n!=null&&(c.newObjectId=n),r!=null&&(c.mode=r)}e.startsWith(`rename from `)&&(c.prevName=e.replace(`rename from `,``)),e.startsWith(`rename to `)&&(c.name=e.replace(`rename to `,``).trim())}}continue}let g,_;for(;s.length>0&&(s[s.length-1]===`
|
|
1404
1404
|
`||s[s.length-1]===`\r`||s[s.length-1]===`\r
|
|
1405
|
-
`||s[s.length-1]===``);)s.pop();let v=parseInt(p[3]),y=parseInt(p[1]);u=l?u:y-1,d=l?d:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:parseInt(p[4]??`1`),additionStart:v,additionLines:m,deletionCount:parseInt(p[2]??`1`),deletionStart:y,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:p[5],hunkSpecs:f,noEOFCRAdditions:!1,noEOFCRDeletions:!1};if(isNaN(b.additionCount)||isNaN(b.deletionCount)||isNaN(b.additionStart)||isNaN(b.deletionStart)){if(a)throw Error(`parsePatchContent: invalid hunk metadata`);console.error(`parsePatchContent: invalid hunk metadata`,b);continue}for(let e of s){let t=vn(e);if(t==null){console.error(`processFile: invalid rawLine:`,e);continue}let{type:n,line:r}=t;if(n===`addition`)(g==null||g.type!==`change`)&&(g=Sn(`change`,u,d),b.hunkContent.push(g)),d++,l&&c.additionLines.push(r),g.additions++,m++,_=`addition`;else if(n===`deletion`)(g==null||g.type!==`change`)&&(g=Sn(`change`,u,d),b.hunkContent.push(g)),u++,l&&c.deletionLines.push(r),g.deletions++,h++,_=`deletion`;else if(n===`context`)(g==null||g.type!==`context`)&&(g=Sn(`context`,u,d),b.hunkContent.push(g)),d++,u++,l&&(c.deletionLines.push(r),c.additionLines.push(r)),g.lines++,_=`context`;else if(n===`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]=M(c.additionLines[e]))}if(l&&(_===`deletion`||_===`context`)){let e=c.deletionLines.length-1;e>=0&&(c.deletionLines[e]=M(c.deletionLines[e]))}}}b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(b.additionStart-1-o,0),c.hunks.push(b),o=b.additionStart+b.additionCount-1;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(c.hunks.length>0&&!l&&c.additionLines.length>0&&c.deletionLines.length>0){let e=c.hunks[c.hunks.length-1],t=e.additionStart+e.additionCount-1,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`:i!=null&&i.contents===``?c.type=`deleted`:r!=null&&r.contents===``&&(c.type=`new`)),c.type!==`rename-pure`&&c.type!==`rename-changed`&&(c.prevName=void 0),c}}function xn(e,t,n=!1){let r=[];for(let i of e.split(y))try{r.push(yn(i,t==null?void 0:`${t}-${r.length}`,n))}catch(e){if(n)throw e;console.error(e)}return r}function Sn(e,t,n){return e===`change`?{type:`change`,additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:`context`,lines:0,additionLineIndex:n,deletionLineIndex:t}}function Cn(e,t,n,r=!1){let i=bn(we(e.name,t.name,e.contents,t.contents,e.header,t.header,n),{cacheKey:(()=>{if(e.cacheKey!=null&&t.cacheKey!=null)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:r});if(i==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);return i}var wn=-1,Tn=class{static LoadedCustomComponent=!0;__id=`file-diff:${++wn}`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;unsafeCSSStyle;hoverContent;headerElement;headerMetadata;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;mouseEventManager;lineSelectionManager;annotationCache=new Map;lineAnnotations=[];deletionFile;additionFile;fileDiff;renderRange;appliedPreAttributes;lastRenderedHeaderHTML;lastRowCount;enabled=!0;constructor(e={theme:z},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=new un({...e,hunkSeparators:typeof e.hunkSeparators==`function`?`custom`:e.hunkSeparators},this.handleHighlightRender,this.workerManager),this.resizeManager=new kt,this.scrollSyncManager=new nn,this.mouseEventManager=new Tt(`diff`,Et(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0)),this.lineSelectionManager=new xt(St(e,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getLineIndex=(e,t=`additions`)=>{if(this.fileDiff==null)return;let n=this.fileDiff.hunks.at(-1),r,i;hunkIterator:for(let a of this.fileDiff.hunks){let o=t===`deletions`?a.deletionStart:a.additionStart,s=t===`deletions`?a.deletionCount:a.additionCount,c=a.splitLineStart,l=a.unifiedLineStart;if(e<o){let t=o-e;r=Math.max(l-t,0),i=Math.max(c-t,0);break hunkIterator}if(e>=o+s){if(a===n){let t=e-(o+s);r=l+a.unifiedLineCount+t,i=c+a.splitLineCount+t;break hunkIterator}continue}for(let n of a.hunkContent)if(n.type===`context`)if(e<o+n.lines){let t=e-o;i=c+t,r=l+t;break hunkIterator}else o+=n.lines,c+=n.lines,l+=n.lines;else{let a=t===`deletions`?n.deletions:n.additions;if(e<o+a){let a=e-o;r=l+(t===`additions`?n.deletions:0)+a,i=c+a;break hunkIterator}else o+=a,c+=Math.max(n.deletions,n.additions),l+=n.deletions+n.additions}break hunkIterator}if(!(r==null||i==null))return[r,i]};setOptions(e){e!=null&&(this.options=e,this.hunksRenderer.setOptions({...this.options,hunkSeparators:typeof e.hunkSeparators==`function`?`custom`:e.hunkSeparators}),this.mouseEventManager.setOptions(Et(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0)),this.lineSelectionManager.setOptions(St(e,this.getLineIndex)))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){if((this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.hunksRenderer.setThemeType(e),this.headerElement!=null&&(e===`system`?delete this.headerElement.dataset.themeType:this.headerElement.dataset.themeType=e),this.pre!=null))switch(e){case`system`:delete this.pre.dataset.themeType;break;case`light`:case`dark`:this.pre.dataset.themeType=e;break}}getHoveredLine=()=>this.mouseEventManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e){this.lineSelectionManager.setSelection(e)}cleanUp(e=!1){this.resizeManager.cleanUp(),this.mouseEventManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.lineSelectionManager.cleanUp(),this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.parentNode?.removeChild(this.fileContainer),this.fileContainer?.shadowRoot!=null&&(this.fileContainer.shadowRoot.innerHTML=``),this.fileContainer=void 0,this.pre!=null&&(this.pre.innerHTML=``,this.pre=void 0),this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0,this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=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.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{overflow:t=`scroll`,diffStyle:n=`split`}=this.options,{fileContainer:r,prerenderedHTML:i}=e;Zt(r,i);for(let e of r.shadowRoot?.children??[]){if(e instanceof SVGElement){this.spriteSVG=e;continue}if(e instanceof HTMLElement){if(e instanceof HTMLPreElement){this.pre=e;for(let t of e.children)!(t instanceof HTMLElement)||t.tagName.toLowerCase()!==`code`||(`deletions`in t.dataset&&(this.codeDeletions=t),`additions`in t.dataset&&(this.codeAdditions=t),`unified`in t.dataset&&(this.codeUnified=t));continue}if(`diffsHeader`in e.dataset){this.headerElement=e;continue}if(e instanceof HTMLStyleElement&&e.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=e;continue}}}if(this.pre!=null&&this.syncCodeNodesFromPre(this.pre),this.pre==null)this.render(e);else{let{lineAnnotations:i,oldFile:a,newFile:o,fileDiff:s}=e;this.fileContainer=r,delete this.pre.dataset.dehydrated,this.lineAnnotations=i??this.lineAnnotations,this.additionFile=o,this.deletionFile=a,this.fileDiff=s??(a!=null&&o!=null?Cn(a,o):void 0),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderHoverUtility(),this.injectUnsafeCSS(),this.mouseEventManager.setup(this.pre),this.lineSelectionManager.setup(this.pre),this.resizeManager.setup(this.pre,t===`wrap`),t===`scroll`&&n===`split`&&this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions)}}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({oldFile:this.deletionFile,newFile:this.additionFile,fileDiff:this.fileDiff,forceRender:!0,renderRange:this.renderRange})}handleExpandHunk=(e,t)=>{this.expandHunk(e,t)};expandHunk(e,t){this.hunksRenderer.expandHunk(e,t),this.rerender()}render({oldFile:e,newFile:t,fileDiff:n,forceRender:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let c=e!=null&&t!=null&&(!Se(e,this.deletionFile)||!Se(t,this.additionFile)),l=n!=null&&n!==this.fileDiff,u=i!=null&&(i.length>0||this.lineAnnotations.length>0)?i!==this.lineAnnotations:!1;if(At(s,this.renderRange)&&!r&&!u&&(n!=null&&n===this.fileDiff||n==null&&!c))return!1;let{renderRange:d}=this;if(this.renderRange=s,this.deletionFile=e,this.additionFile=t,n==null?e!=null&&t!=null&&c&&(l=!0,this.fileDiff=Cn(e,t)):this.fileDiff=n,i!=null&&this.setLineAnnotations(i),this.fileDiff==null)return!1;this.hunksRenderer.setOptions({...this.options,hunkSeparators:typeof this.options.hunkSeparators==`function`?`custom`:this.options.hunkSeparators}),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{diffStyle:f=`split`,disableErrorHandling:p=!1,disableFileHeader:m=!1,overflow:h=`scroll`}=this.options;m&&this.headerElement!=null&&(this.headerElement.parentNode?.removeChild(this.headerElement),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),a=this.getOrCreateFileContainer(a,o);try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(r,u,c||l)&&this.applyPartialRender({previousRenderRange:d,renderRange:s}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,s);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;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.parentNode?.removeChild(this.pre),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,s),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderHoverUtility(),this.mouseEventManager.setup(e),this.lineSelectionManager.setup(e),this.resizeManager.setup(e,h===`wrap`),h===`scroll`&&f===`split`?this.scrollSyncManager.setup(e,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp()}catch(e){if(p)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return!0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(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}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.mouseEventManager.cleanUp(),this.lineSelectionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.hoverContent?.remove(),this.pre?.remove(),this.spriteSVG?.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.hoverContent=void 0,this.pre=void 0,this.spriteSVG=void 0,this.unsafeCSSStyle=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0}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.parentNode?.removeChild(e);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||!_n(r,i.hunkData)){i?.element.parentNode?.removeChild(i.element);let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName,n.appendChild(t(r,this)),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.parentNode?.removeChild(t)}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.parentNode?.removeChild(e);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}-${G(r)}`,a=this.annotationCache.get(i);if(a==null||!gn(r,a.annotation)){a?.element.parentElement?.removeChild(a.element);let e=t(r);if(e==null)continue;a={element:Wt(G(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.parentNode?.removeChild(n)}renderHoverUtility(){let{renderHoverUtility:e}=this.options;if(this.fileContainer==null||e==null)return;let t=e(this.mouseEventManager.getHoveredLine);if(!(t!=null&&this.hoverContent!=null)){if(t==null){this.hoverContent?.parentNode?.removeChild(this.hoverContent),this.hoverContent=void 0;return}this.hoverContent=Gt(),this.hoverContent.appendChild(t),this.fileContainer.appendChild(this.hoverContent)}}getOrCreateFileContainer(e,t){let n=this.fileContainer;if(this.fileContainer=e??this.fileContainer??document.createElement(`diffs-container`),n!=null&&n!==this.fileContainer&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=Ht;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t,this.fileContainer.shadowRoot?.appendChild(this.spriteSVG))}return this.fileContainer}getFileContainer(){return this.fileContainer}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&&(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&&(`unified`in t.dataset?this.codeUnified=t:`deletions`in t.dataset?this.codeDeletions=t:`additions`in t.dataset&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let n=L(e);if(n!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=n;let r=e.firstElementChild;if(!(r instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(r):t.shadowRoot?.replaceChild(r,this.headerElement),this.headerElement=r,this.lastRenderedHeaderHTML=n}if(this.isContainerManaged)return;let{renderHeaderMetadata:r}=this.options;this.headerMetadata!=null&&this.headerMetadata.parentNode?.removeChild(this.headerMetadata);let i=r?.({deletionFile:this.deletionFile,additionFile:this.additionFile,fileDiff:this.fileDiff})??void 0;i!=null&&(this.headerMetadata=document.createElement(`div`),this.headerMetadata.slot=xe,i instanceof Element?this.headerMetadata.appendChild(i):this.headerMetadata.innerText=`${i}`,t.appendChild(this.headerMetadata))}injectUnsafeCSS(){if(this.fileContainer?.shadowRoot==null)return;let{unsafeCSS:e}=this.options;e==null||e===``||(this.unsafeCSSStyle??(this.unsafeCSSStyle=Kt(),this.fileContainer.shadowRoot.appendChild(this.unsafeCSSStyle)),this.unsafeCSSStyle.innerText=Yt(e))}applyHunksToDOM(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);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=Xt({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),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=Xt({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),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=Xt({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),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(`applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`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`)}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=En(t[0]),i=En(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}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}else 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)`)}getCodeColumns(e,t,n,r){function i(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}}if(e===`unified`)return i(t);{let e=i(n),t=i(r);return e!=null||t!=null?[e,t]:void 0}}applyBuffers(e,t){let{disableVirtualizationBuffers:n=!1}=this.options;if(n||t==null){this.bufferBefore!=null&&(this.bufferBefore.parentNode?.removeChild(this.bufferBefore),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.parentNode?.removeChild(this.bufferAfter),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.parentNode?.removeChild(this.bufferBefore),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.parentNode?.removeChild(this.bufferAfter),this.bufferAfter=void 0)}applyPreNodeAttributes(e,{themeStyles:t,baseThemeType:n,additionsContentAST:r,deletionsContentAST:i,totalLines:a}){let{diffIndicators:o=`bars`,disableBackground:s=!1,disableLineNumbers:c=!1,overflow:l=`scroll`,themeType:u=`system`,diffStyle:d=`split`}=this.options,f={type:`diff`,diffIndicators:o,disableBackground:s,disableLineNumbers:c,overflow:l,split:d===`unified`?!1:r!=null&&i!=null,themeStyles:t,themeType:n??u,totalLines:a};Ut(f,this.appliedPreAttributes)||(Qt(e,f),this.appliedPreAttributes=f)}applyErrorToDOM(e,t){this.cleanupErrorWrapper();let n=this.getOrCreatePreNode(t);n.innerHTML=``,n.parentNode?.removeChild(n),this.pre=void 0,this.appliedPreAttributes=void 0;let r=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.innerHTML=``,r.appendChild(this.errorWrapper);let i=document.createElement(`div`);i.dataset.errorMessage=``,i.innerText=e.message,this.errorWrapper.appendChild(i);let a=document.createElement(`pre`);a.dataset.errorStack=``,a.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(a)}cleanupErrorWrapper(){this.errorWrapper?.parentNode?.removeChild(this.errorWrapper),this.errorWrapper=void 0}};function En(e){if(!(e==null||e.type!==`element`))return e.children??[]}function Dn(e,t){let n={...j,...t};return n.hunkSeparatorHeight=On(e,t?.hunkSeparatorHeight),n}function On(e,t){if(t!=null)return t;switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}var kn=-1,An=class extends Tn{__id=`little-virtualized-file-diff:${++kn}`;top;height=0;metrics;heightCache=new Map;isVisible=!1;virtualizer;constructor(e,t,n,r,i=!1){super(e,r,i);let{hunkSeparators:a=`line-info`}=this.options;this.virtualizer=t,this.metrics=Dn(typeof a==`function`?`custom`:a,n)}getLineHeight(e,t=!1){let n=this.heightCache.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(e==null)return;let t=this.options.diffStyle,n=this.options.overflow;super.setOptions(e),(t!==this.options.diffStyle||n!==this.options.overflow)&&(this.heightCache.clear(),this.computeApproximateSize(),this.renderRange=void 0),this.virtualizer.instanceChanged(this)}reconcileHeights(){let{overflow:e=`scroll`}=this.options;if(this.fileContainer!=null&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.fileContainer==null||this.fileDiff==null){this.height=0;return}if(e===`scroll`&&this.lineAnnotations.length===0&&!this.virtualizer.config.resizeDebugging)return;let t=this.getDiffStyle(),n=!1,r=t===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];for(let e of r){if(e==null)continue;let r=e.children[1];if(r instanceof HTMLElement)for(let e of r.children){if(!(e instanceof HTMLElement))continue;let r=e.dataset.lineIndex;if(r==null)continue;let i=Mn(r,t),a=e.getBoundingClientRect().height,o=!1;e.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in e.nextElementSibling.dataset||`noNewline`in e.nextElementSibling.dataset)&&(`noNewline`in e.nextElementSibling.dataset&&(o=!0),a+=e.nextElementSibling.getBoundingClientRect().height);let s=this.getLineHeight(i,o);a!==s&&(n=!0,a===this.metrics.lineHeight*(o?2:1)?this.heightCache.delete(i):this.heightCache.set(i,a))}}(n||this.virtualizer.config.resizeDebugging)&&this.computeApproximateSize()}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.render());cleanUp(){this.fileContainer!=null&&this.virtualizer.disconnect(this.fileContainer),super.cleanUp()}expandHunk(e,t){this.hunksRenderer.expandHunk(e,t),this.computeApproximateSize(),this.renderRange=void 0,this.virtualizer.instanceChanged(this)}setVisibility(e){this.fileContainer!=null&&(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}computeApproximateSize(){let e=this.height===0;if(this.height=0,this.fileDiff==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsedContextThreshold:i=1,hunkSeparators:a=`line-info`}=this.options,{diffHeaderHeight:o,fileGap:s,hunkSeparatorHeight:c}=this.metrics,l=this.getDiffStyle(),u=a!==`simple`&&a!==`metadata`&&a!==`line-info-basic`?s:0;if(n?a!==`simple`&&a!==`metadata`&&(this.height+=s):this.height+=o,t({diff:this.fileDiff,diffStyle:l,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:e,collapsedBefore:t,collapsedAfter:n,deletionLine:r,additionLine:i})=>{let o=i==null?r.splitLineIndex:i.splitLineIndex,s=i==null?r.unifiedLineIndex:i.unifiedLineIndex,d=(i?.noEOFCR??!1)||(r?.noEOFCR??!1);t>0&&(e>0&&(this.height+=u),this.height+=c+u),this.height+=this.getLineHeight(l===`split`?o:s,d),n>0&&a!==`simple`&&(this.height+=u+c)}}),this.fileDiff.hunks.length>0&&(this.height+=s),this.fileContainer!=null&&this.virtualizer.config.resizeDebugging&&!e){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height})}}render({fileContainer:e,oldFile:t,newFile:n,fileDiff:r,...i}={}){let a=this.fileContainer==null;if(this.fileDiff??=r??(t!=null&&n!=null?Cn(t,n):void 0),e=this.getOrCreateFileContainer(e),this.fileDiff==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(a?(this.computeApproximateSize(),this.virtualizer.connect(e,this),this.top??=this.virtualizer.getOffsetInScrollContainer(e),this.isVisible=this.virtualizer.isInstanceVisible(this.top,this.height)):this.top??=this.virtualizer.getOffsetInScrollContainer(e),!this.isVisible)return this.renderPlaceholder(this.height);let o=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.fileDiff,this.top,o);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:s,oldFile:t,newFile:n,...i})}getDiffStyle(){return this.options.diffStyle??`split`}getExpandedRegion(e,t,n){if(n<=0||e)return{fromStart:0,fromEnd:0,collapsedLines:Math.max(n,0),renderAll:!1};let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;if(r||n<=i)return{fromStart:n,fromEnd:0,collapsedLines:0,renderAll:!0};let a=this.hunksRenderer.getExpandedHunk(t),o=Math.min(Math.max(a.fromStart,0),n),s=Math.min(Math.max(a.fromEnd,0),n),c=o+s,l=c>=n;return{fromStart:o,fromEnd:s,collapsedLines:Math.max(n-c,0),renderAll:l}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}for(let[r,i]of e.hunks.entries()){let a=t===`split`?i.splitLineCount:i.unifiedLineCount;n+=a;let o=Math.max(i.collapsedBefore,0),{fromStart:s,fromEnd:c,renderAll:l}=this.getExpandedRegion(e.isPartial,r,o);o>0&&(n+=l?o:s+c)}let r=e.hunks.at(-1);if(r!=null&&jn(e)){let t=e.additionLines.length-(r.additionLineIndex+r.additionCount),i=e.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(r!=null&&t!==i)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${t}, deletions=${i}) for ${e.name}`);let a=Math.min(t,i);if(r!=null&&a>0){let{fromStart:t,renderAll:r}=this.getExpandedRegion(e.isPartial,e.hunks.length,a);n+=r?a:t}}return n}computeRenderRangeFromWindow(e,n,{top:r,bottom:i}){let{disableFileHeader:a=!1,expandUnchanged:o=!1,collapsedContextThreshold:s=1,hunkSeparators:c=`line-info`}=this.options,{diffHeaderHeight:l,fileGap:u,hunkLineCount:d,hunkSeparatorHeight:f,lineHeight:p}=this.metrics,m=this.getDiffStyle(),h=this.height,g=this.getExpandedLineCount(e,m),_=a?u:l;if(n<r-h||n>i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-_-u};if(g<=d||e.hunks.length===0)return{startingLine:0,totalLines:d,bufferBefore:0,bufferAfter:0};let v=Math.ceil(Math.max(i-r,0)/p),y=Math.ceil(v/d)*d+d,b=y/d,x=b,S=[],C=(r+i)/2,w=c===`simple`||c===`metadata`||c===`line-info-basic`?0:u,T=n+_,E=0,D,O,k;if(t({diff:e,diffStyle:m,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,collapsedBefore:t,collapsedAfter:a,deletionLine:o,additionLine:s})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,u=s==null?o.unifiedLineIndex:s.unifiedLineIndex,p=(s?.noEOFCR??!1)||(o?.noEOFCR??!1),h=t>0?f+w+(e>0?w:0):0;e===0&&c===`simple`&&(h=0),T+=h;let g=E%d===0;if(g&&(S.push(T-(n+_+h)),k!=null)){if(k<=0)return!0;k--}let v=this.getLineHeight(m===`split`?l:u,p),y=Math.floor(E/d);return T>r-v&&T<i&&(D??=y),O==null&&T+v>C&&(O=y),k==null&&T>=i&&g&&(k=x),E++,T+=v,a>0&&c!==`simple`&&(T+=f+w),!1}}),D==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-_-u};let A=S.length;O??=D;let j=Math.round(O-b/2),M=Math.max(0,A-b),N=Math.max(0,Math.min(j,M)),P=N*d,F=j<0?y+j*d:y,ee=S[N]??0,I=N+F/d;return{startingLine:P,totalLines:F,bufferBefore:ee,bufferAfter:I<S.length?h-_-S[I]-u:h-(T-n)-u}}};function jn(e){let t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function Mn(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var Nn=typeof window>`u`?X.useEffect:X.useLayoutEffect;function Pn({oldFile:e,newFile:t,fileDiff:n,options:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:o,metrics:c}){let l=vt(),u=(0,X.useContext)(s),d=(0,X.useRef)(null),f=yt(a=>{if(a!=null){if(d.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);l==null?d.current=new Tn(r,u,!0):d.current=new An(r,l,c,u,!0),d.current.hydrate({fileDiff:n,oldFile:e,newFile:t,fileContainer:a,lineAnnotations:i,prerenderedHTML:o})}else{if(d.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);d.current.cleanUp(),d.current=null}});return Nn(()=>{if(d.current==null)return;let o=d.current,s=!en(o.options,r);o.setOptions(r),o.render({forceRender:s,fileDiff:n,oldFile:e,newFile:t,lineAnnotations:i}),a!==void 0&&o.setSelectedLines(a)}),{ref:f,getHoveredLine:(0,X.useCallback)(()=>d.current?.getHoveredLine(),[])}}function Fn({fileDiff:t,options:n,metrics:r,lineAnnotations:i,selectedLines:a,className:o,style:s,prerenderedHTML:c,renderAnnotation:l,renderHeaderMetadata:u,renderHoverUtility:d}){let{ref:f,getHoveredLine:p}=Pn({fileDiff:t,options:n,metrics:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:c});return(0,K.jsx)(e,{ref:f,className:o,style:s,children:nt(tn({fileDiff:t,renderHeaderMetadata:u,renderAnnotation:l,lineAnnotations:i,renderHoverUtility:d,getHoveredLine:p}),c)})}function In(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var Ln=[];function Rn(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:s,highlightedIndex:l,onHighlightedIndexChange:d,rootRef:f,enableHomeAndEndKeys:p=!1,stopEventPropagation:m=!1,disabledIndices:h,modifierKeys:g=Ln}=e,[_,v]=X.useState(0),y=n>1,b=X.useRef(null),x=E(b,f),S=X.useRef([]),C=X.useRef(!1),w=l??_,T=O((e,t=!1)=>{if((d??v)(e),t){let t=S.current[e];qe(b.current,t,s,a)}}),D=O(e=>{if(e.size===0||C.current)return;C.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&T(r),qe(b.current,n,s,a)}),k=X.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:x,onFocus(e){!b.current||!ue(e.target)||e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let l=p?de:Ve;if(!l.has(e.key)||zn(e,g)||!b.current)return;let d=s===`rtl`,f=d?V:H,_={horizontal:f,vertical:Te,both:f}[a],v=d?H:V,x={horizontal:v,vertical:Ne,both:v}[a];if(ue(e.target)&&!In(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==x&&t<r.length||e.key!==_&&t>0)return}let C=w,E=I(S,h),D=Ke(S,h);if(y){let s=t||Array.from({length:S.current.length},()=>({width:1,height:1})),l=Xe(s,n,i),u=l.findIndex(e=>e!=null&&!c(S,e,h)),f=l.reduce((e,t,n)=>t!=null&&!c(S,t,h)?n:e,-1);C=l[o({current:l.map(e=>e?S.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:F([...h||S.current.map((e,t)=>c(S,t)?t:void 0),void 0],l),minIndex:u,maxIndex:f,prevIndex:Je(w>D?E:w,s,l,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:d})]}let O={horizontal:[f],vertical:[Te],both:[f,Te]}[a],k={horizontal:[v],vertical:[Ne],both:[v,Ne]}[a],A=y?l:{horizontal:p?ge:ve,vertical:p?Ye:Ue,both:l}[a];p&&(e.key===`Home`?C=E:e.key===`End`&&(C=D)),C===w&&(O.includes(e.key)||k.includes(e.key))&&(C=r&&C===D&&O.includes(e.key)?E:r&&C===E&&k.includes(e.key)?D:B(S,{startingIndex:C,decrement:k.includes(e.key),disabledIndices:h})),C!==w&&!u(S,C)&&(m&&e.stopPropagation(),A.has(e.key)&&e.preventDefault(),T(C,!0),queueMicrotask(()=>{S.current[C]?.focus()}))}}),[n,i,s,h,S,p,w,y,t,r,x,g,T,a,m]);return X.useMemo(()=>({props:k,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:S,disabledIndices:h,onMapChange:D,relayKeyboardEvent:k.onKeyDown}),[k,w,T,S,h,D])}function zn(e,t){for(let n of oe.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Bn(e){let{render:t,className:r,refs:i=Ce,props:a=Ce,state:o=w,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,dense:d,itemSizes:f,loopFocus:p,cols:m,enableHomeAndEndKeys:h,onMapChange:g,stopEventPropagation:_=!0,rootRef:v,disabledIndices:y,modifierKeys:b,highlightItemOnHover:x=!1,tag:S=`div`,...C}=e,{props:T,highlightedIndex:E,onHighlightedIndexChange:D,elementsRef:O,onMapChange:k,relayKeyboardEvent:A}=Rn({itemSizes:f,cols:m,loopFocus:p,dense:d,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:v,stopEventPropagation:_,enableHomeAndEndKeys:h,direction:se(),disabledIndices:y,modifierKeys:b}),j=n(S,e,{state:o,ref:i,props:[T,...a,C],stateAttributesMapping:s}),M=X.useMemo(()=>({highlightedIndex:E,onHighlightedIndexChange:D,highlightItemOnHover:x,relayKeyboardEvent:A}),[E,D,x,A]);return(0,K.jsx)(We.Provider,{value:M,children:(0,K.jsx)(be,{elementsRef:O,onMapChange:e=>{g?.(e),k(e)},children:j})})}let Vn=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({});var Hn={multiple(e){return e?{[Vn.multiple]:``}:null}};const Un=X.forwardRef(function(e,t){let{defaultValue:r,disabled:i=!1,loopFocus:a=!0,onValueChange:o,orientation:s=`horizontal`,multiple:c=!1,value:l,className:u,render:d,...f}=e,p=Ie(!0),m=X.useMemo(()=>{if(l===void 0)return r??[]},[l,r]),h=X.useMemo(()=>l!==void 0||r!==void 0,[l,r]),g=(p?.disabled??!1)||i,[_,v]=P({controlled:l,default:m,name:`ToggleGroup`,state:`value`}),y=O((e,t,n)=>{let r;if(c?(r=_.slice(),t?r.push(e):r.splice(_.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(o?.(r,n),n.isCanceled)return;v(r)}}),b={disabled:g,multiple:c,orientation:s},x=X.useMemo(()=>({disabled:g,orientation:s,setGroupValue:y,value:_,isValueInitialized:h}),[g,s,y,_,h]),S={role:`group`},C=n(`div`,e,{enabled:!!p,state:b,ref:t,props:[S,f],stateAttributesMapping:Hn});return(0,K.jsx)(ke.Provider,{value:x,children:p?C:(0,K.jsx)(Bn,{render:d,className:u,state:b,refs:[t],props:[S,f],stateAttributesMapping:Hn,loopFocus:a,enableHomeAndEndKeys:!0})})});var Wn=S(),Gn=X.createContext({size:`default`,variant:`default`});function Kn(e){let t=(0,Wn.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:r,variant:a,size:o,orientation:s,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`default`:a,l=o===void 0?`default`:o,u=s===void 0?`horizontal`:s,d,f;t[7]!==l||t[8]!==c?(f={size:l,variant:c},t[7]=l,t[8]=c,t[9]=f):f=t[9],d=f;let p=d,m=u===`horizontal`?`*:pointer-coarse:after:min-w-auto`:`*:pointer-coarse:after:min-h-auto`,h=c===`default`?`gap-0.5`:u===`horizontal`?`*:not-first:not-data-[slot=separator]:before:-start-[0.5px] *:not-last:not-data-[slot=separator]:before:-end-[0.5px] *:not-first:rounded-s-none *:not-last:rounded-e-none *:not-first:border-s-0 *:not-last:border-e-0 *:not-first:before:rounded-s-none *:not-last:before:rounded-e-none`:`*:not-first:not-data-[slot=separator]:before:-top-[0.5px] *:not-last:not-data-[slot=separator]:before:-bottom-[0.5px] flex-col *:not-first:rounded-t-none *:not-last:rounded-b-none *:not-first:border-t-0 *:not-last:border-b-0 *:not-first:before:rounded-t-none *:not-last:before:rounded-b-none *:data-[slot=toggle]:not-last:before:hidden dark:*:last:before:hidden dark:*:first:before:block`,g;t[10]!==r||t[11]!==m||t[12]!==h?(g=U(`flex w-fit *:focus-visible:z-10 dark:*:[[data-slot=separator]:has(+[data-slot=toggle]:hover)]:before:bg-input/64 dark:*:[[data-slot=separator]:has(+[data-slot=toggle][data-pressed])]:before:bg-input dark:*:[[data-slot=toggle]:hover+[data-slot=separator]]:before:bg-input/64 dark:*:[[data-slot=toggle][data-pressed]+[data-slot=separator]]:before:bg-input`,m,h,r),t[10]=r,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==n||t[15]!==p?(_=(0,K.jsx)(Gn.Provider,{value:p,children:n}),t[14]=n,t[15]=p,t[16]=_):_=t[16];let v;return t[17]!==u||t[18]!==i||t[19]!==l||t[20]!==g||t[21]!==_||t[22]!==c?(v=(0,K.jsx)(Un,{className:g,"data-size":l,"data-slot":`toggle-group`,"data-variant":c,orientation:u,...i,children:_}),t[17]=u,t[18]=i,t[19]=l,t[20]=g,t[21]=_,t[22]=c,t[23]=v):v=t[23],v}function qn(e){let t=(0,Wn.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:o,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=X.useContext(Gn),c=o??s.variant,l=a??s.size,u;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==l||t[10]!==c?(u=(0,K.jsx)(ze,{className:r,"data-size":l,"data-variant":c,size:l,variant:c,...i,children:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=l,t[10]=c,t[11]=u):u=t[11],u}var Jn=`
|
|
1405
|
+
`||s[s.length-1]===``);)s.pop();let v=parseInt(p[3]),y=parseInt(p[1]);u=l?u:y-1,d=l?d:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:parseInt(p[4]??`1`),additionStart:v,additionLines:m,deletionCount:parseInt(p[2]??`1`),deletionStart:y,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:p[5],hunkSpecs:f,noEOFCRAdditions:!1,noEOFCRDeletions:!1};if(isNaN(b.additionCount)||isNaN(b.deletionCount)||isNaN(b.additionStart)||isNaN(b.deletionStart)){if(a)throw Error(`parsePatchContent: invalid hunk metadata`);console.error(`parsePatchContent: invalid hunk metadata`,b);continue}for(let e of s){let t=vn(e);if(t==null){console.error(`processFile: invalid rawLine:`,e);continue}let{type:n,line:r}=t;if(n===`addition`)(g==null||g.type!==`change`)&&(g=Sn(`change`,u,d),b.hunkContent.push(g)),d++,l&&c.additionLines.push(r),g.additions++,m++,_=`addition`;else if(n===`deletion`)(g==null||g.type!==`change`)&&(g=Sn(`change`,u,d),b.hunkContent.push(g)),u++,l&&c.deletionLines.push(r),g.deletions++,h++,_=`deletion`;else if(n===`context`)(g==null||g.type!==`context`)&&(g=Sn(`context`,u,d),b.hunkContent.push(g)),d++,u++,l&&(c.deletionLines.push(r),c.additionLines.push(r)),g.lines++,_=`context`;else if(n===`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]=M(c.additionLines[e]))}if(l&&(_===`deletion`||_===`context`)){let e=c.deletionLines.length-1;e>=0&&(c.deletionLines[e]=M(c.deletionLines[e]))}}}b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(b.additionStart-1-o,0),c.hunks.push(b),o=b.additionStart+b.additionCount-1;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(c.hunks.length>0&&!l&&c.additionLines.length>0&&c.deletionLines.length>0){let e=c.hunks[c.hunks.length-1],t=e.additionStart+e.additionCount-1,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`:i!=null&&i.contents===``?c.type=`deleted`:r!=null&&r.contents===``&&(c.type=`new`)),c.type!==`rename-pure`&&c.type!==`rename-changed`&&(c.prevName=void 0),c}}function xn(e,t,n=!1){let r=[];for(let i of e.split(y))try{r.push(yn(i,t==null?void 0:`${t}-${r.length}`,n))}catch(e){if(n)throw e;console.error(e)}return r}function Sn(e,t,n){return e===`change`?{type:`change`,additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:`context`,lines:0,additionLineIndex:n,deletionLineIndex:t}}function Cn(e,t,n,r=!1){let i=bn(we(e.name,t.name,e.contents,t.contents,e.header,t.header,n),{cacheKey:(()=>{if(e.cacheKey!=null&&t.cacheKey!=null)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:r});if(i==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);return i}var wn=-1,Tn=class{static LoadedCustomComponent=!0;__id=`file-diff:${++wn}`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;unsafeCSSStyle;hoverContent;headerElement;headerMetadata;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;mouseEventManager;lineSelectionManager;annotationCache=new Map;lineAnnotations=[];deletionFile;additionFile;fileDiff;renderRange;appliedPreAttributes;lastRenderedHeaderHTML;lastRowCount;enabled=!0;constructor(e={theme:z},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=new un({...e,hunkSeparators:typeof e.hunkSeparators==`function`?`custom`:e.hunkSeparators},this.handleHighlightRender,this.workerManager),this.resizeManager=new Ot,this.scrollSyncManager=new tn,this.mouseEventManager=new wt(`diff`,Tt(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0)),this.lineSelectionManager=new bt(xt(e,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getLineIndex=(e,t=`additions`)=>{if(this.fileDiff==null)return;let n=this.fileDiff.hunks.at(-1),r,i;hunkIterator:for(let a of this.fileDiff.hunks){let o=t===`deletions`?a.deletionStart:a.additionStart,s=t===`deletions`?a.deletionCount:a.additionCount,c=a.splitLineStart,l=a.unifiedLineStart;if(e<o){let t=o-e;r=Math.max(l-t,0),i=Math.max(c-t,0);break hunkIterator}if(e>=o+s){if(a===n){let t=e-(o+s);r=l+a.unifiedLineCount+t,i=c+a.splitLineCount+t;break hunkIterator}continue}for(let n of a.hunkContent)if(n.type===`context`)if(e<o+n.lines){let t=e-o;i=c+t,r=l+t;break hunkIterator}else o+=n.lines,c+=n.lines,l+=n.lines;else{let a=t===`deletions`?n.deletions:n.additions;if(e<o+a){let a=e-o;r=l+(t===`additions`?n.deletions:0)+a,i=c+a;break hunkIterator}else o+=a,c+=Math.max(n.deletions,n.additions),l+=n.deletions+n.additions}break hunkIterator}if(!(r==null||i==null))return[r,i]};setOptions(e){e!=null&&(this.options=e,this.hunksRenderer.setOptions({...this.options,hunkSeparators:typeof e.hunkSeparators==`function`?`custom`:e.hunkSeparators}),this.mouseEventManager.setOptions(Tt(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0)),this.lineSelectionManager.setOptions(xt(e,this.getLineIndex)))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){if((this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.hunksRenderer.setThemeType(e),this.headerElement!=null&&(e===`system`?delete this.headerElement.dataset.themeType:this.headerElement.dataset.themeType=e),this.pre!=null))switch(e){case`system`:delete this.pre.dataset.themeType;break;case`light`:case`dark`:this.pre.dataset.themeType=e;break}}getHoveredLine=()=>this.mouseEventManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e){this.lineSelectionManager.setSelection(e)}cleanUp(e=!1){this.resizeManager.cleanUp(),this.mouseEventManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.lineSelectionManager.cleanUp(),this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.parentNode?.removeChild(this.fileContainer),this.fileContainer?.shadowRoot!=null&&(this.fileContainer.shadowRoot.innerHTML=``),this.fileContainer=void 0,this.pre!=null&&(this.pre.innerHTML=``,this.pre=void 0),this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0,this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=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.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{overflow:t=`scroll`,diffStyle:n=`split`}=this.options,{fileContainer:r,prerenderedHTML:i}=e;Xt(r,i);for(let e of r.shadowRoot?.children??[]){if(e instanceof SVGElement){this.spriteSVG=e;continue}if(e instanceof HTMLElement){if(e instanceof HTMLPreElement){this.pre=e;for(let t of e.children)!(t instanceof HTMLElement)||t.tagName.toLowerCase()!==`code`||(`deletions`in t.dataset&&(this.codeDeletions=t),`additions`in t.dataset&&(this.codeAdditions=t),`unified`in t.dataset&&(this.codeUnified=t));continue}if(`diffsHeader`in e.dataset){this.headerElement=e;continue}if(e instanceof HTMLStyleElement&&e.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=e;continue}}}if(this.pre!=null&&this.syncCodeNodesFromPre(this.pre),this.pre==null)this.render(e);else{let{lineAnnotations:i,oldFile:a,newFile:o,fileDiff:s}=e;this.fileContainer=r,delete this.pre.dataset.dehydrated,this.lineAnnotations=i??this.lineAnnotations,this.additionFile=o,this.deletionFile=a,this.fileDiff=s??(a!=null&&o!=null?Cn(a,o):void 0),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderHoverUtility(),this.injectUnsafeCSS(),this.mouseEventManager.setup(this.pre),this.lineSelectionManager.setup(this.pre),this.resizeManager.setup(this.pre,t===`wrap`),t===`scroll`&&n===`split`&&this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions)}}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({oldFile:this.deletionFile,newFile:this.additionFile,fileDiff:this.fileDiff,forceRender:!0,renderRange:this.renderRange})}handleExpandHunk=(e,t)=>{this.expandHunk(e,t)};expandHunk(e,t){this.hunksRenderer.expandHunk(e,t),this.rerender()}render({oldFile:e,newFile:t,fileDiff:n,forceRender:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let c=e!=null&&t!=null&&(!Se(e,this.deletionFile)||!Se(t,this.additionFile)),l=n!=null&&n!==this.fileDiff,u=i!=null&&(i.length>0||this.lineAnnotations.length>0)?i!==this.lineAnnotations:!1;if(kt(s,this.renderRange)&&!r&&!u&&(n!=null&&n===this.fileDiff||n==null&&!c))return!1;let{renderRange:d}=this;if(this.renderRange=s,this.deletionFile=e,this.additionFile=t,n==null?e!=null&&t!=null&&c&&(l=!0,this.fileDiff=Cn(e,t)):this.fileDiff=n,i!=null&&this.setLineAnnotations(i),this.fileDiff==null)return!1;this.hunksRenderer.setOptions({...this.options,hunkSeparators:typeof this.options.hunkSeparators==`function`?`custom`:this.options.hunkSeparators}),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{diffStyle:f=`split`,disableErrorHandling:p=!1,disableFileHeader:m=!1,overflow:h=`scroll`}=this.options;m&&this.headerElement!=null&&(this.headerElement.parentNode?.removeChild(this.headerElement),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),a=this.getOrCreateFileContainer(a,o);try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(r,u,c||l)&&this.applyPartialRender({previousRenderRange:d,renderRange:s}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,s);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;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.parentNode?.removeChild(this.pre),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,s),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderHoverUtility(),this.mouseEventManager.setup(e),this.lineSelectionManager.setup(e),this.resizeManager.setup(e,h===`wrap`),h===`scroll`&&f===`split`?this.scrollSyncManager.setup(e,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp()}catch(e){if(p)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return!0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(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}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.mouseEventManager.cleanUp(),this.lineSelectionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.hoverContent?.remove(),this.pre?.remove(),this.spriteSVG?.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.hoverContent=void 0,this.pre=void 0,this.spriteSVG=void 0,this.unsafeCSSStyle=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0}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.parentNode?.removeChild(e);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||!_n(r,i.hunkData)){i?.element.parentNode?.removeChild(i.element);let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName,n.appendChild(t(r,this)),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.parentNode?.removeChild(t)}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.parentNode?.removeChild(e);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}-${W(r)}`,a=this.annotationCache.get(i);if(a==null||!gn(r,a.annotation)){a?.element.parentElement?.removeChild(a.element);let e=t(r);if(e==null)continue;a={element:Ut(W(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.parentNode?.removeChild(n)}renderHoverUtility(){let{renderHoverUtility:e}=this.options;if(this.fileContainer==null||e==null)return;let t=e(this.mouseEventManager.getHoveredLine);if(!(t!=null&&this.hoverContent!=null)){if(t==null){this.hoverContent?.parentNode?.removeChild(this.hoverContent),this.hoverContent=void 0;return}this.hoverContent=Wt(),this.hoverContent.appendChild(t),this.fileContainer.appendChild(this.hoverContent)}}getOrCreateFileContainer(e,t){let n=this.fileContainer;if(this.fileContainer=e??this.fileContainer??document.createElement(`diffs-container`),n!=null&&n!==this.fileContainer&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=Vt;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t,this.fileContainer.shadowRoot?.appendChild(this.spriteSVG))}return this.fileContainer}getFileContainer(){return this.fileContainer}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&&(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&&(`unified`in t.dataset?this.codeUnified=t:`deletions`in t.dataset?this.codeDeletions=t:`additions`in t.dataset&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let n=L(e);if(n!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=n;let r=e.firstElementChild;if(!(r instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(r):t.shadowRoot?.replaceChild(r,this.headerElement),this.headerElement=r,this.lastRenderedHeaderHTML=n}if(this.isContainerManaged)return;let{renderHeaderMetadata:r}=this.options;this.headerMetadata!=null&&this.headerMetadata.parentNode?.removeChild(this.headerMetadata);let i=r?.({deletionFile:this.deletionFile,additionFile:this.additionFile,fileDiff:this.fileDiff})??void 0;i!=null&&(this.headerMetadata=document.createElement(`div`),this.headerMetadata.slot=xe,i instanceof Element?this.headerMetadata.appendChild(i):this.headerMetadata.innerText=`${i}`,t.appendChild(this.headerMetadata))}injectUnsafeCSS(){if(this.fileContainer?.shadowRoot==null)return;let{unsafeCSS:e}=this.options;e==null||e===``||(this.unsafeCSSStyle??(this.unsafeCSSStyle=Gt(),this.fileContainer.shadowRoot.appendChild(this.unsafeCSSStyle)),this.unsafeCSSStyle.innerText=Jt(e))}applyHunksToDOM(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);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=Yt({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),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=Yt({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),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=Yt({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),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(`applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`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`)}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=En(t[0]),i=En(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}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}else 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)`)}getCodeColumns(e,t,n,r){function i(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}}if(e===`unified`)return i(t);{let e=i(n),t=i(r);return e!=null||t!=null?[e,t]:void 0}}applyBuffers(e,t){let{disableVirtualizationBuffers:n=!1}=this.options;if(n||t==null){this.bufferBefore!=null&&(this.bufferBefore.parentNode?.removeChild(this.bufferBefore),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.parentNode?.removeChild(this.bufferAfter),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.parentNode?.removeChild(this.bufferBefore),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.parentNode?.removeChild(this.bufferAfter),this.bufferAfter=void 0)}applyPreNodeAttributes(e,{themeStyles:t,baseThemeType:n,additionsContentAST:r,deletionsContentAST:i,totalLines:a}){let{diffIndicators:o=`bars`,disableBackground:s=!1,disableLineNumbers:c=!1,overflow:l=`scroll`,themeType:u=`system`,diffStyle:d=`split`}=this.options,f={type:`diff`,diffIndicators:o,disableBackground:s,disableLineNumbers:c,overflow:l,split:d===`unified`?!1:r!=null&&i!=null,themeStyles:t,themeType:n??u,totalLines:a};Ht(f,this.appliedPreAttributes)||(Zt(e,f),this.appliedPreAttributes=f)}applyErrorToDOM(e,t){this.cleanupErrorWrapper();let n=this.getOrCreatePreNode(t);n.innerHTML=``,n.parentNode?.removeChild(n),this.pre=void 0,this.appliedPreAttributes=void 0;let r=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.innerHTML=``,r.appendChild(this.errorWrapper);let i=document.createElement(`div`);i.dataset.errorMessage=``,i.innerText=e.message,this.errorWrapper.appendChild(i);let a=document.createElement(`pre`);a.dataset.errorStack=``,a.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(a)}cleanupErrorWrapper(){this.errorWrapper?.parentNode?.removeChild(this.errorWrapper),this.errorWrapper=void 0}};function En(e){if(!(e==null||e.type!==`element`))return e.children??[]}function Dn(e,t){let n={...j,...t};return n.hunkSeparatorHeight=On(e,t?.hunkSeparatorHeight),n}function On(e,t){if(t!=null)return t;switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}var kn=-1,An=class extends Tn{__id=`little-virtualized-file-diff:${++kn}`;top;height=0;metrics;heightCache=new Map;isVisible=!1;virtualizer;constructor(e,t,n,r,i=!1){super(e,r,i);let{hunkSeparators:a=`line-info`}=this.options;this.virtualizer=t,this.metrics=Dn(typeof a==`function`?`custom`:a,n)}getLineHeight(e,t=!1){let n=this.heightCache.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(e==null)return;let t=this.options.diffStyle,n=this.options.overflow;super.setOptions(e),(t!==this.options.diffStyle||n!==this.options.overflow)&&(this.heightCache.clear(),this.computeApproximateSize(),this.renderRange=void 0),this.virtualizer.instanceChanged(this)}reconcileHeights(){let{overflow:e=`scroll`}=this.options;if(this.fileContainer!=null&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.fileContainer==null||this.fileDiff==null){this.height=0;return}if(e===`scroll`&&this.lineAnnotations.length===0&&!this.virtualizer.config.resizeDebugging)return;let t=this.getDiffStyle(),n=!1,r=t===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];for(let e of r){if(e==null)continue;let r=e.children[1];if(r instanceof HTMLElement)for(let e of r.children){if(!(e instanceof HTMLElement))continue;let r=e.dataset.lineIndex;if(r==null)continue;let i=Mn(r,t),a=e.getBoundingClientRect().height,o=!1;e.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in e.nextElementSibling.dataset||`noNewline`in e.nextElementSibling.dataset)&&(`noNewline`in e.nextElementSibling.dataset&&(o=!0),a+=e.nextElementSibling.getBoundingClientRect().height);let s=this.getLineHeight(i,o);a!==s&&(n=!0,a===this.metrics.lineHeight*(o?2:1)?this.heightCache.delete(i):this.heightCache.set(i,a))}}(n||this.virtualizer.config.resizeDebugging)&&this.computeApproximateSize()}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer)),this.render());cleanUp(){this.fileContainer!=null&&this.virtualizer.disconnect(this.fileContainer),super.cleanUp()}expandHunk(e,t){this.hunksRenderer.expandHunk(e,t),this.computeApproximateSize(),this.renderRange=void 0,this.virtualizer.instanceChanged(this)}setVisibility(e){this.fileContainer!=null&&(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.virtualizer.getOffsetInScrollContainer(this.fileContainer),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}computeApproximateSize(){let e=this.height===0;if(this.height=0,this.fileDiff==null)return;let{disableFileHeader:n=!1,expandUnchanged:r=!1,collapsedContextThreshold:i=1,hunkSeparators:a=`line-info`}=this.options,{diffHeaderHeight:o,fileGap:s,hunkSeparatorHeight:c}=this.metrics,l=this.getDiffStyle(),u=a!==`simple`&&a!==`metadata`&&a!==`line-info-basic`?s:0;if(n?a!==`simple`&&a!==`metadata`&&(this.height+=s):this.height+=o,t({diff:this.fileDiff,diffStyle:l,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:e,collapsedBefore:t,collapsedAfter:n,deletionLine:r,additionLine:i})=>{let o=i==null?r.splitLineIndex:i.splitLineIndex,s=i==null?r.unifiedLineIndex:i.unifiedLineIndex,d=(i?.noEOFCR??!1)||(r?.noEOFCR??!1);t>0&&(e>0&&(this.height+=u),this.height+=c+u),this.height+=this.getLineHeight(l===`split`?o:s,d),n>0&&a!==`simple`&&(this.height+=u+c)}}),this.fileDiff.hunks.length>0&&(this.height+=s),this.fileContainer!=null&&this.virtualizer.config.resizeDebugging&&!e){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height})}}render({fileContainer:e,oldFile:t,newFile:n,fileDiff:r,...i}={}){let a=this.fileContainer==null;if(this.fileDiff??=r??(t!=null&&n!=null?Cn(t,n):void 0),e=this.getOrCreateFileContainer(e),this.fileDiff==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(a?(this.computeApproximateSize(),this.virtualizer.connect(e,this),this.top??=this.virtualizer.getOffsetInScrollContainer(e),this.isVisible=this.virtualizer.isInstanceVisible(this.top,this.height)):this.top??=this.virtualizer.getOffsetInScrollContainer(e),!this.isVisible)return this.renderPlaceholder(this.height);let o=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.fileDiff,this.top,o);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:s,oldFile:t,newFile:n,...i})}getDiffStyle(){return this.options.diffStyle??`split`}getExpandedRegion(e,t,n){if(n<=0||e)return{fromStart:0,fromEnd:0,collapsedLines:Math.max(n,0),renderAll:!1};let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;if(r||n<=i)return{fromStart:n,fromEnd:0,collapsedLines:0,renderAll:!0};let a=this.hunksRenderer.getExpandedHunk(t),o=Math.min(Math.max(a.fromStart,0),n),s=Math.min(Math.max(a.fromEnd,0),n),c=o+s,l=c>=n;return{fromStart:o,fromEnd:s,collapsedLines:Math.max(n-c,0),renderAll:l}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}for(let[r,i]of e.hunks.entries()){let a=t===`split`?i.splitLineCount:i.unifiedLineCount;n+=a;let o=Math.max(i.collapsedBefore,0),{fromStart:s,fromEnd:c,renderAll:l}=this.getExpandedRegion(e.isPartial,r,o);o>0&&(n+=l?o:s+c)}let r=e.hunks.at(-1);if(r!=null&&jn(e)){let t=e.additionLines.length-(r.additionLineIndex+r.additionCount),i=e.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(r!=null&&t!==i)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${t}, deletions=${i}) for ${e.name}`);let a=Math.min(t,i);if(r!=null&&a>0){let{fromStart:t,renderAll:r}=this.getExpandedRegion(e.isPartial,e.hunks.length,a);n+=r?a:t}}return n}computeRenderRangeFromWindow(e,n,{top:r,bottom:i}){let{disableFileHeader:a=!1,expandUnchanged:o=!1,collapsedContextThreshold:s=1,hunkSeparators:c=`line-info`}=this.options,{diffHeaderHeight:l,fileGap:u,hunkLineCount:d,hunkSeparatorHeight:f,lineHeight:p}=this.metrics,m=this.getDiffStyle(),h=this.height,g=this.getExpandedLineCount(e,m),_=a?u:l;if(n<r-h||n>i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-_-u};if(g<=d||e.hunks.length===0)return{startingLine:0,totalLines:d,bufferBefore:0,bufferAfter:0};let v=Math.ceil(Math.max(i-r,0)/p),y=Math.ceil(v/d)*d+d,b=y/d,x=b,S=[],C=(r+i)/2,w=c===`simple`||c===`metadata`||c===`line-info-basic`?0:u,T=n+_,E=0,D,O,k;if(t({diff:e,diffStyle:m,expandedHunks:o?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:e,collapsedBefore:t,collapsedAfter:a,deletionLine:o,additionLine:s})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,u=s==null?o.unifiedLineIndex:s.unifiedLineIndex,p=(s?.noEOFCR??!1)||(o?.noEOFCR??!1),h=t>0?f+w+(e>0?w:0):0;e===0&&c===`simple`&&(h=0),T+=h;let g=E%d===0;if(g&&(S.push(T-(n+_+h)),k!=null)){if(k<=0)return!0;k--}let v=this.getLineHeight(m===`split`?l:u,p),y=Math.floor(E/d);return T>r-v&&T<i&&(D??=y),O==null&&T+v>C&&(O=y),k==null&&T>=i&&g&&(k=x),E++,T+=v,a>0&&c!==`simple`&&(T+=f+w),!1}}),D==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-_-u};let A=S.length;O??=D;let j=Math.round(O-b/2),M=Math.max(0,A-b),N=Math.max(0,Math.min(j,M)),P=N*d,F=j<0?y+j*d:y,ee=S[N]??0,I=N+F/d;return{startingLine:P,totalLines:F,bufferBefore:ee,bufferAfter:I<S.length?h-_-S[I]-u:h-(T-n)-u}}};function jn(e){let t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function Mn(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var Nn=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function Pn({oldFile:e,newFile:t,fileDiff:n,options:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:o,metrics:c}){let l=_t(),u=(0,Z.useContext)(s),d=(0,Z.useRef)(null),f=vt(a=>{if(a!=null){if(d.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);l==null?d.current=new Tn(r,u,!0):d.current=new An(r,l,c,u,!0),d.current.hydrate({fileDiff:n,oldFile:e,newFile:t,fileContainer:a,lineAnnotations:i,prerenderedHTML:o})}else{if(d.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);d.current.cleanUp(),d.current=null}});return Nn(()=>{if(d.current==null)return;let o=d.current,s=!$t(o.options,r);o.setOptions(r),o.render({forceRender:s,fileDiff:n,oldFile:e,newFile:t,lineAnnotations:i}),a!==void 0&&o.setSelectedLines(a)}),{ref:f,getHoveredLine:(0,Z.useCallback)(()=>d.current?.getHoveredLine(),[])}}function Fn({fileDiff:t,options:n,metrics:r,lineAnnotations:i,selectedLines:a,className:o,style:s,prerenderedHTML:c,renderAnnotation:l,renderHeaderMetadata:u,renderHoverUtility:d}){let{ref:f,getHoveredLine:p}=Pn({fileDiff:t,options:n,metrics:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:c});return(0,G.jsx)(e,{ref:f,className:o,style:s,children:rt(en({fileDiff:t,renderHeaderMetadata:u,renderAnnotation:l,lineAnnotations:i,renderHoverUtility:d,getHoveredLine:p}),c)})}function In(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var Ln=[];function Rn(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:s,highlightedIndex:l,onHighlightedIndexChange:d,rootRef:f,enableHomeAndEndKeys:p=!1,stopEventPropagation:m=!1,disabledIndices:h,modifierKeys:g=Ln}=e,[_,v]=Z.useState(0),y=n>1,b=Z.useRef(null),x=A(b,f),S=Z.useRef([]),C=Z.useRef(!1),w=l??_,T=Te((e,t=!1)=>{if((d??v)(e),t){let t=S.current[e];Je(b.current,t,s,a)}}),E=Te(e=>{if(e.size===0||C.current)return;C.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&T(r),Je(b.current,n,s,a)}),D=Z.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:x,onFocus(e){!b.current||!ue(e.target)||e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let l=p?de:He;if(!l.has(e.key)||zn(e,g)||!b.current)return;let d=s===`rtl`,f=d?V:H,_={horizontal:f,vertical:Ee,both:f}[a],v=d?H:V,x={horizontal:v,vertical:Pe,both:v}[a];if(ue(e.target)&&!In(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==x&&t<r.length||e.key!==_&&t>0)return}let C=w,E=u(S,h),D=I(S,h);if(y){let s=t||Array.from({length:S.current.length},()=>({width:1,height:1})),c=B(s,n,i),l=c.findIndex(e=>e!=null&&!O(S,e,h)),u=c.reduce((e,t,n)=>t!=null&&!O(S,t,h)?n:e,-1);C=c[qe({current:c.map(e=>e?S.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:o([...h||S.current.map((e,t)=>O(S,t)?t:void 0),void 0],c),minIndex:l,maxIndex:u,prevIndex:F(w>D?E:w,s,c,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:d})]}let k={horizontal:[f],vertical:[Ee],both:[f,Ee]}[a],A={horizontal:[v],vertical:[Pe],both:[v,Pe]}[a],j=y?l:{horizontal:p?ge:ve,vertical:p?Xe:We,both:l}[a];p&&(e.key===`Home`?C=E:e.key===`End`&&(C=D)),C===w&&(k.includes(e.key)||A.includes(e.key))&&(C=r&&C===D&&k.includes(e.key)?E:r&&C===E&&A.includes(e.key)?D:Ye(S,{startingIndex:C,decrement:A.includes(e.key),disabledIndices:h})),C!==w&&!c(S,C)&&(m&&e.stopPropagation(),j.has(e.key)&&e.preventDefault(),T(C,!0),queueMicrotask(()=>{S.current[C]?.focus()}))}}),[n,i,s,h,S,p,w,y,t,r,x,g,T,a,m]);return Z.useMemo(()=>({props:D,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:S,disabledIndices:h,onMapChange:E,relayKeyboardEvent:D.onKeyDown}),[D,w,T,S,h,E])}function zn(e,t){for(let n of oe.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Bn(e){let{render:t,className:n,refs:r=w,props:i=w,state:a=E,stateAttributesMapping:o,highlightedIndex:s,onHighlightedIndexChange:c,orientation:l,dense:u,itemSizes:d,loopFocus:f,cols:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:T,onHighlightedIndexChange:D,elementsRef:O,onMapChange:k,relayKeyboardEvent:A}=Rn({itemSizes:d,cols:p,loopFocus:f,dense:u,orientation:l,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:Ge(),disabledIndices:v,modifierKeys:y}),j=Ce(x,e,{state:a,ref:r,props:[C,...i,S],stateAttributesMapping:o}),M=Z.useMemo(()=>({highlightedIndex:T,onHighlightedIndexChange:D,highlightItemOnHover:b,relayKeyboardEvent:A}),[T,D,b,A]);return(0,G.jsx)(Ze.Provider,{value:M,children:(0,G.jsx)(be,{elementsRef:O,onMapChange:e=>{h?.(e),k(e)},children:j})})}let Vn=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({});var Hn={multiple(e){return e?{[Vn.multiple]:``}:null}};const Un=Z.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,...d}=e,f=Le(!0),p=Z.useMemo(()=>{if(c===void 0)return n??[]},[c,n]),m=Z.useMemo(()=>c!==void 0||n!==void 0,[c,n]),h=(f?.disabled??!1)||r,[g,_]=P({controlled:c,default:p,name:`ToggleGroup`,state:`value`}),v=Te((e,t,n)=>{let r;if(s?(r=g.slice(),t?r.push(e):r.splice(g.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(a?.(r,n),n.isCanceled)return;_(r)}}),y={disabled:h,multiple:s,orientation:o},b=Z.useMemo(()=>({disabled:h,orientation:o,setGroupValue:v,value:g,isValueInitialized:m}),[h,o,v,g,m]),x={role:`group`},S=Ce(`div`,e,{enabled:!!f,state:y,ref:t,props:[x,d],stateAttributesMapping:Hn});return(0,G.jsx)(Ae.Provider,{value:b,children:f?S:(0,G.jsx)(Bn,{render:u,className:l,state:y,refs:[t],props:[x,d],stateAttributesMapping:Hn,loopFocus:i,enableHomeAndEndKeys:!0})})});var Wn=v(),Gn=Z.createContext({size:`default`,variant:`default`});function Kn(e){let t=(0,Wn.c)(24),r,i,a,o,s,c;t[0]===e?(r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6]):({className:i,variant:o,size:s,orientation:c,children:r,...a}=e,t[0]=e,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l=o===void 0?`default`:o,u=s===void 0?`default`:s,d=c===void 0?`horizontal`:c,f,p;t[7]!==u||t[8]!==l?(p={size:u,variant:l},t[7]=u,t[8]=l,t[9]=p):p=t[9],f=p;let m=f,h=d===`horizontal`?`*:pointer-coarse:after:min-w-auto`:`*:pointer-coarse:after:min-h-auto`,g=l===`default`?`gap-0.5`:d===`horizontal`?`*:not-first:not-data-[slot=separator]:before:-start-[0.5px] *:not-last:not-data-[slot=separator]:before:-end-[0.5px] *:not-first:rounded-s-none *:not-last:rounded-e-none *:not-first:border-s-0 *:not-last:border-e-0 *:not-first:before:rounded-s-none *:not-last:before:rounded-e-none`:`*:not-first:not-data-[slot=separator]:before:-top-[0.5px] *:not-last:not-data-[slot=separator]:before:-bottom-[0.5px] flex-col *:not-first:rounded-t-none *:not-last:rounded-b-none *:not-first:border-t-0 *:not-last:border-b-0 *:not-first:before:rounded-t-none *:not-last:before:rounded-b-none *:data-[slot=toggle]:not-last:before:hidden dark:*:last:before:hidden dark:*:first:before:block`,_;t[10]!==i||t[11]!==h||t[12]!==g?(_=n(`flex w-fit *:focus-visible:z-10 dark:*:[[data-slot=separator]:has(+[data-slot=toggle]:hover)]:before:bg-input/64 dark:*:[[data-slot=separator]:has(+[data-slot=toggle][data-pressed])]:before:bg-input dark:*:[[data-slot=toggle]:hover+[data-slot=separator]]:before:bg-input/64 dark:*:[[data-slot=toggle][data-pressed]+[data-slot=separator]]:before:bg-input`,h,g,i),t[10]=i,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==r||t[15]!==m?(v=(0,G.jsx)(Gn.Provider,{value:m,children:r}),t[14]=r,t[15]=m,t[16]=v):v=t[16];let y;return t[17]!==d||t[18]!==a||t[19]!==u||t[20]!==_||t[21]!==v||t[22]!==l?(y=(0,G.jsx)(Un,{className:_,"data-size":u,"data-slot":`toggle-group`,"data-variant":l,orientation:d,...a,children:v}),t[17]=d,t[18]=a,t[19]=u,t[20]=_,t[21]=v,t[22]=l,t[23]=y):y=t[23],y}function qn(e){let t=(0,Wn.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:o,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=Z.useContext(Gn),c=o??s.variant,l=a??s.size,u;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==l||t[10]!==c?(u=(0,G.jsx)(Be,{className:r,"data-size":l,"data-variant":c,size:l,variant:c,...i,children:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=l,t[10]=c,t[11]=u):u=t[11],u}var Jn=`
|
|
1406
1406
|
[data-diffs-header],
|
|
1407
1407
|
[data-diff],
|
|
1408
1408
|
[data-file],
|
|
@@ -1464,4 +1464,4 @@ import{$ as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l
|
|
|
1464
1464
|
color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
|
|
1465
1465
|
text-decoration-color: currentColor;
|
|
1466
1466
|
}
|
|
1467
|
-
`;function Yn(e,t=`diff-panel`){if(!e)return null;let n=e.trim();if(n.length===0)return null;try{let e=xn(n,
|
|
1467
|
+
`;function Yn(e,t=`diff-panel`){if(!e)return null;let n=e.trim();if(n.length===0)return null;try{let e=xn(n,Ke(n,t)).flatMap(e=>e.files);return e.length>0?{kind:`files`,files:e}:{kind:`raw`,text:n,reason:`Unsupported diff format. Showing raw patch.`}}catch{return{kind:`raw`,text:n,reason:`Failed to parse patch. Showing raw patch.`}}}function Xn(e){let t=e.name??e.prevName??``;return t.startsWith(`a/`)||t.startsWith(`b/`)?t.slice(2):t}function Zn(e){return e.cacheKey??`${e.prevName??`none`}:${e.name}`}function Qn(e){return new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(new Date(e))}function $n({mode:e=`inline`}){let t=$e(),{resolvedTheme:r}=l(),[a,o]=(0,Z.useState)(`stacked`),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),h=ie({strict:!1,select:e=>e.threadId?f.makeUnsafe(e.threadId):null}),g=i({strict:!1,select:e=>Me(e)}),_=h,v=Fe(e=>_?e.threads.find(e=>e.id===_):void 0),y=v?.projectId??null,b=Fe(e=>y?e.projects.find(e=>e.id===y):void 0),x=v?.worktreePath??b?.cwd,{turnDiffSummaries:C,inferredCheckpointTurnCountByTurnId:w}=ce(v),T=(0,Z.useMemo)(()=>[...C].toSorted((e,t)=>{let n=e.checkpointTurnCount??w[e.turnId]??0,r=t.checkpointTurnCount??w[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[w,C]),E=g.diffTurnId??null,D=E===null?null:g.diffFilePath??null,O=E===null?void 0:T.find(e=>e.turnId===E)??T[0],k=O&&(O.checkpointTurnCount??w[O.turnId]),A=(0,Z.useMemo)(()=>typeof k==`number`?{fromTurnCount:Math.max(0,k-1),toTurnCount:k}:null,[k]),j=(0,Z.useMemo)(()=>{let e=T.map(e=>e.checkpointTurnCount??w[e.turnId]).filter(e=>typeof e==`number`);if(e.length===0)return;let t=Math.max(...e);return t>0?t:void 0},[w,T]),M=(0,Z.useMemo)(()=>!O&&typeof j==`number`?{fromTurnCount:0,toTurnCount:j}:null,[j,O]),P=O?A:M,F=(0,Z.useMemo)(()=>O||T.length===0?null:`conversation:${T.map(e=>e.turnId).join(`,`)}`,[T,O]),I=S(Ue({threadId:_,fromTurnCount:P?.fromTurnCount??null,toTurnCount:P?.toTurnCount??null,cacheScope:O?`turn:${O.turnId}`:F})),te=O?I.data?.diff:void 0,ne=O?void 0:I.data?.diff,re=I.isLoading,L=I.error instanceof Error?I.error.message:I.error?`Failed to load checkpoint diff.`:null,R=O?te:ne,ae=typeof R==`string`&&R.trim().length===0,z=(0,Z.useMemo)(()=>Yn(R,`diff-panel:${r}`),[r,R]),oe=(0,Z.useMemo)(()=>!z||z.kind!==`files`?[]:z.files.toSorted((e,t)=>Xn(e).localeCompare(Xn(t),void 0,{numeric:!0,sensitivity:`base`})),[z]);(0,Z.useEffect)(()=>{!D||!s.current||Array.from(s.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===D)?.scrollIntoView({block:`nearest`})},[D,oe]);let se=(0,Z.useCallback)(e=>{let t=ke();if(!t)return;let n=x?he(e,x):e;t.shell.openInEditor(n,pe()).catch(e=>{console.warn(`Failed to open diff file in editor.`,e)})},[x]),le=e=>{v&&t({to:`/$threadId`,params:{threadId:v.id},search:t=>({...Re(t),diff:`1`,diffTurnId:e})})},ue=()=>{v&&t({to:`/$threadId`,params:{threadId:v.id},search:e=>({...Re(e),diff:`1`})})},B=(0,Z.useCallback)(()=>{let e=c.current;if(!e){d(!1),m(!1);return}let t=Math.max(0,e.scrollWidth-e.clientWidth);d(e.scrollLeft>4),m(e.scrollLeft<t-4)},[]),de=(0,Z.useCallback)(e=>{let t=c.current;t&&t.scrollBy({left:e,behavior:`smooth`})},[]),fe=(0,Z.useCallback)(e=>{let t=c.current;t&&(t.scrollWidth<=t.clientWidth+1||Math.abs(e.deltaY)<=Math.abs(e.deltaX)||(e.preventDefault(),t.scrollBy({left:e.deltaY,behavior:`auto`})))},[]);(0,Z.useEffect)(()=>{let e=c.current;if(!e)return;let t=window.requestAnimationFrame(()=>B()),n=()=>B();e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(()=>B());return r.observe(e),()=>{window.cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),r.disconnect()}},[B]),(0,Z.useEffect)(()=>{let e=window.requestAnimationFrame(()=>B());return()=>{window.cancelAnimationFrame(e)}},[T,E,B]),(0,Z.useEffect)(()=>{let e=c.current;e&&e.querySelector(`[data-turn-chip-selected='true']`)?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},[O?.turnId,E]);let V=N&&e!==`sheet`,me=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1 [-webkit-app-region:no-drag]`,children:[u&&(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-8 z-10 w-7 bg-linear-to-r from-card to-transparent`}),p&&(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-8 z-10 w-7 bg-linear-to-l from-card to-transparent`}),(0,G.jsx)(`button`,{type:`button`,className:n(`absolute left-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,u?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>de(-180),disabled:!u,"aria-label":`Scroll turn list left`,children:(0,G.jsx)(_e,{className:`size-3.5`})}),(0,G.jsx)(`button`,{type:`button`,className:n(`absolute right-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,p?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>de(180),disabled:!p,"aria-label":`Scroll turn list right`,children:(0,G.jsx)(ye,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{ref:c,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,onWheel:fe,children:[(0,G.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:ue,"data-turn-chip-selected":E===null,children:(0,G.jsx)(`div`,{className:n(`rounded-md border px-2 py-1 text-left transition-colors`,E===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,G.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`})})}),T.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>le(e.turnId),title:e.turnId,"data-turn-chip-selected":e.turnId===O?.turnId,children:(0,G.jsx)(`div`,{className:n(`rounded-md border px-2 py-1 text-left transition-colors`,e.turnId===O?.turnId?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn`,` `,e.checkpointTurnCount??w[e.turnId]??`?`]}),(0,G.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:Qn(e.completedAt)})]})})},e.turnId))]})]}),(0,G.jsxs)(Kn,{className:`shrink-0 [-webkit-app-region:no-drag]`,variant:`outline`,size:`xs`,value:[a],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&o(t)},children:[(0,G.jsx)(qn,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,G.jsx)(tt,{className:`size-3`})}),(0,G.jsx)(qn,{"aria-label":`Split diff view`,value:`split`,children:(0,G.jsx)(et,{className:`size-3`})})]})]}),H=n(`flex items-center justify-between gap-2 px-4`,V?`drag-region h-[52px] border-b border-border`:`h-12`);return(0,G.jsxs)(`div`,{className:n(`flex h-full min-w-0 flex-col bg-background`,e===`inline`?`w-[42vw] min-w-[360px] max-w-[560px] shrink-0 border-l border-border`:`w-full`),children:[V?(0,G.jsx)(`div`,{className:H,children:me}):(0,G.jsx)(`div`,{className:`border-b border-border`,children:(0,G.jsx)(`div`,{className:H,children:me})}),v?T.length===0?(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{ref:s,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:[L&&!z&&(0,G.jsx)(`div`,{className:`px-3`,children:(0,G.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:L})}),z?z.kind===`files`?(0,G.jsx)(gt,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:oe.map(e=>{let t=Xn(e),n=`${Zn(e)}:${r}`;return(0,G.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,onClickCapture:e=>{(e.nativeEvent.composedPath?.()??[]).some(e=>e instanceof Element?e.hasAttribute(`data-title`):!1)&&se(t)},children:(0,G.jsx)(Fn,{fileDiff:e,options:{diffStyle:a===`split`?`split`:`unified`,lineDiffType:`none`,theme:ee(r),themeType:r,unsafeCSS:Jn}})},n)})}):(0,G.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:z.reason}),(0,G.jsx)(`pre`,{className:`max-h-[72vh] overflow-auto rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,children:z.text})]})}):(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,G.jsx)(`p`,{children:re?`Loading checkpoint diff...`:ae?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})]})}export{a as DiffWorkerPoolProvider,$n as default};
|