@deslop/workbench 0.0.291 → 0.0.299

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 (46) hide show
  1. package/dist/client/assets/{(home)-DqYzvhAC.js → (home)-DOBmFAyb.js} +1 -1
  2. package/dist/client/assets/agent-CcHomDRK.js +1 -0
  3. package/dist/client/assets/agent-DhIB78HL.js +2 -0
  4. package/dist/client/assets/browser-B8fkyBtE.js +1 -0
  5. package/dist/client/assets/browser-ClOwyJJZ.js +2 -0
  6. package/dist/client/assets/button-Bqawukg7.js +16 -0
  7. package/dist/client/assets/check-DpJM7J4T.js +1 -0
  8. package/dist/client/assets/composite-DXpCs7eA.js +1 -0
  9. package/dist/client/assets/dialog-PAzkmCTH.js +153 -0
  10. package/dist/client/assets/{diff-CQ3kp_ZY.js → diff-Wdd9xz8g.js} +10 -6
  11. package/dist/client/assets/diff-gY3qhzPv.js +2 -0
  12. package/dist/client/assets/{fallbacks-3StR6PZ5.js → fallbacks-BUiFDlyX.js} +1 -1
  13. package/dist/client/assets/{index-B0KpV0Yl.js → index-B8GNfTc7.js} +4 -4
  14. package/dist/client/assets/index-CB7nvBDM.css +2 -0
  15. package/dist/client/assets/{info-DbWKjMtL.js → info-NaVIP-PS.js} +1 -1
  16. package/dist/client/assets/loader-circle-DCgJgOPt.js +1 -0
  17. package/dist/client/assets/route-DGc1kMxd.js +2 -0
  18. package/dist/client/assets/route-dsd1lleB.js +45 -0
  19. package/dist/client/assets/run-CSGyvcrt.js +2 -0
  20. package/dist/client/assets/run-DNgqimzY.js +1 -0
  21. package/dist/client/assets/state-nIOT1NpG.js +2 -0
  22. package/dist/client/assets/terminal-BDNA0nGZ.js +119 -0
  23. package/dist/client/assets/terminal-D8j15kd-.js +2 -0
  24. package/dist/client/assets/terminal-Dn-2EhdC.js +1 -0
  25. package/dist/client/assets/{triangle-alert-DBIRu_Yl.js → triangle-alert-CvzZ7Dfq.js} +1 -1
  26. package/dist/client/index.html +13 -12
  27. package/dist/server.js +1659 -7059
  28. package/package.json +1 -1
  29. package/dist/client/assets/agent-CGU2xxEX.js +0 -2
  30. package/dist/client/assets/agent-CXAodtk6.js +0 -1
  31. package/dist/client/assets/browser-Big0jxfR.js +0 -2
  32. package/dist/client/assets/browser-DCBM0Y0g.js +0 -1
  33. package/dist/client/assets/button-DfUCUTxI.js +0 -16
  34. package/dist/client/assets/check-SxkDrjH-.js +0 -1
  35. package/dist/client/assets/composite-B4-E2IfK.js +0 -1
  36. package/dist/client/assets/dialog-DgrnySLb.js +0 -153
  37. package/dist/client/assets/diff-Ct5O0lZ0.js +0 -2
  38. package/dist/client/assets/index-DzI5lMF1.css +0 -2
  39. package/dist/client/assets/route-BlxnDll3.js +0 -2
  40. package/dist/client/assets/route-DVPqWkmA.js +0 -46
  41. package/dist/client/assets/run-BKul2xTf.js +0 -1
  42. package/dist/client/assets/run-DzoATG3-.js +0 -2
  43. package/dist/client/assets/state-BHj3zfmM.js +0 -2
  44. package/dist/client/assets/terminal-2Tn71jzR.js +0 -2
  45. package/dist/client/assets/terminal-B4yuHpYU.js +0 -119
  46. package/dist/client/assets/terminal-BB7jdQhY.js +0 -1
@@ -1,4 +1,4 @@
1
- import{n as e,o as t,r as n,t as r}from"./compiler-runtime-CUwoe8mk.js";import{Aa as i,Ba as a,Ea as o,Fa as s,Ga as c,H as l,Ha as u,Na as d,Oa as f,P as p,Qo as m,Ra as h,Ta as g,Tr as _,U as v,V as y,Wa as b,ao as x,ba as S,en as C,es as w,gn as T,ja as E,ka as D,t as O,vr as k,wa as ee,yr as te,z as ne}from"./button-DfUCUTxI.js";import{_ as re,a as ie,b as ae,c as oe,f as se,g as ce,h as le,i as ue,m as de,n as fe,o as pe,p as me,s as he,t as ge,u as _e,v as A,y as ve}from"./dialog-DgrnySLb.js";import{r as ye,t as be}from"./diff-Ct5O0lZ0.js";import{B as xe,F as Se,I as Ce,L as we,R as Te,V as Ee,z as De}from"./composite-B4-E2IfK.js";import{c as Oe,d as ke,f as Ae,l as je,o as j,p as Me,t as Ne,u as Pe}from"./state-BHj3zfmM.js";var Fe=w(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ie=w(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Le=w(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),Re=w(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),M=t(n(),1),ze=(0,M.createContext)(null);function Be(){return(0,M.useContext)(ze)?.defaultOptions??{}}function Ve(e){return typeof e==`object`&&!!e&&`current`in e}function N(){if(typeof navigator>`u`)return`linux`;let e=navigator.platform?.toLowerCase()??``,t=navigator.userAgent?.toLowerCase()??``;return e.includes(`mac`)||t.includes(`mac`)?`mac`:e.includes(`win`)||t.includes(`win`)?`windows`:`linux`}var He=[`Control`,`Alt`,`Shift`,`Meta`];new Set(He);var Ue={Control:`Control`,Ctrl:`Control`,control:`Control`,ctrl:`Control`,Shift:`Shift`,shift:`Shift`,Alt:`Alt`,Option:`Alt`,alt:`Alt`,option:`Alt`,Command:`Meta`,Cmd:`Meta`,Meta:`Meta`,command:`Meta`,cmd:`Meta`,meta:`Meta`,OS:`Meta`,os:`Meta`,Win:`Meta`,win:`Meta`,CommandOrControl:`Mod`,Mod:`Mod`,commandorcontrol:`Mod`,mod:`Mod`};function We(e,t=N()){return e===`Mod`?t===`mac`?`Meta`:`Control`:e}var Ge=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``)),Ke=new Set([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),qe=new Set([`F1`,`F2`,`F3`,`F4`,`F5`,`F6`,`F7`,`F8`,`F9`,`F10`,`F11`,`F12`]),Je=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`]),Ye=new Set([`Enter`,`Escape`,`Space`,`Tab`,`Backspace`,`Delete`]),Xe=new Set([`/`,`[`,`]`,`\\`,`=`,`-`,`,`,`.`,`;`,"`"]),Ze={Backquote:"`",Backslash:`\\`,BracketLeft:`[`,BracketRight:`]`,Comma:`,`,Equal:`=`,Minus:`-`,Period:`.`,Semicolon:`;`,Slash:`/`};new Set([...Ge,...Ke,...qe,...Je,...Ye,...Xe]);var Qe={Esc:`Escape`,esc:`Escape`,escape:`Escape`,Return:`Enter`,return:`Enter`,enter:`Enter`," ":`Space`,space:`Space`,Spacebar:`Space`,spacebar:`Space`,tab:`Tab`,backspace:`Backspace`,Del:`Delete`,del:`Delete`,delete:`Delete`,Up:`ArrowUp`,up:`ArrowUp`,arrowup:`ArrowUp`,Down:`ArrowDown`,down:`ArrowDown`,arrowdown:`ArrowDown`,Left:`ArrowLeft`,left:`ArrowLeft`,arrowleft:`ArrowLeft`,Right:`ArrowRight`,right:`ArrowRight`,arrowright:`ArrowRight`,home:`Home`,end:`End`,pageup:`PageUp`,pagedown:`PageDown`,PgUp:`PageUp`,PgDn:`PageDown`,pgup:`PageUp`,pgdn:`PageDown`};function $e(e){return/^\p{Letter}$/u.test(e)}function P(e){if(!e)return``;if(e in Qe)return Qe[e];if($e(e)){let t=e.toUpperCase();return t.length===1?t:e}let t=e.toUpperCase();return/^F([1-9]|1[0-2])$/.test(t)?t:e}function et(e,t=N()){let n=e.split(`+`),r=new Set,i=``;for(let e=0;e<n.length;e++){let a=n[e].trim();if(e===n.length-1)i=P(a);else{let e=Ue[a]??Ue[a.toLowerCase()];if(e){let n=We(e,t);r.add(n)}else n.length===1&&(i=P(a))}}return!i&&n.length>0&&(i=P(n[n.length-1].trim())),{key:i,ctrl:r.has(`Control`),shift:r.has(`Shift`),alt:r.has(`Alt`),meta:r.has(`Meta`),modifiers:He.filter(e=>r.has(e))}}function tt(e,t=N()){let n=e.ctrl??!1,r=e.shift??!1,i=e.alt??!1,a=e.meta??!1;e.mod&&(We(`Mod`,t)===`Control`?n=!0:a=!0);let o=He.filter(e=>{switch(e){case`Control`:return n;case`Shift`:return r;case`Alt`:return i;case`Meta`:return a;default:return!1}});return{key:e.key,ctrl:n,shift:r,alt:i,meta:a,modifiers:o}}function nt(e,t){let n=t===`mac`?e.meta&&!e.ctrl:e.ctrl&&!e.meta,r=[];if(n)r.push(`Mod`),e.alt&&r.push(`Alt`),e.shift&&r.push(`Shift`);else for(let t of He)e.modifiers.includes(t)&&r.push(t);return r.push(P(e.key)),r.join(`+`)}function rt(e,t=N()){return nt(et(e,t),t)}function it(e,t=N()){return nt(e,t)}function at(e,t=N()){return typeof e==`string`?rt(e,t):it(tt(e,t),t)}function ot(e){let t=[];for(let n of He)e.modifiers.includes(n)&&t.push(n);return t.push(e.key),t.join(`+`)}function st(e,t,n=N()){let r=typeof t==`string`?et(t,n):t;if(e.ctrlKey!==r.ctrl||e.shiftKey!==r.shift||e.altKey!==r.alt||e.metaKey!==r.meta)return!1;let i=P(e.key),a=r.key;if(i!==`Dead`&&i.length===1&&a.length===1){if(i.toUpperCase()===a.toUpperCase())return!0;if($e(i)&&(/^[A-Za-z]$/.test(i)||!e.altKey))return!1}if(e.code&&(i===`Dead`||i.length===1&&a.length===1)){if(e.code.startsWith(`Key`)){let t=e.code.slice(3);if(t.length===1&&/^[A-Za-z]$/.test(t))return t.toUpperCase()===a.toUpperCase()}if(e.code.startsWith(`Digit`)){let t=e.code.slice(5);if(t.length===1&&/^[0-9]$/.test(t))return t===a}return e.code in Ze?Ze[e.code]===a:!1}return i===a}var ct={preventDefault:!0,stopPropagation:!0,eventType:`keydown`,enabled:!0,ignoreInputs:!0,conflictBehavior:`warn`};function lt(e){return!(e.ctrl||e.meta||e.key===`Escape`)}function ut(e){if(!e)return!1;if(e instanceof HTMLInputElement){let t=e.type.toLowerCase();return!(t===`button`||t===`submit`||t===`reset`)}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function dt(e){return typeof document>`u`?null:typeof Document<`u`&&e instanceof Document||typeof Node<`u`&&e.nodeType===Node.DOCUMENT_NODE?e.activeElement:typeof HTMLElement<`u`&&e instanceof HTMLElement?e.ownerDocument.activeElement??null:e.document.activeElement??null}function ft(e,t,n){let r=dt(t);return r&&ut(r)&&r!==n||e.composedPath().some(e=>ut(e)&&e!==n)?!0:ut(e.target)&&e.target!==n}function pt(e,t){return t===document||t===window?e.currentTarget===t||e.currentTarget===document.documentElement:t===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(t instanceof HTMLElement&&(e.currentTarget===t||e.target instanceof Node&&t.contains(e.target)))}function mt(e,t,n,r){if(n!==`allow`){if(n===`warn`){console.warn(`'${t}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(n===`error`)throw Error(`'${t}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}var F=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function ht({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&(F.RecursedCheck|F.Recursed|F.Dirty|F.Pending)?a&(F.RecursedCheck|F.Recursed)?a&F.RecursedCheck?!(a&(F.Dirty|F.Pending))&&c(e,i)?(i.flags=a|(F.Recursed|F.Pending),a&=F.Mutable):a=F.None:i.flags=a&~F.Recursed|F.Pending:a=F.None:i.flags=a|F.Pending,a&F.Watching&&t(i),a&F.Mutable){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&F.Dirty)a=!0;else if((c&(F.Mutable|F.Dirty))===(F.Mutable|F.Dirty)){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&(F.Mutable|F.Pending))===(F.Mutable|F.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=~F.Pending;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&(F.Pending|F.Dirty))===F.Pending&&(n.flags=r|F.Dirty,(r&(F.Watching|F.RecursedCheck))===F.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function gt(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var _t=[],vt=0,{link:yt,unlink:bt,propagate:xt,checkDirty:St,shallowPropagate:Ct}=ht({update(e){return e._update()},notify(e){_t[Tt++]=e,e.flags&=~F.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=F.Mutable|F.Dirty,Dt(e))}}),wt=0,Tt=0,I,Et=0;function Dt(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=bt(n,e)}function Ot(){if(!(Et>0)){for(;wt<Tt;){let e=_t[wt];_t[wt++]=void 0,e.notify()}wt=0,Tt=0}}function kt(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?F.None:F.Mutable,get(){return I!==void 0&&yt(i,I,vt),i._snapshot},subscribe(e){let t=gt(e),n={current:!1},r=At(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=I,o=t?.compare??Object.is;if(n)I=i,++vt,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=F.Mutable|F.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{I=a,n&&(i.flags&=~F.RecursedCheck),Dt(i)}}};return n?(i.flags=F.Mutable|F.Dirty,i.get=function(){let e=i.flags;if(e&F.Dirty||e&F.Pending&&St(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Ct(e)}}else e&F.Pending&&(i.flags=e&~F.Pending);return I!==void 0&&yt(i,I,vt),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(xt(e),Ct(e),Ot())}},i}function At(e){let t=()=>{let t=I;I=n,++vt,n.depsTail=void 0,n.flags=F.Watching|F.RecursedCheck;try{return e()}finally{I=t,n.flags&=~F.RecursedCheck,Dt(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:F.Watching|F.RecursedCheck,notify(){let e=this.flags;e&F.Dirty||e&F.Pending&&St(this.deps,this)?t():this.flags=F.Watching},stop(){this.flags=F.None,this.depsTail=void 0,Dt(this)}};return t(),n}var jt=class{constructor(e,t){this.atom=kt(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(gt(e))}},Mt=0;function Nt(){return`hotkey_${++Mt}`}var Pt=class e{static#e=null;#t;#n=new Map;#r=new Map;constructor(){this.registrations=new jt(new Map),this.#t=N()}static getInstance(){return e.#e||=new e,e.#e}static resetInstance(){e.#e&&=(e.#e.destroy(),null)}register(e,t,n={}){if(typeof document>`u`&&!n.target){let e=t;return{id:Nt(),unregister:()=>{},get callback(){return e},set callback(t){e=t},setOptions:()=>{},get isActive(){return!1}}}let r=Nt(),i=n.platform??this.#t,a=typeof e==`string`?et(e,i):tt(e,i),o=typeof e==`string`?e:ot(a),s=n.target??document,c=n.conflictBehavior??`warn`,l=this.#d(o,s);l&&mt(l.id,o,c,e=>this.#i(e));let u=n.ignoreInputs??lt(a),d={id:r,hotkey:o,parsedHotkey:a,callback:t,options:{...ct,requireReset:!1,...n,platform:i,ignoreInputs:u},hasFired:!1,triggerCount:0,target:s};this.registrations.setState(e=>new Map(e).set(r,d)),this.#r.has(s)||this.#r.set(s,new Set),this.#r.get(s).add(r),this.#a(s);let f=this;return{get id(){return r},unregister:()=>{f.#i(r)},get callback(){return f.registrations.state.get(r)?.callback??t},set callback(e){let t=f.registrations.state.get(r);t&&(t.callback=e)},setOptions:e=>{f.registrations.setState(t=>{let n=t.get(r);if(n){let i=new Map(t);return i.set(r,{...n,options:{...n.options,...e}}),i}return t})},get isActive(){return f.registrations.state.has(r)}}}#i(e){let t=this.registrations.state.get(e);if(!t)return;let n=t.target;this.registrations.setState(t=>{let n=new Map(t);return n.delete(e),n});let r=this.#r.get(n);r&&(r.delete(e),r.size===0&&this.#o(n))}#a(e){if(typeof document>`u`||this.#n.has(e))return;let t=this.#l(e),n=this.#u(e);e.addEventListener(`keydown`,t),e.addEventListener(`keyup`,n),this.#n.set(e,{keydown:t,keyup:n})}#o(e){if(typeof document>`u`)return;let t=this.#n.get(e);t&&(e.removeEventListener(`keydown`,t.keydown),e.removeEventListener(`keyup`,t.keyup),this.#n.delete(e),this.#r.delete(e))}#s(e,t,n){let r=this.#r.get(t);if(r)for(let i of r){let r=this.registrations.state.get(i);if(r&&pt(e,t)&&r.options.enabled&&!(r.options.ignoreInputs!==!1&&ft(e,t,r.target)))if(n===`keydown`){if(r.options.eventType!==`keydown`)continue;st(e,r.parsedHotkey,r.options.platform)&&(r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation(),(!r.options.requireReset||!r.hasFired)&&(this.#c(r,e),r.options.requireReset&&(r.hasFired=!0)))}else r.options.eventType===`keyup`&&st(e,r.parsedHotkey,r.options.platform)&&this.#c(r,e),r.options.requireReset&&r.hasFired&&this.#f(r,e)&&(r.hasFired=!1)}}#c(e,t){e.options.preventDefault&&t.preventDefault(),e.options.stopPropagation&&t.stopPropagation(),e.triggerCount++,this.registrations.setState(e=>new Map(e));let n={hotkey:e.hotkey,parsedHotkey:e.parsedHotkey};e.callback(t,n)}#l(e){return t=>{this.#s(t,e,`keydown`)}}#u(e){return t=>{this.#s(t,e,`keyup`)}}#d(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&n.target===t)return n;return null}#f(e,t){let n=e.parsedHotkey,r=P(t.key),i=n.key.length===1?n.key.toUpperCase():n.key;return!!((r.length===1?r.toUpperCase():r)===i||n.ctrl&&r===`Control`||n.shift&&r===`Shift`||n.alt&&r===`Alt`||n.meta&&r===`Meta`)}triggerRegistration(e){let t=this.registrations.state.get(e);if(!t)return!1;let n=t.parsedHotkey,r=new KeyboardEvent(t.options.eventType??`keydown`,{key:n.key,ctrlKey:n.ctrl,shiftKey:n.shift,altKey:n.alt,metaKey:n.meta,bubbles:!0,cancelable:!0});return t.triggerCount++,this.registrations.setState(e=>new Map(e)),t.callback(r,{hotkey:t.hotkey,parsedHotkey:t.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&(t===void 0||n.target===t))return!0;return!1}destroy(){for(let e of this.#n.keys())this.#o(e);this.registrations.setState(()=>new Map),this.#n.clear(),this.#r.clear()}};function Ft(){return Pt.getInstance()}function It(e,t,n={}){let r={...Be().hotkey,...n},i=Ft(),a=(0,M.useRef)(null),o=(0,M.useRef)(t),s=(0,M.useRef)(r),c=(0,M.useRef)(i);o.current=t,s.current=r,c.current=i;let l=(0,M.useRef)(null),u=(0,M.useRef)(null),d=at(e,r.platform??N()),{target:f,...p}=r;(0,M.useEffect)(()=>{let e=Ve(s.current.target)?s.current.target.current:s.current.target??(typeof document<`u`?document:null);if(!e){a.current?.isActive&&(a.current.unregister(),a.current=null),l.current=null,u.current=null;return}let t=l.current!==null&&l.current!==e,n=u.current!==null&&u.current!==d;return a.current?.isActive&&(t||n)&&(a.current.unregister(),a.current=null),(!a.current||!a.current.isActive)&&(a.current=c.current.register(d,o.current,{...s.current,target:e})),l.current=e,u.current=d,()=>{a.current?.isActive&&(a.current.unregister(),a.current=null)}},[d]),a.current?.isActive&&(a.current.callback=t,a.current.setOptions(p))}var Lt=`diffs-container`;(()=>{try{return!1}catch{return!1}})();var Rt=/(?=^From [a-f0-9]+ .+$)/m,zt=/(?=^diff --git)/gm,Bt=/(?=^---\s+\S)/gm,Vt=/(?<=\n)/,Ht=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Ut=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Wt=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Gt=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Kt=`header-prefix`,qt=`header-metadata`,Jt=`header-custom`,L={dark:`pierre-dark`,light:`pierre-light`},Yt=`data-theme-css`,Xt=`data-unsafe-css`,Zt=`data-diffs-scrollbar-measure`,Qt=`--diffs-scrollbar-gutter-measured`,$t=1e5,en={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8};({...en});var tn=Object.freeze({fromStart:0,fromEnd:0}),nn={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},rn={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0};function R(e){return e.replace(/\n$|\r\n$/,``)}var an=new TextEncoder,on=new TextDecoder(`utf-8`,{ignoreBOM:!0}),sn=/[\uD800-\uDFFF]/,cn=1024,ln=new Uint8Array(cn);function un(){ln.length!==cn&&(ln=new Uint8Array(cn))}function z(e){if(e.length===0)return e;if(sn.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;ln.length<t&&(ln=new Uint8Array(t));let{written:n}=an.encodeInto(e,ln);return on.decode(ln.subarray(0,n))}function dn(e,t,n){try{return fn(e,t,n)}finally{un()}}function fn(e,t,n=!1){let r=Sn(e),i=r?Cn(e,`diff --git`):e.split(Bt),a,o=[];for(let e of i){if(r&&!zt.test(e)){if(a==null)a=z(e);else if(n)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}else if(!r&&!Bt.test(e)){if(a==null)a=z(e);else if(n)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}let i=mn(e,{cacheKey:t==null?void 0:`${t}-${o.length}`,isGitDiff:r,throwOnError:n});i!=null&&o.push(i)}return{patchMetadata:a,files:o}}function pn(e,t){try{return mn(e,t)}finally{un()}}function mn(e,{cacheKey:t,isGitDiff:n=zt.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=Cn(e,`@@ `),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=vn(e),f=s[0];if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=yn(f),m=0,h=0;if(p==null||c==null){if(c!=null){if(a)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}c={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:l,additionLines:!l&&r!=null&&i!=null?_n(i.contents):[],deletionLines:!l&&r!=null&&i!=null?_n(r.contents):[],cacheKey:Tn(t)},c.additionLines.length===1&&i?.contents===``&&(c.additionLines.length=0),c.deletionLines.length===1&&r?.contents===``&&(c.deletionLines.length=0);for(let e of s){if(e.startsWith(`diff --git`)){let t=e.trim().match(Wt),n=t?.[1]??t?.[2],r=t?.[3]??t?.[4];if(n==null||r==null){if(a)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}c.name=z(r.trim()),n!==r&&(c.prevName=z(n.trim()));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(n?Ut:Ht):null;if(t!=null){let[,e,n]=t;if(e===`---`&&n!==`/dev/null`){let e=z(n.trim());c.prevName=e,c.name=e}else e===`+++`&&n!==`/dev/null`&&(c.name=z(n.trim()))}else if(n){if(e.startsWith(`new mode `)&&(c.mode=z(e.slice(8).trim())),e.startsWith(`old mode `)&&(c.prevMode=z(e.slice(8).trim())),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=z(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=z(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?c.type=`rename-pure`:c.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(Gt)??[];t!=null&&(c.prevObjectId=z(t)),n!=null&&(c.newObjectId=z(n)),r!=null&&(c.mode=z(r))}e.startsWith(`rename from `)&&(c.prevName=z(e.slice(12).trim())),e.startsWith(`rename to `)&&(c.name=z(e.slice(10).trim()))}}continue}let g,_;for(;s.length>0&&(s[s.length-1]===`
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-CUwoe8mk.js";import{$o as i,$t as a,Aa as o,Ba as s,Ca as c,Da as l,Fa as u,Ga as d,H as f,Ha as p,Na as m,Oa as h,P as g,Ra as _,Ta as v,U as y,V as b,Wa as x,_r as S,hn as C,ka as w,oo as T,t as E,ts as D,vr as ee,wa as O,wr as te,ya as k,z as ne}from"./button-Bqawukg7.js";import{_ as re,a as ie,b as ae,c as oe,f as se,g as ce,h as le,i as ue,m as de,n as fe,o as pe,p as me,s as he,t as ge,u as _e,v as A,y as ve}from"./dialog-PAzkmCTH.js";import{r as ye,t as be}from"./diff-gY3qhzPv.js";import{B as xe,F as Se,I as Ce,L as we,R as Te,V as Ee,z as De}from"./composite-DXpCs7eA.js";import{c as j,d as Oe,f as ke,g as Ae,h as je,m as Me,p as Ne,t as Pe}from"./state-nIOT1NpG.js";var Fe=D(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ie=D(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Le=D(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),Re=D(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),M=t(n(),1),ze=(0,M.createContext)(null);function Be(){return(0,M.useContext)(ze)?.defaultOptions??{}}function Ve(e){return typeof e==`object`&&!!e&&`current`in e}function N(){if(typeof navigator>`u`)return`linux`;let e=navigator.platform?.toLowerCase()??``,t=navigator.userAgent?.toLowerCase()??``;return e.includes(`mac`)||t.includes(`mac`)?`mac`:e.includes(`win`)||t.includes(`win`)?`windows`:`linux`}var He=[`Control`,`Alt`,`Shift`,`Meta`];new Set(He);var Ue={Control:`Control`,Ctrl:`Control`,control:`Control`,ctrl:`Control`,Shift:`Shift`,shift:`Shift`,Alt:`Alt`,Option:`Alt`,alt:`Alt`,option:`Alt`,Command:`Meta`,Cmd:`Meta`,Meta:`Meta`,command:`Meta`,cmd:`Meta`,meta:`Meta`,OS:`Meta`,os:`Meta`,Win:`Meta`,win:`Meta`,CommandOrControl:`Mod`,Mod:`Mod`,commandorcontrol:`Mod`,mod:`Mod`};function We(e,t=N()){return e===`Mod`?t===`mac`?`Meta`:`Control`:e}var Ge=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``)),Ke=new Set([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),qe=new Set([`F1`,`F2`,`F3`,`F4`,`F5`,`F6`,`F7`,`F8`,`F9`,`F10`,`F11`,`F12`]),Je=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`]),Ye=new Set([`Enter`,`Escape`,`Space`,`Tab`,`Backspace`,`Delete`]),Xe=new Set([`/`,`[`,`]`,`\\`,`=`,`-`,`,`,`.`,`;`,"`"]),Ze={Backquote:"`",Backslash:`\\`,BracketLeft:`[`,BracketRight:`]`,Comma:`,`,Equal:`=`,Minus:`-`,Period:`.`,Semicolon:`;`,Slash:`/`};new Set([...Ge,...Ke,...qe,...Je,...Ye,...Xe]);var Qe={Esc:`Escape`,esc:`Escape`,escape:`Escape`,Return:`Enter`,return:`Enter`,enter:`Enter`," ":`Space`,space:`Space`,Spacebar:`Space`,spacebar:`Space`,tab:`Tab`,backspace:`Backspace`,Del:`Delete`,del:`Delete`,delete:`Delete`,Up:`ArrowUp`,up:`ArrowUp`,arrowup:`ArrowUp`,Down:`ArrowDown`,down:`ArrowDown`,arrowdown:`ArrowDown`,Left:`ArrowLeft`,left:`ArrowLeft`,arrowleft:`ArrowLeft`,Right:`ArrowRight`,right:`ArrowRight`,arrowright:`ArrowRight`,home:`Home`,end:`End`,pageup:`PageUp`,pagedown:`PageDown`,PgUp:`PageUp`,PgDn:`PageDown`,pgup:`PageUp`,pgdn:`PageDown`};function $e(e){return/^\p{Letter}$/u.test(e)}function P(e){if(!e)return``;if(e in Qe)return Qe[e];if($e(e)){let t=e.toUpperCase();return t.length===1?t:e}let t=e.toUpperCase();return/^F([1-9]|1[0-2])$/.test(t)?t:e}function et(e,t=N()){let n=e.split(`+`),r=new Set,i=``;for(let e=0;e<n.length;e++){let a=n[e].trim();if(e===n.length-1)i=P(a);else{let e=Ue[a]??Ue[a.toLowerCase()];if(e){let n=We(e,t);r.add(n)}else n.length===1&&(i=P(a))}}return!i&&n.length>0&&(i=P(n[n.length-1].trim())),{key:i,ctrl:r.has(`Control`),shift:r.has(`Shift`),alt:r.has(`Alt`),meta:r.has(`Meta`),modifiers:He.filter(e=>r.has(e))}}function tt(e,t=N()){let n=e.ctrl??!1,r=e.shift??!1,i=e.alt??!1,a=e.meta??!1;e.mod&&(We(`Mod`,t)===`Control`?n=!0:a=!0);let o=He.filter(e=>{switch(e){case`Control`:return n;case`Shift`:return r;case`Alt`:return i;case`Meta`:return a;default:return!1}});return{key:e.key,ctrl:n,shift:r,alt:i,meta:a,modifiers:o}}function nt(e,t){let n=t===`mac`?e.meta&&!e.ctrl:e.ctrl&&!e.meta,r=[];if(n)r.push(`Mod`),e.alt&&r.push(`Alt`),e.shift&&r.push(`Shift`);else for(let t of He)e.modifiers.includes(t)&&r.push(t);return r.push(P(e.key)),r.join(`+`)}function rt(e,t=N()){return nt(et(e,t),t)}function it(e,t=N()){return nt(e,t)}function at(e,t=N()){return typeof e==`string`?rt(e,t):it(tt(e,t),t)}function ot(e){let t=[];for(let n of He)e.modifiers.includes(n)&&t.push(n);return t.push(e.key),t.join(`+`)}function st(e,t,n=N()){let r=typeof t==`string`?et(t,n):t;if(e.ctrlKey!==r.ctrl||e.shiftKey!==r.shift||e.altKey!==r.alt||e.metaKey!==r.meta)return!1;let i=P(e.key),a=r.key;if(i!==`Dead`&&i.length===1&&a.length===1){if(i.toUpperCase()===a.toUpperCase())return!0;if($e(i)&&(/^[A-Za-z]$/.test(i)||!e.altKey))return!1}if(e.code&&(i===`Dead`||i.length===1&&a.length===1)){if(e.code.startsWith(`Key`)){let t=e.code.slice(3);if(t.length===1&&/^[A-Za-z]$/.test(t))return t.toUpperCase()===a.toUpperCase()}if(e.code.startsWith(`Digit`)){let t=e.code.slice(5);if(t.length===1&&/^[0-9]$/.test(t))return t===a}return e.code in Ze?Ze[e.code]===a:!1}return i===a}var ct={preventDefault:!0,stopPropagation:!0,eventType:`keydown`,enabled:!0,ignoreInputs:!0,conflictBehavior:`warn`};function lt(e){return!(e.ctrl||e.meta||e.key===`Escape`)}function ut(e){if(!e)return!1;if(e instanceof HTMLInputElement){let t=e.type.toLowerCase();return!(t===`button`||t===`submit`||t===`reset`)}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function dt(e){return typeof document>`u`?null:typeof Document<`u`&&e instanceof Document||typeof Node<`u`&&e.nodeType===Node.DOCUMENT_NODE?e.activeElement:typeof HTMLElement<`u`&&e instanceof HTMLElement?e.ownerDocument.activeElement??null:e.document.activeElement??null}function ft(e,t,n){let r=dt(t);return r&&ut(r)&&r!==n||e.composedPath().some(e=>ut(e)&&e!==n)?!0:ut(e.target)&&e.target!==n}function pt(e,t){return t===document||t===window?e.currentTarget===t||e.currentTarget===document.documentElement:t===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(t instanceof HTMLElement&&(e.currentTarget===t||e.target instanceof Node&&t.contains(e.target)))}function mt(e,t,n,r){if(n!==`allow`){if(n===`warn`){console.warn(`'${t}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(n===`error`)throw Error(`'${t}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}var F=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function ht({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&(F.RecursedCheck|F.Recursed|F.Dirty|F.Pending)?a&(F.RecursedCheck|F.Recursed)?a&F.RecursedCheck?!(a&(F.Dirty|F.Pending))&&c(e,i)?(i.flags=a|(F.Recursed|F.Pending),a&=F.Mutable):a=F.None:i.flags=a&~F.Recursed|F.Pending:a=F.None:i.flags=a|F.Pending,a&F.Watching&&t(i),a&F.Mutable){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&F.Dirty)a=!0;else if((c&(F.Mutable|F.Dirty))===(F.Mutable|F.Dirty)){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&(F.Mutable|F.Pending))===(F.Mutable|F.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=~F.Pending;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&(F.Pending|F.Dirty))===F.Pending&&(n.flags=r|F.Dirty,(r&(F.Watching|F.RecursedCheck))===F.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function gt(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var _t=[],vt=0,{link:yt,unlink:bt,propagate:xt,checkDirty:St,shallowPropagate:Ct}=ht({update(e){return e._update()},notify(e){_t[Tt++]=e,e.flags&=~F.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=F.Mutable|F.Dirty,Dt(e))}}),wt=0,Tt=0,I,Et=0;function Dt(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=bt(n,e)}function Ot(){if(!(Et>0)){for(;wt<Tt;){let e=_t[wt];_t[wt++]=void 0,e.notify()}wt=0,Tt=0}}function kt(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?F.None:F.Mutable,get(){return I!==void 0&&yt(i,I,vt),i._snapshot},subscribe(e){let t=gt(e),n={current:!1},r=At(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=I,o=t?.compare??Object.is;if(n)I=i,++vt,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=F.Mutable|F.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{I=a,n&&(i.flags&=~F.RecursedCheck),Dt(i)}}};return n?(i.flags=F.Mutable|F.Dirty,i.get=function(){let e=i.flags;if(e&F.Dirty||e&F.Pending&&St(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Ct(e)}}else e&F.Pending&&(i.flags=e&~F.Pending);return I!==void 0&&yt(i,I,vt),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(xt(e),Ct(e),Ot())}},i}function At(e){let t=()=>{let t=I;I=n,++vt,n.depsTail=void 0,n.flags=F.Watching|F.RecursedCheck;try{return e()}finally{I=t,n.flags&=~F.RecursedCheck,Dt(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:F.Watching|F.RecursedCheck,notify(){let e=this.flags;e&F.Dirty||e&F.Pending&&St(this.deps,this)?t():this.flags=F.Watching},stop(){this.flags=F.None,this.depsTail=void 0,Dt(this)}};return t(),n}var jt=class{constructor(e,t){this.atom=kt(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(gt(e))}},Mt=0;function Nt(){return`hotkey_${++Mt}`}var Pt=class e{static#e=null;#t;#n=new Map;#r=new Map;constructor(){this.registrations=new jt(new Map),this.#t=N()}static getInstance(){return e.#e||=new e,e.#e}static resetInstance(){e.#e&&=(e.#e.destroy(),null)}register(e,t,n={}){if(typeof document>`u`&&!n.target){let e=t;return{id:Nt(),unregister:()=>{},get callback(){return e},set callback(t){e=t},setOptions:()=>{},get isActive(){return!1}}}let r=Nt(),i=n.platform??this.#t,a=typeof e==`string`?et(e,i):tt(e,i),o=typeof e==`string`?e:ot(a),s=n.target??document,c=n.conflictBehavior??`warn`,l=this.#d(o,s);l&&mt(l.id,o,c,e=>this.#i(e));let u=n.ignoreInputs??lt(a),d={id:r,hotkey:o,parsedHotkey:a,callback:t,options:{...ct,requireReset:!1,...n,platform:i,ignoreInputs:u},hasFired:!1,triggerCount:0,target:s};this.registrations.setState(e=>new Map(e).set(r,d)),this.#r.has(s)||this.#r.set(s,new Set),this.#r.get(s).add(r),this.#a(s);let f=this;return{get id(){return r},unregister:()=>{f.#i(r)},get callback(){return f.registrations.state.get(r)?.callback??t},set callback(e){let t=f.registrations.state.get(r);t&&(t.callback=e)},setOptions:e=>{f.registrations.setState(t=>{let n=t.get(r);if(n){let i=new Map(t);return i.set(r,{...n,options:{...n.options,...e}}),i}return t})},get isActive(){return f.registrations.state.has(r)}}}#i(e){let t=this.registrations.state.get(e);if(!t)return;let n=t.target;this.registrations.setState(t=>{let n=new Map(t);return n.delete(e),n});let r=this.#r.get(n);r&&(r.delete(e),r.size===0&&this.#o(n))}#a(e){if(typeof document>`u`||this.#n.has(e))return;let t=this.#l(e),n=this.#u(e);e.addEventListener(`keydown`,t),e.addEventListener(`keyup`,n),this.#n.set(e,{keydown:t,keyup:n})}#o(e){if(typeof document>`u`)return;let t=this.#n.get(e);t&&(e.removeEventListener(`keydown`,t.keydown),e.removeEventListener(`keyup`,t.keyup),this.#n.delete(e),this.#r.delete(e))}#s(e,t,n){let r=this.#r.get(t);if(r)for(let i of r){let r=this.registrations.state.get(i);if(r&&pt(e,t)&&r.options.enabled&&!(r.options.ignoreInputs!==!1&&ft(e,t,r.target)))if(n===`keydown`){if(r.options.eventType!==`keydown`)continue;st(e,r.parsedHotkey,r.options.platform)&&(r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation(),(!r.options.requireReset||!r.hasFired)&&(this.#c(r,e),r.options.requireReset&&(r.hasFired=!0)))}else r.options.eventType===`keyup`&&st(e,r.parsedHotkey,r.options.platform)&&this.#c(r,e),r.options.requireReset&&r.hasFired&&this.#f(r,e)&&(r.hasFired=!1)}}#c(e,t){e.options.preventDefault&&t.preventDefault(),e.options.stopPropagation&&t.stopPropagation(),e.triggerCount++,this.registrations.setState(e=>new Map(e));let n={hotkey:e.hotkey,parsedHotkey:e.parsedHotkey};e.callback(t,n)}#l(e){return t=>{this.#s(t,e,`keydown`)}}#u(e){return t=>{this.#s(t,e,`keyup`)}}#d(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&n.target===t)return n;return null}#f(e,t){let n=e.parsedHotkey,r=P(t.key),i=n.key.length===1?n.key.toUpperCase():n.key;return!!((r.length===1?r.toUpperCase():r)===i||n.ctrl&&r===`Control`||n.shift&&r===`Shift`||n.alt&&r===`Alt`||n.meta&&r===`Meta`)}triggerRegistration(e){let t=this.registrations.state.get(e);if(!t)return!1;let n=t.parsedHotkey,r=new KeyboardEvent(t.options.eventType??`keydown`,{key:n.key,ctrlKey:n.ctrl,shiftKey:n.shift,altKey:n.alt,metaKey:n.meta,bubbles:!0,cancelable:!0});return t.triggerCount++,this.registrations.setState(e=>new Map(e)),t.callback(r,{hotkey:t.hotkey,parsedHotkey:t.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&(t===void 0||n.target===t))return!0;return!1}destroy(){for(let e of this.#n.keys())this.#o(e);this.registrations.setState(()=>new Map),this.#n.clear(),this.#r.clear()}};function Ft(){return Pt.getInstance()}function It(e,t,n={}){let r={...Be().hotkey,...n},i=Ft(),a=(0,M.useRef)(null),o=(0,M.useRef)(t),s=(0,M.useRef)(r),c=(0,M.useRef)(i);o.current=t,s.current=r,c.current=i;let l=(0,M.useRef)(null),u=(0,M.useRef)(null),d=at(e,r.platform??N()),{target:f,...p}=r;(0,M.useEffect)(()=>{let e=Ve(s.current.target)?s.current.target.current:s.current.target??(typeof document<`u`?document:null);if(!e){a.current?.isActive&&(a.current.unregister(),a.current=null),l.current=null,u.current=null;return}let t=l.current!==null&&l.current!==e,n=u.current!==null&&u.current!==d;return a.current?.isActive&&(t||n)&&(a.current.unregister(),a.current=null),(!a.current||!a.current.isActive)&&(a.current=c.current.register(d,o.current,{...s.current,target:e})),l.current=e,u.current=d,()=>{a.current?.isActive&&(a.current.unregister(),a.current=null)}},[d]),a.current?.isActive&&(a.current.callback=t,a.current.setOptions(p))}var Lt=`diffs-container`;(()=>{try{return!1}catch{return!1}})();var Rt=/(?=^From [a-f0-9]+ .+$)/m,zt=/(?=^diff --git)/gm,Bt=/(?=^---\s+\S)/gm,Vt=/(?<=\n)/,Ht=/^(---|\+\+\+)\s+([^\t\r\n]+)/,Ut=/^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/,Wt=/^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/,Gt=/^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i,Kt=`header-prefix`,qt=`header-metadata`,Jt=`header-custom`,L={dark:`pierre-dark`,light:`pierre-light`},Yt=`data-theme-css`,Xt=`data-unsafe-css`,Zt=`data-diffs-scrollbar-measure`,Qt=`--diffs-scrollbar-gutter-measured`,$t=1e5,en={hunkLineCount:50,lineHeight:20,diffHeaderHeight:44,spacing:8};({...en});var tn=Object.freeze({fromStart:0,fromEnd:0}),nn={startingLine:0,totalLines:1/0,bufferBefore:0,bufferAfter:0},rn={startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:0};function R(e){return e.replace(/\n$|\r\n$/,``)}var an=new TextEncoder,on=new TextDecoder(`utf-8`,{ignoreBOM:!0}),sn=/[\uD800-\uDFFF]/,cn=1024,ln=new Uint8Array(cn);function un(){ln.length!==cn&&(ln=new Uint8Array(cn))}function z(e){if(e.length===0)return e;if(sn.test(e))return JSON.parse(JSON.stringify(e));let t=e.length*3;ln.length<t&&(ln=new Uint8Array(t));let{written:n}=an.encodeInto(e,ln);return on.decode(ln.subarray(0,n))}function dn(e,t,n){try{return fn(e,t,n)}finally{un()}}function fn(e,t,n=!1){let r=Sn(e),i=r?Cn(e,`diff --git`):e.split(Bt),a,o=[];for(let e of i){if(r&&!zt.test(e)){if(a==null)a=z(e);else if(n)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}else if(!r&&!Bt.test(e)){if(a==null)a=z(e);else if(n)throw Error(`parsePatchContent: unknown file blob`);else console.error(`parsePatchContent: unknown file blob:`,e);continue}let i=mn(e,{cacheKey:t==null?void 0:`${t}-${o.length}`,isGitDiff:r,throwOnError:n});i!=null&&o.push(i)}return{patchMetadata:a,files:o}}function pn(e,t){try{return mn(e,t)}finally{un()}}function mn(e,{cacheKey:t,isGitDiff:n=zt.test(e),oldFile:r,newFile:i,throwOnError:a=!1}={}){let o=0,s=Cn(e,`@@ `),c,l=r==null||i==null,u=0,d=0;for(let e of s){let s=vn(e),f=s[0];if(f==null){if(a)throw Error(`parsePatchContent: invalid hunk`);console.error(`parsePatchContent: invalid hunk`,e);continue}let p=yn(f),m=0,h=0;if(p==null||c==null){if(c!=null){if(a)throw Error(`parsePatchContent: Invalid hunk`);console.error(`parsePatchContent: Invalid hunk`,e);continue}c={name:``,type:`change`,hunks:[],splitLineCount:0,unifiedLineCount:0,isPartial:l,additionLines:!l&&r!=null&&i!=null?_n(i.contents):[],deletionLines:!l&&r!=null&&i!=null?_n(r.contents):[],cacheKey:Tn(t)},c.additionLines.length===1&&i?.contents===``&&(c.additionLines.length=0),c.deletionLines.length===1&&r?.contents===``&&(c.deletionLines.length=0);for(let e of s){if(e.startsWith(`diff --git`)){let t=e.trim().match(Wt),n=t?.[1]??t?.[2],r=t?.[3]??t?.[4];if(n==null||r==null){if(a)throw Error(`parsePatchContent: invalid git diff header`);console.error(`parsePatchContent: invalid git diff header`,e);continue}c.name=z(r.trim()),n!==r&&(c.prevName=z(n.trim()));continue}let t=e.startsWith(`---`)||e.startsWith(`+++`)?e.match(n?Ut:Ht):null;if(t!=null){let[,e,n]=t;if(e===`---`&&n!==`/dev/null`){let e=z(n.trim());c.prevName=e,c.name=e}else e===`+++`&&n!==`/dev/null`&&(c.name=z(n.trim()))}else if(n){if(e.startsWith(`new mode `)&&(c.mode=z(e.slice(8).trim())),e.startsWith(`old mode `)&&(c.prevMode=z(e.slice(8).trim())),e.startsWith(`new file mode`)&&(c.type=`new`,c.mode=z(e.slice(13).trim())),e.startsWith(`deleted file mode`)&&(c.type=`deleted`,c.mode=z(e.slice(17).trim())),e.startsWith(`similarity index`)&&(e.startsWith(`similarity index 100%`)?c.type=`rename-pure`:c.type=`rename-changed`),e.startsWith(`index `)){let[,t,n,r]=e.trim().match(Gt)??[];t!=null&&(c.prevObjectId=z(t)),n!=null&&(c.newObjectId=z(n)),r!=null&&(c.mode=z(r))}e.startsWith(`rename from `)&&(c.prevName=z(e.slice(12).trim())),e.startsWith(`rename to `)&&(c.name=z(e.slice(10).trim()))}}continue}let g,_;for(;s.length>0&&(s[s.length-1]===`
2
2
  `||s[s.length-1]===`\r`||s[s.length-1]===`\r
3
3
  `||s[s.length-1]===``);)s.pop();let{additionStart:v,deletionStart:y}=p;u=l?u:y-1,d=l?d:v-1;let b={collapsedBefore:0,splitLineCount:0,splitLineStart:0,unifiedLineCount:0,unifiedLineStart:0,additionCount:p.additionCount,additionStart:v,additionLines:m,deletionCount:p.deletionCount,deletionStart:y,deletionLines:h,deletionLineIndex:u,additionLineIndex:d,hunkContent:[],hunkContext:Tn(p.hunkContext),hunkSpecs:z(f),noEOFCRAdditions:!1,noEOFCRDeletions:!1},x=0,S=0;for(let e=1;e<s.length;e++){let t=s[e];if(x>=b.additionCount&&S>=b.deletionCount&&!t.startsWith(`\\`))break;let n=t[0];if(n!==`+`&&n!==`-`&&n!==` `&&n!==`\\`){console.error(`parseLineType: Invalid firstChar: "${n}", full line: "${t}"`),console.error(`processFile: invalid rawLine:`,t);continue}let r=En(n);if(r===`addition`){let e=Dn(t);(g==null||g.type!==`change`)&&(g=On(`change`,u,d),b.hunkContent.push(g)),d++,x++,l&&c.additionLines.push(e),g.additions++,m++,_=`addition`}else if(r===`deletion`){let e=Dn(t);(g==null||g.type!==`change`)&&(g=On(`change`,u,d),b.hunkContent.push(g)),u++,S++,l&&c.deletionLines.push(e),g.deletions++,h++,_=`deletion`}else if(r===`context`){let e=Dn(t);(g==null||g.type!==`context`)&&(g=On(`context`,u,d),b.hunkContent.push(g)),d++,u++,x++,S++,l&&(c.deletionLines.push(e),c.additionLines.push(e)),g.lines++,_=`context`}else if(r===`metadata`&&g!=null){if(g.type===`context`?(b.noEOFCRAdditions=!0,b.noEOFCRDeletions=!0):_===`deletion`?b.noEOFCRDeletions=!0:_===`addition`&&(b.noEOFCRAdditions=!0),l&&(_===`addition`||_===`context`)){let e=c.additionLines.length-1;e>=0&&(c.additionLines[e]=R(c.additionLines[e]))}if(l&&(_===`deletion`||_===`context`)){let e=c.deletionLines.length-1;e>=0&&(c.deletionLines[e]=R(c.deletionLines[e]))}}}b.additionLines=m,b.deletionLines=h,b.collapsedBefore=Math.max(b.additionStart-1-o,0),c.hunks.push(b),o=b.additionStart+b.additionCount-1;for(let e of b.hunkContent)e.type===`context`?(b.splitLineCount+=e.lines,b.unifiedLineCount+=e.lines):(b.splitLineCount+=Math.max(e.additions,e.deletions),b.unifiedLineCount+=e.deletions+e.additions);b.splitLineStart=c.splitLineCount+b.collapsedBefore,b.unifiedLineStart=c.unifiedLineCount+b.collapsedBefore,c.splitLineCount+=b.collapsedBefore+b.splitLineCount,c.unifiedLineCount+=b.collapsedBefore+b.unifiedLineCount}if(c!=null){if(c.hunks.length>0&&!l&&c.additionLines.length>0&&c.deletionLines.length>0){let e=c.hunks[c.hunks.length-1],t=e.additionStart+e.additionCount-1,n=c.additionLines.length,r=Math.max(n-t,0);c.splitLineCount+=r,c.unifiedLineCount+=r}return n||(c.prevName!=null&&c.name!==c.prevName?c.hunks.length>0?c.type=`rename-changed`:c.type=`rename-pure`:(r==null||r.contents===``)&&i!=null&&i.contents!==``?c.type=`new`:r!=null&&r.contents!==``&&(i==null||i.contents===``)&&(c.type=`deleted`)),c.type!==`rename-pure`&&c.type!==`rename-changed`&&(c.prevName=void 0),c}}function hn(e,t,n=!1){let r=[],i=gn(e)?e.split(Rt):[e];for(let e of i)try{r.push(dn(e,t==null?void 0:`${t}-${r.length}`,n))}catch(e){if(n)throw e;console.error(e)}return r}function gn(e){return e.startsWith(`From `)||e.includes(`
4
4
  From `)}function _n(e){let t=vn(e);for(let e=0;e<t.length;e++)t[e]=z(t[e]);return t}function vn(e){if(e.length===0)return[``];let t=[],n=0;for(;;){let r=e.indexOf(`
@@ -71,7 +71,7 @@ diff --git`)}function Cn(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.star
71
71
  ${mi(n)}
72
72
  ${e}
73
73
  }
74
- }`}function bi(e,t){let n=mi(t);return e.replace(_i,n)}function xi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Si(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:e?.useTokenTransformer,tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function Ci({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function wi({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=Ti(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function Ti(){let e=document.createElement(`style`);return e.setAttribute(Yt,``),e}function Ei(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function Di(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`);break}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.tabIndex=0,e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(hi)),t.adoptedStyleSheets=[e]}connectedCallback(){pi(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(Lt,t)}var Oi=[],ki=-1,Ai=class{static LoadedCustomComponent=!0;__id=`file:${++ki}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;constructor(e={theme:L},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new ni(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new dr,this.interactionManager=new qn(`file`,Jn(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Jn(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ln(this.appliedThemeCSS.theme,this.options.theme??L)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e===`wrap`),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,this.lineAnnotations=[],this.annotationCache.clear(),this.pre=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;this.hydrateElements(t,n),ji(this.pre,i,this.options.collapsed)||Mi(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ei(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Si(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e==null?Oi:this.fileRenderer.getOrCreateLineCache(e)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){let{collapsed:c=!1,themeType:l=`system`}=this.options;if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);let u=c?void 0:s,d=this.renderRange,f=this.hasThemeChanged(),p=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,m=!q(this.file,e);if(!c&&!n&&gr(u,this.renderRange)&&!m&&!p&&!f)return this.applyCachedThemeState(l);this.renderRange=u,m&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(Si(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:h=!1,disableFileHeader:g=!1}=this.options;if(g&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(l),c){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,rn);n!=null&&this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,p,m||f)||!this.applyPartialRender(d,u)){let n=this.fileRenderer.renderFile(e,u);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,u),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}primeHighlightCache(){let{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||yr(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${B(r)}`,a=this.annotationCache.get(i);if(a==null||!ai(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:li(B(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=ui();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=di(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=vi(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??L,s=typeof o==`string`?o:{...o},c=pi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=wi({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:yi(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=bi(this.themeCSSStyle.textContent??``,pi(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=Ci({code:this.code}),this.code.innerHTML=this.fileRenderer.renderPartialHTML(this.fileRenderer.renderCodeAST(e)),t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l||!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))return!1;let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){let{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??A(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:i,renderCustomHeader:a,renderHeaderMetadata:o}=this.options;if(a!=null){let e=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Jt,e),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0}else{let e=i?.(n)??void 0,r=o?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Kt,e),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,qt,r),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:Bn(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):Bn(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=ii;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};oi(i,this.appliedPreAttributes)||(Di(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function ji(e,t,n=!1){return!n&&e==null&&t!=null}function Mi(e,t,n=!1){return e==null&&t!=null&&!n}function Ni(e){return{...en,...e}}function X(e,t){let n=Pi(e,t);return t?n:e.diffHeaderHeight+n}function Pi(e,t){return e.paddingTop??(t?e.spacing:0)}function Fi(e){return e.paddingBottom??e.spacing}function Ii(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}var Li=5e3,Ri=-1;function zi(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var Bi=class extends Ai{__id=`virtualized-file:${++Ri}`;top;height=0;cache={heights:new Map,checkpoints:[]};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=en,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){!t&&In(this.metrics,e)||(this.metrics=e,this.resetLayoutCache())}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Rn(t,e),r=zi(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1){this.layoutDirty=!0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n){let r=n?.resetFileLayoutCache===!0;n?.metrics!=null&&(this.metrics=n.metrics,r=!0);let{collapsed:i=!1}=this.options;return this.currentCollapsed!==i&&(this.currentCollapsed=i,r=!0),r&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=Vi(this.getOrCreateLineCache(this.file)),i=X(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(o===`scroll`&&this.lineAnnotations.length===0)return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=Vi(this.getOrCreateLineCache(this.file));if(i<0)return;let a=X(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;if(r===`scroll`&&this.lineAnnotations.length===0){let{lineHeight:t}=this.metrics,n=a+this.renderRange.bufferBefore,r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+r*t}}let c=a+this.renderRange.bufferBefore;for(let t=o;t<=s;t++){if(c>=e)return{lineNumber:t+1,top:c};c+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t;return{topOffset:this.top+n+(i===0?r:0),height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.layoutDirty=!0),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1){let t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;let n=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}let{disableFileHeader:r=!1,collapsed:i=!1,overflow:a=`scroll`}=this.options,{lineHeight:o}=this.metrics,s=this.getOrCreateLineCache(this.file),c=X(this.metrics,r),l=Fi(this.metrics);if(this.height+=c,i){this.layoutDirty=!1;return}if(a===`scroll`&&this.lineAnnotations.length===0?this.height+=this.getOrCreateLineCache(this.file).length*o:br({lines:s,callback:({lineIndex:e})=>{this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1)}}),s.length>0&&(this.height+=l),this.fileContainer!=null&&t&&!n){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:this.file.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}render({fileContainer:e,file:t,forceRender:n=!1,...r}){let{forceRenderOverride:i,isSetup:a}=this;if(this.forceRenderOverride=void 0,this.file??=t,e=this.getOrCreateFileContainerNode(e),this.file==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(a)this.top??=this.getVirtualizedTop();else{this.computeApproximateSize();let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);let o=this.virtualizer.getWindowSpecs(),s=this.top??0,c=this.computeRenderRangeFromWindow(this.file,s,o);return super.render({file:this.file,fileContainer:e,renderRange:c,forceRender:i??n,...r})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%Li===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.getOrCreateLineCache(e),l=c.length,u=this.height,d=X(this.metrics,i),f=l>0?Fi(this.metrics):0;if(t<n-u||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:u-d-f};if(l<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let p=Math.ceil(Math.max(r-n,0)/s),m=Math.ceil(p/o)*o+o*2,h=m/o,g=(n+r)/2;if(a===`scroll`&&this.lineAnnotations.length===0){let e=Math.floor((g-(t+d))/s),n=Math.floor(e/o)-Math.floor(h/2),r=Math.ceil(l/o),i=Math.max(0,Math.min(n,r))*o,a=n<0?m+n*o:m,c=i*s,u=Math.min(a,l-i);return{startingLine:i,totalLines:a,bufferBefore:c,bufferAfter:Math.max(0,(l-i-u)*s)}}let _=h,v=[],y=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-m*s*2),o),b=t+(y?.top??d),x=y?.lineIndex??0,S,C,w;if(br({lines:c,startingLine:y?.lineIndex??0,callback:({lineIndex:e})=>{let i=x%o===0,a=Math.floor(x/o);if(i&&(v[a]=b-(t+d),w!=null)){if(w<=0)return!0;w--}let s=this.getLineHeight(e,!1);return b>n-s&&b<r&&(S??=a),b+s>g&&(C??=a),w==null&&b>=r&&i&&(w=_),x++,b+=s,!1}}),S==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:u-d-f};C??=S;let T=Math.round(C-h/2),E=Math.max(0,Math.ceil(l/o)-h),D=Math.max(0,Math.min(T,E)),O=D*o,k=T<0?m+T*o:m,ee=v[D]??0,te=D+k/o;return{startingLine:O,totalLines:k,bufferBefore:ee,bufferAfter:te<v.length?u-d-v[te]-f:u-(b-t)-f}}};function Vi(e){let t=e.at(-1);return t==null||t===``||t===`
74
+ }`}function bi(e,t){let n=mi(t);return e.replace(_i,n)}function xi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Si(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:e?.useTokenTransformer,tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function Ci({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function wi({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=Ti(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function Ti(){let e=document.createElement(`style`);return e.setAttribute(Yt,``),e}function Ei(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function Di(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`);break}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.tabIndex=0,e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(hi)),t.adoptedStyleSheets=[e]}connectedCallback(){pi(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(Lt,t)}var Oi=[],ki=-1,Ai=class{static LoadedCustomComponent=!0;__id=`file:${++ki}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;constructor(e={theme:L},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new ni(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new dr,this.interactionManager=new qn(`file`,Jn(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Jn(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ln(this.appliedThemeCSS.theme,this.options.theme??L)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,e===`wrap`),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,this.lineAnnotations=[],this.annotationCache.clear(),this.pre=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder=void 0,this.unsafeCSSStyle=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;this.hydrateElements(t,n),ji(this.pre,i,this.options.collapsed)||Mi(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ei(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Si(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e==null?Oi:this.fileRenderer.getOrCreateLineCache(e)}render({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){let{collapsed:c=!1,themeType:l=`system`}=this.options;if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);let u=c?void 0:s,d=this.renderRange,f=this.hasThemeChanged(),p=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1,m=!q(this.file,e);if(!c&&!n&&gr(u,this.renderRange)&&!m&&!p&&!f)return this.applyCachedThemeState(l);this.renderRange=u,m&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(Si(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:h=!1,disableFileHeader:g=!1}=this.options;if(g&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(l),c){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,rn);n!=null&&this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,p,m||f)||!this.applyPartialRender(d,u)){let n=this.fileRenderer.renderFile(e,u);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,u),this.injectUnsafeCSS(),this.managersDirty=!0,a||this.flushManagers(),this.renderAnnotations(),this.renderGutterUtility()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}primeHighlightCache(){let{file:e,workerManager:t}=this;e==null||e.cacheKey==null||t==null||yr(e)||this.fileRenderer.getOrCreateLineCache(e).length>(this.options.tokenizeMaxLength??1e5)||t.primeFileHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.gutterUtilityContent?.remove(),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.gutterUtilityContent=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${B(r)}`,a=this.annotationCache.get(i);if(a==null||!ai(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:li(B(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=ui();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=di(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=vi(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??L,s=typeof o==`string`?o:{...o},c=pi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=wi({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:yi(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=bi(this.themeCSSStyle.textContent??``,pi(e)))}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e),this.code=Ci({code:this.code}),this.code.innerHTML=this.fileRenderer.renderPartialHTML(this.fileRenderer.renderCodeAST(e)),t.replaceChildren(this.code),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l||!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))return!1;let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){let{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??A(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:i,renderCustomHeader:a,renderHeaderMetadata:o}=this.options;if(a!=null){let e=a(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Jt,e),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0}else{let e=i?.(n)??void 0,r=o?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Kt,e),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,qt,r),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:Bn(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):Bn(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=ii;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};oi(i,this.appliedPreAttributes)||(Di(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function ji(e,t,n=!1){return!n&&e==null&&t!=null}function Mi(e,t,n=!1){return e==null&&t!=null&&!n}function Ni(e){return{...en,...e}}function X(e,t){let n=Pi(e,t);return t?n:e.diffHeaderHeight+n}function Pi(e,t){return e.paddingTop??(t?e.spacing:0)}function Fi(e){return e.paddingBottom??e.spacing}function Ii(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}var Li=5e3,Ri=-1;function zi(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var Bi=class extends Ai{__id=`virtualized-file:${++Ri}`;top;height=0;cache={heights:new Map,checkpoints:[]};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=en,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){!t&&In(this.metrics,e)||(this.metrics=e,this.resetLayoutCache())}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Rn(t,e),r=zi(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1){this.layoutDirty=!0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n){let r=n?.resetFileLayoutCache===!0;n?.metrics!=null&&(this.metrics=n.metrics,r=!0);let{collapsed:i=!1}=this.options;return this.currentCollapsed!==i&&(this.currentCollapsed=i,r=!0),r&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=Vi(this.getOrCreateLineCache(this.file)),i=X(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(o===`scroll`&&this.lineAnnotations.length===0)return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=Vi(this.getOrCreateLineCache(this.file));if(i<0)return;let a=X(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;if(r===`scroll`&&this.lineAnnotations.length===0){let{lineHeight:t}=this.metrics,n=a+this.renderRange.bufferBefore,r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+r*t}}let c=a+this.renderRange.bufferBefore;for(let t=o;t<=s;t++){if(c>=e)return{lineNumber:t+1,top:c};c+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.layoutDirty=!0),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1){let t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;let n=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.file==null){this.layoutDirty=!1;return}let{disableFileHeader:r=!1,collapsed:i=!1,overflow:a=`scroll`}=this.options,{lineHeight:o}=this.metrics,s=this.getOrCreateLineCache(this.file),c=X(this.metrics,r),l=Fi(this.metrics);if(this.height+=c,i){this.layoutDirty=!1;return}if(a===`scroll`&&this.lineAnnotations.length===0?this.height+=this.getOrCreateLineCache(this.file).length*o:br({lines:s,callback:({lineIndex:e})=>{this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1)}}),s.length>0&&(this.height+=l),this.fileContainer!=null&&t&&!n){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:this.file.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}render({fileContainer:e,file:t,forceRender:n=!1,...r}){let{forceRenderOverride:i,isSetup:a}=this;if(this.forceRenderOverride=void 0,this.file??=t,e=this.getOrCreateFileContainerNode(e),this.file==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(a)this.top??=this.getVirtualizedTop();else{this.computeApproximateSize();let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);let o=this.virtualizer.getWindowSpecs(),s=this.top??0,c=this.computeRenderRangeFromWindow(this.file,s,o);return super.render({file:this.file,fileContainer:e,renderRange:c,forceRender:i??n,...r})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%Li===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.getOrCreateLineCache(e),l=c.length,u=this.height,d=X(this.metrics,i),f=l>0?Fi(this.metrics):0;if(t<n-u||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:u-d-f};if(l<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let p=Math.ceil(Math.max(r-n,0)/s),m=Math.ceil(p/o)*o+o*2,h=m/o,g=(n+r)/2;if(a===`scroll`&&this.lineAnnotations.length===0){let e=Math.floor((g-(t+d))/s),n=Math.floor(e/o)-Math.floor(h/2),r=Math.ceil(l/o),i=Math.max(0,Math.min(n,r))*o,a=n<0?m+n*o:m,c=i*s,u=Math.min(a,l-i);return{startingLine:i,totalLines:a,bufferBefore:c,bufferAfter:Math.max(0,(l-i-u)*s)}}let _=h,v=[],y=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-m*s*2),o),b=t+(y?.top??d),x=y?.lineIndex??0,S,C,w;if(br({lines:c,startingLine:y?.lineIndex??0,callback:({lineIndex:e})=>{let i=x%o===0,a=Math.floor(x/o);if(i&&(v[a]=b-(t+d),w!=null)){if(w<=0)return!0;w--}let s=this.getLineHeight(e,!1);return b>n-s&&b<r&&(S??=a),b+s>g&&(C??=a),w==null&&b>=r&&i&&(w=_),x++,b+=s,!1}}),S==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:u-d-f};C??=S;let T=Math.round(C-h/2),E=Math.max(0,Math.ceil(l/o)-h),D=Math.max(0,Math.min(T,E)),ee=D*o,O=T<0?m+T*o:m,te=v[D]??0,k=D+O/o;return{startingLine:ee,totalLines:O,bufferBefore:te,bufferAfter:k<v.length?u-d-v[k]-f:u-(b-t)-f}}};function Vi(e){let t=e.at(-1);return t==null||t===``||t===`
75
75
  `||t===`\r
76
76
  `||t===`\r`?e.length-2:e.length-1}function Hi(e){let t=(0,M.useRef)(e);return(0,M.useInsertionEffect)(()=>void(t.current=e)),(0,M.useCallback)((...e)=>t.current(...e),[])}function Ui(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function Wi(e,t){return Ln(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function Gi(e){let t=e.lang??J(e.name),n=e.lang??(e.prevName==null?`text`:J(e.prevName));return t===`text`&&n===`text`}function Z({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function Ki({type:e,metrics:t}){return t.hunkSeparatorHeight??Ii(e)}function qi({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function Ji({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 Yi(e){return e!==`simple`&&e!==`metadata`}function Xi({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!Ji({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=Ki({type:e,metrics:t}),a=qi({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function Zi({type:e,metrics:t}){if(!Yi(e))return;let n=Ki({type:e,metrics:t}),r=qi({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function Qi({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=$i({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={finalHunk:e.hunks.at(-1),viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=c.unifiedCount+e<n,a=c.splitCount+r<n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=Z({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),s=(()=>{if(r!==c.finalHunk||!ra(e))return;let t=e.additionLines.length-(r.additionLineIndex+r.additionCount),n=e.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(t!==n)throw Error(`iterateOverDiff: trailing context mismatch (additions=${t}, deletions=${n}) for ${e.name}`);let o=Math.min(t,n);return Z({isPartial:e.isPartial,rangeSize:o,expandedHunks:i,hunkIndex:e.hunks.length,collapsedContextThreshold:a})})(),l=o.fromStart+o.fromEnd;function u(e,n){return s==null||s.collapsedLines<=0||s.fromStart+s.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?s.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?s.collapsedLines:0}function d(){if(o.collapsedLines===0)return 0;let e=o.collapsedLines;return o.collapsedLines=0,e}if(c.shouldSkip(l,l))c.incrementCounts(l,l),d();else{let e=r.unifiedLineStart-o.rangeSize,i=r.splitLineStart-o.rangeSize,a=r.deletionLineIndex-o.rangeSize,s=r.additionLineIndex-o.rangeSize,l=r.deletionStart-o.rangeSize,u=r.additionStart-o.rangeSize,[f,p]=ta(c,o.fromStart,t);f>0&&c.incrementCounts(f,f);let m=f;for(;m<o.fromStart;){if(m>=p){c.incrementCounts(o.fromStart-m,o.fromStart-m);break}if(c.isInWindow(0,0)){if(c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:l+m,lineIndex:a+m,noEOFCR:!1,unifiedLineIndex:e+m,splitLineIndex:i+m},additionLine:{unifiedLineIndex:e+m,splitLineIndex:i+m,lineIndex:s+m,lineNumber:u+m,noEOFCR:!1}}))break hunkIterator}else c.incrementCounts(1,1);m++}e=r.unifiedLineStart-o.fromEnd,i=r.splitLineStart-o.fromEnd,a=r.deletionLineIndex-o.fromEnd,s=r.additionLineIndex-o.fromEnd,l=r.deletionStart-o.fromEnd,u=r.additionStart-o.fromEnd;let[h,g]=ta(c,o.fromEnd,t);for(h>0&&c.incrementCounts(h,h),m=h;m<o.fromEnd;){if(m>=g){c.incrementCounts(o.fromEnd-m,o.fromEnd-m);break}if(c.isInWindow(0,0)){if(c.emit({hunkIndex:n,hunk:r,collapsedBefore:d(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:l+m,lineIndex:a+m,noEOFCR:!1,unifiedLineIndex:e+m,splitLineIndex:i+m},additionLine:{unifiedLineIndex:e+m,splitLineIndex:i+m,lineIndex:s+m,lineNumber:u+m,noEOFCR:!1}}))break hunkIterator}else c.incrementCounts(1,1);m++}}let f=r.unifiedLineStart,p=r.splitLineStart,m=r.deletionLineIndex,h=r.additionLineIndex,g=r.deletionStart,_=r.additionStart,v=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===v;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),d();else{let[a,o]=ta(c,e.lines,t);a>0&&c.incrementCounts(a,a);let s=a;for(;s<e.lines;){if(s>=o){c.incrementCounts(e.lines-s,e.lines-s);break}if(c.isInWindow(0,0)){let t=i&&s===e.lines-1,a=f+s,o=p+s;if(c.emit({hunkIndex:n,hunk:r,collapsedBefore:d(),collapsedAfter:u(a,o),type:`context`,deletionLine:{lineNumber:g+s,lineIndex:m+s,noEOFCR:t&&r.noEOFCRDeletions,unifiedLineIndex:a,splitLineIndex:o},additionLine:{unifiedLineIndex:a,splitLineIndex:o,lineIndex:h+s,lineNumber:_+s,noEOFCR:t&&r.noEOFCRAdditions}}))break hunkIterator}else c.incrementCounts(1,1);s++}}f+=e.lines,p+=e.lines,m+=e.lines,h+=e.lines,g+=e.lines,_+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=ia(c,e,t);for(let[l,v]of s)for(let s=l;s<v;s++){let l=u(f+s,t===`unified`?p+(s<e.deletions?s:s-e.deletions):p+s);if(c.emit(aa({hunkIndex:n,hunk:r,collapsedBefore:d(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:f,splitLineIndex:p,additionLineIndex:h,deletionLineIndex:m,additionLineNumber:_,deletionLineNumber:g,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}d(),c.incrementCounts(o,a),f+=o,p+=a,m+=e.deletions,h+=e.additions,g+=e.deletions,_+=e.additions}}if(s!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=s,a=r+i,[o,l]=ta(c,a,t);o>0&&c.incrementCounts(o,o);let u=o;for(;u<a;){if(c.shouldBreak())break hunkIterator;if(u>=l){c.incrementCounts(a-u,a-u);break}if(c.isInWindow(0,0)){let t=u===a-1;if(c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:t?n:0,type:`context-expanded`,deletionLine:{lineNumber:g+u,lineIndex:m+u,noEOFCR:!1,unifiedLineIndex:f+u,splitLineIndex:p+u},additionLine:{unifiedLineIndex:f+u,splitLineIndex:p+u,lineIndex:h+u,lineNumber:_+u,noEOFCR:!1}}))break hunkIterator}else c.incrementCounts(1,1);u++}}}}function $i({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=ea({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function ea({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=Z({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;if(r+=u+c.splitLineCount,i+=u+c.unifiedLineCount,s===a&&ra(e)){let a=na(e,c),o=Z({isPartial:e.isPartial,rangeSize:a,expandedHunks:t,hunkIndex:e.hunks.length,collapsedContextThreshold:n}),s=o.fromStart+o.fromEnd;r+=s,i+=s}o.push({splitCount:r,unifiedCount:i})}return o}function ta(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function na(e,t){let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`iterateOverDiff: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}function ra(e){let t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function ia(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function aa({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,S=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,C=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,w=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,T=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:C,unifiedLineIndex:g,splitLineIndex:v}:void 0,E=x!=null&&S!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:S,noEOFCR:w}:void 0;if(T==null&&E!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:E};if(T!=null&&E==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:void 0};if(T==null||E==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:E}}var Q=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},oa=new class extends Q{};function sa(e,t,n){return oa.diff(e,t,n)}function ca(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function la(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function ua(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function da(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function fa(e,t){return ua(e,t,``)}function pa(e,t){return da(e,t,``)}function ma(e,t){return t.slice(0,ha(e,t))}function ha(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function ga(e){let t;for(t=e.length-1;t>=0&&e[t].match(/\s/);t--);return e.substring(t+1)}function $(e){let t=e.match(/^\s*/);return t?t[0]:``}var _a=`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}`,va=RegExp(`[${_a}]+|\\s+|[^${_a}]`,`ug`);new class extends Q{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=[];for(let t of Array.from(r.segment(e))){let e=t.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}}else n=e.match(va)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&ya(n,i,r,e),n=e,r=null,i=null)}),(r||i)&&ya(n,i,r,null),e}};function ya(e,t,n,r){if(t&&n){let i=$(t.value),a=ga(t.value),o=$(n.value),s=ga(n.value);if(e){let r=ca(i,o);e.value=da(e.value,o,r),t.value=fa(t.value,r),n.value=fa(n.value,r)}if(r){let e=la(a,s);r.value=ua(r.value,s,e),t.value=pa(t.value,e),n.value=pa(n.value,e)}}else if(n){if(e){let e=$(n.value);n.value=n.value.substring(e.length)}if(r){let e=$(r.value);r.value=r.value.substring(e.length)}}else if(e&&r){let n=$(r.value),i=$(t.value),a=ga(t.value),o=ca(n,i);t.value=fa(t.value,o);let s=la(fa(n,o),a);t.value=pa(t.value,s),r.value=ua(r.value,n,s),e.value=da(e.value,n,n.slice(0,n.length-s.length))}else if(r){let e=$(r.value),n=ma(ga(t.value),e);t.value=pa(t.value,n)}else if(e){let n=ma(ga(e.value),$(t.value));t.value=fa(t.value,n)}}var ba=new class extends Q{tokenize(e){let t=RegExp(`(\\r?\\n)|[${_a}]+|[^\\S\\n\\r]+|[^${_a}]`,`ug`);return e.match(t)||[]}};function xa(e,t,n){return ba.diff(e,t,n)}var Sa=new class extends Q{constructor(){super(...arguments),this.tokenize=wa}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
77
77
  `))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
@@ -85,10 +85,14 @@ diff --git`)}function Cn(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.star
85
85
  `}function Aa(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;Oa(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?ka(e,o.headerOptions):void 0)}}))}else{let s=Oa(e,t,n,r,i,a,o);return s?ka(s,o?.headerOptions):void 0}}function ja(e){let t=e.endsWith(`
86
86
  `),n=e.split(`
87
87
  `).map(e=>e+`
88
- `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function Ma({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 Na({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}var Pa={forcePlainText:!1};function Fa(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=Pa){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=Jr({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??La();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}Qi({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:c?h:!0,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&Ia({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=Ra({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function Ia({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=R(e),t=R(t),e.length>s||t.length>s))return;let c=o===`char`?sa(e,t):xa(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(Na({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),Na({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?Na({item:e,arr:l,enableJoin:d,isLastItem:t}):Na({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(Ma({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(Ma({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function La(){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 Ra({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=L,...l}}){let u=s??J(e.name),d=s??J(t.name),{state:f,transformers:p}=Gr(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:Y(`token`)}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:Y(`token`)};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,Xr(i.codeToHast(R(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,Xr(i.codeToHast(R(t.contents),m)))}}var za=(0,M.createContext)(void 0),Ba=(0,M.createContext)(void 0);function Va(){return(0,M.useContext)(Ba)}var Ha=typeof window>`u`?M.useEffect:M.useLayoutEffect;function Ua({file:e,options:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:i,metrics:a,hasGutterRenderUtility:o,hasCustomHeader:s,disableWorkerPool:c}){let l=Va(),u=r!==void 0,d=(0,M.useContext)(za),f=(0,M.useRef)(null),p=Hi(r=>{if(r!=null){if(f.current!=null)throw Error(`File: An instance should not already exist when a node is created`);l==null?f.current=new Ai(Wa({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),c?void 0:d,!0):f.current=new Bi(Wa({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),l,a,c?void 0:d,!0),f.current.hydrate({file:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:i})}else{if(f.current==null)throw Error(`File: A File instance should exist when unmounting`);f.current.cleanUp(),f.current=null}});return Ha(()=>{if(f.current==null)return;let i=Wa({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),a=!Rn(f.current.options,i);f.current.setOptions(i),f.current.render({file:e,lineAnnotations:n,forceRender:a}),r!==void 0&&f.current.setSelectedLines(r)}),{ref:p,getHoveredLine:(0,M.useCallback)(()=>f.current?.getHoveredLine(),[])}}function Wa({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return!t&&!r&&!n?e:{...e,controlledSelection:t,renderCustomHeader:n?Nn:e?.renderCustomHeader,renderGutterUtility:r?Nn:e?.renderGutterUtility}}function Ga({file:e,lineAnnotations:t,selectedLines:n,options:r,metrics:i,className:a,style:o,renderAnnotation:s,renderCustomHeader:c,renderHeaderPrefix:l,renderHeaderMetadata:u,prerenderedHTML:d,renderGutterUtility:f,disableWorkerPool:p=!1}){let{ref:m,getHoveredLine:h}=Ua({file:e,options:r,metrics:i,lineAnnotations:t,selectedLines:n,prerenderedHTML:d,hasGutterRenderUtility:f!=null,hasCustomHeader:c!=null,disableWorkerPool:p});return(0,V.jsx)(Lt,{ref:m,className:a,style:o,children:Fn(Pn({file:e,renderAnnotation:s,renderCustomHeader:c,renderHeaderPrefix:l,renderHeaderMetadata:u,renderGutterUtility:f,lineAnnotations:t,getHoveredLine:h}),d)})}function Ka({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function qa(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Ja(n,e.startContentIndex)}}function Ja(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function Ya({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderMergeConflictUtility:s,lineAnnotations:c,getHoveredLine:l,getInstance:u}){let d=n?.(e),f=r?.(e),p=i?.(e);return(0,V.jsxs)(V.Fragment,{children:[d==null?(0,V.jsxs)(V.Fragment,{children:[f!=null&&(0,V.jsx)(`div`,{slot:`header-prefix`,children:f}),p!=null&&(0,V.jsx)(`div`,{slot:`header-metadata`,children:p})]}):(0,V.jsx)(`div`,{slot:Jt,children:d}),a!=null&&c?.map((e,t)=>(0,V.jsx)(`div`,{slot:B(e),children:a(e)},t)),t!=null&&s!=null&&u!=null&&t.map(t=>{if(t==null)return;let n=Xa(t,e);return(0,V.jsx)(`div`,{slot:n,style:Mn,children:s(t,u)},n)}),o!=null&&(0,V.jsx)(`div`,{slot:`gutter-utility-slot`,style:jn,children:o(l)})]})}function Xa(e,t){let n=qa(e,t);return n==null?void 0:Ka({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function Za(e,t,n,r=!1){let i=pn(Aa(e.name,t.name,e.contents,t.contents,e.header,t.header,n),{cacheKey:(()=>{if(e.cacheKey!=null&&t.cacheKey!=null)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:r});if(i==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);return t.lang!=null&&(i.lang=t.lang),i}var Qa=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function $a(e){return U({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function eo(e){return U({tagName:`div`,children:[U({tagName:`span`,children:[H(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function to(e){return U({tagName:`div`,children:[Un({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 no({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(U({tagName:`div`,children:[H(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(to(`up`)),s++),o||(e.push(to(`down`)),s++)):(e.push(to(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(U({tagName:`div`,children:[U({tagName:`span`,children:[H(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(U({tagName:`div`,children:[H(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(U({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(U({tagName:`slot`,properties:{name:i}})),U({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function ro(e,t){return`hunk-separator-${e}-${t}`}function io(e){let t=e.at(-1);return t==null?0:Math.max(t.additionStart+t.additionCount,t.deletionStart+t.deletionCount)}function ao(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}var oo=-1,so=class{__id=`diff-hunks-renderer:${++oo}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;constructor(e={theme:L},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=Cr(e.theme??L)?de():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}clearRenderCache(){this.renderCache=void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??tn}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e}}getSplitLineDecoration({side:e,type:t}){return t===`change`?{gutterLineType:e===`deletions`?`change-deletion`:`change-addition`}:{gutterLineType:t}}createAnnotationElement(e){return Er(e)}getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=L,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=$t,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}async initializeHighlighter(){return this.highlighter=await le(Pr(this.computedLang,this.options)),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=ho(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!Wi(t,r.options)&&(r=void 0),this.renderCache??={diff:e,highlighted:!n&&!Gi(e),options:t,result:n?void 0:r?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLang=e.lang??J(e.name),this.initializeHighlighter())}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:ei(this.options),tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!Ui(e,n.diff)||!Wi(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=nn){if(e==null)return;let{expandUnchanged:n=!1,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getMatchingWorkerResultCache(e,i);o!=null&&!this.hasHighlightedRenderCache(e,i)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||Gi(e)||ho(e,this.getTokenizeMaxLength()),l=!Ui(e,this.renderCache.diff),u=!gr(this.renderCache.renderRange,t);if(this.workerManager?.isWorkingPool()===!0)(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,ao(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??J(e.name);let t=this.highlighter!=null&&Cr(i.theme),n=this.highlighter!=null&&xr(this.computedLang),r=!c&&n;if(this.highlighter!=null&&t&&(a||c||!this.renderCache.highlighted&&r||this.renderCache.result==null)){let{result:t,options:i}=this.renderDiffWithHighlighter(e,this.highlighter,c||!n);this.renderCache={diff:e,options:i,highlighted:r,result:t,renderRange:void 0}}(!t||!c&&!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=nn){let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return Mr({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=ho(e,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??J(e.name);let n=this.highlighter!=null&&Cr(this.options.theme??L),r=t||this.highlighter!=null&&xr(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults();return{result:Fa(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i}),options:r}}onHighlightSuccess(e,t,n,r=!0){if(this.renderCache==null)return;let i=!this.renderCache.highlighted||!Wi(this.renderCache.options,n)||!Ui(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){let n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!Wi(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&Ui(e,n.diff)&&Wi(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults();this.diff=e;let d=a===`unified`,f=[],p=[],m=[],h=[],{additionLines:g,deletionLines:_}=n,v={rowCount:0,hunkSeparators:u,additionsContentAST:f,deletionsContentAST:p,unifiedContentAST:m,unifiedGutterAST:W(),deletionsGutterAST:W(),additionsGutterAST:W(),expansionLineCount:c,hunkData:h,incrementRowCount(e=1){v.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:v.unifiedGutterAST.children.push(t);break;case`deletions`:v.deletionsGutterAST.children.push(t);break;case`additions`:v.additionsGutterAST.children.push(t);break}}},y=go(e),b={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!==`unified`){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side===`additions`?(v.pushToGutter(`additions`,G(void 0,`buffer`,this.size)),f?.push($a(this.size))):(v.pushToGutter(`deletions`,G(void 0,`buffer`,this.size)),p?.push($a(this.size))),this.size=0,this.side=void 0}}},x=(e,t,n,r,i)=>{v.pushToGutter(e,Gn(t,n,r,i))};function S(e){b.flush(),a===`unified`?po(`unified`,e,v):(po(`deletions`,e,v),po(`additions`,e,v))}Qi({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,d=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&b.flush(),r>0&&S({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:!e.isPartial});let f=a===`unified`?d:l,p={type:c,hunkIndex:t,lineIndex:f,unifiedLineIndex:d,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(p);n?.before!=null&&lo(n.before,v);let r=s==null?void 0:_[s.lineIndex],i=o==null?void 0:g[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});x(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${d},${l}`,u.gutterProperties),i==null?r!=null&&(r=mo(r,u.contentProperties)):i=mo(i,u.contentProperties),fo({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,f),createAnnotationElement:e=>this.createAnnotationElement(e),context:v}),n?.after!=null&&lo(n.after,v)}else{let n=this.getSplitInjectedRowsForLine?.(p);n?.before!=null&&uo(n.before,v,b);let r=s==null?void 0:_[s.lineIndex],i=o==null?void 0:g[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let d=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();if(d!=null){if(b.side!=null&&b.side!==d)throw Error(`DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits`);b.side=d,b.increment()}let m=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,f);if(m!=null&&b.size>0&&b.flush(),s!=null){let e=mo(r,a.contentProperties);x(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=mo(i,u.contentProperties);x(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}fo({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...m,createAnnotationElement:e=>this.createAnnotationElement(e),context:v}),n?.after!=null&&uo(n.after,v,b)}let m=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,h=m?n.noEOFCRDeletions:!1,C=m?n.noEOFCRAdditions:!1,w=(s?.noEOFCR??!1)||h,T=(o?.noEOFCR??!1)||C;if(T||w){if(a===`split`&&b.flush(),w){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(v.unifiedContentAST.push(eo(e)),v.pushToGutter(`unified`,G(e,`metadata`,1))):(v.deletionsContentAST.push(eo(e)),v.pushToGutter(`deletions`,G(e,`metadata`,1)),T||(v.pushToGutter(`additions`,G(void 0,`buffer`,1)),v.additionsContentAST.push($a(1))))}if(T){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(v.unifiedContentAST.push(eo(e)),v.pushToGutter(`unified`,G(e,`metadata`,1))):(v.additionsContentAST.push(eo(e)),v.pushToGutter(`additions`,G(e,`metadata`,1)),w||(v.pushToGutter(`deletions`,G(void 0,`buffer`,1)),v.deletionsContentAST.push($a(1))))}v.incrementRowCount(1)}i>0&&u!==`simple`&&S({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:i,rangeSize:y,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),v.incrementRowCount(1)}}),a===`split`&&b.flush();let C=Math.max(io(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),w=t.bufferBefore>0||t.bufferAfter>0,T=!d&&e.type!==`deleted`,E=!d&&e.type!==`new`,D=v.rowCount>0||w;f=T&&D?f:void 0,p=E&&D?p:void 0,m=d&&D?m:void 0;let O=this.createPreElement(p!=null&&f!=null,C);return{unifiedGutterAST:d&&D?v.unifiedGutterAST.children:void 0,unifiedContentAST:m,deletionsGutterAST:E&&D?v.deletionsGutterAST.children:void 0,deletionsContentAST:p,additionsGutterAST:T&&D?v.additionsGutterAST.children:void 0,additionsContentAST:f,hunkData:h,preNode:O,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:C,rowCount:v.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=W(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Dr(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(U({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(U({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(U({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return A(this.renderFullAST(e,t))}renderPartialHTML(e,t){return A(t==null?e:U({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(B(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(B(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(!(o.annotations.length===0&&a.annotations.length===0))return{deletionSpan:a,additionSpan:o}}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return kr({fileOrDiff:e,mode:t,stickyHeader:n})}};function co(e){return`${e} unmodified line${e>1?`s`:``}`}function lo(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function uo(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function fo({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,G(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,G(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,G(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function po(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,no({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(no({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,no({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(no({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=ro(e,t),d=r>c.expansionLineCount,f=s?t:void 0;c.pushToGutter(e,no({type:c.hunkSeparators,content:co(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(no({type:c.hunkSeparators,content:co(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:n,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function mo(e,t){return e==null||e.type!==`element`||t==null?e:{...e,properties:{...e.properties,...t}}}function ho(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function go(e){let t=e.hunks.at(-1);if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}function _o(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function vo(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function yo(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:e?.useTokenTransformer,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,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var bo=-1,xo=class{static LoadedCustomComponent=!0;__id=`file-diff:${++bo}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;constructor(e={theme:L},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new dr,this.scrollSyncManager=new Qa,this.interactionManager=new qn(`diff`,Jn(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 yo(e)}createHunksRenderer(e){return new so(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>{if(this.fileDiff==null)return;let n=this.fileDiff.hunks.at(-1),r,i;hunkIterator:for(let a of this.fileDiff.hunks){let o=t===`deletions`?a.deletionStart:a.additionStart,s=t===`deletions`?a.deletionCount:a.additionCount,c=a.splitLineStart,l=a.unifiedLineStart;if(e<o){let t=o-e;r=Math.max(l-t,0),i=Math.max(c-t,0);break hunkIterator}if(e>=o+s){if(a===n){let t=e-(o+s);r=l+a.unifiedLineCount+t,i=c+a.splitLineCount+t;break hunkIterator}continue}for(let n of a.hunkContent)if(n.type===`context`)if(e<o+n.lines){let t=e-o;i=c+t,r=l+t;break hunkIterator}else o+=n.lines,c+=n.lines,l+=n.lines;else{let a=t===`deletions`?n.deletions:n.additions;if(e<o+a){let a=e-o;r=l+(t===`additions`?n.deletions:0)+a,i=c+a;break hunkIterator}else o+=a,c+=Math.max(n.deletions,n.additions),l+=n.deletions+n.additions}break hunkIterator}if(!(r==null||i==null))return[r,i]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Jn(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ln(this.appliedThemeCSS.theme,this.options.theme??L)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,t===`wrap`),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,this.lineAnnotations=[],this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,lineAnnotations:i,oldFile:a,newFile:o,fileDiff:s}=e;this.hydrateElements(t,n),wo(this.pre,So({fileDiff:s,oldFile:a,newFile:o}),this.options.collapsed)||To(this.headerElement,Co({fileDiff:s,oldFile:a,newFile:o}),this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({fileDiff:s,oldFile:a,newFile:o,lineAnnotations:i}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ei(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)!(e instanceof HTMLElement)||e.tagName.toLowerCase()!==`code`||(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!=null&&n!=null?Za(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.rerender()};render({oldFile:e,newFile:t,fileDiff:n,deferManagers:r=!1,forceRender:i=!1,preventEmit:a=!1,lineAnnotations:o,fileContainer:s,containerWrapper:c,renderRange:l}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let{collapsed:u=!1,themeType:d=`system`}=this.options,f=u?void 0:l,p=this.hasThemeChanged(),m=e!=null&&t!=null&&(!q(e,this.deletionFile)||!q(t,this.additionFile)),h=n!=null&&n!==this.fileDiff,g=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1;if(!u&&gr(f,this.renderRange)&&!i&&!g&&!p&&(n!=null&&n===this.fileDiff||n==null&&!m))return this.applyCachedThemeState(d);let{renderRange:_}=this;if(this.renderRange=f,this.deletionFile=e,this.additionFile=t,n==null?e!=null&&t!=null&&m&&(h=!0,this.fileDiff=Za(e,t,this.options.parseDiffOptions)):this.fileDiff=n,h&&(this.cachedHeaderHTML=void 0),o!=null&&this.setLineAnnotations(o),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:v=!1,disableFileHeader:y=!1}=this.options;if(y&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),s=this.getOrCreateFileContainer(s,c),this.applyCachedThemeState(d),u){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(this.fileDiff,rn);e!=null&&this.applyThemeState(s,e.themeStyles,d,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,s),this.renderSeparators([]),this.injectUnsafeCSS()}catch(e){if(v)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,s)}return a||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(i,g,m||h||p)&&this.applyPartialRender({previousRenderRange:_,renderRange:f}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,f);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(s,t.themeStyles,d,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,s),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,f),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,r||this.flushManagers()}catch(e){if(v)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,s)}return a||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}primeHighlightCache(){let{fileDiff:e,workerManager:t}=this;if(e==null||t==null||Gi(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||t.primeDiffHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!vo(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${B(r)}`,a=this.annotationCache.get(i);if(a==null||!_o(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:li(B(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=ui();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:Bn(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):Bn(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=ii;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:n}=this,r=this.cachedHeaderHTML??A(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;let{renderCustomHeader:i,renderHeaderPrefix:a,renderHeaderMetadata:o}=this.options;if(i!=null){let e=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Jt,e),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0;return}let s=a?.(n)??void 0,c=o?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Kt,s),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,qt,c),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=di(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=vi(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??L,s=typeof o==`string`?o:{...o},c=pi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=wi({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:yi(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=bi(this.themeCSSStyle.textContent??``,pi(e)))}applyHunksToDOM(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Ci({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Ci({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Ci({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:a,options:{diffStyle:o=`split`}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(o,r,a,i);if(s==null)return!1;let c=e.startingLine,l=t.startingLine,u=c+e.totalLines,d=l+t.totalLines,f=Math.max(c,l),p=Math.min(u,d);if(p<=f)return!1;let m=Math.max(0,f-c),h=Math.max(0,u-p),g=this.trimColumns({columns:s,trimStart:m,trimEnd:h,previousStart:c,overlapStart:f,overlapEnd:p,diffStyle:o});if(g<0)throw Error(`applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`applyPartialRender: trimmed beyond DOM row count`);let _=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},y=v(l,Math.max(f-l,0));if(y==null&&l<f)return!1;let b=v(p,Math.max(d-p,0));if(b==null&&d>p)return!1;let x=(e,t)=>{if(e!=null){if(o===`unified`&&!Array.isArray(s))this.insertPartialHTML(o,s,e,t);else if(o===`split`&&Array.isArray(s))this.insertPartialHTML(o,s,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);_+=e.rowCount}};return this.cleanupErrorWrapper(),x(y,`afterbegin`),x(b,`beforeend`),this.lastRowCount!==_&&(this.applyRowSpan(o,s,_),this.lastRowCount=_),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Eo(t[0]),i=Eo(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}else throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getCodeColumns(e,t,n,r){function i(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}if(e===`unified`)return i(t);{let e=i(n),t=i(r);return e!=null||t!=null?[e,t]:void 0}}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l===`unified`?!1:t!=null&&n!=null,totalLines:r,customProperties:i};oi(u,this.appliedPreAttributes)||(Di(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function So({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function Co({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function wo(e,t,n=!1){return!n&&e==null&&t}function To(e,t,n=!1){return e==null&&t&&!n}function Eo(e){if(!(e==null||e.type!==`element`))return e.children??[]}function Do({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o}){let s=X(t,n),c=s,l=i?!0:a,u=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=Z({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:l,hunkIndex:n,collapsedContextThreshold:o}),d=(a.fromStart+a.fromEnd)*t.lineHeight;if(s+=d,c+=d,a.collapsedLines>0){let e=Xi({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;s+=e,c+=e}s+=i.splitLineCount*t.lineHeight,c+=i.unifiedLineCount*t.lineHeight;let f=Oo(i);if(s+=f.split*t.lineHeight,c+=f.unified*t.lineHeight,n===u&&Ao(e)){let n=Z({isPartial:e.isPartial,rangeSize:jo(e,i),expandedHunks:l,hunkIndex:e.hunks.length,collapsedContextThreshold:o}),a=(n.fromStart+n.fromEnd)*t.lineHeight;if(s+=a,c+=a,n.collapsedLines>0){let e=Zi({type:r,metrics:t})?.totalHeight??0;s+=e,c+=e}}}if(e.hunks.length>0){let e=Fi(t);s+=e,c+=e}return{splitHeight:s,unifiedHeight:c}}function Oo(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return ko(e,t)}function ko(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function Ao(e){let t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function jo(e,t){let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`computeEstimatedDiffHeights: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}var Mo=5e3,No=-1,Po=class extends xo{__id=`little-virtualized-file-diff:${++No}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=Ni(n)}setMetrics(e,t=!1){let n=Ni(e);!t&&In(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Rn(t,e),r=n&&Ho(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Uo(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1}={}){this.layoutDirty=!0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),t&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1,{overflow:t=`scroll`}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;let n=this.getDiffStyle(),r=n===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];for(let t of r){if(t==null)continue;let r=t.children[1];if(r instanceof HTMLElement)for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let i=Ko(r,n),a=t.getBoundingClientRect().height,o=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(o=!0),a+=t.nextElementSibling.getBoundingClientRect().height);let s=this.getEstimatedLineHeight(o),c=this.cache.heightDeltas.get(i)??0,l=a-s;l!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=l-c,l===0?this.cache.heightDeltas.delete(i):this.cache.heightDeltas.set(i,l))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render());prepareCodeViewItem(e,t,n){let r=!Ui(this.fileDiff,e),i=n?.resetDiffLayoutCache===!0||r,a=r||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=Ni(n.metrics),i=!0,a=!0);let{collapsed:o=!1}=this.options;return this.currentCollapsed!==o&&(this.currentCollapsed=o,i=!0),i&&this.resetLayoutCache({includeEstimatedHeights:a}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t=`additions`){if(this.fileDiff==null)return;let n=this.getLineIndex(e,t);if(n==null)return;let{disableFileHeader:r=!1,expandUnchanged:i=!1,collapsed:a=!1,collapsedContextThreshold:o=1}=this.options,s=this.getDiffStyle(),c=this.getHunkSeparatorType(),l=s===`split`?n[1]:n[0];this.approximateLayoutCheckpoints();let u=this.getLayoutCheckpointBeforeLineIndex(l),d=u?.top??X(this.metrics,r);if(a)return{top:d,height:0};let f;return Qi({diff:this.fileDiff,diffStyle:s,startingLine:u?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=s===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=Xi({type:c,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(d+=r.gapBefore,l>=o-n&&l<o)return f={top:d,height:r.height},!0;d+=r.height+r.gapAfter}}let u=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===l)return f={top:d,height:u},!0;if(d+=u,r>0){let e=Zi({type:c,metrics:this.metrics});if(e!=null){if(l>o&&l<=o+r)return f={top:d+e.gapBefore,height:e.height},!0;d+=e.totalHeight}}return!1}}),f}getNumericScrollAnchor(e){if(this.fileDiff==null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1}=this.options;if(r)return;let a=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();let s=this.getLayoutCheckpointBeforeTop(e),c=s?.top??X(this.metrics,t),l;return Qi({diff:this.fileDiff,diffStyle:a,startingLine:s?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:s,additionLine:u})=>{let d=a===`split`?u?.splitLineIndex??s?.splitLineIndex:u?.unifiedLineIndex??s?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=Xi({type:o,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(c+=e.totalHeight)}if(c>=e&&(s==null?u!=null&&(l={lineNumber:u.lineNumber,side:`additions`,top:c}):l={lineNumber:s.lineNumber,side:`deletions`,top:c},l!=null))return!0;let f=this.getLineHeight(d,(u?.noEOFCR??!1)||(s?.noEOFCR??!1));if(c+=f,i>0){let e=Zi({type:o,metrics:this.metrics});e!=null&&(c+=e.totalHeight)}return!1}}),l}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.fileDiff,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t;return{topOffset:this.top+n+(i===0?r:0),height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache({includeEstimatedHeights:!0}),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize(),this.virtualizer.instanceChanged(this,!0)};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))}computeApproximateSize(e=!1){let t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;let n=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,this.fileDiff==null){this.layoutDirty=!1;return}let{disableFileHeader:r=!1,collapsed:i=!1}=this.options,a=X(this.metrics,r);if(this.height+=a,i){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight()+this.cache.measuredHeightDeltaTotal,t&&!n&&this.validateComputedHeight(),this.layoutDirty=!1}getActiveEstimatedHeight(){this.ensureEstimatedDiffHeights();let e=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(e==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return e}ensureEstimatedDiffHeights(){if(this.fileDiff==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:n=1}=this.options,{splitHeight:r,unifiedHeight:i}=Do({fileDiff:this.fileDiff,metrics:this.metrics,disableFileHeader:e,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:t,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:n});this.cache.estimatedSplitHeight=r,this.cache.estimatedUnifiedHeight=i}validateComputedHeight(){if(this.fileContainer==null||this.fileDiff==null)return;let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height})}render({fileContainer:e,oldFile:t,newFile:n,fileDiff:r,forceRender:i=!1,...a}={}){let{forceRenderOverride:o,isSetup:s}=this;if(this.forceRenderOverride=void 0,this.fileDiff??=r??(t!=null&&n!=null?Za(t,n,this.options.parseDiffOptions):void 0),e=this.getOrCreateFileContainer(e),this.fileDiff==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(s)this.top??=this.getVirtualizedTop();else{this.computeApproximateSize();let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);let c=this.virtualizer.getWindowSpecs(),l=this.top??0,u=this.computeRenderRangeFromWindow(this.fileDiff,l,c);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:u,oldFile:t,newFile:n,forceRender:o??i,...a})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Wo(this.options.hunkSeparators)}approximateLayoutCheckpoints(){if(this.cache.checkpoints.length>0||this.fileDiff==null||this.fileDiff.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:n=1}=this.options,r=this.getDiffStyle(),i=this.getHunkSeparatorType(),a=t?!0:this.hunksRenderer.getExpandedHunksMap(),o=Fo(this.cache.heightDeltas),s=X(this.metrics,e),c=0,l=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=c,l=c+e,u=Ro(a);for(;u<l;){let e=u-a,r=s+(e>0?n:0)+e*this.metrics.lineHeight+zo(i,e)*this.metrics.lineHeight+Io(o,t,t+e);this.cache.checkpoints.push({renderedLineIndex:u,lineIndex:t+e,top:r}),u+=Mo}s+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+Io(o,t,t+e)+r,c=l};for(let e=0;e<this.fileDiff.hunks.length;e++){let t=this.fileDiff.hunks[e];if(t==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let o=Z({isPartial:this.fileDiff.isPartial,rangeSize:t.collapsedBefore,expandedHunks:a,hunkIndex:e,collapsedContextThreshold:n}),s=o.collapsedLines>0?Xi({type:i,metrics:this.metrics,hunkIndex:e,hunkSpecs:t.hunkSpecs})?.totalHeight??0:0;l({rowCount:o.fromStart,startLineIndex:(r===`split`?t.splitLineStart:t.unifiedLineStart)-o.rangeSize});let c=s;l({rowCount:o.fromEnd,startLineIndex:(r===`split`?t.splitLineStart:t.unifiedLineStart)-o.fromEnd,preSeparatorHeight:c}),o.fromEnd>0&&(c=0);let u=Vo({fileDiff:this.fileDiff,hunk:t,hunkIndex:e,expandedHunks:a,collapsedContextThreshold:n}),d=u!=null&&u.collapsedLines>0?Zi({type:i,metrics:this.metrics})?.totalHeight??0:0,f=u==null?0:u.fromStart+u.fromEnd,p=r===`split`?t.splitLineCount:t.unifiedLineCount,m=r===`split`?t.splitLineStart:t.unifiedLineStart;l({rowCount:p,startLineIndex:m,preSeparatorHeight:c,postSeparatorHeight:f===0?d:0,metadataOffsets:Bo({diffStyle:r,hunk:t,rowCount:p})}),u!=null&&f>0&&l({rowCount:f,startLineIndex:m+p,postSeparatorHeight:d})}this.cache.totalLines=c}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=Z({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=e.hunks.at(-1);if(o!=null&&Go(e)){let t=e.additionLines.length-(o.additionLineIndex+o.additionCount),r=e.deletionLines.length-(o.deletionLineIndex+o.deletionCount);if(o!=null&&t!==r)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${t}, deletions=${r}) for ${e.name}`);let s=Math.min(t,r);if(o!=null&&s>0){let{fromStart:t,renderAll:r}=Z({isPartial:e.isPartial,rangeSize:s,expandedHunks:a,hunkIndex:e.hunks.length,collapsedContextThreshold:i});n+=r?s:t}}return n}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=this.height,f=this.cache.totalLines>0?this.cache.totalLines:this.getExpandedLineCount(e,l),p=X(this.metrics,i),m=e.hunks.length>0?Fi(this.metrics):0;if(t<n-d||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-p-m};if(f<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(),f=this.cache.totalLines>0?this.cache.totalLines:f;let h=Math.ceil(Math.max(r-n,0)/c),g=Math.ceil(h/s)*s+s,_=g/s,v=_,y=[],b=(n+r)/2,x=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-g*c*2),s),S=t+(x?.top??p),C=x?.renderedLineIndex??0,w,T,E;if(Qi({diff:e,diffStyle:l,startingLine:x?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:i,collapsedBefore:a,collapsedAfter:o,deletionLine:c,additionLine:d})=>{let f=d==null?c.splitLineIndex:d.splitLineIndex,m=d==null?c.unifiedLineIndex:d.unifiedLineIndex,h=(d?.noEOFCR??!1)||(c?.noEOFCR??!1),g=(a>0?Xi({type:u,metrics:this.metrics,hunkIndex:e,hunkSpecs:i?.hunkSpecs}):void 0)?.totalHeight??0;S+=g;let _=C%s===0,x=Math.floor(C/s);if(_&&(y[x]=S-(t+p+g),E!=null)){if(E<=0)return!0;E--}let D=this.getLineHeight(l===`split`?f:m,h);return S>n-D&&S<r&&(w??=x),T==null&&S+D>b&&(T=x),E==null&&S>=r&&_&&(E=v),C++,S+=D,o>0&&(S+=Zi({type:u,metrics:this.metrics})?.totalHeight??0),!1}}),w==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-p-m};T??=w;let D=Math.round(T-_/2),O=Math.max(0,Math.ceil(f/s)-_),k=Math.max(0,Math.min(D,O)),ee=k*s,te=D<0?g+D*s:g,ne=y[k]??0,re=k+te/s;return{startingLine:ee,totalLines:te,bufferBefore:ne,bufferAfter:re<y.length?d-p-y[re]-m:d-(S-t)-m}}};function Fo(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function Io({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Lo(e,n);return(t[Lo(e,r)]??0)-(t[i]??0)}function Lo(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Ro(e){return Math.ceil(e/Mo)*Mo}function zo(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Bo({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function Vo({fileDiff:e,hunk:t,hunkIndex:n,expandedHunks:r,collapsedContextThreshold:i}){if(n!==e.hunks.length-1||!Go(e))return;let a=e.additionLines.length-(t.additionLineIndex+t.additionCount),o=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(a!==o)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${a}, deletions=${o}) for ${e.name}`);return Z({isPartial:e.isPartial,rangeSize:Math.min(a,o),expandedHunks:r,hunkIndex:e.hunks.length,collapsedContextThreshold:i})}function Ho(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.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Uo(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Wo(e){return typeof e==`function`?`custom`:e??`line-info`}function Go(e){let t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function Ko(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var qo=typeof window>`u`?M.useEffect:M.useLayoutEffect;function Jo({fileDiff:e,options:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:i,metrics:a,hasGutterRenderUtility:o,hasCustomHeader:s,disableWorkerPool:c}){let l=Va(),u=r!==void 0,d=(0,M.useContext)(za),f=(0,M.useRef)(null),p=Hi(r=>{if(r!=null){if(f.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);l==null?f.current=new xo(Yo({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),c?void 0:d,!0):f.current=new Po(Yo({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),l,a,c?void 0:d,!0),f.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:i})}else{if(f.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);f.current.cleanUp(),f.current=null}});return qo(()=>{let{current:i}=f;if(i==null)return;let a=Yo({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),c=!Rn(i.options,a);i.setOptions(a),i.render({forceRender:c,fileDiff:e,lineAnnotations:n}),r!==void 0&&i.setSelectedLines(r)}),{ref:p,getHoveredLine:(0,M.useCallback)(()=>f.current?.getHoveredLine(),[])}}function Yo({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return!t&&!r&&!n?e:{...e,controlledSelection:t,renderCustomHeader:n?Nn:e?.renderCustomHeader,renderGutterUtility:r?Nn:e?.renderGutterUtility}}function Xo({fileDiff:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,className:a,style:o,prerenderedHTML:s,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderMetadata:d,renderGutterUtility:f,disableWorkerPool:p=!1}){let{ref:m,getHoveredLine:h}=Jo({fileDiff:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:s,hasGutterRenderUtility:f!=null,hasCustomHeader:l!=null,disableWorkerPool:p});return(0,V.jsx)(Lt,{ref:m,className:a,style:o,children:Fn(Ya({fileDiff:e,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderMetadata:d,renderAnnotation:c,renderGutterUtility:f,lineAnnotations:r,getHoveredLine:h}),s)})}var Zo=r(),Qo=`
88
+ `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function Ma({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 Na({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}var Pa={forcePlainText:!1};function Fa(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=Pa){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=Jr({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??La();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}Qi({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:c?h:!0,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&Ia({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=Ra({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function Ia({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=R(e),t=R(t),e.length>s||t.length>s))return;let c=o===`char`?sa(e,t):xa(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(Na({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),Na({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?Na({item:e,arr:l,enableJoin:d,isLastItem:t}):Na({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(Ma({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(Ma({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function La(){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 Ra({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=L,...l}}){let u=s??J(e.name),d=s??J(t.name),{state:f,transformers:p}=Gr(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:Y(`token`)}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:Y(`token`)};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,Xr(i.codeToHast(R(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,Xr(i.codeToHast(R(t.contents),m)))}}var za=(0,M.createContext)(void 0),Ba=(0,M.createContext)(void 0);function Va(){return(0,M.useContext)(Ba)}var Ha=typeof window>`u`?M.useEffect:M.useLayoutEffect;function Ua({file:e,options:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:i,metrics:a,hasGutterRenderUtility:o,hasCustomHeader:s,disableWorkerPool:c}){let l=Va(),u=r!==void 0,d=(0,M.useContext)(za),f=(0,M.useRef)(null),p=Hi(r=>{if(r!=null){if(f.current!=null)throw Error(`File: An instance should not already exist when a node is created`);l==null?f.current=new Ai(Wa({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),c?void 0:d,!0):f.current=new Bi(Wa({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),l,a,c?void 0:d,!0),f.current.hydrate({file:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:i})}else{if(f.current==null)throw Error(`File: A File instance should exist when unmounting`);f.current.cleanUp(),f.current=null}});return Ha(()=>{if(f.current==null)return;let i=Wa({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),a=!Rn(f.current.options,i);f.current.setOptions(i),f.current.render({file:e,lineAnnotations:n,forceRender:a}),r!==void 0&&f.current.setSelectedLines(r)}),{ref:p,getHoveredLine:(0,M.useCallback)(()=>f.current?.getHoveredLine(),[])}}function Wa({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return!t&&!r&&!n?e:{...e,controlledSelection:t,renderCustomHeader:n?Nn:e?.renderCustomHeader,renderGutterUtility:r?Nn:e?.renderGutterUtility}}function Ga({file:e,lineAnnotations:t,selectedLines:n,options:r,metrics:i,className:a,style:o,renderAnnotation:s,renderCustomHeader:c,renderHeaderPrefix:l,renderHeaderMetadata:u,prerenderedHTML:d,renderGutterUtility:f,disableWorkerPool:p=!1}){let{ref:m,getHoveredLine:h}=Ua({file:e,options:r,metrics:i,lineAnnotations:t,selectedLines:n,prerenderedHTML:d,hasGutterRenderUtility:f!=null,hasCustomHeader:c!=null,disableWorkerPool:p});return(0,V.jsx)(Lt,{ref:m,className:a,style:o,children:Fn(Pn({file:e,renderAnnotation:s,renderCustomHeader:c,renderHeaderPrefix:l,renderHeaderMetadata:u,renderGutterUtility:f,lineAnnotations:t,getHoveredLine:h}),d)})}function Ka({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function qa(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:Ja(n,e.startContentIndex)}}function Ja(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function Ya({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderMergeConflictUtility:s,lineAnnotations:c,getHoveredLine:l,getInstance:u}){let d=n?.(e),f=r?.(e),p=i?.(e);return(0,V.jsxs)(V.Fragment,{children:[d==null?(0,V.jsxs)(V.Fragment,{children:[f!=null&&(0,V.jsx)(`div`,{slot:`header-prefix`,children:f}),p!=null&&(0,V.jsx)(`div`,{slot:`header-metadata`,children:p})]}):(0,V.jsx)(`div`,{slot:Jt,children:d}),a!=null&&c?.map((e,t)=>(0,V.jsx)(`div`,{slot:B(e),children:a(e)},t)),t!=null&&s!=null&&u!=null&&t.map(t=>{if(t==null)return;let n=Xa(t,e);return(0,V.jsx)(`div`,{slot:n,style:Mn,children:s(t,u)},n)}),o!=null&&(0,V.jsx)(`div`,{slot:`gutter-utility-slot`,style:jn,children:o(l)})]})}function Xa(e,t){let n=qa(e,t);return n==null?void 0:Ka({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}function Za(e,t,n,r=!1){let i=pn(Aa(e.name,t.name,e.contents,t.contents,e.header,t.header,n),{cacheKey:(()=>{if(e.cacheKey!=null&&t.cacheKey!=null)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:r});if(i==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);return t.lang!=null&&(i.lang=t.lang),i}var Qa=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function $a(e){return U({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function eo(e){return U({tagName:`div`,children:[U({tagName:`span`,children:[H(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function to(e){return U({tagName:`div`,children:[Un({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 no({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(U({tagName:`div`,children:[H(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(to(`up`)),s++),o||(e.push(to(`down`)),s++)):(e.push(to(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(U({tagName:`div`,children:[U({tagName:`span`,children:[H(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(U({tagName:`div`,children:[H(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(U({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(U({tagName:`slot`,properties:{name:i}})),U({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function ro(e,t){return`hunk-separator-${e}-${t}`}function io(e){let t=e.at(-1);return t==null?0:Math.max(t.additionStart+t.additionCount,t.deletionStart+t.deletionCount)}function ao(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}var oo=-1,so=class{__id=`diff-hunks-renderer:${++oo}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;constructor(e={theme:L},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=Cr(e.theme??L)?de():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}clearRenderCache(){this.renderCache=void 0}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??tn}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e}}getSplitLineDecoration({side:e,type:t}){return t===`change`?{gutterLineType:e===`deletions`?`change-deletion`:`change-addition`}:{gutterLineType:t}}createAnnotationElement(e){return Er(e)}getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=L,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=$t,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}async initializeHighlighter(){return this.highlighter=await le(Pr(this.computedLang,this.options)),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=ho(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!Wi(t,r.options)&&(r=void 0),this.renderCache??={diff:e,highlighted:!n&&!Gi(e),options:t,result:n?void 0:r?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLang=e.lang??J(e.name),this.initializeHighlighter())}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:ei(this.options),tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!Ui(e,n.diff)||!Wi(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=nn){if(e==null)return;let{expandUnchanged:n=!1,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getMatchingWorkerResultCache(e,i);o!=null&&!this.hasHighlightedRenderCache(e,i)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||Gi(e)||ho(e,this.getTokenizeMaxLength()),l=!Ui(e,this.renderCache.diff),u=!gr(this.renderCache.renderRange,t);if(this.workerManager?.isWorkingPool()===!0)(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,ao(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??J(e.name);let t=this.highlighter!=null&&Cr(i.theme),n=this.highlighter!=null&&xr(this.computedLang),r=!c&&n;if(this.highlighter!=null&&t&&(a||c||!this.renderCache.highlighted&&r||this.renderCache.result==null)){let{result:t,options:i}=this.renderDiffWithHighlighter(e,this.highlighter,c||!n);this.renderCache={diff:e,options:i,highlighted:r,result:t,renderRange:void 0}}(!t||!c&&!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=nn){let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return Mr({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=ho(e,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??J(e.name);let n=this.highlighter!=null&&Cr(this.options.theme??L),r=t||this.highlighter!=null&&xr(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults();return{result:Fa(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i}),options:r}}onHighlightSuccess(e,t,n,r=!0){if(this.renderCache==null)return;let i=!this.renderCache.highlighted||!Wi(this.renderCache.options,n)||!Ui(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){let n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!Wi(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&Ui(e,n.diff)&&Wi(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults();this.diff=e;let d=a===`unified`,f=[],p=[],m=[],h=[],{additionLines:g,deletionLines:_}=n,v={rowCount:0,hunkSeparators:u,additionsContentAST:f,deletionsContentAST:p,unifiedContentAST:m,unifiedGutterAST:W(),deletionsGutterAST:W(),additionsGutterAST:W(),expansionLineCount:c,hunkData:h,incrementRowCount(e=1){v.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:v.unifiedGutterAST.children.push(t);break;case`deletions`:v.deletionsGutterAST.children.push(t);break;case`additions`:v.additionsGutterAST.children.push(t);break}}},y=go(e),b={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!==`unified`){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side===`additions`?(v.pushToGutter(`additions`,G(void 0,`buffer`,this.size)),f?.push($a(this.size))):(v.pushToGutter(`deletions`,G(void 0,`buffer`,this.size)),p?.push($a(this.size))),this.size=0,this.side=void 0}}},x=(e,t,n,r,i)=>{v.pushToGutter(e,Gn(t,n,r,i))};function S(e){b.flush(),a===`unified`?po(`unified`,e,v):(po(`deletions`,e,v),po(`additions`,e,v))}Qi({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,d=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&b.flush(),r>0&&S({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:!e.isPartial});let f=a===`unified`?d:l,p={type:c,hunkIndex:t,lineIndex:f,unifiedLineIndex:d,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(p);n?.before!=null&&lo(n.before,v);let r=s==null?void 0:_[s.lineIndex],i=o==null?void 0:g[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});x(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${d},${l}`,u.gutterProperties),i==null?r!=null&&(r=mo(r,u.contentProperties)):i=mo(i,u.contentProperties),fo({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,f),createAnnotationElement:e=>this.createAnnotationElement(e),context:v}),n?.after!=null&&lo(n.after,v)}else{let n=this.getSplitInjectedRowsForLine?.(p);n?.before!=null&&uo(n.before,v,b);let r=s==null?void 0:_[s.lineIndex],i=o==null?void 0:g[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let d=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();if(d!=null){if(b.side!=null&&b.side!==d)throw Error(`DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits`);b.side=d,b.increment()}let m=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,f);if(m!=null&&b.size>0&&b.flush(),s!=null){let e=mo(r,a.contentProperties);x(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=mo(i,u.contentProperties);x(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}fo({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...m,createAnnotationElement:e=>this.createAnnotationElement(e),context:v}),n?.after!=null&&uo(n.after,v,b)}let m=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,h=m?n.noEOFCRDeletions:!1,C=m?n.noEOFCRAdditions:!1,w=(s?.noEOFCR??!1)||h,T=(o?.noEOFCR??!1)||C;if(T||w){if(a===`split`&&b.flush(),w){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(v.unifiedContentAST.push(eo(e)),v.pushToGutter(`unified`,G(e,`metadata`,1))):(v.deletionsContentAST.push(eo(e)),v.pushToGutter(`deletions`,G(e,`metadata`,1)),T||(v.pushToGutter(`additions`,G(void 0,`buffer`,1)),v.additionsContentAST.push($a(1))))}if(T){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(v.unifiedContentAST.push(eo(e)),v.pushToGutter(`unified`,G(e,`metadata`,1))):(v.additionsContentAST.push(eo(e)),v.pushToGutter(`additions`,G(e,`metadata`,1)),w||(v.pushToGutter(`deletions`,G(void 0,`buffer`,1)),v.deletionsContentAST.push($a(1))))}v.incrementRowCount(1)}i>0&&u!==`simple`&&S({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:i,rangeSize:y,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),v.incrementRowCount(1)}}),a===`split`&&b.flush();let C=Math.max(io(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),w=t.bufferBefore>0||t.bufferAfter>0,T=!d&&e.type!==`deleted`,E=!d&&e.type!==`new`,D=v.rowCount>0||w;f=T&&D?f:void 0,p=E&&D?p:void 0,m=d&&D?m:void 0;let ee=this.createPreElement(p!=null&&f!=null,C);return{unifiedGutterAST:d&&D?v.unifiedGutterAST.children:void 0,unifiedContentAST:m,deletionsGutterAST:E&&D?v.deletionsGutterAST.children:void 0,deletionsContentAST:p,additionsGutterAST:T&&D?v.additionsGutterAST.children:void 0,additionsContentAST:f,hunkData:h,preNode:ee,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:C,rowCount:v.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=W(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,Dr(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(U({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(U({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(U({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return A(this.renderFullAST(e,t))}renderPartialHTML(e,t){return A(t==null?e:U({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(B(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(B(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(!(o.annotations.length===0&&a.annotations.length===0))return{deletionSpan:a,additionSpan:o}}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return kr({fileOrDiff:e,mode:t,stickyHeader:n})}};function co(e){return`${e} unmodified line${e>1?`s`:``}`}function lo(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function uo(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function fo({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,G(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,G(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,G(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function po(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,no({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(no({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,no({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(no({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=ro(e,t),d=r>c.expansionLineCount,f=s?t:void 0;c.pushToGutter(e,no({type:c.hunkSeparators,content:co(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(no({type:c.hunkSeparators,content:co(n),expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:n,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function mo(e,t){return e==null||e.type!==`element`||t==null?e:{...e,properties:{...e.properties,...t}}}function ho(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function go(e){let t=e.hunks.at(-1);if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`DiffHunksRenderer.processDiffResult: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}function _o(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function vo(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function yo(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:e?.useTokenTransformer,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,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var bo=-1,xo=class{static LoadedCustomComponent=!0;__id=`file-diff:${++bo}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;constructor(e={theme:L},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new dr,this.scrollSyncManager=new Qa,this.interactionManager=new qn(`diff`,Jn(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 yo(e)}createHunksRenderer(e){return new so(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>{if(this.fileDiff==null)return;let n=this.fileDiff.hunks.at(-1),r,i;hunkIterator:for(let a of this.fileDiff.hunks){let o=t===`deletions`?a.deletionStart:a.additionStart,s=t===`deletions`?a.deletionCount:a.additionCount,c=a.splitLineStart,l=a.unifiedLineStart;if(e<o){let t=o-e;r=Math.max(l-t,0),i=Math.max(c-t,0);break hunkIterator}if(e>=o+s){if(a===n){let t=e-(o+s);r=l+a.unifiedLineCount+t,i=c+a.splitLineCount+t;break hunkIterator}continue}for(let n of a.hunkContent)if(n.type===`context`)if(e<o+n.lines){let t=e-o;i=c+t,r=l+t;break hunkIterator}else o+=n.lines,c+=n.lines,l+=n.lines;else{let a=t===`deletions`?n.deletions:n.additions;if(e<o+a){let a=e-o;r=l+(t===`additions`?n.deletions:0)+a,i=c+a;break hunkIterator}else o+=a,c+=Math.max(n.deletions,n.additions),l+=n.deletions+n.additions}break hunkIterator}if(!(r==null||i==null))return[r,i]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Jn(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Ln(this.appliedThemeCSS.theme,this.options.theme??L)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,t===`wrap`),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,this.lineAnnotations=[],this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore=void 0,this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,lineAnnotations:i,oldFile:a,newFile:o,fileDiff:s}=e;this.hydrateElements(t,n),wo(this.pre,So({fileDiff:s,oldFile:a,newFile:o}),this.options.collapsed)||To(this.headerElement,Co({fileDiff:s,oldFile:a,newFile:o}),this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({fileDiff:s,oldFile:a,newFile:o,lineAnnotations:i}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Ei(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)!(e instanceof HTMLElement)||e.tagName.toLowerCase()!==`code`||(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!=null&&n!=null?Za(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.rerender()};render({oldFile:e,newFile:t,fileDiff:n,deferManagers:r=!1,forceRender:i=!1,preventEmit:a=!1,lineAnnotations:o,fileContainer:s,containerWrapper:c,renderRange:l}){if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);let{collapsed:u=!1,themeType:d=`system`}=this.options,f=u?void 0:l,p=this.hasThemeChanged(),m=e!=null&&t!=null&&(!q(e,this.deletionFile)||!q(t,this.additionFile)),h=n!=null&&n!==this.fileDiff,g=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1;if(!u&&gr(f,this.renderRange)&&!i&&!g&&!p&&(n!=null&&n===this.fileDiff||n==null&&!m))return this.applyCachedThemeState(d);let{renderRange:_}=this;if(this.renderRange=f,this.deletionFile=e,this.additionFile=t,n==null?e!=null&&t!=null&&m&&(h=!0,this.fileDiff=Za(e,t,this.options.parseDiffOptions)):this.fileDiff=n,h&&(this.cachedHeaderHTML=void 0),o!=null&&this.setLineAnnotations(o),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:v=!1,disableFileHeader:y=!1}=this.options;if(y&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),s=this.getOrCreateFileContainer(s,c),this.applyCachedThemeState(d),u){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(this.fileDiff,rn);e!=null&&this.applyThemeState(s,e.themeStyles,d,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,s),this.renderSeparators([]),this.injectUnsafeCSS()}catch(e){if(v)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,s)}return a||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(s);if(!(this.canPartiallyRender(i,g,m||h||p)&&this.applyPartialRender({previousRenderRange:_,renderRange:f}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,f);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(s,t.themeStyles,d,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,s),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,f),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,r||this.flushManagers()}catch(e){if(v)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,s)}return a||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}primeHighlightCache(){let{fileDiff:e,workerManager:t}=this;if(e==null||t==null||Gi(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||t.primeDiffHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!vo(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${B(r)}`,a=this.annotationCache.get(i);if(a==null||!_o(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:li(B(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=ui();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:Bn(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):Bn(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=ii;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:n}=this,r=this.cachedHeaderHTML??A(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;let{renderCustomHeader:i,renderHeaderPrefix:a,renderHeaderMetadata:o}=this.options;if(i!=null){let e=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Jt,e),this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0;return}let s=a?.(n)??void 0,c=o?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Kt,s),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,qt,c),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=di(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=vi(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??L,s=typeof o==`string`?o:{...o},c=pi(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=wi({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:yi(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=bi(this.themeCSSStyle.textContent??``,pi(e)))}applyHunksToDOM(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Ci({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Ci({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Ci({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:a,options:{diffStyle:o=`split`}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(o,r,a,i);if(s==null)return!1;let c=e.startingLine,l=t.startingLine,u=c+e.totalLines,d=l+t.totalLines,f=Math.max(c,l),p=Math.min(u,d);if(p<=f)return!1;let m=Math.max(0,f-c),h=Math.max(0,u-p),g=this.trimColumns({columns:s,trimStart:m,trimEnd:h,previousStart:c,overlapStart:f,overlapEnd:p,diffStyle:o});if(g<0)throw Error(`applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`applyPartialRender: trimmed beyond DOM row count`);let _=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},y=v(l,Math.max(f-l,0));if(y==null&&l<f)return!1;let b=v(p,Math.max(d-p,0));if(b==null&&d>p)return!1;let x=(e,t)=>{if(e!=null){if(o===`unified`&&!Array.isArray(s))this.insertPartialHTML(o,s,e,t);else if(o===`split`&&Array.isArray(s))this.insertPartialHTML(o,s,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);_+=e.rowCount}};return this.cleanupErrorWrapper(),x(y,`afterbegin`),x(b,`beforeend`),this.lastRowCount!==_&&(this.applyRowSpan(o,s,_),this.lastRowCount=_),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=Eo(t[0]),i=Eo(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}else throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getCodeColumns(e,t,n,r){function i(e){if(e==null)return;let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}if(e===`unified`)return i(t);{let e=i(n),t=i(r);return e!=null||t!=null?[e,t]:void 0}}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l===`unified`?!1:t!=null&&n!=null,totalLines:r,customProperties:i};oi(u,this.appliedPreAttributes)||(Di(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function So({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function Co({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function wo(e,t,n=!1){return!n&&e==null&&t}function To(e,t,n=!1){return e==null&&t&&!n}function Eo(e){if(!(e==null||e.type!==`element`))return e.children??[]}function Do({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o}){let s=X(t,n),c=s,l=i?!0:a,u=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=Z({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:l,hunkIndex:n,collapsedContextThreshold:o}),d=(a.fromStart+a.fromEnd)*t.lineHeight;if(s+=d,c+=d,a.collapsedLines>0){let e=Xi({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;s+=e,c+=e}s+=i.splitLineCount*t.lineHeight,c+=i.unifiedLineCount*t.lineHeight;let f=Oo(i);if(s+=f.split*t.lineHeight,c+=f.unified*t.lineHeight,n===u&&Ao(e)){let n=Z({isPartial:e.isPartial,rangeSize:jo(e,i),expandedHunks:l,hunkIndex:e.hunks.length,collapsedContextThreshold:o}),a=(n.fromStart+n.fromEnd)*t.lineHeight;if(s+=a,c+=a,n.collapsedLines>0){let e=Zi({type:r,metrics:t})?.totalHeight??0;s+=e,c+=e}}}if(e.hunks.length>0){let e=Fi(t);s+=e,c+=e}return{splitHeight:s,unifiedHeight:c}}function Oo(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return ko(e,t)}function ko(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function Ao(e){let t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function jo(e,t){let n=e.additionLines.length-(t.additionLineIndex+t.additionCount),r=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(n!==r)throw Error(`computeEstimatedDiffHeights: trailing context mismatch (additions=${n}, deletions=${r}) for ${e.name}`);return Math.min(n,r)}var Mo=5e3,No=-1,Po=class extends xo{__id=`little-virtualized-file-diff:${++No}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=Ni(n)}setMetrics(e,t=!1){let n=Ni(e);!t&&In(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!Rn(t,e),r=n&&Ho(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Uo(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1}={}){this.layoutDirty=!0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),t&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1,{overflow:t=`scroll`}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;let n=this.getDiffStyle(),r=n===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified];for(let t of r){if(t==null)continue;let r=t.children[1];if(r instanceof HTMLElement)for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let i=Ko(r,n),a=t.getBoundingClientRect().height,o=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(o=!0),a+=t.nextElementSibling.getBoundingClientRect().height);let s=this.getEstimatedLineHeight(o),c=this.cache.heightDeltas.get(i)??0,l=a-s;l!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=l-c,l===0?this.cache.heightDeltas.delete(i):this.cache.heightDeltas.set(i,l))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render());prepareCodeViewItem(e,t,n){let r=!Ui(this.fileDiff,e),i=n?.resetDiffLayoutCache===!0||r,a=r||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=Ni(n.metrics),i=!0,a=!0);let{collapsed:o=!1}=this.options;return this.currentCollapsed!==o&&(this.currentCollapsed=o,i=!0),i&&this.resetLayoutCache({includeEstimatedHeights:a}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t=`additions`){if(this.fileDiff==null)return;let n=this.getLineIndex(e,t);if(n==null)return;let{disableFileHeader:r=!1,expandUnchanged:i=!1,collapsed:a=!1,collapsedContextThreshold:o=1}=this.options,s=this.getDiffStyle(),c=this.getHunkSeparatorType(),l=s===`split`?n[1]:n[0];this.approximateLayoutCheckpoints();let u=this.getLayoutCheckpointBeforeLineIndex(l),d=u?.top??X(this.metrics,r);if(a)return{top:d,height:0};let f;return Qi({diff:this.fileDiff,diffStyle:s,startingLine:u?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=s===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=Xi({type:c,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(d+=r.gapBefore,l>=o-n&&l<o)return f={top:d,height:r.height},!0;d+=r.height+r.gapAfter}}let u=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===l)return f={top:d,height:u},!0;if(d+=u,r>0){let e=Zi({type:c,metrics:this.metrics});if(e!=null){if(l>o&&l<=o+r)return f={top:d+e.gapBefore,height:e.height},!0;d+=e.totalHeight}}return!1}}),f}getNumericScrollAnchor(e){if(this.fileDiff==null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1}=this.options;if(r)return;let a=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();let s=this.getLayoutCheckpointBeforeTop(e),c=s?.top??X(this.metrics,t),l;return Qi({diff:this.fileDiff,diffStyle:a,startingLine:s?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:s,additionLine:u})=>{let d=a===`split`?u?.splitLineIndex??s?.splitLineIndex:u?.unifiedLineIndex??s?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=Xi({type:o,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(c+=e.totalHeight)}if(c>=e&&(s==null?u!=null&&(l={lineNumber:u.lineNumber,side:`additions`,top:c}):l={lineNumber:s.lineNumber,side:`deletions`,top:c},l!=null))return!0;let f=this.getLineHeight(d,(u?.noEOFCR??!1)||(s?.noEOFCR??!1));if(c+=f,i>0){let e=Zi({type:o,metrics:this.metrics});e!=null&&(c+=e.totalHeight)}return!1}}),l}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.fileDiff,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache({includeEstimatedHeights:!0}),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize(),this.virtualizer.instanceChanged(this,!0)};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))}computeApproximateSize(e=!1){let t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;let n=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,this.fileDiff==null){this.layoutDirty=!1;return}let{disableFileHeader:r=!1,collapsed:i=!1}=this.options,a=X(this.metrics,r);if(this.height+=a,i){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight()+this.cache.measuredHeightDeltaTotal,t&&!n&&this.validateComputedHeight(),this.layoutDirty=!1}getActiveEstimatedHeight(){this.ensureEstimatedDiffHeights();let e=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(e==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return e}ensureEstimatedDiffHeights(){if(this.fileDiff==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:n=1}=this.options,{splitHeight:r,unifiedHeight:i}=Do({fileDiff:this.fileDiff,metrics:this.metrics,disableFileHeader:e,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:t,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:n});this.cache.estimatedSplitHeight=r,this.cache.estimatedUnifiedHeight=i}validateComputedHeight(){if(this.fileContainer==null||this.fileDiff==null)return;let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height})}render({fileContainer:e,oldFile:t,newFile:n,fileDiff:r,forceRender:i=!1,...a}={}){let{forceRenderOverride:o,isSetup:s}=this;if(this.forceRenderOverride=void 0,this.fileDiff??=r??(t!=null&&n!=null?Za(t,n,this.options.parseDiffOptions):void 0),e=this.getOrCreateFileContainer(e),this.fileDiff==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(s)this.top??=this.getVirtualizedTop();else{this.computeApproximateSize();let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);let c=this.virtualizer.getWindowSpecs(),l=this.top??0,u=this.computeRenderRangeFromWindow(this.fileDiff,l,c);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:u,oldFile:t,newFile:n,forceRender:o??i,...a})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Wo(this.options.hunkSeparators)}approximateLayoutCheckpoints(){if(this.cache.checkpoints.length>0||this.fileDiff==null||this.fileDiff.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:n=1}=this.options,r=this.getDiffStyle(),i=this.getHunkSeparatorType(),a=t?!0:this.hunksRenderer.getExpandedHunksMap(),o=Fo(this.cache.heightDeltas),s=X(this.metrics,e),c=0,l=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=c,l=c+e,u=Ro(a);for(;u<l;){let e=u-a,r=s+(e>0?n:0)+e*this.metrics.lineHeight+zo(i,e)*this.metrics.lineHeight+Io(o,t,t+e);this.cache.checkpoints.push({renderedLineIndex:u,lineIndex:t+e,top:r}),u+=Mo}s+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+Io(o,t,t+e)+r,c=l};for(let e=0;e<this.fileDiff.hunks.length;e++){let t=this.fileDiff.hunks[e];if(t==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let o=Z({isPartial:this.fileDiff.isPartial,rangeSize:t.collapsedBefore,expandedHunks:a,hunkIndex:e,collapsedContextThreshold:n}),s=o.collapsedLines>0?Xi({type:i,metrics:this.metrics,hunkIndex:e,hunkSpecs:t.hunkSpecs})?.totalHeight??0:0;l({rowCount:o.fromStart,startLineIndex:(r===`split`?t.splitLineStart:t.unifiedLineStart)-o.rangeSize});let c=s;l({rowCount:o.fromEnd,startLineIndex:(r===`split`?t.splitLineStart:t.unifiedLineStart)-o.fromEnd,preSeparatorHeight:c}),o.fromEnd>0&&(c=0);let u=Vo({fileDiff:this.fileDiff,hunk:t,hunkIndex:e,expandedHunks:a,collapsedContextThreshold:n}),d=u!=null&&u.collapsedLines>0?Zi({type:i,metrics:this.metrics})?.totalHeight??0:0,f=u==null?0:u.fromStart+u.fromEnd,p=r===`split`?t.splitLineCount:t.unifiedLineCount,m=r===`split`?t.splitLineStart:t.unifiedLineStart;l({rowCount:p,startLineIndex:m,preSeparatorHeight:c,postSeparatorHeight:f===0?d:0,metadataOffsets:Bo({diffStyle:r,hunk:t,rowCount:p})}),u!=null&&f>0&&l({rowCount:f,startLineIndex:m+p,postSeparatorHeight:d})}this.cache.totalLines=c}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=Z({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=e.hunks.at(-1);if(o!=null&&Go(e)){let t=e.additionLines.length-(o.additionLineIndex+o.additionCount),r=e.deletionLines.length-(o.deletionLineIndex+o.deletionCount);if(o!=null&&t!==r)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${t}, deletions=${r}) for ${e.name}`);let s=Math.min(t,r);if(o!=null&&s>0){let{fromStart:t,renderAll:r}=Z({isPartial:e.isPartial,rangeSize:s,expandedHunks:a,hunkIndex:e.hunks.length,collapsedContextThreshold:i});n+=r?s:t}}return n}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=this.height,f=this.cache.totalLines>0?this.cache.totalLines:this.getExpandedLineCount(e,l),p=X(this.metrics,i),m=e.hunks.length>0?Fi(this.metrics):0;if(t<n-d||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-p-m};if(f<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(),f=this.cache.totalLines>0?this.cache.totalLines:f;let h=Math.ceil(Math.max(r-n,0)/c),g=Math.ceil(h/s)*s+s,_=g/s,v=_,y=[],b=(n+r)/2,x=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-g*c*2),s),S=t+(x?.top??p),C=x?.renderedLineIndex??0,w,T,E;if(Qi({diff:e,diffStyle:l,startingLine:x?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:i,collapsedBefore:a,collapsedAfter:o,deletionLine:c,additionLine:d})=>{let f=d==null?c.splitLineIndex:d.splitLineIndex,m=d==null?c.unifiedLineIndex:d.unifiedLineIndex,h=(d?.noEOFCR??!1)||(c?.noEOFCR??!1),g=(a>0?Xi({type:u,metrics:this.metrics,hunkIndex:e,hunkSpecs:i?.hunkSpecs}):void 0)?.totalHeight??0;S+=g;let _=C%s===0,x=Math.floor(C/s);if(_&&(y[x]=S-(t+p+g),E!=null)){if(E<=0)return!0;E--}let D=this.getLineHeight(l===`split`?f:m,h);return S>n-D&&S<r&&(w??=x),T==null&&S+D>b&&(T=x),E==null&&S>=r&&_&&(E=v),C++,S+=D,o>0&&(S+=Zi({type:u,metrics:this.metrics})?.totalHeight??0),!1}}),w==null)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:d-p-m};T??=w;let D=Math.round(T-_/2),ee=Math.max(0,Math.ceil(f/s)-_),O=Math.max(0,Math.min(D,ee)),te=O*s,k=D<0?g+D*s:g,ne=y[O]??0,re=O+k/s;return{startingLine:te,totalLines:k,bufferBefore:ne,bufferAfter:re<y.length?d-p-y[re]-m:d-(S-t)-m}}};function Fo(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function Io({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Lo(e,n);return(t[Lo(e,r)]??0)-(t[i]??0)}function Lo(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Ro(e){return Math.ceil(e/Mo)*Mo}function zo(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Bo({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function Vo({fileDiff:e,hunk:t,hunkIndex:n,expandedHunks:r,collapsedContextThreshold:i}){if(n!==e.hunks.length-1||!Go(e))return;let a=e.additionLines.length-(t.additionLineIndex+t.additionCount),o=e.deletionLines.length-(t.deletionLineIndex+t.deletionCount);if(a!==o)throw Error(`VirtualizedFileDiff: trailing context mismatch (additions=${a}, deletions=${o}) for ${e.name}`);return Z({isPartial:e.isPartial,rangeSize:Math.min(a,o),expandedHunks:r,hunkIndex:e.hunks.length,collapsedContextThreshold:i})}function Ho(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.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Uo(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Wo(e){return typeof e==`function`?`custom`:e??`line-info`}function Go(e){let t=e.hunks.at(-1);return t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0?!1:t.additionLineIndex+t.additionCount<e.additionLines.length||t.deletionLineIndex+t.deletionCount<e.deletionLines.length}function Ko(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}var qo=typeof window>`u`?M.useEffect:M.useLayoutEffect;function Jo({fileDiff:e,options:t,lineAnnotations:n,selectedLines:r,prerenderedHTML:i,metrics:a,hasGutterRenderUtility:o,hasCustomHeader:s,disableWorkerPool:c}){let l=Va(),u=r!==void 0,d=(0,M.useContext)(za),f=(0,M.useRef)(null),p=Hi(r=>{if(r!=null){if(f.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);l==null?f.current=new xo(Yo({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),c?void 0:d,!0):f.current=new Po(Yo({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),l,a,c?void 0:d,!0),f.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:i})}else{if(f.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);f.current.cleanUp(),f.current=null}});return qo(()=>{let{current:i}=f;if(i==null)return;let a=Yo({controlledSelection:u,hasCustomHeader:s,hasGutterRenderUtility:o,options:t}),c=!Rn(i.options,a);i.setOptions(a),i.render({forceRender:c,fileDiff:e,lineAnnotations:n}),r!==void 0&&i.setSelectedLines(r)}),{ref:p,getHoveredLine:(0,M.useCallback)(()=>f.current?.getHoveredLine(),[])}}function Yo({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return!t&&!r&&!n?e:{...e,controlledSelection:t,renderCustomHeader:n?Nn:e?.renderCustomHeader,renderGutterUtility:r?Nn:e?.renderGutterUtility}}function Xo({fileDiff:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,className:a,style:o,prerenderedHTML:s,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderMetadata:d,renderGutterUtility:f,disableWorkerPool:p=!1}){let{ref:m,getHoveredLine:h}=Jo({fileDiff:e,options:t,metrics:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:s,hasGutterRenderUtility:f!=null,hasCustomHeader:l!=null,disableWorkerPool:p});return(0,V.jsx)(Lt,{ref:m,className:a,style:o,children:Fn(Ya({fileDiff:e,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderMetadata:d,renderAnnotation:c,renderGutterUtility:f,lineAnnotations:r,getHoveredLine:h}),s)})}var Zo=r(),Qo=`
89
89
  :host,
90
90
  pre {
91
91
  --diffs-bg: var(--background) !important;
92
+ font-family: 'JetBrainsMono Nerd Font Mono', 'JetBrains Mono Variable', monospace !important;
93
+ font-size: inherit !important;
94
+ letter-spacing: 0 !important;
95
+ line-height: inherit !important;
92
96
  }
93
97
 
94
98
  pre {
@@ -100,10 +104,10 @@ diff --git`)}function Cn(e,t){if(e.length===0)return[``];let n=`\n${t}`,r=e.star
100
104
  ::after {
101
105
  border-radius: 0 !important;
102
106
  }
103
- `;function $o(e,t){let n=[...e.querySelector(`diffs-container`)?.shadowRoot?.querySelectorAll(`[data-line][data-line-type]`)??[]].find(e=>{let n=e.getBoundingClientRect();return t>=n.top&&t<=n.bottom});if(!n||n.dataset.lineType===`change-deletion`)return;let r=n.dataset.line;if(r)return{clientY:t,lineNumber:r,offsetWithinLine:t-n.getBoundingClientRect().top}}function es(e,t,n){let r=e.querySelector(`diffs-container`)?.shadowRoot?.querySelector(n===`diff`?`[data-line="${CSS.escape(t.lineNumber)}"]:not([data-line-type="change-deletion"])`:`[data-line="${CSS.escape(t.lineNumber)}"]`);r instanceof HTMLElement&&e.scrollTo({behavior:`instant`,top:e.scrollTop+r.getBoundingClientRect().top-(t.clientY-t.offsetWithinLine)})}function ts(e){let t=(0,Zo.c)(18),n=(0,M.useRef)(null),r;t[0]===e.comment.body?r=t[1]:(r=k(e.comment.body),t[0]=e.comment.body,t[1]=r);let[i,a]=(0,M.useState)(r),[o,s]=(0,M.useState)(e.comment.body),c,l;t[2]===i?(c=t[3],l=t[4]):(c=()=>{i&&n.current?.focus()},l=[i],t[2]=i,t[3]=c,t[4]=l),(0,M.useEffect)(c,l);let u;t[5]!==o||t[6]!==e?(u=function(){if(k(_(o))){if(e.isDraft){e.onCloseDraft?.();return}e.onDeleteComment?.({...e.comment,body:o}),a(!1),e.onCloseDraft?.();return}e.onSaveComment?.({...e.comment,body:_(o)}),a(!1),e.onCloseDraft?.()},t[5]=o,t[6]=e,t[7]=u):u=t[7];let d=u;if(i){let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r=e=>{s(e.currentTarget.value)},t[8]=r):r=t[8];let i;t[9]!==e||t[10]!==d?(i=t=>{t.key===`Escape`&&(t.preventDefault(),e.isDraft?e.onCloseDraft?.():a(!1)),t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),d())},t[9]=e,t[10]=d,t[11]=i):i=t[11];let c;return t[12]!==o||t[13]!==i?(c=(0,V.jsx)(`div`,{className:`text-foreground box-border w-full max-w-full bg-transparent px-3 py-2 text-xs`,children:(0,V.jsx)(`textarea`,{ref:n,value:o,placeholder:`Add comment`,className:`font-inherit block min-h-16 w-full resize-y border-0 bg-transparent p-0 text-inherit outline-none`,onChange:r,onClick:ns,onKeyDown:i})}),t[12]=o,t[13]=i,t[14]=c):c=t[14],c}let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{e.stopPropagation(),a(!0)},t[15]=f):f=t[15];let p;return t[16]===e.comment.body?p=t[17]:(p=(0,V.jsx)(`div`,{className:`text-foreground box-border w-full max-w-full bg-transparent px-3 py-2 text-xs`,children:(0,V.jsx)(`button`,{type:`button`,className:`block w-full bg-transparent p-0 text-left leading-relaxed whitespace-pre-wrap`,onClick:f,children:e.comment.body})}),t[16]=e.comment.body,t[17]=p),p}function ns(e){e.stopPropagation()}function rs(e){return e.type===`deleted`?``:s(i(e.hunks,t=>i(t.hunkContent,t=>c(ee(e.additionLines,t.additionLineIndex),t.type===`context`?t.lines:t.additions))),``)}function is(e){let t=(0,Zo.c)(21),n=(0,M.useRef)(null),r=(0,M.useRef)(void 0),i=(0,M.useRef)(void 0),[s,c]=(0,M.useState)(`diff`),[l,u]=(0,M.useState)(),d=me(e.filePath),p=An(kn(e.patch),d),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{n.current?.focus()},t[0]=m):m=t[0];let h;t[1]!==s||t[2]!==e.filePath||t[3]!==e.patch?(h=[s,e.filePath,e.patch],t[1]=s,t[2]=e.filePath,t[3]=e.patch,t[4]=h):h=t[4],(0,M.useEffect)(m,h);let g,_;t[5]===s?(g=t[6],_=t[7]):(g=()=>{let e=n.current,t=i.current;!e||!t||(es(e,t,s),i.current=void 0)},_=[s],t[5]=s,t[6]=g,t[7]=_),(0,M.useLayoutEffect)(g,_);let v;t[8]!==l||t[9]!==e.comments||t[10]!==e.filePath||t[11]!==e.onSaveComment?(v=function(t){e.onSaveComment&&(l&&l.filePath===e.filePath&&l.lineNumber===t.lineNumber&&l.side===`deletions`==(t.side===`deletions`)||l||b(e.comments??o(),n=>n.filePath===e.filePath&&n.lineNumber===t.lineNumber&&n.side===`deletions`==(t.side===`deletions`))||u({body:``,filePath:e.filePath,lineNumber:t.lineNumber,side:t.side===`deletions`?t.side:void 0}))},t[8]=l,t[9]=e.comments,t[10]=e.filePath,t[11]=e.onSaveComment,t[12]=v):v=t[12];let y=v,x,C,w;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{r.current=e.clientY},w=e=>{r.current=e.clientY,e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLButtonElement||e.currentTarget.focus()},x=e=>{if(e.key===`Tab`){e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),n=r.current===void 0?t.top+t.height/2:Math.min(Math.max(r.current,t.top),t.bottom);i.current=$o(e.currentTarget,n),c(cs)}},t[13]=x,t[14]=C,t[15]=w):(x=t[13],C=t[14],w=t[15]);let T=s===`diff`?(0,V.jsx)(Xo,{fileDiff:p,options:{diffIndicators:`bars`,diffStyle:`unified`,disableBackground:!1,disableFileHeader:!0,disableLineNumbers:!1,lineDiffType:`word-alt`,onLineNumberClick:e=>{y({lineNumber:e.lineNumber,side:e.annotationSide})},overflow:`scroll`,theme:se,themeType:`system`,unsafeCSS:Qo},lineAnnotations:a(l?S(e.comments??o(),l):e.comments??o(),ss),renderAnnotation:t=>(0,V.jsx)(ts,{comment:t.metadata,isDraft:l&&t.metadata.filePath===l.filePath&&t.metadata.lineNumber===l.lineNumber&&t.metadata.side===`deletions`==(l.side===`deletions`),onSaveComment:e.onSaveComment,onDeleteComment:e.onDeleteComment,onCloseDraft:()=>{u(void 0)}})},e.patch):(0,V.jsx)(Ga,{file:{contents:rs(p),lang:d,name:e.filePath},options:{disableFileHeader:!0,disableLineNumbers:!1,onLineNumberClick:e=>{y({lineNumber:e.lineNumber})},overflow:`scroll`,theme:se,themeType:`system`,unsafeCSS:Qo},lineAnnotations:a(f(l?S(e.comments??o(),l):e.comments??o(),os),as),renderAnnotation:t=>(0,V.jsx)(ts,{comment:t.metadata,isDraft:l&&t.metadata.filePath===l.filePath&&t.metadata.lineNumber===l.lineNumber&&t.metadata.side===`deletions`==(l.side===`deletions`),onSaveComment:e.onSaveComment,onDeleteComment:e.onDeleteComment,onCloseDraft:()=>{u(void 0)}})},e.patch),E;return t[16]!==x||t[17]!==T||t[18]!==C||t[19]!==w?(E=(0,V.jsx)(`section`,{ref:n,tabIndex:-1,"aria-label":`Diff viewer`,className:`bg-background block h-full min-h-0 w-full overflow-auto rounded-none outline-none`,onPointerMoveCapture:C,onPointerDownCapture:w,onKeyDownCapture:x,children:T}),t[16]=x,t[17]=T,t[18]=C,t[19]=w,t[20]=E):E=t[20],E}function as(e){return{lineNumber:e.lineNumber,metadata:e}}function os(e){return e.side!==`deletions`}function ss(e){return{lineNumber:e.lineNumber,metadata:e,side:e.side??`additions`}}function cs(e){return e===`diff`?`file`:`diff`}var ls=ke(e=>j.runtime.atom(m(j,C(t=>t(`review.metadata`,{cwd:e}))))),us=ke(e=>j.runtime.atom(m(j,C(t=>t(`review.metadata`,e)))));function ds(e){return m(l(e),v({type:`head-to-worktree`},()=>`head-to-worktree`),v({type:`commit-to-worktree`},e=>`worktree:${e.commit}`),ne)}function fs(e){return m(l(e),v({type:`head-to-worktree`},()=>({from:{ref:`HEAD`,type:`ref`},to:{type:`worktree`}})),v({type:`commit-to-worktree`},e=>({from:{ref:e.from,type:`ref`},to:{type:`worktree`}})),ne)}var ps=ke(e=>Ae(j.runtime.atom(m(j,T(t=>t(`review.watchRange`,{cwd:e.cwd,...fs(e.target)})),Me))));function ms(e){let t=new Map;for(let n of e){let e=`${n.scope}:${n.filePath}`,r=t.get(e);r?r.comments.push(n):t.set(e,{comments:[n],filePath:n.filePath,key:e,scope:n.scope})}return E(t.values())}function hs(){let e=(0,Zo.c)(4),t=be.useParams(),n;e[0]===t.worktree?n=e[1]:(n=Ne(t.worktree),e[0]=t.worktree,e[1]=n);let r=Pe(n);if(!r.value.activeWorktree)return;let i;return e[2]===r.value.activeWorktree.root?i=e[3]:(i=(0,V.jsx)(gs,{cwd:r.value.activeWorktree.root},r.value.activeWorktree.root),e[2]=r.value.activeWorktree.root,e[3]=i),i}function gs(e){let t=be.useNavigate(),n=be.useSearch(),[r]=(0,M.useState)(Pe(ls(e.cwd)).value.base),i=Pe(us({base:r,cwd:e.cwd})),[c,l]=(0,M.useState)(o()),[p,h]=(0,M.useState)(!1),g=m(i.value.commits,D(e=>e.hash===n.commit),x),_=g?{commit:g.hash,from:g.parents[0]??`${g.hash}^`,type:`commit-to-worktree`}:{type:`head-to-worktree`},[v,y]=(0,M.useState)(``),C=Pe(ps({cwd:e.cwd,target:_})),w=m(C.value,D(e=>e.filePath===v),x)??C.value[0],T=Oe(ls(e.cwd)),E=Oe(us({base:r,cwd:e.cwd})),k=Oe(ps({cwd:e.cwd,target:_})),ee=b(i.value.commits,e=>e.wip);(0,M.useEffect)(()=>{let e=C.value[0]?.filePath;if(e===void 0){te(v)&&y(``);return}b(C.value,e=>e.filePath===v)||y(e)},[C.value,v]);function ne(e){(0,M.startTransition)(()=>{t({search:e.type===`commit-to-worktree`?{commit:e.commit}:{}})}),y(``)}function re(e){ne({commit:e.hash,from:e.parents[0]??`${e.hash}^`,type:`commit-to-worktree`})}function oe(){T(),E(),k()}It({key:`C`,shift:!0},()=>void se(c),{enabled:!d(c),preventDefault:!0}),It({key:`?`,shift:!0},()=>{h(!0)});async function se(e){await navigator.clipboard.writeText(m(ms(e),a(e=>s([`## ${e.filePath}`,m(e.comments,a(e=>`- ${e.side===`deletions`?`deleted`:`line`}:${e.lineNumber}: ${e.body}`),s(`
107
+ `;function $o(e,t){let n=[...e.querySelector(`diffs-container`)?.shadowRoot?.querySelectorAll(`[data-line][data-line-type]`)??[]].find(e=>{let n=e.getBoundingClientRect();return t>=n.top&&t<=n.bottom});if(!n||n.dataset.lineType===`change-deletion`)return;let r=n.dataset.line;if(r)return{clientY:t,lineNumber:r,offsetWithinLine:t-n.getBoundingClientRect().top}}function es(e,t,n){let r=e.querySelector(`diffs-container`)?.shadowRoot?.querySelector(n===`diff`?`[data-line="${CSS.escape(t.lineNumber)}"]:not([data-line-type="change-deletion"])`:`[data-line="${CSS.escape(t.lineNumber)}"]`);r instanceof HTMLElement&&e.scrollTo({behavior:`instant`,top:e.scrollTop+r.getBoundingClientRect().top-(t.clientY-t.offsetWithinLine)})}function ts(e){let t=(0,Zo.c)(18),n=(0,M.useRef)(null),r;t[0]===e.comment.body?r=t[1]:(r=S(e.comment.body),t[0]=e.comment.body,t[1]=r);let[i,a]=(0,M.useState)(r),[o,s]=(0,M.useState)(e.comment.body),c,l;t[2]===i?(c=t[3],l=t[4]):(c=()=>{i&&n.current?.focus()},l=[i],t[2]=i,t[3]=c,t[4]=l),(0,M.useEffect)(c,l);let u;t[5]!==o||t[6]!==e?(u=function(){if(S(te(o))){if(e.isDraft){e.onCloseDraft?.();return}e.onDeleteComment?.({...e.comment,body:o}),a(!1),e.onCloseDraft?.();return}e.onSaveComment?.({...e.comment,body:te(o)}),a(!1),e.onCloseDraft?.()},t[5]=o,t[6]=e,t[7]=u):u=t[7];let d=u;if(i){let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r=e=>{s(e.currentTarget.value)},t[8]=r):r=t[8];let i;t[9]!==e||t[10]!==d?(i=t=>{t.key===`Escape`&&(t.preventDefault(),e.isDraft?e.onCloseDraft?.():a(!1)),t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),d())},t[9]=e,t[10]=d,t[11]=i):i=t[11];let c;return t[12]!==o||t[13]!==i?(c=(0,V.jsx)(`div`,{className:`text-foreground box-border w-full max-w-full bg-transparent px-2 py-2`,children:(0,V.jsx)(`textarea`,{ref:n,value:o,placeholder:`Add comment`,className:`font-inherit block min-h-16 w-full resize-y border-0 bg-transparent p-0 text-inherit outline-none`,onChange:r,onClick:ns,onKeyDown:i})}),t[12]=o,t[13]=i,t[14]=c):c=t[14],c}let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{e.stopPropagation(),a(!0)},t[15]=f):f=t[15];let p;return t[16]===e.comment.body?p=t[17]:(p=(0,V.jsx)(`div`,{className:`text-foreground box-border w-full max-w-full bg-transparent px-2 py-2`,children:(0,V.jsx)(`button`,{type:`button`,className:`block w-full bg-transparent p-0 text-left whitespace-pre-wrap`,onClick:f,children:e.comment.body})}),t[16]=e.comment.body,t[17]=p),p}function ns(e){e.stopPropagation()}function rs(e){return e.type===`deleted`?``:u(w(e.hunks,t=>w(t.hunkContent,t=>d(c(e.additionLines,t.additionLineIndex),t.type===`context`?t.lines:t.additions))),``)}function is(e){let t=(0,Zo.c)(21),n=(0,M.useRef)(null),r=(0,M.useRef)(void 0),i=(0,M.useRef)(void 0),[a,o]=(0,M.useState)(`diff`),[c,u]=(0,M.useState)(),d=me(e.filePath),f=An(kn(e.patch),d),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{n.current?.focus()},t[0]=p):p=t[0];let m;t[1]!==a||t[2]!==e.filePath||t[3]!==e.patch?(m=[a,e.filePath,e.patch],t[1]=a,t[2]=e.filePath,t[3]=e.patch,t[4]=m):m=t[4],(0,M.useEffect)(p,m);let h,g;t[5]===a?(h=t[6],g=t[7]):(h=()=>{let e=n.current,t=i.current;!e||!t||(es(e,t,a),i.current=void 0)},g=[a],t[5]=a,t[6]=h,t[7]=g),(0,M.useLayoutEffect)(h,g);let _;t[8]!==c||t[9]!==e.comments||t[10]!==e.filePath||t[11]!==e.onSaveComment?(_=function(t){e.onSaveComment&&(c&&c.filePath===e.filePath&&c.lineNumber===t.lineNumber&&c.side===`deletions`==(t.side===`deletions`)||c||x(e.comments??v(),n=>n.filePath===e.filePath&&n.lineNumber===t.lineNumber&&n.side===`deletions`==(t.side===`deletions`))||u({body:``,filePath:e.filePath,lineNumber:t.lineNumber,side:t.side===`deletions`?t.side:void 0}))},t[8]=c,t[9]=e.comments,t[10]=e.filePath,t[11]=e.onSaveComment,t[12]=_):_=t[12];let y=_,b,S,C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{r.current=e.clientY},C=e=>{r.current=e.clientY,e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLButtonElement||e.currentTarget.focus()},b=e=>{if(e.key===`Tab`){e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),n=r.current===void 0?t.top+t.height/2:Math.min(Math.max(r.current,t.top),t.bottom);i.current=$o(e.currentTarget,n),o(cs)}},t[13]=b,t[14]=S,t[15]=C):(b=t[13],S=t[14],C=t[15]);let w=a===`diff`?(0,V.jsx)(Xo,{fileDiff:f,options:{diffIndicators:`bars`,diffStyle:`unified`,disableBackground:!1,disableFileHeader:!0,disableLineNumbers:!1,lineDiffType:`word-alt`,onLineNumberClick:e=>{y({lineNumber:e.lineNumber,side:e.annotationSide})},overflow:`scroll`,theme:se,themeType:`system`,unsafeCSS:Qo},lineAnnotations:s(c?k(e.comments??v(),c):e.comments??v(),ss),renderAnnotation:t=>(0,V.jsx)(ts,{comment:t.metadata,isDraft:c&&t.metadata.filePath===c.filePath&&t.metadata.lineNumber===c.lineNumber&&t.metadata.side===`deletions`==(c.side===`deletions`),onSaveComment:e.onSaveComment,onDeleteComment:e.onDeleteComment,onCloseDraft:()=>{u(void 0)}})},e.patch):(0,V.jsx)(Ga,{file:{contents:rs(f),lang:d,name:e.filePath},options:{disableFileHeader:!0,disableLineNumbers:!1,onLineNumberClick:e=>{y({lineNumber:e.lineNumber})},overflow:`scroll`,theme:se,themeType:`system`,unsafeCSS:Qo},lineAnnotations:s(l(c?k(e.comments??v(),c):e.comments??v(),os),as),renderAnnotation:t=>(0,V.jsx)(ts,{comment:t.metadata,isDraft:c&&t.metadata.filePath===c.filePath&&t.metadata.lineNumber===c.lineNumber&&t.metadata.side===`deletions`==(c.side===`deletions`),onSaveComment:e.onSaveComment,onDeleteComment:e.onDeleteComment,onCloseDraft:()=>{u(void 0)}})},e.patch),T;return t[16]!==b||t[17]!==w||t[18]!==S||t[19]!==C?(T=(0,V.jsx)(`section`,{ref:n,tabIndex:-1,"aria-label":`Diff viewer`,className:`bg-background block h-full min-h-0 w-full overflow-auto rounded-none outline-none`,onPointerMoveCapture:S,onPointerDownCapture:C,onKeyDownCapture:b,children:w}),t[16]=b,t[17]=w,t[18]=S,t[19]=C,t[20]=T):T=t[20],T}function as(e){return{lineNumber:e.lineNumber,metadata:e}}function os(e){return e.side!==`deletions`}function ss(e){return{lineNumber:e.lineNumber,metadata:e,side:e.side??`additions`}}function cs(e){return e===`diff`?`file`:`diff`}var ls=Me(e=>j.runtime.atom(i(j,a(t=>t(`review.metadata`,{cwd:e}))))),us=Me(e=>j.runtime.atom(i(j,a(t=>t(`review.metadata`,e)))));function ds(e){return i(f(e),y({type:`head-to-worktree`},()=>`head-to-worktree`),y({type:`commit-to-worktree`},e=>`worktree:${e.commit}`),ne)}function fs(e){return i(f(e),y({type:`head-to-worktree`},()=>({from:{ref:`HEAD`,type:`ref`},to:{type:`worktree`}})),y({type:`commit-to-worktree`},e=>({from:{ref:e.from,type:`ref`},to:{type:`worktree`}})),ne)}var ps=Me(e=>je(j.runtime.atom(i(j,C(t=>t(`review.watchRange`,{cwd:e.cwd,...fs(e.target)})),Ae))));function ms(e){let t=new Map;for(let n of e){let e=`${n.scope}:${n.filePath}`,r=t.get(e);r?r.comments.push(n):t.set(e,{comments:[n],filePath:n.filePath,key:e,scope:n.scope})}return o(t.values())}function hs(){let e=(0,Zo.c)(4),t=be.useParams(),n;e[0]===t.worktree?n=e[1]:(n=Pe(t.worktree),e[0]=t.worktree,e[1]=n);let r=Ne(n);if(!r.value.activeWorktree)return;let i;return e[2]===r.value.activeWorktree.root?i=e[3]:(i=(0,V.jsx)(gs,{cwd:r.value.activeWorktree.root},r.value.activeWorktree.root),e[2]=r.value.activeWorktree.root,e[3]=i),i}function gs(e){let t=be.useNavigate(),n=be.useSearch(),[r]=(0,M.useState)(Ne(ls(e.cwd)).value.base),a=Ne(us({base:r,cwd:e.cwd})),[o,c]=(0,M.useState)(v()),[d,f]=(0,M.useState)(!1),g=i(a.value.commits,h(e=>e.hash===n.commit),T),_=g?{commit:g.hash,from:g.parents[0]??`${g.hash}^`,type:`commit-to-worktree`}:{type:`head-to-worktree`},[y,b]=(0,M.useState)(``),S=Ne(ps({cwd:e.cwd,target:_})),C=i(S.value,h(e=>e.filePath===y),T)??S.value[0],w=Oe(ls(e.cwd)),D=Oe(us({base:r,cwd:e.cwd})),O=Oe(ps({cwd:e.cwd,target:_})),te=x(a.value.commits,e=>e.wip);(0,M.useEffect)(()=>{let e=S.value[0]?.filePath;if(e===void 0){ee(y)&&b(``);return}x(S.value,e=>e.filePath===y)||b(e)},[S.value,y]);function ne(e){(0,M.startTransition)(()=>{t({search:e.type===`commit-to-worktree`?{commit:e.commit}:{}})}),b(``)}function re(e){ne({commit:e.hash,from:e.parents[0]??`${e.hash}^`,type:`commit-to-worktree`})}function oe(){w(),D(),O()}It({key:`C`,shift:!0},()=>void se(o),{enabled:!m(o),preventDefault:!0}),It({key:`?`,shift:!0},()=>{f(!0)});async function se(e){await navigator.clipboard.writeText(i(ms(e),s(e=>u([`## ${e.filePath}`,i(e.comments,s(e=>`- ${e.side===`deletions`?`deleted`:`line`}:${e.lineNumber}: ${e.body}`),u(`
104
108
 
105
109
  `))],`
106
110
 
107
- `)),u(`# Review comments`),s(`
111
+ `)),p(`# Review comments`),u(`
108
112
 
109
- `))),l(t=>f(t,t=>!new Set(a(e,e=>`${e.scope}:${e.filePath}:${e.side===`deletions`?`deletions`:`file`}:${e.lineNumber}`)).has(`${t.scope}:${t.filePath}:${t.side===`deletions`?`deletions`:`file`}:${t.lineNumber}`)))}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(ge,{open:p,onOpenChange:h,children:(0,V.jsxs)(fe,{children:[(0,V.jsx)(ue,{children:(0,V.jsx)(ie,{children:`Shortcuts`})}),(0,V.jsxs)(`div`,{className:`grid gap-2 text-xs`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] gap-3`,children:[(0,V.jsx)(`kbd`,{className:`border px-1.5 py-0.5 text-center`,children:`?`}),(0,V.jsx)(`span`,{children:`Show shortcuts`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] gap-3`,children:[(0,V.jsx)(`kbd`,{className:`border px-1.5 py-0.5 text-center`,children:`Shift+C`}),(0,V.jsx)(`span`,{children:`Copy all queued comments`})]})]})]})}),(0,V.jsxs)(we,{orientation:`horizontal`,children:[(0,V.jsx)(Ce,{defaultSize:`34%`,minSize:`24%`,maxSize:`46%`,children:(0,V.jsxs)(`div`,{className:`flex h-full flex-col border-r`,children:[(0,V.jsx)(_s,{base:r,cwd:e.cwd,dirty:i.value.dirty,hasWipCommits:ee,refreshReview:oe}),(0,V.jsx)(`div`,{className:`min-h-0 flex-[1.2] border-b`,children:(0,V.jsx)(xs,{diffs:C.value,selectedEntry:w,selectReviewEntry:y})}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(vs,{commits:i.value.commits,selected:_,selectCommit:re,selectHead:()=>{ne({type:`head-to-worktree`})}})})]})}),(0,V.jsx)(Se,{}),(0,V.jsx)(Ce,{defaultSize:`66%`,minSize:`54%`,children:(0,V.jsxs)(`div`,{className:`bg-background flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[!w&&(0,V.jsx)(`div`,{className:`text-muted-foreground flex h-full items-center justify-center text-sm`,children:`No changed files.`}),w&&(0,V.jsx)(`div`,{className:`h-full min-h-0 min-w-0`,children:(0,V.jsx)(is,{filePath:w.filePath,patch:w.patch,comments:f(c,e=>e.scope===ds(_)&&e.filePath===w.filePath),onSaveComment:e=>{l(t=>m(t,f(t=>t.scope!==ds(_)||t.filePath!==e.filePath||t.lineNumber!==e.lineNumber||(t.side===`deletions`?`deletions`:`file`)!=(e.side===`deletions`?`deletions`:`file`)),S({...e,scope:ds(_)})))},onDeleteComment:e=>{l(t=>f(t,t=>t.scope!==ds(_)||t.filePath!==e.filePath||t.lineNumber!==e.lineNumber||(t.side===`deletions`?`deletions`:`file`)!=(e.side===`deletions`?`deletions`:`file`)))}})})]}),!d(c)&&(0,V.jsxs)(`footer`,{className:`grid min-h-8 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 border-t px-2`,children:[(0,V.jsx)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden`,children:a(ms(c),e=>(0,V.jsxs)(O,{type:`button`,variant:`outline`,size:`xs`,"aria-label":`Delete ${e.comments.length} queued comments for ${e.filePath}`,title:`Delete ${e.comments.length} comments for ${e.filePath}`,onClick:()=>{l(t=>f(t,t=>t.scope!==e.scope||t.filePath!==e.filePath))},children:[(0,V.jsx)(_e,{filePath:e.filePath}),(0,V.jsx)(`span`,{className:`max-w-32 truncate`,children:e.filePath.split(`/`).at(-1)??e.filePath})]},e.key))}),(0,V.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-1`,children:[(0,V.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Copy all queued comments`,title:`Copy all queued comments`,onClick:()=>void se(c),children:(0,V.jsx)(Fe,{})}),(0,V.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-destructive hover:text-destructive`,"aria-label":`Delete all queued comments`,title:`Delete all queued comments`,onClick:()=>{l(o())},children:(0,V.jsx)(ae,{})})]})]})]})})]})]})}function _s(e){let t=(0,Zo.c)(33),[n,r]=(0,M.useState)(``),i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=j.mutation(`review.createWipCommit`),a={mode:`promise`},t[0]=i,t[1]=a):(i=t[0],a=t[1]);let o=je(i,a),s,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=j.mutation(`review.commitAndPush`),c={mode:`promise`},t[2]=s,t[3]=c):(s=t[2],c=t[3]);let l=je(s,c),u,d;t[4]!==n||t[5]!==e.dirty||t[6]!==e.hasWipCommits?(d=m(n,_),u=k(d)||!e.dirty&&!e.hasWipCommits,t[4]=n,t[5]=e.dirty,t[6]=e.hasWipCommits,t[7]=u,t[8]=d):(u=t[7],d=t[8]);let f=u,p=e.dirty?`Create WIP commit`:`Squash WIP commits and push`,h;t[9]!==l||t[10]!==o||t[11]!==f||t[12]!==e||t[13]!==d?(h=async function(){if(!f)try{e.dirty?await o({payload:{cwd:e.cwd,message:d}}):await l({payload:{base:e.base,cwd:e.cwd,message:d}}),r(``),e.refreshReview()}catch{ye.error(e.dirty?`Failed to create WIP commit.`:`Failed to commit and push.`)}},t[9]=l,t[10]=o,t[11]=f,t[12]=e,t[13]=d,t[14]=h):h=t[14];let g=h,v;t[15]===g?v=t[16]:(v=e=>{e.preventDefault(),g()},t[15]=g,t[16]=v);let y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{r(e.currentTarget.value)},t[17]=y):y=t[17];let b;t[18]===n?b=t[19]:(b=(0,V.jsx)(Ee,{autoComplete:`off`,value:n,placeholder:`commit message`,onChange:y}),t[18]=n,t[19]=b);let x;t[20]===e.dirty?x=t[21]:(x=e.dirty?(0,V.jsx)(Le,{}):(0,V.jsx)(Re,{}),t[20]=e.dirty,t[21]=x);let S=e.dirty?`WIP`:`Commit`,C;t[22]!==f||t[23]!==S||t[24]!==x||t[25]!==p?(C=(0,V.jsx)(De,{align:`inline-end`,children:(0,V.jsxs)(xe,{type:`submit`,variant:`ghost`,size:`xs`,"aria-label":p,disabled:f,title:p,children:[x,S]})}),t[22]=f,t[23]=S,t[24]=x,t[25]=p,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==b?(w=(0,V.jsxs)(Te,{children:[b,C]}),t[27]=C,t[28]=b,t[29]=w):w=t[29];let T;return t[30]!==w||t[31]!==v?(T=(0,V.jsx)(`form`,{className:`grid gap-1 border-b p-2`,onSubmit:v,children:w}),t[30]=w,t[31]=v,t[32]=T):T=t[32],T}function vs(e){let t=(0,Zo.c)(13),n=e.selected.type===`head-to-worktree`?`page`:void 0,r=e.selectHead,i=e.selected.type===`head-to-worktree`&&`bg-primary/15 text-primary`,o;t[0]===i?o=t[1]:(o=p(`text-muted-foreground hover:bg-muted hover:text-foreground grid h-8 w-full min-w-0 grid-cols-[minmax(0,1fr)_52px] items-center gap-2 px-2 text-left text-xs`,i),t[0]=i,t[1]=o);let s,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:`HEAD`}),c=(0,V.jsx)(`span`,{className:`text-muted-foreground font-mono`,children:`worktree`}),t[2]=s,t[3]=c):(s=t[2],c=t[3]);let l;t[4]!==e.selectHead||t[5]!==n||t[6]!==o?(l=(0,V.jsx)(`li`,{className:`w-full min-w-0`,children:(0,V.jsxs)(`button`,{type:`button`,"aria-current":n,onClick:r,className:o,children:[s,c]})}),t[4]=e.selectHead,t[5]=n,t[6]=o,t[7]=l):l=t[7];let u;t[8]===e?u=t[9]:(u=a(e.commits,t=>{let n=e.selected.type===`commit-to-worktree`&&e.selected.commit===t.hash;return(0,V.jsx)(`li`,{className:`w-full min-w-0`,children:(0,V.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,onClick:()=>{e.selectCommit(t)},className:p(`text-muted-foreground hover:bg-muted hover:text-foreground grid h-8 w-full min-w-0 grid-cols-[minmax(0,1fr)_52px] items-center gap-2 px-2 text-left text-xs`,n&&`bg-primary/15 text-primary`),children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,V.jsx)(`span`,{className:p(t.wip&&`text-amber-600 dark:text-amber-400`),children:t.subject})}),(0,V.jsx)(`span`,{className:`text-muted-foreground font-mono`,children:t.shortHash})]})},t.hash)}),t[8]=e,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,V.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,V.jsx)(pe,{className:`min-h-0 flex-1 overflow-y-auto px-0 py-1`,children:(0,V.jsxs)(oe,{label:`History`,className:`min-h-0 flex-1 [&>ul]:min-h-0 [&>ul]:flex-1`,children:[l,u]})})}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function ys(e){let t={children:o(),name:``,path:``,type:`directory`};for(let n of e){let e=n.filePath.split(`/`),r=t;for(let t of g(e,1)){let e=r.path?`${r.path}/${t}`:t,n=m(r.children,D(e=>e.name===t),x);if(n?.type===`directory`)r=n;else{let n={children:o(),name:t,path:e,type:`directory`};r.children.push(n),r=n}}r.children.push({diff:n,name:e.at(-1)??n.filePath,path:n.filePath,type:`file`})}return m(t.children,a(e=>e.type===`directory`?bs(e):e))}function bs(e){let t=e.children[0];return h(e.children)===1&&t?.type===`directory`?bs({children:t.children,name:`${e.name}/${t.name}`,path:t.path,type:`directory`}):e}function xs(e){let t=(0,Zo.c)(19),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Set,t[0]=n):n=t[0];let[r,i]=(0,M.useState)(n),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=function(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[1]=o):o=t[1];let s=o,c,l,u,f,p,m;if(t[2]!==r||t[3]!==e){function n(t){if(t.type===`directory`){let e=r.has(t.path);return(0,V.jsxs)(`li`,{className:`w-full min-w-0`,children:[(0,V.jsx)(he,{icon:(0,V.jsx)(Ie,{className:`size-3.5 shrink-0`}),onClick:()=>{s(t.path)},actions:(0,V.jsx)(`span`,{className:`text-muted-foreground text-[10px]`,children:h(t.children)}),children:t.name}),!e&&(0,V.jsx)(`ul`,{className:`border-border/70 ml-[19px] flex flex-col border-l pl-2`,children:a(t.children,n)})]},t.path)}return(0,V.jsx)(`li`,{className:`w-full min-w-0`,children:(0,V.jsx)(he,{selected:e.selectedEntry?.filePath===t.diff.filePath,icon:(0,V.jsx)(_e,{filePath:t.diff.filePath,className:`size-3`}),actions:(0,V.jsx)(Ss,{status:t.diff.status}),onClick:()=>{e.selectReviewEntry(t.diff.filePath)},children:t.name})},t.path)}l=pe,m=`h-full overflow-y-auto px-0 py-1`,c=oe,u=`Changed files`,f=`min-h-0 flex-1 [&>ul]:min-h-0 [&>ul]:flex-1`,p=d(e.diffs)?(0,V.jsx)(`li`,{className:`text-muted-foreground flex flex-1 items-center justify-center px-2 py-2 text-xs`,children:`No changed files.`}):a(ys(e.diffs),n),t[2]=r,t[3]=e,t[4]=c,t[5]=l,t[6]=u,t[7]=f,t[8]=p,t[9]=m}else c=t[4],l=t[5],u=t[6],f=t[7],p=t[8],m=t[9];let g;t[10]!==c||t[11]!==u||t[12]!==f||t[13]!==p?(g=(0,V.jsx)(c,{label:u,className:f,children:p}),t[10]=c,t[11]=u,t[12]=f,t[13]=p,t[14]=g):g=t[14];let _;return t[15]!==l||t[16]!==m||t[17]!==g?(_=(0,V.jsx)(l,{className:m,children:g}),t[15]=l,t[16]=m,t[17]=g,t[18]=_):_=t[18],_}function Ss(e){return m(l(e.status),v(`added`,()=>(0,V.jsx)(`span`,{className:`text-[10px] font-semibold text-emerald-600 dark:text-emerald-400`,children:`A`})),v(`deleted`,()=>(0,V.jsx)(`span`,{className:`text-[10px] font-semibold text-red-600 dark:text-red-400`,children:`D`})),v(`renamed`,()=>(0,V.jsx)(`span`,{className:`text-[10px] font-semibold text-sky-600 dark:text-sky-400`,children:`R`})),y(()=>(0,V.jsx)(`span`,{className:`text-[10px] font-semibold text-amber-600 dark:text-amber-400`,children:`M`})))}export{hs as component};
113
+ `))),c(t=>l(t,t=>!new Set(s(e,e=>`${e.scope}:${e.filePath}:${e.side===`deletions`?`deletions`:`file`}:${e.lineNumber}`)).has(`${t.scope}:${t.filePath}:${t.side===`deletions`?`deletions`:`file`}:${t.lineNumber}`)))}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(ge,{open:d,onOpenChange:f,children:(0,V.jsxs)(fe,{children:[(0,V.jsx)(ue,{children:(0,V.jsx)(ie,{children:`Shortcuts`})}),(0,V.jsxs)(`div`,{className:`grid gap-2`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] gap-3`,children:[(0,V.jsx)(`kbd`,{className:`border px-1.5 py-0.5 text-center`,children:`?`}),(0,V.jsx)(`span`,{children:`Show shortcuts`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] gap-3`,children:[(0,V.jsx)(`kbd`,{className:`border px-1.5 py-0.5 text-center`,children:`Shift+C`}),(0,V.jsx)(`span`,{children:`Copy all queued comments`})]})]})]})}),(0,V.jsxs)(we,{orientation:`horizontal`,children:[(0,V.jsx)(Ce,{defaultSize:`34%`,minSize:`24%`,maxSize:`46%`,children:(0,V.jsxs)(`div`,{className:`flex h-full flex-col border-r`,children:[(0,V.jsx)(_s,{base:r,cwd:e.cwd,dirty:a.value.dirty,hasWipCommits:te,refreshReview:oe}),(0,V.jsx)(`div`,{className:`min-h-0 flex-[1.2] border-b`,children:(0,V.jsx)(xs,{diffs:S.value,selectedEntry:C,selectReviewEntry:b})}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,V.jsx)(vs,{commits:a.value.commits,selected:_,selectCommit:re,selectHead:()=>{ne({type:`head-to-worktree`})}})})]})}),(0,V.jsx)(Se,{}),(0,V.jsx)(Ce,{defaultSize:`66%`,minSize:`54%`,children:(0,V.jsxs)(`div`,{className:`bg-background flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[!C&&(0,V.jsx)(`div`,{className:`text-muted-foreground flex h-full items-center justify-center`,children:`No changed files.`}),C&&(0,V.jsx)(`div`,{className:`h-full min-h-0 min-w-0`,children:(0,V.jsx)(is,{filePath:C.filePath,patch:C.patch,comments:l(o,e=>e.scope===ds(_)&&e.filePath===C.filePath),onSaveComment:e=>{c(t=>i(t,l(t=>t.scope!==ds(_)||t.filePath!==e.filePath||t.lineNumber!==e.lineNumber||(t.side===`deletions`?`deletions`:`file`)!=(e.side===`deletions`?`deletions`:`file`)),k({...e,scope:ds(_)})))},onDeleteComment:e=>{c(t=>l(t,t=>t.scope!==ds(_)||t.filePath!==e.filePath||t.lineNumber!==e.lineNumber||(t.side===`deletions`?`deletions`:`file`)!=(e.side===`deletions`?`deletions`:`file`)))}})})]}),!m(o)&&(0,V.jsxs)(`footer`,{className:`grid min-h-8 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 border-t px-2`,children:[(0,V.jsx)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden`,children:s(ms(o),e=>(0,V.jsxs)(E,{type:`button`,variant:`outline`,size:`xs`,"aria-label":`Delete ${e.comments.length} queued comments for ${e.filePath}`,title:`Delete ${e.comments.length} comments for ${e.filePath}`,onClick:()=>{c(t=>l(t,t=>t.scope!==e.scope||t.filePath!==e.filePath))},children:[(0,V.jsx)(_e,{filePath:e.filePath}),(0,V.jsx)(`span`,{className:`max-w-32 truncate`,children:e.filePath.split(`/`).at(-1)??e.filePath})]},e.key))}),(0,V.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-1`,children:[(0,V.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Copy all queued comments`,title:`Copy all queued comments`,onClick:()=>void se(o),children:(0,V.jsx)(Fe,{})}),(0,V.jsx)(E,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`text-destructive hover:text-destructive`,"aria-label":`Delete all queued comments`,title:`Delete all queued comments`,onClick:()=>{c(v())},children:(0,V.jsx)(ae,{})})]})]})]})})]})]})}function _s(e){let t=(0,Zo.c)(33),[n,r]=(0,M.useState)(``),a,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=j.mutation(`review.createWipCommit`),o={mode:`promise`},t[0]=a,t[1]=o):(a=t[0],o=t[1]);let s=ke(a,o),c,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=j.mutation(`review.commitAndPush`),l={mode:`promise`},t[2]=c,t[3]=l):(c=t[2],l=t[3]);let u=ke(c,l),d,f;t[4]!==n||t[5]!==e.dirty||t[6]!==e.hasWipCommits?(f=i(n,te),d=S(f)||!e.dirty&&!e.hasWipCommits,t[4]=n,t[5]=e.dirty,t[6]=e.hasWipCommits,t[7]=d,t[8]=f):(d=t[7],f=t[8]);let p=d,m=e.dirty?`Create WIP commit`:`Squash WIP commits and push`,h;t[9]!==u||t[10]!==s||t[11]!==p||t[12]!==e||t[13]!==f?(h=async function(){if(!p)try{e.dirty?await s({payload:{cwd:e.cwd,message:f}}):await u({payload:{base:e.base,cwd:e.cwd,message:f}}),r(``),e.refreshReview()}catch{ye.error(e.dirty?`Failed to create WIP commit.`:`Failed to commit and push.`)}},t[9]=u,t[10]=s,t[11]=p,t[12]=e,t[13]=f,t[14]=h):h=t[14];let g=h,_;t[15]===g?_=t[16]:(_=e=>{e.preventDefault(),g()},t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{r(e.currentTarget.value)},t[17]=v):v=t[17];let y;t[18]===n?y=t[19]:(y=(0,V.jsx)(Ee,{autoComplete:`off`,value:n,placeholder:`commit message`,onChange:v}),t[18]=n,t[19]=y);let b;t[20]===e.dirty?b=t[21]:(b=e.dirty?(0,V.jsx)(Le,{}):(0,V.jsx)(Re,{}),t[20]=e.dirty,t[21]=b);let x=e.dirty?`WIP`:`Commit`,C;t[22]!==p||t[23]!==x||t[24]!==b||t[25]!==m?(C=(0,V.jsx)(De,{align:`inline-end`,children:(0,V.jsxs)(xe,{type:`submit`,variant:`ghost`,size:`xs`,"aria-label":m,disabled:p,title:m,children:[b,x]})}),t[22]=p,t[23]=x,t[24]=b,t[25]=m,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==y?(w=(0,V.jsxs)(Te,{children:[y,C]}),t[27]=C,t[28]=y,t[29]=w):w=t[29];let T;return t[30]!==w||t[31]!==_?(T=(0,V.jsx)(`form`,{className:`grid gap-1 border-b p-2`,onSubmit:_,children:w}),t[30]=w,t[31]=_,t[32]=T):T=t[32],T}function vs(e){let t=(0,Zo.c)(13),n=e.selected.type===`head-to-worktree`?`page`:void 0,r=e.selectHead,i=e.selected.type===`head-to-worktree`&&`bg-primary/15 text-primary`,a;t[0]===i?a=t[1]:(a=g(`text-muted-foreground hover:bg-muted hover:text-foreground grid h-6 w-full min-w-0 grid-cols-[minmax(0,1fr)_5rem] items-center gap-2 px-3 text-left`,i),t[0]=i,t[1]=a);let o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:`HEAD`}),c=(0,V.jsx)(`span`,{className:`text-muted-foreground min-w-0 truncate text-right`,children:`worktree`}),t[2]=o,t[3]=c):(o=t[2],c=t[3]);let l;t[4]!==e.selectHead||t[5]!==n||t[6]!==a?(l=(0,V.jsx)(`li`,{className:`w-full min-w-0`,children:(0,V.jsxs)(`button`,{type:`button`,"aria-current":n,onClick:r,className:a,children:[o,c]})}),t[4]=e.selectHead,t[5]=n,t[6]=a,t[7]=l):l=t[7];let u;t[8]===e?u=t[9]:(u=s(e.commits,t=>{let n=e.selected.type===`commit-to-worktree`&&e.selected.commit===t.hash;return(0,V.jsx)(`li`,{className:`w-full min-w-0`,children:(0,V.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,onClick:()=>{e.selectCommit(t)},className:g(`text-muted-foreground hover:bg-muted hover:text-foreground grid h-6 w-full min-w-0 grid-cols-[minmax(0,1fr)_5rem] items-center gap-2 px-3 text-left`,n&&`bg-primary/15 text-primary`),children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,V.jsx)(`span`,{className:g(t.wip&&`text-amber-600 dark:text-amber-400`),children:t.subject})}),(0,V.jsx)(`span`,{className:`text-muted-foreground min-w-0 truncate text-right`,children:t.shortHash})]})},t.hash)}),t[8]=e,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,V.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,V.jsx)(pe,{className:`min-h-0 flex-1 overflow-y-auto px-0 py-1`,children:(0,V.jsxs)(oe,{label:`History`,className:`min-h-0 flex-1 [&>ul]:min-h-0 [&>ul]:flex-1`,children:[l,u]})})}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function ys(e){let t={children:v(),name:``,path:``,type:`directory`};for(let n of e){let e=n.filePath.split(`/`),r=t;for(let t of O(e,1)){let e=r.path?`${r.path}/${t}`:t,n=i(r.children,h(e=>e.name===t),T);if(n?.type===`directory`)r=n;else{let n={children:v(),name:t,path:e,type:`directory`};r.children.push(n),r=n}}r.children.push({diff:n,name:e.at(-1)??n.filePath,path:n.filePath,type:`file`})}return i(t.children,s(e=>e.type===`directory`?bs(e):e))}function bs(e){let t=e.children[0];return _(e.children)===1&&t?.type===`directory`?bs({children:t.children,name:`${e.name}/${t.name}`,path:t.path,type:`directory`}):e}function xs(e){let t=(0,Zo.c)(19),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Set,t[0]=n):n=t[0];let[r,i]=(0,M.useState)(n),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=function(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[1]=a):a=t[1];let o=a,c,l,u,d,f,p;if(t[2]!==r||t[3]!==e){function n(t){if(t.type===`directory`){let e=r.has(t.path);return(0,V.jsxs)(`li`,{className:`w-full min-w-0`,children:[(0,V.jsx)(he,{icon:(0,V.jsx)(Ie,{}),onClick:()=>{o(t.path)},actions:(0,V.jsx)(`span`,{className:`text-muted-foreground`,children:_(t.children)}),children:t.name}),!e&&(0,V.jsx)(`ul`,{className:`border-border/70 ml-[19px] flex flex-col border-l pl-2`,children:s(t.children,n)})]},t.path)}return(0,V.jsx)(`li`,{className:`w-full min-w-0`,children:(0,V.jsx)(he,{selected:e.selectedEntry?.filePath===t.diff.filePath,icon:(0,V.jsx)(_e,{filePath:t.diff.filePath}),actions:(0,V.jsx)(Ss,{status:t.diff.status}),onClick:()=>{e.selectReviewEntry(t.diff.filePath)},children:t.name})},t.path)}l=pe,p=`h-full overflow-y-auto px-0 py-1`,c=oe,u=`Changed files`,d=`min-h-0 flex-1 [&>ul]:min-h-0 [&>ul]:flex-1`,f=m(e.diffs)?(0,V.jsx)(`li`,{className:`text-muted-foreground flex flex-1 items-center justify-center px-2 py-2`,children:`No changed files.`}):s(ys(e.diffs),n),t[2]=r,t[3]=e,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f,t[9]=p}else c=t[4],l=t[5],u=t[6],d=t[7],f=t[8],p=t[9];let h;t[10]!==c||t[11]!==u||t[12]!==d||t[13]!==f?(h=(0,V.jsx)(c,{label:u,className:d,children:f}),t[10]=c,t[11]=u,t[12]=d,t[13]=f,t[14]=h):h=t[14];let g;return t[15]!==l||t[16]!==p||t[17]!==h?(g=(0,V.jsx)(l,{className:p,children:h}),t[15]=l,t[16]=p,t[17]=h,t[18]=g):g=t[18],g}function Ss(e){return i(f(e.status),y(`added`,()=>(0,V.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:`A`})),y(`deleted`,()=>(0,V.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:`D`})),y(`renamed`,()=>(0,V.jsx)(`span`,{className:`text-sky-600 dark:text-sky-400`,children:`R`})),b(()=>(0,V.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:`M`})))}export{hs as component};