conductor-remote 1.104.0 → 1.105.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 (40) hide show
  1. package/dist/assets/PierrePatch-D6dtPD_v.js +1532 -0
  2. package/dist/assets/diff-syntax/applescript-Co6uUVPk.js +1 -0
  3. package/dist/assets/diff-syntax/c-BIGW1oBm.js +1 -0
  4. package/dist/assets/diff-syntax/cpp-DddhVWhK.js +1 -0
  5. package/dist/assets/diff-syntax/css-CLj8gQPS.js +1 -0
  6. package/dist/assets/diff-syntax/go-C27-OAKa.js +1 -0
  7. package/dist/assets/diff-syntax/html-pp8916En.js +1 -0
  8. package/dist/assets/diff-syntax/java-CylS5w8V.js +1 -0
  9. package/dist/assets/diff-syntax/javascript-wDzz0qaB.js +1 -0
  10. package/dist/assets/diff-syntax/json-Cp-IABpG.js +1 -0
  11. package/dist/assets/diff-syntax/jsx-g9-lgVsj.js +1 -0
  12. package/dist/assets/diff-syntax/markdown-Cvjx9yec.js +1 -0
  13. package/dist/assets/diff-syntax/objective-cpp-CLxacb5B.js +1 -0
  14. package/dist/assets/diff-syntax/php-Csjmro_R.js +1 -0
  15. package/dist/assets/diff-syntax/python-B6aJPvgy.js +1 -0
  16. package/dist/assets/diff-syntax/ruby-C-9S-GLb.js +1 -0
  17. package/dist/assets/diff-syntax/rust-B1yitclQ.js +1 -0
  18. package/dist/assets/diff-syntax/scss-D5BDwBP9.js +1 -0
  19. package/dist/assets/diff-syntax/sql-CRqJ_cUM.js +1 -0
  20. package/dist/assets/diff-syntax/swift-C2oV4EkX.js +1 -0
  21. package/dist/assets/diff-syntax/toml-vGWfd6FD.js +1 -0
  22. package/dist/assets/diff-syntax/tsx-COt5Ahok.js +1 -0
  23. package/dist/assets/diff-syntax/typescript-BPQ3VLAy.js +1 -0
  24. package/dist/assets/diff-syntax/xml-sdJ4AIDG.js +1 -0
  25. package/dist/assets/diff-syntax/yml-DbVfSbck.js +1 -0
  26. package/dist/assets/diff-syntax/zsh-Yzrsuije.js +1 -0
  27. package/dist/assets/{index-CU8INVlI.css → index-BH4EAaJZ.css} +1 -1
  28. package/dist/assets/index-DxkIsRk2.js +58 -0
  29. package/dist/assets/pierre-dark-CyvmCCZW.js +1 -0
  30. package/dist/assets/pierre-light-480U9XYS.js +1 -0
  31. package/dist/assets/pierre-shiki-wasm-C8ETeZem.js +1 -0
  32. package/dist/index.html +2 -2
  33. package/dist/sw.js +1 -1
  34. package/dist/workbox-dcde9eb3.js +1 -0
  35. package/dist-node/src/git.js +53 -16
  36. package/dist-node/src/routes.js +2 -0
  37. package/dist-node/src/server.js +19 -1
  38. package/package.json +5 -1
  39. package/dist/assets/index-DKKawj8R.js +0 -52
  40. package/dist/workbox-9c191d2f.js +0 -1
@@ -0,0 +1,1532 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-syntax/cpp-DddhVWhK.js","assets/diff-syntax/c-BIGW1oBm.js","assets/diff-syntax/html-pp8916En.js","assets/diff-syntax/javascript-wDzz0qaB.js","assets/diff-syntax/css-CLj8gQPS.js","assets/diff-syntax/php-Csjmro_R.js","assets/diff-syntax/xml-sdJ4AIDG.js","assets/diff-syntax/java-CylS5w8V.js","assets/diff-syntax/sql-CRqJ_cUM.js","assets/diff-syntax/json-Cp-IABpG.js","assets/diff-syntax/ruby-C-9S-GLb.js","assets/diff-syntax/typescript-BPQ3VLAy.js","assets/diff-syntax/jsx-g9-lgVsj.js","assets/diff-syntax/tsx-COt5Ahok.js","assets/diff-syntax/zsh-Yzrsuije.js","assets/diff-syntax/yml-DbVfSbck.js","assets/diff-syntax/scss-D5BDwBP9.js"])))=>i.map(i=>d[i]);
2
+ import{w as er,s as Xs,f as Ba,a as Ga,b as za,c as gr,h as ja,_ as D,r as Q,j,p as Wa,d as Va}from"./index-DxkIsRk2.js";const mr={}.hasOwnProperty;function qa(e,t){const n=t||{};function i(r,...s){let o=i.invalid;const l=i.handlers;if(r&&mr.call(r,e)){const a=String(r[e]);o=mr.call(l,a)?l[a]:i.unknown}if(o)return o.call(this,r,...s)}return i.handlers=n.handlers||{},i.invalid=n.invalid,i.unknown=n.unknown,i}const Ys="diffs-container";(()=>{try{return!1}catch{return!1}})();const Ka=/(?=^From [a-f0-9]+ .+$)/m,Qs=/(?=^diff --git)/gm,Xa=new RegExp("(?<=\\n)"),Ya=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Qa=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Za=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Ja=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Zs="header-prefix",Js="header-filename-suffix",eo="header-metadata",tr="header-custom",le={dark:"pierre-dark",light:"pierre-light"},el="data-theme-css",tl="data-unsafe-css",nl="data-diffs-scrollbar-measure",to="--diffs-scrollbar-gutter-measured",il=1e5,rl={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8},sl=Object.freeze({fromStart:0,fromEnd:0}),br={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},ol={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0},gt=new Set;let mt=null;function no(e){gt.add(e),mt??=requestAnimationFrame(io)}function Ci(e){gt.delete(e)&&gt.size===0&&mt!=null&&(cancelAnimationFrame(mt),mt=null)}function io(e){const t=new Set(gt);gt.clear();for(const n of t)try{n(e)}catch(i){console.error(i)}gt.size>0?mt=requestAnimationFrame(io):mt=null}function Si(e,t,n){if(e===t||e==null||t==null)return e===t;const i=new Set(n),r=Object.keys(e),s=new Set(Object.keys(t));for(const o of r)if(s.delete(o),!i.has(o)&&(!(o in t)||e[o]!==t[o]))return!1;for(const o of Array.from(s))if(!i.has(o))return!1;return!0}function nr(e,t){return e==null||t==null||typeof e=="string"||typeof t=="string"?e===t:e.dark===t.dark&&e.light===t.light}function ro(e,t){const n=e?.theme??le,i=t?.theme??le,r=vr(e),s=vr(t);return nr(n,i)&&Si(e,t,["theme","parseDiffOptions"])&&Si(r,s)}function vr(e){if(e!=null&&"parseDiffOptions"in e)return e.parseDiffOptions}function wi(e,t){return e?.start===t?.start&&e?.end===t?.end&&e?.side===t?.side&&e?.endSide===t?.endSide}function Pe(e){let t=e.length;return e.charCodeAt(t-1)===10&&(t--,e.charCodeAt(t-1)===13&&t--),e.slice(0,t)}const al=new TextEncoder,ll=new TextDecoder("utf-8",{ignoreBOM:!0}),dl=/[\uD800-\uDFFF]/,xi=1024;let ft=new Uint8Array(xi);function so(){ft.length!==xi&&(ft=new Uint8Array(xi))}function W(e){if(e.length===0)return e;if(dl.test(e))return JSON.parse(JSON.stringify(e));const t=e.length*3;ft.length<t&&(ft=new Uint8Array(t));const{written:n}=al.encodeInto(e,ft);return ll.decode(ft.subarray(0,n))}function Se(e,t){return e-(t===0?0:1)}function ie(e,t){return Se(e,t)+t}const cl=4096,ul=.5;function hl(e){for(const t of e.hunks){for(let n=0;n<t.hunkContent.length;n++){const i=t.hunkContent[n];if(i.type!=="change")continue;const r=pl(e,i);r!=null&&(t.hunkContent.splice(n,1,...r),n+=r.length-1)}fl(t,e)}}function fl(e,t){const{hunkContent:n}=e;for(let i=1;i<n.length;i++){const r=n[i],s=n[i-1];if(r.type!=="change"||r.additions>0&&r.deletions>0||s.type!=="context")continue;const o=r.additions>0,l=o?t.additionLines:t.deletionLines,a=o?r.additionLineIndex:r.deletionLineIndex,d=o?r.additions:r.deletions,c=l[a]??"";if(c.trim()!=="")continue;let u=!0;for(let v=1;v<d;v++)if(l[a+v]!==c){u=!1;break}if(!u)continue;let h=0;for(;h<s.lines&&t.additionLines[s.additionLineIndex+s.lines-1-h]===c;)h++;if(h===0||i===1&&h===s.lines)continue;r.additionLineIndex-=h,r.deletionLineIndex-=h;const f=r.additionLineIndex+r.additions,p=r.deletionLineIndex+r.deletions,g=n[i+1];g?.type==="context"?(g.lines+=h,g.additionLineIndex=f,g.deletionLineIndex=p):n.splice(i+1,0,{type:"context",lines:h,additionLineIndex:f,deletionLineIndex:p}),s.lines-=h,s.lines===0&&(n.splice(i-1,1),i--)}}function pl(e,t){const{deletions:n,additions:i,deletionLineIndex:r,additionLineIndex:s}=t,o=Math.min(n,i),l=Math.abs(i-n);if(o===0||l===0||o*(l+1)>cl)return null;const a=[];for(let g=0;g<n;g++)a.push(yr(e.deletionLines[r+g]??""));const d=[];for(let g=0;g<i;g++)d.push(yr(e.additionLines[s+g]??""));const c=i>n;let u=0,h=-1;for(let g=0;g<=l;g++){let v=0;for(let m=0;m<o;m++)v+=ml(a[m+(c?0:g)],d[m+(c?g:0)]);g===0?h=v+o*ul:v>h&&(h=v,u=g)}if(u===0)return null;const f=[],p=(g,v,m,b)=>{(g>0||v>0)&&f.push({type:"change",deletions:g,additions:v,deletionLineIndex:m,additionLineIndex:b})};return c?(p(0,u,r,s),p(o,o,r,s+u),p(0,i-o-u,r+o,s+u+o)):(p(u,0,r,s),p(o,o,r+u,s),p(n-o-u,0,r+u+o,s+o)),f}const gl=/\s+/g;function yr(e){return e.replace(gl,"")}function ml(e,t){if(e===t)return 1;const n=Math.max(e.length,t.length),i=Math.min(e.length,t.length);if(i===0)return 0;let r=0;for(;r<i&&e[r]===t[r];)r++;let s=0;for(;s<i-r&&e[e.length-1-s]===t[t.length-1-s];)s++;return(r+s)/n}function bl(e,t,n){try{return vl(e,t,n)}finally{so()}}function vl(e,t,n=!1){const i=_l(e),r=i?wl(e):xl(e);let s;const o=[];for(const l of r){if(i&&!Qs.test(l)){if(s==null)s=W(l);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}else if(!i&&!kl(l)){if(s==null)s=W(l);else{if(n)throw Error("parsePatchContent: unknown file blob");console.error("parsePatchContent: unknown file blob:",l)}continue}const a=oo(l,{cacheKey:void 0,isGitDiff:i,throwOnError:n});a!=null&&o.push(a)}return{patchMetadata:s,files:o}}function yl(e,t){try{return oo(e,t)}finally{so()}}function oo(e,{cacheKey:t,isGitDiff:n=Qs.test(e),oldFile:i,newFile:r,throwOnError:s=!1}={}){let o=0;const l=uo(e,"@@ ");let a;const d=i==null||r==null;let c=0,u=0;for(const h of l){const f=ao(h),p=f[0];if(p==null){if(s)throw Error("parsePatchContent: invalid hunk");console.error("parsePatchContent: invalid hunk",h);continue}const g=co(p);let v=0,m=0;if(g==null||a==null){if(a!=null){if(s)throw Error("parsePatchContent: Invalid hunk");console.error("parsePatchContent: Invalid hunk",h);continue}a={name:"",type:"change",hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:d,additionLines:!d&&i!=null&&r!=null?Cr(r.contents):[],deletionLines:!d&&i!=null&&r!=null?Cr(i.contents):[],cacheKey:xr(t)},a.additionLines.length===1&&r?.contents===""&&(a.additionLines.length=0),a.deletionLines.length===1&&i?.contents===""&&(a.deletionLines.length=0);for(const k of f){if(k.startsWith("diff --git")){const F=k.trim().match(Za),L=F?.[1]??F?.[2],A=F?.[3]??F?.[4];if(L==null||A==null){if(s)throw Error("parsePatchContent: invalid git diff header");console.error("parsePatchContent: invalid git diff header",k);continue}a.name=W(A.trim()),L!==A&&(a.prevName=W(L.trim()));continue}const _=k.startsWith("---")||k.startsWith("+++")?k.match(n?Qa:Ya):null;if(_!=null){const[,F,L]=_;if(F==="---"&&L!=="/dev/null"){const A=W(L.trim());a.prevName=A,a.name=A}else F==="+++"&&L!=="/dev/null"&&(a.name=W(L.trim()))}else if(n){if(k.startsWith("new mode ")&&(a.mode=W(k.slice(8).trim())),k.startsWith("old mode ")&&(a.prevMode=W(k.slice(8).trim())),k.startsWith("new file mode")&&(a.type="new",a.mode=W(k.slice(13).trim())),k.startsWith("deleted file mode")&&(a.type="deleted",a.mode=W(k.slice(17).trim())),k.startsWith("similarity index")&&(k.startsWith("similarity index 100%")?a.type="rename-pure":a.type="rename-changed"),k.startsWith("index ")){const[,F,L,A]=k.trim().match(Ja)??[];F!=null&&(a.prevObjectId=W(F)),L!=null&&(a.newObjectId=W(L)),A!=null&&(a.mode=W(A))}k.startsWith("rename from ")&&(a.prevName=W(k.slice(12).trim())),k.startsWith("rename to ")&&(a.name=W(k.slice(10).trim()))}}continue}let b,y;for(;f.length>0&&(f[f.length-1]===`
3
+ `||f[f.length-1]==="\r"||f[f.length-1]===`\r
4
+ `||f[f.length-1]==="");)f.pop();const{additionStart:S,deletionStart:C}=g;c=d?c:C-1,u=d?u:S-1;const w={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:g.additionCount,additionStart:S,additionLines:v,deletionCount:g.deletionCount,deletionStart:C,deletionLines:m,deletionLineIndex:c,additionLineIndex:u,hunkContent:[],hunkContext:xr(g.hunkContext),hunkSpecs:W(p),noEOFCRAdditions:!1,noEOFCRDeletions:!1};let x=0,E=0;for(let k=1;k<f.length;k++){const _=f[k];if(x>=w.additionCount&&E>=w.deletionCount&&!_.startsWith("\\")){if(s&&Ll(_)&&!El(_))throw Error("parsePatchContent: hunk has more lines than expected");break}const F=_[0];if(F!=="+"&&F!=="-"&&F!==" "&&F!=="\\"){if(s)throw Error("parsePatchContent: invalid hunk line");console.error(`parseLineType: Invalid firstChar: "${F}", full line: "${_}"`),console.error("processFile: invalid rawLine:",_);continue}const L=Rl(F);if(L==="addition"){if(s&&x>=w.additionCount)throw Error("parsePatchContent: hunk has too many addition lines");const A=jn(_);(b==null||b.type!=="change")&&(b=Wn("change",c,u),w.hunkContent.push(b)),u++,x++,d&&a.additionLines.push(A),b.additions++,v++,y="addition"}else if(L==="deletion"){if(s&&E>=w.deletionCount)throw Error("parsePatchContent: hunk has too many deletion lines");const A=jn(_);(b==null||b.type!=="change")&&(b=Wn("change",c,u),w.hunkContent.push(b)),c++,E++,d&&a.deletionLines.push(A),b.deletions++,m++,y="deletion"}else if(L==="context"){if(s&&(E>=w.deletionCount||x>=w.additionCount))throw Error("parsePatchContent: hunk has too many context lines");const A=jn(_);(b==null||b.type!=="context")&&(b=Wn("context",c,u),w.hunkContent.push(b)),u++,c++,x++,E++,d&&(a.deletionLines.push(A),a.additionLines.push(A)),b.lines++,y="context"}else if(L==="metadata"&&b!=null){if(b.type==="context"?(w.noEOFCRAdditions=!0,w.noEOFCRDeletions=!0):y==="deletion"?w.noEOFCRDeletions=!0:y==="addition"&&(w.noEOFCRAdditions=!0),d&&(y==="addition"||y==="context")){const A=a.additionLines.length-1;A>=0&&(a.additionLines[A]=Pe(a.additionLines[A]))}if(d&&(y==="deletion"||y==="context")){const A=a.deletionLines.length-1;A>=0&&(a.deletionLines[A]=Pe(a.deletionLines[A]))}}}if(s&&(x!==w.additionCount||E!==w.deletionCount))throw Error("parsePatchContent: hunk line count mismatch");w.additionLines=v,w.deletionLines=m,w.collapsedBefore=Math.max(Se(w.additionStart,w.additionCount)-o,0),a.hunks.push(w),o=ie(w.additionStart,w.additionCount);for(const k of w.hunkContent)k.type==="context"?(w.splitLineCount+=k.lines,w.unifiedLineCount+=k.lines):(w.splitLineCount+=Math.max(k.additions,k.deletions),w.unifiedLineCount+=k.deletions+k.additions);w.splitLineStart=a.splitLineCount+w.collapsedBefore,w.unifiedLineStart=a.unifiedLineCount+w.collapsedBefore,a.splitLineCount+=w.collapsedBefore+w.splitLineCount,a.unifiedLineCount+=w.collapsedBefore+w.unifiedLineCount}if(a!=null){if(s&&d&&!n&&a.hunks.length===0)throw Error("parsePatchContent: unified file has no hunks");if(a.hunks.length>0&&!d&&a.additionLines.length>0&&a.deletionLines.length>0){const h=a.hunks[a.hunks.length-1],f=ie(h.additionStart,h.additionCount),p=a.additionLines.length,g=Math.max(p-f,0);a.splitLineCount+=g,a.unifiedLineCount+=g}return n||(a.prevName!=null&&a.name!==a.prevName?a.hunks.length>0?a.type="rename-changed":a.type="rename-pure":(i==null||i.contents==="")&&r!=null&&r.contents!==""?a.type="new":i!=null&&i.contents!==""&&(r==null||r.contents==="")&&(a.type="deleted")),a.type!=="rename-pure"&&a.type!=="rename-changed"&&(a.prevName=void 0),hl(a),a}}function Cl(e,t,n=!1){const i=[],r=Sl(e)?e.split(Ka):[e];for(const s of r)try{i.push(bl(s,t!=null?`${t}-${i.length}`:void 0,n))}catch(o){if(n)throw o;console.error(o)}return i}function Sl(e){return e.startsWith("From ")||e.includes(`
5
+ From `)}function Cr(e){const t=ao(e);for(let n=0;n<t.length;n++)t[n]=W(t[n]);return t}function ao(e){if(e.length===0)return[""];const t=[];let n=0;for(;;){const i=e.indexOf(`
6
+ `,n);if(i===-1)break;t.push(e.slice(n,i+1)),n=i+1}return n<e.length&&t.push(e.slice(n)),t}function wl(e){return uo(e,"diff --git")}function xl(e){if(e.length===0)return[""];const t=[];let n=0,i=0,r=0,s=0,o=!1;for(;i<e.length;){const l=ki(e,i);if(r<=0&&s<=0){if(lo(e,i)){i>n&&t.push(e.slice(n,i)),n=i,o=!0,i=ki(e,l);continue}if(o&&e.startsWith("@@ -",i)){const d=co(e.slice(i,l));d!=null&&(r=d.deletionCount,s=d.additionCount)}i=l;continue}const a=e[i];if(a==="\\"){i=l;continue}a===" "?(r=Math.max(r-1,0),s=Math.max(s-1,0)):a==="-"?r=Math.max(r-1,0):a==="+"&&(s=Math.max(s-1,0)),i=l}return t.push(e.slice(n)),t}function kl(e){return lo(e,0)}function lo(e,t){const n=ki(e,t);return Sr(e,t,"---")&&Sr(e,n,"+++")}function Sr(e,t,n){if(!e.startsWith(n,t))return!1;const i=e[t+n.length];if(i!==" "&&i!==" ")return!1;for(let r=t+n.length+1;r<e.length;r++){const s=e[r];if(s===`
7
+ `||s==="\r")break;if(s!==" "&&s!==" ")return!0}return!1}function ki(e,t){const n=e.indexOf(`
8
+ `,t);return n===-1?e.length:n+1}function Ll(e){const t=e[0];return t==="+"||t==="-"||t===" "}function El(e){if(!e.startsWith("--"))return!1;for(let t=2;t<e.length;t++){const n=e[t];if(n!==" "&&n!==" "&&n!==`
9
+ `&&n!=="\r")return!1}return!0}function co(e){if(!e.startsWith("@@ -"))return;let t=4;const n=Ut(e,t);if(n==null)return;const i=n.value;t=n.endIndex;let r=1;if(e[t]===","){const c=Ut(e,t+1);if(c==null)return;r=c.value,t=c.endIndex}if(e[t]!==" "||e[t+1]!=="+")return;t+=2;const s=Ut(e,t);if(s==null)return;const o=s.value;t=s.endIndex;let l=1;if(e[t]===","){const c=Ut(e,t+1);if(c==null)return;l=c.value,t=c.endIndex}if(e[t]!==" "||e[t+1]!=="@"||e[t+2]!=="@")return;let a;const d=t+3;return e[d]===" "&&(a=Al(e.slice(d+1))),{additionCount:l,additionStart:o,deletionCount:r,deletionStart:i,hunkContext:a}}function Ut(e,t){let n=t,i=0;for(;n<e.length;n++){const r=e.charCodeAt(n)-48;if(r<0||r>9)break;i=i*10+r}if(n!==t)return{value:i,endIndex:n}}function Al(e){return e.endsWith(`\r
10
+ `)?e.slice(0,-2):e.endsWith(`
11
+ `)?e.slice(0,-1):e}function _l(e){return e.startsWith("diff --git")||e.includes(`
12
+ diff --git`)}function uo(e,t){if(e.length===0)return[""];const n=`
13
+ ${t}`,i=e.startsWith(t)?0:wr(e,n,0);if(i===-1)return[e];const r=[];i>0&&r.push(e.slice(0,i));let s=i;for(;;){const o=wr(e,n,s+1);if(o===-1)break;r.push(e.slice(s,o)),s=o}return r.push(e.slice(s)),r}function wr(e,t,n){const i=e.indexOf(t,n);return i===-1?-1:i+1}function xr(e){return e==null?e:W(e)}function Rl(e){return e===" "?"context":e==="\\"?"metadata":e==="+"?"addition":"deletion"}function jn(e){const t=e.slice(1);return W(t===""?`
14
+ `:t)}function Wn(e,t,n){return e==="change"?{type:"change",additions:0,deletions:0,additionLineIndex:n,deletionLineIndex:t}:{type:"context",lines:0,additionLineIndex:n,deletionLineIndex:t}}class ir{diff(t,n,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const s=this.castInput(t,i),o=this.castInput(n,i),l=this.removeEmpty(this.tokenize(s,i)),a=this.removeEmpty(this.tokenize(o,i));return this.diffWithOptionsObj(l,a,i,r)}diffWithOptionsObj(t,n,i,r){var s;const o=b=>{if(b=this.postProcess(b,i),r){setTimeout(function(){r(b)},0);return}else return b},l=n.length,a=t.length;let d=1,c=l+a;i.maxEditLength!=null&&(c=Math.min(c,i.maxEditLength));const u=(s=i.timeout)!==null&&s!==void 0?s:1/0,h=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(f[0],n,t,0,i);if(f[0].oldPos+1>=a&&p+1>=l)return o(this.buildValues(f[0].lastComponent,n,t));let g=-1/0,v=1/0;const m=()=>{for(let b=Math.max(g,-d);b<=Math.min(v,d);b+=2){let y;const S=f[b-1],C=f[b+1];S&&(f[b-1]=void 0);let w=!1;if(C){const E=C.oldPos-b;w=C&&0<=E&&E<l}const x=S&&S.oldPos+1<a;if(!w&&!x){f[b]=void 0;continue}if(!x||w&&S.oldPos<C.oldPos?y=this.addToPath(C,!0,!1,0,i):y=this.addToPath(S,!1,!0,1,i),p=this.extractCommon(y,n,t,b,i),y.oldPos+1>=a&&p+1>=l)return o(this.buildValues(y.lastComponent,n,t))||!0;f[b]=y,y.oldPos+1>=a&&(v=Math.min(v,b-1)),p+1>=l&&(g=Math.max(g,b+1))}d++};if(r)(function b(){setTimeout(function(){if(d>c||Date.now()>h)return r(void 0);m()||b()},0)})();else for(;d<=c&&Date.now()<=h;){const b=m();if(b)return b}}addToPath(t,n,i,r,s){const o=t.lastComponent;return o&&!s.oneChangePerToken&&o.added===n&&o.removed===i?{oldPos:t.oldPos+r,lastComponent:{count:o.count+1,added:n,removed:i,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:n,removed:i,previousComponent:o}}}extractCommon(t,n,i,r,s){const o=n.length,l=i.length;let a=t.oldPos,d=a-r,c=0;for(;d+1<o&&a+1<l&&this.equals(i[a+1],n[d+1],s);)d++,a++,c++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return c&&!s.oneChangePerToken&&(t.lastComponent={count:c,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=a,d}equals(t,n,i){return i.comparator?i.comparator(t,n):t===n||!!i.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let i=0;i<t.length;i++)t[i]&&n.push(t[i]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,i){const r=[];let s;for(;t;)r.push(t),s=t.previousComponent,delete t.previousComponent,t=s;r.reverse();const o=r.length;let l=0,a=0,d=0;for(;l<o;l++){const c=r[l];if(c.removed)c.value=this.join(i.slice(d,d+c.count)),d+=c.count;else{if(!c.added&&this.useLongestToken){let u=n.slice(a,a+c.count);u=u.map(function(h,f){const p=i[d+f];return p.length>h.length?p:h}),c.value=this.join(u)}else c.value=this.join(n.slice(a,a+c.count));a+=c.count,c.added||(d+=c.count)}}return r}}class Il extends ir{}const Tl=new Il;function Pl(e,t,n){return Tl.diff(e,t,n)}const kr="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class Nl extends ir{tokenize(t){const n=new RegExp(`(\\r?\\n)|[${kr}]+|[^\\S\\n\\r]+|[^${kr}]`,"ug");return t.match(n)||[]}}const Ml=new Nl;function Hl(e,t,n){return Ml.diff(e,t,n)}class Dl extends ir{constructor(){super(...arguments),this.tokenize=$l}equals(t,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!t.includes(`
15
+ `))&&(t=t.trim()),(!i.newlineIsToken||!n.includes(`
16
+ `))&&(n=n.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(t.endsWith(`
17
+ `)&&(t=t.slice(0,-1)),n.endsWith(`
18
+ `)&&(n=n.slice(0,-1))),super.equals(t,n,i)}}const Fl=new Dl;function Lr(e,t,n){return Fl.diff(e,t,n)}function $l(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
19
+ `));const n=[],i=e.split(/(\n|\r\n)/);i[i.length-1]||i.pop();for(let r=0;r<i.length;r++){const s=i[r];r%2&&!t.newlineIsToken?n[n.length-1]+=s:n.push(s)}return n}function Ol(e){for(let t=0;t<e.length;t++)if(e[t]<" "||e[t]>"~"||e[t]==='"'||e[t]==="\\")return!0;return!1}function Fe(e){if(!Ol(e))return e;let t='"';const n=new TextEncoder().encode(e);let i=0;for(;i<n.length;){const r=n[i];r===7?t+="\\a":r===8?t+="\\b":r===9?t+="\\t":r===10?t+="\\n":r===11?t+="\\v":r===12?t+="\\f":r===13?t+="\\r":r===34?t+='\\"':r===92?t+="\\\\":r>=32&&r<=126?t+=String.fromCharCode(r):t+="\\"+r.toString(8).padStart(3,"0"),i++}return t+='"',t}const Er={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function Ar(e,t,n,i,r,s,o){let l;o?typeof o=="function"?l={callback:o}:l=o:l={},typeof l.context>"u"&&(l.context=4);const a=l.context;if(l.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(l.callback){const{callback:c}=l;Lr(n,i,Object.assign(Object.assign({},l),{callback:u=>{const h=d(u);c(h)}}))}else return d(Lr(n,i,l));function d(c){if(!c)return;c.push({value:"",lines:[]});function u(b){return b.map(function(y){return" "+y})}const h=[];let f=0,p=0,g=[],v=1,m=1;for(let b=0;b<c.length;b++){const y=c[b],S=y.lines||Bl(y.value);if(y.lines=S,y.added||y.removed){if(!f){const C=c[b-1];f=v,p=m,C&&(g=a>0?u(C.lines.slice(-a)):[],f-=g.length,p-=g.length)}for(const C of S)g.push((y.added?"+":"-")+C);y.added?m+=S.length:v+=S.length}else{if(f)if(S.length<=a*2&&b<c.length-2)for(const C of u(S))g.push(C);else{const C=Math.min(S.length,a);for(const x of u(S.slice(0,C)))g.push(x);const w={oldStart:f,oldLines:v-f+C,newStart:p,newLines:m-p+C,lines:g};h.push(w),f=0,p=0,g=[]}v+=S.length,m+=S.length}}for(const b of h)for(let y=0;y<b.lines.length;y++)b.lines[y].endsWith(`
20
+ `)?b.lines[y]=b.lines[y].slice(0,-1):(b.lines.splice(y+1,0,"\"),y++);return{oldFileName:e,newFileName:t,oldHeader:r,newHeader:s,hunks:h}}}function Li(e,t){var n,i,r,s,o,l;if(t||(t=Er),Array.isArray(e)){if(e.length>1&&!t.includeFileHeaders&&!e.every(c=>c.isGit))throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return e.map(c=>Li(c,t)).join(`
21
+ `)}const a=[];if(e.isGit){if(t=Er,!e.oldFileName)throw new Error("oldFileName must be specified for Git patches");if(!e.newFileName)throw new Error("newFileName must be specified for Git patches");let c=e.oldFileName,u=e.newFileName;e.isCreate&&c==="/dev/null"?c=u.replace(/^b\//,"a/"):e.isDelete&&u==="/dev/null"&&(u=c.replace(/^a\//,"b/")),a.push("diff --git "+Fe(c)+" "+Fe(u)),e.isDelete&&a.push("deleted file mode "+((n=e.oldMode)!==null&&n!==void 0?n:"100644")),e.isCreate&&a.push("new file mode "+((i=e.newMode)!==null&&i!==void 0?i:"100644")),e.oldMode&&e.newMode&&!e.isDelete&&!e.isCreate&&(a.push("old mode "+e.oldMode),a.push("new mode "+e.newMode)),e.isRename&&(a.push("rename from "+Fe(((r=e.oldFileName)!==null&&r!==void 0?r:"").replace(/^a\//,""))),a.push("rename to "+Fe(((s=e.newFileName)!==null&&s!==void 0?s:"").replace(/^b\//,"")))),e.isCopy&&(a.push("copy from "+Fe(((o=e.oldFileName)!==null&&o!==void 0?o:"").replace(/^a\//,""))),a.push("copy to "+Fe(((l=e.newFileName)!==null&&l!==void 0?l:"").replace(/^b\//,""))))}else t.includeIndex&&e.oldFileName==e.newFileName&&e.oldFileName!==void 0&&a.push("Index: "+e.oldFileName),t.includeUnderline&&a.push("===================================================================");const d=e.hunks.length>0;t.includeFileHeaders&&e.oldFileName!==void 0&&e.newFileName!==void 0&&(!e.isGit||d)&&(a.push("--- "+Fe(e.oldFileName)+(e.oldHeader?" "+e.oldHeader:"")),a.push("+++ "+Fe(e.newFileName)+(e.newHeader?" "+e.newHeader:"")));for(let c=0;c<e.hunks.length;c++){const u=e.hunks[c],h=u.oldLines===0?u.oldStart-1:u.oldStart,f=u.newLines===0?u.newStart-1:u.newStart;a.push("@@ -"+h+","+u.oldLines+" +"+f+","+u.newLines+" @@");for(const p of u.lines)a.push(p)}return a.join(`
22
+ `)+`
23
+ `}function Ul(e,t,n,i,r,s,o){if(typeof o=="function"&&(o={callback:o}),o?.callback){const{callback:l}=o;Ar(e,t,n,i,r,s,Object.assign(Object.assign({},o),{callback:a=>{l(a?Li(a,o.headerOptions):void 0)}}))}else{const l=Ar(e,t,n,i,r,s,o);return l?Li(l,o?.headerOptions):void 0}}function Bl(e){const t=e.endsWith(`
24
+ `),n=e.split(`
25
+ `).map(i=>i+`
26
+ `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}const Gl="/dev/null";function tt(e,t,n,i=!1){if(e===null&&t===null)throw new Error("parseDiffFromFile: You must pass oldFile, newFile, or both");const r=e??_r(),s=t??_r(),o=yl(Ul(r.name,s.name,r.contents,s.contents,r.header,s.header,n),{cacheKey:(()=>{const a=e?.cacheKey??e?.name,d=t?.cacheKey??t?.name;return a!=null&&d!=null?a+":"+d:a??d})(),oldFile:r,newFile:s,throwOnError:i});if(o==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");e===null?(o.type="new",o.prevName=void 0):t===null&&(o.type="deleted",o.prevName=void 0);const l=t?.lang??(t===null?e?.lang:void 0);return l!=null&&(o.lang=l),o}function _r(){return{name:Gl,contents:""}}function ho(e,t){return e?.cacheKey===t?.cacheKey&&e?.contents===t?.contents&&e?.name===t?.name&&e?.lang===t?.lang}function Ce(e){return{type:"text",value:e}}function T({tagName:e,children:t=[],properties:n={}}){return{type:"element",tagName:e,properties:n,children:t}}function gn({name:e,width:t=16,height:n=16,properties:i}){return T({tagName:"svg",properties:{width:t,height:n,viewBox:"0 0 16 16",...i},children:[T({tagName:"use",properties:{href:`#${e.replace(/^#/,"")}`}})]})}function zl(e){let t=e.children[0];for(;t!=null;){if(t.type==="element"&&t.tagName==="code")return t;"children"in t?t=t.children[0]:t=null}}function Bt(e){return T({tagName:"div",properties:{"data-gutter":""},children:e})}function jl(e,t,n,i={}){return T({tagName:"div",properties:{"data-line-type":e,"data-column-number":t,"data-line-index":n,...i},children:t!=null?[T({tagName:"span",properties:{"data-line-number-content":""},children:[Ce(`${t}`)]})]:void 0})}function he(e,t,n){return T({tagName:"div",properties:{"data-gutter-buffer":t,"data-buffer-size":n,"data-line-type":t==="annotation"?void 0:e,style:t==="annotation"?`grid-row: span ${n};`:`grid-row: span ${n};min-height:calc(${n} * 1lh);`}})}function Wl(){return T({tagName:"button",properties:{"data-utility-button":"",type:"button"},children:[gn({name:"diffs-icon-plus",properties:{"data-icon":""}})]})}function Vl(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side}function Gt(e){for(const t of e)if(t instanceof HTMLElement&&(t.hasAttribute("data-utility-button")||t.hasAttribute("data-gutter-utility-slot")||t.getAttribute("slot")==="gutter-utility-slot"||t.getAttribute("name")==="gutter-utility-slot"))return!0;return!1}const ql=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],Kl=/["&'<>`]/g,Xl=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Yl=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Ql=/[|\\{}()[\]^$+*?.]/g,Rr=new WeakMap;function Zl(e,t){if(e=e.replace(t.subset?Jl(t.subset):Kl,i),t.subset||t.escapeOnly)return e;return e.replace(Xl,n).replace(Yl,i);function n(r,s,o){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,o.charCodeAt(s+2),t)}function i(r,s,o){return t.format(r.charCodeAt(0),o.charCodeAt(s+1),t)}}function Jl(e){let t=Rr.get(e);return t||(t=ed(e),Rr.set(e,t)),t}function ed(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(Ql,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const td=/[\dA-Fa-f]/;function nd(e,t,n){const i="&#x"+e.toString(16).toUpperCase();return n&&t&&!td.test(String.fromCharCode(t))?i:i+";"}const id=/\d/;function rd(e,t,n){const i="&#"+String(e);return n&&t&&!id.test(String.fromCharCode(t))?i:i+";"}const sd=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],Vn={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},od=["cent","copy","divide","gt","lt","not","para","times"],fo={}.hasOwnProperty,Ei={};let zt;for(zt in Vn)fo.call(Vn,zt)&&(Ei[Vn[zt]]=zt);const ad=/[^\dA-Za-z]/;function ld(e,t,n,i){const r=String.fromCharCode(e);if(fo.call(Ei,r)){const s=Ei[r],o="&"+s;return n&&sd.includes(s)&&!od.includes(s)&&(!i||t&&t!==61&&ad.test(String.fromCharCode(t)))?o:o+";"}return""}function dd(e,t,n){let i=nd(e,t,n.omitOptionalSemicolons),r;if((n.useNamedReferences||n.useShortestReferences)&&(r=ld(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!r)&&n.useShortestReferences){const s=rd(e,t,n.omitOptionalSemicolons);s.length<i.length&&(i=s)}return r&&(!n.useShortestReferences||r.length<i.length)?r:i}function bt(e,t){return Zl(e,Object.assign({format:dd},t))}const cd=/^>|^->|<!--|-->|--!>|<!-$/g,ud=[">"],hd=["<",">"];function fd(e,t,n,i){return i.settings.bogusComments?"<?"+bt(e.value,Object.assign({},i.settings.characterReferences,{subset:ud}))+">":"<!--"+e.value.replace(cd,r)+"-->";function r(s){return bt(s,Object.assign({},i.settings.characterReferences,{subset:hd}))}}function pd(e,t,n,i){return"<!"+(i.settings.upperDoctype?"DOCTYPE":"doctype")+(i.settings.tightDoctype?"":" ")+"html>"}const K=go(1),po=go(-1),gd=[];function go(e){return t;function t(n,i,r){const s=n?n.children:gd;let o=(i||0)+e,l=s[o];if(!r)for(;l&&er(l);)o+=e,l=s[o];return l}}const md={}.hasOwnProperty;function mo(e){return t;function t(n,i,r){return md.call(e,n.tagName)&&e[n.tagName](n,i,r)}}const rr=mo({body:vd,caption:qn,colgroup:qn,dd:wd,dt:Sd,head:qn,html:bd,li:Cd,optgroup:xd,option:kd,p:yd,rp:Ir,rt:Ir,tbody:Ed,td:Tr,tfoot:Ad,th:Tr,thead:Ld,tr:_d});function qn(e,t,n){const i=K(n,t,!0);return!i||i.type!=="comment"&&!(i.type==="text"&&er(i.value.charAt(0)))}function bd(e,t,n){const i=K(n,t);return!i||i.type!=="comment"}function vd(e,t,n){const i=K(n,t);return!i||i.type!=="comment"}function yd(e,t,n){const i=K(n,t);return i?i.type==="element"&&(i.tagName==="address"||i.tagName==="article"||i.tagName==="aside"||i.tagName==="blockquote"||i.tagName==="details"||i.tagName==="div"||i.tagName==="dl"||i.tagName==="fieldset"||i.tagName==="figcaption"||i.tagName==="figure"||i.tagName==="footer"||i.tagName==="form"||i.tagName==="h1"||i.tagName==="h2"||i.tagName==="h3"||i.tagName==="h4"||i.tagName==="h5"||i.tagName==="h6"||i.tagName==="header"||i.tagName==="hgroup"||i.tagName==="hr"||i.tagName==="main"||i.tagName==="menu"||i.tagName==="nav"||i.tagName==="ol"||i.tagName==="p"||i.tagName==="pre"||i.tagName==="section"||i.tagName==="table"||i.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function Cd(e,t,n){const i=K(n,t);return!i||i.type==="element"&&i.tagName==="li"}function Sd(e,t,n){const i=K(n,t);return!!(i&&i.type==="element"&&(i.tagName==="dt"||i.tagName==="dd"))}function wd(e,t,n){const i=K(n,t);return!i||i.type==="element"&&(i.tagName==="dt"||i.tagName==="dd")}function Ir(e,t,n){const i=K(n,t);return!i||i.type==="element"&&(i.tagName==="rp"||i.tagName==="rt")}function xd(e,t,n){const i=K(n,t);return!i||i.type==="element"&&i.tagName==="optgroup"}function kd(e,t,n){const i=K(n,t);return!i||i.type==="element"&&(i.tagName==="option"||i.tagName==="optgroup")}function Ld(e,t,n){const i=K(n,t);return!!(i&&i.type==="element"&&(i.tagName==="tbody"||i.tagName==="tfoot"))}function Ed(e,t,n){const i=K(n,t);return!i||i.type==="element"&&(i.tagName==="tbody"||i.tagName==="tfoot")}function Ad(e,t,n){return!K(n,t)}function _d(e,t,n){const i=K(n,t);return!i||i.type==="element"&&i.tagName==="tr"}function Tr(e,t,n){const i=K(n,t);return!i||i.type==="element"&&(i.tagName==="td"||i.tagName==="th")}const Rd=mo({body:Pd,colgroup:Nd,head:Td,html:Id,tbody:Md});function Id(e){const t=K(e,-1);return!t||t.type!=="comment"}function Td(e){const t=new Set;for(const i of e.children)if(i.type==="element"&&(i.tagName==="base"||i.tagName==="title")){if(t.has(i.tagName))return!1;t.add(i.tagName)}const n=e.children[0];return!n||n.type==="element"}function Pd(e){const t=K(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&er(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Nd(e,t,n){const i=po(n,t),r=K(e,-1,!0);return n&&i&&i.type==="element"&&i.tagName==="colgroup"&&rr(i,n.children.indexOf(i),n)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function Md(e,t,n){const i=po(n,t),r=K(e,-1);return n&&i&&i.type==="element"&&(i.tagName==="thead"||i.tagName==="tbody")&&rr(i,n.children.indexOf(i),n)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}const jt={name:[[`
27
+ \f\r &/=>`.split(""),`
28
+ \f\r "&'/=>\``.split("")],[`\0
29
+ \f\r "&'/<=>`.split(""),`\0
30
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
31
+ \f\r &>`.split(""),`\0
32
+ \f\r "&'<=>\``.split("")],[`\0
33
+ \f\r "&'<=>\``.split(""),`\0
34
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Hd(e,t,n,i){const r=i.schema,s=r.space==="svg"?!1:i.settings.omitOptionalTags;let o=r.space==="svg"?i.settings.closeEmptyElements:i.settings.voids.includes(e.tagName.toLowerCase());const l=[];let a;r.space==="html"&&e.tagName==="svg"&&(i.schema=Xs);const d=Dd(i,e.properties),c=i.all(r.space==="html"&&e.tagName==="template"?e.content:e);return i.schema=r,c&&(o=!1),(d||!s||!Rd(e,t,n))&&(l.push("<",e.tagName,d?" "+d:""),o&&(r.space==="svg"||i.settings.closeSelfClosing)&&(a=d.charAt(d.length-1),(!i.settings.tightSelfClosing||a==="/"||a&&a!=='"'&&a!=="'")&&l.push(" "),l.push("/")),l.push(">")),l.push(c),!o&&(!s||!rr(e,t,n))&&l.push("</"+e.tagName+">"),l.join("")}function Dd(e,t){const n=[];let i=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){const s=Fd(e,r,t[r]);s&&n.push(s)}}for(;++i<n.length;){const s=e.settings.tightAttributes?n[i].charAt(n[i].length-1):void 0;i!==n.length-1&&s!=='"'&&s!=="'"&&(n[i]+=" ")}return n.join("")}function Fd(e,t,n){const i=Ba(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1;let o=e.quote,l;if(i.overloadedBoolean&&(n===i.attribute||n==="")?n=!0:(i.boolean||i.overloadedBoolean)&&(typeof n!="string"||n===i.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const a=bt(i.attribute,Object.assign({},e.settings.characterReferences,{subset:jt.name[r][s]}));return n===!0||(n=Array.isArray(n)?(i.commaSeparated?Ga:za)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?a:(e.settings.preferUnquoted&&(l=bt(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:jt.unquoted[r][s]}))),l!==n&&(e.settings.quoteSmart&&gr(n,o)>gr(n,e.alternative)&&(o=e.alternative),l=o+bt(n,Object.assign({},e.settings.characterReferences,{subset:(o==="'"?jt.single:jt.double)[r][s],attribute:!0}))+o),a+(l&&"="+l))}const $d=["<","&"];function bo(e,t,n,i){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:bt(e.value,Object.assign({},i.settings.characterReferences,{subset:$d}))}function Od(e,t,n,i){return i.settings.allowDangerousHtml?e.value:bo(e,t,n,i)}function Ud(e,t,n,i){return i.all(e)}const Bd=qa("type",{invalid:Gd,unknown:zd,handlers:{comment:fd,doctype:pd,element:Hd,raw:Od,root:Ud,text:bo}});function Gd(e){throw new Error("Expected node, not `"+e+"`")}function zd(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const jd={},Wd={},Vd=[];function Ie(e,t){const n=t||jd,i=n.quote||'"',r=i==='"'?"'":'"';if(i!=='"'&&i!=="'")throw new Error("Invalid quote `"+i+"`, expected `'` or `\"`");return{one:qd,all:Kd,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||ql,characterReferences:n.characterReferences||Wd,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Xs:ja,quote:i,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function qd(e,t,n){return Bd(e,t,n,this)}function Kd(e){const t=[],n=e&&e.children||Vd;let i=-1;for(;++i<n.length;)t[i]=this.one(n[i],i,e);return t.join("")}var Xd=class{mode;options;hoveredLine;hoveredToken;pre;gutterUtilityLine;gutterUtilityContainer;gutterUtilityButton;gutterUtilitySlot;interactiveLinesAttr=!1;interactiveLineNumbersAttr=!1;hasPointerListeners=!1;hasDocumentPointerListeners=!1;selectedRange=null;selectedRangeHighlightSide;selectedRangeLineNumberOnly=!1;editorActiveLine=null;editorActiveLineSide;editorLineNumberOnly=!1;proposedSelectedRange;renderedSelectedLinesState;renderedEditorActiveLineState;selectionAnchor;pointerSession={mode:"idle"};constructor(e,t){this.mode=e,this.options=t}setOptions(e){this.options=e}cleanUp(){this.pre?.removeEventListener("click",this.handlePointerClick),this.pre?.removeEventListener("pointerdown",this.handlePointerDown),this.pre?.removeEventListener("pointermove",this.handlePointerMove),this.pre?.removeEventListener("pointerleave",this.handlePointerLeave),this.pre?.removeAttribute("data-interactive-lines"),this.pre?.removeAttribute("data-interactive-line-numbers"),this.pre=void 0,this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.clearHoveredLine(),this.clearHoveredToken(),this.detachDocumentPointerListeners(),this.clearPointerSession(),Ci(this.renderSelection),this.interactiveLinesAttr=!1,this.interactiveLineNumbersAttr=!1,this.hasPointerListeners=!1,this.setSelectionDirty()}setup(e){this.setSelectionDirty();const{usesCustomGutterUtility:t=!1,enableGutterUtility:n=!1}=this.options;this.pre!==e&&(this.cleanUp(),this.pre=e),n?this.ensureGutterUtilityNode(t):this.gutterUtilityContainer!=null&&(this.gutterUtilityContainer.remove(),this.gutterUtilityLine=void 0,this.gutterUtilityContainer=void 0,this.gutterUtilityButton=void 0,this.gutterUtilitySlot=void 0,this.pointerSession.mode==="gutterSelecting"&&(this.clearPointerSession(),this.detachDocumentPointerListeners())),this.syncPointerListeners(e),this.updateInteractiveLineAttributes(),this.renderSelection(),this.placeUtility()}setSelectionDirty(){this.renderedSelectedLinesState=void 0,this.renderedEditorActiveLineState=void 0}isSelectionDirty(){return this.renderedSelectedLinesState===void 0||this.renderedEditorActiveLineState===void 0}setSelection(e,t){const n=!(e===this.selectedRange||wi(e??void 0,this.selectedRange??void 0)),i=t?.lineNumberOnly??!1,r=t?.activeLineSide!==this.selectedRangeHighlightSide||i!==this.selectedRangeLineNumberOnly;!this.isSelectionDirty()&&!n&&!r||(this.proposedSelectedRange=void 0,this.selectedRange=e,this.selectedRangeHighlightSide=t?.activeLineSide,this.selectedRangeLineNumberOnly=i,this.renderSelection(),this.placeUtility(),n&&t?.notify!==!1&&this.notifySelectionCommitted(e))}setEditorActiveLine(e,{lineNumberOnly:t=!1,side:n}={}){const i=e!==this.editorActiveLine,r=n!==this.editorActiveLineSide||t!==this.editorLineNumberOnly;!this.isSelectionDirty()&&!i&&!r||(this.editorActiveLine=e,this.editorActiveLineSide=n,this.editorLineNumberOnly=t,this.renderSelection())}getSelection(){return this.selectedRange}getHoveredLine=()=>{const e=this.gutterUtilityLine??this.hoveredLine;if(e!=null){if(this.mode==="diff"&&e.type==="diff-line")return{lineNumber:e.lineNumber,side:e.annotationSide};if(this.mode==="file"&&e.type==="line")return{lineNumber:e.lineNumber}}};handlePointerClick=e=>{const{onHunkExpand:t,onLineClick:n,onLineNumberClick:i,onTokenClick:r,onMergeConflictActionClick:s}=this.options;t==null&&n==null&&i==null&&s==null&&r==null||this.options.onGutterUtilityClick!=null&&Gt(e.composedPath())||(ke(this.options.__debugPointerEvents,"click","FileDiff.DEBUG.handlePointerClick:",e),this.handlePointerEvent({eventType:"click",event:e}))};handlePointerMove=e=>{if(e.pointerType!=="mouse")return;const{lineHoverHighlight:t="disabled",onLineEnter:n,onLineLeave:i,onTokenEnter:r,onTokenLeave:s,enableGutterUtility:o=!1}=this.options;t==="disabled"&&!o&&n==null&&i==null&&r==null&&s==null||(ke(this.options.__debugPointerEvents,"move","FileDiff.DEBUG.handlePointerMove:",e),this.handlePointerEvent({eventType:"move",event:e}))};handlePointerLeave=e=>{const{__debugPointerEvents:t}=this.options;if(ke(t,"move","FileDiff.DEBUG.handlePointerLeave: no event"),this.hoveredLine==null&&this.hoveredToken==null){ke(t,"move","FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");return}this.hoveredToken!=null&&(this.options.onTokenLeave?.(this.hoveredToken,e),this.clearHoveredToken()),this.hoveredLine!=null&&(this.options.onLineLeave?.({...this.hoveredLine,event:e}),this.clearHoveredLine()),this.placeUtility()};handlePointerEvent({eventType:e,event:t}){const{__debugPointerEvents:n}=this.options,i=t.composedPath();ke(n,e,"FileDiff.DEBUG.handlePointerEvent:",{eventType:e,composedPath:i});const r=this.resolvePointerTarget(i);ke(n,e,"FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:",r);const{onLineClick:s,onLineNumberClick:o,onLineEnter:l,onLineLeave:a,onTokenClick:d,onTokenEnter:c,onTokenLeave:u,onHunkExpand:h,onMergeConflictActionClick:f}=this.options;switch(e){case"move":{const p=Kn(r)&&this.hoveredLine?.lineElement===r.lineElement;ln(r)&&this.hoveredToken?.tokenElement===r.tokenElement||(this.hoveredToken!=null&&(u?.(this.hoveredToken,t),this.clearHoveredToken()),ln(r)&&(this.setHoveredToken(this.toTokenEventBaseProps(r)),c?.(this.hoveredToken,t))),p||(this.hoveredLine!=null&&(a?.({...this.hoveredLine,event:t}),this.clearHoveredLine()),Kn(r)?(this.setHoveredLine(this.toEventBaseProps(r)),this.placeUtility(),l?.({...this.hoveredLine,event:t})):this.placeUtility());break}case"click":{if(r==null)break;if(Zd(r)&&f!=null){f(r);break}if(Qd(r)&&h!=null){h(r.hunkIndex,r.all||t.shiftKey?"both":r.direction,r.all||t.shiftKey?Number.POSITIVE_INFINITY:void 0);break}if(!Kn(r))break;ln(r)&&d!=null&&d(this.toTokenEventBaseProps(r),t);const p=this.toEventBaseProps(r);o!=null&&r.numberColumn?o({...p,event:t}):s?.({...p,event:t});break}}}syncPointerListeners(e){const{__debugPointerEvents:t,lineHoverHighlight:n="disabled",onLineClick:i,onLineNumberClick:r,onLineEnter:s,onLineLeave:o,onTokenClick:l,onTokenEnter:a,onTokenLeave:d,onHunkExpand:c,onMergeConflictActionClick:u,enableGutterUtility:h=!1,enableLineSelection:f=!1,onGutterUtilityClick:p}=this.options,g=p!=null,v=n!=="disabled"||i!=null||r!=null||s!=null||o!=null||l!=null||a!=null||d!=null||c!=null||u!=null||h||f||g;v&&!this.hasPointerListeners?(e.addEventListener("click",this.handlePointerClick),e.addEventListener("pointerdown",this.handlePointerDown),e.addEventListener("pointermove",this.handlePointerMove),e.addEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!0,ke(t,"click","FileDiff.DEBUG.attachEventListeners: Attaching click events for:",(()=>{const y=[];return(t==="both"||t==="click")&&(i!=null&&y.push("onLineClick"),r!=null&&y.push("onLineNumberClick"),c!=null&&y.push("expandable hunk separators"),u!=null&&y.push("merge conflict actions")),y})()),ke(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer move event"),ke(t,"move","FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event")):!v&&this.hasPointerListeners&&(e.removeEventListener("click",this.handlePointerClick),e.removeEventListener("pointerdown",this.handlePointerDown),e.removeEventListener("pointermove",this.handlePointerMove),e.removeEventListener("pointerleave",this.handlePointerLeave),this.hasPointerListeners=!1);const m=this.pointerSession.mode==="selecting"||this.pointerSession.mode==="pendingSingleLineUnselect",b=this.pointerSession.mode==="gutterSelecting";(!f&&m||!g&&b)&&(this.clearPointerSession(),this.detachDocumentPointerListeners(),this.selectionAnchor=void 0,this.clearPendingSingleLineState())}updateInteractiveLineAttributes(){if(this.pre==null)return;const{onLineClick:e,onLineNumberClick:t,enableLineSelection:n=!1}=this.options,i=e!=null,r=t!=null||n;i&&!this.interactiveLinesAttr?(this.pre.setAttribute("data-interactive-lines",""),this.interactiveLinesAttr=!0):!i&&this.interactiveLinesAttr&&(this.pre.removeAttribute("data-interactive-lines"),this.interactiveLinesAttr=!1),r&&!this.interactiveLineNumbersAttr?(this.pre.setAttribute("data-interactive-line-numbers",""),this.interactiveLineNumbersAttr=!0):!r&&this.interactiveLineNumbersAttr&&(this.pre.removeAttribute("data-interactive-line-numbers"),this.interactiveLineNumbersAttr=!1)}handlePointerDown=e=>{if(e.pointerType==="mouse"&&e.button!==0||this.pre==null||this.pointerSession.mode!=="idle")return;const t=e.composedPath();Gt(t)&&this.options.onGutterUtilityClick!=null?this.startGutterSelectionFromPointerDown(e):(e.pointerType!=="mouse"&&this.revealUtilityFromGutterPath(t),this.startLineSelectionFromPointerDown(e))};startLineSelectionFromPointerDown(e){const{enableLineSelection:t=!1}=this.options;if(!t)return;const n=this.resolveSelectionInfo(e,{source:"event-path",requireNumberColumn:!0});if(n==null)return;const{pre:i}=this;if(i==null)return;const{lineNumber:r,eventSide:s,lineIndex:o}=n;if(e.shiftKey&&this.selectedRange!=null){const l=this.getIndexesFromSelection(this.selectedRange,i.getAttribute("data-diff-type")==="split");if(l==null)return;const a=l.start<=l.end?o>=l.start:o<=l.end;this.selectionAnchor={lineNumber:a?this.selectedRange.start:this.selectedRange.end,side:a?this.selectedRange.side:this.selectedRange.endSide??this.selectedRange.side},this.updateSelection(r,s,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners();return}if(this.selectedRange?.start===r&&this.selectedRange?.end===r){const l={lineNumber:r,side:s};this.selectionAnchor=l,this.pointerSession={mode:"pendingSingleLineUnselect",pointerId:e.pointerId,anchor:l,pending:l},this.attachDocumentPointerListeners();return}this.options.controlledSelection===!0?this.proposedSelectedRange=null:this.selectedRange=null,this.placeUtility(),this.selectionAnchor={lineNumber:r,side:s},this.updateSelection(r,s,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.pointerSession={mode:"selecting",pointerId:e.pointerId},this.attachDocumentPointerListeners()}startGutterSelectionFromPointerDown(e){const{onGutterUtilityClick:t}=this.options;if(t==null)return;const n=this.currentSelectionEnds(),i=n?.bottom??this.resolveSelectionPoint(e,{source:"event-path",excludeUtility:!1}),r=n?.top??i;i==null||r==null||(e.preventDefault(),e.stopPropagation(),this.pointerSession={mode:"gutterSelecting",pointerId:e.pointerId,anchor:r,current:i},this.selectionAnchor={lineNumber:r.lineNumber,side:r.side},this.updateSelection(i.lineNumber,i.side,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.attachDocumentPointerListeners())}handleDocumentPointerMove=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionPoint(e,{source:"coordinates-first"});if(t==null)return;this.pointerSession.current=t,this.updateSelection(t.lineNumber,t.side);return}case"selecting":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;this.updateSelection(t.lineNumber,t.eventSide);return}case"pendingSingleLineUnselect":{if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault();const t=this.resolveSelectionInfo(e,{source:"coordinates-first",requireNumberColumn:!1});if(t==null||this.selectionAnchor==null)return;const n={lineNumber:t.lineNumber,side:t.eventSide};if(Vl(this.pointerSession.pending,n))return;this.updateSelection(t.lineNumber,t.eventSide,!1),this.notifySelectionStart(this.getCurrentSelectionRange()),this.notifySelectionChangeDelta(),this.pointerSession={mode:"selecting",pointerId:e.pointerId};return}}};handleDocumentPointerUp=e=>{const{onGutterUtilityClick:t}=this.options;switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":{const{pointerSession:n}=this;if(e.pointerId!==n.pointerId)return;e.preventDefault();const i=this.resolveSelectionPoint(e,{source:"coordinates-first"});i!=null&&(n.current=i,this.updateSelection(i.lineNumber,i.side));const r=this.buildSelectedLineRange(n.anchor,n.current);t?.({...r}),this.selectionAnchor=void 0,this.notifySelectionEnd(r),this.notifySelectionCommitted(r),this.clearProposedSelection(),this.clearPointerSession(),this.detachDocumentPointerListeners();return}case"pendingSingleLineUnselect":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.updateSelection(null,void 0,!1),this.selectionAnchor=void 0,this.clearPendingSingleLineState(),this.detachDocumentPointerListeners(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection();return;case"selecting":if(e.pointerId!==this.pointerSession.pointerId)return;e.preventDefault(),this.selectionAnchor=void 0,this.detachDocumentPointerListeners(),this.clearPointerSession(),this.notifySelectionEnd(this.getCurrentSelectionRange()),this.notifySelectionCommitted(this.getCurrentSelectionRange()),this.clearProposedSelection()}};handleDocumentPointerCancel=e=>{switch(this.pointerSession.mode){case"idle":return;case"gutterSelecting":case"selecting":case"pendingSingleLineUnselect":if("pointerId"in this.pointerSession&&e.pointerId!==this.pointerSession.pointerId)return;this.selectionAnchor=void 0,this.clearProposedSelection(),this.clearPendingSingleLineState(),this.clearPointerSession(),this.detachDocumentPointerListeners()}};clearHoveredLine(){this.hoveredLine!=null&&(this.hoveredLine.lineElement.removeAttribute("data-hovered"),this.hoveredLine.numberElement.removeAttribute("data-hovered"),this.hoveredLine=void 0)}setHoveredLine(e){const{lineHoverHighlight:t="disabled"}=this.options;this.hoveredLine!=null&&this.clearHoveredLine(),this.hoveredLine=e,t!=="disabled"&&((t==="both"||t==="line")&&this.hoveredLine.lineElement.setAttribute("data-hovered",""),(t==="both"||t==="number")&&this.hoveredLine.numberElement.setAttribute("data-hovered",""))}clearHoveredToken(){this.hoveredToken!=null&&(this.hoveredToken=void 0)}setHoveredToken(e){this.hoveredToken!=null&&this.clearHoveredToken(),this.hoveredToken=e}ensureGutterUtilityNode(e){if(this.gutterUtilityContainer==null&&(this.gutterUtilityContainer=document.createElement("div"),this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot","")),e)this.gutterUtilityButton!=null&&(this.gutterUtilityButton.remove(),this.gutterUtilityButton=void 0),this.gutterUtilitySlot==null&&(this.gutterUtilitySlot=document.createElement("slot"),this.gutterUtilitySlot.name="gutter-utility-slot"),this.gutterUtilitySlot.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);else{if(this.gutterUtilitySlot?.remove(),this.gutterUtilitySlot=void 0,this.gutterUtilityButton==null){const t=document.createElement("div");t.innerHTML=Ie(Wl());const n=t.firstElementChild;if(!(n instanceof HTMLButtonElement))throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");n.remove(),this.gutterUtilityButton=n}this.gutterUtilityButton.parentNode!==this.gutterUtilityContainer&&this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton)}}revealUtilityFromGutterPath(e){if(this.placeUtilityFromSelection())return;const t=this.resolvePointerTarget(e);xt(t)&&t.numberColumn&&this.showUtilityOnLine(this.toEventBaseProps(t))}placeUtility(){if(!this.placeUtilityFromSelection()){if(this.hoveredLine!=null){this.showUtilityOnLine(this.hoveredLine);return}this.hideUtility()}}placeUtilityFromSelection(){const e=this.currentSelectionEnds();if(e==null)return!1;const t=this.targetForSelectionPoint(e.bottom);return t==null?this.hideUtility():this.showUtilityOnLine(this.toEventBaseProps(t)),!0}showUtilityOnLine(e){this.gutterUtilityContainer!=null&&(this.gutterUtilityLine=e,e.numberElement.appendChild(this.gutterUtilityContainer))}hideUtility(){this.gutterUtilityContainer?.remove(),this.gutterUtilityLine=void 0}currentSelectionEnds(){const e=this.getCurrentSelectionRange();return e==null?void 0:this.selectionEnds(e)}selectionEnds(e){const t={lineNumber:e.start,side:e.side},n={lineNumber:e.end,side:e.endSide??e.side},i=this.selectionPointRowIndex(t),r=this.selectionPointRowIndex(n);if(!(i==null||r==null))return i>r?{top:n,bottom:t}:{top:t,bottom:n}}selectionPointRowIndex(e){const t=this.getLineIndex(e.lineNumber,e.side);if(t!=null)return this.isSplitDiff()?t[1]:t[0]}targetForSelectionPoint(e){if(this.pre==null)return;const t=this.getLineIndex(e.lineNumber,e.side);if(t==null)return;const n=this.mode==="diff"?`${t[0]},${t[1]}`:`${t[0]}`,i=this.pre.querySelectorAll(`[data-column-number="${e.lineNumber}"][data-line-index="${n}"]`);for(const r of i){if(!(r instanceof HTMLElement))continue;const s=this.resolvePointerTarget(Wt(r));if(xt(s)&&!(this.mode==="diff"&&e.side!=null&&s.side!==e.side))return s}}attachDocumentPointerListeners(){this.hasDocumentPointerListeners||(document.addEventListener("pointermove",this.handleDocumentPointerMove),document.addEventListener("pointerup",this.handleDocumentPointerUp),document.addEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!0)}detachDocumentPointerListeners(){this.hasDocumentPointerListeners&&(document.removeEventListener("pointermove",this.handleDocumentPointerMove),document.removeEventListener("pointerup",this.handleDocumentPointerUp),document.removeEventListener("pointercancel",this.handleDocumentPointerCancel),this.hasDocumentPointerListeners=!1)}clearPointerSession(){this.pointerSession={mode:"idle"}}clearPendingSingleLineState(){this.pointerSession.mode==="pendingSingleLineUnselect"&&(this.pointerSession={mode:"idle"})}selectionInfoFromPath(e,t){const n=this.resolvePointerTarget(e);if(xt(n)&&!(t&&!n.numberColumn)&&n.splitLineIndex!=null)return{lineIndex:n.splitLineIndex,lineNumber:n.lineNumber,eventSide:this.mode==="diff"?n.side:void 0}}resolveSelectionInfo(e,t){const n=this.resolveSelectionPath(e,t);return n!=null?this.selectionInfoFromPath(n,t.requireNumberColumn):void 0}selectionPointFromPath(e){const t=this.resolvePointerTarget(e);if(xt(t))return{lineNumber:t.lineNumber,side:this.mode==="diff"?t.side:void 0}}resolveSelectionPoint(e,t){const n=this.resolveSelectionPath(e,t);return n!=null?this.selectionPointFromPath(n):void 0}resolveSelectionPath(e,t){const n=t.excludeUtility!==!1;switch(t.source){case"event-path":return this.pathFromEventPath(e.composedPath(),n);case"coordinates-first":{const i=this.pathFromCoordinates(e,n);return i!==void 0?i??void 0:this.pathFromEventPath(e.composedPath(),n)}}}pathFromCoordinates(e,t){const n=this.hitTest(e);if(n!==void 0)return n===null?null:this.pathFromElement(n,t)??null}pathFromEventPath(e,t){if(!(t&&Gt(e))){for(const n of e)if(n instanceof Element)return this.pathFromElement(n,t)}}pathFromElement(e,t){const n=Wt(e);if(t&&Gt(n))return;const i=ec(e);return i!=null?Wt(i):this.pathFromAnnotationSlot(e)}pathFromAnnotationSlot(e){const t=nc(tc(e));if(t==null)return;const n=this.targetForSelectionPoint(t);return n!=null?Wt(n.lineElement):void 0}hitTest(e){if(!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return;const t=this.pre?.getRootNode(),n=Mr(t)?t:Mr(document)?document:void 0;if(n!=null)return n.elementFromPoint(e.clientX,e.clientY)}getLineIndex(e,t){const{getLineIndex:n}=this.options;return n!=null?n(e,t):[e-1,e-1]}getCurrentSelectionRange(){return this.proposedSelectedRange!==void 0?this.proposedSelectedRange:this.selectedRange}clearProposedSelection(){this.proposedSelectedRange=void 0}updateSelection(e,t,n=!0){const i=this.getCurrentSelectionRange();let r;if(e==null)r=null;else{const s=this.selectionAnchor?.side??t,o=this.selectionAnchor?.lineNumber??e;r=this.buildSelectionRange(o,e,s,t)}wi(i??void 0,r??void 0)||(this.selectedRangeHighlightSide=void 0,this.selectedRangeLineNumberOnly=!1,this.options.controlledSelection===!0?this.proposedSelectedRange=r:(this.selectedRange=r,no(this.renderSelection)),this.placeUtility(),n&&this.notifySelectionChangeDelta())}getIndexesFromSelection(e,t){if(this.pre==null)return;const n=this.getLineIndex(e.start,e.side),i=this.getLineIndex(e.end,e.endSide??e.side);return n!=null&&i!=null?{start:t?n[1]:n[0],end:t?i[1]:i[0]}:void 0}getSelectionRenderState(){return{selectedLines:{range:this.selectedRange,highlightSide:this.selectedRangeHighlightSide,lineNumberOnly:this.selectedRangeLineNumberOnly},editorActiveLine:{range:this.editorActiveLine==null?null:{start:this.editorActiveLine,end:this.editorActiveLine,side:this.editorActiveLineSide},highlightSide:this.editorActiveLineSide,lineNumberOnly:this.editorLineNumberOnly}}}resolveLineRenderRange(e,t,n){if(e.range==null)return;const i=this.getIndexesFromSelection(e.range,t);if(i==null)throw console.error({rowRange:i,range:e.range}),new Error(`InteractionManager.renderSelection: No valid ${n} rowRange`);return i}getLineRenderColumns(e,t,n,i){if(this.pre==null||t==null&&i==null)return[];const{children:r}=this.pre;if(r.length>2)throw console.error(r),new Error("InteractionManager.renderSelection: Somehow there are more than 2 code elements...");const s=[];for(const o of r){const l=o.hasAttribute("data-deletions")?"deletions":o.hasAttribute("data-additions")?"additions":void 0,a=e!=null&&t!=null&&(e.highlightSide==null||l==null||e.highlightSide===l),d=n!=null&&i!=null&&(n.highlightSide==null||l==null||n.highlightSide===l);if(!a&&!d)continue;const[c,u]=o.children;if(!(c instanceof HTMLElement)||!(u instanceof HTMLElement))throw new Error("InteractionManager.renderSelection: missing gutter or content element");if(u.children.length!==c.children.length)throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");s.push({content:u,gutter:c,renderEditorActiveLine:d,renderSelectedLines:a})}return s}renderSelection=()=>{Ci(this.renderSelection);const e=this.getSelectionRenderState();if(this.pre==null)return;const{editorActiveLine:t,selectedLines:n}=e,i=!Hr(this.renderedSelectedLinesState,n),r=!Hr(this.renderedEditorActiveLineState,t);if(!i&&!r)return;i&&(this.renderedSelectedLinesState=void 0),r&&(this.renderedEditorActiveLineState=void 0);const s=this.pre.getAttribute("data-diff-type")==="split",o=i?this.resolveLineRenderRange(n,s,"selected-lines"):void 0,l=r?this.resolveLineRenderRange(t,s,"editor-active-line"):void 0,a=this.getLineRenderColumns(i?n:void 0,o,r?t:void 0,l),d=n.range==null||a.some(g=>g.renderSelectedLines),c=t.range==null||a.some(g=>g.renderEditorActiveLine);if(i)for(const g of this.pre.querySelectorAll("[data-selected-line]"))g.removeAttribute("data-selected-line");if(r)for(const g of this.pre.querySelectorAll("[data-editor-active-line]"))g.removeAttribute("data-editor-active-line");const u=o==null?void 0:Math.min(o.start,o.end),h=o==null?void 0:Math.max(o.start,o.end),f=u===h,p=l?.start;for(const g of a){const{content:v,gutter:m,renderEditorActiveLine:b,renderSelectedLines:y}=g,S=Math.max(y?h??-1/0:-1/0,b?p??-1/0:-1/0),C=v.children.length;for(let w=0;w<C;w++){const x=v.children[w],E=m.children[w];if(!(x instanceof HTMLElement)||!(E instanceof HTMLElement))continue;const k=this.parseLineIndex(x,s);if((k??0)>S)break;if(k!=null){if(y&&u!=null&&h!=null&&k>=u&&k<=h){let _=f?"single":k===u?"first":k===h?"last":"";E.setAttribute("data-selected-line",_),n.lineNumberOnly||(x.setAttribute("data-selected-line",_),E.nextSibling instanceof HTMLElement&&x.nextSibling instanceof HTMLElement&&(x.nextSibling.hasAttribute("data-line-annotation")||x.nextSibling.hasAttribute("data-merge-conflict-actions"))&&(f?(_="last",x.setAttribute("data-selected-line","first")):k===u?_="":k===h&&x.setAttribute("data-selected-line",""),x.nextSibling.setAttribute("data-selected-line",_),E.nextSibling.setAttribute("data-selected-line",_)))}b&&k===p&&(E.setAttribute("data-editor-active-line",""),t.lineNumberOnly||x.setAttribute("data-editor-active-line",""))}}}i&&d&&(this.renderedSelectedLinesState=n),r&&c&&(this.renderedEditorActiveLineState=t)};notifySelectionCommitted(e){this.options.onLineSelected?.(e)}notifySelectionChangeDelta(){this.options.onLineSelectionChange?.(this.getCurrentSelectionRange()??null)}notifySelectionStart(e){this.options.onLineSelectionStart?.(e)}notifySelectionEnd(e){this.options.onLineSelectionEnd?.(e)}toEventBaseProps(e){return this.mode==="file"?{type:"line",lineElement:e.lineElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn,numberElement:e.numberElement}:{type:"diff-line",annotationSide:e.side,lineType:e.lineType,lineElement:e.lineElement,numberElement:e.numberElement,lineNumber:e.lineNumber,numberColumn:e.numberColumn}}toTokenEventBaseProps({lineCharEnd:e,lineCharStart:t,lineNumber:n,side:i,tokenElement:r,tokenText:s}){return this.mode==="file"?{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,tokenElement:r,tokenText:s}:{type:"token",lineCharEnd:e,lineCharStart:t,lineNumber:n,side:i,tokenElement:r,tokenText:s}}buildSelectedLineRange(e,t){return this.buildSelectionRange(e.lineNumber,t.lineNumber,e.side,t.side)}buildSelectionRange(e,t,n,i){return{start:e,end:t,...n!=null?{side:n}:{},...n!==i&&i!=null?{endSide:i}:{}}}resolvePointerTarget(e){let t=!1,n,i,r,s,o,l,a,d,c,u;for(const f of e){if(!(f instanceof HTMLElement))continue;if(u==null&&f.hasAttribute("data-merge-conflict-action")){const m=f.getAttribute("data-merge-conflict-action")??void 0,b=f.getAttribute("data-merge-conflict-conflict-index")??void 0,y=b!=null?Number.parseInt(b,10):NaN;Jd(m)&&Number.isFinite(y)&&(u={kind:"merge-conflict-action",resolution:m,conflictIndex:y})}if(l==null&&f.hasAttribute("data-char")){l=f;const m=f.getAttribute("data-char");if(m!=null){const b=Number.parseInt(m,10);if(!Number.isNaN(b)){const y=f.textContent??"",S=b+y.length;(y.trim()!==""||this.options.enableTokenInteractionsOnWhitespace===!0)&&(a={tokenElement:l,lineCharStart:b,lineCharEnd:S,tokenText:y});continue}}}const p=o==null?f.getAttribute("data-column-number")??void 0:void 0;if(p!=null){o=f,c=Number.parseInt(p,10),t=!0,n=Fr(f),s=f.getAttribute("data-line-index")??void 0;continue}const g=r==null?f.getAttribute("data-line")??void 0:void 0;if(g!=null){r=f,c=Number.parseInt(g,10),n=Fr(f),s=f.getAttribute("data-line-index")??void 0;continue}if(d==null&&(f.hasAttribute("data-expand-button")||f.hasAttribute("data-unmodified-lines"))){d={hunkIndex:void 0,direction:f.hasAttribute("data-expand-up")?"up":f.hasAttribute("data-expand-down")?"down":"both",all:f.hasAttribute("data-expand-all-button")};continue}const v=d!=null?f.getAttribute("data-expand-index")??void 0:void 0;if(d!=null&&v!=null){const m=Number.parseInt(v,10);Number.isNaN(m)||(d.hunkIndex=m);continue}if(i==null&&f.hasAttribute("data-code")){i=f;break}}if(u!=null)return u;if(d?.hunkIndex!=null)return{type:"line-info",hunkIndex:d.hunkIndex,direction:d.direction,all:d.all};if(r??=s!=null?Nr(i,`[data-line][data-line-index="${s}"]`):void 0,o??=s!=null?Nr(i,`[data-column-number][data-line-index="${s}"]`):void 0,i==null||r==null||o==null||n==null||c==null||Number.isNaN(c))return;const h=this.parseLineIndex(r,this.isSplitDiff());return a!=null?this.mode==="file"?{kind:"token",lineType:n,lineElement:r,lineNumber:c,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:h,...a}:{kind:"token",lineType:n,lineElement:r,lineNumber:c,numberColumn:t,numberElement:o,side:Dr(n,i),splitLineIndex:h,...a}:this.mode==="file"?{kind:"line",lineType:n,lineElement:r,lineNumber:c,numberColumn:t,numberElement:o,side:void 0,splitLineIndex:h}:{kind:"line",lineType:n,lineElement:r,lineNumber:c,numberColumn:t,numberElement:o,side:Dr(n,i),splitLineIndex:h}}isSplitDiff(){return this.pre?.getAttribute("data-diff-type")==="split"}parseLineIndex(e,t){const n=(e.getAttribute("data-line-index")??"").split(",").map(i=>Number.parseInt(i,10)).filter(i=>!Number.isNaN(i));if(t&&n.length===2)return n[1];if(!t)return n[0]}};function Pr({enableTokenInteractionsOnWhitespace:e,enableGutterUtility:t,lineHoverHighlight:n,onGutterUtilityClick:i,onLineClick:r,onLineEnter:s,onLineLeave:o,onLineNumberClick:l,onTokenClick:a,onTokenEnter:d,onTokenLeave:c,renderGutterUtility:u,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:p,onLineSelected:g,onLineSelectionStart:v,onLineSelectionChange:m,onLineSelectionEnd:b},y,S,C){return{enableTokenInteractionsOnWhitespace:e,enableGutterUtility:Yd({enableGutterUtility:t,renderGutterUtility:u,onGutterUtilityClick:i}),usesCustomGutterUtility:u!=null,lineHoverHighlight:n,onGutterUtilityClick:i,onHunkExpand:y,onMergeConflictActionClick:C,onLineClick:r,onLineEnter:s,onLineLeave:o,onLineNumberClick:l,onTokenClick:a,onTokenEnter:d,onTokenLeave:c,__debugPointerEvents:h,enableLineSelection:f,controlledSelection:p,onLineSelected:g,onLineSelectionStart:v,onLineSelectionChange:m,onLineSelectionEnd:b,getLineIndex:S}}function Yd({enableGutterUtility:e,renderGutterUtility:t,onGutterUtilityClick:n}){if(n!=null&&t!=null)throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");return e??!1}function xt(e){return e!=null&&"kind"in e&&e.kind==="line"}function ln(e){return e!=null&&"kind"in e&&e.kind==="token"}function Kn(e){return xt(e)||ln(e)}function Qd(e){return"type"in e&&e.type==="line-info"}function Zd(e){return"kind"in e&&e.kind==="merge-conflict-action"}function Jd(e){return e==="current"||e==="incoming"||e==="both"}function Nr(e,t){const n=e?.querySelector(t);return n instanceof HTMLElement?n:void 0}function Wt(e){const t=[];let n=e;for(;n!=null;)t.push(n),n=n.parentNode;return t}function ec(e){const t=e.closest("[data-line], [data-column-number]");if(t instanceof HTMLElement)return t;const n=e.closest('[data-line-annotation], [data-gutter-buffer="annotation"]');if(!(n instanceof HTMLElement))return;const i=n.previousElementSibling;return i instanceof HTMLElement&&(i.hasAttribute("data-line")||i.hasAttribute("data-column-number"))?i:void 0}function tc(e){const t=e.closest('[slot^="annotation-"]');if(t instanceof HTMLElement)return t.getAttribute("slot")??void 0;if(e instanceof HTMLElement){const n=e.getAttribute("name")??void 0;return n!=null&&n.startsWith("annotation-")?n:void 0}}function nc(e){if(e==null)return;const t=/^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(e);if(t==null)return;const n=Number.parseInt(t[2],10);if(!(!Number.isFinite(n)||n<=0))return{lineNumber:n,side:t[1]}}function Mr(e){return e!=null&&typeof e.elementFromPoint=="function"}function ic(e,t){return e===t||wi(e??void 0,t??void 0)}function Hr(e,t){return e?.highlightSide===t.highlightSide&&e?.lineNumberOnly===t.lineNumberOnly&&ic(e?.range??null,t.range)}function Dr(e,t){switch(e){case"change-deletion":return"deletions";case"change-addition":return"additions";default:return t.hasAttribute("data-deletions")?"deletions":"additions"}}function Fr(e){const t=e.getAttribute("data-line-type");if(t!=null)switch(t){case"change-deletion":case"change-addition":case"context":case"context-expanded":return t;default:return}}function ke(e="none",t,...n){switch(e){case"none":return;case"both":break;case"click":if(t!=="click")return;break;case"move":if(t!=="move")return;break}console.log(...n)}var rc=class _e{static resizeObserver;static managersByElement=new Map;static getResizeObserver(){const t=_e.resizeObserver??new ResizeObserver(_e.handleSharedResizeEntries);return _e.resizeObserver=t,t}static handleSharedResizeEntries(t){const n=new Map;for(const i of t){const r=_e.managersByElement.get(i.target);if(r==null)continue;const s=n.get(r);s==null?n.set(r,[i]):s.push(i)}for(const[i,r]of n)i.handleResizeEntries(r)}observedNodes=new Map;setup(t,{disableAnnotations:n,columnVariables:i="apply"}){const r=new Set,s=i==="apply";let o=0;const l=new Map(this.observedNodes);this.observedNodes.clear();for(const a of t.children){if(o===2)break;const d=(()=>{if(a instanceof HTMLElement&&a.tagName==="CODE")return a})();if(d==null)continue;o++;let c=l.get(d);if(c!=null&&c.type!=="code")throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");let u=d.firstElementChild;u instanceof HTMLElement||(u=null),c!=null?(this.observedNodes.set(d,c),l.delete(d),c.numberElement!==u?(c.numberElement!=null&&(this.unobserve(c.numberElement),l.delete(c.numberElement)),u!=null&&(this.observe(u),l.delete(u),this.observedNodes.set(u,c)),c.numberElement=u,c.numberWidth=0):c.numberElement!=null?(l.delete(c.numberElement),this.observedNodes.set(c.numberElement,c)):c.numberWidth=0,ac(c,s)):(c={type:"code",codeElement:d,numberElement:u,codeWidth:"auto",numberWidth:0,applyColumnVariables:s},this.observedNodes.set(d,c),this.observe(d),u!=null&&(this.observedNodes.set(u,c),this.observe(u)))}if(o>1&&!n){const a=t.querySelectorAll('[data-line-annotation*=","]'),d=new Map;for(const c of a){if(!(c instanceof HTMLElement))continue;const u=c.getAttribute("data-line-annotation")??"";if(!/^-?\d+,-?\d+$/.test(u)){console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation",{lineAnnotation:u,element:c});continue}let h=d.get(u);h==null&&(h=[],d.set(u,h)),h.push(c)}for(const[c,u]of d){if(u.length!==2){console.error("DiffFileRenderer.setupResizeObserver: Bad Pair",c,u);continue}const[h,f]=u,p=h.firstElementChild,g=f.firstElementChild;if(!(h instanceof HTMLElement)||!(f instanceof HTMLElement)||!(p instanceof HTMLElement)||!(g instanceof HTMLElement))continue;let v=l.get(p);if(v!=null){this.observedNodes.set(p,v),this.observedNodes.set(g,v),l.delete(p),l.delete(g);continue}const m=p.getBoundingClientRect().height,b=g.getBoundingClientRect().height;v={type:"annotations",column1:{container:h,child:p,childHeight:m},column2:{container:f,child:g,childHeight:b},currentHeight:"auto"},r.add({child1:p,child2:g,item:v,newHeight:Math.max(m,b)})}for(const c of r)this.applyNewHeight(c.item,c.newHeight),this.observedNodes.set(c.child1,c.item),this.observedNodes.set(c.child2,c.item),this.observe(c.child1),this.observe(c.child2);r.clear()}for(const[a,d]of l)this.unobserve(a),d.type==="code"?lc(d):dc(d);l.clear()}cleanUp(){for(const t of this.observedNodes.keys())this.unobserve(t);this.observedNodes.clear()}observe(t){const{managersByElement:n}=_e,i=n.get(t);if(i!==this){if(i!=null&&i!==this)throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");n.set(t,this),_e.getResizeObserver().observe(t)}}unobserve(t){const{managersByElement:n,resizeObserver:i}=_e,r=n.get(t);if(r!=null){if(r!==this)throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");n.delete(t),i?.unobserve(t),i!=null&&n.size===0&&(i.disconnect(),_e.resizeObserver=void 0)}}handleResizeEntries(t){const n=new Map,i=new Set;for(const r of t){const{target:s,borderBoxSize:o,contentBoxSize:l}=r;if(!(s instanceof HTMLElement)){console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver",r);continue}const a=this.observedNodes.get(s);if(a==null){console.error("ResizeManager.handleResizeEntries: Not a valid observed node",r);continue}if(a.type==="annotations"){const d=(()=>{if(s===a.column1.child)return a.column1;if(s===a.column2.child)return a.column2})();if(d==null){console.error("ResizeManager.handleResizeEntries: Couldn't find a column for",{item:a,target:s});continue}d.childHeight=o[0].blockSize,i.add(a)}else if(a.type==="code"){const d=n.get(a)??{},c=l[0].inlineSize;s===a.codeElement?d.codeInlineSize=c:s===a.numberElement&&(d.numberInlineSize=c),n.set(a,d)}}this.applyAnnotationUpdates(i),i.clear(),this.applyColumnUpdates(n),n.clear()}applyAnnotationUpdates(t){for(const n of t)this.applyNewHeight(n,Math.max(n.column1.childHeight,n.column2.childHeight))}applyColumnUpdates=t=>{for(const[n,i]of t){const r=i.codeInlineSize!=null?sc(i.codeInlineSize):n.codeWidth,s=i.numberInlineSize!=null?oc(i.numberInlineSize):n.numberWidth,o=r!==n.codeWidth,l=s!==n.numberWidth;!o&&!l||(n.codeWidth=r,n.numberWidth=s,n.applyColumnVariables&&vo(n,{codeWidthChanged:o,numberWidthChanged:l}))}};applyNewHeight(t,n){n!==t.currentHeight&&(t.currentHeight=Math.max(n,0),t.column1.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`),t.column2.container.style.setProperty("--diffs-annotation-min-height",`${t.currentHeight}px`))}};function sc(e){const t=Math.max(Math.floor(e),0);return t===0?"auto":t}function oc(e){return Math.max(Math.ceil(e),0)}function ac(e,t){e.applyColumnVariables!==t&&(e.applyColumnVariables=t,t?vo(e,{codeWidthChanged:!0,numberWidthChanged:!0}):yo(e))}function vo(e,{codeWidthChanged:t,numberWidthChanged:n}){const{codeElement:i,codeWidth:r,numberWidth:s}=e;if(t&&i.style.setProperty("--diffs-column-width",`${typeof r=="number"?`${r}px`:"auto"}`),n&&i.style.setProperty("--diffs-column-number-width",`${s===0?"auto":`${s}px`}`),t||n&&r!=="auto"){const o=typeof r=="number"?Math.max(r-s,0):0;i.style.setProperty("--diffs-column-content-width",`${o>0?`${o}px`:"auto"}`)}}function yo(e){e.codeElement.style.removeProperty("--diffs-column-content-width"),e.codeElement.style.removeProperty("--diffs-column-number-width"),e.codeElement.style.removeProperty("--diffs-column-width")}function lc(e){e.codeElement.isConnected&&yo(e)}function dc(e){e.column1.container.isConnected&&e.column1.container.style.removeProperty("--diffs-annotation-min-height"),e.column2.container.isConnected&&e.column2.container.style.removeProperty("--diffs-annotation-min-height")}const _t=new Map,Xn=new Map,cc=new Map,Ai=new Set;function $r(e){for(const t of Array.isArray(e)?e:[e])if(!(t==="text"||t==="ansi")&&!Ai.has(t))return!1;return!0}function Or(e,t){e=Array.isArray(e)?e:[e];for(const n of e){if(Ai.has(n.name))continue;let i=_t.get(n.name);i==null&&(i=n,_t.set(n.name,i)),Ai.add(i.name),t.loadLanguageSync(i.data)}}function Co(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}var O=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function uc(e){return sr(e)}function sr(e){return Array.isArray(e)?hc(e):e instanceof RegExp?e:typeof e=="object"?fc(e):e}function hc(e){let t=[];for(let n=0,i=e.length;n<i;n++)t[n]=sr(e[n]);return t}function fc(e){let t={};for(let n in e)t[n]=sr(e[n]);return t}function So(e,...t){return t.forEach(n=>{for(let i in n)e[i]=n[i]}),e}function wo(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?wo(e.substring(0,e.length-1)):e.substr(~t+1)}var Yn=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Vt=class{static hasCaptures(e){return e===null?!1:(Yn.lastIndex=0,Yn.test(e))}static replaceCaptures(e,t,n){return e.replace(Yn,(i,r,s,o)=>{let l=n[parseInt(r||s,10)];if(l){let a=t.substring(l.start,l.end);for(;a[0]===".";)a=a.substring(1);switch(o){case"downcase":return a.toLowerCase();case"upcase":return a.toUpperCase();default:return a}}else return i})}};function xo(e,t){return e<t?-1:e>t?1:0}function ko(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,i=t.length;if(n===i){for(let r=0;r<n;r++){let s=xo(e[r],t[r]);if(s!==0)return s}return 0}return n-i}function Ur(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Lo(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Eo=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},mn=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(mc(e),t)}static createFromParsedTheme(e,t){return vc(e,t)}_cachedMatchRoot=new Eo(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,i=this._cachedMatchRoot.get(t).find(r=>pc(e.parent,r.parentScopes));return i?new Ao(i.fontStyle,i.foreground,i.background):null}},Qn=class dn{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const i of n)t=new dn(t,i);return t}static from(...t){let n=null;for(let i=0;i<t.length;i++)n=new dn(n,t[i]);return n}push(t){return new dn(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let i=this;for(;i&&i!==t;)n.push(i.scopeName),i=i.parent;return i===t?n.reverse():void 0}};function pc(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let i=t[n],r=!1;if(i===">"){if(n===t.length-1)return!1;i=t[++n],r=!0}for(;e&&!gc(e.scopeName,i);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function gc(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Ao=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function mc(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],i=0;for(let r=0,s=t.length;r<s;r++){let o=t[r];if(!o.settings)continue;let l;if(typeof o.scope=="string"){let u=o.scope;u=u.replace(/^[,]+/,""),u=u.replace(/[,]+$/,""),l=u.split(",")}else Array.isArray(o.scope)?l=o.scope:l=[""];let a=-1;if(typeof o.settings.fontStyle=="string"){a=0;let u=o.settings.fontStyle.split(" ");for(let h=0,f=u.length;h<f;h++)switch(u[h]){case"italic":a=a|1;break;case"bold":a=a|2;break;case"underline":a=a|4;break;case"strikethrough":a=a|8;break}}let d=null;typeof o.settings.foreground=="string"&&Ur(o.settings.foreground)&&(d=o.settings.foreground);let c=null;typeof o.settings.background=="string"&&Ur(o.settings.background)&&(c=o.settings.background);for(let u=0,h=l.length;u<h;u++){let p=l[u].trim().split(" "),g=p[p.length-1],v=null;p.length>1&&(v=p.slice(0,p.length-1),v.reverse()),n[i++]=new bc(g,v,r,a,d,c)}}return n}var bc=class{constructor(e,t,n,i,r,s){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=i,this.foreground=r,this.background=s}},J=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(J||{});function vc(e,t){e.sort((a,d)=>{let c=xo(a.scope,d.scope);return c!==0||(c=ko(a.parentScopes,d.parentScopes),c!==0)?c:a.index-d.index});let n=0,i="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let a=e.shift();a.fontStyle!==-1&&(n=a.fontStyle),a.foreground!==null&&(i=a.foreground),a.background!==null&&(r=a.background)}let s=new yc(t),o=new Ao(n,s.getId(i),s.getId(r)),l=new Sc(new _i(0,null,-1,0,0),[]);for(let a=0,d=e.length;a<d;a++){let c=e[a];l.insert(0,c.scope,c.parentScopes,c.fontStyle,s.getId(c.foreground),s.getId(c.background))}return new mn(s,o,l)}var yc=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Cc=Object.freeze([]),_i=class _o{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,i,r,s){this.scopeDepth=t,this.parentScopes=n||Cc,this.fontStyle=i,this.foreground=r,this.background=s}clone(){return new _o(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let i=0,r=t.length;i<r;i++)n[i]=t[i].clone();return n}acceptOverwrite(t,n,i,r){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),i!==0&&(this.foreground=i),r!==0&&(this.background=r)}},Sc=class Ri{constructor(t,n=[],i={}){this._mainRule=t,this._children=i,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let i=0,r=0;for(;t.parentScopes[i]===">"&&i++,n.parentScopes[r]===">"&&r++,!(i>=t.parentScopes.length||r>=n.parentScopes.length);){const s=n.parentScopes[r].length-t.parentScopes[i].length;if(s!==0)return s;i++,r++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let i=t.indexOf("."),r,s;if(i===-1?(r=t,s=""):(r=t.substring(0,i),s=t.substring(i+1)),this._children.hasOwnProperty(r))return this._children[r].match(s)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Ri._cmpBySpecificity),n}insert(t,n,i,r,s,o){if(n===""){this._doInsertHere(t,i,r,s,o);return}let l=n.indexOf("."),a,d;l===-1?(a=n,d=""):(a=n.substring(0,l),d=n.substring(l+1));let c;this._children.hasOwnProperty(a)?c=this._children[a]:(c=new Ri(this._mainRule.clone(),_i.cloneArr(this._rulesWithParentScopes)),this._children[a]=c),c.insert(t+1,d,i,r,s,o)}_doInsertHere(t,n,i,r,s){if(n===null){this._mainRule.acceptOverwrite(t,i,r,s);return}for(let o=0,l=this._rulesWithParentScopes.length;o<l;o++){let a=this._rulesWithParentScopes[o];if(ko(a.parentScopes,n)===0){a.acceptOverwrite(t,i,r,s);return}}i===-1&&(i=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new _i(t,n,i,r,s))}},Ze=class oe{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=oe.getLanguageId(t),i=oe.getTokenType(t),r=oe.getFontStyle(t),s=oe.getForeground(t),o=oe.getBackground(t);console.log({languageId:n,tokenType:i,fontStyle:r,foreground:s,background:o})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,i,r,s,o,l){let a=oe.getLanguageId(t),d=oe.getTokenType(t),c=oe.containsBalancedBrackets(t)?1:0,u=oe.getFontStyle(t),h=oe.getForeground(t),f=oe.getBackground(t);return n!==0&&(a=n),i!==8&&(d=i),r!==null&&(c=r?1:0),s!==-1&&(u=s),o!==0&&(h=o),l!==0&&(f=l),(a<<0|d<<8|c<<10|u<<11|h<<15|f<<24)>>>0}};function bn(e,t){const n=[],i=wc(e);let r=i.next();for(;r!==null;){let a=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":a=1;break;case"L":a=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=i.next()}let d=o();if(n.push({matcher:d,priority:a}),r!==",")break;r=i.next()}return n;function s(){if(r==="-"){r=i.next();const a=s();return d=>!!a&&!a(d)}if(r==="("){r=i.next();const a=l();return r===")"&&(r=i.next()),a}if(Br(r)){const a=[];do a.push(r),r=i.next();while(Br(r));return d=>t(a,d)}return null}function o(){const a=[];let d=s();for(;d;)a.push(d),d=s();return c=>a.every(u=>u(c))}function l(){const a=[];let d=o();for(;d&&(a.push(d),r==="|"||r===",");){do r=i.next();while(r==="|"||r===",");d=o()}return c=>a.some(u=>u(c))}}function Br(e){return!!e&&!!e.match(/[\w\.:]+/)}function wc(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const i=n[0];return n=t.exec(e),i}}}function Ro(e){typeof e.dispose=="function"&&e.dispose()}var Rt=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},xc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},kc=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Lc=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Rt(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new kc;for(const n of e)Ec(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof Rt){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function Ec(e,t,n,i){const r=n.lookup(e.scopeName);if(!r){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const s=n.lookup(t);e instanceof Rt?cn({baseGrammar:s,selfGrammar:r},i):Ii(e.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},i);const o=n.injections(e.scopeName);if(o)for(const l of o)i.add(new Rt(l))}function Ii(e,t,n){if(t.repository&&t.repository[e]){const i=t.repository[e];vn([i],t,n)}}function cn(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&vn(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&vn(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function vn(e,t,n){for(const i of e){if(n.visitedRule.has(i))continue;n.visitedRule.add(i);const r=i.repository?So({},t.repository,i.repository):t.repository;Array.isArray(i.patterns)&&vn(i.patterns,{...t,repository:r},n);const s=i.include;if(!s)continue;const o=Io(s);switch(o.kind){case 0:cn({...t,selfGrammar:t.baseGrammar},n);break;case 1:cn(t,n);break;case 2:Ii(o.ruleName,{...t,repository:r},n);break;case 3:case 4:const l=o.scopeName===t.selfGrammar.scopeName?t.selfGrammar:o.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(l){const a={baseGrammar:t.baseGrammar,selfGrammar:l,repository:r};o.kind===4?Ii(o.ruleName,a,n):cn(a,n)}else o.kind===4?n.add(new xc(o.scopeName,o.ruleName)):n.add(new Rt(o.scopeName));break}}}var Ac=class{kind=0},_c=class{kind=1},Rc=class{constructor(e){this.ruleName=e}kind=2},Ic=class{constructor(e){this.scopeName=e}kind=3},Tc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Io(e){if(e==="$base")return new Ac;if(e==="$self")return new _c;const t=e.indexOf("#");if(t===-1)return new Ic(e);if(t===0)return new Rc(e.substring(1));{const n=e.substring(0,t),i=e.substring(t+1);return new Tc(n,i)}}var Pc=/\\(\d+)/,Gr=/\\(\d+)/g,Nc=-1,To=-2;var Dt=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,i){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Vt.hasCaptures(this._name),this._contentName=i||null,this._contentNameIsCapturing=Vt.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${wo(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Vt.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Vt.replaceCaptures(this._contentName,e,t)}},Mc=class extends Dt{retokenizeCapturedWithRuleId;constructor(e,t,n,i,r){super(e,t,n,i),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,i){throw new Error("Not supported!")}},Hc=class extends Dt{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,i,r){super(e,t,n,null),this._match=new It(i,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,i){return this._getCachedCompiledPatterns(e).compileAG(e,n,i)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Tt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},zr=class extends Dt{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,i,r){super(e,t,n,i),this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,i){return this._getCachedCompiledPatterns(e).compileAG(e,n,i)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Tt,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ti=class extends Dt{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,i,r,s,o,l,a,d){super(e,t,n,i),this._begin=new It(r,this.id),this.beginCaptures=s,this._end=new It(o||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=a||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,i){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,i)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Tt;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},yn=class extends Dt{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,i,r,s,o,l,a){super(e,t,n,i),this._begin=new It(r,this.id),this.beginCaptures=s,this.whileCaptures=l,this._while=new It(o,To),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=a.patterns,this.hasMissingPatterns=a.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,i){return this._getCachedCompiledPatterns(e).compileAG(e,n,i)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Tt;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,i){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,i)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Tt,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"￿"),this._cachedCompiledWhilePatterns}},Po=class Z{static createCaptureRule(t,n,i,r,s){return t.registerRule(o=>new Mc(n,o,i,r,s))}static getCompiledRuleId(t,n,i){return t.id||n.registerRule(r=>{if(t.id=r,t.match)return new Hc(t.$vscodeTextmateLocation,t.id,t.name,t.match,Z._compileCaptures(t.captures,n,i));if(typeof t.begin>"u"){t.repository&&(i=So({},i,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new zr(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Z._compilePatterns(s,n,i))}return t.while?new yn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Z._compileCaptures(t.beginCaptures||t.captures,n,i),t.while,Z._compileCaptures(t.whileCaptures||t.captures,n,i),Z._compilePatterns(t.patterns,n,i)):new Ti(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Z._compileCaptures(t.beginCaptures||t.captures,n,i),t.end,Z._compileCaptures(t.endCaptures||t.captures,n,i),t.applyEndPatternLast,Z._compilePatterns(t.patterns,n,i))}),t.id}static _compileCaptures(t,n,i){let r=[];if(t){let s=0;for(const o in t){if(o==="$vscodeTextmateLocation")continue;const l=parseInt(o,10);l>s&&(s=l)}for(let o=0;o<=s;o++)r[o]=null;for(const o in t){if(o==="$vscodeTextmateLocation")continue;const l=parseInt(o,10);let a=0;t[o].patterns&&(a=Z.getCompiledRuleId(t[o],n,i)),r[l]=Z.createCaptureRule(n,t[o].$vscodeTextmateLocation,t[o].name,t[o].contentName,a)}}return r}static _compilePatterns(t,n,i){let r=[];if(t)for(let s=0,o=t.length;s<o;s++){const l=t[s];let a=-1;if(l.include){const d=Io(l.include);switch(d.kind){case 0:case 1:a=Z.getCompiledRuleId(i[l.include],n,i);break;case 2:let c=i[d.ruleName];c&&(a=Z.getCompiledRuleId(c,n,i));break;case 3:case 4:const u=d.scopeName,h=d.kind===4?d.ruleName:null,f=n.getExternalGrammar(u,i);if(f)if(h){let p=f.repository[h];p&&(a=Z.getCompiledRuleId(p,n,f.repository))}else a=Z.getCompiledRuleId(f.repository.$self,n,f.repository);break}}else a=Z.getCompiledRuleId(l,n,i);if(a!==-1){const d=n.getRule(a);let c=!1;if((d instanceof zr||d instanceof Ti||d instanceof yn)&&d.hasMissingPatterns&&d.patterns.length===0&&(c=!0),c)continue;r.push(a)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},It=class No{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){const i=t.length;let r=0,s=[],o=!1;for(let l=0;l<i;l++)if(t.charAt(l)==="\\"&&l+1<i){const d=t.charAt(l+1);d==="z"?(s.push(t.substring(r,l)),s.push("$(?!\\n)(?<!\\n)"),r=l+2):(d==="A"||d==="G")&&(o=!0),l++}this.hasAnchor=o,r===0?this.source=t:(s.push(t.substring(r,i)),this.source=s.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Pc.test(this.source):this.hasBackReferences=!1}clone(){return new No(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let i=n.map(r=>t.substring(r.start,r.end));return Gr.lastIndex=0,this.source.replace(Gr,(r,s)=>Lo(i[parseInt(s,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],i=[],r=[],s,o,l,a;for(s=0,o=this.source.length;s<o;s++)l=this.source.charAt(s),t[s]=l,n[s]=l,i[s]=l,r[s]=l,l==="\\"&&s+1<o&&(a=this.source.charAt(s+1),a==="A"?(t[s+1]="￿",n[s+1]="￿",i[s+1]="A",r[s+1]="A"):a==="G"?(t[s+1]="￿",n[s+1]="G",i[s+1]="￿",r[s+1]="G"):(t[s+1]=a,n[s+1]=a,i[s+1]=a,r[s+1]=a),s++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:i.join(""),A1_G1:r.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Tt=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new jr(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let i=this._items.map(r=>r.resolveAnchors(t,n));return new jr(e,i,this._items.map(r=>r.ruleId))}},jr=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
35
+ `)}findNextMatchSync(e,t,n){const i=this.scanner.findNextMatchSync(e,t,n);return i?{ruleId:this.rules[i.index],captureIndices:i.captureIndices}:null}},Zn=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Dc=class Pi{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Zn(t,8),this._embeddedLanguagesMatcher=new Fc(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Pi._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Zn(0,0);_getBasicScopeAttributes=new Eo(t=>{const n=this._scopeToLanguage(t),i=this._toStandardTokenType(t);return new Zn(n,i)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(Pi.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Fc=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,i])=>Lo(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Wr=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Mo(e,t,n,i,r,s,o,l){const a=t.content.length;let d=!1,c=-1;if(o){const f=$c(e,t,n,i,r,s);r=f.stack,i=f.linePos,n=f.isFirstLine,c=f.anchorPosition}const u=Date.now();for(;!d;){if(l!==0&&Date.now()-u>l)return new Wr(r,!0);h()}return new Wr(r,!1);function h(){const f=Oc(e,t,n,i,r,c);if(!f){s.produce(r,a),d=!0;return}const p=f.captureIndices,g=f.matchedRuleId,v=p&&p.length>0?p[0].end>i:!1;if(g===Nc){const m=r.getRule(e);s.produce(r,p[0].start),r=r.withContentNameScopesList(r.nameScopesList),kt(e,t,n,r,s,m.endCaptures,p),s.produce(r,p[0].end);const b=r;if(r=r.parent,c=b.getAnchorPos(),!v&&b.getEnterPos()===i){r=b,s.produce(r,a),d=!0;return}}else{const m=e.getRule(g);s.produce(r,p[0].start);const b=r,y=m.getName(t.content,p),S=r.contentNameScopesList.pushAttributed(y,e);if(r=r.push(g,i,c,p[0].end===a,null,S,S),m instanceof Ti){const C=m;kt(e,t,n,r,s,C.beginCaptures,p),s.produce(r,p[0].end),c=p[0].end;const w=C.getContentName(t.content,p),x=S.pushAttributed(w,e);if(r=r.withContentNameScopesList(x),C.endHasBackReferences&&(r=r.withEndRule(C.getEndWithResolvedBackReferences(t.content,p))),!v&&b.hasSameRuleAs(r)){r=r.pop(),s.produce(r,a),d=!0;return}}else if(m instanceof yn){const C=m;kt(e,t,n,r,s,C.beginCaptures,p),s.produce(r,p[0].end),c=p[0].end;const w=C.getContentName(t.content,p),x=S.pushAttributed(w,e);if(r=r.withContentNameScopesList(x),C.whileHasBackReferences&&(r=r.withEndRule(C.getWhileWithResolvedBackReferences(t.content,p))),!v&&b.hasSameRuleAs(r)){r=r.pop(),s.produce(r,a),d=!0;return}}else if(kt(e,t,n,r,s,m.captures,p),s.produce(r,p[0].end),r=r.pop(),!v){r=r.safePop(),s.produce(r,a),d=!0;return}}p[0].end>i&&(i=p[0].end,n=!1)}}function $c(e,t,n,i,r,s){let o=r.beginRuleCapturedEOL?0:-1;const l=[];for(let a=r;a;a=a.pop()){const d=a.getRule(e);d instanceof yn&&l.push({rule:d,stack:a})}for(let a=l.pop();a;a=l.pop()){const{ruleScanner:d,findOptions:c}=Gc(a.rule,e,a.stack.endRule,n,i===o),u=d.findNextMatchSync(t,i,c);if(u){if(u.ruleId!==To){r=a.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(s.produce(a.stack,u.captureIndices[0].start),kt(e,t,n,a.stack,s,a.rule.whileCaptures,u.captureIndices),s.produce(a.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>i&&(i=u.captureIndices[0].end,n=!1))}else{r=a.stack.pop();break}}return{stack:r,linePos:i,anchorPosition:o,isFirstLine:n}}function Oc(e,t,n,i,r,s){const o=Uc(e,t,n,i,r,s),l=e.getInjections();if(l.length===0)return o;const a=Bc(l,e,t,n,i,r,s);if(!a)return o;if(!o)return a;const d=o.captureIndices[0].start,c=a.captureIndices[0].start;return c<d||a.priorityMatch&&c===d?a:o}function Uc(e,t,n,i,r,s){const o=r.getRule(e),{ruleScanner:l,findOptions:a}=Ho(o,e,r.endRule,n,i===s),d=l.findNextMatchSync(t,i,a);return d?{captureIndices:d.captureIndices,matchedRuleId:d.ruleId}:null}function Bc(e,t,n,i,r,s,o){let l=Number.MAX_VALUE,a=null,d,c=0;const u=s.contentNameScopesList.getScopeNames();for(let h=0,f=e.length;h<f;h++){const p=e[h];if(!p.matcher(u))continue;const g=t.getRule(p.ruleId),{ruleScanner:v,findOptions:m}=Ho(g,t,null,i,r===o),b=v.findNextMatchSync(n,r,m);if(!b)continue;const y=b.captureIndices[0].start;if(!(y>=l)&&(l=y,a=b.captureIndices,d=b.ruleId,c=p.priority,l===r))break}return a?{priorityMatch:c===-1,captureIndices:a,matchedRuleId:d}:null}function Ho(e,t,n,i,r){return{ruleScanner:e.compileAG(t,n,i,r),findOptions:0}}function Gc(e,t,n,i,r){return{ruleScanner:e.compileWhileAG(t,n,i,r),findOptions:0}}function kt(e,t,n,i,r,s,o){if(s.length===0)return;const l=t.content,a=Math.min(s.length,o.length),d=[],c=o[0].end;for(let u=0;u<a;u++){const h=s[u];if(h===null)continue;const f=o[u];if(f.length===0)continue;if(f.start>c)break;for(;d.length>0&&d[d.length-1].endPos<=f.start;)r.produceFromScopes(d[d.length-1].scopes,d[d.length-1].endPos),d.pop();if(d.length>0?r.produceFromScopes(d[d.length-1].scopes,f.start):r.produce(i,f.start),h.retokenizeCapturedWithRuleId){const g=h.getName(l,o),v=i.contentNameScopesList.pushAttributed(g,e),m=h.getContentName(l,o),b=v.pushAttributed(m,e),y=i.push(h.retokenizeCapturedWithRuleId,f.start,-1,!1,null,v,b),S=e.createOnigString(l.substring(0,f.end));Mo(e,S,n&&f.start===0,f.start,y,r,!1,0),Ro(S);continue}const p=h.getName(l,o);if(p!==null){const v=(d.length>0?d[d.length-1].scopes:i.contentNameScopesList).pushAttributed(p,e);d.push(new zc(v,f.end))}}for(;d.length>0;)r.produceFromScopes(d[d.length-1].scopes,d[d.length-1].endPos),d.pop()}var zc=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function jc(e,t,n,i,r,s,o,l){return new Vc(e,t,n,i,r,s,o,l)}function Vr(e,t,n,i,r){const s=bn(t,Cn),o=Po.getCompiledRuleId(n,i,r.repository);for(const l of s)e.push({debugSelector:t,matcher:l.matcher,ruleId:o,grammar:r,priority:l.priority})}function Cn(e,t){if(t.length<e.length)return!1;let n=0;return e.every(i=>{for(let r=n;r<t.length;r++)if(Wc(t[r],i))return n=r+1,!0;return!1})}function Wc(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var Vc=class{constructor(e,t,n,i,r,s,o,l){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=l,this._basicScopeAttributesProvider=new Dc(n,i),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=qr(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(const a of Object.keys(r)){const d=bn(a,Cn);for(const c of d)this._tokenTypeMatchers.push({matcher:c.matcher,type:r[a]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},t=[],n=this._rootScopeName,i=e.lookup(n);if(i){const r=i.injections;if(r)for(let o in r)Vr(t,o,r[o],this,i);const s=this._grammarRepository.injections(n);s&&s.forEach(o=>{const l=this.getExternalGrammar(o);if(l){const a=l.injectionSelector;a&&Vr(t,a,l,this,l)}})}return t.sort((r,s)=>r.priority-s.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=qr(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const i=this._tokenize(e,t,!1,n);return{tokens:i.lineTokens.getResult(i.ruleStack,i.lineLength),ruleStack:i.ruleStack,stoppedEarly:i.stoppedEarly}}tokenizeLine2(e,t,n=0){const i=this._tokenize(e,t,!0,n);return{tokens:i.lineTokens.getBinaryResult(i.ruleStack,i.lineLength),ruleStack:i.ruleStack,stoppedEarly:i.stoppedEarly}}_tokenize(e,t,n,i){this._rootId===-1&&(this._rootId=Po.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===Ni.NULL){r=!0;const d=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),u=Ze.set(0,d.languageId,d.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),h=this.getRule(this._rootId).getName(null,null);let f;h?f=Et.createRootAndLookUpScopeName(h,u,this):f=Et.createRoot("unknown",u),t=new Ni(null,this._rootId,-1,-1,!1,null,f,f)}else r=!1,t.reset();e=e+`
36
+ `;const s=this.createOnigString(e),o=s.content.length,l=new Kc(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),a=Mo(this,s,r,0,t,l,!0,i);return Ro(s),{lineLength:o,lineTokens:l,ruleStack:a.stack,stoppedEarly:a.stoppedEarly}}};function qr(e,t){return e=uc(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Et=class be{constructor(t,n,i){this.parent=t,this.scopePath=n,this.tokenAttributes=i}static fromExtension(t,n){let i=t,r=t?.scopePath??null;for(const s of n)r=Qn.push(r,s.scopeNames),i=new be(i,r,s.encodedTokenAttributes);return i}static createRoot(t,n){return new be(null,new Qn(null,t),n)}static createRootAndLookUpScopeName(t,n,i){const r=i.getMetadataForScope(t),s=new Qn(null,t),o=i.themeProvider.themeMatch(s),l=be.mergeAttributes(n,r,o);return new be(null,s,l)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return be.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,i){let r=-1,s=0,o=0;return i!==null&&(r=i.fontStyle,s=i.foregroundId,o=i.backgroundId),Ze.set(t,n.languageId,n.tokenType,null,r,s,o)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return be._pushAttributed(this,t,n);const i=t.split(/ /g);let r=this;for(const s of i)r=be._pushAttributed(r,s,n);return r}static _pushAttributed(t,n,i){const r=i.getMetadataForScope(n),s=t.scopePath.push(n),o=i.themeProvider.themeMatch(s),l=be.mergeAttributes(t.tokenAttributes,r,o);return new be(t,s,l)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){const n=[];let i=this;for(;i&&i!==t;)n.push({encodedTokenAttributes:i.tokenAttributes,scopeNames:i.scopePath.getExtensionIfDefined(i.parent?.scopePath??null)}),i=i.parent;return i===t?n.reverse():void 0}},Ni=class qe{constructor(t,n,i,r,s,o,l,a){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=s,this.endRule=o,this.nameScopesList=l,this.contentNameScopesList=a,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=i,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new qe(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:qe._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Et.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){qe._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,i,r,s,o,l){return new qe(this,t,n,i,r,s,o,l)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new qe(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){const i=Et.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new qe(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,i,Et.fromExtension(i,n.contentNameScopesList))}},qc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):bn(n,Cn).map(i=>i.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>bn(n,Cn).map(i=>i.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Kc=class{constructor(e,t,n,i){this.balancedBracketSelectors=i,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let i=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const s=e?.getScopeNames()??[];for(const o of this._tokenTypeOverrides)o.matcher(s)&&(i=Ze.set(i,0,o.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(i=Ze.set(i,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===i){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(i),this._lastTokenEndIndex=t;return}const n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let i=0,r=this._binaryTokens.length;i<r;i++)n[i]=this._binaryTokens[i];return n}},Xc=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,i,r){if(!this._grammars.has(e)){let s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,jc(e,s,t,n,i,r,this,this._onigLib))}return this._grammars.get(e)}},Yc=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new Xc(mn.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(mn.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,i){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:i})}loadGrammarWithConfiguration(t,n,i){return this._loadGrammar(t,n,i.embeddedLanguages,i.tokenTypes,new qc(i.balancedBracketSelectors||[],i.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,i,r,s){const o=new Lc(this._syncRegistry,t);for(;o.Q.length>0;)o.Q.map(l=>this._loadSingleGrammar(l.scopeName)),o.processQueue();return this._grammarForScopeName(t,n,i,r,s)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const i=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,i)}}addGrammar(t,n=[],i=0,r=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,i,r)}_grammarForScopeName(t,n=0,i=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(t,n,i,r,s)}},Mi=Ni.NULL;function Sn(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},i=typeof e=="string"?e:e.name;for(const[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?n[r]=s:r===i&&Object.assign(n,s);return n}function Ge(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Qc(e){return Array.isArray(e)?e:[e]}async function Do(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function In(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Fo(e){return e==="ansi"||In(e)}function Tn(e){return e==="none"}function $o(e){return Tn(e)}const Zc=/(\r?\n)/g;function Pn(e,t=!1){if(e.length===0)return[["",0]];const n=e.split(Zc);let i=0;const r=[];for(let s=0;s<n.length;s+=2){const o=t?n[s]+(n[s+1]||""):n[s];r.push([o,i]),i+=n[s].length,i+=n[s+1]?.length||0}return r}const Kr={light:"#333333",dark:"#bbbbbb"},Xr={light:"#fffffe",dark:"#1e1e1e"},Yr="__shiki_resolved";function Nn(e){if(e?.[Yr])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:i}=t;if(!n||!i){const l=t.settings?t.settings.find(a=>!a.name&&!a.scope):void 0;l?.settings?.foreground&&(i=l.settings.foreground),l?.settings?.background&&(n=l.settings.background),!i&&t?.colors?.["editor.foreground"]&&(i=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),i||(i=t.type==="light"?Kr.light:Kr.dark),n||(n=t.type==="light"?Xr.light:Xr.dark),t.fg=i,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0;const s=new Map;function o(l){if(s.has(l))return s.get(l);r+=1;const a=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${a}`]?o(l):(s.set(l,a),a)}t.settings=t.settings.map(l=>{const a=l.settings?.foreground&&!l.settings.foreground.startsWith("#"),d=l.settings?.background&&!l.settings.background.startsWith("#");if(!a&&!d)return l;const c={...l,settings:{...l.settings}};if(a){const u=o(l.settings.foreground);t.colorReplacements[u]=l.settings.foreground,c.settings.foreground=u}if(d){const u=o(l.settings.background);t.colorReplacements[u]=l.settings.background,c.settings.background=u}return c});for(const l of Object.keys(t.colors||{}))if((l==="editor.foreground"||l==="editor.background"||l.startsWith("terminal.ansi"))&&!t.colors[l]?.startsWith("#")){const a=o(t.colors[l]);t.colorReplacements[a]=t.colors[l],t.colors[l]=a}return Object.defineProperty(t,Yr,{enumerable:!1,writable:!1,value:!0}),t}async function Oo(e){return[...new Set((await Promise.all(e.filter(t=>!Fo(t)).map(async t=>await Do(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Uo(e){return(await Promise.all(e.map(async t=>$o(t)?null:Nn(await Do(t))))).filter(t=>!!t)}function Bo(e,t){if(!t)return e;if(t[e]){const n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new O(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Jc=class extends Yc{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,i={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=i,this._themes.map(r=>this.loadTheme(r)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const t=Nn(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=mn.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Bo(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const t=new Set([...this._langMap.values()].filter(r=>r.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const i=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(i.name=e.name,this._resolvedGrammars.set(e.name,i),e.aliases&&e.aliases.forEach(r=>{this._alias[r]=e.name}),this._loadedLanguagesCache=null,t.size)for(const r of t)this._resolvedGrammars.delete(r.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(r.scopeName),this._syncRegistry?._grammars?.delete(r.scopeName),this.loadLanguage(this._langMap.get(r.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const i of e)this.resolveEmbeddedLanguages(i);const t=[...this._langGraph.entries()],n=t.filter(([i,r])=>!r);if(n.length){const i=t.filter(([r,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(o=>n.map(([l])=>l).includes(o)):!1).filter(r=>!n.includes(r));throw new O(`Missing languages ${n.map(([r])=>`\`${r}\``).join(", ")}, required by ${i.map(([r])=>`\`${r}\``).join(", ")}`)}for(const[i,r]of t)this._resolver.addLanguage(r);for(const[i,r]of t)this.loadLanguage(r)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const t=e.embeddedLanguages??e.embeddedLangs;if(t)for(const n of t)this._langGraph.set(n,this._langMap.get(n))}},eu=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let i=1;i<=t.length;i++){const r=t.slice(0,i).join(".");n=[...n,...this._injections.get(r)||[]]}return n}};let wt=0;function tu(e){wt+=1,e.warnings!==!1&&wt>=10&&wt%10===0&&console.warn(`[Shiki] ${wt} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new O("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),i=(e.themes||[]).flat(1).map(Nn),r=new Jc(new eu(e.engine,n),i,n,e.langAlias);let s;function o(b){return Bo(b,e.langAlias)}function l(b){v();const y=r.getGrammar(typeof b=="string"?b:b.name);if(!y)throw new O(`Language \`${b}\` not found, you may need to load it first`);return y}function a(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};v();const y=r.getTheme(b);if(!y)throw new O(`Theme \`${b}\` not found, you may need to load it first`);return y}function d(b){v();const y=a(b);return s!==b&&(r.setTheme(y),s=b),{theme:y,colorMap:r.getColorMap()}}function c(){return v(),r.getLoadedThemes()}function u(){return v(),r.getLoadedLanguages()}function h(...b){v(),r.loadLanguages(b.flat(1))}async function f(...b){return h(await Oo(b))}function p(...b){v();for(const y of b.flat(1))r.loadTheme(y)}async function g(...b){return v(),p(await Uo(b))}function v(){if(t)throw new O("Shiki instance has been disposed")}function m(){t||(t=!0,r.dispose(),wt-=1)}return{setTheme:d,getTheme:a,getLanguage:l,getLoadedThemes:c,getLoadedLanguages:u,resolveLangAlias:o,loadLanguage:f,loadLanguageSync:h,loadTheme:g,loadThemeSync:p,dispose:m,[Symbol.dispose]:m}}async function nu(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,i]=await Promise.all([Uo(e.themes||[]),Oo(e.langs||[]),e.engine]);return tu({...e,themes:t,langs:n,engine:i})}const Go=new WeakMap;function Mn(e,t){Go.set(e,t)}function Pt(e){return Go.get(e)}var Hn=class zo{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new zo(Object.fromEntries(Qc(n).map(i=>[i,Mi])),t)}constructor(...t){if(t.length===2){const[n,i]=t;this.lang=i,this._stacks=n}else{const[n,i,r]=t;this.lang=i,this._stacks={[r]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return iu(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function iu(e){const t=[],n=new Set;function i(r){if(n.has(r))return;n.add(r);const s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&i(r.parent)}return i(e),t}function ru(e,t){if(!(e instanceof Hn))throw new O("Invalid grammar state");return e.getInternalStack(t)}const su=/,/,ou=/ /;function jo(e,t,n={}){const{theme:i=e.getLoadedThemes()[0]}=n;if(In(e.resolveLangAlias(n.lang||"text"))||Tn(i))return Pn(t).map(l=>[{content:l[0],offset:l[1]}]);const{theme:r,colorMap:s}=e.setTheme(i),o=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==o.name)throw new O(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(r.name))throw new O(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${r.name}"`)}return lu(t,o,r,s,n)}function au(...e){if(e.length===2)return Pt(e[1]);const[t,n,i={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=i;if(In(r)||Tn(s))throw new O("Plain language does not have grammar state");if(r==="ansi")throw new O("ANSI language does not have grammar state");const{theme:o,colorMap:l}=t.setTheme(s),a=t.getLanguage(r);return new Hn(or(n,a,o,l,i).stateStack,a.name,o.name)}function lu(e,t,n,i,r){const s=or(e,t,n,i,r),o=new Hn(s.stateStack,t.name,n.name);return Mn(s.tokens,o),s.tokens}function or(e,t,n,i,r){const s=Sn(n,r),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:l=500,includeExplanation:a=!1}=r,d=Pn(e);let c=r.grammarState?ru(r.grammarState,n.name)??Mi:r.grammarContextCode!=null?or(r.grammarContextCode,t,n,i,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Mi,u=[];const h=[];for(let f=0,p=d.length;f<p;f++){const[g,v]=d[f];if(g===""){u=[],h.push([]);continue}if(o>0&&g.length>=o){u=[],h.push([{content:g,offset:v,color:"",fontStyle:0}]);continue}let m,b,y;a&&a!=="tokenType"&&(m=t.tokenizeLine(g,c,l),b=m.tokens,y=0);const S=t.tokenizeLine2(g,c,l),C=S.tokens.length/2;for(let w=0;w<C;w++){const x=S.tokens[2*w],E=w+1<C?S.tokens[2*w+2]:g.length;if(x===E)continue;const k=S.tokens[2*w+1],_=Ge(i[Ze.getForeground(k)],s),F=Ze.getFontStyle(k),L={content:g.substring(x,E),offset:v+x,color:_,fontStyle:F};if(a==="tokenType")L.type=Ze.getTokenType(k);else if(a){const A=[];if(a!=="scopeName")for(const M of n.settings){let R;switch(typeof M.scope){case"string":R=M.scope.split(su).map(P=>P.trim());break;case"object":R=M.scope;break;default:continue}A.push({settings:M,selectors:R.map(P=>P.split(ou))})}L.explanation=[];let N=0;for(;x+N<E;){const M=b[y],R=g.substring(M.startIndex,M.endIndex);N+=R.length,L.explanation.push({content:R,scopes:a==="scopeName"?du(M.scopes):cu(A,M.scopes)}),y+=1}}u.push(L)}h.push(u),u=[],c=S.ruleStack}return{tokens:h,stateStack:c}}function du(e){return e.map(t=>({scopeName:t}))}function cu(e,t){const n=[];for(let i=0,r=t.length;i<r;i++){const s=t[i];n[i]={scopeName:s,themeMatches:hu(e,s,t.slice(0,i))}}return n}function Qr(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function uu(e,t,n){if(!Qr(e.at(-1),t))return!1;let i=e.length-2,r=n.length-1;for(;i>=0&&r>=0;)Qr(e[i],n[r])&&(i-=1),r-=1;return i===-1}function hu(e,t,n){const i=[];for(const{selectors:r,settings:s}of e)for(const o of r)if(uu(o,t,n)){i.push(s);break}return i}function Wo(e,t,n,i=jo){const r=Object.entries(n.themes).filter(d=>d[1]).map(d=>({color:d[0],theme:d[1]})),s=r.map(d=>{const c=i(e,t,{...n,theme:d.theme});return{tokens:c,state:Pt(c),theme:typeof d.theme=="string"?d.theme:d.theme.name}}),o=fu(...s.map(d=>d.tokens)),l=o[0].map((d,c)=>d.map((u,h)=>{const f={content:u.content,variants:{},offset:u.offset};return"includeExplanation"in n&&n.includeExplanation&&(f.explanation=u.explanation),o.forEach((p,g)=>{const{content:v,explanation:m,offset:b,...y}=p[c][h];f.variants[r[g].color]=y}),f})),a=s[0].state?new Hn(Object.fromEntries(s.map(d=>[d.theme,d.state?.getInternalStack(d.theme)])),s[0].state.lang):void 0;return a&&Mn(l,a),l}function fu(...e){const t=e.map(()=>[]),n=e.length;for(let i=0;i<e[0].length;i++){const r=e.map(a=>a[i]),s=t.map(()=>[]);t.forEach((a,d)=>a.push(s[d]));const o=r.map(()=>0),l=r.map(a=>a[0]);for(;l.every(a=>a);){const a=Math.min(...l.map(d=>d.content.length));for(let d=0;d<n;d++){const c=l[d];c.content.length===a?(s[d].push(c),o[d]+=1,l[d]=r[d][o[d]]):(s[d].push({...c,content:c.content.slice(0,a)}),l[d]={...c,content:c.content.slice(a),offset:c.offset+a})}}}return t}const Zr=/\s+/g;function Vo(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Zr)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(Zr);for(const i of n)i&&!e.properties.class.includes(i)&&e.properties.class.push(i);return e}function pu(e){const t=Pn(e,!0).map(([r])=>r);function n(r){if(r===e.length)return{line:t.length-1,character:t.at(-1).length};let s=r,o=0;for(const l of t){if(s<l.length)break;s-=l.length,o++}return{line:o,character:s}}function i(r,s){let o=0;for(let l=0;l<r;l++)o+=t[l].length;return o+=s,o}return{lines:t,indexToPos:n,posToIndex:i}}const gu=["color","background-color"];function mu(e,t){let n=0;const i=[];for(const r of t)r>n&&i.push({...e,content:e.content.slice(n,r),offset:e.offset+n}),n=r;return n<e.content.length&&i.push({...e,content:e.content.slice(n),offset:e.offset+n}),i}function bu(e,t){let n=0,i=e.length;for(;n<i;){const r=n+(i-n>>1);e[r]<=t?n=r+1:i=r}return n}function vu(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((i,r)=>i-r);return n.length?e.map(i=>i.flatMap(r=>{const s=r.offset+r.content.length,o=bu(n,r.offset);let l=o;for(;l<n.length&&n[l]<s;)l++;if(o===l)return r;const a=n.slice(o,l);for(let d=0;d<a.length;d++)a[d]-=r.offset;return mu(r,a)})):e}function yu(e,t,n,i,r="css-vars"){const s={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(c=>wn(e.variants[c])),l=new Set(o.flatMap(c=>Object.keys(c))),a={},d=(c,u)=>{const h=u==="color"?"":u==="background-color"?"-bg":`-${u}`;return n+t[c]+(u==="color"?"":h)};return o.forEach((c,u)=>{for(const h of l){const f=c[h]||"inherit";if(u===0&&i&&gu.includes(h))if(i==="light-dark()"&&o.length>1){const p=t.findIndex(b=>b==="light"),g=t.findIndex(b=>b==="dark");if(p===-1||g===-1)throw new O('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const v=o[p][h]||"inherit",m=o[g][h]||"inherit";a[h]=`light-dark(${v}, ${m})`,r==="css-vars"&&(a[d(u,h)]=f)}else a[h]=f;else r==="css-vars"&&(a[d(u,h)]=f)}}),s.htmlStyle=a,s}function wn(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&J.Italic&&(t["font-style"]="italic"),e.fontStyle&J.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&J.Underline&&n.push("underline"),e.fontStyle&J.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Hi(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function Cu(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let r=function(o){if(typeof o=="number"){if(o<0||o>n.source.length)throw new O(`Invalid decoration offset: ${o}. Code length: ${n.source.length}`);return{...i.indexToPos(o),offset:o}}else{const l=i.lines[o.line];if(l===void 0)throw new O(`Invalid decoration position ${JSON.stringify(o)}. Lines length: ${i.lines.length}`);let a=o.character;if(a<0&&(a=l.length+a),a<0||a>l.length)throw new O(`Invalid decoration position ${JSON.stringify(o)}. Line ${o.line} length: ${l.length}`);return{...o,character:a,offset:i.posToIndex(o.line,a)}}};const i=pu(n.source),s=(n.options.decorations||[]).map(o=>({...o,start:r(o.start),end:r(o.end)}));Su(s),e.set(n.meta,{decorations:s,converter:i,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return vu(n,t(this).decorations.flatMap(i=>[i.start.offset,i.end.offset]))},code(n){if(!this.options.decorations?.length)return;const i=t(this),r=[...n.children].filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==i.converter.lines.length)throw new O(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${i.converter.lines.length}). Failed to apply decorations.`);function s(c,u,h,f){const p=r[c];let g="",v=-1,m=-1;if(u===0&&(v=0),h===0&&(m=0),h===Number.POSITIVE_INFINITY&&(m=p.children.length),v===-1||m===-1)for(let y=0;y<p.children.length;y++)g+=qo(p.children[y]),v===-1&&g.length===u&&(v=y+1),m===-1&&g.length===h&&(m=y+1);if(v===-1)throw new O(`Failed to find start index for decoration ${JSON.stringify(f.start)}`);if(m===-1)throw new O(`Failed to find end index for decoration ${JSON.stringify(f.end)}`);const b=p.children.slice(v,m);if(!f.alwaysWrap&&b.length===p.children.length)l(p,f,"line");else if(!f.alwaysWrap&&b.length===1&&b[0].type==="element")l(b[0],f,"token");else{const y={type:"element",tagName:"span",properties:{},children:b};l(y,f,"wrapper"),p.children.splice(v,b.length,y)}}function o(c,u){r[c]=l(r[c],u,"line")}function l(c,u,h){const f=u.properties||{},p=u.transform||(g=>g);return c.tagName=u.tagName||"span",c.properties={...c.properties,...f,class:c.properties.class},u.properties?.class&&Vo(c,u.properties.class),c=p(c,h)||c,c}const a=[],d=i.decorations.sort((c,u)=>u.start.offset-c.start.offset||c.end.offset-u.end.offset);for(const c of d){const{start:u,end:h}=c;if(u.line===h.line)s(u.line,u.character,h.character,c);else if(u.line<h.line){s(u.line,u.character,Number.POSITIVE_INFINITY,c);for(let f=u.line+1;f<h.line;f++)a.unshift(()=>o(f,c));s(h.line,0,h.character,c)}}a.forEach(c=>c())}}}function Su(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new O(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let i=t+1;i<e.length;i++){const r=e[i],s=n.start.offset<=r.start.offset&&r.start.offset<n.end.offset,o=n.start.offset<r.end.offset&&r.end.offset<=n.end.offset,l=r.start.offset<=n.start.offset&&n.start.offset<r.end.offset,a=r.start.offset<n.end.offset&&n.end.offset<=r.end.offset;if(s||o||l||a){if(s&&o||l&&a||l&&n.start.offset===n.end.offset||o&&r.start.offset===r.end.offset)continue;throw new O(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function qo(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(qo).join(""):""}const wu=[Cu()];function xn(e){const t=xu(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...wu]}function xu(e){const t=[],n=[],i=[];for(const r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":n.push(r);break;default:i.push(r)}return{pre:t,post:n,normal:i}}var Ye=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Jn={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function ku(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const i=e.indexOf("m",n);if(i!==-1)return{sequence:e.substring(n+2,i).split(";"),startPosition:n,position:i+1}}return{position:e.length}}function Jr(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(i=>Number.parseInt(i));return n.length!==3||n.some(i=>Number.isNaN(i))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function Lu(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const i=Number.parseInt(n);if(!Number.isNaN(i))if(i===0)t.push({type:"resetAll"});else if(i<=9)Jn[i]&&t.push({type:"setDecoration",value:Jn[i]});else if(i<=29){const r=Jn[i-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(i<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Ye[i-30]}});else if(i===38){const r=Jr(e);r&&t.push({type:"setForegroundColor",value:r})}else if(i===39)t.push({type:"resetForegroundColor"});else if(i<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Ye[i-40]}});else if(i===48){const r=Jr(e);r&&t.push({type:"setBackgroundColor",value:r})}else i===49?t.push({type:"resetBackgroundColor"}):i===53?t.push({type:"setDecoration",value:"overline"}):i===55?t.push({type:"resetDecoration",value:"overline"}):i>=90&&i<=97?t.push({type:"setForegroundColor",value:{type:"named",name:Ye[i-90+8]}}):i>=100&&i<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Ye[i-100+8]}})}return t}function Eu(){let e=null,t=null,n=new Set;return{parse(i){const r=[];let s=0;do{const o=ku(i,s),l=o.sequence?i.substring(s,o.startPosition):i.substring(s);if(l.length>0&&r.push({value:l,foreground:e,background:t,decorations:new Set(n)}),o.sequence){const a=Lu(o.sequence);for(const d of a)d.type==="resetAll"?(e=null,t=null,n.clear()):d.type==="resetForegroundColor"?e=null:d.type==="resetBackgroundColor"?t=null:d.type==="resetDecoration"&&n.delete(d.value);for(const d of a)d.type==="setForegroundColor"?e=d.value:d.type==="setBackgroundColor"?t=d.value:d.type==="setDecoration"&&n.add(d.value)}s=o.position}while(s<i.length);return r}}}var Au={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function _u(e=Au){function t(l){return e[l]}function n(l){return`#${l.map(a=>Math.max(0,Math.min(a,255)).toString(16).padStart(2,"0")).join("")}`}let i;function r(){if(i)return i;i=[];for(let d=0;d<Ye.length;d++)i.push(t(Ye[d]));let l=[0,95,135,175,215,255];for(let d=0;d<6;d++)for(let c=0;c<6;c++)for(let u=0;u<6;u++)i.push(n([l[d],l[c],l[u]]));let a=8;for(let d=0;d<24;d++,a+=10)i.push(n([a,a,a]));return i}function s(l){return r()[l]}function o(l){switch(l.type){case"named":return t(l.name);case"rgb":return n(l.rgb);case"table":return s(l.index)}}return{value:o}}const Ru=/#([0-9a-f]{3,8})/i,Iu=/var\((--[\w-]+-ansi-[\w-]+)\)/,Tu={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Pu(e,t,n){const i=Sn(e,n),r=Pn(t),s=_u(Object.fromEntries(Ye.map(l=>{const a=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`;return[l,e.colors?.[a]||Tu[l]]}))),o=Eu();return r.map(l=>o.parse(l[0]).map(a=>{let d,c;a.decorations.has("reverse")?(d=a.background?s.value(a.background):e.bg,c=a.foreground?s.value(a.foreground):e.fg):(d=a.foreground?s.value(a.foreground):e.fg,c=a.background?s.value(a.background):void 0),d=Ge(d,i),c=Ge(c,i),a.decorations.has("dim")&&(d=Nu(d));let u=J.None;return a.decorations.has("bold")&&(u|=J.Bold),a.decorations.has("italic")&&(u|=J.Italic),a.decorations.has("underline")&&(u|=J.Underline),a.decorations.has("strikethrough")&&(u|=J.Strikethrough),{content:a.value,offset:l[1],color:d,bgColor:c,fontStyle:u}}))}function Nu(e){const t=e.match(Ru);if(t){const i=t[1];if(i.length===8){const r=Math.round(Number.parseInt(i.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${i.slice(0,6)}${r}`}else{if(i.length===6)return`#${i}80`;if(i.length===4){const r=i[0],s=i[1],o=i[2],l=i[3];return`#${r}${r}${s}${s}${o}${o}${Math.round(Number.parseInt(`${l}${l}`,16)/2).toString(16).padStart(2,"0")}`}else if(i.length===3){const r=i[0],s=i[1],o=i[2];return`#${r}${r}${s}${s}${o}${o}80`}}}const n=e.match(Iu);return n?`var(${n[1]}-dim)`:e}function Di(e,t,n={}){const i=e.resolveLangAlias(n.lang||"text"),{theme:r=e.getLoadedThemes()[0]}=n;if(!In(i)&&!Tn(r)&&i==="ansi"){const{theme:s}=e.setTheme(r);return Pu(s,t,n)}return jo(e,t,n)}function kn(e,t,n){let i,r,s,o,l,a;if("themes"in n){const{defaultColor:d="light",cssVariablePrefix:c="--shiki-",colorsRendering:u="css-vars"}=n,h=Object.entries(n.themes).filter(m=>m[1]).map(m=>({color:m[0],theme:m[1]})).sort((m,b)=>m.color===d?-1:b.color===d?1:0);if(h.length===0)throw new O("`themes` option must not be empty");const f=Wo(e,t,n,Di);if(a=Pt(f),d&&d!=="light-dark()"&&!h.some(m=>m.color===d))throw new O(`\`themes\` option must contain the defaultColor key \`${d}\``);const p=h.map(m=>e.getTheme(m.theme)),g=h.map(m=>m.color);s=f.map(m=>m.map(b=>yu(b,g,c,d,u))),a&&Mn(s,a);const v=h.map(m=>Sn(m.theme,n));r=es(h,p,v,c,d,"fg",u),i=es(h,p,v,c,d,"bg",u),o=`shiki-themes ${p.map(m=>m.name).join(" ")}`,l=d?void 0:[r,i].join(";")}else if("theme"in n){const d=Sn(n.theme,n);s=Di(e,t,n);const c=e.getTheme(n.theme);i=Ge(c.bg,d),r=Ge(c.fg,d),o=c.name,a=Pt(s)}else throw new O("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:i,themeName:o,rootStyle:l,grammarState:a}}function es(e,t,n,i,r,s,o){return e.map((l,a)=>{const d=Ge(t[a][s],n[a])||"inherit",c=`${i+l.color}${s==="bg"?"-bg":""}:${d}`;if(a===0&&r){if(r==="light-dark()"&&e.length>1){const u=e.findIndex(f=>f.color==="light"),h=e.findIndex(f=>f.color==="dark");if(u===-1||h===-1)throw new O('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Ge(t[u][s],n[u])||"inherit"}, ${Ge(t[h][s],n[h])||"inherit"});${c}`}return d}return o==="css-vars"?c:null}).filter(l=>!!l).join(";")}const Ko=/^\s+$/,Mu=/^(\s*)(.*?)(\s*)$/;function Ln(e,t,n,i={meta:{},options:n,codeToHast:(r,s)=>Ln(e,r,s),codeToTokens:(r,s)=>kn(e,r,s)}){let r=t;for(const p of xn(n))r=p.preprocess?.call(i,r,n)||r;let{tokens:s,fg:o,bg:l,themeName:a,rootStyle:d,grammarState:c}=kn(e,r,n);const{mergeWhitespaces:u=!0,mergeSameStyleTokens:h=!1}=n;u===!0?s=Du(s):u==="never"&&(s=Fu(s)),h&&(s=$u(s));const f={...i,get source(){return r}};for(const p of xn(n))s=p.tokens?.call(f,s)||s;return Hu(s,{...n,fg:o,bg:l,themeName:a,rootStyle:n.rootStyle===!1?!1:n.rootStyle??d},f,c)}function Hu(e,t,n,i=Pt(e)){const r=xn(t),s=[],o={type:"root",children:[]},{structure:l="classic",tabindex:a="0"}=t,d={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?d.style=t.rootStyle:d.style=`background-color:${t.bg};color:${t.fg}`),a!==!1&&a!=null&&(d.tabindex=a.toString());for(const[g,v]of Object.entries(t.meta||{}))g.startsWith("_")||(d[g]=v);let c={type:"element",tagName:"pre",properties:d,children:[],data:t.data},u={type:"element",tagName:"code",properties:{},children:s};const h=[],f={...n,structure:l,addClassToHast:Vo,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return c},get code(){return u},get lines(){return h}};if(e.forEach((g,v)=>{v&&(l==="inline"?o.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&s.push({type:"text",value:`
37
+ `}));let m={type:"element",tagName:"span",properties:{class:"line"},children:[]},b=0;for(const y of g){let S={type:"element",tagName:"span",properties:{...y.htmlAttrs},children:[{type:"text",value:y.content}]};const C=Hi(y.htmlStyle||wn(y));C&&(S.properties.style=C);for(const w of r)S=w?.span?.call(f,S,v+1,b,m,y)||S;l==="inline"?o.children.push(S):l==="classic"&&m.children.push(S),b+=y.content.length}if(l==="classic"){for(const y of r)m=y?.line?.call(f,m,v+1)||m;h.push(m),s.push(m)}else l==="inline"&&h.push(m)}),l==="classic"){for(const g of r)u=g?.code?.call(f,u)||u;c.children.push(u);for(const g of r)c=g?.pre?.call(f,c)||c;o.children.push(c)}else if(l==="inline"){const g=[];let v={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const b of o.children)b.type==="element"&&b.tagName==="br"?(g.push(v),v={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(b.type==="element"||b.type==="text")&&v.children.push(b);g.push(v);let m={type:"element",tagName:"code",properties:{},children:g};for(const b of r)m=b?.code?.call(f,m)||m;o.children=[];for(let b=0;b<m.children.length;b++){b>0&&o.children.push({type:"element",tagName:"br",properties:{},children:[]});const y=m.children[b];y.type==="element"&&o.children.push(...y.children)}}let p=o;for(const g of r)p=g?.root?.call(f,p)||p;return i&&Mn(p,i),p}function Du(e){return e.map(t=>{const n=[];let i="",r;return t.forEach((s,o)=>{const l=!(s.fontStyle&&(s.fontStyle&J.Underline||s.fontStyle&J.Strikethrough));l&&Ko.test(s.content)&&t[o+1]?(r===void 0&&(r=s.offset),i+=s.content):i?(l?n.push({...s,offset:r,content:i+s.content}):n.push({content:i,offset:r},s),r=void 0,i=""):n.push(s)}),n})}function Fu(e){return e.map(t=>t.flatMap(n=>{if(Ko.test(n.content))return n;const i=n.content.match(Mu);if(!i)return n;const[,r,s,o]=i;if(!r&&!o)return n;const l=[{...n,offset:n.offset+r.length,content:s}];return r&&l.unshift({content:r,offset:n.offset}),o&&l.push({content:o,offset:n.offset+r.length+s.length}),l}))}function $u(e){return e.map(t=>{const n=[];for(const i of t){if(n.length===0){n.push({...i});continue}const r=n.at(-1),s=Hi(r.htmlStyle||wn(r)),o=Hi(i.htmlStyle||wn(i)),l=r.fontStyle&&(r.fontStyle&J.Underline||r.fontStyle&J.Strikethrough),a=i.fontStyle&&(i.fontStyle&J.Underline||i.fontStyle&J.Strikethrough);!l&&!a&&s===o?r.content+=i.content:n.push({...i})}return n})}const Ou=Ie;function Uu(e,t,n){const i={meta:{},options:n,codeToHast:(s,o)=>Ln(e,s,o),codeToTokens:(s,o)=>kn(e,s,o)};let r=Ou(Ln(e,t,n,i));for(const s of xn(n))r=s.postprocess?.call(i,r,n)||r;return r}async function Bu(e){const t=await nu(e);return{getLastGrammarState:(...n)=>au(t,...n),codeToTokensBase:(n,i)=>Di(t,n,i),codeToTokensWithThemes:(n,i)=>Wo(t,n,i),codeToTokens:(n,i)=>kn(t,n,i),codeToHast:(n,i)=>Ln(t,n,i),codeToHtml:(n,i)=>Uu(t,n,i),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Gu(e){const t=e.langs,n=e.themes,i=e.engine;async function r(s){function o(u){if(typeof u=="string"){if(u=s.langAlias?.[u]||u,Fo(u))return[];const h=t[u];if(!h)throw new O(`Language \`${u}\` is not included in this bundle. You may want to load it from external source.`);return h}return u}function l(u){if($o(u))return"none";if(typeof u=="string"){const h=n[u];if(!h)throw new O(`Theme \`${u}\` is not included in this bundle. You may want to load it from external source.`);return h}return u}const a=(s.themes??[]).map(u=>l(u)),d=(s.langs??[]).map(u=>o(u)),c=await Bu({engine:s.engine??i(),...s,themes:a,langs:d});return{...c,loadLanguage(...u){return c.loadLanguage(...u.map(o))},loadTheme(...u){return c.loadTheme(...u.map(l))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return r}const ts=4294967295;var zu=class{patterns;options;regexps;constructor(e,t={}){this.patterns=e,this.options=t;const{forgiving:n=!1,cache:i,regexConstructor:r}=t;if(!r)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(s=>{if(typeof s!="string")return s;const o=i?.get(s);if(o){if(o instanceof RegExp)return o;if(n)return null;throw o}try{const l=r(s);return i?.set(s,l),l}catch(l){if(i?.set(s,l),n)return null;throw l}})}findNextMatchSync(e,t,n){const i=typeof e=="string"?e:e.content,r=[];function s(o,l,a=0){return{index:o,captureIndices:l.indices.map(d=>d==null?{start:ts,end:ts,length:0}:{start:d[0]+a,end:d[1]+a,length:d[1]-d[0]})}}for(let o=0;o<this.regexps.length;o++){const l=this.regexps[o];if(l)try{l.lastIndex=t;const a=l.exec(i);if(!a)continue;if(a.index===t)return s(o,a,0);r.push([o,a,0])}catch(a){if(this.options.forgiving)continue;throw a}}if(r.length){const o=Math.min(...r.map(l=>l[1].index));for(const[l,a,d]of r)if(a.index===o)return s(l,a,d)}return null}};function yt(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function ju(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const ar=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Y=String.raw;function Ct(e,t){if(e==null)throw new Error(t??"Value expected");return e}const Xo=Y`\[\^?`,Yo=`c.? | C(?:-.?)?|${Y`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Y`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Y`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Y`o\{[^\}]*\}?`}|${Y`\d{1,3}`}`,lr=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,qt=new RegExp(Y`
38
+ \\ (?:
39
+ ${Yo}
40
+ | [gk]<[^>]*>?
41
+ | [gk]'[^']*'?
42
+ | .
43
+ )
44
+ | \( (?:
45
+ \? (?:
46
+ [:=!>({]
47
+ | <[=!]
48
+ | <[^>]*>
49
+ | '[^']*'
50
+ | ~\|?
51
+ | #(?:[^)\\]|\\.?)*
52
+ | [^:)]*[:)]
53
+ )?
54
+ | \*[^\)]*\)?
55
+ )?
56
+ | (?:${lr.source})+
57
+ | ${Xo}
58
+ | .
59
+ `.replace(/\s+/g,""),"gsu"),ei=new RegExp(Y`
60
+ \\ (?:
61
+ ${Yo}
62
+ | .
63
+ )
64
+ | \[:(?:\^?\p{Alpha}+|\^):\]
65
+ | ${Xo}
66
+ | &&
67
+ | .
68
+ `.replace(/\s+/g,""),"gsu");function Wu(e,t={}){const n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const i=ch(n.flags),r=[i.extended],s={captureGroup:n.rules.captureGroup,getCurrentModX(){return r.at(-1)},numOpenGroups:0,popModX(){r.pop()},pushModX(u){r.push(u)},replaceCurrentModX(u){r[r.length-1]=u},singleline:n.rules.singleline};let o=[],l;for(qt.lastIndex=0;l=qt.exec(e);){const u=Vu(s,e,l[0],qt.lastIndex);u.tokens?o.push(...u.tokens):u.token&&o.push(u.token),u.lastIndex!==void 0&&(qt.lastIndex=u.lastIndex)}const a=[];let d=0;o.filter(u=>u.type==="GroupOpen").forEach(u=>{u.kind==="capturing"?u.number=++d:u.raw==="("&&a.push(u)}),d||a.forEach((u,h)=>{u.kind="capturing",u.number=h+1});const c=d||a.length;return{tokens:o.map(u=>u.type==="EscapedNumber"?hh(u,c):u).flat(),flags:i}}function Vu(e,t,n,i){const[r,s]=n;if(n==="["||n==="[^"){const o=qu(t,n,i);return{tokens:o.tokens,lastIndex:o.lastIndex}}if(r==="\\"){if("AbBGyYzZ".includes(s))return{token:ns(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:ih(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Zo(n)}}if(s==="K")return{token:Jo("keep",n)};if(s==="N"||s==="R")return{token:Qe("newline",n,{negate:s==="N"})};if(s==="O")return{token:Qe("any",n)};if(s==="X")return{token:Qe("text_segment",n)};const o=Qo(n,{inCharClass:!1});return Array.isArray(o)?{tokens:o}:{token:o}}if(r==="("){if(s==="*")return{token:ah(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[i]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:i+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:oh(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:dt("group",n)};if(n==="(?>")return{token:dt("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:dt(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:dt("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:dt("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:eh(n)}}if(e.getCurrentModX()){if(n==="#"){const o=t.indexOf(`
69
+ `,i);return{lastIndex:o===-1?t.length:o}}if(/^\s$/.test(n)){const o=/\s+/y;return o.lastIndex=i,{lastIndex:o.exec(t)?o.lastIndex:i}}}if(n===".")return{token:Qe("dot",n)};if(n==="^"||n==="$"){const o=e.singleline?{"^":Y`\A`,$:Y`\Z`}[n]:n;return{token:ns(o,n)}}return n==="|"?{token:Xu(n)}:lr.test(n)?{tokens:fh(n)}:{token:Te(yt(n),n)}}function qu(e,t,n){const i=[is(t[1]==="^",t)];let r=1,s;for(ei.lastIndex=n;s=ei.exec(e);){const o=s[0];if(o[0]==="["&&o[1]!==":")r++,i.push(is(o[1]==="^",o));else if(o==="]"){if(i.at(-1).type==="CharacterClassOpen")i.push(Te(93,o));else if(r--,i.push(Yu(o)),!r)break}else{const l=Ku(o);Array.isArray(l)?i.push(...l):i.push(l)}}return{tokens:i,lastIndex:ei.lastIndex||e.length}}function Ku(e){if(e[0]==="\\")return Qo(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!ar.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Qe("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Qu(e):e==="&&"?Zu(e):Te(yt(e),e)}function Qo(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return sh(e);if("dDhHsSwW".includes(n))return lh(e);if(e.startsWith(Y`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return dh(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const i=e.split(/\\x/).slice(1).map(o=>parseInt(o,16)),r=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(i)),s=new TextEncoder;return[...r].map(o=>{const l=[...s.encode(o)].map(a=>`\\x${a.toString(16)}`).join("");return Te(yt(o),l)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Te(uh(e),e);if(rs.has(n))return Te(rs.get(n),e);if(/\d/.test(n))return Ju(t,e);if(e==="\\")throw new Error(Y`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Te(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Xu(e){return{type:"Alternator",raw:e}}function ns(e,t){return{type:"Assertion",kind:e,raw:t}}function Zo(e){return{type:"Backreference",raw:e}}function Te(e,t){return{type:"Character",value:e,raw:t}}function Yu(e){return{type:"CharacterClassClose",raw:e}}function Qu(e){return{type:"CharacterClassHyphen",raw:e}}function Zu(e){return{type:"CharacterClassIntersector",raw:e}}function is(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Qe(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function Jo(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Ct(n.flags),raw:t}}function Ju(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function eh(e){return{type:"GroupClose",raw:e}}function dt(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function th(e,t,n,i){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:i}}function nh(e,t,n,i){return{type:"Quantifier",kind:e,min:t,max:n,raw:i}}function ih(e){return{type:"Subroutine",raw:e}}const rh=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),rs=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function sh(e){const t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Te(yt(t.toUpperCase())-64,e)}function oh(e,t){let{on:n,off:i}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;i??="";const r=(t.getCurrentModX()||n.includes("x"))&&!i.includes("x"),s=os(n),o=os(i),l={};if(s&&(l.enable=s),o&&(l.disable=o),e.endsWith(")"))return t.replaceCurrentModX(r),Jo("flags",e,{flags:l});if(e.endsWith(":"))return t.pushModX(r),t.numOpenGroups++,dt("group",e,{...(s||o)&&{flags:l}});throw new Error(`Unexpected flag modifier "${e}"`)}function ah(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:i,args:r}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(i==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const s=r?r.split(",").filter(c=>c!=="").map(c=>/^[+-]?\d+$/.test(c)?+c:c):[],[o,l,a]=s,d=rh.has(n)?n.toLowerCase():"custom";switch(d){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(typeof o=="string")throw new Error(`Named callout argument must be a number "${o}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(s.length===2&&(typeof l=="number"||!/^[<>X]$/.test(l)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${l}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(s.length===1&&(typeof o=="number"||!/^[<>X]$/.test(o)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case"cmp":if(s.length!==3)throw new Error(`Named callout must have three arguments "${s}"`);if(typeof o=="string"&&!/^[A-Za-z_]\w*$/.test(o))throw new Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof l=="number"||!/^(?:[<>!=]=|[<>])$/.test(l))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${l}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument three must be a tag or number "${a}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${d}"`)}return th(d,i??null,r?.split(",")??null,e)}function ss(e){let t=null,n,i;if(e[0]==="{"){const{minStr:r,maxStr:s}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+r>o||s&&+s>o)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+r,i=s===void 0?+r:s===""?1/0:+s,n>i&&(t="possessive",[n,i]=[i,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,i=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return nh(t,n,i,e)}function lh(e){const t=e[1].toLowerCase();return Qe({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function dh(e){const{p:t,neg:n,value:i}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Qe("property",e,{value:i,negate:t==="P"&&!n||t==="p"&&!!n})}function os(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function ch(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){const i=e[n];if(!"imxDPSWy".includes(i))throw new Error(`Invalid flag "${i}"`);if(i==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[i]]=!0}return t}function uh(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function hh(e,t){const{raw:n,inCharClass:i}=e,r=n.slice(1);if(!i&&(r!=="0"&&r.length===1||r[0]!=="0"&&+r<=t))return[Zo(n)];const s=[],o=r.match(/^[0-7]+|\d/g);for(let l=0;l<o.length;l++){const a=o[l];let d;if(l===0&&a!=="8"&&a!=="9"){if(d=parseInt(a,8),d>127)throw new Error(Y`Octal encoded byte above 177 unsupported "${n}"`)}else d=yt(a);s.push(Te(d,(l===0?"\\":"")+a))}return s}function fh(e){const t=[],n=new RegExp(lr,"gy");let i;for(;i=n.exec(e);){const r=i[0];if(r[0]==="{"){const s=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(r);if(s){const{min:o,max:l}=s.groups;if(+o>+l&&r.endsWith("?")){n.lastIndex--,t.push(ss(r.slice(0,-1)));continue}}}t.push(ss(r))}return t}function ea(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const n=e.body[0];return!t||Object.keys(t).every(i=>t[i]===n[i])}function ph(e){return gh.has(e.type)}const gh=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function ta(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},i=Wu(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),r=(h,f)=>{const p=i.tokens[s.nextIndex];switch(s.parent=h,s.nextIndex++,p.type){case"Alternator":return nt();case"Assertion":return mh(p);case"Backreference":return bh(p,s);case"Character":return Dn(p.value,{useLastValid:!!f.isCheckingRangeEnd});case"CharacterClassHyphen":return vh(p,s,f);case"CharacterClassOpen":return yh(p,s,f);case"CharacterSet":return Ch(p,s);case"Directive":return Eh(p.kind,{flags:p.flags});case"GroupOpen":return Sh(p,s,f);case"NamedCallout":return _h(p.kind,p.tag,p.arguments);case"Quantifier":return wh(p,s);case"Subroutine":return xh(p,s);default:throw new Error(`Unexpected token type "${p.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:i.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:r},o=Ih(Ah(i.flags));let l=o.body[0];for(;s.nextIndex<i.tokens.length;){const h=r(l,{});h.type==="Alternative"?(o.body.push(h),l=h):l.body.push(h)}const{capturingGroups:a,hasNumberedRef:d,namedGroupsByName:c,subroutines:u}=s;if(d&&c.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:h}of u)if(typeof h=="number"){if(h>a.length)throw new Error("Subroutine uses a group number that's not defined");h&&(a[h-1].isSubroutined=!0)}else if(c.has(h)){if(c.get(h).length>1)throw new Error(Y`Subroutine uses a duplicate group name "\g<${h}>"`);c.get(h)[0].isSubroutined=!0}else throw new Error(Y`Subroutine uses a group name that's not defined "\g<${h}>"`);return o}function mh({kind:e}){return Fi(Ct({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===Y`\B`||e===Y`\Y`})}function bh({raw:e},t){const n=/^\\k[<']/.test(e),i=n?e.slice(3,-1):e.slice(1),r=(s,o=!1)=>{const l=t.capturingGroups.length;let a=!1;if(s>l)if(t.skipBackrefValidation)a=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,$i(o?l+1-s:s,{orphan:a})};if(n){const s=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(i);if(s)return r(+s.groups.num,!!s.groups.sign);if(/[-+]/.test(i))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(i))throw new Error(`Group name not defined to the left "${e}"`);return $i(i)}return r(+i)}function vh(e,t,n){const{tokens:i,walk:r}=t,s=t.parent,o=s.body.at(-1),l=i[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!=="CharacterClass"&&o.type!=="CharacterClassRange"&&l&&l.type!=="CharacterClassOpen"&&l.type!=="CharacterClassClose"&&l.type!=="CharacterClassIntersector"){const a=r(s,{...n,isCheckingRangeEnd:!0});if(o.type==="Character"&&a.type==="Character")return s.body.pop(),Lh(o,a);throw new Error("Invalid character class range")}return Dn(yt("-"))}function yh({negate:e},t,n){const{tokens:i,walk:r}=t,s=[un()],o=i[t.nextIndex];let l=ds(o);for(;l.type!=="CharacterClassClose";){if(l.type==="CharacterClassIntersector")s.push(un()),t.nextIndex++;else{const d=s.at(-1);d.body.push(r(d,n))}l=ds(i[t.nextIndex],o)}const a=un({negate:e});return s.length===1?a.body=s[0].body:(a.kind="intersection",a.body=s.map(d=>d.body.length===1?d.body[0]:d)),t.nextIndex++,a}function Ch({kind:e,negate:t,value:n},i){const{normalizeUnknownPropertyNames:r,skipPropertyNameValidation:s,unicodePropertyMap:o}=i;if(e==="property"){const l=Fn(n);if(ar.has(l)&&!o?.has(l))e="posix",n=l;else return ct(n,{negate:t,normalizeUnknownPropertyNames:r,skipPropertyNameValidation:s,unicodePropertyMap:o})}return e==="posix"?Rh(n,{negate:t}):Oi(e,{negate:t})}function Sh(e,t,n){const{tokens:i,capturingGroups:r,namedGroupsByName:s,skipLookbehindValidation:o,walk:l}=t,a=Th(e),d=a.type==="AbsenceFunction",c=ls(a),u=c&&a.negate;if(a.type==="CapturingGroup"&&(r.push(a),a.name&&ju(s,a.name,[]).push(a)),d&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let h=cs(i[t.nextIndex]);for(;h.type!=="GroupClose";){if(h.type==="Alternator")a.body.push(nt()),t.nextIndex++;else{const f=a.body.at(-1),p=l(f,{...n,isInAbsenceFunction:n.isInAbsenceFunction||d,isInLookbehind:n.isInLookbehind||c,isInNegLookbehind:n.isInNegLookbehind||u});if(f.body.push(p),(c||n.isInLookbehind)&&!o){const g="Lookbehind includes a pattern not allowed by Oniguruma";if(u||n.isInNegLookbehind){if(as(p)||p.type==="CapturingGroup")throw new Error(g)}else if(as(p)||ls(p)&&p.negate)throw new Error(g)}}h=cs(i[t.nextIndex])}return t.nextIndex++,a}function wh({kind:e,min:t,max:n},i){const r=i.parent,s=r.body.at(-1);if(!s||!ph(s))throw new Error("Quantifier requires a repeatable token");const o=ia(e,t,n,s);return r.body.pop(),o}function xh({raw:e},t){const{capturingGroups:n,subroutines:i}=t;let r=e.slice(3,-1);const s=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(r);if(s){const l=+s.groups.num,a=n.length;if(t.hasNumberedRef=!0,r={"":l,"+":a+l,"-":a+1-l}[s.groups.sign],r<1)throw new Error("Invalid subroutine number")}else r==="0"&&(r=0);const o=ra(r);return i.push(o),o}function kh(e,t){return{type:"AbsenceFunction",kind:e,body:Ft(t?.body)}}function nt(e){return{type:"Alternative",body:sa(e?.body)}}function Fi(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function $i(e,t){const n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function na(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!Ph(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Ft(t?.body)}}function Dn(e,t){const n={useLastValid:!1,...t};if(e>1114111){const i=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${i}}"`):new Error(`Invalid code point out of range in JS "\\x{${i}}"`)}return{type:"Character",value:e}}function un(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:sa(e?.body)}}function Lh(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function Oi(e,t){const n=!!t?.negate,i={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(i.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(i.variableLength=!0),i}function Eh(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Ct(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function Ah(e){return{type:"Flags",...e}}function pe(e){const t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:Ft(e?.body)}}function Ke(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Ft(e?.body)}}function _h(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function Rh(e,t){const n=!!t?.negate;if(!ar.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function ia(e,t,n,i){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:i}}function Ih(e,t){return{type:"Regex",body:Ft(t?.body),flags:e}}function ra(e){return{type:"Subroutine",ref:e}}function ct(e,t){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let i=n.unicodePropertyMap?.get(Fn(e));if(!i){if(n.normalizeUnknownPropertyNames)i=Nh(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Y`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:i??e,negate:n.negate}}function Th({flags:e,kind:t,name:n,negate:i,number:r}){switch(t){case"absence_repeater":return kh("repeater");case"atomic":return pe({atomic:!0});case"capturing":return na(r,{name:n});case"group":return pe({flags:e});case"lookahead":case"lookbehind":return Ke({behind:t==="lookbehind",negate:i});default:throw new Error(`Unexpected group kind "${t}"`)}}function Ft(e){if(e===void 0)e=[nt()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function sa(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function as(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function ls(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function Ph(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function Nh(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function Fn(e){return e.replace(/[- _]+/g,"").toLowerCase()}function ds(e,t){const n=t;return Ct(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function cs(e){return Ct(e,"Unclosed group")}function At(e,t,n=null){function i(s,o){for(let l=0;l<s.length;l++){const a=r(s[l],o,l,s);l=Math.max(-1,l+a)}}function r(s,o=null,l=null,a=null){let d=0,c=!1;const u={node:s,parent:o,key:l,container:a,root:e,remove(){Kt(a).splice(Math.max(0,st(l)+d),1),d--,c=!0},removeAllNextSiblings(){return Kt(a).splice(st(l)+1)},removeAllPrevSiblings(){const m=st(l)+d;return d-=m,Kt(a).splice(0,Math.max(0,m))},replaceWith(m,b={}){const y=!!b.traverse;a?a[Math.max(0,st(l)+d)]=m:Ct(o,"Can't replace root node")[l]=m,y&&r(m,o,l,a),c=!0},replaceWithMultiple(m,b={}){const y=!!b.traverse;if(Kt(a).splice(Math.max(0,st(l)+d),1,...m),d+=m.length-1,y){let S=0;for(let C=0;C<m.length;C++)S+=r(m[C],o,st(l)+C+S,a)}c=!0},skip(){c=!0}},{type:h}=s,f=t["*"],p=t[h],g=typeof f=="function"?f:f?.enter,v=typeof p=="function"?p:p?.enter;if(g?.(u,n),v?.(u,n),!c)switch(h){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":i(s.body,s);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":r(s.min,s,"min"),r(s.max,s,"max");break;case"Quantifier":r(s.body,s,"body");break;case"Regex":i(s.body,s),r(s.flags,s,"flags");break;default:throw new Error(`Unexpected node type "${h}"`)}return p?.exit?.(u,n),f?.exit?.(u,n),d}return r(e),e}function Kt(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function st(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const Mh=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Hh(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Dh(e,t,n,i){return e.slice(0,t)+i+e.slice(t+n.length)}const de=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function dr(e,t,n,i){const r=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),s=[!1];let o=0,l="";for(const a of e.matchAll(r)){const{0:d,groups:{$skip:c}}=a;if(!c&&(!i||i===de.DEFAULT==!o)){n instanceof Function?l+=n(a,{context:o?de.CHAR_CLASS:de.DEFAULT,negated:s[s.length-1]}):l+=n;continue}d[0]==="["?(o++,s.push(d[1]==="^")):d==="]"&&o&&(o--,s.pop()),l+=d}return l}function oa(e,t,n,i){dr(e,t,n,i)}function Fh(e,t,n=0,i){if(!new RegExp(t,"su").test(e))return null;const r=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");r.lastIndex=n;let s=0,o;for(;o=r.exec(e);){const{0:l,groups:{$skip:a}}=o;if(!a&&(!i||i===de.DEFAULT==!s))return o;l==="["?s++:l==="]"&&s&&s--,r.lastIndex==o.index&&r.lastIndex++}return null}function Xt(e,t,n){return!!Fh(e,t,0,n)}function $h(e,t){const n=/\\?./gsu;n.lastIndex=t;let i=e.length,r=0,s=1,o;for(;o=n.exec(e);){const[l]=o;if(l==="[")r++;else if(r)l==="]"&&r--;else if(l==="(")s++;else if(l===")"&&(s--,!s)){i=o.index;break}}return e.slice(t,i)}const us=new RegExp(String.raw`(?<noncapturingStart>${Mh})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Oh(e,t){const n=t?.hiddenCaptures??[];let i=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};const r="(?>",s="(?:(?=(",o=[0],l=[];let a=0,d=0,c=NaN,u;do{u=!1;let h=0,f=0,p=!1,g;for(us.lastIndex=Number.isNaN(c)?0:c+s.length;g=us.exec(e);){const{0:v,index:m,groups:{capturingStart:b,noncapturingStart:y}}=g;if(v==="[")h++;else if(h)v==="]"&&h--;else if(v===r&&!p)c=m,p=!0;else if(p&&y)f++;else if(b)p?f++:(a++,o.push(a+d));else if(v===")"&&p){if(!f){d++;const S=a+d;if(e=`${e.slice(0,c)}${s}${e.slice(c+r.length,m)}))<$$${S}>)${e.slice(m+1)}`,u=!0,l.push(S),Hh(n,S),i.size){const C=new Map;i.forEach((w,x)=>{C.set(x>=S?x+1:x,w.map(E=>E>=S?E+1:E))}),i=C}break}f--}}}while(u);return n.push(...l),e=dr(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:h,groups:{backrefNum:f,wrappedBackrefNum:p}})=>{if(f){const g=+f;if(g>o.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${o[g]}`}return`\\${p}`},de.DEFAULT),{pattern:e,captureTransfers:i,hiddenCaptures:n}}const aa=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,ti=new RegExp(String.raw`
70
+ \\(?: \d+
71
+ | c[A-Za-z]
72
+ | [gk]<[^>]+>
73
+ | [pPu]\{[^\}]+\}
74
+ | u[A-Fa-f\d]{4}
75
+ | x[A-Fa-f\d]{2}
76
+ )
77
+ | \((?: \? (?: [:=!>]
78
+ | <(?:[=!]|[^>]+>)
79
+ | [A-Za-z\-]+:
80
+ | \(DEFINE\)
81
+ ))?
82
+ | (?<qBase>${aa})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
83
+ | \\?.
84
+ `.replace(/\s+/g,""),"gsu");function Uh(e){if(!new RegExp(`${aa}\\+`).test(e))return{pattern:e};const t=[];let n=null,i=null,r="",s=0,o;for(ti.lastIndex=0;o=ti.exec(e);){const{0:l,index:a,groups:{qBase:d,qMod:c,invalidQ:u}}=o;if(l==="[")s||(i=a),s++;else if(l==="]")s?s--:i=null;else if(!s)if(c==="+"&&r&&!r.startsWith("(")){if(u)throw new Error(`Invalid quantifier "${l}"`);let h=-1;if(/^\{\d+\}$/.test(d))e=Dh(e,a+d.length,c,"");else{if(r===")"||r==="]"){const f=r===")"?n:i;if(f===null)throw new Error(`Invalid unmatched "${r}"`);e=`${e.slice(0,f)}(?>${e.slice(f,a)}${d})${e.slice(a+l.length)}`}else e=`${e.slice(0,a-r.length)}(?>${r}${d})${e.slice(a+l.length)}`;h+=4}ti.lastIndex+=h}else l[0]==="("?t.push(a):l===")"&&(n=t.length?t.pop():null);r=l}return{pattern:e}}const ae=String.raw,Bh=ae`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Ui=ae`\(\?R=(?<rDepth>[^\)]+)\)|${Bh}`,$n=ae`\(\?<(?![=!])(?<captureName>[^>]+)>`,la=ae`${$n}|(?<unnamed>\()(?!\?)`,Ve=new RegExp(ae`${$n}|${Ui}|\(\?|\\?.`,"gsu"),ni="Cannot use multiple overlapping recursions";function Gh(e,t){const{hiddenCaptures:n,mode:i}={hiddenCaptures:[],mode:"plugin",...t};let r=t?.captureTransfers??new Map;if(!new RegExp(Ui,"su").test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};if(i==="plugin"&&Xt(e,ae`\(\?\(DEFINE\)`,de.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const s=[],o=Xt(e,ae`\\[1-9]`,de.DEFAULT),l=new Map,a=[];let d=!1,c=0,u=0,h;for(Ve.lastIndex=0;h=Ve.exec(e);){const{0:f,groups:{captureName:p,rDepth:g,gRNameOrNum:v,gRDepth:m}}=h;if(f==="[")c++;else if(c)f==="]"&&c--;else if(g){if(hs(g),d)throw new Error(ni);if(o)throw new Error(`${i==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const b=e.slice(0,h.index),y=e.slice(Ve.lastIndex);if(Xt(y,Ui,de.DEFAULT))throw new Error(ni);const S=+g-1;e=fs(b,y,S,!1,n,s,u),r=gs(r,b,S,s.length,0,u);break}else if(v){hs(m);let b=!1;for(const L of a)if(L.name===v||L.num===+v){if(b=!0,L.hasRecursedWithin)throw new Error(ni);break}if(!b)throw new Error(ae`Recursive \g cannot be used outside the referenced group "${i==="external"?v:ae`\g<${v}&R=${m}>`}"`);const y=l.get(v),S=$h(e,y);if(o&&Xt(S,ae`${$n}|\((?!\?)`,de.DEFAULT))throw new Error(`${i==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const C=e.slice(y,h.index),w=S.slice(C.length+f.length),x=s.length,E=+m-1,k=fs(C,w,E,!0,n,s,u);r=gs(r,C,E,s.length-x,x,u);const _=e.slice(0,y),F=e.slice(y+S.length);e=`${_}${k}${F}`,Ve.lastIndex+=k.length-f.length-C.length-w.length,a.forEach(L=>L.hasRecursedWithin=!0),d=!0}else if(p)u++,l.set(String(u),Ve.lastIndex),l.set(p,Ve.lastIndex),a.push({num:u,name:p});else if(f[0]==="("){const b=f==="(";b&&(u++,l.set(String(u),Ve.lastIndex)),a.push(b?{num:u}:{})}else f===")"&&a.pop()}return n.push(...s),{pattern:e,captureTransfers:r,hiddenCaptures:n}}function hs(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function fs(e,t,n,i,r,s,o){const l=new Set;i&&oa(e+t,$n,({groups:{captureName:d}})=>{l.add(d)},de.DEFAULT);const a=[n,i?l:null,r,s,o];return`${e}${ps(`(?:${e}`,"forward",...a)}(?:)${ps(`${t})`,"backward",...a)}${t}`}function ps(e,t,n,i,r,s,o){const a=c=>t==="forward"?c+2:n-c+2-1;let d="";for(let c=0;c<n;c++){const u=a(c);d+=dr(e,ae`${la}|\\k<(?<backref>[^>]+)>`,({0:h,groups:{captureName:f,unnamed:p,backref:g}})=>{if(g&&i&&!i.has(g))return h;const v=`_$${u}`;if(p||f){const m=o+s.length+1;return s.push(m),zh(r,m),p?h:`(?<${f}${v}>`}return ae`\k<${g}${v}>`},de.DEFAULT)}return d}function zh(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function gs(e,t,n,i,r,s){if(e.size&&i){let o=0;oa(t,la,()=>o++,de.DEFAULT);const l=s-o+r,a=new Map;return e.forEach((d,c)=>{const u=(i-o*n)/n,h=o*n,f=c>l+o?c+i:c,p=[];for(const g of d)if(g<=l)p.push(g);else if(g>l+o+u)p.push(g+i);else if(g<=l+o)for(let v=0;v<=n;v++)p.push(g+o*v);else for(let v=0;v<=n;v++)p.push(g+h+u*v);a.set(f,p)}),a}return e}var V=String.fromCodePoint,I=String.raw,ge={},On=globalThis.RegExp;ge.flagGroups=(()=>{try{new On("(?i:)")}catch{return!1}return!0})();ge.unicodeSets=(()=>{try{new On("[[]]","v")}catch{return!1}return!0})();ge.bugFlagVLiteralHyphenIsRange=ge.unicodeSets?(()=>{try{new On(I`[\d\-a]`,"v")}catch{return!0}return!1})():!1;ge.bugNestedClassIgnoresNegation=ge.unicodeSets&&new On("[[^a]]","v").test("a");function En(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function Nt(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Bi(e,t){return ms[e]>=ms[t]}function jh(e,t){if(e==null)throw new Error(t??"Value expected");return e}var ms={ES2025:2025,ES2024:2024,ES2018:2018},Wh={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function da(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!Wh[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=ge.flagGroups?"ES2025":ge.unicodeSets?"ES2024":"ES2018"),t}var Vh="[ -\r ]",qh=new Set([V(304),V(305)]),Le=I`[\p{L}\p{M}\p{N}\p{Pc}]`;function ca(e){if(qh.has(e))return[e];const t=new Set,n=e.toLowerCase(),i=n.toUpperCase(),r=Yh.get(n),s=Kh.get(n),o=Xh.get(n);return[...i].length===1&&t.add(i),o&&t.add(o),r&&t.add(r),t.add(n),s&&t.add(s),[...t]}var cr=new Map(`C Other
85
+ Cc Control cntrl
86
+ Cf Format
87
+ Cn Unassigned
88
+ Co Private_Use
89
+ Cs Surrogate
90
+ L Letter
91
+ LC Cased_Letter
92
+ Ll Lowercase_Letter
93
+ Lm Modifier_Letter
94
+ Lo Other_Letter
95
+ Lt Titlecase_Letter
96
+ Lu Uppercase_Letter
97
+ M Mark Combining_Mark
98
+ Mc Spacing_Mark
99
+ Me Enclosing_Mark
100
+ Mn Nonspacing_Mark
101
+ N Number
102
+ Nd Decimal_Number digit
103
+ Nl Letter_Number
104
+ No Other_Number
105
+ P Punctuation punct
106
+ Pc Connector_Punctuation
107
+ Pd Dash_Punctuation
108
+ Pe Close_Punctuation
109
+ Pf Final_Punctuation
110
+ Pi Initial_Punctuation
111
+ Po Other_Punctuation
112
+ Ps Open_Punctuation
113
+ S Symbol
114
+ Sc Currency_Symbol
115
+ Sk Modifier_Symbol
116
+ Sm Math_Symbol
117
+ So Other_Symbol
118
+ Z Separator
119
+ Zl Line_Separator
120
+ Zp Paragraph_Separator
121
+ Zs Space_Separator
122
+ ASCII
123
+ ASCII_Hex_Digit AHex
124
+ Alphabetic Alpha
125
+ Any
126
+ Assigned
127
+ Bidi_Control Bidi_C
128
+ Bidi_Mirrored Bidi_M
129
+ Case_Ignorable CI
130
+ Cased
131
+ Changes_When_Casefolded CWCF
132
+ Changes_When_Casemapped CWCM
133
+ Changes_When_Lowercased CWL
134
+ Changes_When_NFKC_Casefolded CWKCF
135
+ Changes_When_Titlecased CWT
136
+ Changes_When_Uppercased CWU
137
+ Dash
138
+ Default_Ignorable_Code_Point DI
139
+ Deprecated Dep
140
+ Diacritic Dia
141
+ Emoji
142
+ Emoji_Component EComp
143
+ Emoji_Modifier EMod
144
+ Emoji_Modifier_Base EBase
145
+ Emoji_Presentation EPres
146
+ Extended_Pictographic ExtPict
147
+ Extender Ext
148
+ Grapheme_Base Gr_Base
149
+ Grapheme_Extend Gr_Ext
150
+ Hex_Digit Hex
151
+ IDS_Binary_Operator IDSB
152
+ IDS_Trinary_Operator IDST
153
+ ID_Continue IDC
154
+ ID_Start IDS
155
+ Ideographic Ideo
156
+ Join_Control Join_C
157
+ Logical_Order_Exception LOE
158
+ Lowercase Lower
159
+ Math
160
+ Noncharacter_Code_Point NChar
161
+ Pattern_Syntax Pat_Syn
162
+ Pattern_White_Space Pat_WS
163
+ Quotation_Mark QMark
164
+ Radical
165
+ Regional_Indicator RI
166
+ Sentence_Terminal STerm
167
+ Soft_Dotted SD
168
+ Terminal_Punctuation Term
169
+ Unified_Ideograph UIdeo
170
+ Uppercase Upper
171
+ Variation_Selector VS
172
+ White_Space space
173
+ XID_Continue XIDC
174
+ XID_Start XIDS`.split(/\s/).map(e=>[Fn(e),e])),Kh=new Map([["s",V(383)],[V(383),"s"]]),Xh=new Map([[V(223),V(7838)],[V(107),V(8490)],[V(229),V(8491)],[V(969),V(8486)]]),Yh=new Map([Oe(453),Oe(456),Oe(459),Oe(498),...ii(8072,8079),...ii(8088,8095),...ii(8104,8111),Oe(8124),Oe(8140),Oe(8188)]),Qh=new Map([["alnum",I`[\p{Alpha}\p{Nd}]`],["alpha",I`\p{Alpha}`],["ascii",I`\p{ASCII}`],["blank",I`[\p{Zs}\t]`],["cntrl",I`\p{Cc}`],["digit",I`\p{Nd}`],["graph",I`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",I`\p{Lower}`],["print",I`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",I`[\p{P}\p{S}]`],["space",I`\p{space}`],["upper",I`\p{Upper}`],["word",I`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",I`\p{AHex}`]]);function Zh(e,t){const n=[];for(let i=e;i<=t;i++)n.push(i);return n}function Oe(e){const t=V(e);return[t.toLowerCase(),t]}function ii(e,t){return Zh(e,t).map(n=>Oe(n))}var ua=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function Jh(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};ha(e);const i={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Bi(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};At(e,ef,i);const r={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},s={currentFlags:r,prevFlags:null,globalFlags:r,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:i.subroutineRefMap};At(e,tf,s);const o={groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer};return At(e,nf,o),e._originMap=s.groupOriginByCopy,e._strategy=i.strategy,e}var ef={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:i,kind:r}=e;if(r==="repeater"){const s=pe();s.body[0].body.push(Ke({negate:!0,body:i}),ct("Any"));const o=pe();o.body[0].body.push(ia("greedy",0,1/0,s)),n(z(o,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:i}){const r=e.body.filter(s=>s.kind==="flags");for(let s=n+1;s<t.body.length;s++){const o=t.body[s];Nt(i,o,[]).push(...r)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){const n=pa(t.get(e));if(n){const i=pe({flags:n});i.body[0].body=e.body,e.body=[z(i,e)]}}}},Assertion({node:e,parent:t,key:n,container:i,root:r,remove:s,replaceWith:o},l){const{kind:a,negate:d}=e,{asciiWordBoundaries:c,avoidSubclass:u,supportedGNodes:h,wordIsAscii:f}=l;if(a==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${d?"Y":"y"}"`);if(a==="line_end")o(z(Ke({body:[nt({body:[Fi("string_end")]}),nt({body:[Dn(10)]})]}),t));else if(a==="line_start")o(z(Ee(I`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(a==="search_start")if(h.has(e))r.flags.sticky=!0,s();else{const p=i[n-1];if(p&&df(p))o(z(Ke({negate:!0}),t));else{if(u)throw new Error(I`Uses "\G" in a way that requires a subclass`);o(Ue(Fi("string_start"),t)),l.strategy="clip_search"}}else if(!(a==="string_end"||a==="string_start"))if(a==="string_end_newline")o(z(Ee(I`(?=\n?\z)`),t));else if(a==="word_boundary"){if(!f&&!c){const p=`(?:(?<=${Le})(?!${Le})|(?<!${Le})(?=${Le}))`,g=`(?:(?<=${Le})(?=${Le})|(?<!${Le})(?!${Le}))`;o(z(Ee(d?g:p),t))}}else throw new Error(`Unexpected assertion kind "${a}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!si(n)&&(n=ri(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:i}=e;i&&!si(i)&&(i=ri(i,t),e.name=i),n.set(e.number,e),i&&n.set(i,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){const i=un({body:[e]});n(z(i,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:i,minTargetEs2024:r,digitIsAscii:s,spaceIsAscii:o,wordIsAscii:l}){const{kind:a,negate:d,value:c}=e;if(s&&(a==="digit"||c==="digit")){n(Ue(Oi("digit",{negate:d}),t));return}if(o&&(a==="space"||c==="space")){n(z(oi(Ee(Vh),d),t));return}if(l&&(a==="word"||c==="word")){n(Ue(Oi("word",{negate:d}),t));return}if(a==="any")n(Ue(ct("Any"),t));else if(a==="digit")n(Ue(ct("Nd",{negate:d}),t));else if(a!=="dot")if(a==="text_segment"){if(i==="strict")throw new Error(I`Use of "\X" requires non-strict accuracy`);const u="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",h=I`\p{RI}{2}|${u}(?:\u200D${u})*`;n(z(Ee(I`(?>\r\n|${r?I`\p{RGI_Emoji}`:h}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(a==="hex")n(Ue(ct("AHex",{negate:d}),t));else if(a==="newline")n(z(Ee(d?`[^
175
+ ]`:`(?>\r
176
+ ?|[
177
+ \v\f…\u2028\u2029])`),t));else if(a==="posix")if(!r&&(c==="graph"||c==="print")){if(i==="strict")throw new Error(`POSIX class "${c}" requires min target ES2024 or non-strict accuracy`);let u={graph:"!-~",print:" -~"}[c];d&&(u=`\0-${V(u.codePointAt(0)-1)}${V(u.codePointAt(2)+1)}-􏿿`),n(z(Ee(`[${u}]`),t))}else n(z(oi(Ee(Qh.get(c)),d),t));else if(a==="property")cr.has(Fn(c))||(e.key="sc");else if(a==="space")n(Ue(ct("space",{negate:d}),t));else if(a==="word")n(z(oi(Ee(Le),d),t));else throw new Error(`Unexpected character set kind "${a}"`)},Directive({node:e,parent:t,root:n,remove:i,replaceWith:r,removeAllPrevSiblings:s,removeAllNextSiblings:o}){const{kind:l,flags:a}=e;if(l==="flags")if(!a.enable&&!a.disable)i();else{const d=pe({flags:a});d.body[0].body=o(),r(z(d,t),{traverse:!0})}else if(l==="keep"){const d=n.body[0],u=n.body.length===1&&ea(d,{type:"Group"})&&d.body[0].body.length===1?d.body[0]:n;if(t.parent!==u||u.body.length>1)throw new Error(I`Uses "\K" in a way that's unsupported`);const h=Ke({behind:!0});h.body[0].body=s(),r(z(h,t))}else throw new Error(`Unexpected directive kind "${l}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:i}=e;if(i==="fail")n(z(Ke({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${i.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=pe();t.body[0].body.push(e.body),e.body=z(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let i=!1,r=!1;for(const s of e.body)if(s.body.length===1&&s.body[0].kind==="search_start")s.body.pop();else{const o=ma(s.body);o?(i=!0,Array.isArray(o)?n.push(...o):n.push(o)):r=!0}i&&!r&&n.forEach(s=>t.add(s))},exit(e,{accuracy:t,passedLookbehind:n,strategy:i}){if(t==="strict"&&n&&i)throw new Error(I`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!si(n)&&(n=ri(n,t),e.ref=n)}},tf={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:i,ref:r}=e;i||n.set(e,[...t.get(r).map(({node:s})=>s)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:i},{groupOriginByCopy:r,groupsByName:s,multiplexCapturesToLeftByRef:o,openRefs:l,reffedNodesByReferencer:a}){const d=r.get(e);if(d&&l.has(e.number)){const u=Ue(bs(e.number),t);a.set(u,l.get(e.number)),n(u);return}l.set(e.number,e),o.set(e.number,[]),e.name&&Nt(o,e.name,[]);const c=o.get(e.name??e.number);for(let u=0;u<c.length;u++){const h=c[u];if(d===h.node||d&&d===h.origin||e===h.origin){c.splice(u,1);break}}if(o.get(e.number).push({node:e,origin:d}),e.name&&o.get(e.name).push({node:e,origin:d}),e.name){const u=Nt(s,e.name,new Map);let h=!1;if(d)h=!0;else for(const f of u.values())if(!f.hasDuplicateNameToRemove){h=!0;break}s.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:h})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=En(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},i){const{isRecursive:r,ref:s}=e;if(r){let c=t;for(;(c=c.parent)&&!(c.type==="CapturingGroup"&&(c.name===s||c.number===s)););i.reffedNodesByReferencer.set(e,c);return}const o=i.subroutineRefMap.get(s),l=s===0,a=l?bs(0):fa(o,i.groupOriginByCopy,null);let d=a;if(!l){const c=pa(of(o,h=>h.type==="Group"&&!!h.flags)),u=c?En(i.globalFlags,c):i.globalFlags;rf(u,i.currentFlags)||(d=pe({flags:af(u)}),d.body[0].body.push(a))}n(z(d,t),{traverse:!l})}},nf={Backreference({node:e,parent:t,replaceWith:n},i){if(e.orphan){i.highestOrphanBackref=Math.max(i.highestOrphanBackref,e.ref);return}const s=i.reffedNodesByReferencer.get(e).filter(o=>sf(o,e));if(!s.length)n(z(Ke({negate:!0}),t));else if(s.length>1){const o=pe({atomic:!0,body:s.reverse().map(l=>nt({body:[$i(l.number)]}))});n(z(o,t))}else e.ref=s[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let i=0;i<n;i++){const r=na();e.body.at(-1).body.push(r)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function ha(e){At(e,{"*"({node:t,parent:n}){t.parent=n}})}function rf(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function sf(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const i=ga(n.parent);for(const r of i){if(r===n)break;if(r===e||ba(r,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function fa(e,t,n,i){const r=Array.isArray(e)?[]:{};for(const[s,o]of Object.entries(e))s==="parent"?r.parent=Array.isArray(n)?i:n:o&&typeof o=="object"?r[s]=fa(o,t,r,n):(s==="type"&&o==="CapturingGroup"&&t.set(r,t.get(e)??e),r[s]=o);return r}function bs(e){const t=ra(e);return t.isRecursive=!0,t}function of(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function ri(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function pa(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:i})=>{t.forEach(r=>{i.enable?.[r]&&(delete n.disable[r],n.enable[r]=!0),i.disable?.[r]&&(n.disable[r]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function af({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function ga(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function ma(e){const t=e.find(n=>n.kind==="search_start"||cf(n,{negate:!1})||!lf(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const i of t.body){const r=ma(i.body);if(!r)return null;Array.isArray(r)?n.push(...r):n.push(r)}return n}return null}function ba(e,t){const n=ga(e)??[];for(const i of n)if(i===t||ba(i,t))return!0;return!1}function lf({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function df(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function cf(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&ea(e.body[0],{type:"Assertion",kind:"search_start"})}function si(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Ee(e,t){const i=ta(e,{...t,unicodePropertyMap:cr}).body;return i.length>1||i[0].body.length>1?pe({body:i}):i[0].body[0]}function oi(e,t){return e.negate=t,e}function Ue(e,t){return e.parent=t,e}function z(e,t){return ha(e),e.parent=t,e}function uf(e,t){const n=da(t),i=Bi(n.target,"ES2024"),r=Bi(n.target,"ES2025"),s=n.rules.recursionLimit;if(!Number.isInteger(s)||s<2||s>20)throw new Error("Invalid recursionLimit; use 2-20");let o=null,l=null;if(!r){const f=[e.flags.ignoreCase];At(e,hf,{getCurrentModI:()=>f.at(-1),popModI(){f.pop()},pushModI(p){f.push(p)},setHasCasedChar(){f.at(-1)?o=!0:l=!0}})}const a={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!l)};let d=e;const c={accuracy:n.accuracy,appliedGlobalFlags:a,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:d,originMap:e._originMap,recursionLimit:s,useAppliedIgnoreCase:!!(!r&&o&&l),useFlagMods:r,useFlagV:i,verbose:n.verbose};function u(f){return c.lastNode=d,d=f,jh(ff[f.type],`Unexpected node type "${f.type}"`)(f,c,u)}const h={pattern:e.body.map(u).join("|"),flags:u(e.flags),options:{...e.options}};return i||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],c.captureMap.forEach((f,p)=>{f.hidden&&h._hiddenCaptures.push(p),f.transferTo&&Nt(h._captureTransfers,f.transferTo,[]).push(p)}),h}var hf={"*":{enter({node:e},t){if(ys(e)){const n=t.getCurrentModI();t.pushModI(e.flags?En({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){ys(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){ur(V(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),va(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&ua.has(e.value)&&t.setHasCasedChar()}},ff={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?I`\B`:I`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:i,name:r,number:s}=e,o={ignoreCase:t.currentFlags.ignoreCase},l=t.originMap.get(e);return l&&(o.hidden=!0,s>l.number&&(o.transferTo=l.number)),t.captureMap.set(s,o),`(${r?`?<${r}>`:""}${i.map(n).join("|")})`},Character({value:e},t){const n=V(e),i=ot(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(i!==n)return i;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&ur(n)){const r=ca(n);return t.inCharClass?r.join(""):r.length>1?`[${r.join("")}]`:r[0]}return n},CharacterClass(e,t,n){const{kind:i,negate:r,parent:s}=e;let{body:o}=e;if(i==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ge.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(Cs)&&(o=[Dn(45),...o.filter(d=>!Cs(d))]);const l=()=>`[${r?"^":""}${o.map(n).join(i==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ge.bugNestedClassIgnoresNegation)&&!r){const c=o.filter(u=>u.type==="CharacterClass"&&u.kind==="union"&&u.negate);if(c.length){const u=pe(),h=u.body[0];return u.parent=s,h.parent=u,o=o.filter(f=>!c.includes(f)),e.body=o,o.length?(e.parent=h,h.body.push(e)):u.body.pop(),c.forEach(f=>{const p=nt({body:[f]});f.parent=p,p.parent=u,u.body.push(p)}),n(u)}}t.inCharClass=!0;const d=l();return t.inCharClass=!1,d}const a=o[0];if(i==="union"&&!r&&a&&((!t.useFlagV||!t.verbose)&&s.kind==="union"&&!(ge.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&s.kind==="intersection"&&o.length===1&&a.type!=="CharacterClassRange"))return o.map(n).join("");if(!t.useFlagV&&s.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return l()},CharacterClassRange(e,t){const n=e.min.value,i=e.max.value,r={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},s=ot(n,r),o=ot(i,r),l=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const a=va(e);vf(a).forEach(c=>{l.add(Array.isArray(c)?`${ot(c[0],r)}-${ot(c[1],r)}`:ot(c,r))})}return`${s}-${o}${[...l].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:i},r){if(e==="dot")return r.currentFlags.dotAll?r.appliedGlobalFlags.dotAll||r.useFlagMods?".":"[^]":I`[^\n]`;if(e==="digit")return t?I`\D`:I`\d`;if(e==="property"){if(r.useAppliedIgnoreCase&&r.currentFlags.ignoreCase&&ua.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?I`\P`:I`\p`}{${i?`${i}=`:""}${n}}`}if(e==="word")return t?I`\W`:I`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:i},r,s){const o=r.currentFlags;n&&(r.currentFlags=En(o,n));const l=t.map(s).join("|"),a=!r.verbose&&t.length===1&&i.type!=="Quantifier"&&!e&&(!r.useFlagMods||!n)?l:`(?${yf(e,n,r.useFlagMods)}${l})`;return r.currentFlags=o,a},LookaroundAssertion({body:e,kind:t,negate:n},i,r){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(r).join("|")})`},Quantifier(e,t,n){return n(e.body)+Cf(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const i=n.recursionLimit;return t===0?`(?R=${i})`:I`\g<${t}&R=${i}>`}},pf=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),gf=new Set(["-","\\","]","^","["]),mf=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),vs=new Map([[9,I`\t`],[10,I`\n`],[11,I`\v`],[12,I`\f`],[13,I`\r`],[8232,I`\u2028`],[8233,I`\u2029`],[65279,I`\uFEFF`]]),bf=new RegExp("^\\p{Cased}$","u");function ur(e){return bf.test(e)}function va(e,t){const n=!!t?.firstOnly,i=e.min.value,r=e.max.value,s=[];if(i<65&&(r===65535||r>=131071)||i===65536&&r>=131071)return s;for(let o=i;o<=r;o++){const l=V(o);if(!ur(l))continue;const a=ca(l).filter(d=>{const c=d.codePointAt(0);return c<i||c>r});if(a.length&&(s.push(...a),n))break}return s}function ot(e,{escDigit:t,inCharClass:n,useFlagV:i}){if(vs.has(e))return vs.get(e);if(e<32||e>126&&e<160||e>262143||t&&Sf(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const r=n?i?mf:gf:pf,s=V(e);return(r.has(s)?"\\":"")+s}function vf(e){const t=e.map(r=>r.codePointAt(0)).sort((r,s)=>r-s),n=[];let i=null;for(let r=0;r<t.length;r++)t[r+1]===t[r]+1?i??=t[r]:i===null?n.push(t[r]):(n.push([i,t[r]]),i=null);return n}function yf(e,t,n){if(e)return">";let i="";if(t&&n){const{enable:r,disable:s}=t;i=(r?.ignoreCase?"i":"")+(r?.dotAll?"s":"")+(s?"-":"")+(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")}return`${i}:`}function Cf({kind:e,max:t,min:n}){let i;return!n&&t===1?i="?":!n&&t===1/0?i="*":n===1&&t===1/0?i="+":n===t?i=`{${n}}`:i=`{${n},${t===1/0?"":t}}`,i+{greedy:"",lazy:"?",possessive:"+"}[e]}function ys({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function Sf(e){return e>47&&e<58}function Cs({type:e,value:t}){return e==="Character"&&t===45}var wf=class Gi extends RegExp{#t=new Map;#e=null;#i;#n=null;#r=null;rawOptions={};get source(){return this.#i||"(?:)"}constructor(t,n,i){const r=!!i?.lazyCompile;if(t instanceof RegExp){if(i)throw new Error("Cannot provide options when copying a regexp");const s=t;super(s,n),this.#i=s.source,s instanceof Gi&&(this.#t=s.#t,this.#n=s.#n,this.#r=s.#r,this.rawOptions=s.rawOptions)}else{const s={hiddenCaptures:[],strategy:null,transfers:[],...i};super(r?"":t,n),this.#i=t,this.#t=kf(s.hiddenCaptures,s.transfers),this.#r=s.strategy,this.rawOptions=i??{}}r||(this.#e=this)}exec(t){if(!this.#e){const{lazyCompile:r,...s}=this.rawOptions;this.#e=new Gi(this.#i,this.flags,s)}const n=this.global||this.sticky,i=this.lastIndex;if(this.#r==="clip_search"&&n&&i){this.lastIndex=0;const r=this.#s(t.slice(i));return r&&(xf(r,i,t,this.hasIndices),this.lastIndex+=i),r}return this.#s(t)}#s(t){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,t);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const i=[...n];n.length=1;let r;this.hasIndices&&(r=[...n.indices],n.indices.length=1);const s=[0];for(let o=1;o<i.length;o++){const{hidden:l,transferTo:a}=this.#t.get(o)??{};if(l?s.push(null):(s.push(n.length),n.push(i[o]),this.hasIndices&&n.indices.push(r[o])),a&&i[o]!==void 0){const d=s[a];if(!d)throw new Error(`Invalid capture transfer to "${d}"`);if(n[d]=i[o],this.hasIndices&&(n.indices[d]=r[o]),n.groups){this.#n||(this.#n=Lf(this.source));const c=this.#n.get(a);c&&(n.groups[c]=i[o],this.hasIndices&&(n.indices.groups[c]=r[o]))}}}return n}};function xf(e,t,n,i){if(e.index+=t,e.input=n,i){const r=e.indices;for(let o=0;o<r.length;o++){const l=r[o];l&&(r[o]=[l[0]+t,l[1]+t])}const s=r.groups;s&&Object.keys(s).forEach(o=>{const l=s[o];l&&(s[o]=[l[0]+t,l[1]+t])})}}function kf(e,t){const n=new Map;for(const i of e)n.set(i,{hidden:!0});for(const[i,r]of t)for(const s of r)Nt(n,s,{}).transferTo=i;return n}function Lf(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let i=0,r=0,s;for(;s=t.exec(e);){const{0:o,groups:{capture:l,name:a}}=s;o==="["?i++:i?o==="]"&&i--:l&&(r++,a&&n.set(r,a))}return n}function Ef(e,t){const n=Af(e,t);return n.options?new wf(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Af(e,t){const n=da(t),i=ta(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:cr}),r=Jh(i,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),s=uf(r,n),o=Gh(s.pattern,{captureTransfers:s._captureTransfers,hiddenCaptures:s._hiddenCaptures,mode:"external"}),l=Uh(o.pattern),a=Oh(l.pattern,{captureTransfers:o.captureTransfers,hiddenCaptures:o.hiddenCaptures}),d={pattern:a.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${s.flags}${s.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const c=a.hiddenCaptures.sort((p,g)=>p-g),u=Array.from(a.captureTransfers),h=r._strategy,f=d.pattern.length>=n.lazyCompileLength;(c.length||u.length||h||f)&&(d.options={...c.length&&{hiddenCaptures:c},...u.length&&{transfers:u},...h&&{strategy:h},...f&&{lazyCompile:f}})}return d}function _f(e,t){return Ef(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function ya(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>_f(n,{target:t.target}),{createScanner(n){return new zu(n,t)},createString(n){return{content:n}}}}var hr=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Rf(){return 2147483648}function If(){return typeof performance<"u"?performance.now():Date.now()}const Tf=(e,t)=>e+(t-e%t)%t;async function Pf(e){let t,n;const i={};function r(f){n=f,i.HEAPU8=new Uint8Array(f),i.HEAPU32=new Uint32Array(f)}function s(f,p,g){i.HEAPU8.copyWithin(f,p,p+g)}function o(f){try{return t.grow(f-n.byteLength+65535>>>16),r(t.buffer),1}catch{}}function l(f){const p=i.HEAPU8.length;f=f>>>0;const g=Rf();if(f>g)return!1;for(let v=1;v<=4;v*=2){let m=p*(1+.2/v);m=Math.min(m,f+100663296);const b=Math.min(g,Tf(Math.max(f,m),65536));if(o(b))return!0}return!1}const a=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function d(f,p,g=1024){const v=p+g;let m=p;for(;f[m]&&!(m>=v);)++m;if(m-p>16&&f.buffer&&a)return a.decode(f.subarray(p,m));let b="";for(;p<m;){let y=f[p++];if(!(y&128)){b+=String.fromCharCode(y);continue}const S=f[p++]&63;if((y&224)===192){b+=String.fromCharCode((y&31)<<6|S);continue}const C=f[p++]&63;if((y&240)===224?y=(y&15)<<12|S<<6|C:y=(y&7)<<18|S<<12|C<<6|f[p++]&63,y<65536)b+=String.fromCharCode(y);else{const w=y-65536;b+=String.fromCharCode(55296|w>>10,56320|w&1023)}}return b}function c(f,p){return f?d(i.HEAPU8,f,p):""}const u={emscripten_get_now:If,emscripten_memcpy_big:s,emscripten_resize_heap:l,fd_write:()=>0};async function h(){const p=await e({env:u,wasi_snapshot_preview1:u});t=p.memory,r(t.buffer),Object.assign(i,p),i.UTF8ToString=c}return await h(),i}var Nf=Object.defineProperty,Mf=(e,t,n)=>t in e?Nf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t,n)=>Mf(e,typeof t!="symbol"?t+"":t,n);let X=null;function Hf(e){throw new hr(e.UTF8ToString(e.getLastOnigError()))}class Un{constructor(t){q(this,"utf16Length"),q(this,"utf8Length"),q(this,"utf16Value"),q(this,"utf8Value"),q(this,"utf16OffsetToUtf8"),q(this,"utf8OffsetToUtf16");const n=t.length,i=Un._utf8ByteLength(t),r=i!==n,s=r?new Uint32Array(n+1):null;r&&(s[n]=i);const o=r?new Uint32Array(i+1):null;r&&(o[i]=n);const l=new Uint8Array(i);let a=0;for(let d=0;d<n;d++){const c=t.charCodeAt(d);let u=c,h=!1;if(c>=55296&&c<=56319&&d+1<n){const f=t.charCodeAt(d+1);f>=56320&&f<=57343&&(u=(c-55296<<10)+65536|f-56320,h=!0)}r&&(s[d]=a,h&&(s[d+1]=a),u<=127?o[a+0]=d:u<=2047?(o[a+0]=d,o[a+1]=d):u<=65535?(o[a+0]=d,o[a+1]=d,o[a+2]=d):(o[a+0]=d,o[a+1]=d,o[a+2]=d,o[a+3]=d)),u<=127?l[a++]=u:u<=2047?(l[a++]=192|(u&1984)>>>6,l[a++]=128|(u&63)>>>0):u<=65535?(l[a++]=224|(u&61440)>>>12,l[a++]=128|(u&4032)>>>6,l[a++]=128|(u&63)>>>0):(l[a++]=240|(u&1835008)>>>18,l[a++]=128|(u&258048)>>>12,l[a++]=128|(u&4032)>>>6,l[a++]=128|(u&63)>>>0),h&&d++}this.utf16Length=n,this.utf8Length=i,this.utf16Value=t,this.utf8Value=l,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=o}static _utf8ByteLength(t){let n=0;for(let i=0,r=t.length;i<r;i++){const s=t.charCodeAt(i);let o=s,l=!1;if(s>=55296&&s<=56319&&i+1<r){const a=t.charCodeAt(i+1);a>=56320&&a<=57343&&(o=(s-55296<<10)+65536|a-56320,l=!0)}o<=127?n+=1:o<=2047?n+=2:o<=65535?n+=3:n+=4,l&&i++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const Bn=class ve{constructor(t){if(q(this,"id",++ve.LAST_ID),q(this,"_onigBinding"),q(this,"content"),q(this,"utf16Length"),q(this,"utf8Length"),q(this,"utf16OffsetToUtf8"),q(this,"utf8OffsetToUtf16"),q(this,"ptr"),!X)throw new hr("Must invoke loadWasm first.");this._onigBinding=X,this.content=t;const n=new Un(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!ve._sharedPtrInUse?(ve._sharedPtr||(ve._sharedPtr=X.omalloc(1e4)),ve._sharedPtrInUse=!0,X.HEAPU8.set(n.utf8Value,ve._sharedPtr),this.ptr=ve._sharedPtr):this.ptr=n.createString(X)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===ve._sharedPtr?ve._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};q(Bn,"LAST_ID",0);q(Bn,"_sharedPtr",0);q(Bn,"_sharedPtrInUse",!1);let Ca=Bn;class Df{constructor(t){if(q(this,"_onigBinding"),q(this,"_ptr"),!X)throw new hr("Must invoke loadWasm first.");const n=[],i=[];for(let l=0,a=t.length;l<a;l++){const d=new Un(t[l]);n[l]=d.createString(X),i[l]=d.utf8Length}const r=X.omalloc(4*t.length);X.HEAPU32.set(n,r/4);const s=X.omalloc(4*t.length);X.HEAPU32.set(i,s/4);const o=X.createOnigScanner(r,s,t.length);for(let l=0,a=t.length;l<a;l++)X.ofree(n[l]);X.ofree(s),X.ofree(r),o===0&&Hf(X),this._onigBinding=X,this._ptr=o}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,i){let r=0;if(typeof i=="number"&&(r=i),typeof t=="string"){t=new Ca(t);const s=this._findNextMatchSync(t,n,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,n,!1,r)}_findNextMatchSync(t,n,i,r){const s=this._onigBinding,o=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(n),r);if(o===0)return null;const l=s.HEAPU32;let a=o/4;const d=l[a++],c=l[a++],u=[];for(let h=0;h<c;h++){const f=t.convertUtf8OffsetToUtf16(l[a++]),p=t.convertUtf8OffsetToUtf16(l[a++]);u[h]={start:f,end:p,length:p-f}}return{index:d,captureIndices:u}}}function Ff(e){return typeof e.instantiator=="function"}function $f(e){return typeof e.default=="function"}function Of(e){return typeof e.data<"u"}function Uf(e){return typeof Response<"u"&&e instanceof Response}function Bf(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}let Yt;function Gf(e){if(Yt)return Yt;async function t(){X=await Pf(async n=>{let i=e;return i=await i,typeof i=="function"&&(i=await i(n)),typeof i=="function"&&(i=await i(n)),Ff(i)?i=await i.instantiator(n):$f(i)?i=await i.default(n):(Of(i)&&(i=i.data),Uf(i)?typeof WebAssembly.instantiateStreaming=="function"?i=await zf(i)(n):i=await jf(i)(n):Bf(i)?i=await ai(i)(n):i instanceof WebAssembly.Module?i=await ai(i)(n):"default"in i&&i.default instanceof WebAssembly.Module&&(i=await ai(i.default)(n))),"instance"in i&&(i=i.instance),"exports"in i&&(i=i.exports),i})}return Yt=t(),Yt}function ai(e){return t=>WebAssembly.instantiate(e,t)}function zf(e){return t=>WebAssembly.instantiateStreaming(e,t)}function jf(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}async function Wf(e){return e&&await Gf(e),{createScanner(t){return new Df(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new Ca(t)}}}const An={applescript:()=>D(()=>import("./diff-syntax/applescript-Co6uUVPk.js"),[]),c:()=>D(()=>import("./diff-syntax/c-BIGW1oBm.js"),[]),cpp:()=>D(()=>import("./diff-syntax/cpp-DddhVWhK.js"),__vite__mapDeps([0,1])),css:()=>D(()=>import("./diff-syntax/css-CLj8gQPS.js"),[]),go:()=>D(()=>import("./diff-syntax/go-C27-OAKa.js"),[]),html:()=>D(()=>import("./diff-syntax/html-pp8916En.js"),__vite__mapDeps([2,3,4])),java:()=>D(()=>import("./diff-syntax/java-CylS5w8V.js"),[]),javascript:()=>D(()=>import("./diff-syntax/javascript-wDzz0qaB.js"),[]),json:()=>D(()=>import("./diff-syntax/json-Cp-IABpG.js"),[]),jsx:()=>D(()=>import("./diff-syntax/jsx-g9-lgVsj.js"),[]),markdown:()=>D(()=>import("./diff-syntax/markdown-Cvjx9yec.js"),[]),"objective-cpp":()=>D(()=>import("./diff-syntax/objective-cpp-CLxacb5B.js"),[]),php:()=>D(()=>import("./diff-syntax/php-Csjmro_R.js"),__vite__mapDeps([5,2,3,4,6,7,8,9])),python:()=>D(()=>import("./diff-syntax/python-B6aJPvgy.js"),[]),ruby:()=>D(()=>import("./diff-syntax/ruby-C-9S-GLb.js"),__vite__mapDeps([10,2,3,4,6,7,8,11,12,13,0,1,14,15])),rust:()=>D(()=>import("./diff-syntax/rust-B1yitclQ.js"),[]),scss:()=>D(()=>import("./diff-syntax/scss-D5BDwBP9.js"),__vite__mapDeps([16,4])),sql:()=>D(()=>import("./diff-syntax/sql-CRqJ_cUM.js"),[]),swift:()=>D(()=>import("./diff-syntax/swift-C2oV4EkX.js"),[]),toml:()=>D(()=>import("./diff-syntax/toml-vGWfd6FD.js"),[]),tsx:()=>D(()=>import("./diff-syntax/tsx-COt5Ahok.js"),[]),typescript:()=>D(()=>import("./diff-syntax/typescript-BPQ3VLAy.js"),[]),xml:()=>D(()=>import("./diff-syntax/xml-sdJ4AIDG.js"),__vite__mapDeps([6,7])),yaml:()=>D(()=>import("./diff-syntax/yml-DbVfSbck.js").then(e=>e.a),[]),yml:()=>D(()=>import("./diff-syntax/yml-DbVfSbck.js").then(e=>e.b),[]),zsh:()=>D(()=>import("./diff-syntax/zsh-Yzrsuije.js"),[])},Vf=new Set(Object.keys(An)),qf=Gu({langs:An,themes:{},engine:()=>ya()});async function Kf(e){if(Co())throw new Error(`resolveLanguage("${e}") cannot be called from a worker context. Languages must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);const t=Xn.get(e);if(t!=null)return t;try{let n=cc.get(e);if(n==null&&Object.prototype.hasOwnProperty.call(An,e)&&(n=An[e]),n==null)throw new Error(`resolveLanguage: "${e}" not found in bundled or custom languages`);const i=n().then(({default:r})=>{const s={name:e,data:r};return _t.has(e)||_t.set(e,s),s});return Xn.set(e,i),await i}finally{Xn.delete(e)}}function Xf(e){return _t.get(e)??Kf(e)}const zi=new Set;function Mt(e){const t=[],n=new Set;for(const u of Yf(e.themes)){const h=Sa(u)?u.getThemes():[u];for(const f of h){if(n.has(f.name))throw new Error(`Theme collection already contains theme "${f.name}"`);n.add(f.name),t.push(f)}}const i=Object.freeze([...t]),r=Object.freeze(i.filter(u=>u.colorScheme==="light")),s=Object.freeze(i.filter(u=>u.colorScheme==="dark")),o=new Map(i.map(u=>[u.name,u])),l=Object.freeze(i.map(u=>u.name)),a=Object.freeze(r.map(u=>u.name)),d=Object.freeze(s.map(u=>u.name));function c(u){if(u==null)return i;const{colorScheme:h,collection:f}=u;return f==null?h==="light"?r:h==="dark"?s:i:i.filter(p=>p.collection!==f?!1:h==null||p.colorScheme===h)}return{getTheme(u){return o.get(u)},getThemes(u){return c(u)},getThemeNames(u){return u?.collection==null?u?.colorScheme==="light"?a:u?.colorScheme==="dark"?d:l:c(u).map(h=>h.name)},hasTheme(u){return o.has(u)},orderBy(u){return Mt({themes:i.map((h,f)=>({descriptor:h,index:f})).sort((h,f)=>{const p=u(h.descriptor,f.descriptor);return p!==0?p:h.index-f.index}).map(h=>h.descriptor)})},pick(u){const h=[],f=new Set;for(const p of u){if(f.has(p))throw new Error(`Theme collection pick already includes theme "${p}"`);f.add(p);const g=o.get(p);if(g==null)throw new Error(`Theme collection does not contain theme "${p}"`);h.push(g)}return Mt({themes:h})},registerInto(u){for(const h of i)u.registerThemeIfAbsent(h.name,h.load)}}}function Yf(e){return Qf(e)?[e]:e}function Qf(e){return Sa(e)||Zf(e)}function Zf(e){return typeof e.name=="string"&&typeof e.load=="function"}function Sa(e){return typeof e.getThemes=="function"}function Jf(e){return e!==null&&typeof e=="object"&&"default"in e?e.default:e}var ep=class extends Error{constructor(e){super(`Theme "${e}" is already registered`),this.name="DuplicateThemeError"}},tp=class extends Error{constructor(e){super(`No loader registered for theme "${e}"`),this.name="UnregisteredThemeError"}},np=class extends Error{constructor(e){super(`Theme "${e}" has not been resolved`),this.name="UnresolvedThemeError"}};function ip(){const e=new Map,t=new Map,n=new Map;let i=0;function r(m,b){if(e.has(m))throw new ep(m);e.set(m,b)}function s(m,b){return e.has(m)?!1:(e.set(m,b),!0)}function o(m){return e.has(m)}function l(m){const b=t.get(m);if(b!==void 0)return Promise.resolve(b);const y=n.get(m);if(y!==void 0)return y;const S=e.get(m);if(S===void 0)return Promise.reject(new tp(m));const C=i,w=S().then(x=>{const E=Jf(x);return C===i&&t.set(m,E),n.get(m)===w&&n.delete(m),E}).catch(x=>{throw n.get(m)===w&&n.delete(m),x});return n.set(m,w),w}function a(m){return Promise.all(m.map(b=>l(b)))}function d(m,b){t.set(m,b)}function c(m){for(const[b,y]of m)d(b,y)}function u(m){return t.get(m)}function h(m){const b=[];for(const y of m){const S=t.get(y);if(S===void 0)throw new np(y);b.push(S)}return b}function f(m){return t.has(m)}function p(m){for(const b of m)if(!t.has(b))return!1;return!0}function g(m){const b=t.get(m);return b!==void 0?b:l(m)}function v(){i++,t.clear(),n.clear()}return{clearResolvedThemes:v,getResolvedOrResolveTheme:g,getResolvedTheme:u,getResolvedThemes:h,hasRegisteredTheme:o,hasResolvedTheme:f,hasResolvedThemes:p,registerTheme:r,registerThemeIfAbsent:s,resolveTheme:l,resolveThemes:a,seedResolvedTheme:d,seedResolvedThemes:c}}const ze=ip();function Ss(e,t){e=Array.isArray(e)?e:[e];for(let n of e){let i;if(typeof n=="string"){if(i=ze.getResolvedTheme(n),i==null)throw new Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else i=n,n=n.name,ze.getResolvedTheme(n)==null&&ze.seedResolvedTheme(n,i);zi.has(n)||(zi.add(n),t.loadThemeSync(i))}}function ws({name:e,load:t,colorScheme:n,collection:i,displayName:r}){return{name:e,colorScheme:n,collection:i,displayName:r,load:async()=>Nn(rp(await t()))}}function rp(e){return"default"in e?e.default:e}const sp=[ws({name:"pierre-light",displayName:"Pierre Light",collection:"pierre",colorScheme:"light",load:()=>D(()=>import("./pierre-light-480U9XYS.js"),[])}),ws({name:"pierre-dark",displayName:"Pierre Dark",collection:"pierre",colorScheme:"dark",load:()=>D(()=>import("./pierre-dark-CyvmCCZW.js"),[])})],wa=Mt({themes:sp}),xa=Mt({themes:[]});Mt({themes:[wa,xa]});function op(e){if(Co())throw new Error(`Theme "${e}" cannot be resolved from a worker context. Themes must be pre-resolved on the main thread and passed to the worker via the resolvedLanguages parameter.`);if(ze.hasRegisteredTheme(e))return;const t=xa.getTheme(e);if(t!=null){ze.registerThemeIfAbsent(t.name,t.load);return}throw new Error(`No valid theme loader registered for "${e}"`)}function ap(e,t){if(t.name!==e)throw new Error(`resolvedTheme: themeName: ${e} does not match theme.name: ${t.name}`)}async function lp(e){op(e);const t=await ze.resolveTheme(e);return ap(e,t),t}function dp(e){return ze.getResolvedTheme(e)??lp(e)}let ye;async function cp({themes:e,langs:t,preferredHighlighter:n="shiki-js"}){ye??=qf({themes:[],langs:["text"],engine:n==="shiki-wasm"?Wf(D(()=>import("./pierre-shiki-wasm-C8ETeZem.js"),[])):ya()});const i=hp(ye)?await ye:ye;ye=i;const r=[];for(const o of t){if(o==="text"||o==="ansi")continue;const l=Xf(o);"then"in l?r.push(l):Or(l,i)}const s=[];for(const o of e){const l=dp(o);"then"in l?s.push(l):Ss(l,ye)}return(r.length>0||s.length>0)&&await Promise.all([Promise.all(r).then(o=>{Or(o,i)}),Promise.all(s).then(o=>{Ss(o,i)})]),i}function up(){if(ye!=null&&!("then"in ye))return ye}function hp(e=ye){return e!=null&&"then"in e}for(const e of wa.getThemes())ze.registerThemeIfAbsent(e.name,e.load);function ka(e=le){const t=[];return typeof e=="string"?t.push(e):(t.push(e.dark),t.push(e.light)),t}function li(e){for(const t of ka(e))if(!zi.has(t))return!1;return!0}function La(e,t){return e==null||t==null?e===t:e.startingLine===t.startingLine&&e.totalLines===t.totalLines&&e.bufferBefore===t.bufferBefore&&e.bufferAfter===t.bufferAfter}function fp(e){return T({tagName:"div",children:[T({tagName:"div",children:e.annotations?.map(t=>T({tagName:"slot",properties:{name:t}})),properties:{"data-annotation-content":""}})],properties:{"data-line-annotation":`${e.hunkIndex},${e.lineIndex}`}})}function pp(e){switch(e){case"file":return"diffs-icon-file-code";case"change":return"diffs-icon-symbol-modified";case"new":return"diffs-icon-symbol-added";case"deleted":return"diffs-icon-symbol-deleted";case"rename-pure":case"rename-changed":return"diffs-icon-symbol-moved"}}function gp({fileOrDiff:e,mode:t,stickyHeader:n}){const i="type"in e?e:void 0,r={"data-diffs-header":t,"data-change-type":i?.type,"data-sticky":n?"":void 0};return T({tagName:"div",children:[t==="custom"?T({tagName:"slot",properties:{name:tr}}):mp({name:e.name,prevName:"prevName"in e?e.prevName:void 0,iconType:i?.type??"file"}),...t==="custom"?[]:[bp(i)]],properties:r})}function mp({name:e,prevName:t,iconType:n}){const i=[T({tagName:"slot",properties:{name:Zs}}),gn({name:pp(n),properties:{"data-change-icon":n}})];return t!=null&&(i.push(T({tagName:"div",children:[T({tagName:"bdi",children:[Ce(t)]})],properties:{"data-prev-name":""}})),i.push(gn({name:"diffs-icon-arrow-right-short",properties:{"data-rename-icon":""}}))),i.push(T({tagName:"div",children:[T({tagName:"bdi",children:[Ce(e)]})],properties:{"data-title":""}})),i.push(T({tagName:"slot",properties:{name:Js}})),T({tagName:"div",children:i,properties:{"data-header-content":""}})}function bp(e){const t=[];if(e!=null){let n=0,i=0;for(const r of e.hunks)n+=r.additionLines,i+=r.deletionLines;(i>0||n===0)&&t.push(T({tagName:"span",children:[Ce(`-${i}`)],properties:{"data-deletions-count":""}})),(n>0||i===0)&&t.push(T({tagName:"span",children:[Ce(`+${n}`)],properties:{"data-additions-count":""}}))}return t.push(T({tagName:"slot",properties:{name:eo}})),T({tagName:"div",children:t,properties:{"data-metadata":""}})}function vp(e){return T({tagName:"pre",properties:yp(e)})}function yp({diffIndicators:e,disableBackground:t,disableLineNumbers:n,overflow:i,split:r,totalLines:s,type:o,customProperties:l}){return{...l,"data-diff":o==="diff"?"":void 0,"data-file":o==="file"?"":void 0,"data-diff-type":o==="diff"?r?"split":"single":void 0,"data-overflow":i,"data-disable-line-numbers":n?"":void 0,"data-background":t?void 0:"","data-indicators":e==="bars"||e==="classic"?e:void 0,style:`--diffs-min-number-column-width-default:${`${s}`.length}ch;`}}const Be=new Map,ut={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",jbuilder:"ruby",builder:"ruby",rabl:"ruby",arb:"ruby",ru:"ruby",podspec:"ruby",Gemfile:"ruby",Rakefile:"ruby",Guardfile:"ruby",Capfile:"ruby",Berksfile:"ruby",Brewfile:"ruby",Vagrantfile:"ruby",Thorfile:"ruby",Appraisals:"ruby",Dangerfile:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",mts:"typescript",cts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function Je(e){if(Be.has(e))return Be.get(e)??"text";if(ut[e]!=null)return ut[e];const t=e.match(/\.([^/\\]+\.[^/\\]+)$/);if(t!=null){if(Be.has(t[1]))return Be.get(t[1])??"text";if(ut[t[1]]!=null)return ut[t[1]]??"text"}const n=e.match(/\.([^.]+)$/)?.[1]??"";return Be.has(n)?Be.get(n)??"text":ut[n]??"text"}function Cp(e,t){const n=Be.get(e);return n===t?!1:(n!=null&&console.warn(`setCustomExtension: overriding custom mapping for "${e}" from "${n}" to "${t}"`),Be.set(e,t),!0)}function Sp(e,{theme:t,preferredHighlighter:n="shiki-js"}){return{langs:[e??"text"],themes:ka(t),preferredHighlighter:n}}function vt(e){return`annotation-${"side"in e?`${e.side}-`:""}${e.lineNumber}`}function wp(e,t,n){const i=typeof n.lineInfo=="function"?n.lineInfo(t):n.lineInfo[t-1];if(i==null){const r=`processLine: line ${t}, contains no state.lineInfo`;throw console.error(r,{node:e,line:t,state:n}),new Error(r)}return e.tagName="div",e.properties["data-line"]=i.lineNumber,e.properties["data-alt-line"]=i.altLineNumber,e.properties["data-line-type"]=i.type,e.properties["data-line-index"]=i.lineIndex,e.children.length===0&&e.children.push(Ce(`
178
+ `)),e}const Qt=Symbol("no-token"),di=Symbol("multiple-tokens");function Ea(e){const t=xp(e);if(t!=null)return t;let n=Qt;const i=[];let r=[],s;const o=()=>{if(r.length===0||s==null){r=[],s=void 0;return}if(r.length===1){const a=r[0];if(a?.type==="element"){kp(a,s);for(const d of a.children)hn(d)}else hn(a);i.push(a),r=[],s=void 0;return}for(const a of r)hn(a);i.push(T({tagName:"span",properties:{"data-char":s},children:r})),r=[],s=void 0},l=a=>{if(a!==Qt){if(a===di){n=di;return}if(n===Qt){n=a;return}n!==a&&(n=di)}};for(const a of e.children){const d=a.type==="element"?Ea(a):Qt;if(l(d),typeof d!="number"){o(),i.push(a);continue}s!=null&&s!==d&&o(),s??=d,r.push(a)}return o(),e.children=i,n}function xp(e){const t=e.properties["data-char"];if(typeof t=="number")return t}function hn(e){if(e.type==="element"){e.properties["data-char"]=void 0;for(const t of e.children)hn(t)}}function kp(e,t){e.properties["data-char"]=t}function Lp(e={}){const{classPrefix:t="__shiki_",classSuffix:n="",classReplacer:i=l=>l}=e,r=new Map;function s(l){return Object.entries(l).map(([a,d])=>`${a}:${d}`).join(";")}function o(l){const a=typeof l=="string"?l:s(l);let d=t+Ep(a)+n;return d=i(d),r.has(d)||r.set(d,typeof l=="string"?l:{...l}),d}return{name:"@shikijs/transformers:style-to-class",pre(l){if(!l.properties.style)return;const a=o(l.properties.style);delete l.properties.style,this.addClassToHast(l,a)},tokens(l){for(const a of l)for(const d of a){if(!d.htmlStyle)continue;const c=o(d.htmlStyle);d.htmlStyle={},d.htmlAttrs||={},d.htmlAttrs.class?d.htmlAttrs.class+=` ${c}`:d.htmlAttrs.class=c}},getClassRegistry(){return r},getCSS(){let l="";for(const[a,d]of r.entries())l+=`.${a}{${typeof d=="string"?d:s(d)}}`;return l},clearRegistry(){r.clear()}}}function Ep(e,t=0){let n=3735928559^t,i=1103547991^t;for(let r=0,s;r<e.length;r++)s=e.charCodeAt(r),n=Math.imul(n^s,2654435761),i=Math.imul(i^s,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&i)+(n>>>0)).toString(36).slice(0,6)}function Ap(e=!1,t=!1){const n={lineInfo:[]},i=[{line(r){return delete r.properties.class,r},pre(r){const s=zl(r),o=[];if(s!=null){let l=1;for(const a of s.children)a.type==="element"&&(e&&Ea(a),o.push(wp(a,l,n)),l++);s.children=o}return r},...e?{tokens(r){for(const s of r){let o=0;for(const l of s){const a=l;a.__lineChar??=o,o+=l.content.length}}},preprocess(r,s){s.mergeWhitespaces="never"},span(r,s,o,l,a){if(a?.offset!=null&&a.content!=null){const d=a.__lineChar;return d!=null&&(r.properties["data-char"]=d),r}return r}}:null}];return t&&i.push(_p,xs),e&&i.push({line:r=>(r.type==="element"&&r.children.length===0&&r.children.push({type:"element",tagName:"br",properties:{},children:[]}),r)}),{state:n,transformers:i,toClass:xs}}const xs=Lp({classPrefix:"hl-"}),_p={name:"token-style-normalizer",tokens(e){for(const t of e)for(const n of t){if(n.htmlStyle!=null)continue;const i={};n.color!=null&&(i.color=n.color),n.bgColor!=null&&(i["background-color"]=n.bgColor),n.fontStyle!=null&&n.fontStyle!==0&&((n.fontStyle&1)!==0&&(i["font-style"]="italic"),(n.fontStyle&2)!==0&&(i["font-weight"]="bold"),(n.fontStyle&4)!==0&&(i["text-decoration"]="underline")),Object.keys(i).length>0&&(n.htmlStyle=i)}}};function fe(e){return`--${e==="token"?"diffs-token":"diffs"}-`}const Rp=/^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i,Ip=/^0(?:\.0+)?%?$/;function Tp(e){const t=e.indexOf("(");if(t<=0||!e.endsWith(")"))return;const n=e.slice(0,t).trim();if(!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(n))return;const i=e.slice(t+1,-1).trim();if(i.length===0)return;const r=i.lastIndexOf("/");if(r!==-1)return i.slice(r+1).trim();if(/^(?:rgba|hsla)$/i.test(n)){const s=i.split(",");if(s.length===4)return s[3]?.trim()}}function Pp(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(e.trim());if(t==null)return null;const n=t[1];let i,r=1;return n.length===3?i=n.split("").map(s=>s+s).join(""):n.length===6?i=n:(i=n.slice(0,6),r=parseInt(n.slice(6,8),16)/255),[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),r]}function ci(e){if(e==null)return null;const t=Pp(e);if(t==null)return null;const n=t[0]/255,i=t[1]/255,r=t[2]/255,s=o=>o<=.03928?o/12.92:((o+.055)/1.055)**2.4;return .2126*s(n)+.7152*s(i)+.0722*s(r)}function ks(e){if(e==null)return!1;const t=e.trim().toLowerCase();if(t==="transparent"||Rp.test(t))return!0;const n=Tp(t);return n!=null&&Ip.test(n)}function Np(e,t,n){if(t==null||n==null)return!1;const i=ci(e),r=ci(t),s=ci(n);return i==null||r==null||s==null?!1:Math.abs(i-s)<Math.abs(i-r)}const Ls=new WeakMap;function ui(e){const t=Ls.get(e);if(t!=null)return t;const n=e.colors??{},i={...n},r=n["editor.background"]??e.bg,s=n["editor.foreground"]??e.fg,o=n["sideBar.background"]??r,l=n["sideBar.foreground"]??s;me(i,"editor.background",r),me(i,"editor.foreground",s),me(i,"sideBar.background",o),me(i,"sideBar.foreground",l),me(i,"input.background",n["input.background"]??o),me(i,"sideBarSectionHeader.foreground",n["sideBarSectionHeader.foreground"]??l),me(i,"list.activeSelectionForeground",n["list.activeSelectionForeground"]??l),me(i,"gitDecoration.addedResourceForeground",hi(n["gitDecoration.addedResourceForeground"],n["terminal.ansiGreen"],n["editorGutter.addedBackground"])),me(i,"gitDecoration.modifiedResourceForeground",hi(n["gitDecoration.modifiedResourceForeground"],n["terminal.ansiBlue"],n["editorGutter.modifiedBackground"])),me(i,"gitDecoration.deletedResourceForeground",hi(n["gitDecoration.deletedResourceForeground"],n["terminal.ansiRed"],n["editorGutter.deletedBackground"]));const a=(ks(n["list.focusOutline"])?void 0:n["list.focusOutline"])??(ks(n.focusBorder)?void 0:n.focusBorder);a!=null?i["list.focusOutline"]=a:delete i["list.focusOutline"];const d=n["list.hoverBackground"];d!=null&&(Mp(d,o)||Np(d,o,l))&&delete i["list.hoverBackground"];const c=Object.freeze({...e,colors:Object.freeze(i)});return Ls.set(e,c),c}function me(e,t,n){n!=null&&n!==""&&(e[t]=n)}function hi(...e){for(const t of e)if(t!=null&&t!=="")return t}function Mp(e,t){return t!=null&&e.toLowerCase()===t.toLowerCase()}function Hp({theme:e=le,highlighter:t,prefix:n}){let i="";if(typeof e=="string"){const r=t.getTheme(e),s=ui(r);i+=`color:${s.fg};`,i+=`background-color:${s.bg};`,i+=`${fe("global")}fg:${s.fg};`,i+=`${fe("global")}bg:${s.bg};`,i+=fi(r,n)}else{let r=t.getTheme(e.dark),s=ui(r);i+=`${fe("global")}dark:${s.fg};`,i+=`${fe("global")}dark-bg:${s.bg};`,i+=fi(r,"dark"),r=t.getTheme(e.light),s=ui(r),i+=`${fe("global")}light:${s.fg};`,i+=`${fe("global")}light-bg:${s.bg};`,i+=fi(r,"light")}return i}function fi(e,t){t=t!=null?`${t}-`:"";let n="";const i=e.colors?.["gitDecoration.addedResourceForeground"]??e.colors?.["terminal.ansiGreen"];i!=null&&(n+=`${fe("global")}${t}addition-color:${i};`);const r=e.colors?.["gitDecoration.deletedResourceForeground"]??e.colors?.["terminal.ansiRed"];r!=null&&(n+=`${fe("global")}${t}deletion-color:${r};`);const s=e.colors?.["gitDecoration.modifiedResourceForeground"]??e.colors?.["terminal.ansiBlue"];return s!=null&&(n+=`${fe("global")}${t}modified-color:${s};`),n}function Es(e){let t=e.children[0];for(;t!=null;){if(t.type==="element"&&t.tagName==="code")return t.children;"children"in t?t=t.children[0]:t=null}throw console.error(e),new Error("getLineNodes: Unable to find children")}const Dp="-1,-1";function Fp(e){return e?.some(t=>t.lineNumber===0)??!1}function As(e){const t=e[0];return t!=null&&t.length>0?t:void 0}function Aa(e){return e.startingLine===0&&e.totalLines>0}function $p(e,t){return e.endsWith(`\r
179
+ `)?t+`\r
180
+ `:e.endsWith("\r")?t+"\r":e.endsWith(`
181
+ `)?t+`
182
+ `:t}function Op(e,t){return T({tagName:"div",children:e,properties:{"data-content":"",style:`grid-row: span ${t}`}})}const Up=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
183
+ <symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
184
+ <path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
185
+ </symbol>
186
+ <symbol id="diffs-icon-brand-github" viewBox="0 0 16 16">
187
+ <path d="M8 0c4.42 0 8 3.58 8 8a8.01 8.01 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27s-1.36.09-2 .27c-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8"/>
188
+ </symbol>
189
+ <symbol id="diffs-icon-chevron" viewBox="0 0 16 16">
190
+ <path d="M1.47 4.47a.75.75 0 0 1 1.06 0L8 9.94l5.47-5.47a.75.75 0 1 1 1.06 1.06l-6 6a.75.75 0 0 1-1.06 0l-6-6a.75.75 0 0 1 0-1.06"/>
191
+ </symbol>
192
+ <symbol id="diffs-icon-chevrons-narrow" viewBox="0 0 10 16">
193
+ <path d="M4.47 2.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1-1.06 1.06L5 3.81 2.28 6.53a.75.75 0 0 1-1.06-1.06zM1.22 9.47a.75.75 0 0 1 1.06 0L5 12.19l2.72-2.72a.75.75 0 0 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0l-3.25-3.25a.75.75 0 0 1 0-1.06"/>
194
+ </symbol>
195
+ <symbol id="diffs-icon-diff-split" viewBox="0 0 16 16">
196
+ <path d="M14 0H8.5v16H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2m-1.5 6.5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0"/><path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h5.5V0zm.5 7.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1" opacity=".3"/>
197
+ </symbol>
198
+ <symbol id="diffs-icon-diff-unified" viewBox="0 0 16 16">
199
+ <path fill-rule="evenodd" d="M16 14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V8.5h16zm-8-4a.5.5 0 0 0-.5.5v1h-1a.5.5 0 0 0 0 1h1v1a.5.5 0 0 0 1 0v-1h1a.5.5 0 0 0 0-1h-1v-1A.5.5 0 0 0 8 10" clip-rule="evenodd"/><path fill-rule="evenodd" d="M14 0a2 2 0 0 1 2 2v5.5H0V2a2 2 0 0 1 2-2zM6.5 3.5a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" clip-rule="evenodd" opacity=".4"/>
200
+ </symbol>
201
+ <symbol id="diffs-icon-expand" viewBox="0 0 16 16">
202
+ <path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06"/>
203
+ </symbol>
204
+ <symbol id="diffs-icon-expand-all" viewBox="0 0 16 16">
205
+ <path d="M11.47 9.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06L8 12.94zM7.526 1.418a.75.75 0 0 1 1.004.052l4 4a.75.75 0 1 1-1.06 1.06L8 3.06 4.53 6.53a.75.75 0 1 1-1.06-1.06l4-4z"/>
206
+ </symbol>
207
+ <symbol id="diffs-icon-file-code" viewBox="0 0 16 16">
208
+ <path d="M10.75 0c.199 0 .39.08.53.22l3.5 3.5c.14.14.22.331.22.53v9A2.75 2.75 0 0 1 12.25 16h-8.5A2.75 2.75 0 0 1 1 13.25V2.75A2.75 2.75 0 0 1 3.75 0zm-7 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h8.5c.69 0 1.25-.56 1.25-1.25V5h-1.25A2.25 2.25 0 0 1 10 2.75V1.5z"/><path d="M7.248 6.19a.75.75 0 0 1 .063 1.058L5.753 9l1.558 1.752a.75.75 0 0 1-1.122.996l-2-2.25a.75.75 0 0 1 0-.996l2-2.25a.75.75 0 0 1 1.06-.063M8.69 7.248a.75.75 0 1 1 1.12-.996l2 2.25a.75.75 0 0 1 0 .996l-2 2.25a.75.75 0 1 1-1.12-.996L10.245 9z"/>
209
+ </symbol>
210
+ <symbol id="diffs-icon-plus" viewBox="0 0 16 16">
211
+ <path d="M8 3a.75.75 0 0 1 .75.75v3.5h3.5a.75.75 0 0 1 0 1.5h-3.5v3.5a.75.75 0 0 1-1.5 0v-3.5h-3.5a.75.75 0 0 1 0-1.5h3.5v-3.5A.75.75 0 0 1 8 3"/>
212
+ </symbol>
213
+ <symbol id="diffs-icon-symbol-added" viewBox="0 0 16 16">
214
+ <path d="M8 4a.75.75 0 0 1 .75.75v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5A.75.75 0 0 1 8 4"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
215
+ </symbol>
216
+ <symbol id="diffs-icon-symbol-deleted" viewBox="0 0 16 16">
217
+ <path d="M4 8a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 4 8"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
218
+ </symbol>
219
+ <symbol id="diffs-icon-symbol-diffstat" viewBox="0 0 16 16">
220
+ <path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.75 4.296a.75.75 0 0 0-1.5 0V6.25h-2a.75.75 0 0 0 0 1.5h2v1.5h1.5v-1.5h2a.75.75 0 0 0 0-1.5h-2zM5.25 10a.75.75 0 0 0 0 1.5h5.5a.75.75 0 0 0 0-1.5z"/>
221
+ </symbol>
222
+ <symbol id="diffs-icon-symbol-ignored" viewBox="0 0 16 16">
223
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m11.53-2.47a.75.75 0 0 0-1.06-1.06l-6 6a.75.75 0 1 0 1.06 1.06z"/>
224
+ </symbol>
225
+ <symbol id="diffs-icon-symbol-modified" viewBox="0 0 16 16">
226
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m8 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6"/>
227
+ </symbol>
228
+ <symbol id="diffs-icon-symbol-moved" viewBox="0 0 16 16">
229
+ <path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.495 4.695a.75.75 0 0 0-.05 1.06L10.486 8l-2.041 2.246a.75.75 0 0 0 1.11 1.008l2.5-2.75a.75.75 0 0 0 0-1.008l-2.5-2.75a.75.75 0 0 0-1.06-.051m-4 0a.75.75 0 0 0-.05 1.06l2.044 2.248-1.796 1.995a.75.75 0 0 0 1.114 1.004l2.25-2.5a.75.75 0 0 0-.002-1.007l-2.5-2.75a.75.75 0 0 0-1.06-.05"/>
230
+ </symbol>
231
+ <symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
232
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
233
+ </symbol>
234
+ </svg>`;function Bp(e,t){return e==null||t==null?e===t:Gp(e.customProperties,t.customProperties)&&e.type===t.type&&e.diffIndicators===t.diffIndicators&&e.disableBackground===t.disableBackground&&e.disableLineNumbers===t.disableLineNumbers&&e.overflow===t.overflow&&e.split===t.split&&e.totalLines===t.totalLines}const _s={};function Gp(e=_s,t=_s){if(e===t)return!0;const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n)if(e[r]!==t[r])return!1;return!0}function zp(e){const t=document.createElement("div");return t.dataset.annotationSlot="",t.slot=e,t.style.whiteSpace="normal",t}function jp(){const e=document.createElement("div");return e.slot="gutter-utility-slot",e.style.position="absolute",e.style.top="0",e.style.bottom="0",e.style.textAlign="center",e.style.whiteSpace="normal",e.style.touchAction="none",e}function Wp(){const e=document.createElement("style");return e.setAttribute(tl,""),e}var Vp=`@layer base {
235
+ :host {
236
+ --diffs-font-fallback: "SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono",
237
+ "Courier New", monospace;
238
+ --diffs-header-font-fallback: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
239
+ "Noto Sans", "Liberation Sans", Arial, sans-serif;
240
+ --diffs-mixer: light-dark(#000, #fff);
241
+ --diffs-gap-fallback: 8px;
242
+ --diffs-scrollbar-gutter-fallback: 6px;
243
+ --diffs-scrollbar-gutter: var(--diffs-scrollbar-gutter-override, var(--diffs-scrollbar-gutter-measured, var(--diffs-scrollbar-gutter-fallback)));
244
+ --diffs-added-light: #0dbe4e;
245
+ --diffs-added-dark: #5ecc71;
246
+ --diffs-modified-light: #009fff;
247
+ --diffs-modified-dark: #69b1ff;
248
+ --diffs-deleted-light: #ff2e3f;
249
+ --diffs-deleted-dark: #ff6762;
250
+ --diffs-warning-light: #d5a910;
251
+ --diffs-warning-dark: #ffd452;
252
+ color-scheme: light dark;
253
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
254
+ font-size: var(--diffs-font-size, 13px);
255
+ line-height: var(--diffs-line-height, 20px);
256
+ font-feature-settings: var(--diffs-font-features);
257
+ --diffs-bg: light-dark(var(--diffs-light-bg, #fff), var(--diffs-dark-bg, #000));
258
+ --diffs-bg-buffer: var(--diffs-bg-buffer-override, light-dark(color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer))));
259
+ --diffs-bg-context: var(--diffs-bg-context-override, light-dark(color-mix(in lab, var(--diffs-bg) 98.5%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 92.5%, var(--diffs-mixer))));
260
+ --diffs-bg-context-gutter: var(--diffs-bg-context-gutter-override, light-dark(color-mix(in lab, var(--diffs-bg-context) 90%, var(--diffs-bg)), color-mix(in lab, var(--diffs-bg-context) 45%, var(--diffs-bg))));
261
+ --diffs-bg-separator: var(--diffs-bg-separator-override, light-dark(color-mix(in lab, var(--diffs-bg) 96%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-bg) 85%, var(--diffs-mixer))));
262
+ --diffs-fg: light-dark(var(--diffs-light, #000), var(--diffs-dark, #fff));
263
+ --diffs-fg-number: var(--diffs-fg-number-override, light-dark(color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg)), color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg))));
264
+ --diffs-fg-conflict-marker: var(--diffs-fg-conflict-marker-override, var(--diffs-fg-number));
265
+ --diffs-deletion-base: var(--diffs-deletion-color-override, light-dark(var(--diffs-light-deletion-color, var(--diffs-deletion-color, var(--diffs-deleted-light))), var(--diffs-dark-deletion-color, var(--diffs-deletion-color, var(--diffs-deleted-dark)))));
266
+ --diffs-addition-base: var(--diffs-addition-color-override, light-dark(var(--diffs-light-addition-color, var(--diffs-addition-color, var(--diffs-added-light))), var(--diffs-dark-addition-color, var(--diffs-addition-color, var(--diffs-added-dark)))));
267
+ --diffs-modified-base: var(--diffs-modified-color-override, light-dark(var(--diffs-light-modified-color, var(--diffs-modified-color, var(--diffs-modified-light))), var(--diffs-dark-modified-color, var(--diffs-modified-color, var(--diffs-modified-dark)))));
268
+ --diffs-bg-deletion: var(--diffs-bg-deletion-override, light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-deletion-base)), color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-deletion-base))));
269
+ --diffs-bg-deletion-emphasis: var(--diffs-bg-deletion-emphasis-override, light-dark(rgb(from var(--diffs-deletion-base) r g b / .15), rgb(from var(--diffs-deletion-base) r g b / .2)));
270
+ --diffs-bg-addition: var(--diffs-bg-addition-override, light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-addition-base)), color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-addition-base))));
271
+ --diffs-bg-addition-emphasis: var(--diffs-bg-addition-emphasis-override, light-dark(rgb(from var(--diffs-addition-base) r g b / .15), rgb(from var(--diffs-addition-base) r g b / .2)));
272
+ --diffs-selection-base: var(--diffs-modified-base);
273
+ --diffs-selection-number-fg: light-dark(color-mix(in lab, var(--diffs-selection-base) 65%, var(--diffs-mixer)), color-mix(in lab, var(--diffs-selection-base) 75%, var(--diffs-mixer)));
274
+ background-color: var(--diffs-bg);
275
+ color: var(--diffs-fg);
276
+ display: block;
277
+ }
278
+
279
+ pre, code, [data-error-wrapper] {
280
+ isolation: isolate;
281
+ font-family: var(--diffs-font-family, var(--diffs-font-fallback));
282
+ outline: none;
283
+ margin: 0;
284
+ padding: 0;
285
+ display: block;
286
+ }
287
+
288
+ pre, code {
289
+ background-color: var(--diffs-bg);
290
+ }
291
+
292
+ code {
293
+ contain: content;
294
+ }
295
+
296
+ input, button {
297
+ font-family: inherit;
298
+ font-size: inherit;
299
+ line-height: inherit;
300
+ }
301
+
302
+ *, :before, :after {
303
+ box-sizing: border-box;
304
+ }
305
+
306
+ [data-icon-sprite] {
307
+ display: none;
308
+ }
309
+
310
+ [data-diffs-header], [data-separator] {
311
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
312
+ }
313
+
314
+ [data-diffs-header][data-sticky] {
315
+ z-index: 1;
316
+ background-color: var(--diffs-bg);
317
+ position: sticky;
318
+ top: 0;
319
+ }
320
+
321
+ [data-file-info] {
322
+ color: var(--fg);
323
+ background-color: color-mix(in lab, var(--bg) 98%, var(--fg));
324
+ border-block: 1px solid color-mix(in lab, var(--bg) 95%, var(--fg));
325
+ padding: 10px;
326
+ font-weight: 700;
327
+ }
328
+
329
+ [data-diff], [data-file] {
330
+ --diffs-grid-number-column-width: minmax(min-content, max-content);
331
+ --diffs-code-grid: var(--diffs-grid-number-column-width) 1fr;
332
+
333
+ &[data-dehydrated] {
334
+ --diffs-code-grid: var(--diffs-grid-number-column-width) minmax(0, 1fr);
335
+ }
336
+
337
+ &:hover [data-code]::-webkit-scrollbar-thumb {
338
+ background-color: var(--diffs-bg-context);
339
+ }
340
+ }
341
+
342
+ @supports (-webkit-touch-callout: none) {
343
+ :host {
344
+ --diffs-scrollbar-gutter-fallback: 0px;
345
+ }
346
+ }
347
+
348
+ [data-line] span {
349
+ color: light-dark(var(--diffs-token-light, var(--diffs-light)), var(--diffs-token-dark, var(--diffs-dark)));
350
+ background-color: light-dark(var(--diffs-token-light-bg, inherit), var(--diffs-token-dark-bg, inherit));
351
+ font-weight: light-dark(var(--diffs-token-light-font-weight, inherit), var(--diffs-token-dark-font-weight, inherit));
352
+ font-style: light-dark(var(--diffs-token-light-font-style, inherit), var(--diffs-token-dark-font-style, inherit));
353
+ text-decoration: light-dark(var(--diffs-token-light-text-decoration, inherit), var(--diffs-token-dark-text-decoration, inherit));
354
+ }
355
+
356
+ [data-line], [data-gutter-buffer], [data-column-number], [data-line-annotation], [data-no-newline], [data-merge-conflict], [data-merge-conflict-actions], [data-editor-overlay] {
357
+ --diffs-computed-decoration-bg: var(--diffs-bg);
358
+ --diffs-computed-diff-line-bg: var(--diffs-computed-decoration-bg);
359
+ --diffs-computed-selected-line-bg: var(--diffs-computed-diff-line-bg);
360
+ --diffs-computed-editor-active-line-bg: var(--diffs-computed-selected-line-bg);
361
+ --diffs-computed-hovered-line-bg: var(--diffs-computed-editor-active-line-bg);
362
+ --diffs-hover-mix-target: var(--diffs-bg-hover-override, var(--diffs-mixer));
363
+ --diffs-line-bg: var(--diffs-computed-hovered-line-bg);
364
+ color: var(--diffs-fg);
365
+ background-color: var(--diffs-line-bg, var(--diffs-bg));
366
+ }
367
+
368
+ [data-line], [data-no-newline] {
369
+ &[data-decoration-bg] {
370
+ --mix-deco-light: 92%;
371
+ --mix-deco-dark: 85%;
372
+
373
+ &[data-decoration-bg-depth="2"] {
374
+ --mix-deco-light: 88%;
375
+ --mix-deco-dark: 80%;
376
+ }
377
+
378
+ &[data-decoration-bg-depth="3"] {
379
+ --mix-deco-light: 85%;
380
+ --mix-deco-dark: 78%;
381
+ }
382
+
383
+ --diffs-hover-mix-target: var(--diffs-decoration-bg);
384
+ --diffs-computed-decoration-bg: light-dark(color-mix(in lab,
385
+ var(--diffs-bg) var(--mix-deco-light),
386
+ var(--diffs-decoration-bg)), color-mix(in lab,
387
+ var(--diffs-bg) var(--mix-deco-dark),
388
+ var(--diffs-decoration-bg)));
389
+ }
390
+ }
391
+
392
+ [data-line-annotation], [data-gutter-buffer="annotation"] {
393
+ --diffs-annotation-bg: var(--diffs-bg-context);
394
+ --diffs-computed-decoration-bg: var(--diffs-annotation-bg);
395
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
396
+ }
397
+
398
+ [data-merge-conflict-actions], [data-gutter-buffer="merge-conflict-action"], [data-gutter-buffer="merge-conflict-marker-base"], [data-gutter-buffer="merge-conflict-marker-separator"], [data-merge-conflict="marker-base"], [data-merge-conflict="marker-separator"] {
399
+ --diffs-computed-decoration-bg: var(--diffs-bg-context);
400
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
401
+ }
402
+
403
+ [data-gutter-buffer="merge-conflict-marker-start"], [data-merge-conflict="marker-start"] {
404
+ --diffs-computed-decoration-bg: light-dark(color-mix(in lab,
405
+ var(--diffs-bg) 78%,
406
+ var(--conflict-bg-current-header-override, var(--diffs-addition-base))), color-mix(in lab,
407
+ var(--diffs-bg) 68%,
408
+ var(--conflict-bg-current-header-override, var(--diffs-addition-base))));
409
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
410
+ }
411
+
412
+ [data-gutter-buffer="merge-conflict-marker-end"], [data-merge-conflict="marker-end"] {
413
+ --diffs-computed-decoration-bg: light-dark(color-mix(in lab,
414
+ var(--diffs-bg) 78%,
415
+ var(--conflict-bg-incoming-header-override, var(--diffs-modified-base))), color-mix(in lab,
416
+ var(--diffs-bg) 68%,
417
+ var(--conflict-bg-incoming-header-override, var(--diffs-modified-base))));
418
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
419
+ }
420
+
421
+ [data-has-merge-conflict] [data-line-annotation], [data-has-merge-conflict] [data-gutter-buffer="annotation"] {
422
+ --diffs-computed-decoration-bg: var(--diffs-bg);
423
+ --diffs-hover-mix-target: var(--diffs-computed-editor-active-line-bg);
424
+ }
425
+
426
+ :where([data-background]) {
427
+ & [data-gutter-buffer], & [data-column-number] {
428
+ --mix-light: 91%;
429
+ --mix-dark: 85%;
430
+ }
431
+
432
+ & [data-line], & [data-no-newline] {
433
+ --mix-light: 88%;
434
+ --mix-dark: 80%;
435
+ }
436
+
437
+ & [data-gutter-buffer], & [data-column-number], & [data-line], & [data-no-newline] {
438
+ --diffs-diff-line-mix-target: var(--diffs-bg);
439
+
440
+ &[data-line-type="change-deletion"] {
441
+ --diffs-diff-line-mix-target: var(--diffs-bg-deletion-override, var(--diffs-deletion-base));
442
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
443
+
444
+ &:where([data-gutter-buffer], [data-column-number]) {
445
+ color: var(--diffs-fg-number-deletion-override, var(--diffs-deletion-base));
446
+ --diffs-diff-line-mix-target: var(--diffs-bg-deletion-number-override, var(--diffs-deletion-base));
447
+ }
448
+
449
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
450
+ var(--diffs-computed-decoration-bg) var(--mix-light),
451
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
452
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
453
+ var(--diffs-diff-line-mix-target)));
454
+ }
455
+
456
+ &[data-line-type="change-addition"] {
457
+ --diffs-diff-line-mix-target: var(--diffs-bg-addition-override, var(--diffs-addition-base));
458
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
459
+
460
+ &:where([data-gutter-buffer], [data-column-number]) {
461
+ color: var(--diffs-fg-number-addition-override, var(--diffs-addition-base));
462
+ --diffs-diff-line-mix-target: var(--diffs-bg-addition-number-override, var(--diffs-addition-base));
463
+ }
464
+
465
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
466
+ var(--diffs-computed-decoration-bg) var(--mix-light),
467
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
468
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
469
+ var(--diffs-diff-line-mix-target)));
470
+ }
471
+
472
+ &[data-merge-conflict="current"] {
473
+ --diffs-diff-line-mix-target: var(--conflict-bg-current-override, var(--diffs-addition-base));
474
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
475
+
476
+ &:where([data-gutter-buffer], [data-column-number]) {
477
+ color: var(--diffs-fg-number-addition-override, var(--diffs-addition-base));
478
+ --diffs-diff-line-mix-target: var(--conflict-bg-current-number-override, var(--diffs-addition-base));
479
+ }
480
+
481
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
482
+ var(--diffs-computed-decoration-bg) var(--mix-light),
483
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
484
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
485
+ var(--diffs-diff-line-mix-target)));
486
+ }
487
+
488
+ &[data-merge-conflict="incoming"] {
489
+ --diffs-diff-line-mix-target: var(--conflict-bg-incoming-override, var(--diffs-modified-base));
490
+ --diffs-hover-mix-target: var(--diffs-diff-line-mix-target);
491
+
492
+ &:where([data-gutter-buffer], [data-column-number]) {
493
+ color: var(--diffs-modified-base);
494
+ --diffs-diff-line-mix-target: var(--conflict-bg-incoming-number-override, var(--diffs-modified-base));
495
+ }
496
+
497
+ --diffs-computed-diff-line-bg: light-dark(color-mix(in lab,
498
+ var(--diffs-computed-decoration-bg) var(--mix-light),
499
+ var(--diffs-diff-line-mix-target)), color-mix(in lab,
500
+ var(--diffs-computed-decoration-bg) var(--mix-dark),
501
+ var(--diffs-diff-line-mix-target)));
502
+ }
503
+ }
504
+ }
505
+
506
+ [data-gutter-buffer], [data-column-number], [data-line], [data-line-annotation], [data-merge-conflict], [data-merge-conflict-actions], [data-no-newline], [data-editor-overlay] {
507
+ --diffs-selection-mix-target: var(--diffs-bg-selection-override, var(--diffs-selection-base));
508
+ --diffs-selection-emphasis-mix-target: var(--diffs-selection-mix-target);
509
+
510
+ &:where([data-editor-overlay]), &:where([data-line], [data-line-annotation], [data-merge-conflict], [data-merge-conflict-actions], [data-no-newline])[data-selected-line] {
511
+ --mix-selection-light: 82%;
512
+ --mix-selection-dark: 75%;
513
+ --diffs-hover-mix-target: var(--diffs-selection-mix-target);
514
+ }
515
+
516
+ &:where([data-gutter-buffer][data-selected-line], [data-column-number]:is([data-selected-line], [data-editor-active-line])) {
517
+ --mix-selection-light: 75%;
518
+ --mix-selection-dark: 60%;
519
+ --diffs-selection-mix-target: var(--diffs-bg-selection-number-override, var(--diffs-selection-base));
520
+ --diffs-hover-mix-target: var(--diffs-selection-mix-target);
521
+ }
522
+
523
+ &:where([data-line][data-selected-line]):is([data-line-type="change-addition"], [data-line-type="change-deletion"]) {
524
+ --diffs-selection-emphasis-mix-target: light-dark(color-mix(in lab,
525
+ var(--diffs-diff-line-mix-target, var(--diffs-selection-mix-target))
526
+ var(--mix-selection-light),
527
+ var(--diffs-selection-mix-target)), var(--diffs-selection-mix-target));
528
+ }
529
+
530
+ &:where([data-editor-overlay]), &[data-selected-line] {
531
+ --diffs-computed-selected-line-bg: light-dark(color-mix(in lab,
532
+ var(--diffs-computed-diff-line-bg) var(--mix-selection-light),
533
+ var(--diffs-selection-mix-target)), color-mix(in lab,
534
+ var(--diffs-computed-diff-line-bg) var(--mix-selection-dark),
535
+ var(--diffs-selection-mix-target)));
536
+ }
537
+ }
538
+
539
+ [data-line][data-editor-active-line], [data-column-number][data-editor-active-line] {
540
+ --diffs-computed-editor-active-line-bg: color-mix(in lab,
541
+ var(--diffs-computed-selected-line-bg)
542
+ var(--diffs-editor-active-line-source-mix, 100%),
543
+ var(--diffs-selection-emphasis-mix-target));
544
+ }
545
+
546
+ @media (pointer: fine) {
547
+ [data-line][data-hovered], [data-gutter-buffer][data-hovered], [data-column-number][data-hovered], [data-line-annotation][data-hovered], [data-no-newline][data-hovered], [data-merge-conflict][data-hovered], [data-merge-conflict-actions][data-hovered], [data-editor-overlay][data-hovered] {
548
+ --diffs-computed-hovered-line-bg: light-dark(color-mix(in lab,
549
+ var(--diffs-computed-editor-active-line-bg) 97%,
550
+ var(--diffs-hover-mix-target)), color-mix(in lab,
551
+ var(--diffs-computed-editor-active-line-bg) 91%,
552
+ var(--diffs-hover-mix-target)));
553
+ }
554
+ }
555
+
556
+ [data-gutter-buffer][data-selected-line], [data-column-number]:is([data-selected-line], [data-editor-active-line]) {
557
+ color: var(--diffs-selection-number-fg);
558
+ }
559
+
560
+ [data-no-newline] {
561
+ user-select: none;
562
+
563
+ & span {
564
+ opacity: .6;
565
+ }
566
+ }
567
+
568
+ [data-diff-type="split"][data-overflow="scroll"] {
569
+ grid-template-columns: 1fr 1fr;
570
+ display: grid;
571
+
572
+ & [data-additions] {
573
+ border-left: 1px solid var(--diffs-bg);
574
+ }
575
+
576
+ & [data-deletions] {
577
+ border-right: 1px solid var(--diffs-bg);
578
+ }
579
+ }
580
+
581
+ [data-code] {
582
+ grid-auto-flow: dense;
583
+ grid-template-columns: var(--diffs-code-grid);
584
+ overflow: var(--diffs-overflow-override, scroll) clip;
585
+ overscroll-behavior-x: none;
586
+ tab-size: var(--diffs-tab-size, 2);
587
+ padding-top: var(--diffs-gap-block, var(--diffs-gap-fallback));
588
+ padding-bottom: max(0px,
589
+ calc(var(--diffs-gap-block, var(--diffs-gap-fallback)) -
590
+ var(--diffs-scrollbar-gutter)));
591
+ scrollbar-gutter: stable;
592
+ align-self: flex-start;
593
+ display: grid;
594
+ }
595
+
596
+ [data-diffs-scrollbar-measure] {
597
+ opacity: 0;
598
+ pointer-events: none;
599
+ scrollbar-gutter: auto;
600
+ grid-template-columns: none;
601
+ width: 100px;
602
+ height: 100px;
603
+ padding: 0;
604
+ position: absolute;
605
+ top: -200px;
606
+ left: -200px;
607
+ }
608
+
609
+ [data-container-size] {
610
+ container-type: inline-size;
611
+ }
612
+
613
+ [data-code]::-webkit-scrollbar {
614
+ width: 0;
615
+ height: var(--diffs-scrollbar-gutter);
616
+ }
617
+
618
+ [data-code]::-webkit-scrollbar-track {
619
+ background: none;
620
+ }
621
+
622
+ [data-code]::-webkit-scrollbar-thumb {
623
+ background-color: #0000;
624
+ background-clip: content-box;
625
+ border: 1px solid #0000;
626
+ border-radius: 3px;
627
+ }
628
+
629
+ [data-code]::-webkit-scrollbar-corner {
630
+ background-color: #0000;
631
+ }
632
+
633
+ @supports ((-moz-appearance: none)) {
634
+ [data-code] {
635
+ scrollbar-width: thin;
636
+ scrollbar-color: var(--diffs-bg-context) transparent;
637
+ padding-bottom: var(--diffs-gap-block, var(--diffs-gap-fallback));
638
+ }
639
+ }
640
+
641
+ [data-diffs-header] ~ [data-diff], [data-diffs-header] ~ [data-file] {
642
+ & [data-code], &[data-overflow="wrap"], &[data-dehydrated][data-diff-type="split"][data-overflow="scroll"] {
643
+ padding-top: 0;
644
+ }
645
+ }
646
+
647
+ [data-gutter] {
648
+ grid-template-rows: subgrid;
649
+ grid-template-columns: subgrid;
650
+ z-index: 3;
651
+ background-color: var(--diffs-bg);
652
+ grid-column: 1;
653
+ display: grid;
654
+ position: relative;
655
+
656
+ & [data-gutter-buffer], & [data-column-number] {
657
+ border-right: var(--diffs-gap-style, 2px solid var(--diffs-bg));
658
+ }
659
+ }
660
+
661
+ [data-content] {
662
+ grid-template-rows: subgrid;
663
+ grid-template-columns: subgrid;
664
+ background-color: var(--diffs-bg);
665
+ grid-column: 2;
666
+ min-width: 0;
667
+ display: grid;
668
+ }
669
+
670
+ [data-diff-type="split"][data-overflow="wrap"], [data-dehydrated][data-diff-type="split"][data-overflow="scroll"] {
671
+ grid-auto-flow: dense;
672
+ grid-template-columns: repeat(2, var(--diffs-code-grid));
673
+ padding-block: var(--diffs-gap-block, var(--diffs-gap-fallback));
674
+ display: grid;
675
+
676
+ & [data-code] {
677
+ display: contents;
678
+ }
679
+
680
+ & [data-deletions] {
681
+ & [data-gutter] {
682
+ grid-column: 1;
683
+ }
684
+
685
+ & [data-content] {
686
+ border-right: 1px solid var(--diffs-bg);
687
+ grid-column: 2;
688
+ }
689
+ }
690
+
691
+ & [data-additions] {
692
+ & [data-gutter] {
693
+ border-left: 1px solid var(--diffs-bg);
694
+ grid-column: 3;
695
+ }
696
+
697
+ & [data-content] {
698
+ grid-column: 4;
699
+ }
700
+ }
701
+ }
702
+
703
+ [data-dehydrated][data-diff-type="split"][data-overflow="scroll"] [data-content] {
704
+ overflow: clip;
705
+ }
706
+
707
+ [data-overflow="scroll"] [data-gutter] {
708
+ position: sticky;
709
+ left: 0;
710
+ }
711
+
712
+ [data-interactive-lines] [data-line] {
713
+ cursor: pointer;
714
+ }
715
+
716
+ [data-interactive-line-numbers] [data-column-number] {
717
+ cursor: pointer;
718
+ touch-action: none;
719
+ }
720
+
721
+ [data-content-buffer], [data-gutter-buffer] {
722
+ user-select: none;
723
+ min-height: 1lh;
724
+ position: relative;
725
+ }
726
+
727
+ [data-gutter-buffer] {
728
+ padding-left: 2ch;
729
+ padding-right: 1ch;
730
+
731
+ &:before {
732
+ content: "";
733
+ min-width: var(--diffs-min-number-column-width, var(--diffs-min-number-column-width-default, 3ch));
734
+ display: block;
735
+ }
736
+ }
737
+
738
+ [data-gutter-buffer="annotation"] {
739
+ --diffs-annotation-bg: var(--diffs-bg-context-gutter);
740
+ min-height: 0;
741
+ }
742
+
743
+ [data-gutter-buffer="buffer"] {
744
+ --diffs-line-bg: var(--diffs-bg-context-gutter);
745
+ }
746
+
747
+ [data-content-buffer] {
748
+ background-position: 5px 0;
749
+ background-size: 8px 8px;
750
+ background-origin: border-box;
751
+ background-image: repeating-linear-gradient(-45deg,
752
+ transparent,
753
+ transparent calc(3px * 1.414),
754
+ var(--diffs-bg-buffer) calc(3px * 1.414),
755
+ var(--diffs-bg-buffer) calc(4px * 1.414));
756
+ grid-column: 1;
757
+ }
758
+
759
+ [data-separator] {
760
+ box-sizing: content-box;
761
+ background-color: var(--diffs-bg);
762
+ }
763
+
764
+ [data-separator="simple"] {
765
+ min-height: 4px;
766
+ }
767
+
768
+ [data-separator="line-info"], [data-separator="line-info-basic"], [data-separator="metadata"], [data-separator="simple"] {
769
+ background-color: var(--diffs-bg-separator);
770
+ }
771
+
772
+ [data-separator="line-info"], [data-separator="line-info-basic"], [data-separator="metadata"] {
773
+ height: 32px;
774
+ position: relative;
775
+ }
776
+
777
+ [data-separator-wrapper] {
778
+ user-select: none;
779
+ fill: currentColor;
780
+ background-color: var(--diffs-bg);
781
+ align-items: center;
782
+ height: 100%;
783
+ display: flex;
784
+ position: absolute;
785
+ inset-inline: 0;
786
+ }
787
+
788
+ [data-content] [data-separator-wrapper] {
789
+ display: none;
790
+ }
791
+
792
+ [data-separator="metadata"] [data-separator-wrapper] {
793
+ background-color: var(--diffs-bg-separator);
794
+ height: 100%;
795
+ color: var(--diffs-fg-number);
796
+ white-space: nowrap;
797
+ text-overflow: ellipsis;
798
+ min-width: min-content;
799
+ padding-inline: 1ch;
800
+ inset-inline: 100% auto;
801
+ overflow: hidden;
802
+ }
803
+
804
+ [data-separator="line-info"] {
805
+ margin-block: var(--diffs-gap-block, var(--diffs-gap-fallback));
806
+
807
+ & [data-separator-wrapper] {
808
+ min-width: 16px;
809
+ }
810
+ }
811
+
812
+ [data-separator="line-info-basic"], [data-separator="metadata"] {
813
+ margin-block: 0;
814
+ }
815
+
816
+ [data-separator="line-info"][data-separator-first] {
817
+ margin-top: 0;
818
+ }
819
+
820
+ [data-separator="line-info"][data-separator-last] {
821
+ margin-bottom: 0;
822
+ }
823
+
824
+ [data-expand-index] [data-separator-wrapper] {
825
+ grid-template-columns: 32px auto;
826
+ display: grid;
827
+ }
828
+
829
+ [data-expand-index] [data-separator-wrapper][data-separator-multi-button] {
830
+ grid-template-columns: 32px 32px auto;
831
+ }
832
+
833
+ [data-expand-button], [data-separator-content] {
834
+ background-color: var(--diffs-bg-separator);
835
+ flex: none;
836
+ align-items: center;
837
+ display: flex;
838
+ }
839
+
840
+ [data-expand-index] [data-separator-content]:hover {
841
+ cursor: pointer;
842
+ text-decoration: underline;
843
+ }
844
+
845
+ [data-expand-button] {
846
+ cursor: pointer;
847
+ min-width: 32px;
848
+ color: var(--diffs-fg-number);
849
+ border-right: 2px solid var(--diffs-bg);
850
+ flex-shrink: 0;
851
+ justify-content: center;
852
+ align-self: stretch;
853
+
854
+ &:hover {
855
+ color: var(--diffs-fg);
856
+ }
857
+
858
+ &[data-expand-all-button] {
859
+ display: none;
860
+ }
861
+ }
862
+
863
+ [data-expand-down] [data-icon] {
864
+ transform: scaleY(-1);
865
+ }
866
+
867
+ [data-separator-content] {
868
+ height: 100%;
869
+ color: var(--diffs-fg-number);
870
+ flex: auto;
871
+ justify-content: flex-start;
872
+ padding: 0 1ch;
873
+ overflow: hidden;
874
+ }
875
+
876
+ [data-separator="line-info"], [data-separator="line-info-basic"] {
877
+ & [data-separator-content] {
878
+ user-select: none;
879
+ height: 100%;
880
+ overflow: clip;
881
+ }
882
+ }
883
+
884
+ [data-unmodified-lines] {
885
+ text-overflow: ellipsis;
886
+ white-space: nowrap;
887
+ flex: 0 auto;
888
+ min-width: 0;
889
+ display: block;
890
+ overflow: hidden;
891
+ }
892
+
893
+ @supports (width: 1cqi) {
894
+ [data-unified] {
895
+ & [data-separator="line-info"] [data-separator-wrapper] {
896
+ padding-inline: var(--diffs-gap-inline, var(--diffs-gap-fallback));
897
+ width: 100cqi;
898
+
899
+ & [data-separator-content] {
900
+ border-radius: 6px;
901
+ }
902
+ }
903
+
904
+ & [data-separator="line-info"][data-expand-index] [data-separator-wrapper] [data-separator-content] {
905
+ border-top-left-radius: unset;
906
+ border-bottom-left-radius: unset;
907
+ }
908
+ }
909
+
910
+ [data-gutter] {
911
+ & [data-separator="line-info"] [data-separator-wrapper] {
912
+ padding-left: var(--diffs-gap-inline, var(--diffs-gap-fallback));
913
+ }
914
+
915
+ & [data-separator="line-info"] [data-separator-content] {
916
+ border-top-left-radius: 6px;
917
+ border-bottom-left-radius: 6px;
918
+ }
919
+
920
+ & [data-separator="line-info"][data-expand-index] [data-separator-content] {
921
+ border-top-left-radius: unset;
922
+ border-bottom-left-radius: unset;
923
+ }
924
+ }
925
+
926
+ [data-additions] {
927
+ & [data-content] [data-separator="line-info"] {
928
+ background-color: var(--diffs-bg);
929
+
930
+ & [data-separator-wrapper] {
931
+ display: none;
932
+ }
933
+ }
934
+
935
+ & [data-gutter] [data-separator="line-info"] [data-separator-wrapper] {
936
+ background-color: var(--diffs-bg-separator);
937
+ border-top-right-radius: 6px;
938
+ border-bottom-right-radius: 6px;
939
+ height: 100%;
940
+ display: block;
941
+
942
+ & [data-separator-content], & [data-expand-button] {
943
+ display: none;
944
+ }
945
+ }
946
+ }
947
+
948
+ [data-overflow="scroll"] [data-additions] [data-gutter] [data-separator="line-info"] [data-separator-wrapper] {
949
+ width: calc(100cqi - var(--diffs-gap-inline, var(--diffs-gap-fallback)));
950
+ }
951
+
952
+ [data-overflow="wrap"] [data-additions] [data-content] [data-separator="line-info"] [data-separator-wrapper] {
953
+ background-color: var(--diffs-bg-separator);
954
+ height: 100%;
955
+ margin-right: var(--diffs-gap-inline, var(--diffs-gap-fallback));
956
+ border-top-right-radius: 6px;
957
+ border-bottom-right-radius: 6px;
958
+ display: block;
959
+
960
+ & [data-separator-content], & [data-expand-button] {
961
+ display: none;
962
+ }
963
+ }
964
+
965
+ [data-separator="line-info"] [data-separator-wrapper] {
966
+ & [data-expand-both], & [data-expand-down], & [data-expand-up] {
967
+ border-top-left-radius: 6px;
968
+ border-bottom-left-radius: 6px;
969
+ }
970
+ }
971
+
972
+ @media (pointer: fine) {
973
+ [data-separator="line-info"] [data-separator-wrapper] {
974
+ &[data-separator-multi-button] {
975
+ & [data-expand-up] {
976
+ border-top-left-radius: 6px;
977
+ border-bottom-left-radius: unset;
978
+ }
979
+
980
+ & [data-expand-down] {
981
+ border-bottom-left-radius: 6px;
982
+ border-top-left-radius: unset;
983
+ }
984
+ }
985
+ }
986
+ }
987
+ }
988
+
989
+ @media (pointer: coarse) {
990
+ [data-separator="line-info-basic"] [data-separator-wrapper][data-separator-multi-button] {
991
+ grid-template-columns: 34px 34px auto;
992
+
993
+ & [data-separator-content] {
994
+ grid-column: unset;
995
+ grid-row: unset;
996
+ }
997
+ }
998
+
999
+ @supports (width: 1cqi) {
1000
+ [data-separator="line-info"] [data-separator-wrapper] {
1001
+ & [data-expand-both], & [data-expand-down], & [data-expand-up] {
1002
+ border-top-left-radius: 6px;
1003
+ border-bottom-left-radius: 6px;
1004
+ }
1005
+
1006
+ &[data-separator-multi-button] {
1007
+ & [data-expand-up] {
1008
+ border-top-left-radius: 6px;
1009
+ border-bottom-left-radius: 6px;
1010
+ }
1011
+
1012
+ & [data-expand-down] {
1013
+ border-bottom-left-radius: unset;
1014
+ border-top-left-radius: unset;
1015
+ }
1016
+ }
1017
+ }
1018
+ }
1019
+ }
1020
+
1021
+ @media (pointer: fine) {
1022
+ [data-separator-wrapper][data-separator-multi-button] {
1023
+ grid-template-rows: 50% 50%;
1024
+ display: grid;
1025
+
1026
+ & [data-separator-content] {
1027
+ grid-area: 1 / 2 / -1;
1028
+ min-width: min-content;
1029
+ }
1030
+
1031
+ & [data-expand-button] {
1032
+ grid-column: 1;
1033
+ }
1034
+ }
1035
+
1036
+ [data-separator="line-info"] [data-separator-wrapper], [data-separator="line-info"] [data-separator-wrapper][data-separator-multi-button] {
1037
+ grid-template-columns: 34px auto;
1038
+ }
1039
+
1040
+ [data-separator="line-info-basic"][data-expand-index] [data-separator-wrapper] {
1041
+ grid-template-columns: 100% auto;
1042
+ }
1043
+
1044
+ [data-separator="line-info"], [data-separator="line-info-basic"] {
1045
+ & [data-separator-multi-button] {
1046
+ & [data-expand-up] {
1047
+ border-bottom: 1px solid var(--diffs-bg);
1048
+ border-right: 2px solid var(--diffs-bg);
1049
+ }
1050
+
1051
+ & [data-expand-down] {
1052
+ border-top: 1px solid var(--diffs-bg);
1053
+ border-right: 2px solid var(--diffs-bg);
1054
+ }
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+ [data-additions] [data-gutter] [data-separator-wrapper], [data-additions] [data-separator="line-info-basic"] [data-separator-wrapper], [data-content] [data-separator-wrapper] {
1060
+ display: none;
1061
+ }
1062
+
1063
+ [data-line-annotation] {
1064
+ min-height: var(--diffs-annotation-min-height, 0);
1065
+ z-index: 2;
1066
+ }
1067
+
1068
+ [data-merge-conflict-actions] {
1069
+ z-index: 2;
1070
+ }
1071
+
1072
+ [data-separator="custom"] {
1073
+ grid-template-columns: subgrid;
1074
+ display: grid;
1075
+ }
1076
+
1077
+ [data-line], [data-column-number], [data-no-newline] {
1078
+ padding-inline: 1ch;
1079
+ position: relative;
1080
+ }
1081
+
1082
+ [data-indicators="classic"] [data-line] {
1083
+ padding-inline-start: 2ch;
1084
+ }
1085
+
1086
+ [data-indicators="classic"] {
1087
+ & [data-line-type="change-addition"], & [data-line-type="change-deletion"] {
1088
+ &[data-no-newline], &[data-line] {
1089
+ &:before {
1090
+ user-select: none;
1091
+ width: 1ch;
1092
+ height: 1lh;
1093
+ display: inline-block;
1094
+ position: absolute;
1095
+ top: 0;
1096
+ left: 0;
1097
+ }
1098
+ }
1099
+ }
1100
+
1101
+ & [data-line-type="change-addition"] {
1102
+ &[data-line], &[data-no-newline] {
1103
+ &:before {
1104
+ content: "+";
1105
+ color: var(--diffs-addition-base);
1106
+ }
1107
+ }
1108
+ }
1109
+
1110
+ & [data-line-type="change-deletion"] {
1111
+ &[data-line], &[data-no-newline] {
1112
+ &:before {
1113
+ content: "-";
1114
+ color: var(--diffs-deletion-base);
1115
+ }
1116
+ }
1117
+ }
1118
+ }
1119
+
1120
+ [data-indicators="bars"] {
1121
+ & [data-line-type="change-deletion"], & [data-line-type="change-addition"] {
1122
+ &[data-column-number] {
1123
+ &:before {
1124
+ content: "";
1125
+ user-select: none;
1126
+ contain: strict;
1127
+ width: 4px;
1128
+ height: 100%;
1129
+ display: block;
1130
+ position: absolute;
1131
+ top: 0;
1132
+ left: 0;
1133
+ }
1134
+ }
1135
+ }
1136
+
1137
+ & [data-line-type="change-deletion"] {
1138
+ &[data-column-number] {
1139
+ &:before {
1140
+ background-image: linear-gradient(0deg,
1141
+ var(--diffs-bg-deletion) 50%,
1142
+ var(--diffs-deletion-base) 50%);
1143
+ background-repeat: repeat;
1144
+ background-size: 2px 2px;
1145
+ background-size: calc(1lh / round(1lh / 2px))
1146
+ calc(1lh / round(1lh / 2px));
1147
+ }
1148
+ }
1149
+ }
1150
+
1151
+ & [data-line-type="change-addition"] {
1152
+ &[data-column-number] {
1153
+ &:before {
1154
+ background-color: var(--diffs-addition-base);
1155
+ }
1156
+ }
1157
+ }
1158
+ }
1159
+
1160
+ [data-overflow="wrap"] {
1161
+ & [data-line] {
1162
+ white-space: pre-wrap;
1163
+ word-break: break-word;
1164
+ }
1165
+
1166
+ & [data-annotation-content] {
1167
+ word-break: break-word;
1168
+ }
1169
+ }
1170
+
1171
+ [data-overflow="scroll"] [data-line] {
1172
+ white-space: pre;
1173
+ min-height: 1lh;
1174
+ }
1175
+
1176
+ [data-column-number] {
1177
+ box-sizing: content-box;
1178
+ text-align: right;
1179
+ user-select: none;
1180
+ color: var(--diffs-fg-number);
1181
+ padding-left: 2ch;
1182
+ }
1183
+
1184
+ [data-line-number-content] {
1185
+ min-width: var(--diffs-min-number-column-width, var(--diffs-min-number-column-width-default, 3ch));
1186
+ z-index: 1;
1187
+ display: inline-block;
1188
+ position: relative;
1189
+ }
1190
+
1191
+ [data-disable-line-numbers] {
1192
+ & [data-gutter-buffer], & [data-column-number] {
1193
+ min-width: 4px;
1194
+ padding: 0;
1195
+
1196
+ &:before {
1197
+ min-width: 0;
1198
+ }
1199
+ }
1200
+
1201
+ & [data-line-number-content] {
1202
+ display: none;
1203
+ }
1204
+
1205
+ & [data-gutter-utility-slot] {
1206
+ right: unset;
1207
+ justify-content: flex-start;
1208
+ left: 0;
1209
+ }
1210
+
1211
+ &[data-indicators="bars"] [data-gutter-utility-slot] {
1212
+ left: 6px;
1213
+ }
1214
+ }
1215
+
1216
+ [data-file][data-disable-line-numbers] {
1217
+ & [data-gutter-buffer], & [data-column-number] {
1218
+ border-right: 0;
1219
+ min-width: 0;
1220
+ }
1221
+ }
1222
+
1223
+ [data-diff-span] {
1224
+ box-decoration-break: clone;
1225
+ border-radius: 3px;
1226
+ }
1227
+
1228
+ [data-line-type="change-addition"] [data-diff-span] {
1229
+ background-color: var(--diffs-bg-addition-emphasis);
1230
+ }
1231
+
1232
+ [data-line-type="change-deletion"] [data-diff-span] {
1233
+ background-color: var(--diffs-bg-deletion-emphasis);
1234
+ }
1235
+
1236
+ [data-merge-conflict="marker-start"], [data-merge-conflict="marker-base"], [data-merge-conflict="marker-separator"], [data-merge-conflict="marker-end"] {
1237
+ color: var(--diffs-fg);
1238
+ padding-left: 1ch;
1239
+ }
1240
+
1241
+ [data-merge-conflict="marker-start"], [data-merge-conflict="marker-end"] {
1242
+ align-items: center;
1243
+ display: flex;
1244
+
1245
+ &:after {
1246
+ color: var(--diffs-fg-conflict-marker);
1247
+ font-size: .75rem;
1248
+ font-style: normal;
1249
+ line-height: 1.25rem;
1250
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
1251
+ padding-left: 1ch;
1252
+ }
1253
+ }
1254
+
1255
+ [data-merge-conflict="marker-start"]:after {
1256
+ content: "(Current Change)";
1257
+ }
1258
+
1259
+ [data-merge-conflict="marker-end"]:after {
1260
+ content: "(Incoming Change)";
1261
+ }
1262
+
1263
+ [data-merge-conflict-actions-content] {
1264
+ min-height: 1.75rem;
1265
+ font-family: var(--diffs-header-font-family, var(--diffs-header-font-fallback));
1266
+ color: var(--diffs-fg);
1267
+ align-items: center;
1268
+ gap: .25rem;
1269
+ padding-inline: .5rem;
1270
+ font-size: .75rem;
1271
+ line-height: 1.2;
1272
+ display: flex;
1273
+ }
1274
+
1275
+ [data-merge-conflict-action] {
1276
+ appearance: none;
1277
+ color: var(--diffs-fg-number);
1278
+ font: inherit;
1279
+ cursor: pointer;
1280
+ background: none;
1281
+ border: 0;
1282
+ padding: 0;
1283
+ font-style: normal;
1284
+ }
1285
+
1286
+ [data-merge-conflict-action]:hover {
1287
+ color: var(--diffs-fg);
1288
+ }
1289
+
1290
+ [data-merge-conflict-action="current"]:hover {
1291
+ color: var(--diffs-addition-base);
1292
+ }
1293
+
1294
+ [data-merge-conflict-action="incoming"]:hover {
1295
+ color: var(--diffs-modified-base);
1296
+ }
1297
+
1298
+ [data-merge-conflict-action-separator] {
1299
+ color: var(--diffs-fg-number);
1300
+ opacity: .6;
1301
+ user-select: none;
1302
+ }
1303
+
1304
+ [data-diffs-header="default"] {
1305
+ background-color: var(--diffs-bg);
1306
+ justify-content: space-between;
1307
+ align-items: center;
1308
+ gap: var(--diffs-gap-inline, var(--diffs-gap-fallback));
1309
+ min-height: calc(1lh + (var(--diffs-gap-block, var(--diffs-gap-fallback)) * 3));
1310
+ z-index: 2;
1311
+ flex-direction: row;
1312
+ padding-inline: 16px;
1313
+ display: flex;
1314
+ position: relative;
1315
+ top: 0;
1316
+ }
1317
+
1318
+ [data-header-content] {
1319
+ align-items: center;
1320
+ gap: var(--diffs-gap-inline, var(--diffs-gap-fallback));
1321
+ white-space: nowrap;
1322
+ flex-direction: row;
1323
+ min-width: 0;
1324
+ display: flex;
1325
+ }
1326
+
1327
+ [data-header-content] [data-prev-name], [data-header-content] [data-title] {
1328
+ text-overflow: ellipsis;
1329
+ white-space: nowrap;
1330
+ direction: rtl;
1331
+ min-width: 0;
1332
+ overflow: hidden;
1333
+ }
1334
+
1335
+ [data-prev-name] {
1336
+ opacity: .7;
1337
+ }
1338
+
1339
+ [data-rename-icon] {
1340
+ fill: currentColor;
1341
+ flex-grow: 0;
1342
+ flex-shrink: 0;
1343
+ }
1344
+
1345
+ [data-diffs-header="default"] [data-metadata] {
1346
+ white-space: nowrap;
1347
+ align-items: center;
1348
+ gap: 1ch;
1349
+ display: flex;
1350
+ }
1351
+
1352
+ [data-diffs-header="default"] [data-additions-count] {
1353
+ font-family: var(--diffs-font-family, var(--diffs-font-fallback));
1354
+ color: var(--diffs-addition-base);
1355
+ }
1356
+
1357
+ [data-diffs-header="default"] [data-deletions-count] {
1358
+ font-family: var(--diffs-font-family, var(--diffs-font-fallback));
1359
+ color: var(--diffs-deletion-base);
1360
+ }
1361
+
1362
+ [data-change-icon] {
1363
+ fill: currentColor;
1364
+ flex-shrink: 0;
1365
+ }
1366
+
1367
+ [data-change-icon="change"], [data-change-icon="rename-pure"], [data-change-icon="rename-changed"] {
1368
+ color: var(--diffs-modified-base);
1369
+ }
1370
+
1371
+ [data-change-icon="new"] {
1372
+ color: var(--diffs-addition-base);
1373
+ }
1374
+
1375
+ [data-change-icon="deleted"] {
1376
+ color: var(--diffs-deletion-base);
1377
+ }
1378
+
1379
+ [data-change-icon="file"] {
1380
+ opacity: .6;
1381
+ }
1382
+
1383
+ [data-annotation-content] {
1384
+ z-index: 2;
1385
+ isolation: isolate;
1386
+ white-space: normal;
1387
+ align-self: flex-start;
1388
+ min-width: 0;
1389
+ display: flow-root;
1390
+ position: relative;
1391
+ }
1392
+
1393
+ [data-overflow="scroll"] [data-annotation-content], [data-overflow="scroll"] [data-merge-conflict-actions-content] {
1394
+ width: var(--diffs-column-content-width, auto);
1395
+ left: var(--diffs-column-number-width, 0);
1396
+ position: sticky;
1397
+ }
1398
+
1399
+ [data-annotation-slot] {
1400
+ text-wrap-mode: wrap;
1401
+ word-break: normal;
1402
+ white-space-collapse: collapse;
1403
+ }
1404
+
1405
+ [data-gutter-utility-slot] {
1406
+ touch-action: none;
1407
+ justify-content: flex-end;
1408
+ display: flex;
1409
+ position: absolute;
1410
+ top: 0;
1411
+ bottom: 0;
1412
+ right: 0;
1413
+ }
1414
+
1415
+ [data-utility-button] {
1416
+ appearance: none;
1417
+ cursor: pointer;
1418
+ width: 1lh;
1419
+ height: 1lh;
1420
+ font-size: var(--diffs-font-size, 13px);
1421
+ line-height: var(--diffs-line-height, 20px);
1422
+ background-color: var(--diffs-modified-base);
1423
+ color: var(--diffs-bg);
1424
+ fill: currentColor;
1425
+ z-index: 4;
1426
+ touch-action: none;
1427
+ border: none;
1428
+ border-radius: 4px;
1429
+ justify-content: center;
1430
+ align-items: center;
1431
+ margin-right: calc(-1lh + 1ch);
1432
+ padding: 0;
1433
+ display: flex;
1434
+ position: relative;
1435
+
1436
+ &:before {
1437
+ content: "";
1438
+ display: block;
1439
+ position: absolute;
1440
+ inset: 0 0 0 -4px;
1441
+ }
1442
+ }
1443
+
1444
+ [data-decoration-bar-stack] {
1445
+ pointer-events: none;
1446
+ isolation: isolate;
1447
+ z-index: 1;
1448
+ background-color: var(--diffs-decoration-bar-color, transparent);
1449
+ box-sizing: content-box;
1450
+ border-left: 2px solid var(--diffs-bg);
1451
+ border-right: 2px solid var(--diffs-bg);
1452
+ width: 6px;
1453
+ position: absolute;
1454
+ top: 0;
1455
+ bottom: 0;
1456
+ right: -2px;
1457
+
1458
+ [data-decoration-bar-depth="1"] & {
1459
+ background-color: color-mix(in lab,
1460
+ var(--diffs-bg) 20%,
1461
+ var(--diffs-decoration-bar-color, transparent));
1462
+ }
1463
+
1464
+ [data-decoration-bar-depth="2"] & {
1465
+ background-color: color-mix(in lab,
1466
+ var(--diffs-bg) 45%,
1467
+ var(--diffs-decoration-bar-color, transparent));
1468
+ }
1469
+
1470
+ [data-decoration-bar-depth="3"] & {
1471
+ background-color: color-mix(in lab,
1472
+ var(--diffs-bg) 65%,
1473
+ var(--diffs-decoration-bar-color, transparent));
1474
+ }
1475
+
1476
+ [data-decoration-bar-start] & {
1477
+ border-top-left-radius: 5px;
1478
+ border-top-right-radius: 5px;
1479
+ }
1480
+
1481
+ [data-decoration-bar-end] & {
1482
+ z-index: 3;
1483
+ border-bottom-right-radius: 5px;
1484
+ border-bottom-left-radius: 5px;
1485
+ }
1486
+ }
1487
+
1488
+ [data-placeholder] {
1489
+ contain: strict;
1490
+ }
1491
+
1492
+ [data-error-wrapper] {
1493
+ padding: var(--diffs-gap-block, var(--diffs-gap-fallback))
1494
+ var(--diffs-gap-inline, var(--diffs-gap-fallback));
1495
+ scrollbar-width: none;
1496
+ max-height: 400px;
1497
+ overflow: auto;
1498
+
1499
+ & [data-error-message] {
1500
+ color: var(--diffs-deletion-base);
1501
+ font-size: 18px;
1502
+ font-weight: bold;
1503
+ }
1504
+
1505
+ & [data-error-stack] {
1506
+ color: var(--diffs-fg-number);
1507
+ }
1508
+ }
1509
+ }
1510
+
1511
+ @layer theme, rendered, unsafe;
1512
+ `;let Zt;function ji(e){if(Zt!=null)return Zt;const t=e.host;if(typeof HTMLElement<"u"&&t instanceof HTMLElement&&!t.isConnected)return;const n=document.createElement("div");n.setAttribute("data-code",""),n.setAttribute(nl,"true");const i=document.createElement("div");return i.style.position="relative",i.style.width="200%",i.style.height="200%",n.appendChild(i),e.appendChild(n),Zt=Math.max(n.offsetHeight-n.clientHeight,0),n.remove(),Zt}function _a(e){return`${to}: ${e==null?"var(--diffs-scrollbar-gutter-fallback)":`${e}px`};`}const Ra="@layer base, theme, rendered, unsafe;",qp=new RegExp(`${Qp(to)}\\s*:\\s*[^;]+;`);function Kp(e){return`${Ra}
1513
+ @layer unsafe {
1514
+ ${e}
1515
+ }`}function Xp(e,t="system",n){return`${Ra}
1516
+ @layer rendered {
1517
+ :host {${t==="system"?"":`
1518
+ color-scheme: ${t};`}
1519
+ ${_a(n)}
1520
+ ${e}
1521
+ }
1522
+ }`}function Yp(e,t){const n=_a(t);return e.replace(qp,n)}function Qp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pi({code:e,pre:t,columnType:n,rowSpan:i,containerSize:r=!1}={}){return e==null&&(e=document.createElement("code"),e.setAttribute("data-code",""),n!=null&&e.setAttribute(`data-${n}`,""),t?.appendChild(e)),i!=null?e.style.setProperty("grid-row",`span ${i}`):e.style.removeProperty("grid-row"),r?e.setAttribute("data-container-size",""):e.removeAttribute("data-container-size"),e}function Zp(e,t){if(t==null)return;const n=e.shadowRoot??e.attachShadow({mode:"open"});n.innerHTML===""&&(n.innerHTML=t)}function Jp(e,{type:t,diffIndicators:n,disableBackground:i,disableLineNumbers:r,overflow:s,split:o,totalLines:l,customProperties:a}){if(a!=null)for(const d in a){const c=a[d];c!=null&&e.setAttribute(d,`${c}`)}switch(t==="diff"?(e.setAttribute("data-diff",""),e.removeAttribute("data-file")):(e.setAttribute("data-file",""),e.removeAttribute("data-diff")),n){case"bars":case"classic":e.setAttribute("data-indicators",n);break;case"none":e.removeAttribute("data-indicators");break}return r?e.setAttribute("data-disable-line-numbers",""):e.removeAttribute("data-disable-line-numbers"),i?e.removeAttribute("data-background"):e.setAttribute("data-background",""),t==="diff"?e.setAttribute("data-diff-type",o?"split":"single"):e.removeAttribute("data-diff-type"),e.setAttribute("data-overflow",s),e.style.setProperty("--diffs-min-number-column-width-default",`${`${l}`.length}ch`),e}function Rs(e){if(typeof HTMLStyleElement<"u"&&e instanceof HTMLStyleElement)return!0;const t=e.tagName??e.nodeName;return typeof t=="string"&&t.toLowerCase()==="style"}function eg(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function Is(e,t){const n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=""}}function tg({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===""){t?.remove();return}return t??=ng(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function ng(){const e=document.createElement("style");return e.setAttribute(el,""),e}let ig;function rg(){return ig??="safari"in window&&"pushNotification"in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}if(typeof HTMLElement<"u"&&customElements.get("diffs-container")==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;const i=this.attachShadow({mode:"open"});e==null&&(e=new CSSStyleSheet,e.replaceSync(Vp)),i.adoptedStyleSheets=[e]}connectedCallback(){ji(this.shadowRoot??this.attachShadow({mode:"open"}))}}customElements.define(Ys,t)}function gi(e){return{...rl,...e}}function ht(e,t){const n=sg(e,t);return t?n:e.diffHeaderHeight+n}function sg(e,t){return e.paddingTop??(t?e.spacing:0)}function Ia(e){return e.paddingBottom??e.spacing}function og(e){switch(e){case"simple":return 4;case"metadata":case"line-info":case"line-info-basic":case"custom":return 32}}function pt(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function ag(e){return{...e,hunks:e.hunks.map(t=>({...t,hunkContent:t.hunkContent.map(n=>({...n}))})),deletionLines:[...e.deletionLines],additionLines:[...e.additionLines]}}function Wi(e){return e!==""?e.split(Xa):[]}function Vi(e,t,n){const i=e==="clone"?ag(t):t;if(!i.isPartial)throw new Error("hydratePartialDiff: fileDiff must be partial");switch(i.type){case"change":case"rename-changed":return lg(i,cg(i,n),Ts(i,n));case"rename-pure":{const r=Ts(i,n);ug(i,n);const s=Wi(r.contents);return i.isPartial=!1,i.deletionLines=s,i.additionLines=s,Ta(i,null,r),i}}throw new Error(`hydratePartialDiff: ${i.type} diffs cannot be hydrated from loaded files`)}function lg(e,t,n){const i=Wi(t.contents),r=Wi(n.contents),{hunks:s,splitLineCount:o,unifiedLineCount:l}=dg(e.hunks,r.length);return e.hunks=s,e.splitLineCount=o,e.unifiedLineCount=l,e.isPartial=!1,e.deletionLines=i,e.additionLines=r,Ta(e,t,n),e}function dg(e,t){let n=0,i=0,r=0;const s=[];for(const o of e){const l=Math.max(o.additionStart-1,0),a=Math.max(o.deletionStart-1,0);let d=l,c=a,u=0,h=0,f=0,p=0;const g=[];for(const m of o.hunkContent){if(m.type==="context"){g.push({...m,additionLineIndex:d,deletionLineIndex:c}),d+=m.lines,c+=m.lines,f+=m.lines,p+=m.lines;continue}g.push({...m,additionLineIndex:d,deletionLineIndex:c}),d+=m.additions,c+=m.deletions,u+=m.additions,h+=m.deletions,f+=Math.max(m.additions,m.deletions),p+=m.additions+m.deletions}const v=Math.max(Se(o.additionStart,o.additionCount)-r,0);s.push({...o,collapsedBefore:v,additionLineIndex:l,deletionLineIndex:a,additionLines:u,deletionLines:h,hunkContent:g,splitLineStart:n+v,unifiedLineStart:i+v,splitLineCount:f,unifiedLineCount:p}),n+=v+f,i+=v+p,r=ie(o.additionStart,o.additionCount)}if(s.length>0){const o=s[s.length-1],l=ie(o.additionStart,o.additionCount),a=Math.max(t-l,0);n+=a,i+=a}return{hunks:s,splitLineCount:n,unifiedLineCount:i}}function cg(e,t){if(t.oldFile==null)throw new Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Ts(e,t){if(t.newFile==null)throw new Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function ug(e,t){if(t.oldFile!==null)throw new Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function hg(e,t,n){return e.cacheKey!=null?`${e.cacheKey}:hydrated`:fg(t,n)}function Ta(e,t,n){const i=hg(e,t,n);if(i==null){delete e.cacheKey;return}e.cacheKey=i}function fg(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?`${e.cacheKey}:${t.cacheKey}`:void 0:e?.cacheKey??t?.cacheKey}var pg=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,this.enabled=!1)}setup(e,t,n){if(t==null||n==null)for(const i of e.children??[])i instanceof HTMLElement&&("deletions"in i.dataset?t=i:"additions"in i.dataset&&(n=i));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function at(e,t){return nr(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function Jt(e){return T({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function en(e){return T({tagName:"div",children:[T({tagName:"span",children:[Ce("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":e,"data-column-content":""}})}function mi(e){return T({tagName:"div",children:[gn({name:e==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":e==="both"?"":void 0,"data-expand-up":e==="up"?"":void 0,"data-expand-down":e==="down"?"":void 0}})}function lt({type:e,content:t,expandIndex:n,chunked:i=!1,slotName:r,isFirstHunk:s,isLastHunk:o}){let l=0;const a=[];if(e==="metadata"&&t!=null&&a.push(T({tagName:"div",children:[Ce(t)],properties:{"data-separator-wrapper":""}})),(e==="line-info"||e==="line-info-basic")&&t!=null){const d=[];n!=null&&(i?(s||(d.push(mi("up")),l++),o||(d.push(mi("down")),l++)):(d.push(mi(!s&&!o?"both":s?"down":"up")),l++)),d.push(T({tagName:"div",children:[T({tagName:"span",children:[Ce(t)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),i&&n!=null&&d.push(T({tagName:"div",children:[Ce("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}})),a.push(T({tagName:"div",children:d,properties:{"data-separator-wrapper":"","data-separator-multi-button":l>1?"":void 0}}))}return e==="custom"&&r!=null&&a.push(T({tagName:"slot",properties:{name:r}})),T({tagName:"div",children:a,properties:{"data-separator":a.length===0?"simple":e,"data-expand-index":n,"data-separator-first":s?"":void 0,"data-separator-last":o?"":void 0}})}function gg(e,t){return`hunk-separator-${e}-${t}`}function mg(e){const t=e.at(-1);return t==null?0:Math.max(ie(t.additionStart,t.additionCount),ie(t.deletionStart,t.deletionCount))}function qi(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function Ps({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function tn({item:e,arr:t,enableJoin:n,isNeutral:i=!1,isLastItem:r=!1}){const s=t[t.length-1];if(s==null||r||!n){t.push([i?0:1,e.value]);return}const o=s[0]===0;if(i===o||i&&e.value.length===1&&!o){s[1]+=e.value;return}t.push([i?0:1,e.value])}function Ht(e){return[Se(e.additionStart,e.additionCount)+1,ie(e.additionStart,e.additionCount)+1]}function Ne({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}){const s=Math.max(t,0);if(s===0||e)return{fromStart:0,fromEnd:0,rangeSize:s,collapsedLines:s,renderAll:!1};if(n===!0||s<=r)return{fromStart:s,fromEnd:0,rangeSize:s,collapsedLines:0,renderAll:!0};const o=n?.get(i),l=Math.min(Math.max(o?.fromStart??0,0),s),a=Math.min(Math.max(o?.fromEnd??0,0),s),d=l+a,c=d>=s;return{fromStart:c?s:l,fromEnd:c?0:a,rangeSize:s,collapsedLines:Math.max(s-d,0),renderAll:c}}function bg(e){const t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;const n=e.additionLines.length-ie(t.additionStart,t.additionCount),i=e.deletionLines.length-ie(t.deletionStart,t.deletionCount);return n<=0&&i<=0?!1:n!==i}function Pa({fileDiff:e,errorPrefix:t}){const n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;const i=e.additionLines.length-ie(n.additionStart,n.additionCount),r=e.deletionLines.length-ie(n.deletionStart,n.deletionCount);if(i<=0&&r<=0)return 0;if(i!==r)throw new Error(`${t}: trailing context mismatch (additions=${i}, deletions=${r}) for ${e.name}`);return Math.min(i,r)}function Me({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:i,errorPrefix:r}){if(t!==e.hunks.length-1)return;const s=Pa({fileDiff:e,errorPrefix:r});if(s<=0)return;if(n===!0||s<=i)return{fromStart:s,fromEnd:0,rangeSize:s,collapsedLines:0,renderAll:!0};const o=n?.get(e.hunks.length),l=Math.min(Math.max(o?.fromStart??0,0),s);return{fromStart:l,fromEnd:0,rangeSize:s,collapsedLines:s-l,renderAll:l>=s}}function Na({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:i}){if(n===!0||e.isPartial)return!0;for(const[l,a]of e.hunks.entries()){const[d,c]=Ht(a);if(t<d){const u=Ne({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:l,collapsedContextThreshold:i}),h=d-u.rangeSize;return u.renderAll||t<h+u.fromStart||t>=d-u.fromEnd}if(t<c)return!0}const r=Me({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:i,errorPrefix:"isAdditionLineRenderable"});if(r==null||r.renderAll)return!0;const s=e.hunks[e.hunks.length-1],[,o]=Ht(s);return t<o+r.fromStart||t>=o+r.rangeSize}function vg({fileDiff:e,lineNumber:t,direction:n,expandedHunks:i,collapsedContextThreshold:r}){if(i===!0||e.isPartial)return t;const s=[];let o=1;for(const[a,d]of e.hunks.entries()){const[c,u]=Ht(d),h=Ne({isPartial:e.isPartial,rangeSize:d.collapsedBefore,expandedHunks:i,hunkIndex:a,collapsedContextThreshold:r}),f=c-h.rangeSize;h.renderAll?s.push([f,c]):(h.fromStart>0&&s.push([f,f+h.fromStart]),h.fromEnd>0&&s.push([c-h.fromEnd,c])),s.push([c,u]),o=u}const l=Me({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:i,collapsedContextThreshold:r,errorPrefix:"getNearestRenderableAdditionLine"});if(l!=null){const a=o;o=a+l.rangeSize,l.renderAll?s.push([a,o]):l.fromStart>0&&s.push([a,a+l.fromStart])}if(t>=o)return t;if(n==="down"){for(const[a,d]of s)if(d>t)return Math.max(a,t);return}for(let a=s.length-1;a>=0;a--){const[d,c]=s[a];if(d<=t)return Math.min(c-1,t)}}function Ma({type:e,metrics:t}){return t.hunkSeparatorHeight??og(e)}function Ha({type:e,metrics:t}){return e==="simple"||e==="metadata"||e==="line-info-basic"?0:t.spacing}function yg({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case"simple":return t>0;case"metadata":return n!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function Cg(e){return e!=="simple"&&e!=="metadata"}function Lt({type:e,metrics:t,hunkIndex:n,hunkSpecs:i}){if(!yg({type:e,hunkIndex:n,hunkSpecs:i}))return;const r=Ma({type:e,metrics:t}),s=Ha({type:e,metrics:t}),o=n>0?s:0,l=s;return{height:r,gapBefore:o,gapAfter:l,totalHeight:o+r+l}}function Xe({type:e,metrics:t}){if(!Cg(e))return;const n=Ma({type:e,metrics:t}),i=Ha({type:e,metrics:t});return{height:n,gapBefore:i,gapAfter:0,totalHeight:i+n}}function et({diff:e,diffStyle:t,startingLine:n=0,totalLines:i=1/0,expandedHunks:r,collapsedContextThreshold:s=1,callback:o}){const l=Sg({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:s}),a={viewportStart:n,viewportEnd:n+i,isWindowedHighlight:n>0||i<1/0,splitCount:l.splitCount,unifiedCount:l.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!a.isWindowedHighlight)return!1;const d=a.unifiedCount>=n+i,c=a.splitCount>=n+i;return t==="unified"?d:(t==="split"||d)&&c},shouldSkip(d,c){if(!a.isWindowedHighlight)return!1;const u=d>0&&a.unifiedCount+d<=n,h=c>0&&a.splitCount+c<=n;return t==="unified"?u:(t==="split"||u)&&h},incrementCounts(d,c){(t==="unified"||t==="both")&&(a.unifiedCount+=d),(t==="split"||t==="both")&&(a.splitCount+=c)},isInWindow(d,c){if(!a.isWindowedHighlight)return!0;const u=a.isInUnifiedWindow(d),h=a.isInSplitWindow(c);return t==="unified"?u:t==="split"?h:u||h},isInUnifiedWindow(d){return!a.isWindowedHighlight||a.unifiedCount>=n-d&&a.unifiedCount<n+i},isInSplitWindow(d){return!a.isWindowedHighlight||a.splitCount>=n-d&&a.splitCount<n+i},emit(d,c=!1){return c||(t==="unified"?a.incrementCounts(1,0):t==="split"?a.incrementCounts(0,1):a.incrementCounts(1,1)),o(d)??!1}};e:for(let d=l.hunkIndex;d<e.hunks.length;d++){let b=function(L,A){return v==null||v.collapsedLines<=0||v.fromStart+v.fromEnd>0?0:t==="unified"?L===c.unifiedLineStart+c.unifiedLineCount-1?v.collapsedLines:0:A===c.splitLineStart+c.splitLineCount-1?v.collapsedLines:0},S=function(){return y?0:(y=!0,g.collapsedLines)};const c=e.hunks[d];if(c==null)throw new Error("iterateOverDiff: invalid hunk index");if(a.shouldBreak())break;const u=Se(c.deletionStart,c.deletionCount),h=Se(c.additionStart,c.additionCount),f=!e.isPartial&&c.deletionCount===0?u:c.deletionLineIndex,p=!e.isPartial&&c.additionCount===0?h:c.additionLineIndex,g=Ne({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:r,hunkIndex:d,collapsedContextThreshold:s}),v=d===a.finalHunkIndex?Me({fileDiff:e,hunkIndex:d,expandedHunks:r,collapsedContextThreshold:s,errorPrefix:"iterateOverDiff"}):void 0,m=g.fromStart+g.fromEnd;let y=g.collapsedLines===0;if(a.shouldSkip(m,m))a.incrementCounts(m,m),S();else{let L=c.unifiedLineStart-g.rangeSize,A=c.splitLineStart-g.rangeSize,N=f-g.rangeSize,M=p-g.rangeSize,R=u+1-g.rangeSize,P=h+1-g.rangeSize;if(nn(a,g.fromStart,t,$=>a.emit({hunkIndex:d,hunk:c,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:R+$,lineIndex:N+$,noEOFCR:!1,unifiedLineIndex:L+$,splitLineIndex:A+$},additionLine:{unifiedLineIndex:L+$,splitLineIndex:A+$,lineIndex:M+$,lineNumber:P+$,noEOFCR:!1}}))||(L=c.unifiedLineStart-g.fromEnd,A=c.splitLineStart-g.fromEnd,N=f-g.fromEnd,M=p-g.fromEnd,R=u+1-g.fromEnd,P=h+1-g.fromEnd,nn(a,g.fromEnd,t,$=>a.emit({hunkIndex:d,hunk:c,collapsedBefore:S(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:R+$,lineIndex:N+$,noEOFCR:!1,unifiedLineIndex:L+$,splitLineIndex:A+$},additionLine:{unifiedLineIndex:L+$,splitLineIndex:A+$,lineIndex:M+$,lineNumber:P+$,noEOFCR:!1}}),()=>{S()})))break e}let C=c.unifiedLineStart,w=c.splitLineStart,x=f,E=p,k=u+1,_=h+1;const F=c.hunkContent.at(-1);for(const L of c.hunkContent){if(a.shouldBreak())break e;const A=L===F;if(L.type==="context"){if(a.shouldSkip(L.lines,L.lines))a.incrementCounts(L.lines,L.lines),S();else if(nn(a,L.lines,t,N=>{const M=A&&N===L.lines-1,R=C+N,P=w+N;return a.emit({hunkIndex:d,hunk:c,collapsedBefore:S(),collapsedAfter:b(R,P),type:"context",deletionLine:{lineNumber:k+N,lineIndex:x+N,noEOFCR:M&&c.noEOFCRDeletions,unifiedLineIndex:R,splitLineIndex:P},additionLine:{unifiedLineIndex:R,splitLineIndex:P,lineIndex:E+N,lineNumber:_+N,noEOFCR:M&&c.noEOFCRAdditions}})},()=>{S()}))break e;C+=L.lines,w+=L.lines,x+=L.lines,E+=L.lines,k+=L.lines,_+=L.lines}else{const N=Math.max(L.deletions,L.additions),M=L.deletions+L.additions;if(!a.shouldSkip(M,N)){const R=kg(a,L,t);(R[0]?.[0]??0)>0&&S();for(const[P,$]of R)for(let ee=P;ee<$;ee++){const H=b(C+ee,t==="unified"?w+(ee<L.deletions?ee:ee-L.deletions):w+ee);if(a.emit(Lg({hunkIndex:d,hunk:c,collapsedBefore:S(),collapsedAfter:H,diffStyle:t,index:ee,unifiedLineIndex:C,splitLineIndex:w,additionLineIndex:E,deletionLineIndex:x,additionLineNumber:_,deletionLineNumber:k,content:L,isLastContent:A,unifiedCount:M,splitCount:N}),!0))break e}}S(),a.incrementCounts(M,N),C+=M,w+=N,x+=L.deletions,E+=L.additions,k+=L.deletions,_+=L.additions}}if(v!=null){const{collapsedLines:L,fromStart:A,fromEnd:N}=v,M=A+N;if(nn(a,M,t,R=>{const P=R===M-1;return a.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:P?L:0,type:"context-expanded",deletionLine:{lineNumber:k+R,lineIndex:x+R,noEOFCR:!1,unifiedLineIndex:C+R,splitLineIndex:w+R},additionLine:{unifiedLineIndex:C+R,splitLineIndex:w+R,lineIndex:E+R,lineNumber:_+R,noEOFCR:!1}})},void 0,()=>a.shouldBreak()))break e}}}function Sg({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:r}){if(n<=0||t==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const s=wg({diff:e,expandedHunks:i,collapsedContextThreshold:r});let o=0,l=e.hunks.length-1,a=e.hunks.length;for(;o<=l;){const c=o+l>>1,u=s[c+1];if(u==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(t==="unified"?u.unifiedCount:u.splitCount)>n?(a=c,l=c-1):o=c+1}if(a>=e.hunks.length){const c=s[e.hunks.length];if(c==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:e.hunks.length,splitCount:c.splitCount,unifiedCount:c.unifiedCount}}const d=s[a];if(d==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:a,splitCount:d.splitCount,unifiedCount:d.unifiedCount}}function wg({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let i=0,r=0;const s=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let l=0;l<e.hunks.length;l++){const a=e.hunks[l];if(a==null)throw new Error("iterateOverDiff: invalid hunk summary index");const d=Ne({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:l,collapsedContextThreshold:n}),c=d.fromStart+d.fromEnd;i+=c+a.splitLineCount,r+=c+a.unifiedLineCount;const u=l===s?Me({fileDiff:e,hunkIndex:l,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"iterateOverDiff"}):void 0;if(u!=null){const h=u.fromStart+u.fromEnd;i+=h,r+=h}o.push({splitCount:i,unifiedCount:r})}return o}function xg(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];const i=[];function r(l){const a=Math.max(0,e.viewportStart-l),d=Math.min(t,e.viewportEnd-l);d>a&&i.push([a,d])}if(n!=="split"&&r(e.unifiedCount),n!=="unified"&&r(e.splitCount),i.length===0)return[0,0];let s=i[0][0],o=i[0][1];for(let l=1;l<i.length;l++){const a=i[l];s=Math.min(s,a[0]),o=Math.max(o,a[1])}return[s,o]}function nn(e,t,n,i,r,s){const[o,l]=xg(e,t,n);o>0&&(e.incrementCounts(o,o),r?.());let a=o;for(;a<t;){if(s?.()===!0)return!0;if(a>=l){e.incrementCounts(t-a,t-a);break}if(e.isInWindow(0,0)){if(i(a)===!0)return!0}else e.incrementCounts(1,1);a++}return!1}function kg(e,t,n){if(!e.isWindowedHighlight)return[[0,n==="unified"?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];const i=n!=="split",r=n!=="unified",s=n==="unified"?"unified":"split",o=[];function l(u,h){if(u+h<=e.viewportStart||u>=e.viewportEnd)return;const f=Math.max(0,e.viewportStart-u),p=Math.min(h,e.viewportEnd-u);return p>f?[f,p]:void 0}function a(u,h){return s==="split"?u:h==="additions"?[u[0]+t.deletions,u[1]+t.deletions]:u}function d(u,h){if(u==null)return;const[f,p]=a(u,h);p>f&&o.push([f,p])}if(i&&(d(l(e.unifiedCount,t.deletions),"deletions"),d(l(e.unifiedCount+t.deletions,t.additions),"additions")),r&&(d(l(e.splitCount,t.deletions),"deletions"),d(l(e.splitCount,t.additions),"additions")),o.length===0)return o;o.sort((u,h)=>u[0]-h[0]);const c=[o[0]];for(const[u,h]of o.slice(1)){const f=c[c.length-1];u<=f[1]?f[1]=Math.max(f[1],h):c.push([u,h])}return c}function Lg({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,diffStyle:r,index:s,unifiedLineIndex:o,splitLineIndex:l,additionLineIndex:a,deletionLineIndex:d,additionLineNumber:c,deletionLineNumber:u,content:h,isLastContent:f,unifiedCount:p,splitCount:g}){const v=s<h.deletions?o+s:void 0,m=r==="unified"?s>=h.deletions?o+s:void 0:s<h.additions?o+h.deletions+s:void 0,b=r==="unified"?l+(s<h.deletions?s:s-h.deletions):l+s,y=s<h.deletions?d+s:void 0,S=s<h.deletions?u+s:void 0,C=r==="unified"?s>=h.deletions?a+(s-h.deletions):void 0:s<h.additions?a+s:void 0,w=r==="unified"?s>=h.deletions?c+(s-h.deletions):void 0:s<h.additions?c+s:void 0,x=r==="unified"?f&&s===h.deletions-1&&t.noEOFCRDeletions:f&&s===g-1&&t.noEOFCRDeletions,E=r==="unified"?f&&s===p-1&&t.noEOFCRAdditions:f&&s===g-1&&t.noEOFCRAdditions,k=y!=null&&S!=null&&v!=null?{lineNumber:S,lineIndex:y,noEOFCR:x,unifiedLineIndex:v,splitLineIndex:b}:void 0,_=C!=null&&w!=null&&m!=null?{unifiedLineIndex:m,splitLineIndex:b,lineIndex:C,lineNumber:w,noEOFCR:E}:void 0;if(k==null&&_!=null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,deletionLine:void 0,additionLine:_};if(k!=null&&_==null)return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,deletionLine:k,additionLine:void 0};if(k==null||_==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:i,deletionLine:k,additionLine:_}}const Eg={forcePlainText:!1};function Ag(e,t,n,{forcePlainText:i,startingLine:r,totalLines:s,expandedHunks:o,collapsedContextThreshold:l=1}=Eg){i?(r??=0,s??=1/0):(r=0,s=1/0);const a=r>0||s<1/0,d=typeof n.theme=="string"?t.getTheme(n.theme).type:void 0,c=Hp({theme:n.theme,highlighter:t}),u=i&&!a&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?"none":n.lineDiffType,h={deletionLines:[],additionLines:[]},{maxLineDiffLength:f}=n,p=!i&&!e.isPartial,g=i?o:void 0,v=new Map;function m(y){const S=p?0:y,C=v.get(S)??Rg();return v.set(S,C),C}function b(y,S,C,w){if(a){let x=C.at(-1);(x==null||x.targetIndex+x.count!==S)&&(x={targetIndex:S,originalOffset:w.length,count:0},C.push(x)),x.count++}w.push(y)}et({diff:e,diffStyle:"both",startingLine:r,totalLines:s,expandedHunks:a?g:!0,collapsedContextThreshold:l,callback:({hunkIndex:y,additionLine:S,deletionLine:C,type:w})=>{const x=m(y),E=S!=null?S.splitLineIndex:C.splitLineIndex;w==="change"&&S!=null&&C!=null&&_g({additionLine:e.additionLines[S.lineIndex],deletionLine:e.deletionLines[C.lineIndex],deletionLineIndex:x.deletionContent.length,additionLineIndex:x.additionContent.length,deletionDecorations:x.deletionDecorations,additionDecorations:x.additionDecorations,lineDiffType:u,maxLineDiffLength:f}),C!=null&&(b(e.deletionLines[C.lineIndex],C.lineIndex,x.deletionSegments,x.deletionContent),x.deletionInfo.push({type:w==="change"?"change-deletion":w,lineNumber:C.lineNumber,altLineNumber:w==="change"?void 0:S.lineNumber??void 0,lineIndex:`${C.unifiedLineIndex},${E}`})),S!=null&&(b(e.additionLines[S.lineIndex],S.lineIndex,x.additionSegments,x.additionContent),x.additionInfo.push({type:w==="change"?"change-addition":w,lineNumber:S.lineNumber,altLineNumber:w==="change"?void 0:C.lineNumber??void 0,lineIndex:`${S.unifiedLineIndex},${E}`}))}});for(const y of v.values()){if(y.deletionContent.length===0&&y.additionContent.length===0)continue;const S={name:e.prevName??e.name,contents:y.deletionContent.value},C={name:e.name,contents:y.additionContent.value},{deletionLines:w,additionLines:x}=Ig({deletionFile:S,deletionInfo:y.deletionInfo,deletionDecorations:y.deletionDecorations,additionFile:C,additionInfo:y.additionInfo,additionDecorations:y.additionDecorations,highlighter:t,options:n,languageOverride:i?"text":e.lang});if(p){h.deletionLines=w,h.additionLines=x;continue}if(y.deletionSegments.length>0)for(const E of y.deletionSegments)for(let k=0;k<E.count;k++)h.deletionLines[E.targetIndex+k]=w[E.originalOffset+k];else h.deletionLines.push(...w);if(y.additionSegments.length>0)for(const E of y.additionSegments)for(let k=0;k<E.count;k++)h.additionLines[E.targetIndex+k]=x[E.originalOffset+k];else h.additionLines.push(...x)}return{code:h,themeStyles:c,baseThemeType:d}}function _g({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:i,deletionDecorations:r,additionDecorations:s,lineDiffType:o,maxLineDiffLength:l}){if(e==null||t==null||o==="none"||(e=Pe(e),t=Pe(t),e.length>l||t.length>l))return;const a=o==="char"?Pl(e,t):Hl(e,t),d=[],c=[],u=o==="word-alt",h=a.at(-1);for(const p of a){const g=p===h;!p.added&&!p.removed?(tn({item:p,arr:d,enableJoin:u,isNeutral:!0,isLastItem:g}),tn({item:p,arr:c,enableJoin:u,isNeutral:!0,isLastItem:g})):p.removed?tn({item:p,arr:d,enableJoin:u,isLastItem:g}):tn({item:p,arr:c,enableJoin:u,isLastItem:g})}let f=0;for(const p of d)p[0]===1&&r.push(Ps({line:n,spanStart:f,spanLength:p[1].length})),f+=p[1].length;f=0;for(const p of c)p[0]===1&&s.push(Ps({line:i,spanStart:f,spanLength:p[1].length})),f+=p[1].length}function Rg(){return{deletionContent:{push(e){this.value+=e,this.length++},value:"",length:0},additionContent:{push(e){this.value+=e,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function Ig({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:i,highlighter:r,deletionDecorations:s,additionDecorations:o,languageOverride:l,options:{theme:a=le,...d}}){const c=l??Je(e.name),u=l??Je(t.name),{state:h,transformers:f}=Ap(d.useTokenTransformer),p=typeof a=="string"?{...d,lang:"text",theme:a,transformers:f,decorations:void 0,defaultColor:!1,cssVariablePrefix:fe("token"),tokenizeTimeLimit:0}:{...d,lang:"text",themes:a,transformers:f,decorations:void 0,defaultColor:!1,cssVariablePrefix:fe("token"),tokenizeTimeLimit:0};return{deletionLines:e.contents===""?[]:(p.lang=c,h.lineInfo=n,p.decorations=s,Es(r.codeToHast(Pe(e.contents),p))),additionLines:t.contents===""?[]:(p.lang=u,p.decorations=o,h.lineInfo=i,Es(r.codeToHast(Pe(t.contents),p)))}}function Re(e,t){const n=tt({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function Tg(e,t){const n=Math.max(e,1);let i=Array.from({length:n},(r,s)=>`${" ".repeat(s+1)}
1523
+ `).join("");return i===t&&(i=Array.from({length:n},(r,s)=>`\0${" ".repeat(s)}
1524
+ `).join("")),i}function Pg(e){for(const t of e)if(t.trim().length>0)return!1;return!0}function Ki(e,t){return t.length>0&&t.length<e.deletionLines.length&&Pg(t)}function _n(e,t,n){const i=e.deletionLines.join(""),r=Tg(t.length,i),s=tt({name:e.prevName??e.name,contents:i},{name:e.name,contents:r,lang:e.lang},n);return{hunks:s.hunks,splitLineCount:s.splitLineCount,unifiedLineCount:s.unifiedLineCount,additionLines:t,deletionLines:s.deletionLines,type:s.type}}function fn(e,t){return _n(e,[""],t)}function Da(e,t){if(e.additionLines.length===0)return fn(e,t);if(Ki(e,e.additionLines))return _n(e,e.additionLines,t);const n=e.additionLines,i=Re(e,t);return Fa(i,n),i}function Ng(e){return e.length>1&&e.at(-1)===""}function Fa(e,t){if(!Ng(t))return;const n=t.length-e.additionLines.length;if(n<=0)return;const i=e.additionLines.length,r=e.hunks.at(-1);if(r!=null&&ie(r.additionStart,r.additionCount)===i){for(const s of r.hunkContent)if(s.type==="change"&&s.additions<s.deletions&&s.additionLineIndex+s.additions===i){e.additionLines=t,s.additions+=n,r.additionCount+=n,r.additionLines+=n,pr(e);return}}}function Mg(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return Ae(e,Re(e,n));const i=Array.from(t);if(i.length===0)return Ae(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(const s of i){const o=e.additionLines[s],l=e.deletionLines[s];if(o==null||l==null||Pe(o)===Pe(l))return Ae(e,Re(e,n))}const r=Hg(e,i);if(r.size===0)return Ae(e,Re(e,n));for(const s of r)if(!Fg(e,s,n))return Ae(e,Re(e,n));return pr(e),bg(e)?Ae(e,Re(e,n)):Ae(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Ae(e,t){return Object.assign(e,t),t}function Hg(e,t){const n=new Set;for(const i of t){const r=Dg(e,i);if(r==null)return new Set;n.add(r)}return n}function Dg(e,t){for(const[n,i]of e.hunks.entries()){const r=i.additionLineIndex+i.additionCount;if(t>=i.additionLineIndex&&t<r)return n}}function Fg(e,t,n){const i=e.hunks[t];if(i==null)return!1;const r=e.deletionLines.slice(i.deletionLineIndex,i.deletionLineIndex+i.deletionCount),s=e.additionLines.slice(i.additionLineIndex,i.additionLineIndex+i.additionCount),o=tt({name:e.prevName??e.name,contents:r.join("")},{name:e.name,contents:s.join(""),lang:e.lang},{...n,context:0}),l=o.hunks[0];return l==null||o.hunks.length!==1?!1:($g(i,l),$a(e,t),!0)}function $a(e,t){const n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}const i=e.additionLines.at(-1),r=e.deletionLines.at(-1);n.noEOFCRAdditions=i!=null&&i!==""&&!i.endsWith(`
1525
+ `),n.noEOFCRDeletions=r!=null&&r!==""&&!r.endsWith(`
1526
+ `)}function $g(e,t){const n=e.additionLineIndex,i=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(r=>Oa(r,n,i)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart=e.additionStart+t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=i+t.deletionLineIndex,e.deletionStart=e.deletionStart+t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,fr(e)}function Oa(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function fr(e){let t=0,n=0;for(const i of e.hunkContent)i.type==="context"?(t+=i.lines,n+=i.lines):(t+=Math.max(i.additions,i.deletions),n+=i.additions+i.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function pr(e){let t=0,n=0,i=0;for(const r of e.hunks)r.collapsedBefore=Math.max(Se(r.additionStart,r.additionCount)-i,0),r.splitLineStart=t+r.collapsedBefore,r.unifiedLineStart=n+r.collapsedBefore,fr(r),t+=r.collapsedBefore+r.splitLineCount,n+=r.collapsedBefore+r.unifiedLineCount,i=ie(r.additionStart,r.additionCount);if(e.hunks.length>0){const r=e.hunks[e.hunks.length-1],s=Math.max(e.additionLines.length-ie(r.additionStart,r.additionCount),0);t+=s,n+=s}e.splitLineCount=t,e.unifiedLineCount=n}const Ns=new WeakMap;function Og(e){return e.length>1&&e[e.length-1]===""?e.slice(0,-1):e}function Ug(e,t){const n=Math.min(e.length,t.length);let i=0;for(;i<n&&e[i]===t[i];)i++;let r=e.length,s=t.length;for(;r>i&&s>i&&e[r-1]===t[s-1];)r--,s--;if(!(i===r&&i===s))return{start:i,deletionEnd:r,additionEnd:s}}function Xi(e,t){const n=e.hunks,i=e.additionLines,r=Og(i),s=r===i?e:{...e,additionLines:r},o=Xg(n,Kg(s,t),e.deletionLines.length),l=Zg(s,o);if(e.additionLines=r,e.hunks=l,e.editSessionDirty=!0,nm(e),Fa(e,i),!!em(n,e.hunks))return{regions:o.map(a=>a.previousSpan)}}function Bg(e,t,n,i){const r=Array.from(new Set(t)).filter(a=>a>=0&&a<e.additionLines.length).sort((a,d)=>a-d);if(r.length===0)return;const{hunks:s}=e;let o,l=0;for(const a of r){for(;l<s.length;){const u=s[l];if(a<Rn(u)+u.additionCount)break;l++}const d=s[l],c=d==null?void 0:Rn(d);if(c==null||a<c||o!=null&&o!==l)return Xi(e,n);o=l}if(o!=null){if(Gg(e,r,o,i,n)){e.editSessionDirty=!0;return}return Xi(e,n)}}function Gg(e,t,n,i,r){if(i==null||r?.ignoreWhitespace===!0||r?.stripTrailingCr===!0)return!1;const s=zg(e),o=e.hunks[n];if(o.hunkContent.some(jg))return!1;for(const l of t){const a=i.get(l),d=e.additionLines[l];if(a==null||d==null||s.has(a)||s.has(d))return!1;let c=!1;for(const u of o.hunkContent)if(u.type==="change"&&u.additions===u.deletions&&l>=u.additionLineIndex&&l<u.additionLineIndex+u.additions){c=!0;break}if(!c)return!1}return!0}function zg(e){const t=Ns.get(e);if(t?.lines===e.deletionLines)return t.set;const n=new Set(e.deletionLines);return Ns.set(e,{lines:e.deletionLines,set:n}),n}function jg(e){return e?.type==="change"&&(e.additions===0||e.deletions===0)}function Wg(e,t){const n=new Map,{regions:i}=t;for(let r=0;r<=i.length;r++){const s=i[r-1],o=i[r],l=r===0?e.get(0):s==null?void 0:e.get(s.lastIndex+1),a=o==null?void 0:e.get(o.firstIndex),d=l?.fromStart??0,c=a?.fromEnd??0;(d>0||c>0)&&n.set(r,{fromStart:d,fromEnd:c})}return n}function Vg(e,t,n){const i=[];if(e.isPartial)return i;for(const[s,o]of e.hunks.entries()){const l=Ne({isPartial:e.isPartial,rangeSize:o.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n});if(l.rangeSize<=n)continue;const a=it(o),d=a-l.rangeSize;l.fromStart>0&&i.push([d,d+l.fromStart]),l.fromEnd>0&&i.push([a-l.fromEnd,a])}const r=Me({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:"captureExpansionAnchors"});if(r!=null&&r.fromStart>0&&r.rangeSize>n){const s=e.hunks[e.hunks.length-1],o=it(s)+s.deletionCount;i.push([o,o+r.fromStart])}return i}function qg(e,t){const n=new Map;if(t.length===0)return n;const i=(s,o,l)=>{if(l<=o)return;let a=0,d=0;for(const[c,u]of t)u<=o||c>=l||(c<=o&&(a=Math.max(a,Math.min(u,l)-o)),u>=l&&(d=Math.max(d,l-Math.max(c,o))));(a>0||d>0)&&n.set(s,{fromStart:a,fromEnd:d})};for(const[s,o]of e.hunks.entries()){const l=it(o);i(s,l-Math.max(o.collapsedBefore,0),l)}const r=e.hunks[e.hunks.length-1];return r!=null&&!e.isPartial&&e.deletionLines.length>0&&i(e.hunks.length,it(r)+r.deletionCount,e.deletionLines.length),n}function Ms(e,t){return e.editSessionDirty!==!0?!1:(e.editSessionDirty=void 0,Object.assign(e,e.additionLines.length<=1&&e.additionLines.join("")===""?Re(e,t):Da(e,t)),!0)}function Kg(e,t){if(Ug(e.deletionLines,e.additionLines)==null)return[];const n=tt({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t),i=[];let r=0,s=0;for(const o of n.hunks){const l=o.additionCount>0?o.additionLineIndex-r:o.deletionLineIndex-s;r+=l,s+=l;for(const a of o.hunkContent){if(a.type==="context"){r+=a.lines,s+=a.lines;continue}const d=Oa(a,0,0);d.additions===0&&(d.additionLineIndex=r),d.deletions===0&&(d.deletionLineIndex=s),i.push(d),r+=d.additions,s+=d.deletions}}return i}function Xg(e,t,n){const i=e.map((o,l)=>{const a=it(o);return{deletionStart:a,deletionEnd:a+o.deletionCount,blocks:[],previousSpan:{firstIndex:l,lastIndex:l}}}),r=[];let s=0;for(const o of t){const l=o.deletionLineIndex,a=l+o.deletions;for(;s<i.length&&i[s].deletionEnd<l;)r.push(i[s]),s++;let d=r.length>0&&Yg(l,a,r[r.length-1])?r.pop():void 0;for(;s<i.length&&i[s].deletionStart<=a;)d=Qg(d,i[s]),s++;if(d==null){let c=l,u=a;if((o.deletions===0||o.additions===0)&&n>o.deletions){const h=r[r.length-1]?.deletionEnd??0,f=i[s]?.deletionStart??n;l>h?c--:a<f&&u++}d={deletionStart:c,deletionEnd:u,blocks:[],previousSpan:void 0}}d.deletionStart=Math.min(d.deletionStart,l),d.deletionEnd=Math.max(d.deletionEnd,a),d.blocks.push(o),r.push(d)}for(;s<i.length;)r.push(i[s]),s++;return r}function Yg(e,t,n){return e<=n.deletionEnd&&t>=n.deletionStart}function Qg(e,t){return e==null?t:(e.deletionStart=Math.min(e.deletionStart,t.deletionStart),e.deletionEnd=Math.max(e.deletionEnd,t.deletionEnd),e.blocks.push(...t.blocks),t.previousSpan!=null&&(e.previousSpan??={...t.previousSpan},e.previousSpan.firstIndex=Math.min(e.previousSpan.firstIndex,t.previousSpan.firstIndex),e.previousSpan.lastIndex=Math.max(e.previousSpan.lastIndex,t.previousSpan.lastIndex)),e)}function Zg(e,t){const n=[];let i=0,r=0;for(const s of t){const o=s.deletionStart-i;if(o<0)throw new Error("buildRegionHunks: overlapping old-side regions");i+=o,r+=o;const l=r,a=[];for(const c of s.blocks){const u=c.deletionLineIndex-i,h=c.additionLineIndex-r;if(u<0||u!==h)throw new Error("buildRegionHunks: canonical block context mismatch");Hs(a,u,r,i),i+=u,r+=h,a.push({...c}),i+=c.deletions,r+=c.additions}const d=s.deletionEnd-i;if(d<0)throw new Error("buildRegionHunks: block exceeds its old-side region");Hs(a,d,r,i),i+=d,r+=d,n.push(Jg(e,{additionStart:l,additionEnd:r,deletionStart:s.deletionStart,deletionEnd:s.deletionEnd},a))}if(e.deletionLines.length-i!==e.additionLines.length-r)throw new Error("buildRegionHunks: trailing context mismatch");return n}function Jg(e,t,n){const i=t.additionEnd-t.additionStart,r=t.deletionEnd-t.deletionStart;let s=0,o=0;for(const a of n)a.type==="change"&&(s+=a.additions,o+=a.deletions);const l={collapsedBefore:0,additionStart:rn(t.additionStart,i),additionCount:i,additionLines:s,additionLineIndex:Fs(t.additionStart,i),deletionStart:rn(t.deletionStart,r),deletionCount:r,deletionLines:o,deletionLineIndex:Fs(t.deletionStart,r),hunkContent:n,hunkSpecs:`@@ -${rn(t.deletionStart,r)},${r} +${rn(t.additionStart,i)},${i} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return fr(l),l}function Hs(e,t,n,i){t>0&&e.push({type:"context",lines:t,additionLineIndex:n,deletionLineIndex:i})}function em(e,t){if(e.length!==t.length)return!0;for(let n=0;n<e.length;n++){const i=e[n],r=t[n];if(it(i)!==it(r)||i.deletionCount!==r.deletionCount||Rn(i)!==Rn(r)||i.additionCount!==r.additionCount||i.splitLineCount!==r.splitLineCount||!tm(i,r))return!0}return!1}function tm(e,t){const n=Ds(e),i=Ds(t);for(;;){const r=n.next(),s=i.next();if(r.done===!0||s.done===!0)return r.done===s.done;if(r.value[0]!==s.value[0]||r.value[1]!==s.value[1])return!1}}function*Ds(e){for(const t of e.hunkContent){if(t.type==="context"){for(let i=0;i<t.lines;i++)yield[t.deletionLineIndex+i,t.additionLineIndex+i];continue}const n=Math.max(t.deletions,t.additions);for(let i=0;i<n;i++)yield[i<t.deletions?t.deletionLineIndex+i:void 0,i<t.additions?t.additionLineIndex+i:void 0]}}function Rn(e){return Se(e.additionStart,e.additionCount)}function it(e){return Se(e.deletionStart,e.deletionCount)}function rn(e,t){return t===0?e:e+1}function Fs(e,t){return t===0?e-1:e}function nm(e){pr(e);for(let t=0;t<e.hunks.length;t++)$a(e,t)}function pn(e){const t=e.lang??Je(e.name),n=e.lang??(e.prevName!=null?Je(e.prevName):"text");return t==="text"&&n==="text"}let im=-1;var rm=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++im}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang="text";renderCache;editSessionActive=!1;constructor(e={theme:le},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=li(e.theme??le)?up():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(){this.editSessionActive=!0;const e=this.diffCache;e!=null&&!e.isPartial&&e.additionLines.length===0&&(Object.assign(e,fn(e,this.options.parseDiffOptions)),this.markEditSessionPass(e),this.clearRenderCache())}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}refreshHighlightedResult(){const{renderCache:e}=this;if(e==null||pn(e.diff)||an(e.diff,this.getTokenizeMaxLength()))return Promise.resolve();const{diff:t}=e,{workerManager:n}=this;return!this.editSessionActive&&n?.isWorkingPool()===!0&&t.cacheKey!=null?(n.evictDiffFromCache(t.cacheKey),n.primeDiffHighlightCache(t).then(()=>{this.applyRefreshedResult(t,n.getDiffResultCache(t))}).catch(i=>this.onHighlightError(i))):this.asyncHighlight(t).then(i=>this.applyRefreshedResult(t,i)).catch(i=>this.onHighlightError(i))}applyRefreshedResult(e,t){if(t==null||this.renderCache==null||this.renderCache.diff!==e||this.editSessionActive)return;const{options:n}=this.getRenderOptions(e);at(n,t.options)&&(this.renderCache={diff:e,options:t.options,highlighted:!0,result:t.result,renderRange:void 0},this.onRenderUpdate?.())}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){const e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){const i={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t==="up"||t==="both")&&(i.fromStart+=n),(t==="down"||t==="both")&&(i.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,i)}getExpandedHunk(e){return this.expandedHunks.get(e)??sl}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(const t of e){const n=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),i=n[t.lineNumber]??[];n[t.lineNumber]=i,i.push(t)}}updateRenderCache(e,t,n=!1){if(this.renderCache==null)return!1;const{result:i,diff:r}=this.renderCache;if(i==null)return!1;if(r.isPartial)throw new Error("Could not update render cache for partial diff");const s=i.code.additionLines,o=[],l=new Map;for(const[d,c]of e){const u=s[d]?.properties??{},h=c.map(v=>v[2]).join(""),f=d<r.additionLines.length,p=f?r.additionLines[d]??"":"",g=Pe(p);f&&(r.additionLines[d]=$p(p,h),g!==h&&(o.push(d),l.set(d,p))),s[d]={type:"element",tagName:"div",properties:{"data-line":u["data-line"]??d+1,"data-line-index":u["data-line-index"]??d,"data-line-type":u["data-line-type"]??"context"},children:c.map(([v,m,b])=>v===0&&m===""?b===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:b}:{type:"element",tagName:"span",properties:{"data-char":v,style:`color:${m};`},children:[{type:"text",value:b}]})}}let a=!1;if(o.length>0)if(this.editSessionActive&&!r.isPartial){if(!n)if(r.additionLines.length<=1&&r.additionLines.join("")==="")Object.assign(r,fn(r,this.options.parseDiffOptions)),this.markEditSessionPass(r),a=!0;else if(Ki(r,r.additionLines))Object.assign(r,_n(r,r.additionLines,this.options.parseDiffOptions)),this.markEditSessionPass(r),a=!0;else{const d=Bg(r,o,this.options.parseDiffOptions,l);this.applyExpansionRemap(d),a=d!=null}}else Object.assign(r,Mg(r,o,this.options.parseDiffOptions));return i.baseThemeType=t,this.renderCache.isDirty=!0,a}applyExpansionRemap(e){e!=null&&(this.expandedHunks=Wg(this.expandedHunks,e))}applyDocumentChange(e){if(this.renderCache==null)return;const{diff:t,result:n}=this.renderCache;if(n==null)return;if(t.isPartial)throw new Error("Could not apply document change for partial diff");const{additionLines:i}=t;t.additionLines=lm(e,i),n.code.additionLines=am(i,t.additionLines,n.code.additionLines,e),t.additionLines.length<=1&&t.additionLines.join("")===""?(Object.assign(t,fn(t,this.options.parseDiffOptions)),n.code.additionLines[0]=Yi(0,e.getLineText(0)),this.markEditSessionPass(t)):this.editSessionActive?this.applySessionDocumentChange(t):Object.assign(t,Da(t,this.options.parseDiffOptions)),this.renderCache.isDirty=!0}applySessionDocumentChange(e){const{parseDiffOptions:t}=this.options,n=e.additionLines;if(Ki(e,n)){Object.assign(e,_n(e,n,t)),this.markEditSessionPass(e);return}this.applyExpansionRemap(Xi(e,t))}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0)}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){const n=t==="change"?e==="deletions"?"change-deletion":"change-addition":t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>fp(e);getOptionsWithDefaults(){const{diffIndicators:e="bars",diffStyle:t="split",disableBackground:n=!1,disableFileHeader:i=!1,disableLineNumbers:r=!1,disableVirtualizationBuffers:s=!1,collapsed:o=!1,expandUnchanged:l=!1,collapsedContextThreshold:a=1,expansionLineCount:d=100,hunkSeparators:c="line-info",lineDiffType:u="word-alt",maxLineDiffLength:h=1e3,overflow:f="scroll",stickyHeader:p=!1,theme:g=le,headerRenderMode:v="default",tokenizeMaxLineLength:m=1e3,tokenizeMaxLength:b=il,useTokenTransformer:y=!1,useCSSClasses:S=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:i,disableLineNumbers:r,disableVirtualizationBuffers:s,collapsed:o,expandUnchanged:l,collapsedContextThreshold:a,expansionLineCount:d,hunkSeparators:c,lineDiffType:u,maxLineDiffLength:h,overflow:f,stickyHeader:p,theme:this.workerManager?.getDiffRenderOptions().theme??g,headerRenderMode:v,tokenizeMaxLineLength:m,tokenizeMaxLength:b,useTokenTransformer:y,useCSSClasses:S}}async initializeHighlighter(){return this.highlighter=await cp(Sp(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;const{options:t}=this.getRenderOptions(e),n=an(e,this.getTokenizeMaxLength());let i=this.workerManager?.getDiffResultCache(e);i!=null&&!at(t,i.options)&&(i=void 0),this.renderCache??={diff:e,highlighted:!n&&!pn(e),options:t,result:n?void 0:i?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter==null&&(this.computedLang=e.lang??Je(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getDiffRenderOptions().theme??this.options.theme??le}getEffectiveCodeOptions(){const e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getDiffRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){const t=(()=>{if(this.workerManager?.isWorkingPool()===!0){const l=this.workerManager.getDiffRenderOptions();return this.editSessionActive&&l.useTokenTransformer!==!0?{...l,useTokenTransformer:!0}:l}const{theme:i,tokenizeMaxLineLength:r,lineDiffType:s,maxLineDiffLength:o}=this.getOptionsWithDefaults();return{theme:i,useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:r,lineDiffType:s,maxLineDiffLength:o}})();this.getOptionsWithDefaults();const{renderCache:n}=this;return n?.result==null?{options:t,forceHighlight:!0}:!pt(e,n.diff)||!at(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=br){if(e==null)return;const{expandUnchanged:n,collapsedContextThreshold:i}=this.getOptionsWithDefaults();let{options:r,forceHighlight:s}=this.getRenderOptions(e);const o=this.getMatchingWorkerResultCache(e,r);o!=null&&!this.hasHighlightedRenderCache(e,r)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},s=!1),this.renderCache??={diff:e,highlighted:!1,options:r,result:void 0,renderRange:void 0};const l=e.additionLines.length>0||e.deletionLines.length>0,a=!l||pn(e)||an(e,this.getTokenizeMaxLength()),d=!pt(e,this.renderCache.diff),c=!La(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0){const u=this.renderCache.result==null&&this.renderCache.highlighted&&!a&&!d&&qi(t);u&&(this.renderCache.highlightPending=!0),!u&&(a||this.renderCache.result==null||!this.renderCache.highlighted&&(d||c))&&(this.renderCache.diff=e,this.renderCache.options=r,this.renderCache.highlighted=!1,(this.renderCache.result==null||d||c||s)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,qi(t)||n?!0:this.expandedHunks,i)),this.renderCache.renderRange=t),!a&&l&&(!this.renderCache.highlighted||s)&&this.workerManager.highlightDiffAST(this,e)}else{this.computedLang=e.lang??Je(e.name);const u=this.highlighter!=null&&li(r.theme),h=this.highlighter!=null&&$r(this.computedLang),f=!a&&h;if(this.highlighter!=null&&u&&(s||a||!this.renderCache.highlighted&&f||this.renderCache.result==null)){const{result:p,options:g}=this.renderDiffWithHighlighter(e,this.highlighter,a||!h);this.renderCache={diff:e,options:g,highlighted:f,result:p,renderRange:void 0}}(!u||!a&&!h)&&this.asyncHighlight(e).then(({result:p,options:g})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,p,g,!a)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=br){const{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){const{diffIndicators:i,disableBackground:r,disableLineNumbers:s,overflow:o}=this.getOptionsWithDefaults();return vp({type:"diff",diffIndicators:i,disableBackground:r,disableLineNumbers:s,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){const t=an(e,this.getTokenizeMaxLength());this.computedLang=t?"text":e.lang??Je(e.name);const n=this.highlighter!=null&&li(this.getLocalHighlightTheme()),i=t||this.highlighter!=null&&$r(this.computedLang);return(this.highlighter==null||!n||!i)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){const{options:i}=this.getRenderOptions(e),{collapsedContextThreshold:r}=this.getOptionsWithDefaults(),s=Ag(e,t,i,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:r});if(this.editSessionActive&&e.additionLines.length===1&&e.additionLines[0]===""&&s.code.additionLines[0]==null){let o;if(et({diff:e,diffStyle:"both",expandedHunks:n?!0:void 0,collapsedContextThreshold:r,callback:({additionLine:l})=>{if(l?.lineIndex===0)return o=l,!0}}),o==null)throw new Error("DiffHunksRenderer: missing empty addition line");s.code.additionLines[0]=Yi(0,"",o.unifiedLineIndex,o.splitLineIndex)}return{result:s,options:i}}onHighlightSuccess(e,t,n,i=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,i)}applyHighlightResult(e,t,n,i=!0){if(this.renderCache==null)return;const r=this.renderCache.highlightPending===!0||!this.renderCache.highlighted||!at(this.renderCache.options,n)||!pt(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:i,result:t,renderRange:void 0},r&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;const n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!at(t,n.options)))return n}hasHighlightedRenderCache(e,t){const{renderCache:n}=this;return n?.result!=null&&n.highlighted&&pt(e,n.diff)&&at(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:i,baseThemeType:r}){const{diffStyle:s,disableFileHeader:o,expandUnchanged:l,expansionLineCount:a,collapsedContextThreshold:d,hunkSeparators:c}=this.getOptionsWithDefaults(),u=this.renderCache?.isDirty??!1;this.diff=e;const h=s==="unified",f=um(e,this.options.loadDiffFiles!=null),p=!e.isPartial||f;let g=[],v=[],m=[];const b=[],{additionLines:y,deletionLines:S}=n,C={rowCount:0,hunkSeparators:c,additionsContentAST:g,deletionsContentAST:v,unifiedContentAST:m,unifiedGutterAST:Bt(),deletionsGutterAST:Bt(),additionsGutterAST:Bt(),expansionLineCount:a,hunkData:b,incrementRowCount(R=1){C.rowCount+=R},pushToGutter(R,P){switch(R){case"unified":C.unifiedGutterAST.children.push(P);break;case"deletions":C.deletionsGutterAST.children.push(P);break;case"additions":C.additionsGutterAST.children.push(P);break}}},w=Pa({fileDiff:e,errorPrefix:"DiffHunksRenderer.processDiffResult"}),x={size:0,side:void 0,increment(){this.size+=1},flush(){if(s!=="unified"){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side==="additions"?(C.pushToGutter("additions",he(void 0,"buffer",this.size)),g?.push(Jt(this.size))):(C.pushToGutter("deletions",he(void 0,"buffer",this.size)),v?.push(Jt(this.size))),this.size=0,this.side=void 0}}},E=(R,P,$,ee,H)=>{C.pushToGutter(R,jl(P,$,ee,H))};function k(R){x.flush(),s==="unified"?bi("unified",R,C):(bi("deletions",R,C),bi("additions",R,C))}this.pushFileLevelAnnotations(e,s,t,C),et({diff:e,diffStyle:s,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:l?!0:this.expandedHunks,collapsedContextThreshold:d,callback:({hunkIndex:R,hunk:P,collapsedBefore:$,collapsedAfter:ee,additionLine:H,deletionLine:U,type:G})=>{const re=U!=null?U.splitLineIndex:H.splitLineIndex,He=H!=null?H.unifiedLineIndex:U.unifiedLineIndex;s==="split"&&G!=="change"&&x.flush(),$>0&&k({hunkIndex:R,collapsedLines:$,rangeSize:Math.max(P?.collapsedBefore??0,0),hunkSpecs:P?.hunkSpecs,isFirstHunk:R===0,isLastHunk:!1,isExpandable:p});const rt=s==="unified"?He:re,$t={type:G,hunkIndex:R,lineIndex:rt,unifiedLineIndex:He,splitLineIndex:re,deletionLine:U,additionLine:H};if(s==="unified"){const B=this.getUnifiedInjectedRowsForLine?.($t);B?.before!=null&&Os(B.before,C);let te=U!=null?S[U.lineIndex]:void 0,se=H!=null?y[H.lineIndex]:void 0;if(te==null&&se==null){const ue="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(ue,{file:e.name}),new Error(ue)}const We=G==="change"?H!=null?"change-addition":"change-deletion":G,ce=this.getUnifiedLineDecoration({type:G,lineType:We,additionLineIndex:H?.lineIndex,deletionLineIndex:U?.lineIndex});E("unified",ce.gutterLineType,H!=null?H.lineNumber:U.lineNumber,`${He},${re}`,ce.gutterProperties),se!=null?se=on(se,ce.contentProperties,u&&H!=null?{"data-line":H.lineNumber,"data-line-index":`${He},${re}`}:void 0):te!=null&&(te=on(te,ce.contentProperties,u&&U!=null?{"data-line":U.lineNumber,"data-line-index":`${He},${re}`}:void 0)),sn({diffStyle:"unified",type:G,deletionLine:te,additionLine:se,unifiedSpan:this.getAnnotations("unified",U?.lineNumber,H?.lineNumber,R,rt),createAnnotationElement:ue=>this.createAnnotationElement(ue),context:C}),B?.after!=null&&Os(B.after,C)}else{const B=this.getSplitInjectedRowsForLine?.($t);B?.before!=null&&Us(B.before,C,x);let te=U!=null?S[U.lineIndex]:void 0,se=H!=null?y[H.lineIndex]:void 0;const We=this.getSplitLineDecoration({side:"deletions",type:G,lineIndex:U?.lineIndex}),ce=this.getSplitLineDecoration({side:"additions",type:G,lineIndex:H?.lineIndex});if(te==null&&se==null){const ne="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(ne,{file:e.name}),new Error(ne)}const ue=(()=>{if(G==="change"){if(se==null)return"additions";if(te==null)return"deletions"}})();ue!=null?(x.side!=null&&x.side!==ue&&x.flush(),x.side=ue,x.increment()):G==="change"&&x.flush();const De=this.getAnnotations("split",U?.lineNumber,H?.lineNumber,R,rt);if(De!=null&&x.size>0&&x.flush(),U!=null){const ne=on(te,We.contentProperties,u?{"data-line":U.lineNumber,"data-line-index":`${U.unifiedLineIndex},${re}`}:void 0);E("deletions",We.gutterLineType,U.lineNumber,`${U.unifiedLineIndex},${re}`,We.gutterProperties),ne!=null&&(te=ne)}if(H!=null){const ne=on(se,ce.contentProperties,u?{"data-line":H.lineNumber,"data-line-index":`${H.unifiedLineIndex},${re}`}:void 0);E("additions",ce.gutterLineType,H.lineNumber,`${H.unifiedLineIndex},${re}`,ce.gutterProperties),ne!=null&&(se=ne)}sn({diffStyle:"split",type:G,additionLine:se,deletionLine:te,...De,createAnnotationElement:ne=>this.createAnnotationElement(ne),context:C}),B?.after!=null&&Us(B.after,C,x)}const St=s==="split"&&P!=null&&re===P.splitLineStart+P.splitLineCount-1,we=R===e.hunks.length-1&&P!=null&&(s==="split"?re===P.splitLineStart+P.splitLineCount-1:He===P.unifiedLineStart+P.unifiedLineCount-1),Gn=St?P.noEOFCRDeletions:!1,zn=St?P.noEOFCRAdditions:!1,je=(U?.noEOFCR??!1)||Gn,xe=(H?.noEOFCR??!1)||zn;if(xe||je){if(s==="split"&&x.flush(),je){const B=G==="context"||G==="context-expanded"?G:"change-deletion";s==="unified"?(C.unifiedContentAST.push(en(B)),C.pushToGutter("unified",he(B,"metadata",1))):(C.deletionsContentAST.push(en(B)),C.pushToGutter("deletions",he(B,"metadata",1)),xe||(C.pushToGutter("additions",he(void 0,"buffer",1)),C.additionsContentAST.push(Jt(1))))}if(xe){const B=G==="context"||G==="context-expanded"?G:"change-addition";s==="unified"?(C.unifiedContentAST.push(en(B)),C.pushToGutter("unified",he(B,"metadata",1))):(C.additionsContentAST.push(en(B)),C.pushToGutter("additions",he(B,"metadata",1)),je||(C.pushToGutter("deletions",he(void 0,"buffer",1)),C.deletionsContentAST.push(Jt(1))))}C.incrementRowCount(1)}c!=="simple"&&c!=="metadata"&&(ee>0||we&&f)&&k({hunkIndex:G==="context-expanded"?R:R+1,collapsedLines:we&&f?"unknown":ee,rangeSize:w,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:p}),C.incrementRowCount(1)}}),s==="split"&&x.flush();const _=Math.max(mg(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),F=t.bufferBefore>0||t.bufferAfter>0,L=!h&&e.type!=="deleted",A=!h&&e.type!=="new",N=C.rowCount>0||F;g=L&&N?g:void 0,v=A&&N?v:void 0,m=h&&N?m:void 0;const M=this.createPreElement(v!=null&&g!=null,_);return{unifiedGutterAST:h&&N?C.unifiedGutterAST.children:void 0,unifiedContentAST:m,deletionsGutterAST:A&&N?C.deletionsGutterAST.children:void 0,deletionsContentAST:v,additionsGutterAST:L&&N?C.additionsGutterAST.children:void 0,additionsContentAST:g,hunkData:b,preNode:M,themeStyles:i,baseThemeType:r,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:_,rowCount:C.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){const n=e==="unified"?t.unifiedGutterAST:e==="deletions"?t.deletionsGutterAST:t.additionsGutterAST,i=e==="unified"?t.unifiedContentAST:e==="deletions"?t.deletionsContentAST:t.additionsContentAST;if(n==null||i==null)return;const r=Bt(n);return r.properties.style=`grid-row: span ${t.rowCount}`,[r,Op(i,t.rowCount)]}renderFullAST(e,t=[]){const n=this.getOptionsWithDefaults().hunkSeparators==="line-info",i=this.renderCodeAST("unified",e);if(i!=null)return t.push(T({tagName:"code",children:i,properties:{"data-code":"","data-container-size":n?"":void 0,"data-unified":""}})),{...e.preNode,children:t};const r=this.renderCodeAST("deletions",e);r!=null&&t.push(T({tagName:"code",children:r,properties:{"data-code":"","data-container-size":n?"":void 0,"data-deletions":""}}));const s=this.renderCodeAST("additions",e);return s!=null&&t.push(T({tagName:"code",children:s,properties:{"data-code":"","data-container-size":n?"":void 0,"data-additions":""}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return Ie(this.renderFullAST(e,t))}renderPartialHTML(e,t){return t==null?Ie(e):Ie(T({tagName:"code",children:e,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${t}`]:""}}))}pushFileLevelAnnotations(e,t,n,i){if(!Aa(n))return;const r=e.type!=="new"?$s(As(this.deletionAnnotations)):[],s=e.type!=="deleted"?$s(As(this.additionAnnotations)):[];if(r.length===0&&s.length===0)return;const o=-1,l=-1,{createAnnotationElement:a}=this;if(t==="unified"){sn({diffStyle:t,type:"context",unifiedSpan:{type:"annotation",hunkIndex:o,lineIndex:l,annotations:r.concat(s)},createAnnotationElement:a,context:i});return}sn({diffStyle:t,type:"context",deletionSpan:{type:"annotation",hunkIndex:o,lineIndex:l,annotations:r},additionSpan:{type:"annotation",hunkIndex:o,lineIndex:l,annotations:s},createAnnotationElement:a,context:i})}getAnnotations(e,t,n,i,r){const s={type:"annotation",hunkIndex:i,lineIndex:r,annotations:[]};if(t!=null)for(const l of this.deletionAnnotations[t]??[])s.annotations.push(vt(l));const o={type:"annotation",hunkIndex:i,lineIndex:r,annotations:[]};if(n!=null)for(const l of this.additionAnnotations[n]??[])(e==="unified"?s:o).annotations.push(vt(l));if(e==="unified")return s.annotations.length>0?s:void 0;if(!(o.annotations.length===0&&s.annotations.length===0))return{deletionSpan:s,additionSpan:o}}renderHeader(e){const{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return gp({fileOrDiff:e,mode:t,stickyHeader:n})}};function $s(e){return e?.map(t=>vt(t))??[]}const sm=new Intl.PluralRules("en-US");function om(e){return`${e} unmodified line${sm.select(e)==="one"?"":"s"}`}function Os(e,t){for(const n of e)t.unifiedContentAST.push(n.content),t.pushToGutter("unified",n.gutter),t.incrementRowCount(1)}function Us(e,t,n){for(const{deletion:i,addition:r}of e){if(i==null&&r==null)continue;const s=i!=null&&r!=null?void 0:i==null?"deletions":"additions";(s==null||n.side!==s)&&n.flush(),i!=null&&(t.deletionsContentAST.push(i.content),t.pushToGutter("deletions",i.gutter)),r!=null&&(t.additionsContentAST.push(r.content),t.pushToGutter("additions",r.gutter)),s!=null&&(n.side=s,n.increment()),t.incrementRowCount(1)}}function sn({diffStyle:e,type:t,deletionLine:n,additionLine:i,unifiedSpan:r,deletionSpan:s,additionSpan:o,createAnnotationElement:l,context:a}){let d=!1;if(e==="unified"){if(i!=null?a.unifiedContentAST.push(i):n!=null&&a.unifiedContentAST.push(n),r!=null){const c=t==="change"?n!=null?"change-deletion":"change-addition":t;a.unifiedContentAST.push(l(r)),a.pushToGutter("unified",he(c,"annotation",1)),d=!0}}else if(e==="split"){if(n!=null&&a.deletionsContentAST.push(n),i!=null&&a.additionsContentAST.push(i),s!=null){const c=t==="change"?n!=null?"change-deletion":"context":t;a.deletionsContentAST.push(l(s)),a.pushToGutter("deletions",he(c,"annotation",1)),d=!0}if(o!=null){const c=t==="change"?i!=null?"change-addition":"context":t;a.additionsContentAST.push(l(o)),a.pushToGutter("additions",he(c,"annotation",1)),d=!0}}d&&a.incrementRowCount(1)}function bi(e,{hunkIndex:t,collapsedLines:n,rangeSize:i,hunkSpecs:r,isFirstHunk:s,isLastHunk:o,isExpandable:l},a){if(typeof n=="number"&&n<=0)return;const d=e==="unified"?a.unifiedContentAST:e==="deletions"?a.deletionsContentAST:a.additionsContentAST;if(a.hunkSeparators==="metadata"){r!=null&&(a.pushToGutter(e,lt({type:"metadata",content:r,isFirstHunk:s,isLastHunk:o})),d.push(lt({type:"metadata",content:r,isFirstHunk:s,isLastHunk:o})),e!=="additions"&&a.incrementRowCount(1));return}if(a.hunkSeparators==="simple"){t>0&&(a.pushToGutter(e,lt({type:"simple",isFirstHunk:s,isLastHunk:!1})),d.push(lt({type:"simple",isFirstHunk:s,isLastHunk:!1})),e!=="additions"&&a.incrementRowCount(1));return}const c=gg(e,t),u=i>a.expansionLineCount,h=l?t:void 0,f=typeof n=="number"?om(n):"More unchanged context may be available";a.pushToGutter(e,lt({type:a.hunkSeparators,content:f,expandIndex:h,chunked:u,slotName:c,isFirstHunk:s,isLastHunk:o})),d.push(lt({type:a.hunkSeparators,content:f,expandIndex:h,chunked:u,slotName:c,isFirstHunk:s,isLastHunk:o})),e!=="additions"&&a.incrementRowCount(1),a.hunkData.push({slotName:c,hunkIndex:t,lines:typeof n=="number"?n:0,lineCountKnown:typeof n=="number",type:e,expandable:l?{up:!s,down:!o,chunked:u}:void 0})}function on(e,t,n){return e==null||e.type!=="element"||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function Bs(e){return e.length>0&&e[e.length-1]===""?e.length-1:e.length}function am(e,t,n,i){const r=Bs(e),s=Bs(t),o=Math.min(r,s);let l=0;for(;l<o&&e[l]===t[l];)l++;let a=0;for(;a<o-l&&e[r-1-a]===t[s-1-a];)a++;const d=new Array(t.length);for(let c=0;c<l;c++)d[c]=n[c];for(let c=0;c<a;c++)d[s-1-c]=n[r-1-c];r<e.length&&s<t.length&&(d[t.length-1]=n[e.length-1]);for(let c=e.length;c<t.length;c++)d[c]??=n[c];for(let c=l;c<t.length;c++)d[c]??=Yi(c,i.getLineText(c));return d}function Yi(e,t,n=e,i=e){return{type:"element",tagName:"div",properties:{"data-line":e+1,"data-line-index":`${n},${i}`,"data-line-type":"context"},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:t}]}]}}function lm(e,t){const n=[],i=cm(t);for(let r=0;r<e.lineCount;r++){const s=e.getLineText(r,!0);n.push(r<e.lineCount-1&&!dm(s)?s+i:s)}return n}function dm(e){return e.endsWith(`
1527
+ `)||e.endsWith("\r")}function cm(e){for(const t of e){if(t.endsWith(`\r
1528
+ `))return`\r
1529
+ `;if(t.endsWith(`
1530
+ `))return`
1531
+ `;if(t.endsWith("\r"))return"\r"}return`
1532
+ `}function an(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function um(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function hm(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function fm(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}async function Qi(e,t=300){let n;try{await Promise.race([e(),new Promise(i=>{n=setTimeout(i,t)})])}finally{n!=null&&clearTimeout(n)}}function Zi({oldFile:e,newFile:t},n){if(!(e===void 0&&t===void 0)){if(e===void 0||t===void 0)throw new Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw new Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return t===null?{oldFile:e,newFile:t}:{oldFile:e,newFile:t}}}function pm(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:eg(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}function gm(e){return e.isPartial&&(e.type==="change"||e.type==="rename-changed"||e.type==="rename-pure")}let mm=-1;var Ua=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++mm}`;type="file-diff";fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;pendingFiles;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;lineStateRefreshPending=!1;deferredSelectedLines;deferredEditorActiveLine;constructor(e={theme:le},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new rc,this.scrollSyncManager=new pg,this.interactionManager=new Xd("diff",Pr(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return pm(e)}createHunksRenderer(e){return new rm(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t="additions")=>{const n=this.fileDiffCache;if(n==null)return;const i=n.hunks.at(-1);let r,s;e:for(const o of n.hunks){const l=t==="deletions"?o.deletionStart:o.additionStart,a=t==="deletions"?o.deletionCount:o.additionCount;let d=Se(l,a)+1,c=o.splitLineStart,u=o.unifiedLineStart;if(e<d){const h=d-e;r=Math.max(u-h,0),s=Math.max(c-h,0);break e}if(e>=d+a){if(o===i){const h=e-(d+a);r=u+o.unifiedLineCount+h,s=c+o.splitLineCount+h;break e}continue}for(const h of o.hunkContent)if(h.type==="context")if(e<d+h.lines){const f=e-d;s=c+f,r=u+f;break e}else d+=h.lines,c+=h.lines,u+=h.lines;else{const f=t==="deletions"?h.deletions:h.additions;if(e<d+f){const p=e-d;r=u+(t==="additions"?h.deletions:0)+p,s=c+p;break e}else d+=f,c+=Math.max(h.deletions,h.additions),u+=h.deletions+h.additions}break e}if(!(r==null||s==null))return[r,s]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Pr(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!nr(this.appliedThemeCSS.theme,this.options.theme??le)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators=="function")}setSelectedLines(e,t){this.lineStateRefreshPending?this.deferredSelectedLines=[e,t]:this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.lineStateRefreshPending?this.deferredEditorActiveLine=[e,t]:this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??"additions"})}flushDeferredLineState(){const{deferredEditorActiveLine:e,deferredSelectedLines:t}=this;this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,e!=null&&this.setEditorActiveLine(...e),t!=null&&this.interactionManager.setSelection(...t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{diffStyle:e="split",overflow:t="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t==="wrap",columnVariables:this.shouldApplyColumnVariables(t)?"apply":"measure"}),t==="scroll"&&e==="split"?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators=="function"?!0:e==="scroll"&&(this.lineAnnotations.length>0||this.pre?.hasAttribute("data-has-merge-conflict")===!0)}getCodeScrollLeft(){return Math.max(this.codeUnified?.scrollLeft??0,this.codeDeletions?.scrollLeft??0,this.codeAdditions?.scrollLeft??0)}setCodeScrollLeft(e){this.codeUnified!=null&&(this.codeUnified.scrollLeft=e),this.codeAdditions!=null&&(this.codeAdditions.scrollLeft=e),this.codeDeletions!=null&&(this.codeDeletions.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.hunksRenderer.getEffectiveCodeOptions()}}cleanUp(e=!1){Ci(this.handleEditSessionRender),this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.pendingFiles=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!1,this.deferredEditorActiveLine=void 0,this.deferredSelectedLines=void 0,this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:i,fileDiff:r,...s}){if(!this.enabled)throw new Error("FileDiff.hydrate: attempting to call hydrate after cleaned up");if(this.fileContainer!=null)throw new Error("FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated");const o=Zi(s,"FileDiff.hydrate"),l=o?.oldFile,a=o?.newFile;this.hydrateElements(e,t),ym(this.pre,bm({fileDiff:r,oldFile:l,newFile:a}),this.options.collapsed)||Cm(this.headerElement,vm({fileDiff:r,oldFile:l,newFile:a}),this.options.disableFileHeader)?this.render({...s,fileContainer:e,lineAnnotations:i,fileDiff:r,preventEmit:!0}):this.hydrationSetup({fileDiff:r,lineAnnotations:i,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Zp(e,t);for(const n of e.shadowRoot?.children??[]){if(n instanceof SVGElement){this.spriteSVG=n;continue}if(n instanceof HTMLElement){if(n instanceof HTMLPreElement){this.pre=n;for(const i of n.children)!(i instanceof HTMLElement)||i.tagName.toLowerCase()!=="code"||("deletions"in i.dataset&&(this.codeDeletions=i),"additions"in i.dataset&&(this.codeAdditions=i),"unified"in i.dataset&&(this.codeUnified=i));continue}if("diffsHeader"in n.dataset){this.headerElement=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-theme-css")){this.themeCSSStyle=n;continue}if(n instanceof HTMLStyleElement&&n.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=n,this.appliedUnsafeCSS=n.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:i}){this.lineAnnotations=i??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?tt(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){const{fileDiff:e,options:{loadDiffFiles:t}}=this;e==null||t==null||!gm(e)||this.pendingFiles?.fileDiff===e||(this.pendingFiles={fileDiff:e,promise:this.loadFilesForDiff(e,t)})}async loadFilesForDiff(e,t){try{const n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(n){if(this.options.disableErrorHandling===!0)throw n;console.error(n)}finally{this.pendingFiles?.fileDiff===e&&(this.pendingFiles=void 0)}}async handleFilesLoaded(e,t){this.fileDiff!==e||!e.isPartial||(Vi("merge",e,t),this.setHydratedState(t),await Qi(()=>this.primeHighlightCache(e)),!(!this.enabled||this.fileDiff!==e)&&this.rerender())}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:i=!1,lineAnnotations:r,fileContainer:s,containerWrapper:o,renderRange:l,...a}){const d=Zi(a,"FileDiff.render"),c=d?.oldFile,u=d?.newFile;if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");e!=null&&e.cacheKey===void 0&&(e.cacheKey=e.prevName!=null?e.prevName+":"+e.name:e.name),this.editor?.__postponeBgTokenizeToNextFrame();const{collapsed:h=!1,themeType:f="system",expandUnchanged:p=!1}=this.options,g=h?void 0:l,v=this.hasThemeChanged(),m=d!=null,b=m&&(!Gs(c,this.deletionFile)||!Gs(u,this.additionFile));let y=e!=null&&e!==this.fileDiff;const S=r!=null&&(r.length>0||this.lineAnnotations.length>0)?r!==this.lineAnnotations:!1;if(!h&&La(g,this.renderRange)&&!n&&!S&&!v&&(e!=null&&e===this.fileDiff||e==null&&!b))return this.applyCachedThemeState(f);let C;e==null&&m&&(b||this.fileDiff==null)&&(C=tt(d.oldFile,d.newFile,this.options.parseDiffOptions));const{renderRange:w}=this;if(this.renderRange=g,m?(this.deletionFile=c,this.additionFile=u):e!=null&&(this.deletionFile=void 0,this.additionFile=void 0),e!=null?this.fileDiff=e:C!=null&&(y=!0,this.fileDiff=C),y&&(this.cachedHeaderHTML=void 0),r!=null&&this.setLineAnnotations(r),this.fileDiff==null)return!1;this.fileDiff.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&(Ms(this.fileDiff,this.options.parseDiffOptions),this.hunksRenderer.refreshHighlightedResult()),p&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:x=!1,disableFileHeader:E=!1}=this.options;if(E&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),s=this.getOrCreateFileContainer(s,o),this.applyCachedThemeState(f),h){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const k=this.hunksRenderer.renderDiff(this.fileDiff,ol);k!=null&&this.applyThemeState(s,k.themeStyles,f,k.baseThemeType),k?.headerElement!=null&&this.applyHeaderToDOM(k.headerElement,s),this.renderSeparators([]),this.injectUnsafeCSS()}catch(k){if(x)throw k;console.error(k),k instanceof Error&&this.applyErrorToDOM(k,s)}return i||this.emitPostRender(),!0}try{const k=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(n,S,b||y||v)&&this.applyPartialRender({previousRenderRange:w,renderRange:g}))){const _=this.hunksRenderer.renderDiff(this.fileDiff,g);if(_==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(s,_.themeStyles,f,_.baseThemeType),_.headerElement!=null&&this.applyHeaderToDOM(_.headerElement,s),_.additionsContentAST!=null||_.deletionsContentAST!=null||_.unifiedContentAST!=null?this.applyHunksToDOM(k,_):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(_.hunkData)}this.applyBuffers(k,g),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(k){if(x)throw k;console.error(k),k instanceof Error&&this.applyErrorToDOM(k,s)}return i||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,"unmount");return}if(t==null)return;const i=this.mounted?"update":"mount";this.mounted=!0,n?.(t,this,i)}get fileDiffCache(){return this.hunksRenderer.diffCache??this.fileDiff}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,n=this.fileDiffCache,i=this.lineAnnotations,r=this.computeEditorRenderRange(this.renderRange);e!=null&&t!=null&&n!=null&&!n.isPartial&&this.hunksRenderer.initializeHighlighter().then(s=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.fileDiffCache!==n||e.__syncRenderView(s,t,n,i,r)})}computeEditorRenderRange(e){const t=this.fileDiffCache;if(e==null||t==null||qi(e))return e;const{diffStyle:n="split",expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options;let s,o;return et({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,callback:({additionLine:l})=>{l!=null&&(s??=l.lineNumber,o=l.lineNumber)}}),s==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:s-1,totalLines:o-s+1}}attachEditor(e){if(this.type!=="file-diff")throw new Error(`FileDiff.attachEditor: cannot attach an editor to a "${this.type}" diff`);return this.editor?.cleanUp(),this.editor=e,this.hunksRenderer.beginEditSession(),this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary(),this.hunksRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),t=>{this.editor=void 0,t!==!0&&this.finishEditSession()}}finishEditSession(){this.hunksRenderer.endEditSession(),this.completeEditSession()}completeEditSession(){const e=this.fileDiffCache;if(e==null||e.editSessionDirty!==!0)return!1;const{collapsedContextThreshold:t=1}=this.options,n=Vg(e,this.hunksRenderer.getExpandedHunksMap(),t);return Ms(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(qg(e,n)),this.hunksRenderer.refreshHighlightedResult(),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);const n=this.hunksRenderer.diffCache;if(n!=null){const i=this.fileDiff?.cacheKey;i!=null&&n.cacheKey==null&&(n.cacheKey=i),this.fileDiff=n}t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations()),this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n={}){const{shouldRefreshDiffsView:i,lineCountChangeInFlight:r}=n;if(this.hunksRenderer.updateRenderCache(e,t,r)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.lineStateRefreshPending=!0,this.escalateEditSessionRender();return}i===!0&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.lineStateRefreshPending=!0,this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle==="split"?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.flushDeferredLineState()},150))}isLineRenderable(e){const t=this.fileDiffCache;if(t==null)return!0;const{expandUnchanged:n=!1,collapsedContextThreshold:i=1}=this.options;return Na({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}getNearestRenderableLine(e,t){const n=this.fileDiffCache;if(n==null)return e;const{expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options;return vg({fileDiff:n,lineNumber:e,direction:t,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}revealLine(e){const t=this.fileDiffCache,{expandUnchanged:n=!1,collapsedContextThreshold:i=1,expansionLineCount:r=100}=this.options;if(t==null||t.isPartial||n)return!1;const s=this.hunksRenderer.getExpandedHunksMap();for(const[d,c]of t.hunks.entries()){const[u,h]=Ht(c);if(e<u){const f=Ne({isPartial:t.isPartial,rangeSize:c.collapsedBefore,expandedHunks:s,hunkIndex:d,collapsedContextThreshold:i}),p=u-f.rangeSize;if(f.renderAll||e<p+f.fromStart||e>=u-f.fromEnd)return!1;const g=e-(p+f.fromStart)+1,v=u-f.fromEnd-e;return g<=v?this.expandHunk(d,"up",g+r):this.expandHunk(d,"down",v+r),!0}if(e<h)return!1}const o=Me({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:s,collapsedContextThreshold:i,errorPrefix:"FileDiff.revealLine"});if(o==null||o.renderAll)return!1;const l=t.hunks[t.hunks.length-1],[,a]=Ht(l);return e<a+o.fromStart||e>=a+o.rangeSize?!1:(this.expandHunk(t.hunks.length,"up",e-(a+o.fromStart)+1+r),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){no(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender(),this.flushDeferredLineState()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){const{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||pn(e))return;const n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(i=>{console.error(i)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){const{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!="function"){for(const{element:i}of this.separatorCache.values())i.remove();this.separatorCache.clear();return}const n=new Map(this.separatorCache);for(const i of e){const r=i.slotName;let s=this.separatorCache.get(r);if(s==null||!fm(i,s.hunkData)){s?.element.remove();const o=document.createElement("div");o.style.display="contents",o.slot=i.slotName;const l=t(i,this);l!=null&&o.appendChild(l),this.fileContainer.appendChild(o),s={element:o,hunkData:i},this.separatorCache.set(r,s)}n.delete(r)}for(const[i,{element:r}]of n.entries())this.separatorCache.delete(i),r.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:n}of this.annotationCache.values())n.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[n,i]of this.lineAnnotations.entries()){const r=`${n}-${vt(i)}`;let s=this.annotationCache.get(r);if(s==null||!hm(i,s.annotation)){s?.element.remove();const o=t(i);if(o==null)continue;s={element:zp(vt(i)),annotation:i},s.element.appendChild(o),this.fileContainer.appendChild(s.element),this.annotationCache.set(r,s)}e.delete(r)}for(const[n,{element:i}]of e.entries())this.annotationCache.delete(n),i.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const n=jp();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){const{fileContainer:n}=this,i=e??n??document.createElement("diffs-container"),r=n!==i;return n!=null&&r&&this.editor?.__captureFocusForDOMReplacement(),r&&this.emitPostRender(!0),this.fileContainer=i,n!=null&&r&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),r&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const n of t.children)n instanceof SVGElement?this.spriteSVG??=n:Rs(n)&&n.hasAttribute("data-theme-css")?(this.themeCSSStyle??=n,this.hasAdoptedThemeCSS=!0):Rs(n)&&n.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=n,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const n=document.createElement("div");n.innerHTML=Up;const i=n.firstChild;i instanceof SVGElement&&(this.spriteSVG=i)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(const t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute("data-unified")?this.codeUnified=t:t.hasAttribute("data-deletions")?this.codeDeletions=t:t.hasAttribute("data-additions")&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const{fileDiff:n}=this,i=this.cachedHeaderHTML??Ie(e);if(this.cachedHeaderHTML=i,i!==this.lastRenderedHeaderHTML){const u=document.createElement("div");u.innerHTML=i;const h=u.firstElementChild;if(!(h instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(h,this.headerElement):t.shadowRoot?.prepend(h),this.headerElement=h,this.lastRenderedHeaderHTML=i}if(this.isContainerManaged||n==null)return;const{renderCustomHeader:r,renderHeaderPrefix:s,renderHeaderFilenameSuffix:o,renderHeaderMetadata:l}=this.options;if(r!=null){const u=r(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,tr,u),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}const a=s?.(n)??void 0,d=o?.(n)??void 0,c=l?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Zs,a),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Js,d),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,eo,c),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,i){if(i==null){t?.remove();return}const r=t??this.createHeaderSlotElement(n);return t==null&&e.appendChild(r),this.replaceHeaderSlotContent(r,i),r}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=Wp(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Kp(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,i){const r=e.shadowRoot??e.attachShadow({mode:"open"}),s=i??n,o=this.options.theme??le,l=typeof o=="string"?o:{...o},a=ji(r);if(this.themeCSSStyle?.parentNode===r&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===s&&this.appliedThemeCSS.scrollbarGutter===a){this.appliedThemeCSS.theme=l;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===r){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:l,themeStyles:t,themeType:s,baseThemeType:i,scrollbarGutter:a};return}this.themeCSSStyle=tg({shadowRoot:r,currentNode:this.themeCSSStyle,themeCSS:Xp(t,s,a)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:l,themeStyles:t,themeType:s,baseThemeType:i,scrollbarGutter:a}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=Yp(this.themeCSSStyle.textContent??"",ji(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&rg()}applyHunksToDOM(e,t){this.shouldGuardRebuildScroll()?Is(e,()=>this.replaceCodeColumns(e,t)):this.replaceCodeColumns(e,t)}applyCodeColumnsInPlace(e,t,n){const i=this.getColumnPair(e);if(i==null)return!1;const r=$e(t[0]),s=$e(t[1]);return r==null||s==null?!1:(i.gutter.innerHTML=Ie(r),i.content.innerHTML=Ie(s),n!==this.lastRowCount&&(i.gutter.style.setProperty("grid-row",`span ${n}`),i.content.style.setProperty("grid-row",`span ${n}`)),!0)}replaceCodeColumns(e,t){const{overflow:n="scroll"}=this.options,i=(this.options.hunkSeparators??"line-info")==="line-info",r=n==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let s=!1;const o=[],l=this.hunksRenderer.renderCodeAST("unified",t),a=this.hunksRenderer.renderCodeAST("deletions",t),d=this.hunksRenderer.renderCodeAST("additions",t);this.editor?.__captureFocusForDOMReplacement(),l!=null?(s=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=pi({code:this.codeUnified,columnType:"unified",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeUnified,l,t.rowCount)||(this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(l)),o.push(this.codeUnified)):a!=null||d!=null?(a!=null?(s=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=pi({code:this.codeDeletions,columnType:"deletions",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeDeletions,a,t.rowCount)||(this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(a)),o.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),d!=null?(s=s||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=pi({code:this.codeAdditions,columnType:"additions",rowSpan:r,containerSize:i}),this.applyCodeColumnsInPlace(this.codeAdditions,d,t.rowCount)||(this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(d)),o.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),o.length===0?e.textContent="":s&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){const{pre:n,codeUnified:i,codeAdditions:r,codeDeletions:s,options:{diffStyle:o="split"}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;const l=this.getCodeColumns(o,i,s,r);if(l==null)return!1;const a=e.startingLine,d=t.startingLine,c=a+e.totalLines,u=d+t.totalLines,h=Math.max(a,d),f=Math.min(c,u);if(f<=h)return!1;const p=Math.max(0,h-a),g=Math.max(0,c-f),v=this.trimColumns({columns:l,trimStart:p,trimEnd:g,previousStart:a,overlapStart:h,overlapEnd:f,diffStyle:o});if(v<0)throw new Error("FileDiff.applyPartialRender: failed to trim to overlap");if(this.lastRowCount<v)throw new Error("FileDiff.applyPartialRender: trimmed beyond DOM row count");let m=this.lastRowCount-v;const b=(w,x)=>{if(!(x<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:w,totalLines:x,bufferBefore:0,bufferAfter:0})},y=b(d,Math.max(h-d,0));if(y==null&&d<h)return!1;const S=b(f,Math.max(u-f,0));if(S==null&&u>f)return!1;const C=(w,x)=>{if(w!=null){if(o==="unified"&&!Array.isArray(l))this.insertPartialHTML(o,l,w,x);else if(o==="split"&&Array.isArray(l))this.insertPartialHTML(o,l,w,x);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");m+=w.rowCount}};return this.cleanupErrorWrapper(),C(y,"afterbegin"),C(S,"beforeend"),this.lastRowCount!==m&&(this.applyRowSpan(o,l,m),this.lastRowCount=m),!0}insertPartialHTML(e,t,n,i){if(e==="unified"&&!Array.isArray(t)){const r=this.hunksRenderer.renderCodeAST("unified",n);this.renderPartialColumn(t,r,i)}else if(e==="split"&&Array.isArray(t)){const r=this.hunksRenderer.renderCodeAST("deletions",n),s=this.hunksRenderer.renderCodeAST("additions",n);this.renderPartialColumn(t[0],r,i),this.renderPartialColumn(t[1],s,i)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}refreshSplitDiffView(){if(this.options.diffStyle!=="split")return;const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns("split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;const n=(i,r)=>{if(r==null)return;const s=this.hunksRenderer.renderCodeAST(i,e),o=$e(s?.[0]),l=$e(s?.[1]);for(const[a,d]of[[r.gutter,o],[r.content,l]])if(d!=null&&a.childElementCount===d.length)for(let c=0;c<d.length;c++){const u=a.children[c],h=d[c].properties["data-line-type"];h!=null&&u.dataset.lineType!==h&&(u.dataset.lineType=h)}};n("deletions",t[0]),n("additions",t[1])}refreshUnifiedDiffView(){if(this.options.diffStyle!=="unified")return;const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns("unified",this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null||Array.isArray(t))return;const n=this.hunksRenderer.renderCodeAST("unified",e),i=$e(n?.[0]),r=$e(n?.[1]),s=()=>{for(const[o,l]of[[t.gutter,i],[t.content,r]])l!=null&&(o.innerHTML=Ie(l));e.rowCount!==this.lastRowCount&&(this.applyRowSpan("unified",t,e.rowCount),this.lastRowCount=e.rowCount)};this.shouldGuardRebuildScroll()?Is(this.pre,s):s(),this.renderSeparators(e.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;const i=$e(t[0]),r=$e(t[1]);if(i==null||r==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");const s=r.at(0);n==="beforeend"&&s?.type==="element"&&typeof s.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(s.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],i,r,!0);const o=r.at(-1);n==="afterbegin"&&o?.type==="element"&&typeof o.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],i,r,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r))}mergeBuffersIfNecessary(e,t,n,i,r,s){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;const o=this.getBufferSize(t.dataset);o!=null&&(s?(i.shift(),r.shift()):(i.pop(),r.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){const i=r=>{r!=null&&(r.gutter.style.setProperty("grid-row",`span ${n}`),r.content.style.setProperty("grid-row",`span ${n}`))};if(e==="unified"&&!Array.isArray(t))i(t);else if(e==="split"&&Array.isArray(t))i(t[0]),i(t[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(e,t,n){let i=0,r=0,s=0,o=!1;const l=n>=0;if(e==null)return 0;const a=Array.from(e.content.children),d=Array.from(e.gutter.children);if(a.length!==d.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;s<a.length&&!(t<=0&&!l&&!o);){const c=d[s],u=a[s];if(s++,!(c instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:c,contentElement:u}),new Error("FileDiff.trimColumnRows: invalid row elements");if(o&&(o=!1,c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in u.dataset||c.dataset.gutterBuffer==="metadata"&&"noNewline"in u.dataset)){c.remove(),u.remove(),r++;continue}if("lineIndex"in c.dataset&&"lineIndex"in u.dataset){(t>0||l&&i>=n)&&(c.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),r++),i++;continue}if("separator"in c.dataset&&"separator"in u.dataset){(t>0||l&&i>=n)&&(c.remove(),u.remove(),r++);continue}if(c.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in u.dataset){(t>0||l&&i>=n)&&(c.remove(),u.remove(),r++);continue}if(c.dataset.gutterBuffer==="metadata"&&"noNewline"in u.dataset){(t>0||l&&i>=n)&&(c.remove(),u.remove(),r++);continue}if(c.dataset.gutterBuffer==="buffer"&&"contentBuffer"in u.dataset){const h=this.getBufferSize(u.dataset);if(h==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(t>0){const f=Math.min(t,h),p=h-f;p>0?(this.updateBufferSize(c,p),this.updateBufferSize(u,p),r+=f):(c.remove(),u.remove(),r+=h),t-=f,t===0&&p===0&&(o=!0)}else if(l){const f=i,p=i+h-1;if(n<=f)c.remove(),u.remove(),r+=h;else if(n<=p){const g=p-n+1,v=h-g;this.updateBufferSize(c,v),this.updateBufferSize(u,v),r+=g}}i+=h;continue}throw console.error({gutterElement:c,contentElement:u}),new Error("FileDiff.trimColumnRows: unknown row elements")}return r}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:i,previousStart:r,trimEnd:s,trimStart:o}){const l=Math.max(0,i-r),a=n-r;if(a<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");const d=o>0,c=s>0;if(!d&&!c)return 0;const u=d?l:0,h=c?a:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,u,h);if(t==="split"&&Array.isArray(e)){const f=this.trimColumnRows(e[0],u,h),p=this.trimColumnRows(e[1],u,h);if(e[0]!=null&&e[1]!=null&&f!==p)throw new Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?f:p}else throw console.error({diffStyle:t,columns:e}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){const t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getColumnPair(e){if(e==null)return;const t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}getCodeColumns(e,t,n,i){if(e==="unified")return this.getColumnPair(t);{const r=this.getColumnPair(n),s=this.getColumnPair(i);return r!=null||s!=null?[r,s]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:i},r){const{diffIndicators:s="bars",disableBackground:o=!1,disableLineNumbers:l=!1,overflow:a="scroll",diffStyle:d="split"}=this.options,c={type:"diff",diffIndicators:s,disableBackground:o,disableLineNumbers:l,overflow:a,split:d==="unified"?!1:t!=null&&n!=null,totalLines:i,customProperties:r};Bp(c,this.appliedPreAttributes)||(Jp(e,c),this.appliedPreAttributes=c)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const n=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",n.appendChild(this.errorWrapper);const i=document.createElement("div");i.dataset.errorMessage="",i.innerText=e.message,this.errorWrapper.appendChild(i);const r=document.createElement("pre");r.dataset.errorStack="",r.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(r)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function Gs(e,t){return e==null||t==null?e==null&&t==null:ho(e,t)}function bm({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function vm({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function ym(e,t,n=!1){return!n&&e==null&&t}function Cm(e,t,n=!1){return e==null&&t&&!n}function $e(e){if(!(e==null||e.type!=="element"))return e.children??[]}function Sm({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:i,expandUnchanged:r,expandedHunks:s,collapsedContextThreshold:o,canHydratePartialDiff:l}){let a=ht(t,n),d=a;const c=r?!0:s,u=e.hunks.length-1;for(let h=0;h<e.hunks.length;h++){const f=e.hunks[h];if(f==null)throw new Error("computeEstimatedDiffHeights: invalid hunk index");const p=Ne({isPartial:e.isPartial,rangeSize:f.collapsedBefore,expandedHunks:c,hunkIndex:h,collapsedContextThreshold:o}),g=(p.fromStart+p.fromEnd)*t.lineHeight;if(a+=g,d+=g,p.collapsedLines>0){const b=Lt({type:i,metrics:t,hunkIndex:h,hunkSpecs:f.hunkSpecs})?.totalHeight??0;a+=b,d+=b}a+=f.splitLineCount*t.lineHeight,d+=f.unifiedLineCount*t.lineHeight;const v=wm(f);a+=v.split*t.lineHeight,d+=v.unified*t.lineHeight;const m=h===u?Me({fileDiff:e,hunkIndex:h,expandedHunks:c,collapsedContextThreshold:o,errorPrefix:"computeEstimatedDiffHeights"}):void 0;if(m!=null){const b=(m.fromStart+m.fromEnd)*t.lineHeight;if(a+=b,d+=b,m.collapsedLines>0){const y=Xe({type:i,metrics:t})?.totalHeight??0;a+=y,d+=y}}else if(h===u&&e.isPartial&&l){const b=Xe({type:i,metrics:t})?.totalHeight??0;a+=b,d+=b}}if(e.hunks.length>0){const h=Ia(t);a+=h,d+=h}return{splitHeight:a,unifiedHeight:d}}function wm(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};const t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type==="context"){const n=t.lines>0?1:0;return{split:n,unified:n}}return xm(e,t)}function xm(e,t){const n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),i=t.deletions>0&&e.noEOFCRDeletions,r=t.additions>0&&e.noEOFCRAdditions;return{split:i||r?1:0,unified:n}}const Ji=3e3;let km=-1;var Lm=class extends Ua{__id=`little-virtualized-file-diff:${++km}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;currentExpandUnchanged;pendingHydratedDiff;pendingExpansions;constructor(e,t,n,i,r=!1){super(e,i,r),this.virtualizer=t,this.metrics=gi(n)}setMetrics(e,t=!1){const n=gi(e);!t&&Si(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){const t=this.cache.fileAnnotationHeight;return e===t?!1:(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!Fp(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber!==0?!1:e.type==="new"?t.side==="additions":e.type==="deleted"?t.side==="deletions":!0)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){const t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;const{options:t}=this,n=!ro(t,e),i=n&&Tm(t,e);super.setOptions(e),i&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Pm(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,i)}setThemeType(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}reconcileHeights(){let e=!1;const{overflow:t="scroll"}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;const n=this.getDiffStyle(),i=n==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],r=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&r&&Aa(this.renderRange)){const s=Em(i)??0;this.setFileAnnotationHeight(s)&&(e=!0)}else!r&&this.setFileAnnotationHeight(0)&&(e=!0);for(const s of i){if(s==null)continue;const o=s.children[1];if(o instanceof HTMLElement)for(const l of o.children){if(!(l instanceof HTMLElement))continue;const a=l.dataset.lineIndex;if(a==null)continue;const d=Mm(a,n);let c=l.getBoundingClientRect().height,u=!1;l.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in l.nextElementSibling.dataset||"noNewline"in l.nextElementSibling.dataset)&&("noNewline"in l.nextElementSibling.dataset&&(u=!0),c+=l.nextElementSibling.getBoundingClientRect().height);const h=this.getEstimatedLineHeight(u),f=this.cache.heightDeltas.get(d)??0,p=c-h;p!==f&&(e=!0,this.cache.measuredHeightDeltaTotal+=p-f,p===0?this.cache.heightDeltas.delete(d):this.cache.heightDeltas.set(d,p))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render());flushManagers(){super.flushManagers(),this.lineStateRefreshPending&&this.flushDeferredLineState()}prepareCodeViewItem(e,t,n,i){const r=!pt(this.fileDiff,e),s=this.syncLineAnnotations(i);let o=n?.resetDiffLayoutCache===!0||r||s,l=r||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=gi(n.metrics),o=!0,l=!0);const{collapsed:a=!1,expandUnchanged:d=!1}=this.options;return this.currentCollapsed!==a&&(this.currentCollapsed=a,o=!0),this.currentExpandUnchanged!==d&&(this.currentExpandUnchanged=d,o=!0,l=!0),o&&this.resetLayoutCache({includeEstimatedHeights:l}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t="additions"){if(this.fileDiff==null||e<1)return;const n=this.getLineIndex(e,t);if(n==null)return;const{disableFileHeader:i=!1,expandUnchanged:r=!1,collapsed:s=!1,collapsedContextThreshold:o=1}=this.options,l=this.getDiffStyle(),a=this.getHunkSeparatorType(),d=l==="split"?n[1]:n[0];this.approximateLayoutCheckpoints();const c=ht(this.metrics,i),u=this.getLayoutCheckpointBeforeLineIndex(d);let h=u?.top??c+this.cache.fileAnnotationHeight;if(s)return{top:c,height:0};let f;return et({diff:this.fileDiff,diffStyle:l,startingLine:u?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:p,hunk:g,collapsedBefore:v,collapsedAfter:m,deletionLine:b,additionLine:y})=>{const S=l==="split"?y?.splitLineIndex??b?.splitLineIndex:y?.unifiedLineIndex??b?.unifiedLineIndex;if(S==null)throw new Error("VirtualizedFileDiff.getLinePosition: missing line index data");if(v>0){const w=Lt({type:a,metrics:this.metrics,hunkIndex:p,hunkSpecs:g?.hunkSpecs});if(w!=null){if(h+=w.gapBefore,d>=S-v&&d<S)return f={top:h,height:w.height},!0;h+=w.height+w.gapAfter}}const C=this.getLineHeight(S,(y?.noEOFCR??!1)||(b?.noEOFCR??!1));if(S===d)return f={top:h,height:C},!0;if(h+=C,m>0){const w=Xe({type:a,metrics:this.metrics});if(w!=null){if(d>S&&d<=S+m)return f={top:h+w.gapBefore,height:w.height},!0;h+=w.totalHeight}}return!1}}),f}getEditorViewport(){return this.virtualizer.type==="simple"?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.fileDiff==null)return;const{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:i=!1,collapsedContextThreshold:r=1}=this.options;if(i)return;const s=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();const l=this.getLayoutCheckpointBeforeTop(e);let a=l?.top??ht(this.metrics,t)+this.cache.fileAnnotationHeight,d;return et({diff:this.fileDiff,diffStyle:s,startingLine:l?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,callback:({hunkIndex:c,hunk:u,collapsedBefore:h,collapsedAfter:f,deletionLine:p,additionLine:g})=>{const v=s==="split"?g?.splitLineIndex??p?.splitLineIndex:g?.unifiedLineIndex??p?.unifiedLineIndex;if(v==null)throw new Error("VirtualizedFileDiff.getNumericScrollAnchor: missing line index data");if(h>0){const b=Lt({type:o,metrics:this.metrics,hunkIndex:c,hunkSpecs:u?.hunkSpecs});b!=null&&(a+=b.totalHeight)}if(a>=e&&(p!=null?d={lineNumber:p.lineNumber,side:"deletions",top:a}:g!=null&&(d={lineNumber:g.lineNumber,side:"additions",top:a}),d!=null))return!0;const m=this.getLineHeight(v,(g?.noEOFCR??!1)||(p?.noEOFCR??!1));if(a+=m,f>0){const b=Xe({type:o,metrics:this.metrics});b!=null&&(a+=b.totalHeight)}return!1}}),d}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const t=e!=null?this.computeRenderRangeFromWindow(this.fileDiff,this.top,e):this.renderRange;if(t==null)return;const{bufferBefore:n,bufferAfter:i,totalLines:r}=t;let s=0;if(r===0){const o=e??this.virtualizer.getWindowSpecs();this.top<o.top&&(s=i)}return{topOffset:this.top+n+s,height:this.height-(n+i)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(!(this.fileDiff!==e||!e.isPartial)){if(this.isAdvancedMode()){const n=Vi("clone",e,t);if(await Qi(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Vi("merge",e,t),this.setHydratedState(t),await Qi(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}consumeCodeViewLayoutChanges(e){let t=!1,n;const{pendingExpansions:i,pendingHydratedDiff:r}=this;if(i!=null){this.pendingExpansions=void 0;for(const s of i)this.hunksRenderer.expandHunk(s.hunkIndex,s.direction,s.expansionLineCountOverride),t=!0}return r!=null&&(this.pendingHydratedDiff=void 0,r.expectedDiff===e&&(this.setHydratedState(r.files),n=r.nextDiff)),n!=null?(this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0})):t&&(this.forceRenderOverride=!0,this.invalidateDerivedLayoutCache(!0)),n}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;const{pendingExpansions:t}=this,n=this.fileDiffCache;if(t==null||t.length===0||n==null)return!1;const{expansionLineCount:i=100,collapsedContextThreshold:r=1}=this.options,s=new Map(this.hunksRenderer.getExpandedHunksMap());for(const o of t){const l={...s.get(o.hunkIndex)??{fromStart:0,fromEnd:0}},a=o.expansionLineCountOverride??i;(o.direction==="up"||o.direction==="both")&&(l.fromStart+=a),(o.direction==="down"||o.direction==="both")&&(l.fromEnd+=a),s.set(o.hunkIndex,l)}return Na({fileDiff:n,lineNumber:e,expandedHunks:s,collapsedContextThreshold:r})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),!(!this.enabled||this.fileDiff==null)&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){const{renderRange:i}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&i!==void 0&&this.fileDiff!==void 0){const r=this.virtualizer.getWindowSpecs(),s=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,r);s.bufferAfter!==i.bufferAfter&&this.updateBuffers(s)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}computeApproximateSize(e=!1,t=this.fileDiff){const n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;const i=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}const{disableFileHeader:r=!1,collapsed:s=!1}=this.options,o=ht(this.metrics,r);if(this.height+=o,s){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!i&&this.validateComputedHeight(t),this.layoutDirty=!1}getActiveEstimatedHeight(e=this.fileDiff){this.ensureEstimatedDiffHeights(e);const t=this.getDiffStyle()==="split"?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw new Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");return t}ensureEstimatedDiffHeights(e=this.fileDiff){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;const{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:i=1}=this.options,{splitHeight:r,unifiedHeight:s}=Sm({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,canHydratePartialDiff:vi(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=r,this.cache.estimatedUnifiedHeight=s}validateComputedHeight(e=this.fileDiff){if(this.fileContainer==null||e==null)return;const t=this.fileContainer.getBoundingClientRect();t.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:e.name,elementHeight:t.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:i,...r}={}){const s=Zi(r,"VirtualizedFileDiff.render"),o=s!=null,l=s?.oldFile,a=s?.newFile,d=o&&(!Ws(l,this.deletionFile)||!Ws(a,this.additionFile));let c=t??this.fileDiff;t==null&&o&&(d||this.fileDiff==null)&&(c=tt(s.oldFile,s.newFile,this.options.parseDiffOptions));const{forceRenderOverride:u,isSetup:h}=this;this.forceRenderOverride=void 0;const f=this.syncLineAnnotations(i);f&&this.resetLayoutCache({includeEstimatedHeights:!1});const p=t!=null&&t!==this.fileDiff,g=c!=null&&!pt(this.fileDiff,c),v=p||d;if(g&&this.resetLayoutCache({includeEstimatedHeights:!0}),e=this.getOrCreateFileContainer(e),c==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(h)this.top??=this.getVirtualizedTop(),g&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.computeApproximateSize(!1,c));else{this.computeApproximateSize(!1,c);const C=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(C==null)throw new Error("VirtualizedFileDiff.render: simple virtualizer is not available");C.connect(e,this),this.isVisible=C.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!v||!h))return this.fileDiff=c,s!=null&&(this.deletionFile=l,this.additionFile=a),g&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);const m=this.virtualizer.getWindowSpecs(),b=this.top??0,y=this.computeRenderRangeFromWindow(c,b,m),S=super.render({fileDiff:c,fileContainer:e,renderRange:y,lineAnnotations:i,forceRender:(u??n)||f||g,...s,...r});return this.isSimpleMode()&&S&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),S}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type==="advanced"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??"split"}getHunkSeparatorType(){return Nm(this.options.hunkSeparators)}approximateLayoutCheckpoints(e=this.fileDiff){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e==null||e.hunks.length===0||this.options.collapsed===!0)return;const{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:i=1}=this.options,r=e.hunks.length-1,s=vi(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),l=this.getHunkSeparatorType(),a=n?!0:this.hunksRenderer.getExpandedHunksMap(),d=Am(this.cache.heightDeltas);let c=ht(this.metrics,t)+this.cache.fileAnnotationHeight,u=0;const h=({rowCount:f,startLineIndex:p,preSeparatorHeight:g=0,postSeparatorHeight:v=0,metadataOffsets:m=[]})=>{if(f<=0)return;const b=u,y=u+f;let S=_m(b);for(;S<y;){const C=S-b,w=c+(C>0?g:0)+C*this.metrics.lineHeight+Rm(m,C)*this.metrics.lineHeight+zs(d,p,p+C);this.cache.checkpoints.push({renderedLineIndex:S,lineIndex:p+C,top:w}),S+=Ji}c+=g+f*this.metrics.lineHeight+m.length*this.metrics.lineHeight+zs(d,p,p+f)+v,u=y};for(let f=0;f<e.hunks.length;f++){const p=e.hunks[f];if(p==null)throw new Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");const g=Ne({isPartial:e.isPartial,rangeSize:p.collapsedBefore,expandedHunks:a,hunkIndex:f,collapsedContextThreshold:i}),v=g.collapsedLines>0?Lt({type:l,metrics:this.metrics,hunkIndex:f,hunkSpecs:p.hunkSpecs})?.totalHeight??0:0;h({rowCount:g.fromStart,startLineIndex:(o==="split"?p.splitLineStart:p.unifiedLineStart)-g.rangeSize});let m=v;h({rowCount:g.fromEnd,startLineIndex:(o==="split"?p.splitLineStart:p.unifiedLineStart)-g.fromEnd,preSeparatorHeight:m}),g.fromEnd>0&&(m=0);const b=f===r?Me({fileDiff:e,hunkIndex:f,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:"VirtualizedFileDiff"}):void 0,y=b!=null&&b.collapsedLines>0?Xe({type:l,metrics:this.metrics})?.totalHeight??0:f===r&&s?Xe({type:l,metrics:this.metrics})?.totalHeight??0:0,S=b!=null?b.fromStart+b.fromEnd:0,C=o==="split"?p.splitLineCount:p.unifiedLineCount,w=o==="split"?p.splitLineStart:p.unifiedLineStart;h({rowCount:C,startLineIndex:w,preSeparatorHeight:m,postSeparatorHeight:S===0?y:0,metadataOffsets:Im({diffStyle:o,hunk:p,rowCount:C})}),b!=null&&S>0&&h({rowCount:S,startLineIndex:w+C,postSeparatorHeight:y})}this.cache.totalLines=u}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,i;for(;t<=n;){const r=t+n>>1,s=this.cache.checkpoints[r];if(s==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");s.lineIndex<=e?(i=s,t=r+1):n=r-1}return i}getLayoutCheckpointBeforeTop(e,t){let n=0,i=this.cache.checkpoints.length-1,r=-1;for(;n<=i;){const s=n+i>>1,o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");o.top<=e?(r=s,n=s+1):i=s-1}if(t==null)return r>=0?this.cache.checkpoints[r]:void 0;for(let s=r;s>=0;s--){const o=this.cache.checkpoints[s];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");if(o.renderedLineIndex%t===0)return o}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(const l of e.hunks)n+=t==="split"?l.splitLineCount:l.unifiedLineCount;return n}const{expandUnchanged:i=!1,collapsedContextThreshold:r=1}=this.options,s=i?!0:this.hunksRenderer.getExpandedHunksMap();for(const[l,a]of e.hunks.entries()){const d=t==="split"?a.splitLineCount:a.unifiedLineCount;n+=d;const c=Math.max(a.collapsedBefore,0),{fromStart:u,fromEnd:h,renderAll:f}=Ne({isPartial:e.isPartial,rangeSize:c,expandedHunks:s,hunkIndex:l,collapsedContextThreshold:r});c>0&&(n+=f?c:u+h)}const o=Me({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:s,collapsedContextThreshold:r,errorPrefix:"VirtualizedFileDiff"});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){const n=this.getExpandedLineCount(e,t),i=t==="split"?e.splitLineCount:e.unifiedLineCount;return Math.max(n,i,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:i}){const{disableFileHeader:r=!1,expandUnchanged:s=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:l,lineHeight:a}=this.metrics,d=this.getDiffStyle(),c=this.getHunkSeparatorType(),u=vi(e,this.options.loadDiffFiles!=null),h=this.height;let f=this.getLayoutLineCount(e,d);const p=ht(this.metrics,r),g=e.hunks.length>0?Ia(this.metrics):0,{fileAnnotationHeight:v}=this.cache,m=p+v,b=Math.max(0,h-p-v-g),y=this.hasFileAnnotations(e),S=t+p,C=v>0&&y&&S<i&&S+v>n;if(t<n-h||t>i)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-p-g};if(f<=l||e.hunks.length===0)return{startingLine:0,totalLines:l,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),f=this.getLayoutLineCount(e,d);const w=Math.ceil(Math.max(i-n,0)/a),x=Math.ceil(w/l)*l+l,E=x/l,k=E,_=[],F=(n+i)/2,L=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-x*a*2),l);let A=t+(L?.top??m),N=L?.renderedLineIndex??0,M,R,P;if(et({diff:e,diffStyle:d,startingLine:L?.renderedLineIndex??0,expandedHunks:s?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:St,hunk:we,collapsedBefore:Gn,collapsedAfter:zn,deletionLine:je,additionLine:xe})=>{const B=xe!=null?xe.splitLineIndex:je.splitLineIndex,te=xe!=null?xe.unifiedLineIndex:je.unifiedLineIndex,se=(xe?.noEOFCR??!1)||(je?.noEOFCR??!1),We=St===e.hunks.length-1&&we!=null&&(d==="split"?B===we.splitLineStart+we.splitLineCount-1:te===we.unifiedLineStart+we.unifiedLineCount-1),ce=(Gn>0?Lt({type:c,metrics:this.metrics,hunkIndex:St,hunkSpecs:we?.hunkSpecs}):void 0)?.totalHeight??0;A+=ce;const ue=N%l===0,De=Math.floor(N/l);if(ue&&(_[De]=A-(t+m+ce),P!=null)){if(P<=0)return!0;P--}const ne=this.getLineHeight(d==="split"?B:te,se);if(A>n-ne&&A<i&&(M??=De),R==null&&A+ne>F&&(R=De),P==null&&A>=i&&ue&&(P=k),N++,A+=ne,zn>0||We&&u){const Ot=Xe({type:c,metrics:this.metrics});Ot!=null&&(A<i&&A+Ot.totalHeight>n&&(M??=De),R==null&&A+Ot.totalHeight>F&&(R=De),A+=Ot.totalHeight)}return!1}}),M==null)if(C)M=0,R=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-p-g};R??=M;const $=Math.round(R-E/2),ee=Math.max(0,Math.ceil(f/l)-E),H=Math.max(0,Math.min($,ee)),U=H*l,G=$<0?x+$*l:x,re=_[H]??0,He=U===0?0:v+re,rt=H+G/l,$t=rt<_.length?b-_[rt]:b-(A-t-m);return{startingLine:U,totalLines:G,bufferBefore:He,bufferAfter:Math.max(0,$t)}}};function Em(e){let t;for(const n of e){if(n==null)continue;const i=n.children[1];if(i instanceof HTMLElement)for(const r of i.children)r instanceof HTMLElement&&r.dataset.lineAnnotation===Dp&&(t=Math.max(t??0,r.getBoundingClientRect().height))}return t}function Am(e){const t=Array.from(e).sort((s,o)=>s[0]-o[0]),n=[],i=[0];let r=0;for(const[s,o]of t)n.push(s),r+=o,i.push(r);return{lineIndexes:n,prefixTotals:i}}function zs({lineIndexes:e,prefixTotals:t},n,i){if(n>=i||e.length===0)return 0;const r=js(e,n);return(t[js(e,i)]??0)-(t[r]??0)}function js(e,t){let n=0,i=e.length;for(;n<i;){const r=n+i>>1,s=e[r];if(s==null)throw new Error("VirtualizedFileDiff: invalid prefix index");s<t?n=r+1:i=r}return n}function _m(e){return Math.ceil(e/Ji)*Ji}function Rm(e,t){let n=0;for(const i of e)i<t&&n++;return n}function Im({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];const i=t.hunkContent.at(-1);if(i==null)return[];if(i.type==="context")return[n-1];const r=Math.max(i.deletions,i.additions),s=i.deletions+i.additions;if(e==="split")return r>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];const o=[],l=n-s;return i.deletions>0&&t.noEOFCRDeletions&&o.push(l+i.deletions-1),i.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function Tm(e,t){return(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Pm(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function vi(e,t){return e.isPartial&&t&&(e.type==="change"||e.type==="rename-changed")}function Nm(e){return typeof e=="function"?"custom":e??"line-info"}function Ws(e,t){return e==null||t==null?e==null&&t==null:ho(e,t)}function Mm(e,t){const[n,i]=e.split(",").map(Number);return t==="split"?i:n}function Hm({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function Dm(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Fm(n,e.startContentIndex)}}function Fm(e,t){let n=e.unifiedLineStart;for(let i=0;i<t;i++){const r=e.hunkContent[i];n+=r.type==="context"?r.lines:r.deletions+r.additions}return n}function $m(e){const t=Cl(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function Om(e){const t=Q.useRef(e);return Q.useInsertionEffect(()=>{t.current=e}),Q.useCallback((...n)=>t.current(...n),[])}const Um=Q.createContext(void 0);function Bm(){return Q.useContext(Um)}const Gm={position:"absolute",top:0,bottom:0,textAlign:"center",whiteSpace:"normal",touchAction:"none"},zm={display:"contents"};function Vs(){return null}function jm({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:i,renderHeaderFilenameSuffix:r,renderHeaderMetadata:s,renderAnnotation:o,renderGutterUtility:l,renderMergeConflictUtility:a,lineAnnotations:d,getHoveredLine:c,getInstance:u}){const h=n?.(e),f=i?.(e),p=r?.(e),g=s?.(e);return j.jsxs(j.Fragment,{children:[h!=null?j.jsx("div",{slot:tr,children:h}):j.jsxs(j.Fragment,{children:[f!=null&&j.jsx("div",{slot:"header-prefix",children:f}),p!=null&&j.jsx("div",{slot:"header-filename-suffix",children:p}),g!=null&&j.jsx("div",{slot:"header-metadata",children:g})]}),o!=null&&d?.map((v,m)=>j.jsx("div",{slot:vt(v),children:o(v)},m)),t!=null&&a!=null&&u!=null&&t.map(v=>{if(v==null)return;const m=Wm(v,e);return j.jsx("div",{slot:m,style:zm,children:a(v,u)},m)}),l!=null&&j.jsx("div",{slot:"gutter-utility-slot",style:Gm,children:l(c)})]})}function Wm(e,t){const n=Dm(e,t);return n!=null?Hm({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const Vm=Q.createContext(void 0);function qm(e,t){return typeof window>"u"&&t!=null?j.jsxs(j.Fragment,{children:[j.jsx("template",{shadowrootmode:"open",dangerouslySetInnerHTML:{__html:t}}),e]}):j.jsx(j.Fragment,{children:e})}const Km=Q.createContext(void 0);function Xm(){return Q.useContext(Km)}const qs=typeof window>"u"?Q.useEffect:Q.useLayoutEffect;function Ym({fileDiff:e,options:t,editorOptions:n,lineAnnotations:i,selectedLines:r,prerenderedHTML:s,metrics:o,hasGutterRenderUtility:l,hasCustomHeader:a,disableWorkerPool:d,edit:c}){const u=Xm(),h=r!==void 0,f=Q.useContext(Vm),p=Bm(),g=Q.useRef(null),v=Om(m=>{if(m!=null){if(g.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");u!=null?g.current=new Lm(yi({controlledSelection:h,hasCustomHeader:a,hasGutterRenderUtility:l,options:t}),u,o,d?void 0:f,!0):g.current=new Ua(yi({controlledSelection:h,hasCustomHeader:a,hasGutterRenderUtility:l,options:t}),d?void 0:f,!0),g.current.hydrate({fileDiff:e,fileContainer:m,lineAnnotations:i,prerenderedHTML:s})}else{if(g.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");g.current.cleanUp(),g.current=null}});return qs(()=>{const{current:m}=g;if(m==null)return;const b=yi({controlledSelection:h,hasCustomHeader:a,hasGutterRenderUtility:l,options:t}),y=b!==void 0&&!ro(m.options,b);m.setOptions(b),m.render({forceRender:y,fileDiff:e,lineAnnotations:i}),r!==void 0&&m.setSelectedLines(r)}),qs(()=>{if(c&&g.current!=null){if(p===void 0)throw new Error("FileDiff: EditContext is not attached");const m=p(n??{});if(m==null)throw new Error("FileDiff: EditProvider.createEditor must return an editor instance");try{return m.edit(g.current)}catch(b){throw m.cleanUp(),b}}},[c]),{ref:v,getHoveredLine:Q.useCallback(()=>g.current?.getHoveredLine(),[])}}function yi({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:i}){return t||i||n?{...e,controlledSelection:t,renderCustomHeader:n?Vs:e?.renderCustomHeader,renderGutterUtility:i?Vs:e?.renderGutterUtility}:e}function Qm({patch:e,options:t,editorOptions:n,metrics:i,lineAnnotations:r,selectedLines:s,className:o,style:l,prerenderedHTML:a,renderAnnotation:d,renderCustomHeader:c,renderHeaderPrefix:u,renderHeaderFilenameSuffix:h,renderHeaderMetadata:f,renderGutterUtility:p,disableWorkerPool:g=!1,edit:v=!1}){const m=Zm(e),{ref:b,getHoveredLine:y}=Ym({fileDiff:m,options:t,editorOptions:n,metrics:i,lineAnnotations:r,selectedLines:s,prerenderedHTML:a,hasGutterRenderUtility:p!=null,hasCustomHeader:c!=null,disableWorkerPool:g,edit:v});return j.jsx(Ys,{ref:b,className:o,style:l,children:qm(jm({fileDiff:m,renderCustomHeader:c,renderHeaderPrefix:u,renderHeaderFilenameSuffix:h,renderHeaderMetadata:f,renderAnnotation:d,lineAnnotations:r,renderGutterUtility:p,getHoveredLine:y}),a)})}function Zm(e){return Q.useMemo(()=>$m(e),[e])}const Jm={diffStyle:"unified",overflow:"scroll",preferredHighlighter:"shiki-js"};for(const[e,t]of Object.entries(ut))(!t||!Vf.has(t))&&Cp(e,"text");function Ks(){if(typeof document>"u")return"system";const e=document.documentElement.dataset.theme;return e==="light"||e==="dark"?e:"system"}function e0(){const[e,t]=Q.useState(Ks);return Q.useEffect(()=>{const n=document.documentElement,i=new MutationObserver(()=>t(Ks()));return i.observe(n,{attributes:!0,attributeFilter:["data-theme"]}),()=>i.disconnect()},[]),e}function r0({patch:e,fileName:t,hideFileHeader:n,truncated:i,className:r}){const s=Q.useMemo(()=>Wa(e,t),[e,t]),o=e0(),l=Q.useMemo(()=>({...Jm,themeType:o,disableFileHeader:n}),[o,n]);return j.jsxs("div",{className:Va("min-w-0",r),children:[s.preamble?j.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap font-mono text-[11.5px] leading-[1.5] text-faint",children:s.preamble}):null,j.jsx(Qm,{patch:s.patch,options:l,className:"min-w-0 [--diffs-font-family:var(--font-mono)] [--diffs-font-size:11.5px] [--diffs-line-height:17.25px]"}),i?j.jsx("div",{className:"mt-2 font-mono text-[11.5px] text-faint",children:"… diff truncated …"}):null]})}export{r0 as default};