@openclaw/diffs 2026.5.28 → 2026.5.31-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/assets/viewer-runtime.js +1 -1
  2. package/dist/index.js +12 -7
  3. package/node_modules/@pierre/diffs/dist/components/File.d.ts +5 -3
  4. package/node_modules/@pierre/diffs/dist/components/File.d.ts.map +1 -1
  5. package/node_modules/@pierre/diffs/dist/components/File.js +25 -5
  6. package/node_modules/@pierre/diffs/dist/components/File.js.map +1 -1
  7. package/node_modules/@pierre/diffs/dist/components/FileDiff.d.ts +8 -5
  8. package/node_modules/@pierre/diffs/dist/components/FileDiff.d.ts.map +1 -1
  9. package/node_modules/@pierre/diffs/dist/components/FileDiff.js +25 -5
  10. package/node_modules/@pierre/diffs/dist/components/FileDiff.js.map +1 -1
  11. package/node_modules/@pierre/diffs/dist/components/UnresolvedFile.d.ts +4 -3
  12. package/node_modules/@pierre/diffs/dist/components/UnresolvedFile.d.ts.map +1 -1
  13. package/node_modules/@pierre/diffs/dist/components/UnresolvedFile.js +2 -0
  14. package/node_modules/@pierre/diffs/dist/components/UnresolvedFile.js.map +1 -1
  15. package/node_modules/@pierre/diffs/dist/constants.d.ts.map +1 -1
  16. package/node_modules/@pierre/diffs/dist/index.d.ts +3 -3
  17. package/node_modules/@pierre/diffs/dist/react/UnresolvedFile.d.ts +2 -2
  18. package/node_modules/@pierre/diffs/dist/react/UnresolvedFile.d.ts.map +1 -1
  19. package/node_modules/@pierre/diffs/dist/react/UnresolvedFile.js.map +1 -1
  20. package/node_modules/@pierre/diffs/dist/react/index.d.ts +2 -2
  21. package/node_modules/@pierre/diffs/dist/react/jsx.d.ts.map +1 -1
  22. package/node_modules/@pierre/diffs/dist/ssr/index.d.ts +2 -2
  23. package/node_modules/@pierre/diffs/dist/types.d.ts +2 -1
  24. package/node_modules/@pierre/diffs/dist/types.d.ts.map +1 -1
  25. package/node_modules/@pierre/diffs/dist/worker/worker-portable.js +6 -9
  26. package/node_modules/@pierre/diffs/dist/worker/worker-portable.js.map +1 -1
  27. package/node_modules/@pierre/diffs/package.json +1 -1
  28. package/node_modules/typebox/build/type/script/mapping.d.mts +5 -2
  29. package/node_modules/typebox/build/type/script/mapping.mjs +15 -8
  30. package/node_modules/typebox/build/type/script/parser.d.mts +3 -1
  31. package/node_modules/typebox/build/type/script/parser.mjs +2 -1
  32. package/node_modules/typebox/package.json +29 -29
  33. package/npm-shrinkwrap.json +10 -10
  34. package/package.json +6 -6
@@ -231,7 +231,7 @@ ${e}`,n=A.startsWith(e)?0:Cp(A,t,0);if(n===-1)return[A];let o=[];n>0&&o.push(A.s
231
231
  `}function ar(A,e,t,n,o,a,r){if(typeof r=="function"&&(r={callback:r}),r?.callback){let{callback:s}=r;or(A,e,t,n,o,a,Object.assign(Object.assign({},r),{callback:i=>{s(i?Wn(i,r.headerOptions):void 0)}}))}else{let s=or(A,e,t,n,o,a,r);return s?Wn(s,r?.headerOptions):void 0}}function RI(A){let e=A.endsWith(`
232
232
  `),t=A.split(`
233
233
  `).map(n=>n+`
234
- `);return e?t.pop():t.push(t.pop().slice(0,-1)),t}function rr(A,e,t,n=!1){let o=fp(ar(A.name,e.name,A.contents,e.contents,A.header,e.header,t),{cacheKey:(()=>{if(A.cacheKey!=null&&e.cacheKey!=null)return`${A.cacheKey}:${e.cacheKey}`})(),oldFile:A,newFile:e,throwOnError:n});if(o==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");return e.lang!=null&&(o.lang=e.lang),o}var kp=class{constructor(){B(this,"isDeletionsScrolling",!1);B(this,"isAdditionsScrolling",!1);B(this,"timeoutId",-1);B(this,"codeDeletions");B(this,"codeAdditions");B(this,"enabled",!1);B(this,"handleDeletionsScroll",()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))});B(this,"handleAdditionsScroll",()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))})}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,this.enabled=!1)}setup(A,e,t){if(e==null||t==null)for(let n of A.children??[])n instanceof HTMLElement&&("deletions"in n.dataset?e=n:"additions"in n.dataset&&(t=n));if(t==null||e==null){this.cleanUp();return}this.codeDeletions!==e&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=e,e.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==t&&(this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=t,t.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}};function Re(A,e){return St(A.theme,e.theme)&&A.useTokenTransformer===e.useTokenTransformer&&A.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&A.lineDiffType===e.lineDiffType&&A.maxLineDiffLength===e.maxLineDiffLength}function _t(A){return v({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":A,style:`grid-row: span ${A};min-height:calc(${A} * 1lh)`}})}function xt(A){return v({tagName:"div",children:[v({tagName:"span",children:[rA("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":A,"data-column-content":""}})}function ir(A){return v({tagName:"div",children:[ne({name:A==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":A==="both"?"":void 0,"data-expand-up":A==="up"?"":void 0,"data-expand-down":A==="down"?"":void 0}})}function Ee({type:A,content:e,expandIndex:t,chunked:n=!1,slotName:o,isFirstHunk:a,isLastHunk:r}){let s=0,i=[];if(A==="metadata"&&e!=null&&i.push(v({tagName:"div",children:[rA(e)],properties:{"data-separator-wrapper":""}})),(A==="line-info"||A==="line-info-basic")&&e!=null){let c=[];t!=null&&(n?(a||(c.push(ir("up")),s++),r||(c.push(ir("down")),s++)):(c.push(ir(!a&&!r?"both":a?"down":"up")),s++)),c.push(v({tagName:"div",children:[v({tagName:"span",children:[rA(e)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),n&&t!=null&&c.push(v({tagName:"div",children:[rA("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}})),i.push(v({tagName:"div",children:c,properties:{"data-separator-wrapper":"","data-separator-multi-button":s>1?"":void 0}}))}return A==="custom"&&o!=null&&i.push(v({tagName:"slot",properties:{name:o}})),v({tagName:"div",children:i,properties:{"data-separator":i.length===0?"simple":A,"data-expand-index":t,"data-separator-first":a?"":void 0,"data-separator-last":r?"":void 0}})}function yp(A,e){return`hunk-separator-${A}-${e}`}function Fp(A){let e=A.at(-1);return e==null?0:Math.max(e.additionStart+e.additionCount,e.deletionStart+e.deletionCount)}function _p(A){return A.startingLine===0&&A.totalLines===1/0&&A.bufferBefore===0&&A.bufferAfter===0}function sr({line:A,spanStart:e,spanLength:t}){return{start:{line:A,character:e},end:{line:A,character:e+t},properties:{"data-diff-span":""},alwaysWrap:!0}}function vt({item:A,arr:e,enableJoin:t,isNeutral:n=!1,isLastItem:o=!1}){let a=e[e.length-1];if(a==null||o||!t){e.push([n?0:1,A.value]);return}let r=a[0]===0;if(n===r||n&&A.value.length===1&&!r){a[1]+=A.value;return}e.push([n?0:1,A.value])}function Mt({isPartial:A,rangeSize:e,expandedHunks:t,hunkIndex:n,collapsedContextThreshold:o}){let a=Math.max(e,0);if(a===0||A)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(t===!0||a<=o)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let r=t?.get(n),s=Math.min(Math.max(r?.fromStart??0,0),a),i=Math.min(Math.max(r?.fromEnd??0,0),a),c=s+i,g=c>=a;return{fromStart:g?a:s,fromEnd:g?0:i,rangeSize:a,collapsedLines:Math.max(a-c,0),renderAll:g}}function Zn({diff:A,diffStyle:e,startingLine:t=0,totalLines:n=1/0,expandedHunks:o,collapsedContextThreshold:a=Ie,callback:r}){let s=SI({diff:A,diffStyle:e,startingLine:t,expandedHunks:o,collapsedContextThreshold:a}),i={finalHunk:A.hunks.at(-1),viewportStart:t,viewportEnd:t+n,isWindowedHighlight:t>0||n<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,shouldBreak(){if(!i.isWindowedHighlight)return!1;let c=i.unifiedCount>=t+n,g=i.splitCount>=t+n;return e==="unified"?c:(e==="split"||c)&&g},shouldSkip(c,g){if(!i.isWindowedHighlight)return!1;let d=i.unifiedCount+c<t,u=i.splitCount+g<t;return e==="unified"?d:(e==="split"||d)&&u},incrementCounts(c,g){(e==="unified"||e==="both")&&(i.unifiedCount+=c),(e==="split"||e==="both")&&(i.splitCount+=g)},isInWindow(c,g){if(!i.isWindowedHighlight)return!0;let d=i.isInUnifiedWindow(c),u=i.isInSplitWindow(g);return e==="unified"?d:e==="split"?u:d||u},isInUnifiedWindow(c){return!i.isWindowedHighlight||i.unifiedCount>=t-c&&i.unifiedCount<t+n},isInSplitWindow(c){return!i.isWindowedHighlight||i.splitCount>=t-c&&i.splitCount<t+n},emit(c,g=!1){return g||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),r(c)??!1}};A:for(let c=s.hunkIndex;c<A.hunks.length;c++){let l=function(h,M){return u==null||u.collapsedLines<=0||u.fromStart+u.fromEnd>0?0:e==="unified"?h===g.unifiedLineStart+g.unifiedLineCount-1?u.collapsedLines:0:M===g.splitLineStart+g.splitLineCount-1?u.collapsedLines:0},C=function(){if(d.collapsedLines===0)return 0;let h=d.collapsedLines;return d.collapsedLines=0,h},g=A.hunks[c];if(g==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;let d=Mt({isPartial:A.isPartial,rangeSize:g.collapsedBefore,expandedHunks:o,hunkIndex:c,collapsedContextThreshold:a}),u=(()=>{if(g!==i.finalHunk||!xp(A))return;let h=A.additionLines.length-(g.additionLineIndex+g.additionCount),M=A.deletionLines.length-(g.deletionLineIndex+g.deletionCount);if(h!==M)throw new Error(`iterateOverDiff: trailing context mismatch (additions=${h}, deletions=${M}) for ${A.name}`);let F=Math.min(h,M);return Mt({isPartial:A.isPartial,rangeSize:F,expandedHunks:o,hunkIndex:A.hunks.length,collapsedContextThreshold:a})})(),p=d.fromStart+d.fromEnd;if(i.shouldSkip(p,p))i.incrementCounts(p,p),C();else{let h=g.unifiedLineStart-d.rangeSize,M=g.splitLineStart-d.rangeSize,F=g.deletionLineIndex-d.rangeSize,H=g.additionLineIndex-d.rangeSize,x=g.deletionStart-d.rangeSize,S=g.additionStart-d.rangeSize,[_,R]=$n(i,d.fromStart,e);_>0&&i.incrementCounts(_,_);let L=_;for(;L<d.fromStart;){if(L>=R){i.incrementCounts(d.fromStart-L,d.fromStart-L);break}if(i.isInWindow(0,0)){if(i.emit({hunkIndex:c,hunk:g,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+L,lineIndex:F+L,noEOFCR:!1,unifiedLineIndex:h+L,splitLineIndex:M+L},additionLine:{unifiedLineIndex:h+L,splitLineIndex:M+L,lineIndex:H+L,lineNumber:S+L,noEOFCR:!1}}))break A}else i.incrementCounts(1,1);L++}h=g.unifiedLineStart-d.fromEnd,M=g.splitLineStart-d.fromEnd,F=g.deletionLineIndex-d.fromEnd,H=g.additionLineIndex-d.fromEnd,x=g.deletionStart-d.fromEnd,S=g.additionStart-d.fromEnd;let[cA,K]=$n(i,d.fromEnd,e);for(cA>0&&i.incrementCounts(cA,cA),L=cA;L<d.fromEnd;){if(L>=K){i.incrementCounts(d.fromEnd-L,d.fromEnd-L);break}if(i.isInWindow(0,0)){if(i.emit({hunkIndex:c,hunk:g,collapsedBefore:C(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+L,lineIndex:F+L,noEOFCR:!1,unifiedLineIndex:h+L,splitLineIndex:M+L},additionLine:{unifiedLineIndex:h+L,splitLineIndex:M+L,lineIndex:H+L,lineNumber:S+L,noEOFCR:!1}}))break A}else i.incrementCounts(1,1);L++}}let f=g.unifiedLineStart,E=g.splitLineStart,m=g.deletionLineIndex,Q=g.additionLineIndex,I=g.deletionStart,w=g.additionStart,y=g.hunkContent.at(-1);for(let h of g.hunkContent){if(i.shouldBreak())break A;let M=h===y;if(h.type==="context"){if(i.shouldSkip(h.lines,h.lines))i.incrementCounts(h.lines,h.lines),C();else{let[F,H]=$n(i,h.lines,e);F>0&&i.incrementCounts(F,F);let x=F;for(;x<h.lines;){if(x>=H){i.incrementCounts(h.lines-x,h.lines-x);break}if(i.isInWindow(0,0)){let S=M&&x===h.lines-1,_=f+x,R=E+x;if(i.emit({hunkIndex:c,hunk:g,collapsedBefore:C(),collapsedAfter:l(_,R),type:"context",deletionLine:{lineNumber:I+x,lineIndex:m+x,noEOFCR:S&&g.noEOFCRDeletions,unifiedLineIndex:_,splitLineIndex:R},additionLine:{unifiedLineIndex:_,splitLineIndex:R,lineIndex:Q+x,lineNumber:w+x,noEOFCR:S&&g.noEOFCRAdditions}}))break A}else i.incrementCounts(1,1);x++}}f+=h.lines,E+=h.lines,m+=h.lines,Q+=h.lines,I+=h.lines,w+=h.lines}else{let F=Math.max(h.deletions,h.additions),H=h.deletions+h.additions;if(!i.shouldSkip(H,F)){let x=YI(i,h,e);for(let[S,_]of x)for(let R=S;R<_;R++){let L=l(f+R,e==="unified"?E+(R<h.deletions?R:R-h.deletions):E+R);if(i.emit(KI({hunkIndex:c,hunk:g,collapsedBefore:C(),collapsedAfter:L,diffStyle:e,index:R,unifiedLineIndex:f,splitLineIndex:E,additionLineIndex:Q,deletionLineIndex:m,additionLineNumber:w,deletionLineNumber:I,content:h,isLastContent:M,unifiedCount:H,splitCount:F}),!0))break A}}C(),i.incrementCounts(H,F),f+=H,E+=F,m+=h.deletions,Q+=h.additions,I+=h.deletions,w+=h.additions}}if(u!=null){let{collapsedLines:h,fromStart:M,fromEnd:F}=u,H=M+F,[x,S]=$n(i,H,e);x>0&&i.incrementCounts(x,x);let _=x;for(;_<H;){if(i.shouldBreak())break A;if(_>=S){i.incrementCounts(H-_,H-_);break}if(i.isInWindow(0,0)){let R=_===H-1;if(i.emit({hunkIndex:A.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:R?h:0,type:"context-expanded",deletionLine:{lineNumber:I+_,lineIndex:m+_,noEOFCR:!1,unifiedLineIndex:f+_,splitLineIndex:E+_},additionLine:{unifiedLineIndex:f+_,splitLineIndex:E+_,lineIndex:Q+_,lineNumber:w+_,noEOFCR:!1}}))break A}else i.incrementCounts(1,1);_++}}}}function SI({diff:A,diffStyle:e,startingLine:t,expandedHunks:n,collapsedContextThreshold:o}){if(t<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=UI({diff:A,expandedHunks:n,collapsedContextThreshold:o}),r=0,s=A.hunks.length-1,i=A.hunks.length;for(;r<=s;){let g=r+s>>1,d=a[g+1];if(d==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?d.unifiedCount:d.splitCount)>t?(i=g,s=g-1):r=g+1}if(i>=A.hunks.length){let g=a[A.hunks.length];if(g==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:A.hunks.length,splitCount:g.splitCount,unifiedCount:g.unifiedCount}}let c=a[i];if(c==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:c.splitCount,unifiedCount:c.unifiedCount}}function UI({diff:A,expandedHunks:e,collapsedContextThreshold:t}){let n=0,o=0,a=A.hunks.length-1,r=[{splitCount:0,unifiedCount:0}];for(let s=0;s<A.hunks.length;s++){let i=A.hunks[s];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");let c=Mt({isPartial:A.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:s,collapsedContextThreshold:t}),g=c.fromStart+c.fromEnd;if(n+=g+i.splitLineCount,o+=g+i.unifiedLineCount,s===a&&xp(A)){let d=PI(A,i),u=Mt({isPartial:A.isPartial,rangeSize:d,expandedHunks:e,hunkIndex:A.hunks.length,collapsedContextThreshold:t}),p=u.fromStart+u.fromEnd;n+=p,o+=p}r.push({splitCount:n,unifiedCount:o})}return r}function $n(A,e,t){if(!A.isWindowedHighlight||e<=0)return[0,e];let n=[];function o(s){let i=Math.max(0,A.viewportStart-s),c=Math.min(e,A.viewportEnd-s);c>i&&n.push([i,c])}if(t!=="split"&&o(A.unifiedCount),t!=="unified"&&o(A.splitCount),n.length===0)return[0,0];let a=n[0][0],r=n[0][1];for(let s=1;s<n.length;s++){let i=n[s];a=Math.min(a,i[0]),r=Math.max(r,i[1])}return[a,r]}function PI(A,e){let t=A.additionLines.length-(e.additionLineIndex+e.additionCount),n=A.deletionLines.length-(e.deletionLineIndex+e.deletionCount);if(t!==n)throw new Error(`iterateOverDiff: trailing context mismatch (additions=${t}, deletions=${n}) for ${A.name}`);return Math.min(t,n)}function xp(A){let e=A.hunks.at(-1);return e==null||A.isPartial||A.additionLines.length===0||A.deletionLines.length===0?!1:e.additionLineIndex+e.additionCount<A.additionLines.length||e.deletionLineIndex+e.deletionCount<A.deletionLines.length}function YI(A,e,t){if(!A.isWindowedHighlight)return[[0,t==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];let n=t!=="split",o=t!=="unified",a=t==="unified"?"unified":"split",r=[];function s(d,u){if(d+u<=A.viewportStart||d>=A.viewportEnd)return;let p=Math.max(0,A.viewportStart-d),l=Math.min(u,A.viewportEnd-d);return l>p?[p,l]:void 0}function i(d,u){return a==="split"?d:u==="additions"?[d[0]+e.deletions,d[1]+e.deletions]:d}function c(d,u){if(d==null)return;let[p,l]=i(d,u);l>p&&r.push([p,l])}if(n&&(c(s(A.unifiedCount,e.deletions),"deletions"),c(s(A.unifiedCount+e.deletions,e.additions),"additions")),o&&(c(s(A.splitCount,e.deletions),"deletions"),c(s(A.splitCount,e.additions),"additions")),r.length===0)return r;r.sort((d,u)=>d[0]-u[0]);let g=[r[0]];for(let[d,u]of r.slice(1)){let p=g[g.length-1];d<=p[1]?p[1]=Math.max(p[1],u):g.push([d,u])}return g}function KI({hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,diffStyle:o,index:a,unifiedLineIndex:r,splitLineIndex:s,additionLineIndex:i,deletionLineIndex:c,additionLineNumber:g,deletionLineNumber:d,content:u,isLastContent:p,unifiedCount:l,splitCount:C}){let f=a<u.deletions?r+a:void 0,E=o==="unified"?a>=u.deletions?r+a:void 0:a<u.additions?r+u.deletions+a:void 0,m=o==="unified"?s+(a<u.deletions?a:a-u.deletions):s+a,Q=a<u.deletions?c+a:void 0,I=a<u.deletions?d+a:void 0,w=o==="unified"?a>=u.deletions?i+(a-u.deletions):void 0:a<u.additions?i+a:void 0,y=o==="unified"?a>=u.deletions?g+(a-u.deletions):void 0:a<u.additions?g+a:void 0,h=o==="unified"?p&&a===u.deletions-1&&e.noEOFCRDeletions:p&&a===C-1&&e.noEOFCRDeletions,M=o==="unified"?p&&a===l-1&&e.noEOFCRAdditions:p&&a===C-1&&e.noEOFCRAdditions,F=Q!=null&&I!=null&&f!=null?{lineNumber:I,lineIndex:Q,noEOFCR:h,unifiedLineIndex:f,splitLineIndex:m}:void 0,H=w!=null&&y!=null&&E!=null?{unifiedLineIndex:E,splitLineIndex:m,lineIndex:w,lineNumber:y,noEOFCR:M}:void 0;if(F==null&&H!=null)return{type:"change",hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,deletionLine:void 0,additionLine:H};if(F!=null&&H==null)return{type:"change",hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,deletionLine:F,additionLine:void 0};if(F==null||H==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,deletionLine:F,additionLine:H}}var jI={forcePlainText:!1};function vp(A,e,t,{forcePlainText:n,startingLine:o,totalLines:a,expandedHunks:r,collapsedContextThreshold:s=Ie}=jI){n?(o??(o=0),a??(a=1/0)):(o=0,a=1/0);let i=o>0||a<1/0,c=typeof t.theme=="string"?e.getTheme(t.theme).type:void 0,g=Xu({theme:t.theme,highlighter:e}),d=n&&!i&&(A.unifiedLineCount>1e3||A.splitLineCount>1e3)?"none":t.lineDiffType,u={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=t,l=!n&&!A.isPartial,C=n?r:void 0,f=new Map;function E(Q){let I=l?0:Q,w=f.get(I)??qI();return f.set(I,w),w}function m(Q,I,w,y){if(i){let h=w.at(-1);(h==null||h.targetIndex+h.count!==I)&&(h={targetIndex:I,originalOffset:y.length,count:0},w.push(h)),h.count++}y.push(Q)}Zn({diff:A,diffStyle:"both",startingLine:o,totalLines:a,expandedHunks:i?C:!0,collapsedContextThreshold:s,callback:({hunkIndex:Q,additionLine:I,deletionLine:w,type:y})=>{let h=E(Q),M=I!=null?I.splitLineIndex:w.splitLineIndex;y==="change"&&I!=null&&w!=null&&JI({additionLine:A.additionLines[I.lineIndex],deletionLine:A.deletionLines[w.lineIndex],deletionLineIndex:h.deletionContent.length,additionLineIndex:h.additionContent.length,deletionDecorations:h.deletionDecorations,additionDecorations:h.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),w!=null&&(m(A.deletionLines[w.lineIndex],w.lineIndex,h.deletionSegments,h.deletionContent),h.deletionInfo.push({type:y==="change"?"change-deletion":y,lineNumber:w.lineNumber,altLineNumber:y==="change"?void 0:I.lineNumber??void 0,lineIndex:`${w.unifiedLineIndex},${M}`})),I!=null&&(m(A.additionLines[I.lineIndex],I.lineIndex,h.additionSegments,h.additionContent),h.additionInfo.push({type:y==="change"?"change-addition":y,lineNumber:I.lineNumber,altLineNumber:y==="change"?void 0:w.lineNumber??void 0,lineIndex:`${I.unifiedLineIndex},${M}`}))}});for(let Q of f.values()){if(Q.deletionContent.length===0&&Q.additionContent.length===0)continue;let I={name:A.prevName??A.name,contents:Q.deletionContent.value},w={name:A.name,contents:Q.additionContent.value},{deletionLines:y,additionLines:h}=OI({deletionFile:I,deletionInfo:Q.deletionInfo,deletionDecorations:Q.deletionDecorations,additionFile:w,additionInfo:Q.additionInfo,additionDecorations:Q.additionDecorations,highlighter:e,options:t,languageOverride:n?"text":A.lang});if(l){u.deletionLines=y,u.additionLines=h;continue}if(Q.deletionSegments.length>0)for(let M of Q.deletionSegments)for(let F=0;F<M.count;F++)u.deletionLines[M.targetIndex+F]=y[M.originalOffset+F];else u.deletionLines.push(...y);if(Q.additionSegments.length>0)for(let M of Q.additionSegments)for(let F=0;F<M.count;F++)u.additionLines[M.targetIndex+F]=h[M.originalOffset+F];else u.additionLines.push(...h)}return{code:u,themeStyles:g,baseThemeType:c}}function JI({deletionLine:A,additionLine:e,deletionLineIndex:t,additionLineIndex:n,deletionDecorations:o,additionDecorations:a,lineDiffType:r,maxLineDiffLength:s}){if(A==null||e==null||r==="none"||(A=ee(A),e=ee(e),A.length>s||e.length>s))return;let i=r==="char"?$a(A,e):er(A,e),c=[],g=[],d=r==="word-alt",u=i.at(-1);for(let l of i){let C=l===u;!l.added&&!l.removed?(vt({item:l,arr:c,enableJoin:d,isNeutral:!0,isLastItem:C}),vt({item:l,arr:g,enableJoin:d,isNeutral:!0,isLastItem:C})):l.removed?vt({item:l,arr:c,enableJoin:d,isLastItem:C}):vt({item:l,arr:g,enableJoin:d,isLastItem:C})}let p=0;for(let l of c)l[0]===1&&o.push(sr({line:t,spanStart:p,spanLength:l[1].length})),p+=l[1].length;p=0;for(let l of g)l[0]===1&&a.push(sr({line:n,spanStart:p,spanLength:l[1].length})),p+=l[1].length}function qI(){return{deletionContent:{push(A){this.value+=A,this.length++},value:"",length:0},additionContent:{push(A){this.value+=A,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function OI({deletionFile:A,additionFile:e,deletionInfo:t,additionInfo:n,highlighter:o,deletionDecorations:a,additionDecorations:r,languageOverride:s,options:{theme:i=oA,...c}}){let g=s??FA(A.name),d=s??FA(e.name),{state:u,transformers:p}=zu(c.useTokenTransformer),l=typeof i=="string"?{...c,lang:"text",theme:i,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:dA("token")}:{...c,lang:"text",themes:i,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:dA("token")};return{deletionLines:A.contents===""?[]:(l.lang=g,u.lineInfo=t,l.decorations=a,Ka(o.codeToHast(ee(A.contents),l))),additionLines:e.contents===""?[]:(l.lang=d,l.decorations=r,u.lineInfo=n,Ka(o.codeToHast(ee(e.contents),l)))}}function Gt(A){let e=A.lang??FA(A.name),t=A.lang??(A.prevName!=null?FA(A.prevName):"text");return e==="text"&&t==="text"}var TI=-1,Hp=class{constructor(A={theme:oA},e,t){B(this,"__id",`diff-hunks-renderer:${++TI}`);B(this,"highlighter");B(this,"diff");B(this,"expandedHunks",new Map);B(this,"deletionAnnotations",{});B(this,"additionAnnotations",{});B(this,"computedLang","text");B(this,"renderCache");this.options=A,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=Sn(A.theme??oA)?Ha():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}clearRenderCache(){this.renderCache=void 0}setOptions(A){this.options=A}mergeOptions(A){this.options={...this.options,...A}}expandHunk(A,e,t=this.getOptionsWithDefaults().expansionLineCount){let n={...this.expandedHunks.get(A)??{fromStart:0,fromEnd:0}};(e==="up"||e==="both")&&(n.fromStart+=t),(e==="down"||e==="both")&&(n.fromEnd+=t),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(A,n)}getExpandedHunk(A){return this.expandedHunks.get(A)??kr}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(A){this.additionAnnotations={},this.deletionAnnotations={};for(let e of A){let t=(()=>{switch(e.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),n=t[e.lineNumber]??[];t[e.lineNumber]=n,n.push(e)}}getUnifiedLineDecoration({lineType:A}){return{gutterLineType:A}}getSplitLineDecoration({side:A,type:e}){return e!=="change"?{gutterLineType:e}:{gutterLineType:A==="deletions"?"change-deletion":"change-addition"}}createAnnotationElement(A){return ju(A)}getOptionsWithDefaults(){let{diffIndicators:A="bars",diffStyle:e="split",disableBackground:t=!1,disableFileHeader:n=!1,disableLineNumbers:o=!1,disableVirtualizationBuffers:a=!1,collapsed:r=!1,expandUnchanged:s=!1,collapsedContextThreshold:i=Ie,expansionLineCount:c=100,hunkSeparators:g="line-info",lineDiffType:d="word-alt",maxLineDiffLength:u=1e3,overflow:p="scroll",stickyHeader:l=!1,theme:C=oA,headerRenderMode:f="default",tokenizeMaxLineLength:E=1e3,tokenizeMaxLength:m=je,useTokenTransformer:Q=!1,useCSSClasses:I=!1}=this.options;return{diffIndicators:A,diffStyle:e,disableBackground:t,disableFileHeader:n,disableLineNumbers:o,disableVirtualizationBuffers:a,collapsed:r,expandUnchanged:s,collapsedContextThreshold:i,expansionLineCount:c,hunkSeparators:g,lineDiffType:d,maxLineDiffLength:u,overflow:p,stickyHeader:l,theme:this.workerManager?.getDiffRenderOptions().theme??C,headerRenderMode:f,tokenizeMaxLineLength:E,tokenizeMaxLength:m,useTokenTransformer:Q,useCSSClasses:I}}async initializeHighlighter(){return this.highlighter=await Hn(Tu(this.computedLang,this.options)),this.highlighter}hydrate(A){if(A==null)return;this.diff=A;let{options:e}=this.getRenderOptions(A),t=gr(A,this.getTokenizeMaxLength()),n=this.workerManager?.getDiffResultCache(A);n!=null&&!Re(e,n.options)&&(n=void 0),this.renderCache??(this.renderCache={diff:A,highlighted:!t&&!Gt(A),options:e,result:t?void 0:n?.result,renderRange:void 0}),this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter==null&&(this.computedLang=A.lang??FA(A.name),this.initializeHighlighter())}getRenderOptions(A){let e=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:n,tokenizeMaxLineLength:o,lineDiffType:a,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:n,useTokenTransformer:Ap(this.options),tokenizeMaxLineLength:o,lineDiffType:a,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!yt(A,t.diff)||!Re(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}renderDiff(A=this.renderCache?.diff,e=io){if(A==null)return;let{expandUnchanged:t=!1,collapsedContextThreshold:n}=this.getOptionsWithDefaults(),{options:o,forceHighlight:a}=this.getRenderOptions(A),r=this.getMatchingWorkerResultCache(A,o);r!=null&&!this.hasHighlightedRenderCache(A,o)&&(this.renderCache={diff:A,highlighted:!0,renderRange:void 0,...r},a=!1),this.renderCache??(this.renderCache={diff:A,highlighted:!1,options:o,result:void 0,renderRange:void 0});let s=A.additionLines.length>0||A.deletionLines.length>0,i=!s||Gt(A)||gr(A,this.getTokenizeMaxLength()),c=!yt(A,this.renderCache.diff),g=!Un(this.renderCache.renderRange,e);if(this.workerManager?.isWorkingPool()===!0)(i||this.renderCache.result==null||!this.renderCache.highlighted&&(c||g))&&(this.renderCache.diff=A,this.renderCache.options=o,this.renderCache.highlighted=!1,(this.renderCache.result==null||c||g||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(A,e.startingLine,e.totalLines,_p(e)||t?!0:this.expandedHunks,n)),this.renderCache.renderRange=e),!i&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,A);else{this.computedLang=A.lang??FA(A.name);let d=this.highlighter!=null&&Sn(o.theme),u=this.highlighter!=null&&wo(this.computedLang),p=!i&&u;if(this.highlighter!=null&&d&&(a||i||!this.renderCache.highlighted&&p||this.renderCache.result==null)){let{result:l,options:C}=this.renderDiffWithHighlighter(A,this.highlighter,i||!u);this.renderCache={diff:A,options:C,highlighted:p,result:l,renderRange:void 0}}(!d||!i&&!u)&&this.asyncHighlight(A).then(({result:l,options:C})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(A,l,C,!i)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,e,this.renderCache.result):void 0}async asyncRender(A,e=io){let{result:t}=await this.asyncHighlight(A);return this.processDiffResult(A,e,t)}createPreElement(A,e,t){let{diffIndicators:n,disableBackground:o,disableLineNumbers:a,overflow:r}=this.getOptionsWithDefaults();return Ou({type:"diff",diffIndicators:n,disableBackground:o,disableLineNumbers:a,overflow:r,split:A,totalLines:e,customProperties:t})}async asyncHighlight(A){let e=gr(A,this.getTokenizeMaxLength());this.computedLang=e?"text":A.lang??FA(A.name);let t=this.highlighter!=null&&Sn(this.options.theme??oA),n=e||this.highlighter!=null&&wo(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(A,this.highlighter,e)}renderDiffWithHighlighter(A,e,t=!1){let{options:n}=this.getRenderOptions(A),{collapsedContextThreshold:o}=this.getOptionsWithDefaults();return{result:vp(A,e,n,{forcePlainText:t,expandedHunks:t?!0:void 0,collapsedContextThreshold:o}),options:n}}onHighlightSuccess(A,e,t,n=!0){if(this.renderCache==null)return;let o=!this.renderCache.highlighted||!Re(this.renderCache.options,t)||!yt(this.renderCache.diff,A);this.renderCache={diff:A,options:t,highlighted:n,result:e,renderRange:void 0},o&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(A,e){let t=this.workerManager?.getDiffResultCache(A);if(!(t==null||!Re(e,t.options)))return t}hasHighlightedRenderCache(A,e){let{renderCache:t}=this;return t?.result!=null&&t.highlighted&&yt(A,t.diff)&&Re(e,t.options)}onHighlightError(A){console.error(A)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??je}processDiffResult(A,e,{code:t,themeStyles:n,baseThemeType:o}){let{diffStyle:a,disableFileHeader:r,expandUnchanged:s,expansionLineCount:i,collapsedContextThreshold:c,hunkSeparators:g}=this.getOptionsWithDefaults();this.diff=A;let d=a==="unified",u=[],p=[],l=[],C=[],{additionLines:f,deletionLines:E}=t,m={rowCount:0,hunkSeparators:g,additionsContentAST:u,deletionsContentAST:p,unifiedContentAST:l,unifiedGutterAST:Je(),deletionsGutterAST:Je(),additionsGutterAST:Je(),expansionLineCount:i,hunkData:C,incrementRowCount(_=1){m.rowCount+=_},pushToGutter(_,R){switch(_){case"unified":m.unifiedGutterAST.children.push(R);break;case"deletions":m.deletionsGutterAST.children.push(R);break;case"additions":m.additionsGutterAST.children.push(R);break}}},Q=WI(A),I={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!=="unified"){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side==="additions"?(m.pushToGutter("additions",uA(void 0,"buffer",this.size)),u?.push(_t(this.size))):(m.pushToGutter("deletions",uA(void 0,"buffer",this.size)),p?.push(_t(this.size))),this.size=0,this.side=void 0}}},w=(_,R,L,cA,K)=>{m.pushToGutter(_,_r(R,L,cA,K))};function y(_){I.flush(),a==="unified"?cr("unified",_,m):(cr("deletions",_,m),cr("additions",_,m))}Zn({diff:A,diffStyle:a,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:c,callback:({hunkIndex:_,hunk:R,collapsedBefore:L,collapsedAfter:cA,additionLine:K,deletionLine:V,type:AA})=>{let fe=V!=null?V.splitLineIndex:K.splitLineIndex,eo=K!=null?K.unifiedLineIndex:V.unifiedLineIndex;a==="split"&&AA!=="change"&&I.flush(),L>0&&y({hunkIndex:_,collapsedLines:L,rangeSize:Math.max(R?.collapsedBefore??0,0),hunkSpecs:R?.hunkSpecs,isFirstHunk:_===0,isLastHunk:!1,isExpandable:!A.isPartial});let to=a==="unified"?eo:fe,lr={type:AA,hunkIndex:_,lineIndex:to,unifiedLineIndex:eo,splitLineIndex:fe,deletionLine:V,additionLine:K};if(a==="unified"){let T=this.getUnifiedInjectedRowsForLine?.(lr);T?.before!=null&&Gp(T.before,m);let QA=V!=null?E[V.lineIndex]:void 0,CA=K!=null?f[K.lineIndex]:void 0;if(QA==null&&CA==null){let qA="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(qA,{file:A.name}),new Error(qA)}let Ue=AA==="change"?K!=null?"change-addition":"change-deletion":AA,JA=this.getUnifiedLineDecoration({type:AA,lineType:Ue,additionLineIndex:K?.lineIndex,deletionLineIndex:V?.lineIndex});w("unified",JA.gutterLineType,K!=null?K.lineNumber:V.lineNumber,`${eo},${fe}`,JA.gutterProperties),CA!=null?CA=zn(CA,JA.contentProperties):QA!=null&&(QA=zn(QA,JA.contentProperties)),Lp({diffStyle:"unified",type:AA,deletionLine:QA,additionLine:CA,unifiedSpan:this.getAnnotations("unified",V?.lineNumber,K?.lineNumber,_,to),createAnnotationElement:qA=>this.createAnnotationElement(qA),context:m}),T?.after!=null&&Gp(T.after,m)}else{let T=this.getSplitInjectedRowsForLine?.(lr);T?.before!=null&&Np(T.before,m,I);let QA=V!=null?E[V.lineIndex]:void 0,CA=K!=null?f[K.lineIndex]:void 0,Ue=this.getSplitLineDecoration({side:"deletions",type:AA,lineIndex:V?.lineIndex}),JA=this.getSplitLineDecoration({side:"additions",type:AA,lineIndex:K?.lineIndex});if(QA==null&&CA==null){let wA="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(wA,{file:A.name}),new Error(wA)}let qA=(()=>{if(AA==="change"){if(CA==null)return"additions";if(QA==null)return"deletions"}})();if(qA!=null){if(I.side!=null&&I.side!==qA)throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");I.side=qA,I.increment()}let mr=this.getAnnotations("split",V?.lineNumber,K?.lineNumber,_,to);if(mr!=null&&I.size>0&&I.flush(),V!=null){let wA=zn(QA,Ue.contentProperties);w("deletions",Ue.gutterLineType,V.lineNumber,`${V.unifiedLineIndex},${fe}`,Ue.gutterProperties),wA!=null&&(QA=wA)}if(K!=null){let wA=zn(CA,JA.contentProperties);w("additions",JA.gutterLineType,K.lineNumber,`${K.unifiedLineIndex},${fe}`,JA.gutterProperties),wA!=null&&(CA=wA)}Lp({diffStyle:"split",type:AA,additionLine:CA,deletionLine:QA,...mr,createAnnotationElement:wA=>this.createAnnotationElement(wA),context:m}),T?.after!=null&&Np(T.after,m,I)}let Br=a==="split"&&R!=null&&fe===R.splitLineStart+R.splitLineCount-1,Xp=Br?R.noEOFCRDeletions:!1,Vp=Br?R.noEOFCRAdditions:!1,no=(V?.noEOFCR??!1)||Xp,oo=(K?.noEOFCR??!1)||Vp;if(oo||no){if(a==="split"&&I.flush(),no){let T=AA==="context"||AA==="context-expanded"?AA:"change-deletion";a==="unified"?(m.unifiedContentAST.push(xt(T)),m.pushToGutter("unified",uA(T,"metadata",1))):(m.deletionsContentAST.push(xt(T)),m.pushToGutter("deletions",uA(T,"metadata",1)),oo||(m.pushToGutter("additions",uA(void 0,"buffer",1)),m.additionsContentAST.push(_t(1))))}if(oo){let T=AA==="context"||AA==="context-expanded"?AA:"change-addition";a==="unified"?(m.unifiedContentAST.push(xt(T)),m.pushToGutter("unified",uA(T,"metadata",1))):(m.additionsContentAST.push(xt(T)),m.pushToGutter("additions",uA(T,"metadata",1)),no||(m.pushToGutter("deletions",uA(void 0,"buffer",1)),m.deletionsContentAST.push(_t(1))))}m.incrementRowCount(1)}cA>0&&g!=="simple"&&y({hunkIndex:AA==="context-expanded"?_:_+1,collapsedLines:cA,rangeSize:Q,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!A.isPartial}),m.incrementRowCount(1)}}),a==="split"&&I.flush();let h=Math.max(Fp(A.hunks),A.additionLines.length??0,A.deletionLines.length??0),M=e.bufferBefore>0||e.bufferAfter>0,F=!d&&A.type!=="deleted",H=!d&&A.type!=="new",x=m.rowCount>0||M;u=F&&x?u:void 0,p=H&&x?p:void 0,l=d&&x?l:void 0;let S=this.createPreElement(p!=null&&u!=null,h);return{unifiedGutterAST:d&&x?m.unifiedGutterAST.children:void 0,unifiedContentAST:l,deletionsGutterAST:H&&x?m.deletionsGutterAST.children:void 0,deletionsContentAST:p,additionsGutterAST:F&&x?m.additionsGutterAST.children:void 0,additionsContentAST:u,hunkData:C,preNode:S,themeStyles:n,baseThemeType:o,headerElement:r?void 0:this.renderHeader(this.diff),totalLines:h,rowCount:m.rowCount,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderCodeAST(A,e){let t=A==="unified"?e.unifiedGutterAST:A==="deletions"?e.deletionsGutterAST:e.additionsGutterAST,n=A==="unified"?e.unifiedContentAST:A==="deletions"?e.deletionsContentAST:e.additionsContentAST;if(t==null||n==null)return;let o=Je(t);return o.properties.style=`grid-row: span ${e.rowCount}`,[o,Vu(n,e.rowCount)]}renderFullAST(A,e=[]){let t=this.getOptionsWithDefaults().hunkSeparators==="line-info",n=this.renderCodeAST("unified",A);if(n!=null)return e.push(v({tagName:"code",children:n,properties:{"data-code":"","data-container-size":t?"":void 0,"data-unified":""}})),{...A.preNode,children:e};let o=this.renderCodeAST("deletions",A);o!=null&&e.push(v({tagName:"code",children:o,properties:{"data-code":"","data-container-size":t?"":void 0,"data-deletions":""}}));let a=this.renderCodeAST("additions",A);return a!=null&&e.push(v({tagName:"code",children:a,properties:{"data-code":"","data-container-size":t?"":void 0,"data-additions":""}})),{...A.preNode,children:e}}renderFullHTML(A,e=[]){return fA(this.renderFullAST(A,e))}renderPartialHTML(A,e){return e==null?fA(A):fA(v({tagName:"code",children:A,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${e}`]:""}}))}getAnnotations(A,e,t,n,o){let a={type:"annotation",hunkIndex:n,lineIndex:o,annotations:[]};if(e!=null)for(let s of this.deletionAnnotations[e]??[])a.annotations.push(Ge(s));let r={type:"annotation",hunkIndex:n,lineIndex:o,annotations:[]};if(t!=null)for(let s of this.additionAnnotations[t]??[])(A==="unified"?a:r).annotations.push(Ge(s));if(A==="unified")return a.annotations.length>0?a:void 0;if(!(r.annotations.length===0&&a.annotations.length===0))return{deletionSpan:a,additionSpan:r}}renderHeader(A){let{headerRenderMode:e,stickyHeader:t}=this.getOptionsWithDefaults();return qu({fileOrDiff:A,mode:e,stickyHeader:t})}};function Mp(A){return`${A} unmodified line${A>1?"s":""}`}function Gp(A,e){for(let t of A)e.unifiedContentAST.push(t.content),e.pushToGutter("unified",t.gutter),e.incrementRowCount(1)}function Np(A,e,t){for(let{deletion:n,addition:o}of A){if(n==null&&o==null)continue;let a=n!=null&&o!=null?void 0:n==null?"deletions":"additions";(a==null||t.side!==a)&&t.flush(),n!=null&&(e.deletionsContentAST.push(n.content),e.pushToGutter("deletions",n.gutter)),o!=null&&(e.additionsContentAST.push(o.content),e.pushToGutter("additions",o.gutter)),a!=null&&(t.side=a,t.increment()),e.incrementRowCount(1)}}function Lp({diffStyle:A,type:e,deletionLine:t,additionLine:n,unifiedSpan:o,deletionSpan:a,additionSpan:r,createAnnotationElement:s,context:i}){let c=!1;if(A==="unified"){if(n!=null?i.unifiedContentAST.push(n):t!=null&&i.unifiedContentAST.push(t),o!=null){let g=e==="change"?t!=null?"change-deletion":"change-addition":e;i.unifiedContentAST.push(s(o)),i.pushToGutter("unified",uA(g,"annotation",1)),c=!0}}else if(A==="split"){if(t!=null&&i.deletionsContentAST.push(t),n!=null&&i.additionsContentAST.push(n),a!=null){let g=e==="change"?t!=null?"change-deletion":"context":e;i.deletionsContentAST.push(s(a)),i.pushToGutter("deletions",uA(g,"annotation",1)),c=!0}if(r!=null){let g=e==="change"?n!=null?"change-addition":"context":e;i.additionsContentAST.push(s(r)),i.pushToGutter("additions",uA(g,"annotation",1)),c=!0}}c&&i.incrementRowCount(1)}function cr(A,{hunkIndex:e,collapsedLines:t,rangeSize:n,hunkSpecs:o,isFirstHunk:a,isLastHunk:r,isExpandable:s},i){if(t<=0)return;let c=A==="unified"?i.unifiedContentAST:A==="deletions"?i.deletionsContentAST:i.additionsContentAST;if(i.hunkSeparators==="metadata"){o!=null&&(i.pushToGutter(A,Ee({type:"metadata",content:o,isFirstHunk:a,isLastHunk:r})),c.push(Ee({type:"metadata",content:o,isFirstHunk:a,isLastHunk:r})),A!=="additions"&&i.incrementRowCount(1));return}if(i.hunkSeparators==="simple"){e>0&&(i.pushToGutter(A,Ee({type:"simple",isFirstHunk:a,isLastHunk:!1})),c.push(Ee({type:"simple",isFirstHunk:a,isLastHunk:!1})),A!=="additions"&&i.incrementRowCount(1));return}let g=yp(A,e),d=n>i.expansionLineCount,u=s?e:void 0;i.pushToGutter(A,Ee({type:i.hunkSeparators,content:Mp(t),expandIndex:u,chunked:d,slotName:g,isFirstHunk:a,isLastHunk:r})),c.push(Ee({type:i.hunkSeparators,content:Mp(t),expandIndex:u,chunked:d,slotName:g,isFirstHunk:a,isLastHunk:r})),A!=="additions"&&i.incrementRowCount(1),i.hunkData.push({slotName:g,hunkIndex:e,lines:t,type:A,expandable:s?{up:!a,down:!r,chunked:d}:void 0})}function zn(A,e){return A==null||A.type!=="element"||e==null?A:{...A,properties:{...A.properties,...e}}}function gr(A,e){return Math.max(A.additionLines.length,A.deletionLines.length)>e}function WI(A){let e=A.hunks.at(-1);if(e==null||A.isPartial||A.additionLines.length===0||A.deletionLines.length===0)return 0;let t=A.additionLines.length-(e.additionLineIndex+e.additionCount),n=A.deletionLines.length-(e.deletionLineIndex+e.deletionCount);if(t!==n)throw new Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${t}, deletions=${n}) for ${A.name}`);return Math.min(t,n)}function Rp(A,e){return A.lineNumber===e.lineNumber&&A.side===e.side&&A.metadata===e.metadata}function Sp(A,e){return A.slotName===e.slotName&&A.hunkIndex===e.hunkIndex&&A.lines===e.lines&&A.type===e.type&&A.expandable?.chunked===e.expandable?.chunked&&A.expandable?.up===e.expandable?.up&&A.expandable?.down===e.expandable?.down}function Up(A){return{theme:A?.theme,disableLineNumbers:A?.disableLineNumbers,overflow:A?.overflow,collapsed:A?.collapsed,disableFileHeader:A?.disableFileHeader,disableVirtualizationBuffers:A?.disableVirtualizationBuffers,stickyHeader:A?.stickyHeader,preferredHighlighter:A?.preferredHighlighter,useCSSClasses:A?.useCSSClasses,useTokenTransformer:A?.useTokenTransformer,tokenizeMaxLineLength:A?.tokenizeMaxLineLength,tokenizeMaxLength:A?.tokenizeMaxLength,diffStyle:A?.diffStyle,diffIndicators:A?.diffIndicators,disableBackground:A?.disableBackground,hunkSeparators:typeof A?.hunkSeparators=="function"?"custom":A?.hunkSeparators,expandUnchanged:A?.expandUnchanged,collapsedContextThreshold:A?.collapsedContextThreshold,lineDiffType:A?.lineDiffType,maxLineDiffLength:A?.maxLineDiffLength,expansionLineCount:A?.expansionLineCount,headerRenderMode:A?.renderCustomHeader!=null?"custom":"default"}}var $I=-1,dr,ur=(dr=class{constructor(A={theme:oA},e,t=!1){B(this,"__id",`file-diff:${++$I}`);B(this,"fileContainer");B(this,"spriteSVG");B(this,"pre");B(this,"codeUnified");B(this,"codeDeletions");B(this,"codeAdditions");B(this,"bufferBefore");B(this,"bufferAfter");B(this,"themeCSSStyle");B(this,"appliedThemeCSS");B(this,"hasAdoptedThemeCSS",!1);B(this,"unsafeCSSStyle");B(this,"appliedUnsafeCSS");B(this,"gutterUtilityContent");B(this,"headerElement");B(this,"headerPrefix");B(this,"headerMetadata");B(this,"headerCustom");B(this,"separatorCache",new Map);B(this,"errorWrapper");B(this,"placeHolder");B(this,"hunksRenderer");B(this,"resizeManager");B(this,"scrollSyncManager");B(this,"interactionManager");B(this,"annotationCache",new Map);B(this,"lineAnnotations",[]);B(this,"managersDirty",!1);B(this,"deletionFile");B(this,"additionFile");B(this,"fileDiff");B(this,"renderRange");B(this,"appliedPreAttributes");B(this,"lastRenderedHeaderHTML");B(this,"cachedHeaderHTML");B(this,"lastRowCount");B(this,"enabled",!0);B(this,"handleHighlightRender",()=>{this.rerender()});B(this,"getLineIndex",(A,e="additions")=>{if(this.fileDiff==null)return;let t=this.fileDiff.hunks.at(-1),n,o;A:for(let a of this.fileDiff.hunks){let r=e==="deletions"?a.deletionStart:a.additionStart,s=e==="deletions"?a.deletionCount:a.additionCount,i=a.splitLineStart,c=a.unifiedLineStart;if(A<r){let g=r-A;n=Math.max(c-g,0),o=Math.max(i-g,0);break A}if(A>=r+s){if(a===t){let g=A-(r+s);n=c+a.unifiedLineCount+g,o=i+a.splitLineCount+g;break A}continue}for(let g of a.hunkContent)if(g.type==="context")if(A<r+g.lines){let d=A-r;o=i+d,n=c+d;break A}else r+=g.lines,i+=g.lines,c+=g.lines;else{let d=e==="deletions"?g.deletions:g.additions;if(A<r+d){let u=A-r;n=c+(e==="additions"?g.deletions:0)+u,o=i+u;break A}else r+=d,i+=Math.max(g.deletions,g.additions),c+=g.deletions+g.additions}break A}if(!(n==null||o==null))return[n,o]});B(this,"getHoveredLine",()=>this.interactionManager.getHoveredLine());B(this,"handleExpandHunk",(A,e,t)=>{this.expandHunk(A,e,t)});B(this,"expandHunk",(A,e,t)=>{this.hunksRenderer.expandHunk(A,e,t),this.rerender()});this.options=A,this.workerManager=e,this.isContainerManaged=t,this.hunksRenderer=this.createHunksRenderer(A),this.resizeManager=new pi,this.scrollSyncManager=new kp,this.interactionManager=new ui("diff",bo(A,typeof A.hunkSeparators=="function"||(A.hunkSeparators??"line-info")==="line-info"||A.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}getHunksRendererOptions(A){return Up(A)}createHunksRenderer(A){return new Hp(this.getHunksRendererOptions(A),this.handleHighlightRender,this.workerManager)}setOptions(A){A!=null&&(this.options=A,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(A)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(bo(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(A){this.options={...this.options,...A}}setThemeType(A){(this.options.themeType??"system")!==A&&(this.mergeOptions({themeType:A}),this.applyCachedThemeState(A))}applyCachedThemeState(A){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let e=this.appliedThemeCSS.baseThemeType??A;return this.appliedThemeCSS.themeType===e?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,A,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!St(this.appliedThemeCSS.theme,this.options.theme??oA)}setLineAnnotations(A){this.lineAnnotations=A}canPartiallyRender(A,e,t){return!(A||e||t||typeof this.options.hunkSeparators=="function")}setSelectedLines(A,e){this.interactionManager.setSelection(A,e)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:A="split",overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e==="wrap"),e==="scroll"&&A==="split"?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}cleanUp(A=!1){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.lineAnnotations=[],this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,A||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,A?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(A){let{fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:o,oldFile:a,newFile:r,fileDiff:s}=A;this.hydrateElements(e,t),XI(this.pre,ZI({fileDiff:s,oldFile:a,newFile:r}),this.options.collapsed)||VI(this.headerElement,zI({fileDiff:s,oldFile:a,newFile:r}),this.options.disableFileHeader)?this.render({...A,preventEmit:!0}):this.hydrationSetup({fileDiff:s,oldFile:a,newFile:r,lineAnnotations:o}),n||this.emitPostRender()}hydrateElements(A,e){up(A,e);for(let t of A.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let n of t.children)!(n instanceof HTMLElement)||n.tagName.toLowerCase()!=="code"||("deletions"in n.dataset&&(this.codeDeletions=n),"additions"in n.dataset&&(this.codeAdditions=n),"unified"in n.dataset&&(this.codeUnified=n));continue}if("diffsHeader"in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(Ye)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(Ke)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=A,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:A,oldFile:e,newFile:t,lineAnnotations:n}){this.lineAnnotations=n??this.lineAnnotations,this.additionFile=t,this.deletionFile=e,this.fileDiff=A??(e!=null&&t!=null?rr(e,t,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}render({oldFile:A,newFile:e,fileDiff:t,deferManagers:n=!1,forceRender:o=!1,preventEmit:a=!1,lineAnnotations:r,fileContainer:s,containerWrapper:i,renderRange:c}){if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");let{collapsed:g=!1,themeType:d="system"}=this.options,u=g?void 0:c,p=this.hasThemeChanged(),l=A!=null&&e!=null&&(!Sa(A,this.deletionFile)||!Sa(e,this.additionFile)),C=t!=null&&t!==this.fileDiff,f=r!=null&&(r.length>0||this.lineAnnotations.length>0)?r!==this.lineAnnotations:!1;if(!g&&Un(u,this.renderRange)&&!o&&!f&&!p&&(t!=null&&t===this.fileDiff||t==null&&!l))return this.applyCachedThemeState(d);let{renderRange:E}=this;if(this.renderRange=u,this.deletionFile=A,this.additionFile=e,t!=null?this.fileDiff=t:A!=null&&e!=null&&l&&(C=!0,this.fileDiff=rr(A,e,this.options.parseDiffOptions)),C&&(this.cachedHeaderHTML=void 0),r!=null&&this.setLineAnnotations(r),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:m=!1,disableFileHeader:Q=!1}=this.options;if(Q&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),s=this.getOrCreateFileContainer(s,i),this.applyCachedThemeState(d),g){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let I=this.hunksRenderer.renderDiff(this.fileDiff,yr);I!=null&&this.applyThemeState(s,I.themeStyles,d,I.baseThemeType),I?.headerElement!=null&&this.applyHeaderToDOM(I.headerElement,s),this.renderSeparators([]),this.injectUnsafeCSS()}catch(I){if(m)throw I;console.error(I),I instanceof Error&&this.applyErrorToDOM(I,s)}return a||this.emitPostRender(),!0}try{let I=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(o,f,l||C||p)&&this.applyPartialRender({previousRenderRange:E,renderRange:u}))){let w=this.hunksRenderer.renderDiff(this.fileDiff,u);if(w==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(s,w.themeStyles,d,w.baseThemeType),w.headerElement!=null&&this.applyHeaderToDOM(w.headerElement,s),w.additionsContentAST!=null||w.deletionsContentAST!=null||w.unifiedContentAST!=null?this.applyHunksToDOM(I,w):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(w.hunkData)}this.applyBuffers(I,u),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,n||this.flushManagers()}catch(I){if(m)throw I;console.error(I),I instanceof Error&&this.applyErrorToDOM(I,s)}return a||this.emitPostRender(),!0}emitPostRender(){this.fileContainer!=null&&this.options.onPostRender?.(this.fileContainer,this)}removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:A}of this.separatorCache.values())A.remove();this.separatorCache.clear();for(let{element:A}of this.annotationCache.values())A.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(A){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",`${A}px`),!0}primeHighlightCache(){let{fileDiff:A,workerManager:e}=this;if(A==null||e==null||Gt(A))return;let t=this.options.tokenizeMaxLength??je;Math.max(A.additionLines.length,A.deletionLines.length)>t||e.primeDiffHighlightCache(A)}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0}renderSeparators(A){let{hunkSeparators:e}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof e!="function"){for(let{element:n}of this.separatorCache.values())n.remove();this.separatorCache.clear();return}let t=new Map(this.separatorCache);for(let n of A){let o=n.slotName,a=this.separatorCache.get(o);if(a==null||!Sp(n,a.hunkData)){a?.element.remove();let r=document.createElement("div");r.style.display="contents",r.slot=n.slotName;let s=e(n,this);s!=null&&r.appendChild(s),this.fileContainer.appendChild(r),a={element:r,hunkData:n},this.separatorCache.set(o,a)}t.delete(o)}for(let[n,{element:o}]of t.entries())this.separatorCache.delete(n),o.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:t}of this.annotationCache.values())t.remove();this.annotationCache.clear();return}let A=new Map(this.annotationCache),{renderAnnotation:e}=this.options;if(e!=null&&this.lineAnnotations.length>0)for(let[t,n]of this.lineAnnotations.entries()){let o=`${t}-${Ge(n)}`,a=this.annotationCache.get(o);if(a==null||!Rp(n,a.annotation)){a?.element.remove();let r=e(n);if(r==null)continue;a={element:op(Ge(n)),annotation:n},a.element.appendChild(r),this.fileContainer.appendChild(a.element),this.annotationCache.set(o,a)}A.delete(o)}for(let[t,{element:n}]of A.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:A}=this.options;if(this.fileContainer==null||A==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let e=A(this.interactionManager.getHoveredLine);if(e!=null&&this.gutterUtilityContent!=null)return;if(e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=ap();t.appendChild(e),this.fileContainer.appendChild(t),this.gutterUtilityContent=t}getOrCreateFileContainer(A,e){let t=this.fileContainer;this.fileContainer=A??this.fileContainer??document.createElement(Pe);let n=t!==this.fileContainer;return t!=null&&n&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),e!=null&&this.fileContainer.parentNode!==e&&e.appendChild(this.fileContainer),n&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(A){let{shadowRoot:e}=A;if(e!=null)for(let t of e.children)t instanceof SVGElement?this.spriteSVG??(this.spriteSVG=t):Ja(t)&&t.hasAttribute(Ye)?(this.themeCSSStyle??(this.themeCSSStyle=t),this.hasAdoptedThemeCSS=!0):Ja(t)&&t.hasAttribute(Ke)&&(this.unsafeCSSStyle??(this.unsafeCSSStyle=t),this.appliedUnsafeCSS??(this.appliedUnsafeCSS=this.options.unsafeCSS??void 0))}ensureSpriteSVG(A){let e=A.shadowRoot??A.attachShadow({mode:"open"});if(this.spriteSVG==null){let t=document.createElement("div");t.innerHTML=ep;let n=t.firstChild;n instanceof SVGElement&&(this.spriteSVG=n)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==e&&e.appendChild(this.spriteSVG)}getOrCreatePreNode(A){let e=A.shadowRoot??A.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,e.appendChild(this.pre)):this.pre.parentNode!==e&&(e.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(A){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let e of Array.from(A.children))e instanceof HTMLElement&&(e.hasAttribute("data-unified")?this.codeUnified=e:e.hasAttribute("data-deletions")?this.codeDeletions=e:e.hasAttribute("data-additions")&&(this.codeAdditions=e))}applyHeaderToDOM(A,e){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:t}=this,n=this.cachedHeaderHTML??fA(A);if(this.cachedHeaderHTML=n,n!==this.lastRenderedHeaderHTML){let c=document.createElement("div");c.innerHTML=n;let g=c.firstElementChild;if(!(g instanceof HTMLElement))return;this.headerElement!=null?e.shadowRoot?.replaceChild(g,this.headerElement):e.shadowRoot?.prepend(g),this.headerElement=g,this.lastRenderedHeaderHTML=n}if(this.isContainerManaged||t==null)return;let{renderCustomHeader:o,renderHeaderPrefix:a,renderHeaderMetadata:r}=this.options;if(o!=null){let c=o(t)??void 0;this.headerCustom=this.upsertHeaderSlotElement(e,this.headerCustom,Ht,c),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0;return}let s=a?.(t)??void 0,i=r?.(t)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(e,this.headerPrefix,Nt,s),this.headerMetadata=this.upsertHeaderSlotElement(e,this.headerMetadata,Lt,i),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(A,e,t,n){if(n==null){e?.remove();return}let o=e??this.createHeaderSlotElement(t);return e==null&&A.appendChild(o),this.replaceHeaderSlotContent(o,n),o}replaceHeaderSlotContent(A,e){A.replaceChildren(),e instanceof Element?A.appendChild(e):A.innerText=`${e}`}createHeaderSlotElement(A){let e=document.createElement("div");return e.slot=A,e}injectUnsafeCSS(){let{unsafeCSS:A}=this.options,e=this.fileContainer?.shadowRoot;if(e!=null){if(A==null||A===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===e&&this.appliedUnsafeCSS===A||(this.unsafeCSSStyle??(this.unsafeCSSStyle=rp()),this.unsafeCSSStyle.parentNode!==e&&e.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=cp(A),this.appliedUnsafeCSS=A)}}applyThemeState(A,e,t,n){let o=A.shadowRoot??A.attachShadow({mode:"open"}),a=n??t,r=this.options.theme??oA,s=typeof r=="string"?r:{...r},i=kt(o);if(this.themeCSSStyle?.parentNode===o&&this.appliedThemeCSS?.themeStyles===e&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===i){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===o){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:e,themeType:a,baseThemeType:n,scrollbarGutter:i};return}this.themeCSSStyle=lp({shadowRoot:o,currentNode:this.themeCSSStyle,themeCSS:gp(e,a,i)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:s,themeStyles:e,themeType:a,baseThemeType:n,scrollbarGutter:i}:void 0}hydrateMeasuredScrollbar(){let A=this.fileContainer?.shadowRoot;A==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=dp(this.themeCSSStyle.textContent??"",kt(A)))}applyHunksToDOM(A,e){let{overflow:t="scroll"}=this.options,n=(this.options.hunkSeparators??"line-info")==="line-info",o=t==="wrap"?e.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(A,e);let a=!1,r=[],s=this.hunksRenderer.renderCodeAST("unified",e),i=this.hunksRenderer.renderCodeAST("deletions",e),c=this.hunksRenderer.renderCodeAST("additions",e);s!=null?(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=jn({code:this.codeUnified,columnType:"unified",rowSpan:o,containerSize:n}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s),r.push(this.codeUnified)):i!=null||c!=null?(i!=null?(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=jn({code:this.codeDeletions,columnType:"deletions",rowSpan:o,containerSize:n}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(i),r.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),c!=null?(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=jn({code:this.codeAdditions,columnType:"additions",rowSpan:o,containerSize:n}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(c),r.push(this.codeAdditions)):(this.codeAdditions?.remove(),this.codeAdditions=void 0)):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0),r.length===0?A.textContent="":a&&A.replaceChildren(...r),this.lastRowCount=e.rowCount}applyPartialRender({previousRenderRange:A,renderRange:e}){let{pre:t,codeUnified:n,codeAdditions:o,codeDeletions:a,options:{diffStyle:r="split"}}=this;if(t==null||A==null||e==null||!Number.isFinite(A.totalLines)||!Number.isFinite(e.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(r,n,a,o);if(s==null)return!1;let i=A.startingLine,c=e.startingLine,g=i+A.totalLines,d=c+e.totalLines,u=Math.max(i,c),p=Math.min(g,d);if(p<=u)return!1;let l=Math.max(0,u-i),C=Math.max(0,g-p),f=this.trimColumns({columns:s,trimStart:l,trimEnd:C,previousStart:i,overlapStart:u,overlapEnd:p,diffStyle:r});if(f<0)throw new Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<f)throw new Error("applyPartialRender: trimmed beyond DOM row count");let E=this.lastRowCount-f,m=(y,h)=>{if(!(h<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:y,totalLines:h,bufferBefore:0,bufferAfter:0})},Q=m(c,Math.max(u-c,0));if(Q==null&&c<u)return!1;let I=m(p,Math.max(d-p,0));if(I==null&&d>p)return!1;let w=(y,h)=>{if(y!=null){if(r==="unified"&&!Array.isArray(s))this.insertPartialHTML(r,s,y,h);else if(r==="split"&&Array.isArray(s))this.insertPartialHTML(r,s,y,h);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");E+=y.rowCount}};return this.cleanupErrorWrapper(),w(Q,"afterbegin"),w(I,"beforeend"),this.lastRowCount!==E&&(this.applyRowSpan(r,s,E),this.lastRowCount=E),!0}insertPartialHTML(A,e,t,n){if(A==="unified"&&!Array.isArray(e)){let o=this.hunksRenderer.renderCodeAST("unified",t);this.renderPartialColumn(e,o,n)}else if(A==="split"&&Array.isArray(e)){let o=this.hunksRenderer.renderCodeAST("deletions",t),a=this.hunksRenderer.renderCodeAST("additions",t);this.renderPartialColumn(e[0],o,n),this.renderPartialColumn(e[1],a,n)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}renderPartialColumn(A,e,t){if(A==null||e==null)return;let n=Pp(e[0]),o=Pp(e[1]);if(n==null||o==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");let a=o.at(0);t==="beforeend"&&a?.type==="element"&&typeof a.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(a.properties["data-buffer-size"],A.content.children[A.content.children.length-1],A.gutter.children[A.gutter.children.length-1],n,o,!0);let r=o.at(-1);t==="afterbegin"&&r?.type==="element"&&typeof r.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(r.properties["data-buffer-size"],A.content.children[0],A.gutter.children[0],n,o,!1),A.gutter.insertAdjacentHTML(t,this.hunksRenderer.renderPartialHTML(n)),A.content.insertAdjacentHTML(t,this.hunksRenderer.renderPartialHTML(o))}mergeBuffersIfNecessary(A,e,t,n,o,a){if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement))return;let r=this.getBufferSize(e.dataset);r!=null&&(a?(n.shift(),o.shift()):(n.pop(),o.pop()),this.updateBufferSize(e,r+A),this.updateBufferSize(t,r+A))}applyRowSpan(A,e,t){let n=o=>{o!=null&&(o.gutter.style.setProperty("grid-row",`span ${t}`),o.content.style.setProperty("grid-row",`span ${t}`))};if(A==="unified"&&!Array.isArray(e))n(e);else if(A==="split"&&Array.isArray(e))n(e[0]),n(e[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(A,e,t){let n=0,o=0,a=0,r=!1,s=t>=0;if(A==null)return 0;let i=Array.from(A.content.children),c=Array.from(A.gutter.children);if(i.length!==c.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;a<i.length&&!(e<=0&&!s&&!r);){let g=c[a],d=i[a];if(a++,!(g instanceof HTMLElement)||!(d instanceof HTMLElement))throw console.error({gutterElement:g,contentElement:d}),new Error("FileDiff.trimColumnRows: invalid row elements");if(r&&(r=!1,g.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in d.dataset||g.dataset.gutterBuffer==="metadata"&&"noNewline"in d.dataset)){g.remove(),d.remove(),o++;continue}if("lineIndex"in g.dataset&&"lineIndex"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),e>0&&(e--,e===0&&(r=!0)),o++),n++;continue}if("separator"in g.dataset&&"separator"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),o++);continue}if(g.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),o++);continue}if(g.dataset.gutterBuffer==="metadata"&&"noNewline"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),o++);continue}if(g.dataset.gutterBuffer==="buffer"&&"contentBuffer"in d.dataset){let u=this.getBufferSize(d.dataset);if(u==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(e>0){let p=Math.min(e,u),l=u-p;l>0?(this.updateBufferSize(g,l),this.updateBufferSize(d,l),o+=p):(g.remove(),d.remove(),o+=u),e-=p,e===0&&l===0&&(r=!0)}else if(s){let p=n,l=n+u-1;if(t<=p)g.remove(),d.remove(),o+=u;else if(t<=l){let C=l-t+1,f=u-C;this.updateBufferSize(g,f),this.updateBufferSize(d,f),o+=C}}n+=u;continue}throw console.error({gutterElement:g,contentElement:d}),new Error("FileDiff.trimColumnRows: unknown row elements")}return o}trimColumns({columns:A,diffStyle:e,overlapEnd:t,overlapStart:n,previousStart:o,trimEnd:a,trimStart:r}){let s=Math.max(0,n-o),i=t-o;if(i<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");let c=r>0,g=a>0;if(!c&&!g)return 0;let d=c?s:0,u=g?i:-1;if(e==="unified"&&!Array.isArray(A))return this.trimColumnRows(A,d,u);if(e==="split"&&Array.isArray(A)){let p=this.trimColumnRows(A[0],d,u),l=this.trimColumnRows(A[1],d,u);if(A[0]!=null&&A[1]!=null&&p!==l)throw new Error("FileDiff.trimColumns: split columns out of sync");return A[0]!=null?p:l}else throw console.error({diffStyle:e,columns:A}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(A){let e=Number.parseInt(A?.bufferSize??"",10);return Number.isNaN(e)?void 0:e}updateBufferSize(A,e){A.dataset.bufferSize=`${e}`,A.style.setProperty("grid-row",`span ${e}`),A.style.setProperty("min-height",`calc(${e} * 1lh)`)}getCodeColumns(A,e,t,n){function o(a){if(a==null)return;let r=a.children[0],s=a.children[1];if(!(!(r instanceof HTMLElement)||!(s instanceof HTMLElement)||r.dataset.gutter==null||s.dataset.content==null))return{gutter:r,content:s}}if(A==="unified")return o(e);{let a=o(t),r=o(n);return a!=null||r!=null?[a,r]:void 0}}applyBuffers(A,e){if(e==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}e.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",A.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${e.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),e.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",A.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${e.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(A,{additionsContentAST:e,deletionsContentAST:t,totalLines:n},o){let{diffIndicators:a="bars",disableBackground:r=!1,disableLineNumbers:s=!1,overflow:i="scroll",diffStyle:c="split"}=this.options,g={type:"diff",diffIndicators:a,disableBackground:r,disableLineNumbers:s,overflow:i,split:c==="unified"?!1:e!=null&&t!=null,totalLines:n,customProperties:o};np(g,this.appliedPreAttributes)||(pp(A,g),this.appliedPreAttributes=g)}applyErrorToDOM(A,e){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let t=e.shadowRoot??e.attachShadow({mode:"open"});this.errorWrapper??(this.errorWrapper=document.createElement("div")),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",t.appendChild(this.errorWrapper);let n=document.createElement("div");n.dataset.errorMessage="",n.innerText=A.message,this.errorWrapper.appendChild(n);let o=document.createElement("pre");o.dataset.errorStack="",o.innerText=A.stack??"No Error Stack",this.errorWrapper.appendChild(o)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}},B(dr,"LoadedCustomComponent",Bp),dr);function ZI({fileDiff:A,oldFile:e,newFile:t}){return A!=null&&A.hunks.length>0||e!=null||t!=null}function zI({fileDiff:A,oldFile:e,newFile:t}){return A!=null||e!=null||t!=null}function XI(A,e,t=!1){return!t&&A==null&&e}function VI(A,e,t=!1){return A==null&&e&&!t}function Pp(A){if(!(A==null||A.type!=="element"))return A.children??[]}var Ab=[...Object.keys(Nn),"text","ansi"],eb=new Set(Ab),tb=new Map(Et.flatMap(A=>va(A).map(e=>[e,A.id])));function nb(A){if(typeof A!="string")return;let e=A.trim();return e||void 0}async function Yp(A,e={}){let t=nb(A);if(!t)return;let n=tb.get(t);if(n)return n;if(eb.has(t))return t;if(e.languagePackAvailable)try{return await It(t),t}catch{return}}async function ob(A,e){let t=new Set;for(let n of A){let o=await Yp(n,e);o&&t.add(o)}return e.fallbackToText&&t.size===0&&t.add("text"),[...t]}function ab(A){let e=new Set;return A.fileDiff?.lang&&e.add(A.fileDiff.lang),A.oldFile?.lang&&e.add(A.oldFile.lang),A.newFile?.lang&&e.add(A.newFile.lang),[...e]}async function pr(A,e){if(!A)return;if(typeof A.lang!="string")return A;let t=await Yp(A.lang,e);return A.lang===t?A:t?{...A,lang:t}:{...A,lang:"text"}}async function Kp(A,e={}){let[t,n,o,a]=await Promise.all([pr(A.fileDiff,e),pr(A.oldFile,e),pr(A.newFile,e),ob(A.langs,{fallbackToText:!1,...e})]),r=new Set(a);for(let s of ab({fileDiff:t,oldFile:n,newFile:o}))r.add(s);return r.size===0&&r.add("text"),{...A,fileDiff:t,oldFile:n,newFile:o,langs:[...r]}}var jp=["unified","split"];var Jp=["light","dark"],qp=["bars","classic","none"];var rb=["scroll","wrap"];function Se(A){return A!==null&&typeof A=="object"&&!Array.isArray(A)}function Op(A){let e;try{e=JSON.parse(A)}catch{throw new Error("Diff payload is not valid JSON.")}if(!ib(e))throw new Error("Diff payload has invalid shape.");return e}function ib(A){if(!Se(A)||typeof A.prerenderedHTML!="string"||!Array.isArray(A.langs)||!A.langs.every(n=>typeof n=="string")||!sb(A.options))return!1;let e=Se(A.fileDiff),t=Se(A.oldFile)&&Se(A.newFile);return!(!e&&!t)}function sb(A){return!(!Se(A)||!Se(A.theme)||A.theme.light!=="pierre-light"||A.theme.dark!=="pierre-dark"||!Xn(jp,A.diffStyle)||!Xn(qp,A.diffIndicators)||!Xn(Jp,A.themeType)||!Xn(rb,A.overflow)||typeof A.disableLineNumbers!="boolean"||typeof A.expandUnchanged!="boolean"||typeof A.backgroundEnabled!="boolean"||typeof A.unsafeCSS!="string")}function Xn(A,e){return typeof e=="string"&&A.includes(e)}var Wp=[],U={theme:"dark",layout:"unified",backgroundEnabled:!0,wrapEnabled:!0};function cb(A){let e=A.textContent?.trim();if(!e)throw new Error("Diff payload was empty.");return Op(e)}function gb(){let A=[];for(let e of document.querySelectorAll(".oc-diff-card")){let t=e.querySelector("[data-openclaw-diff-host]"),n=e.querySelector("[data-openclaw-diff-payload]");if(!(!t||!n))try{A.push({host:t,payload:cb(n)})}catch(o){console.warn("Skipping invalid diff payload",o)}}return A}function db(A){if(A.shadowRoot)return;let e=A.querySelector(":scope > template[shadowrootmode='open']");if(!e)return;A.attachShadow({mode:"open"}).append(e.content.cloneNode(!0)),e.remove()}function ub(A){return A.fileDiff?{fileDiff:A.fileDiff}:{oldFile:A.oldFile,newFile:A.newFile}}var pb={split:`<svg viewBox="0 0 16 16" aria-hidden="true">
234
+ `);return e?t.pop():t.push(t.pop().slice(0,-1)),t}function rr(A,e,t,n=!1){let o=fp(ar(A.name,e.name,A.contents,e.contents,A.header,e.header,t),{cacheKey:(()=>{if(A.cacheKey!=null&&e.cacheKey!=null)return`${A.cacheKey}:${e.cacheKey}`})(),oldFile:A,newFile:e,throwOnError:n});if(o==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");return e.lang!=null&&(o.lang=e.lang),o}var kp=class{constructor(){B(this,"isDeletionsScrolling",!1);B(this,"isAdditionsScrolling",!1);B(this,"timeoutId",-1);B(this,"codeDeletions");B(this,"codeAdditions");B(this,"enabled",!1);B(this,"handleDeletionsScroll",()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))});B(this,"handleAdditionsScroll",()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))})}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,this.enabled=!1)}setup(A,e,t){if(e==null||t==null)for(let n of A.children??[])n instanceof HTMLElement&&("deletions"in n.dataset?e=n:"additions"in n.dataset&&(t=n));if(t==null||e==null){this.cleanUp();return}this.codeDeletions!==e&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=e,e.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==t&&(this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=t,t.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}};function Re(A,e){return St(A.theme,e.theme)&&A.useTokenTransformer===e.useTokenTransformer&&A.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&A.lineDiffType===e.lineDiffType&&A.maxLineDiffLength===e.maxLineDiffLength}function _t(A){return v({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":A,style:`grid-row: span ${A};min-height:calc(${A} * 1lh)`}})}function xt(A){return v({tagName:"div",children:[v({tagName:"span",children:[rA("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":A,"data-column-content":""}})}function ir(A){return v({tagName:"div",children:[ne({name:A==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":A==="both"?"":void 0,"data-expand-up":A==="up"?"":void 0,"data-expand-down":A==="down"?"":void 0}})}function Ee({type:A,content:e,expandIndex:t,chunked:n=!1,slotName:o,isFirstHunk:a,isLastHunk:r}){let s=0,i=[];if(A==="metadata"&&e!=null&&i.push(v({tagName:"div",children:[rA(e)],properties:{"data-separator-wrapper":""}})),(A==="line-info"||A==="line-info-basic")&&e!=null){let c=[];t!=null&&(n?(a||(c.push(ir("up")),s++),r||(c.push(ir("down")),s++)):(c.push(ir(!a&&!r?"both":a?"down":"up")),s++)),c.push(v({tagName:"div",children:[v({tagName:"span",children:[rA(e)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),n&&t!=null&&c.push(v({tagName:"div",children:[rA("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}})),i.push(v({tagName:"div",children:c,properties:{"data-separator-wrapper":"","data-separator-multi-button":s>1?"":void 0}}))}return A==="custom"&&o!=null&&i.push(v({tagName:"slot",properties:{name:o}})),v({tagName:"div",children:i,properties:{"data-separator":i.length===0?"simple":A,"data-expand-index":t,"data-separator-first":a?"":void 0,"data-separator-last":r?"":void 0}})}function yp(A,e){return`hunk-separator-${A}-${e}`}function Fp(A){let e=A.at(-1);return e==null?0:Math.max(e.additionStart+e.additionCount,e.deletionStart+e.deletionCount)}function _p(A){return A.startingLine===0&&A.totalLines===1/0&&A.bufferBefore===0&&A.bufferAfter===0}function sr({line:A,spanStart:e,spanLength:t}){return{start:{line:A,character:e},end:{line:A,character:e+t},properties:{"data-diff-span":""},alwaysWrap:!0}}function vt({item:A,arr:e,enableJoin:t,isNeutral:n=!1,isLastItem:o=!1}){let a=e[e.length-1];if(a==null||o||!t){e.push([n?0:1,A.value]);return}let r=a[0]===0;if(n===r||n&&A.value.length===1&&!r){a[1]+=A.value;return}e.push([n?0:1,A.value])}function Mt({isPartial:A,rangeSize:e,expandedHunks:t,hunkIndex:n,collapsedContextThreshold:o}){let a=Math.max(e,0);if(a===0||A)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(t===!0||a<=o)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let r=t?.get(n),s=Math.min(Math.max(r?.fromStart??0,0),a),i=Math.min(Math.max(r?.fromEnd??0,0),a),c=s+i,g=c>=a;return{fromStart:g?a:s,fromEnd:g?0:i,rangeSize:a,collapsedLines:Math.max(a-c,0),renderAll:g}}function Zn({diff:A,diffStyle:e,startingLine:t=0,totalLines:n=1/0,expandedHunks:o,collapsedContextThreshold:a=Ie,callback:r}){let s=SI({diff:A,diffStyle:e,startingLine:t,expandedHunks:o,collapsedContextThreshold:a}),i={finalHunk:A.hunks.at(-1),viewportStart:t,viewportEnd:t+n,isWindowedHighlight:t>0||n<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,shouldBreak(){if(!i.isWindowedHighlight)return!1;let c=i.unifiedCount>=t+n,g=i.splitCount>=t+n;return e==="unified"?c:(e==="split"||c)&&g},shouldSkip(c,g){if(!i.isWindowedHighlight)return!1;let d=i.unifiedCount+c<t,u=i.splitCount+g<t;return e==="unified"?d:(e==="split"||d)&&u},incrementCounts(c,g){(e==="unified"||e==="both")&&(i.unifiedCount+=c),(e==="split"||e==="both")&&(i.splitCount+=g)},isInWindow(c,g){if(!i.isWindowedHighlight)return!0;let d=i.isInUnifiedWindow(c),u=i.isInSplitWindow(g);return e==="unified"?d:e==="split"?u:d||u},isInUnifiedWindow(c){return!i.isWindowedHighlight||i.unifiedCount>=t-c&&i.unifiedCount<t+n},isInSplitWindow(c){return!i.isWindowedHighlight||i.splitCount>=t-c&&i.splitCount<t+n},emit(c,g=!1){return g||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),r(c)??!1}};A:for(let c=s.hunkIndex;c<A.hunks.length;c++){let l=function(h,M){return u==null||u.collapsedLines<=0||u.fromStart+u.fromEnd>0?0:e==="unified"?h===g.unifiedLineStart+g.unifiedLineCount-1?u.collapsedLines:0:M===g.splitLineStart+g.splitLineCount-1?u.collapsedLines:0},C=function(){if(d.collapsedLines===0)return 0;let h=d.collapsedLines;return d.collapsedLines=0,h},g=A.hunks[c];if(g==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;let d=Mt({isPartial:A.isPartial,rangeSize:g.collapsedBefore,expandedHunks:o,hunkIndex:c,collapsedContextThreshold:a}),u=(()=>{if(g!==i.finalHunk||!xp(A))return;let h=A.additionLines.length-(g.additionLineIndex+g.additionCount),M=A.deletionLines.length-(g.deletionLineIndex+g.deletionCount);if(h!==M)throw new Error(`iterateOverDiff: trailing context mismatch (additions=${h}, deletions=${M}) for ${A.name}`);let F=Math.min(h,M);return Mt({isPartial:A.isPartial,rangeSize:F,expandedHunks:o,hunkIndex:A.hunks.length,collapsedContextThreshold:a})})(),p=d.fromStart+d.fromEnd;if(i.shouldSkip(p,p))i.incrementCounts(p,p),C();else{let h=g.unifiedLineStart-d.rangeSize,M=g.splitLineStart-d.rangeSize,F=g.deletionLineIndex-d.rangeSize,H=g.additionLineIndex-d.rangeSize,x=g.deletionStart-d.rangeSize,S=g.additionStart-d.rangeSize,[_,R]=$n(i,d.fromStart,e);_>0&&i.incrementCounts(_,_);let L=_;for(;L<d.fromStart;){if(L>=R){i.incrementCounts(d.fromStart-L,d.fromStart-L);break}if(i.isInWindow(0,0)){if(i.emit({hunkIndex:c,hunk:g,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+L,lineIndex:F+L,noEOFCR:!1,unifiedLineIndex:h+L,splitLineIndex:M+L},additionLine:{unifiedLineIndex:h+L,splitLineIndex:M+L,lineIndex:H+L,lineNumber:S+L,noEOFCR:!1}}))break A}else i.incrementCounts(1,1);L++}h=g.unifiedLineStart-d.fromEnd,M=g.splitLineStart-d.fromEnd,F=g.deletionLineIndex-d.fromEnd,H=g.additionLineIndex-d.fromEnd,x=g.deletionStart-d.fromEnd,S=g.additionStart-d.fromEnd;let[cA,K]=$n(i,d.fromEnd,e);for(cA>0&&i.incrementCounts(cA,cA),L=cA;L<d.fromEnd;){if(L>=K){i.incrementCounts(d.fromEnd-L,d.fromEnd-L);break}if(i.isInWindow(0,0)){if(i.emit({hunkIndex:c,hunk:g,collapsedBefore:C(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:x+L,lineIndex:F+L,noEOFCR:!1,unifiedLineIndex:h+L,splitLineIndex:M+L},additionLine:{unifiedLineIndex:h+L,splitLineIndex:M+L,lineIndex:H+L,lineNumber:S+L,noEOFCR:!1}}))break A}else i.incrementCounts(1,1);L++}}let f=g.unifiedLineStart,E=g.splitLineStart,m=g.deletionLineIndex,Q=g.additionLineIndex,I=g.deletionStart,w=g.additionStart,y=g.hunkContent.at(-1);for(let h of g.hunkContent){if(i.shouldBreak())break A;let M=h===y;if(h.type==="context"){if(i.shouldSkip(h.lines,h.lines))i.incrementCounts(h.lines,h.lines),C();else{let[F,H]=$n(i,h.lines,e);F>0&&i.incrementCounts(F,F);let x=F;for(;x<h.lines;){if(x>=H){i.incrementCounts(h.lines-x,h.lines-x);break}if(i.isInWindow(0,0)){let S=M&&x===h.lines-1,_=f+x,R=E+x;if(i.emit({hunkIndex:c,hunk:g,collapsedBefore:C(),collapsedAfter:l(_,R),type:"context",deletionLine:{lineNumber:I+x,lineIndex:m+x,noEOFCR:S&&g.noEOFCRDeletions,unifiedLineIndex:_,splitLineIndex:R},additionLine:{unifiedLineIndex:_,splitLineIndex:R,lineIndex:Q+x,lineNumber:w+x,noEOFCR:S&&g.noEOFCRAdditions}}))break A}else i.incrementCounts(1,1);x++}}f+=h.lines,E+=h.lines,m+=h.lines,Q+=h.lines,I+=h.lines,w+=h.lines}else{let F=Math.max(h.deletions,h.additions),H=h.deletions+h.additions;if(!i.shouldSkip(H,F)){let x=YI(i,h,e);for(let[S,_]of x)for(let R=S;R<_;R++){let L=l(f+R,e==="unified"?E+(R<h.deletions?R:R-h.deletions):E+R);if(i.emit(KI({hunkIndex:c,hunk:g,collapsedBefore:C(),collapsedAfter:L,diffStyle:e,index:R,unifiedLineIndex:f,splitLineIndex:E,additionLineIndex:Q,deletionLineIndex:m,additionLineNumber:w,deletionLineNumber:I,content:h,isLastContent:M,unifiedCount:H,splitCount:F}),!0))break A}}C(),i.incrementCounts(H,F),f+=H,E+=F,m+=h.deletions,Q+=h.additions,I+=h.deletions,w+=h.additions}}if(u!=null){let{collapsedLines:h,fromStart:M,fromEnd:F}=u,H=M+F,[x,S]=$n(i,H,e);x>0&&i.incrementCounts(x,x);let _=x;for(;_<H;){if(i.shouldBreak())break A;if(_>=S){i.incrementCounts(H-_,H-_);break}if(i.isInWindow(0,0)){let R=_===H-1;if(i.emit({hunkIndex:A.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:R?h:0,type:"context-expanded",deletionLine:{lineNumber:I+_,lineIndex:m+_,noEOFCR:!1,unifiedLineIndex:f+_,splitLineIndex:E+_},additionLine:{unifiedLineIndex:f+_,splitLineIndex:E+_,lineIndex:Q+_,lineNumber:w+_,noEOFCR:!1}}))break A}else i.incrementCounts(1,1);_++}}}}function SI({diff:A,diffStyle:e,startingLine:t,expandedHunks:n,collapsedContextThreshold:o}){if(t<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=UI({diff:A,expandedHunks:n,collapsedContextThreshold:o}),r=0,s=A.hunks.length-1,i=A.hunks.length;for(;r<=s;){let g=r+s>>1,d=a[g+1];if(d==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?d.unifiedCount:d.splitCount)>t?(i=g,s=g-1):r=g+1}if(i>=A.hunks.length){let g=a[A.hunks.length];if(g==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:A.hunks.length,splitCount:g.splitCount,unifiedCount:g.unifiedCount}}let c=a[i];if(c==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:c.splitCount,unifiedCount:c.unifiedCount}}function UI({diff:A,expandedHunks:e,collapsedContextThreshold:t}){let n=0,o=0,a=A.hunks.length-1,r=[{splitCount:0,unifiedCount:0}];for(let s=0;s<A.hunks.length;s++){let i=A.hunks[s];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");let c=Mt({isPartial:A.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:s,collapsedContextThreshold:t}),g=c.fromStart+c.fromEnd;if(n+=g+i.splitLineCount,o+=g+i.unifiedLineCount,s===a&&xp(A)){let d=PI(A,i),u=Mt({isPartial:A.isPartial,rangeSize:d,expandedHunks:e,hunkIndex:A.hunks.length,collapsedContextThreshold:t}),p=u.fromStart+u.fromEnd;n+=p,o+=p}r.push({splitCount:n,unifiedCount:o})}return r}function $n(A,e,t){if(!A.isWindowedHighlight||e<=0)return[0,e];let n=[];function o(s){let i=Math.max(0,A.viewportStart-s),c=Math.min(e,A.viewportEnd-s);c>i&&n.push([i,c])}if(t!=="split"&&o(A.unifiedCount),t!=="unified"&&o(A.splitCount),n.length===0)return[0,0];let a=n[0][0],r=n[0][1];for(let s=1;s<n.length;s++){let i=n[s];a=Math.min(a,i[0]),r=Math.max(r,i[1])}return[a,r]}function PI(A,e){let t=A.additionLines.length-(e.additionLineIndex+e.additionCount),n=A.deletionLines.length-(e.deletionLineIndex+e.deletionCount);if(t!==n)throw new Error(`iterateOverDiff: trailing context mismatch (additions=${t}, deletions=${n}) for ${A.name}`);return Math.min(t,n)}function xp(A){let e=A.hunks.at(-1);return e==null||A.isPartial||A.additionLines.length===0||A.deletionLines.length===0?!1:e.additionLineIndex+e.additionCount<A.additionLines.length||e.deletionLineIndex+e.deletionCount<A.deletionLines.length}function YI(A,e,t){if(!A.isWindowedHighlight)return[[0,t==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];let n=t!=="split",o=t!=="unified",a=t==="unified"?"unified":"split",r=[];function s(d,u){if(d+u<=A.viewportStart||d>=A.viewportEnd)return;let p=Math.max(0,A.viewportStart-d),l=Math.min(u,A.viewportEnd-d);return l>p?[p,l]:void 0}function i(d,u){return a==="split"?d:u==="additions"?[d[0]+e.deletions,d[1]+e.deletions]:d}function c(d,u){if(d==null)return;let[p,l]=i(d,u);l>p&&r.push([p,l])}if(n&&(c(s(A.unifiedCount,e.deletions),"deletions"),c(s(A.unifiedCount+e.deletions,e.additions),"additions")),o&&(c(s(A.splitCount,e.deletions),"deletions"),c(s(A.splitCount,e.additions),"additions")),r.length===0)return r;r.sort((d,u)=>d[0]-u[0]);let g=[r[0]];for(let[d,u]of r.slice(1)){let p=g[g.length-1];d<=p[1]?p[1]=Math.max(p[1],u):g.push([d,u])}return g}function KI({hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,diffStyle:o,index:a,unifiedLineIndex:r,splitLineIndex:s,additionLineIndex:i,deletionLineIndex:c,additionLineNumber:g,deletionLineNumber:d,content:u,isLastContent:p,unifiedCount:l,splitCount:C}){let f=a<u.deletions?r+a:void 0,E=o==="unified"?a>=u.deletions?r+a:void 0:a<u.additions?r+u.deletions+a:void 0,m=o==="unified"?s+(a<u.deletions?a:a-u.deletions):s+a,Q=a<u.deletions?c+a:void 0,I=a<u.deletions?d+a:void 0,w=o==="unified"?a>=u.deletions?i+(a-u.deletions):void 0:a<u.additions?i+a:void 0,y=o==="unified"?a>=u.deletions?g+(a-u.deletions):void 0:a<u.additions?g+a:void 0,h=o==="unified"?p&&a===u.deletions-1&&e.noEOFCRDeletions:p&&a===C-1&&e.noEOFCRDeletions,M=o==="unified"?p&&a===l-1&&e.noEOFCRAdditions:p&&a===C-1&&e.noEOFCRAdditions,F=Q!=null&&I!=null&&f!=null?{lineNumber:I,lineIndex:Q,noEOFCR:h,unifiedLineIndex:f,splitLineIndex:m}:void 0,H=w!=null&&y!=null&&E!=null?{unifiedLineIndex:E,splitLineIndex:m,lineIndex:w,lineNumber:y,noEOFCR:M}:void 0;if(F==null&&H!=null)return{type:"change",hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,deletionLine:void 0,additionLine:H};if(F!=null&&H==null)return{type:"change",hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,deletionLine:F,additionLine:void 0};if(F==null||H==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:A,hunk:e,collapsedAfter:t,collapsedBefore:n,deletionLine:F,additionLine:H}}var jI={forcePlainText:!1};function vp(A,e,t,{forcePlainText:n,startingLine:o,totalLines:a,expandedHunks:r,collapsedContextThreshold:s=Ie}=jI){n?(o??(o=0),a??(a=1/0)):(o=0,a=1/0);let i=o>0||a<1/0,c=typeof t.theme=="string"?e.getTheme(t.theme).type:void 0,g=Xu({theme:t.theme,highlighter:e}),d=n&&!i&&(A.unifiedLineCount>1e3||A.splitLineCount>1e3)?"none":t.lineDiffType,u={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=t,l=!n&&!A.isPartial,C=n?r:void 0,f=new Map;function E(Q){let I=l?0:Q,w=f.get(I)??qI();return f.set(I,w),w}function m(Q,I,w,y){if(i){let h=w.at(-1);(h==null||h.targetIndex+h.count!==I)&&(h={targetIndex:I,originalOffset:y.length,count:0},w.push(h)),h.count++}y.push(Q)}Zn({diff:A,diffStyle:"both",startingLine:o,totalLines:a,expandedHunks:i?C:!0,collapsedContextThreshold:s,callback:({hunkIndex:Q,additionLine:I,deletionLine:w,type:y})=>{let h=E(Q),M=I!=null?I.splitLineIndex:w.splitLineIndex;y==="change"&&I!=null&&w!=null&&JI({additionLine:A.additionLines[I.lineIndex],deletionLine:A.deletionLines[w.lineIndex],deletionLineIndex:h.deletionContent.length,additionLineIndex:h.additionContent.length,deletionDecorations:h.deletionDecorations,additionDecorations:h.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),w!=null&&(m(A.deletionLines[w.lineIndex],w.lineIndex,h.deletionSegments,h.deletionContent),h.deletionInfo.push({type:y==="change"?"change-deletion":y,lineNumber:w.lineNumber,altLineNumber:y==="change"?void 0:I.lineNumber??void 0,lineIndex:`${w.unifiedLineIndex},${M}`})),I!=null&&(m(A.additionLines[I.lineIndex],I.lineIndex,h.additionSegments,h.additionContent),h.additionInfo.push({type:y==="change"?"change-addition":y,lineNumber:I.lineNumber,altLineNumber:y==="change"?void 0:w.lineNumber??void 0,lineIndex:`${I.unifiedLineIndex},${M}`}))}});for(let Q of f.values()){if(Q.deletionContent.length===0&&Q.additionContent.length===0)continue;let I={name:A.prevName??A.name,contents:Q.deletionContent.value},w={name:A.name,contents:Q.additionContent.value},{deletionLines:y,additionLines:h}=OI({deletionFile:I,deletionInfo:Q.deletionInfo,deletionDecorations:Q.deletionDecorations,additionFile:w,additionInfo:Q.additionInfo,additionDecorations:Q.additionDecorations,highlighter:e,options:t,languageOverride:n?"text":A.lang});if(l){u.deletionLines=y,u.additionLines=h;continue}if(Q.deletionSegments.length>0)for(let M of Q.deletionSegments)for(let F=0;F<M.count;F++)u.deletionLines[M.targetIndex+F]=y[M.originalOffset+F];else u.deletionLines.push(...y);if(Q.additionSegments.length>0)for(let M of Q.additionSegments)for(let F=0;F<M.count;F++)u.additionLines[M.targetIndex+F]=h[M.originalOffset+F];else u.additionLines.push(...h)}return{code:u,themeStyles:g,baseThemeType:c}}function JI({deletionLine:A,additionLine:e,deletionLineIndex:t,additionLineIndex:n,deletionDecorations:o,additionDecorations:a,lineDiffType:r,maxLineDiffLength:s}){if(A==null||e==null||r==="none"||(A=ee(A),e=ee(e),A.length>s||e.length>s))return;let i=r==="char"?$a(A,e):er(A,e),c=[],g=[],d=r==="word-alt",u=i.at(-1);for(let l of i){let C=l===u;!l.added&&!l.removed?(vt({item:l,arr:c,enableJoin:d,isNeutral:!0,isLastItem:C}),vt({item:l,arr:g,enableJoin:d,isNeutral:!0,isLastItem:C})):l.removed?vt({item:l,arr:c,enableJoin:d,isLastItem:C}):vt({item:l,arr:g,enableJoin:d,isLastItem:C})}let p=0;for(let l of c)l[0]===1&&o.push(sr({line:t,spanStart:p,spanLength:l[1].length})),p+=l[1].length;p=0;for(let l of g)l[0]===1&&a.push(sr({line:n,spanStart:p,spanLength:l[1].length})),p+=l[1].length}function qI(){return{deletionContent:{push(A){this.value+=A,this.length++},value:"",length:0},additionContent:{push(A){this.value+=A,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function OI({deletionFile:A,additionFile:e,deletionInfo:t,additionInfo:n,highlighter:o,deletionDecorations:a,additionDecorations:r,languageOverride:s,options:{theme:i=oA,...c}}){let g=s??FA(A.name),d=s??FA(e.name),{state:u,transformers:p}=zu(c.useTokenTransformer),l=typeof i=="string"?{...c,lang:"text",theme:i,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:dA("token")}:{...c,lang:"text",themes:i,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:dA("token")};return{deletionLines:A.contents===""?[]:(l.lang=g,u.lineInfo=t,l.decorations=a,Ka(o.codeToHast(ee(A.contents),l))),additionLines:e.contents===""?[]:(l.lang=d,l.decorations=r,u.lineInfo=n,Ka(o.codeToHast(ee(e.contents),l)))}}function Gt(A){let e=A.lang??FA(A.name),t=A.lang??(A.prevName!=null?FA(A.prevName):"text");return e==="text"&&t==="text"}var TI=-1,Hp=class{constructor(A={theme:oA},e,t){B(this,"__id",`diff-hunks-renderer:${++TI}`);B(this,"highlighter");B(this,"diff");B(this,"expandedHunks",new Map);B(this,"deletionAnnotations",{});B(this,"additionAnnotations",{});B(this,"computedLang","text");B(this,"renderCache");this.options=A,this.onRenderUpdate=e,this.workerManager=t,t?.isWorkingPool()!==!0&&(this.highlighter=Sn(A.theme??oA)?Ha():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}clearRenderCache(){this.renderCache=void 0}setOptions(A){this.options=A}mergeOptions(A){this.options={...this.options,...A}}expandHunk(A,e,t=this.getOptionsWithDefaults().expansionLineCount){let n={...this.expandedHunks.get(A)??{fromStart:0,fromEnd:0}};(e==="up"||e==="both")&&(n.fromStart+=t),(e==="down"||e==="both")&&(n.fromEnd+=t),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(A,n)}getExpandedHunk(A){return this.expandedHunks.get(A)??kr}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(A){this.additionAnnotations={},this.deletionAnnotations={};for(let e of A){let t=(()=>{switch(e.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),n=t[e.lineNumber]??[];t[e.lineNumber]=n,n.push(e)}}getUnifiedLineDecoration({lineType:A}){return{gutterLineType:A}}getSplitLineDecoration({side:A,type:e}){return e!=="change"?{gutterLineType:e}:{gutterLineType:A==="deletions"?"change-deletion":"change-addition"}}createAnnotationElement(A){return ju(A)}getOptionsWithDefaults(){let{diffIndicators:A="bars",diffStyle:e="split",disableBackground:t=!1,disableFileHeader:n=!1,disableLineNumbers:o=!1,disableVirtualizationBuffers:a=!1,collapsed:r=!1,expandUnchanged:s=!1,collapsedContextThreshold:i=Ie,expansionLineCount:c=100,hunkSeparators:g="line-info",lineDiffType:d="word-alt",maxLineDiffLength:u=1e3,overflow:p="scroll",stickyHeader:l=!1,theme:C=oA,headerRenderMode:f="default",tokenizeMaxLineLength:E=1e3,tokenizeMaxLength:m=je,useTokenTransformer:Q=!1,useCSSClasses:I=!1}=this.options;return{diffIndicators:A,diffStyle:e,disableBackground:t,disableFileHeader:n,disableLineNumbers:o,disableVirtualizationBuffers:a,collapsed:r,expandUnchanged:s,collapsedContextThreshold:i,expansionLineCount:c,hunkSeparators:g,lineDiffType:d,maxLineDiffLength:u,overflow:p,stickyHeader:l,theme:this.workerManager?.getDiffRenderOptions().theme??C,headerRenderMode:f,tokenizeMaxLineLength:E,tokenizeMaxLength:m,useTokenTransformer:Q,useCSSClasses:I}}async initializeHighlighter(){return this.highlighter=await Hn(Tu(this.computedLang,this.options)),this.highlighter}hydrate(A){if(A==null)return;this.diff=A;let{options:e}=this.getRenderOptions(A),t=gr(A,this.getTokenizeMaxLength()),n=this.workerManager?.getDiffResultCache(A);n!=null&&!Re(e,n.options)&&(n=void 0),this.renderCache??(this.renderCache={diff:A,highlighted:!t&&!Gt(A),options:e,result:t?void 0:n?.result,renderRange:void 0}),this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!t&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter==null&&(this.computedLang=A.lang??FA(A.name),this.initializeHighlighter())}getRenderOptions(A){let e=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:n,tokenizeMaxLineLength:o,lineDiffType:a,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:n,useTokenTransformer:Ap(this.options),tokenizeMaxLineLength:o,lineDiffType:a,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:t}=this;return t?.result==null?{options:e,forceHighlight:!0}:!yt(A,t.diff)||!Re(e,t.options)?{options:e,forceHighlight:!0}:{options:e,forceHighlight:!1}}renderDiff(A=this.renderCache?.diff,e=io){if(A==null)return;let{expandUnchanged:t=!1,collapsedContextThreshold:n}=this.getOptionsWithDefaults(),{options:o,forceHighlight:a}=this.getRenderOptions(A),r=this.getMatchingWorkerResultCache(A,o);r!=null&&!this.hasHighlightedRenderCache(A,o)&&(this.renderCache={diff:A,highlighted:!0,renderRange:void 0,...r},a=!1),this.renderCache??(this.renderCache={diff:A,highlighted:!1,options:o,result:void 0,renderRange:void 0});let s=A.additionLines.length>0||A.deletionLines.length>0,i=!s||Gt(A)||gr(A,this.getTokenizeMaxLength()),c=!yt(A,this.renderCache.diff),g=!Un(this.renderCache.renderRange,e);if(this.workerManager?.isWorkingPool()===!0)(i||this.renderCache.result==null||!this.renderCache.highlighted&&(c||g))&&(this.renderCache.diff=A,this.renderCache.options=o,this.renderCache.highlighted=!1,(this.renderCache.result==null||c||g||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(A,e.startingLine,e.totalLines,_p(e)||t?!0:this.expandedHunks,n)),this.renderCache.renderRange=e),!i&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,A);else{this.computedLang=A.lang??FA(A.name);let d=this.highlighter!=null&&Sn(o.theme),u=this.highlighter!=null&&wo(this.computedLang),p=!i&&u;if(this.highlighter!=null&&d&&(a||i||!this.renderCache.highlighted&&p||this.renderCache.result==null)){let{result:l,options:C}=this.renderDiffWithHighlighter(A,this.highlighter,i||!u);this.renderCache={diff:A,options:C,highlighted:p,result:l,renderRange:void 0}}(!d||!i&&!u)&&this.asyncHighlight(A).then(({result:l,options:C})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(A,l,C,!i)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,e,this.renderCache.result):void 0}async asyncRender(A,e=io){let{result:t}=await this.asyncHighlight(A);return this.processDiffResult(A,e,t)}createPreElement(A,e,t){let{diffIndicators:n,disableBackground:o,disableLineNumbers:a,overflow:r}=this.getOptionsWithDefaults();return Ou({type:"diff",diffIndicators:n,disableBackground:o,disableLineNumbers:a,overflow:r,split:A,totalLines:e,customProperties:t})}async asyncHighlight(A){let e=gr(A,this.getTokenizeMaxLength());this.computedLang=e?"text":A.lang??FA(A.name);let t=this.highlighter!=null&&Sn(this.options.theme??oA),n=e||this.highlighter!=null&&wo(this.computedLang);return(this.highlighter==null||!t||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(A,this.highlighter,e)}renderDiffWithHighlighter(A,e,t=!1){let{options:n}=this.getRenderOptions(A),{collapsedContextThreshold:o}=this.getOptionsWithDefaults();return{result:vp(A,e,n,{forcePlainText:t,expandedHunks:t?!0:void 0,collapsedContextThreshold:o}),options:n}}onHighlightSuccess(A,e,t,n=!0){if(this.renderCache==null)return;let o=!this.renderCache.highlighted||!Re(this.renderCache.options,t)||!yt(this.renderCache.diff,A);this.renderCache={diff:A,options:t,highlighted:n,result:e,renderRange:void 0},o&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(A,e){let t=this.workerManager?.getDiffResultCache(A);if(!(t==null||!Re(e,t.options)))return t}hasHighlightedRenderCache(A,e){let{renderCache:t}=this;return t?.result!=null&&t.highlighted&&yt(A,t.diff)&&Re(e,t.options)}onHighlightError(A){console.error(A)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??je}processDiffResult(A,e,{code:t,themeStyles:n,baseThemeType:o}){let{diffStyle:a,disableFileHeader:r,expandUnchanged:s,expansionLineCount:i,collapsedContextThreshold:c,hunkSeparators:g}=this.getOptionsWithDefaults();this.diff=A;let d=a==="unified",u=[],p=[],l=[],C=[],{additionLines:f,deletionLines:E}=t,m={rowCount:0,hunkSeparators:g,additionsContentAST:u,deletionsContentAST:p,unifiedContentAST:l,unifiedGutterAST:Je(),deletionsGutterAST:Je(),additionsGutterAST:Je(),expansionLineCount:i,hunkData:C,incrementRowCount(_=1){m.rowCount+=_},pushToGutter(_,R){switch(_){case"unified":m.unifiedGutterAST.children.push(R);break;case"deletions":m.deletionsGutterAST.children.push(R);break;case"additions":m.additionsGutterAST.children.push(R);break}}},Q=WI(A),I={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!=="unified"){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side==="additions"?(m.pushToGutter("additions",uA(void 0,"buffer",this.size)),u?.push(_t(this.size))):(m.pushToGutter("deletions",uA(void 0,"buffer",this.size)),p?.push(_t(this.size))),this.size=0,this.side=void 0}}},w=(_,R,L,cA,K)=>{m.pushToGutter(_,_r(R,L,cA,K))};function y(_){I.flush(),a==="unified"?cr("unified",_,m):(cr("deletions",_,m),cr("additions",_,m))}Zn({diff:A,diffStyle:a,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:c,callback:({hunkIndex:_,hunk:R,collapsedBefore:L,collapsedAfter:cA,additionLine:K,deletionLine:V,type:AA})=>{let fe=V!=null?V.splitLineIndex:K.splitLineIndex,eo=K!=null?K.unifiedLineIndex:V.unifiedLineIndex;a==="split"&&AA!=="change"&&I.flush(),L>0&&y({hunkIndex:_,collapsedLines:L,rangeSize:Math.max(R?.collapsedBefore??0,0),hunkSpecs:R?.hunkSpecs,isFirstHunk:_===0,isLastHunk:!1,isExpandable:!A.isPartial});let to=a==="unified"?eo:fe,lr={type:AA,hunkIndex:_,lineIndex:to,unifiedLineIndex:eo,splitLineIndex:fe,deletionLine:V,additionLine:K};if(a==="unified"){let T=this.getUnifiedInjectedRowsForLine?.(lr);T?.before!=null&&Gp(T.before,m);let QA=V!=null?E[V.lineIndex]:void 0,CA=K!=null?f[K.lineIndex]:void 0;if(QA==null&&CA==null){let qA="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(qA,{file:A.name}),new Error(qA)}let Ue=AA==="change"?K!=null?"change-addition":"change-deletion":AA,JA=this.getUnifiedLineDecoration({type:AA,lineType:Ue,additionLineIndex:K?.lineIndex,deletionLineIndex:V?.lineIndex});w("unified",JA.gutterLineType,K!=null?K.lineNumber:V.lineNumber,`${eo},${fe}`,JA.gutterProperties),CA!=null?CA=zn(CA,JA.contentProperties):QA!=null&&(QA=zn(QA,JA.contentProperties)),Lp({diffStyle:"unified",type:AA,deletionLine:QA,additionLine:CA,unifiedSpan:this.getAnnotations("unified",V?.lineNumber,K?.lineNumber,_,to),createAnnotationElement:qA=>this.createAnnotationElement(qA),context:m}),T?.after!=null&&Gp(T.after,m)}else{let T=this.getSplitInjectedRowsForLine?.(lr);T?.before!=null&&Np(T.before,m,I);let QA=V!=null?E[V.lineIndex]:void 0,CA=K!=null?f[K.lineIndex]:void 0,Ue=this.getSplitLineDecoration({side:"deletions",type:AA,lineIndex:V?.lineIndex}),JA=this.getSplitLineDecoration({side:"additions",type:AA,lineIndex:K?.lineIndex});if(QA==null&&CA==null){let wA="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(wA,{file:A.name}),new Error(wA)}let qA=(()=>{if(AA==="change"){if(CA==null)return"additions";if(QA==null)return"deletions"}})();if(qA!=null){if(I.side!=null&&I.side!==qA)throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");I.side=qA,I.increment()}let mr=this.getAnnotations("split",V?.lineNumber,K?.lineNumber,_,to);if(mr!=null&&I.size>0&&I.flush(),V!=null){let wA=zn(QA,Ue.contentProperties);w("deletions",Ue.gutterLineType,V.lineNumber,`${V.unifiedLineIndex},${fe}`,Ue.gutterProperties),wA!=null&&(QA=wA)}if(K!=null){let wA=zn(CA,JA.contentProperties);w("additions",JA.gutterLineType,K.lineNumber,`${K.unifiedLineIndex},${fe}`,JA.gutterProperties),wA!=null&&(CA=wA)}Lp({diffStyle:"split",type:AA,additionLine:CA,deletionLine:QA,...mr,createAnnotationElement:wA=>this.createAnnotationElement(wA),context:m}),T?.after!=null&&Np(T.after,m,I)}let Br=a==="split"&&R!=null&&fe===R.splitLineStart+R.splitLineCount-1,Xp=Br?R.noEOFCRDeletions:!1,Vp=Br?R.noEOFCRAdditions:!1,no=(V?.noEOFCR??!1)||Xp,oo=(K?.noEOFCR??!1)||Vp;if(oo||no){if(a==="split"&&I.flush(),no){let T=AA==="context"||AA==="context-expanded"?AA:"change-deletion";a==="unified"?(m.unifiedContentAST.push(xt(T)),m.pushToGutter("unified",uA(T,"metadata",1))):(m.deletionsContentAST.push(xt(T)),m.pushToGutter("deletions",uA(T,"metadata",1)),oo||(m.pushToGutter("additions",uA(void 0,"buffer",1)),m.additionsContentAST.push(_t(1))))}if(oo){let T=AA==="context"||AA==="context-expanded"?AA:"change-addition";a==="unified"?(m.unifiedContentAST.push(xt(T)),m.pushToGutter("unified",uA(T,"metadata",1))):(m.additionsContentAST.push(xt(T)),m.pushToGutter("additions",uA(T,"metadata",1)),no||(m.pushToGutter("deletions",uA(void 0,"buffer",1)),m.deletionsContentAST.push(_t(1))))}m.incrementRowCount(1)}cA>0&&g!=="simple"&&y({hunkIndex:AA==="context-expanded"?_:_+1,collapsedLines:cA,rangeSize:Q,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!A.isPartial}),m.incrementRowCount(1)}}),a==="split"&&I.flush();let h=Math.max(Fp(A.hunks),A.additionLines.length??0,A.deletionLines.length??0),M=e.bufferBefore>0||e.bufferAfter>0,F=!d&&A.type!=="deleted",H=!d&&A.type!=="new",x=m.rowCount>0||M;u=F&&x?u:void 0,p=H&&x?p:void 0,l=d&&x?l:void 0;let S=this.createPreElement(p!=null&&u!=null,h);return{unifiedGutterAST:d&&x?m.unifiedGutterAST.children:void 0,unifiedContentAST:l,deletionsGutterAST:H&&x?m.deletionsGutterAST.children:void 0,deletionsContentAST:p,additionsGutterAST:F&&x?m.additionsGutterAST.children:void 0,additionsContentAST:u,hunkData:C,preNode:S,themeStyles:n,baseThemeType:o,headerElement:r?void 0:this.renderHeader(this.diff),totalLines:h,rowCount:m.rowCount,bufferBefore:e.bufferBefore,bufferAfter:e.bufferAfter,css:""}}renderCodeAST(A,e){let t=A==="unified"?e.unifiedGutterAST:A==="deletions"?e.deletionsGutterAST:e.additionsGutterAST,n=A==="unified"?e.unifiedContentAST:A==="deletions"?e.deletionsContentAST:e.additionsContentAST;if(t==null||n==null)return;let o=Je(t);return o.properties.style=`grid-row: span ${e.rowCount}`,[o,Vu(n,e.rowCount)]}renderFullAST(A,e=[]){let t=this.getOptionsWithDefaults().hunkSeparators==="line-info",n=this.renderCodeAST("unified",A);if(n!=null)return e.push(v({tagName:"code",children:n,properties:{"data-code":"","data-container-size":t?"":void 0,"data-unified":""}})),{...A.preNode,children:e};let o=this.renderCodeAST("deletions",A);o!=null&&e.push(v({tagName:"code",children:o,properties:{"data-code":"","data-container-size":t?"":void 0,"data-deletions":""}}));let a=this.renderCodeAST("additions",A);return a!=null&&e.push(v({tagName:"code",children:a,properties:{"data-code":"","data-container-size":t?"":void 0,"data-additions":""}})),{...A.preNode,children:e}}renderFullHTML(A,e=[]){return fA(this.renderFullAST(A,e))}renderPartialHTML(A,e){return e==null?fA(A):fA(v({tagName:"code",children:A,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${e}`]:""}}))}getAnnotations(A,e,t,n,o){let a={type:"annotation",hunkIndex:n,lineIndex:o,annotations:[]};if(e!=null)for(let s of this.deletionAnnotations[e]??[])a.annotations.push(Ge(s));let r={type:"annotation",hunkIndex:n,lineIndex:o,annotations:[]};if(t!=null)for(let s of this.additionAnnotations[t]??[])(A==="unified"?a:r).annotations.push(Ge(s));if(A==="unified")return a.annotations.length>0?a:void 0;if(!(r.annotations.length===0&&a.annotations.length===0))return{deletionSpan:a,additionSpan:r}}renderHeader(A){let{headerRenderMode:e,stickyHeader:t}=this.getOptionsWithDefaults();return qu({fileOrDiff:A,mode:e,stickyHeader:t})}};function Mp(A){return`${A} unmodified line${A>1?"s":""}`}function Gp(A,e){for(let t of A)e.unifiedContentAST.push(t.content),e.pushToGutter("unified",t.gutter),e.incrementRowCount(1)}function Np(A,e,t){for(let{deletion:n,addition:o}of A){if(n==null&&o==null)continue;let a=n!=null&&o!=null?void 0:n==null?"deletions":"additions";(a==null||t.side!==a)&&t.flush(),n!=null&&(e.deletionsContentAST.push(n.content),e.pushToGutter("deletions",n.gutter)),o!=null&&(e.additionsContentAST.push(o.content),e.pushToGutter("additions",o.gutter)),a!=null&&(t.side=a,t.increment()),e.incrementRowCount(1)}}function Lp({diffStyle:A,type:e,deletionLine:t,additionLine:n,unifiedSpan:o,deletionSpan:a,additionSpan:r,createAnnotationElement:s,context:i}){let c=!1;if(A==="unified"){if(n!=null?i.unifiedContentAST.push(n):t!=null&&i.unifiedContentAST.push(t),o!=null){let g=e==="change"?t!=null?"change-deletion":"change-addition":e;i.unifiedContentAST.push(s(o)),i.pushToGutter("unified",uA(g,"annotation",1)),c=!0}}else if(A==="split"){if(t!=null&&i.deletionsContentAST.push(t),n!=null&&i.additionsContentAST.push(n),a!=null){let g=e==="change"?t!=null?"change-deletion":"context":e;i.deletionsContentAST.push(s(a)),i.pushToGutter("deletions",uA(g,"annotation",1)),c=!0}if(r!=null){let g=e==="change"?n!=null?"change-addition":"context":e;i.additionsContentAST.push(s(r)),i.pushToGutter("additions",uA(g,"annotation",1)),c=!0}}c&&i.incrementRowCount(1)}function cr(A,{hunkIndex:e,collapsedLines:t,rangeSize:n,hunkSpecs:o,isFirstHunk:a,isLastHunk:r,isExpandable:s},i){if(t<=0)return;let c=A==="unified"?i.unifiedContentAST:A==="deletions"?i.deletionsContentAST:i.additionsContentAST;if(i.hunkSeparators==="metadata"){o!=null&&(i.pushToGutter(A,Ee({type:"metadata",content:o,isFirstHunk:a,isLastHunk:r})),c.push(Ee({type:"metadata",content:o,isFirstHunk:a,isLastHunk:r})),A!=="additions"&&i.incrementRowCount(1));return}if(i.hunkSeparators==="simple"){e>0&&(i.pushToGutter(A,Ee({type:"simple",isFirstHunk:a,isLastHunk:!1})),c.push(Ee({type:"simple",isFirstHunk:a,isLastHunk:!1})),A!=="additions"&&i.incrementRowCount(1));return}let g=yp(A,e),d=n>i.expansionLineCount,u=s?e:void 0;i.pushToGutter(A,Ee({type:i.hunkSeparators,content:Mp(t),expandIndex:u,chunked:d,slotName:g,isFirstHunk:a,isLastHunk:r})),c.push(Ee({type:i.hunkSeparators,content:Mp(t),expandIndex:u,chunked:d,slotName:g,isFirstHunk:a,isLastHunk:r})),A!=="additions"&&i.incrementRowCount(1),i.hunkData.push({slotName:g,hunkIndex:e,lines:t,type:A,expandable:s?{up:!a,down:!r,chunked:d}:void 0})}function zn(A,e){return A==null||A.type!=="element"||e==null?A:{...A,properties:{...A.properties,...e}}}function gr(A,e){return Math.max(A.additionLines.length,A.deletionLines.length)>e}function WI(A){let e=A.hunks.at(-1);if(e==null||A.isPartial||A.additionLines.length===0||A.deletionLines.length===0)return 0;let t=A.additionLines.length-(e.additionLineIndex+e.additionCount),n=A.deletionLines.length-(e.deletionLineIndex+e.deletionCount);if(t!==n)throw new Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${t}, deletions=${n}) for ${A.name}`);return Math.min(t,n)}function Rp(A,e){return A.lineNumber===e.lineNumber&&A.side===e.side&&A.metadata===e.metadata}function Sp(A,e){return A.slotName===e.slotName&&A.hunkIndex===e.hunkIndex&&A.lines===e.lines&&A.type===e.type&&A.expandable?.chunked===e.expandable?.chunked&&A.expandable?.up===e.expandable?.up&&A.expandable?.down===e.expandable?.down}function Up(A){return{theme:A?.theme,disableLineNumbers:A?.disableLineNumbers,overflow:A?.overflow,collapsed:A?.collapsed,disableFileHeader:A?.disableFileHeader,disableVirtualizationBuffers:A?.disableVirtualizationBuffers,stickyHeader:A?.stickyHeader,preferredHighlighter:A?.preferredHighlighter,useCSSClasses:A?.useCSSClasses,useTokenTransformer:A?.useTokenTransformer,tokenizeMaxLineLength:A?.tokenizeMaxLineLength,tokenizeMaxLength:A?.tokenizeMaxLength,diffStyle:A?.diffStyle,diffIndicators:A?.diffIndicators,disableBackground:A?.disableBackground,hunkSeparators:typeof A?.hunkSeparators=="function"?"custom":A?.hunkSeparators,expandUnchanged:A?.expandUnchanged,collapsedContextThreshold:A?.collapsedContextThreshold,lineDiffType:A?.lineDiffType,maxLineDiffLength:A?.maxLineDiffLength,expansionLineCount:A?.expansionLineCount,headerRenderMode:A?.renderCustomHeader!=null?"custom":"default"}}var $I=-1,dr,ur=(dr=class{constructor(A={theme:oA},e,t=!1){B(this,"__id",`file-diff:${++$I}`);B(this,"type","file-diff");B(this,"fileContainer");B(this,"spriteSVG");B(this,"pre");B(this,"codeUnified");B(this,"codeDeletions");B(this,"codeAdditions");B(this,"bufferBefore");B(this,"bufferAfter");B(this,"themeCSSStyle");B(this,"appliedThemeCSS");B(this,"hasAdoptedThemeCSS",!1);B(this,"unsafeCSSStyle");B(this,"appliedUnsafeCSS");B(this,"gutterUtilityContent");B(this,"headerElement");B(this,"headerPrefix");B(this,"headerMetadata");B(this,"headerCustom");B(this,"separatorCache",new Map);B(this,"errorWrapper");B(this,"placeHolder");B(this,"hunksRenderer");B(this,"resizeManager");B(this,"scrollSyncManager");B(this,"interactionManager");B(this,"annotationCache",new Map);B(this,"lineAnnotations",[]);B(this,"managersDirty",!1);B(this,"deletionFile");B(this,"additionFile");B(this,"fileDiff");B(this,"renderRange");B(this,"appliedPreAttributes");B(this,"lastRenderedHeaderHTML");B(this,"cachedHeaderHTML");B(this,"lastRowCount");B(this,"mounted",!1);B(this,"enabled",!0);B(this,"handleHighlightRender",()=>{this.rerender()});B(this,"getLineIndex",(A,e="additions")=>{if(this.fileDiff==null)return;let t=this.fileDiff.hunks.at(-1),n,o;A:for(let a of this.fileDiff.hunks){let r=e==="deletions"?a.deletionStart:a.additionStart,s=e==="deletions"?a.deletionCount:a.additionCount,i=a.splitLineStart,c=a.unifiedLineStart;if(A<r){let g=r-A;n=Math.max(c-g,0),o=Math.max(i-g,0);break A}if(A>=r+s){if(a===t){let g=A-(r+s);n=c+a.unifiedLineCount+g,o=i+a.splitLineCount+g;break A}continue}for(let g of a.hunkContent)if(g.type==="context")if(A<r+g.lines){let d=A-r;o=i+d,n=c+d;break A}else r+=g.lines,i+=g.lines,c+=g.lines;else{let d=e==="deletions"?g.deletions:g.additions;if(A<r+d){let u=A-r;n=c+(e==="additions"?g.deletions:0)+u,o=i+u;break A}else r+=d,i+=Math.max(g.deletions,g.additions),c+=g.deletions+g.additions}break A}if(!(n==null||o==null))return[n,o]});B(this,"getHoveredLine",()=>this.interactionManager.getHoveredLine());B(this,"handleExpandHunk",(A,e,t)=>{this.expandHunk(A,e,t)});B(this,"expandHunk",(A,e,t)=>{this.hunksRenderer.expandHunk(A,e,t),this.rerender()});this.options=A,this.workerManager=e,this.isContainerManaged=t,this.hunksRenderer=this.createHunksRenderer(A),this.resizeManager=new pi,this.scrollSyncManager=new kp,this.interactionManager=new ui("diff",bo(A,typeof A.hunkSeparators=="function"||(A.hunkSeparators??"line-info")==="line-info"||A.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}getHunksRendererOptions(A){return Up(A)}createHunksRenderer(A){return new Hp(this.getHunksRendererOptions(A),this.handleHighlightRender,this.workerManager)}setOptions(A){A!=null&&(this.options=A,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(A)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(bo(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(A){this.options={...this.options,...A}}setThemeType(A){(this.options.themeType??"system")!==A&&(this.mergeOptions({themeType:A}),this.applyCachedThemeState(A))}applyCachedThemeState(A){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let e=this.appliedThemeCSS.baseThemeType??A;return this.appliedThemeCSS.themeType===e?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,A,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!St(this.appliedThemeCSS.theme,this.options.theme??oA)}setLineAnnotations(A){this.lineAnnotations=A}canPartiallyRender(A,e,t){return!(A||e||t||typeof this.options.hunkSeparators=="function")}setSelectedLines(A,e){this.interactionManager.setSelection(A,e)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:A="split",overflow:e="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e==="wrap"),e==="scroll"&&A==="split"?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}cleanUp(A=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,this.lineAnnotations=[],this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,A||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,A?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(A){let{fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:o,oldFile:a,newFile:r,fileDiff:s}=A;this.hydrateElements(e,t),XI(this.pre,ZI({fileDiff:s,oldFile:a,newFile:r}),this.options.collapsed)||VI(this.headerElement,zI({fileDiff:s,oldFile:a,newFile:r}),this.options.disableFileHeader)?this.render({...A,preventEmit:!0}):this.hydrationSetup({fileDiff:s,oldFile:a,newFile:r,lineAnnotations:o}),n||this.emitPostRender()}hydrateElements(A,e){this.fileContainer!==A&&this.emitPostRender(!0),up(A,e);for(let t of A.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let n of t.children)!(n instanceof HTMLElement)||n.tagName.toLowerCase()!=="code"||("deletions"in n.dataset&&(this.codeDeletions=n),"additions"in n.dataset&&(this.codeAdditions=n),"unified"in n.dataset&&(this.codeUnified=n));continue}if("diffsHeader"in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(Ye)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(Ke)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=A,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:A,oldFile:e,newFile:t,lineAnnotations:n}){this.lineAnnotations=n??this.lineAnnotations,this.additionFile=t,this.deletionFile=e,this.fileDiff=A??(e!=null&&t!=null?rr(e,t,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}render({oldFile:A,newFile:e,fileDiff:t,deferManagers:n=!1,forceRender:o=!1,preventEmit:a=!1,lineAnnotations:r,fileContainer:s,containerWrapper:i,renderRange:c}){if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");let{collapsed:g=!1,themeType:d="system"}=this.options,u=g?void 0:c,p=this.hasThemeChanged(),l=A!=null&&e!=null&&(!Sa(A,this.deletionFile)||!Sa(e,this.additionFile)),C=t!=null&&t!==this.fileDiff,f=r!=null&&(r.length>0||this.lineAnnotations.length>0)?r!==this.lineAnnotations:!1;if(!g&&Un(u,this.renderRange)&&!o&&!f&&!p&&(t!=null&&t===this.fileDiff||t==null&&!l))return this.applyCachedThemeState(d);let{renderRange:E}=this;if(this.renderRange=u,this.deletionFile=A,this.additionFile=e,t!=null?this.fileDiff=t:A!=null&&e!=null&&l&&(C=!0,this.fileDiff=rr(A,e,this.options.parseDiffOptions)),C&&(this.cachedHeaderHTML=void 0),r!=null&&this.setLineAnnotations(r),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:m=!1,disableFileHeader:Q=!1}=this.options;if(Q&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),s=this.getOrCreateFileContainer(s,i),this.applyCachedThemeState(d),g){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let I=this.hunksRenderer.renderDiff(this.fileDiff,yr);I!=null&&this.applyThemeState(s,I.themeStyles,d,I.baseThemeType),I?.headerElement!=null&&this.applyHeaderToDOM(I.headerElement,s),this.renderSeparators([]),this.injectUnsafeCSS()}catch(I){if(m)throw I;console.error(I),I instanceof Error&&this.applyErrorToDOM(I,s)}return a||this.emitPostRender(),!0}try{let I=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(o,f,l||C||p)&&this.applyPartialRender({previousRenderRange:E,renderRange:u}))){let w=this.hunksRenderer.renderDiff(this.fileDiff,u);if(w==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(s,w.themeStyles,d,w.baseThemeType),w.headerElement!=null&&this.applyHeaderToDOM(w.headerElement,s),w.additionsContentAST!=null||w.deletionsContentAST!=null||w.unifiedContentAST!=null?this.applyHunksToDOM(I,w):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(w.hunkData)}this.applyBuffers(I,u),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,n||this.flushManagers()}catch(I){if(m)throw I;console.error(I),I instanceof Error&&this.applyErrorToDOM(I,s)}return a||this.emitPostRender(),!0}emitPostRender(A=!1){let{fileContainer:e,options:{onPostRender:t}}=this;if(A){if(!this.mounted||(this.mounted=!1,e==null))return;this.options.onPostRender?.(e,this,"unmount");return}if(e==null)return;let n=this.mounted?"update":"mount";this.mounted=!0,t?.(e,this,n)}removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:A}of this.separatorCache.values())A.remove();this.separatorCache.clear();for(let{element:A}of this.annotationCache.values())A.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(A){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${A}px`),!0}primeHighlightCache(){let{fileDiff:A,workerManager:e}=this;if(A==null||e==null||Gt(A))return;let t=this.options.tokenizeMaxLength??je;Math.max(A.additionLines.length,A.deletionLines.length)>t||e.primeDiffHighlightCache(A)}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(A){let{hunkSeparators:e}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof e!="function"){for(let{element:n}of this.separatorCache.values())n.remove();this.separatorCache.clear();return}let t=new Map(this.separatorCache);for(let n of A){let o=n.slotName,a=this.separatorCache.get(o);if(a==null||!Sp(n,a.hunkData)){a?.element.remove();let r=document.createElement("div");r.style.display="contents",r.slot=n.slotName;let s=e(n,this);s!=null&&r.appendChild(s),this.fileContainer.appendChild(r),a={element:r,hunkData:n},this.separatorCache.set(o,a)}t.delete(o)}for(let[n,{element:o}]of t.entries())this.separatorCache.delete(n),o.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:t}of this.annotationCache.values())t.remove();this.annotationCache.clear();return}let A=new Map(this.annotationCache),{renderAnnotation:e}=this.options;if(e!=null&&this.lineAnnotations.length>0)for(let[t,n]of this.lineAnnotations.entries()){let o=`${t}-${Ge(n)}`,a=this.annotationCache.get(o);if(a==null||!Rp(n,a.annotation)){a?.element.remove();let r=e(n);if(r==null)continue;a={element:op(Ge(n)),annotation:n},a.element.appendChild(r),this.fileContainer.appendChild(a.element),this.annotationCache.set(o,a)}A.delete(o)}for(let[t,{element:n}]of A.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:A}=this.options;if(this.fileContainer==null||A==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let e=A(this.interactionManager.getHoveredLine);if(e!=null&&this.gutterUtilityContent!=null)return;if(e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=ap();t.appendChild(e),this.fileContainer.appendChild(t),this.gutterUtilityContent=t}getOrCreateFileContainer(A,e){let{fileContainer:t}=this,n=A??t??document.createElement(Pe),o=t!==n;return o&&this.emitPostRender(!0),this.fileContainer=n,t!=null&&o&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),e!=null&&this.fileContainer.parentNode!==e&&e.appendChild(this.fileContainer),o&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(A){let{shadowRoot:e}=A;if(e!=null)for(let t of e.children)t instanceof SVGElement?this.spriteSVG??(this.spriteSVG=t):Ja(t)&&t.hasAttribute(Ye)?(this.themeCSSStyle??(this.themeCSSStyle=t),this.hasAdoptedThemeCSS=!0):Ja(t)&&t.hasAttribute(Ke)&&(this.unsafeCSSStyle??(this.unsafeCSSStyle=t),this.appliedUnsafeCSS??(this.appliedUnsafeCSS=this.options.unsafeCSS??void 0))}ensureSpriteSVG(A){let e=A.shadowRoot??A.attachShadow({mode:"open"});if(this.spriteSVG==null){let t=document.createElement("div");t.innerHTML=ep;let n=t.firstChild;n instanceof SVGElement&&(this.spriteSVG=n)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==e&&e.appendChild(this.spriteSVG)}getOrCreatePreNode(A){let e=A.shadowRoot??A.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,e.appendChild(this.pre)):this.pre.parentNode!==e&&(e.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(A){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let e of Array.from(A.children))e instanceof HTMLElement&&(e.hasAttribute("data-unified")?this.codeUnified=e:e.hasAttribute("data-deletions")?this.codeDeletions=e:e.hasAttribute("data-additions")&&(this.codeAdditions=e))}applyHeaderToDOM(A,e){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:t}=this,n=this.cachedHeaderHTML??fA(A);if(this.cachedHeaderHTML=n,n!==this.lastRenderedHeaderHTML){let c=document.createElement("div");c.innerHTML=n;let g=c.firstElementChild;if(!(g instanceof HTMLElement))return;this.headerElement!=null?e.shadowRoot?.replaceChild(g,this.headerElement):e.shadowRoot?.prepend(g),this.headerElement=g,this.lastRenderedHeaderHTML=n}if(this.isContainerManaged||t==null)return;let{renderCustomHeader:o,renderHeaderPrefix:a,renderHeaderMetadata:r}=this.options;if(o!=null){let c=o(t)??void 0;this.headerCustom=this.upsertHeaderSlotElement(e,this.headerCustom,Ht,c),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0;return}let s=a?.(t)??void 0,i=r?.(t)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(e,this.headerPrefix,Nt,s),this.headerMetadata=this.upsertHeaderSlotElement(e,this.headerMetadata,Lt,i),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(A,e,t,n){if(n==null){e?.remove();return}let o=e??this.createHeaderSlotElement(t);return e==null&&A.appendChild(o),this.replaceHeaderSlotContent(o,n),o}replaceHeaderSlotContent(A,e){A.replaceChildren(),e instanceof Element?A.appendChild(e):A.innerText=`${e}`}createHeaderSlotElement(A){let e=document.createElement("div");return e.slot=A,e}injectUnsafeCSS(){let{unsafeCSS:A}=this.options,e=this.fileContainer?.shadowRoot;if(e!=null){if(A==null||A===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===e&&this.appliedUnsafeCSS===A||(this.unsafeCSSStyle??(this.unsafeCSSStyle=rp()),this.unsafeCSSStyle.parentNode!==e&&e.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=cp(A),this.appliedUnsafeCSS=A)}}applyThemeState(A,e,t,n){let o=A.shadowRoot??A.attachShadow({mode:"open"}),a=n??t,r=this.options.theme??oA,s=typeof r=="string"?r:{...r},i=kt(o);if(this.themeCSSStyle?.parentNode===o&&this.appliedThemeCSS?.themeStyles===e&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===i){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===o){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:e,themeType:a,baseThemeType:n,scrollbarGutter:i};return}this.themeCSSStyle=lp({shadowRoot:o,currentNode:this.themeCSSStyle,themeCSS:gp(e,a,i)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:s,themeStyles:e,themeType:a,baseThemeType:n,scrollbarGutter:i}:void 0}hydrateMeasuredScrollbar(){let A=this.fileContainer?.shadowRoot;A==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=dp(this.themeCSSStyle.textContent??"",kt(A)))}applyHunksToDOM(A,e){let{overflow:t="scroll"}=this.options,n=(this.options.hunkSeparators??"line-info")==="line-info",o=t==="wrap"?e.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(A,e);let a=!1,r=[],s=this.hunksRenderer.renderCodeAST("unified",e),i=this.hunksRenderer.renderCodeAST("deletions",e),c=this.hunksRenderer.renderCodeAST("additions",e);s!=null?(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=jn({code:this.codeUnified,columnType:"unified",rowSpan:o,containerSize:n}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s),r.push(this.codeUnified)):i!=null||c!=null?(i!=null?(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=jn({code:this.codeDeletions,columnType:"deletions",rowSpan:o,containerSize:n}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(i),r.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),c!=null?(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=jn({code:this.codeAdditions,columnType:"additions",rowSpan:o,containerSize:n}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(c),r.push(this.codeAdditions)):(this.codeAdditions?.remove(),this.codeAdditions=void 0)):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0),r.length===0?A.textContent="":a&&A.replaceChildren(...r),this.lastRowCount=e.rowCount}applyPartialRender({previousRenderRange:A,renderRange:e}){let{pre:t,codeUnified:n,codeAdditions:o,codeDeletions:a,options:{diffStyle:r="split"}}=this;if(t==null||A==null||e==null||!Number.isFinite(A.totalLines)||!Number.isFinite(e.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(r,n,a,o);if(s==null)return!1;let i=A.startingLine,c=e.startingLine,g=i+A.totalLines,d=c+e.totalLines,u=Math.max(i,c),p=Math.min(g,d);if(p<=u)return!1;let l=Math.max(0,u-i),C=Math.max(0,g-p),f=this.trimColumns({columns:s,trimStart:l,trimEnd:C,previousStart:i,overlapStart:u,overlapEnd:p,diffStyle:r});if(f<0)throw new Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<f)throw new Error("applyPartialRender: trimmed beyond DOM row count");let E=this.lastRowCount-f,m=(y,h)=>{if(!(h<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:y,totalLines:h,bufferBefore:0,bufferAfter:0})},Q=m(c,Math.max(u-c,0));if(Q==null&&c<u)return!1;let I=m(p,Math.max(d-p,0));if(I==null&&d>p)return!1;let w=(y,h)=>{if(y!=null){if(r==="unified"&&!Array.isArray(s))this.insertPartialHTML(r,s,y,h);else if(r==="split"&&Array.isArray(s))this.insertPartialHTML(r,s,y,h);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");E+=y.rowCount}};return this.cleanupErrorWrapper(),w(Q,"afterbegin"),w(I,"beforeend"),this.lastRowCount!==E&&(this.applyRowSpan(r,s,E),this.lastRowCount=E),!0}insertPartialHTML(A,e,t,n){if(A==="unified"&&!Array.isArray(e)){let o=this.hunksRenderer.renderCodeAST("unified",t);this.renderPartialColumn(e,o,n)}else if(A==="split"&&Array.isArray(e)){let o=this.hunksRenderer.renderCodeAST("deletions",t),a=this.hunksRenderer.renderCodeAST("additions",t);this.renderPartialColumn(e[0],o,n),this.renderPartialColumn(e[1],a,n)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}renderPartialColumn(A,e,t){if(A==null||e==null)return;let n=Pp(e[0]),o=Pp(e[1]);if(n==null||o==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");let a=o.at(0);t==="beforeend"&&a?.type==="element"&&typeof a.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(a.properties["data-buffer-size"],A.content.children[A.content.children.length-1],A.gutter.children[A.gutter.children.length-1],n,o,!0);let r=o.at(-1);t==="afterbegin"&&r?.type==="element"&&typeof r.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(r.properties["data-buffer-size"],A.content.children[0],A.gutter.children[0],n,o,!1),A.gutter.insertAdjacentHTML(t,this.hunksRenderer.renderPartialHTML(n)),A.content.insertAdjacentHTML(t,this.hunksRenderer.renderPartialHTML(o))}mergeBuffersIfNecessary(A,e,t,n,o,a){if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement))return;let r=this.getBufferSize(e.dataset);r!=null&&(a?(n.shift(),o.shift()):(n.pop(),o.pop()),this.updateBufferSize(e,r+A),this.updateBufferSize(t,r+A))}applyRowSpan(A,e,t){let n=o=>{o!=null&&(o.gutter.style.setProperty("grid-row",`span ${t}`),o.content.style.setProperty("grid-row",`span ${t}`))};if(A==="unified"&&!Array.isArray(e))n(e);else if(A==="split"&&Array.isArray(e))n(e[0]),n(e[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(A,e,t){let n=0,o=0,a=0,r=!1,s=t>=0;if(A==null)return 0;let i=Array.from(A.content.children),c=Array.from(A.gutter.children);if(i.length!==c.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;a<i.length&&!(e<=0&&!s&&!r);){let g=c[a],d=i[a];if(a++,!(g instanceof HTMLElement)||!(d instanceof HTMLElement))throw console.error({gutterElement:g,contentElement:d}),new Error("FileDiff.trimColumnRows: invalid row elements");if(r&&(r=!1,g.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in d.dataset||g.dataset.gutterBuffer==="metadata"&&"noNewline"in d.dataset)){g.remove(),d.remove(),o++;continue}if("lineIndex"in g.dataset&&"lineIndex"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),e>0&&(e--,e===0&&(r=!0)),o++),n++;continue}if("separator"in g.dataset&&"separator"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),o++);continue}if(g.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),o++);continue}if(g.dataset.gutterBuffer==="metadata"&&"noNewline"in d.dataset){(e>0||s&&n>=t)&&(g.remove(),d.remove(),o++);continue}if(g.dataset.gutterBuffer==="buffer"&&"contentBuffer"in d.dataset){let u=this.getBufferSize(d.dataset);if(u==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(e>0){let p=Math.min(e,u),l=u-p;l>0?(this.updateBufferSize(g,l),this.updateBufferSize(d,l),o+=p):(g.remove(),d.remove(),o+=u),e-=p,e===0&&l===0&&(r=!0)}else if(s){let p=n,l=n+u-1;if(t<=p)g.remove(),d.remove(),o+=u;else if(t<=l){let C=l-t+1,f=u-C;this.updateBufferSize(g,f),this.updateBufferSize(d,f),o+=C}}n+=u;continue}throw console.error({gutterElement:g,contentElement:d}),new Error("FileDiff.trimColumnRows: unknown row elements")}return o}trimColumns({columns:A,diffStyle:e,overlapEnd:t,overlapStart:n,previousStart:o,trimEnd:a,trimStart:r}){let s=Math.max(0,n-o),i=t-o;if(i<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");let c=r>0,g=a>0;if(!c&&!g)return 0;let d=c?s:0,u=g?i:-1;if(e==="unified"&&!Array.isArray(A))return this.trimColumnRows(A,d,u);if(e==="split"&&Array.isArray(A)){let p=this.trimColumnRows(A[0],d,u),l=this.trimColumnRows(A[1],d,u);if(A[0]!=null&&A[1]!=null&&p!==l)throw new Error("FileDiff.trimColumns: split columns out of sync");return A[0]!=null?p:l}else throw console.error({diffStyle:e,columns:A}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(A){let e=Number.parseInt(A?.bufferSize??"",10);return Number.isNaN(e)?void 0:e}updateBufferSize(A,e){A.dataset.bufferSize=`${e}`,A.style.setProperty("grid-row",`span ${e}`),A.style.setProperty("min-height",`calc(${e} * 1lh)`)}getCodeColumns(A,e,t,n){function o(a){if(a==null)return;let r=a.children[0],s=a.children[1];if(!(!(r instanceof HTMLElement)||!(s instanceof HTMLElement)||r.dataset.gutter==null||s.dataset.content==null))return{gutter:r,content:s}}if(A==="unified")return o(e);{let a=o(t),r=o(n);return a!=null||r!=null?[a,r]:void 0}}applyBuffers(A,e){if(e==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}e.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",A.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${e.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),e.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",A.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${e.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(A,{additionsContentAST:e,deletionsContentAST:t,totalLines:n},o){let{diffIndicators:a="bars",disableBackground:r=!1,disableLineNumbers:s=!1,overflow:i="scroll",diffStyle:c="split"}=this.options,g={type:"diff",diffIndicators:a,disableBackground:r,disableLineNumbers:s,overflow:i,split:c==="unified"?!1:e!=null&&t!=null,totalLines:n,customProperties:o};np(g,this.appliedPreAttributes)||(pp(A,g),this.appliedPreAttributes=g)}applyErrorToDOM(A,e){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let t=e.shadowRoot??e.attachShadow({mode:"open"});this.errorWrapper??(this.errorWrapper=document.createElement("div")),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",t.appendChild(this.errorWrapper);let n=document.createElement("div");n.dataset.errorMessage="",n.innerText=A.message,this.errorWrapper.appendChild(n);let o=document.createElement("pre");o.dataset.errorStack="",o.innerText=A.stack??"No Error Stack",this.errorWrapper.appendChild(o)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}},B(dr,"LoadedCustomComponent",Bp),dr);function ZI({fileDiff:A,oldFile:e,newFile:t}){return A!=null&&A.hunks.length>0||e!=null||t!=null}function zI({fileDiff:A,oldFile:e,newFile:t}){return A!=null||e!=null||t!=null}function XI(A,e,t=!1){return!t&&A==null&&e}function VI(A,e,t=!1){return A==null&&e&&!t}function Pp(A){if(!(A==null||A.type!=="element"))return A.children??[]}var Ab=[...Object.keys(Nn),"text","ansi"],eb=new Set(Ab),tb=new Map(Et.flatMap(A=>va(A).map(e=>[e,A.id])));function nb(A){if(typeof A!="string")return;let e=A.trim();return e||void 0}async function Yp(A,e={}){let t=nb(A);if(!t)return;let n=tb.get(t);if(n)return n;if(eb.has(t))return t;if(e.languagePackAvailable)try{return await It(t),t}catch{return}}async function ob(A,e){let t=new Set;for(let n of A){let o=await Yp(n,e);o&&t.add(o)}return e.fallbackToText&&t.size===0&&t.add("text"),[...t]}function ab(A){let e=new Set;return A.fileDiff?.lang&&e.add(A.fileDiff.lang),A.oldFile?.lang&&e.add(A.oldFile.lang),A.newFile?.lang&&e.add(A.newFile.lang),[...e]}async function pr(A,e){if(!A)return;if(typeof A.lang!="string")return A;let t=await Yp(A.lang,e);return A.lang===t?A:t?{...A,lang:t}:{...A,lang:"text"}}async function Kp(A,e={}){let[t,n,o,a]=await Promise.all([pr(A.fileDiff,e),pr(A.oldFile,e),pr(A.newFile,e),ob(A.langs,{fallbackToText:!1,...e})]),r=new Set(a);for(let s of ab({fileDiff:t,oldFile:n,newFile:o}))r.add(s);return r.size===0&&r.add("text"),{...A,fileDiff:t,oldFile:n,newFile:o,langs:[...r]}}var jp=["unified","split"];var Jp=["light","dark"],qp=["bars","classic","none"];var rb=["scroll","wrap"];function Se(A){return A!==null&&typeof A=="object"&&!Array.isArray(A)}function Op(A){let e;try{e=JSON.parse(A)}catch{throw new Error("Diff payload is not valid JSON.")}if(!ib(e))throw new Error("Diff payload has invalid shape.");return e}function ib(A){if(!Se(A)||typeof A.prerenderedHTML!="string"||!Array.isArray(A.langs)||!A.langs.every(n=>typeof n=="string")||!sb(A.options))return!1;let e=Se(A.fileDiff),t=Se(A.oldFile)&&Se(A.newFile);return!(!e&&!t)}function sb(A){return!(!Se(A)||!Se(A.theme)||A.theme.light!=="pierre-light"||A.theme.dark!=="pierre-dark"||!Xn(jp,A.diffStyle)||!Xn(qp,A.diffIndicators)||!Xn(Jp,A.themeType)||!Xn(rb,A.overflow)||typeof A.disableLineNumbers!="boolean"||typeof A.expandUnchanged!="boolean"||typeof A.backgroundEnabled!="boolean"||typeof A.unsafeCSS!="string")}function Xn(A,e){return typeof e=="string"&&A.includes(e)}var Wp=[],U={theme:"dark",layout:"unified",backgroundEnabled:!0,wrapEnabled:!0};function cb(A){let e=A.textContent?.trim();if(!e)throw new Error("Diff payload was empty.");return Op(e)}function gb(){let A=[];for(let e of document.querySelectorAll(".oc-diff-card")){let t=e.querySelector("[data-openclaw-diff-host]"),n=e.querySelector("[data-openclaw-diff-payload]");if(!(!t||!n))try{A.push({host:t,payload:cb(n)})}catch(o){console.warn("Skipping invalid diff payload",o)}}return A}function db(A){if(A.shadowRoot)return;let e=A.querySelector(":scope > template[shadowrootmode='open']");if(!e)return;A.attachShadow({mode:"open"}).append(e.content.cloneNode(!0)),e.remove()}function ub(A){return A.fileDiff?{fileDiff:A.fileDiff}:{oldFile:A.oldFile,newFile:A.newFile}}var pb={split:`<svg viewBox="0 0 16 16" aria-hidden="true">
235
235
  <path fill="currentColor" d="M14 0H8.5v16H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2m-1.5 6.5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0"></path>
236
236
  <path fill="currentColor" opacity="0.5" d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h5.5V0zm.5 7.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1"></path>
237
237
  </svg>`,unified:`<svg viewBox="0 0 16 16" aria-hidden="true">
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "opencl
11
11
  import crypto from "node:crypto";
12
12
  import fs$1 from "node:fs/promises";
13
13
  import { fileURLToPath } from "node:url";
14
+ import { MAX_DATE_TIMESTAMP_MS, timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
14
15
  import { root, writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime";
15
16
  import { optionalFiniteNumberSchema, stringEnum } from "openclaw/plugin-sdk/channel-actions";
16
17
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
@@ -652,15 +653,16 @@ var DiffArtifactStore = class {
652
653
  const htmlPath = path.join(artifactDir, "viewer.html");
653
654
  const ttlMs = normalizeTtlMs$1(params.ttlMs);
654
655
  const createdAt = /* @__PURE__ */ new Date();
655
- const expiresAt = new Date(createdAt.getTime() + ttlMs);
656
+ const createdAtIso = createdAt.toISOString();
657
+ const expiresAt = resolveExpiresAtIso(createdAt.getTime(), ttlMs);
656
658
  const meta = {
657
659
  id,
658
660
  token,
659
661
  title: params.title,
660
662
  inputKind: params.inputKind,
661
663
  fileCount: params.fileCount,
662
- createdAt: createdAt.toISOString(),
663
- expiresAt: expiresAt.toISOString(),
664
+ createdAt: createdAtIso,
665
+ expiresAt,
664
666
  viewerPath: `${VIEWER_PREFIX}/${id}/${token}`,
665
667
  htmlPath,
666
668
  ...params.context ? { context: params.context } : {}
@@ -714,12 +716,11 @@ var DiffArtifactStore = class {
714
716
  const filePath = path.join(artifactDir, `preview.${format}`);
715
717
  const ttlMs = normalizeTtlMs$1(params.ttlMs);
716
718
  const createdAt = /* @__PURE__ */ new Date();
717
- const expiresAt = new Date(createdAt.getTime() + ttlMs).toISOString();
718
719
  const meta = {
719
720
  kind: "standalone_file",
720
721
  id,
721
722
  createdAt: createdAt.toISOString(),
722
- expiresAt,
723
+ expiresAt: resolveExpiresAtIso(createdAt.getTime(), ttlMs),
723
724
  filePath: this.normalizeStoredPath(filePath, "filePath"),
724
725
  ...params.context ? { context: params.context } : {}
725
726
  };
@@ -853,6 +854,9 @@ function normalizeTtlMs$1(value) {
853
854
  if (rounded <= 0) return DEFAULT_TTL_MS;
854
855
  return Math.min(rounded, MAX_TTL_MS);
855
856
  }
857
+ function resolveExpiresAtIso(createdAtMs, ttlMs) {
858
+ return timestampMsToIsoString(createdAtMs + ttlMs) ?? timestampMsToIsoString(MAX_DATE_TIMESTAMP_MS) ?? "1970-01-01T00:00:00.000Z";
859
+ }
856
860
  function isExpired(meta) {
857
861
  const expiresAt = Date.parse(meta.expiresAt);
858
862
  if (!Number.isFinite(expiresAt)) return true;
@@ -2027,6 +2031,7 @@ const MAX_PATCH_BYTES = 2 * 1024 * 1024;
2027
2031
  const MAX_TITLE_BYTES = 1024;
2028
2032
  const MAX_PATH_BYTES = 2048;
2029
2033
  const MAX_LANG_BYTES = 128;
2034
+ const MAX_DIFF_ARTIFACT_TTL_SECONDS = 21600;
2030
2035
  const DiffsToolSchema = Type.Object({
2031
2036
  before: Type.Optional(Type.String({ description: "Original text content." })),
2032
2037
  after: Type.Optional(Type.String({ description: "Updated text content." })),
@@ -2089,7 +2094,7 @@ const DiffsToolSchema = Type.Object({
2089
2094
  ttlSeconds: optionalFiniteNumberSchema({
2090
2095
  description: "Artifact lifetime in seconds. Default: 1800. Maximum: 21600.",
2091
2096
  minimum: 1,
2092
- maximum: 21600
2097
+ maximum: MAX_DIFF_ARTIFACT_TTL_SECONDS
2093
2098
  }),
2094
2099
  baseUrl: Type.Optional(Type.String({ description: "Optional gateway base URL override used when building the viewer URL. Overrides configured viewerBaseUrl, for example https://gateway.example.com." }))
2095
2100
  }, { additionalProperties: false });
@@ -2369,7 +2374,7 @@ function normalizeLayout(layout, fallback) {
2369
2374
  }
2370
2375
  function normalizeTtlMs(ttlSeconds) {
2371
2376
  if (!Number.isFinite(ttlSeconds) || ttlSeconds === void 0) return;
2372
- return Math.floor(ttlSeconds * 1e3);
2377
+ return Math.floor(Math.min(Math.max(ttlSeconds, 1), MAX_DIFF_ARTIFACT_TTL_SECONDS) * 1e3);
2373
2378
  }
2374
2379
  var PluginToolInputError = class extends Error {
2375
2380
  constructor(message) {
@@ -1,4 +1,4 @@
1
- import { AppliedThemeStyleCache, BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, SelectedLineRange, ThemeTypes } from "../types.js";
1
+ import { AppliedThemeStyleCache, BaseCodeOptions, FileContents, LineAnnotation, PostRenderPhase, PrePropertiesConfig, RenderFileMetadata, RenderRange, SelectedLineRange, ThemeTypes } from "../types.js";
2
2
  import { GetHoveredLineResult, InteractionManager, InteractionManagerBaseOptions, SelectionWriteOptions } from "../managers/InteractionManager.js";
3
3
  import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
4
4
  import "../worker/index.js";
@@ -33,7 +33,7 @@ interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBa
33
33
  disableErrorHandling?: boolean;
34
34
  renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;
35
35
  renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;
36
- onPostRender?(node: HTMLElement, instance: File<LAnnotation>): unknown;
36
+ onPostRender?(node: HTMLElement, instance: File<LAnnotation>, phase: PostRenderPhase): unknown;
37
37
  }
38
38
  interface AnnotationElementCache<LAnnotation> {
39
39
  element: HTMLElement;
@@ -49,6 +49,7 @@ declare class File<LAnnotation = undefined> {
49
49
  private isContainerManaged;
50
50
  static LoadedCustomComponent: boolean;
51
51
  readonly __id: string;
52
+ readonly type = "file";
52
53
  protected fileContainer: HTMLElement | undefined;
53
54
  protected spriteSVG: SVGElement | undefined;
54
55
  protected pre: HTMLPreElement | undefined;
@@ -67,6 +68,7 @@ declare class File<LAnnotation = undefined> {
67
68
  protected cachedHeaderHTML: string | undefined;
68
69
  protected appliedPreAttributes: PrePropertiesConfig | undefined;
69
70
  protected lastRowCount: number | undefined;
71
+ private mounted;
70
72
  protected headerElement: HTMLElement | undefined;
71
73
  protected headerCustom: HTMLElement | undefined;
72
74
  protected headerPrefix: HTMLElement | undefined;
@@ -77,7 +79,7 @@ declare class File<LAnnotation = undefined> {
77
79
  protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;
78
80
  protected lineAnnotations: LineAnnotation<LAnnotation>[];
79
81
  protected managersDirty: boolean;
80
- protected file: FileContents | undefined;
82
+ file: FileContents | undefined;
81
83
  protected renderRange: RenderRange | undefined;
82
84
  protected enabled: boolean;
83
85
  constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);
@@ -1 +1 @@
1
- {"version":3,"file":"File.d.ts","names":["GetHoveredLineResult","InteractionManager","InteractionManagerBaseOptions","SelectionWriteOptions","ResizeManager","FileRenderer","AppliedThemeStyleCache","BaseCodeOptions","FileContents","LineAnnotation","PrePropertiesConfig","RenderFileMetadata","RenderRange","SelectedLineRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHydrateProps","Omit","FileOptions","File","AnnotationElementCache","HydrationSetup","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","lineAnnotations","fileContainer","forceRender","preventEmit","containerWrapper","deferManagers","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { type GetHoveredLineResult, InteractionManager, type InteractionManagerBaseOptions, type SelectionWriteOptions } from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { AppliedThemeStyleCache, BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, SelectedLineRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n deferManagers?: boolean;\n forceRender?: boolean;\n preventEmit?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHydrateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {\n disableFileHeader?: boolean;\n renderHeaderPrefix?: RenderFileMetadata;\n renderHeaderMetadata?: RenderFileMetadata;\n renderCustomHeader?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n onPostRender?(node: HTMLElement, instance: File<LAnnotation>): unknown;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\ninterface HydrationSetup<LAnnotation> {\n file: FileContents;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected themeCSSStyle: HTMLStyleElement | undefined;\n protected appliedThemeCSS: AppliedThemeStyleCache | undefined;\n protected hasAdoptedThemeCSS: boolean;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected appliedUnsafeCSS: string | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected cachedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n protected headerElement: HTMLElement | undefined;\n protected headerCustom: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected interactionManager: InteractionManager<'file'>;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected managersDirty: boolean;\n protected file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n protected enabled: boolean;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n onThemeChange(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n protected syncInteractionOptions(): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n private applyCachedThemeState;\n private hasThemeChanged;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null, options?: SelectionWriteOptions): void;\n flushManagers(): void;\n cleanUp(recycle?: boolean): void;\n virtualizedSetup(): void;\n hydrate(props: FileHydrateProps<LAnnotation>): void;\n protected hydrateElements(fileContainer: HTMLElement, prerenderedHTML: string | undefined): void;\n protected hydrationSetup({ file, lineAnnotations }: HydrationSetup<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, preventEmit, containerWrapper, deferManagers, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private emitPostRender;\n private removeRenderedCode;\n private clearAuxiliaryNodes;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n primeHighlightCache(): void;\n private cleanChildNodes;\n private renderAnnotations;\n private renderGutterUtility;\n private injectUnsafeCSS;\n private applyThemeState;\n private hydrateMeasuredScrollbar;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n protected shouldDisableVirtualizationBuffers(): boolean;\n private applyHeaderToDOM;\n private clearHeaderSlots;\n private upsertHeaderSlotElement;\n private replaceHeaderSlotContent;\n private createHeaderSlotElement;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private adoptReusableShellElements;\n private ensureSpriteSVG;\n private getOrCreatePreNode;\n private syncCodeNodeFromPre;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":"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"}
1
+ {"version":3,"file":"File.d.ts","names":["GetHoveredLineResult","InteractionManager","InteractionManagerBaseOptions","SelectionWriteOptions","ResizeManager","FileRenderer","AppliedThemeStyleCache","BaseCodeOptions","FileContents","LineAnnotation","PostRenderPhase","PrePropertiesConfig","RenderFileMetadata","RenderRange","SelectedLineRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHydrateProps","Omit","FileOptions","File","AnnotationElementCache","HydrationSetup","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","lineAnnotations","fileContainer","forceRender","preventEmit","containerWrapper","deferManagers","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { type GetHoveredLineResult, InteractionManager, type InteractionManagerBaseOptions, type SelectionWriteOptions } from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { AppliedThemeStyleCache, BaseCodeOptions, FileContents, LineAnnotation, PostRenderPhase, PrePropertiesConfig, RenderFileMetadata, RenderRange, SelectedLineRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n deferManagers?: boolean;\n forceRender?: boolean;\n preventEmit?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHydrateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {\n disableFileHeader?: boolean;\n renderHeaderPrefix?: RenderFileMetadata;\n renderHeaderMetadata?: RenderFileMetadata;\n renderCustomHeader?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n onPostRender?(node: HTMLElement, instance: File<LAnnotation>, phase: PostRenderPhase): unknown;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\ninterface HydrationSetup<LAnnotation> {\n file: FileContents;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n readonly type = \"file\";\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected themeCSSStyle: HTMLStyleElement | undefined;\n protected appliedThemeCSS: AppliedThemeStyleCache | undefined;\n protected hasAdoptedThemeCSS: boolean;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected appliedUnsafeCSS: string | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected cachedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n private mounted;\n protected headerElement: HTMLElement | undefined;\n protected headerCustom: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected interactionManager: InteractionManager<'file'>;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected managersDirty: boolean;\n file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n protected enabled: boolean;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n onThemeChange(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n protected syncInteractionOptions(): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n private applyCachedThemeState;\n private hasThemeChanged;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null, options?: SelectionWriteOptions): void;\n flushManagers(): void;\n cleanUp(recycle?: boolean): void;\n virtualizedSetup(): void;\n hydrate(props: FileHydrateProps<LAnnotation>): void;\n protected hydrateElements(fileContainer: HTMLElement, prerenderedHTML: string | undefined): void;\n protected hydrationSetup({ file, lineAnnotations }: HydrationSetup<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, preventEmit, containerWrapper, deferManagers, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private emitPostRender;\n private removeRenderedCode;\n private clearAuxiliaryNodes;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n primeHighlightCache(): void;\n private cleanChildNodes;\n private renderAnnotations;\n private renderGutterUtility;\n private injectUnsafeCSS;\n private applyThemeState;\n private hydrateMeasuredScrollbar;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n protected shouldDisableVirtualizationBuffers(): boolean;\n private applyHeaderToDOM;\n private clearHeaderSlots;\n private upsertHeaderSlotElement;\n private replaceHeaderSlotContent;\n private createHeaderSlotElement;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private adoptReusableShellElements;\n private ensureSpriteSVG;\n private getOrCreatePreNode;\n private syncCodeNodeFromPre;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":"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"}